Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 165901
b: refs/heads/master
c: f85d7d6
h: refs/heads/master
i:
  165899: b99cf3f
v: v3
  • Loading branch information
Chris Mason committed Sep 18, 2009
1 parent ebdcd44 commit ca6b7e5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 11833d66be94b514652466802100378046c16b72
refs/heads/master: f85d7d6c8f2ad4a86a1f4f4e3791f36dede2fa76
38 changes: 27 additions & 11 deletions trunk/fs/btrfs/extent_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2182,7 +2182,7 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
delalloc_end = 0;
page_started = 0;
if (!epd->extent_locked) {
u64 delalloc_to_write;
u64 delalloc_to_write = 0;
/*
* make sure the wbc mapping index is at least updated
* to this page.
Expand All @@ -2202,16 +2202,24 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
tree->ops->fill_delalloc(inode, page, delalloc_start,
delalloc_end, &page_started,
&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_end is already one less than the total
* length, so we don't subtract one from
* PAGE_CACHE_SIZE
*/
delalloc_to_write += (delalloc_end - delalloc_start +
PAGE_CACHE_SIZE) >>
PAGE_CACHE_SHIFT;
delalloc_start = delalloc_end + 1;
}
if (wbc->nr_to_write < delalloc_to_write) {
int thresh = 8192;

if (delalloc_to_write < thresh * 2)
thresh = delalloc_to_write;
wbc->nr_to_write = min_t(u64, delalloc_to_write,
thresh);
}

/* did the fill delalloc function already unlock and start
* the IO?
Expand Down Expand Up @@ -2388,6 +2396,7 @@ static int extent_write_cache_pages(struct extent_io_tree *tree,
{
int ret = 0;
int done = 0;
int nr_to_write_done = 0;
struct pagevec pvec;
int nr_pages;
pgoff_t index;
Expand All @@ -2407,7 +2416,7 @@ static int extent_write_cache_pages(struct extent_io_tree *tree,
scanned = 1;
}
retry:
while (!done && (index <= end) &&
while (!done && !nr_to_write_done && (index <= end) &&
(nr_pages = pagevec_lookup_tag(&pvec, mapping, &index,
PAGECACHE_TAG_DIRTY, min(end - index,
(pgoff_t)PAGEVEC_SIZE-1) + 1))) {
Expand Down Expand Up @@ -2458,8 +2467,15 @@ static int extent_write_cache_pages(struct extent_io_tree *tree,
unlock_page(page);
ret = 0;
}
if (ret || wbc->nr_to_write <= 0)
if (ret)
done = 1;

/*
* the filesystem may choose to bump up nr_to_write.
* We have to make sure to honor the new nr_to_write
* at any time
*/
nr_to_write_done = wbc->nr_to_write <= 0;
}
pagevec_release(&pvec);
cond_resched();
Expand Down

0 comments on commit ca6b7e5

Please sign in to comment.