Commit a97adc9f authored by Chris Mason's avatar Chris Mason
Browse files

Btrfs: use larger nr_to_write for larger extents



When btrfs fills a large delayed allocation extent, it is a good idea
to try and convince the write_cache_pages caller to go ahead and
write a good chunk of that extent.  The extra IO is basically free
because we know it is contiguous.
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 4f878e84
...@@ -2135,6 +2135,7 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc, ...@@ -2135,6 +2135,7 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
delalloc_end = 0; delalloc_end = 0;
page_started = 0; page_started = 0;
if (!epd->extent_locked) { if (!epd->extent_locked) {
u64 delalloc_to_write;
/* /*
* make sure the wbc mapping index is at least updated * make sure the wbc mapping index is at least updated
* to this page. * to this page.
...@@ -2154,6 +2155,14 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc, ...@@ -2154,6 +2155,14 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
tree->ops->fill_delalloc(inode, page, delalloc_start, tree->ops->fill_delalloc(inode, page, delalloc_start,
delalloc_end, &page_started, delalloc_end, &page_started,
&nr_written); &nr_written);
delalloc_to_write = (delalloc_end -
max_t(u64, page_offset(page),
delalloc_start) + 1) >>
PAGE_CACHE_SHIFT;
if (wbc->nr_to_write < delalloc_to_write) {
wbc->nr_to_write = min_t(long, 8192,
delalloc_to_write);
}
delalloc_start = delalloc_end + 1; delalloc_start = delalloc_end + 1;
} }
...@@ -2350,7 +2359,6 @@ static int extent_write_cache_pages(struct extent_io_tree *tree, ...@@ -2350,7 +2359,6 @@ static int extent_write_cache_pages(struct extent_io_tree *tree,
writepage_t writepage, void *data, writepage_t writepage, void *data,
void (*flush_fn)(void *)) void (*flush_fn)(void *))
{ {
struct backing_dev_info *bdi = mapping->backing_dev_info;
int ret = 0; int ret = 0;
int done = 0; int done = 0;
struct pagevec pvec; struct pagevec pvec;
...@@ -2425,10 +2433,6 @@ retry: ...@@ -2425,10 +2433,6 @@ retry:
} }
if (ret || wbc->nr_to_write <= 0) if (ret || wbc->nr_to_write <= 0)
done = 1; done = 1;
if (wbc->nonblocking && bdi_write_congested(bdi)) {
wbc->encountered_congestion = 1;
done = 1;
}
} }
pagevec_release(&pvec); pagevec_release(&pvec);
cond_resched(); cond_resched();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment