X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Fmpage.c;h=4bbf15ee91fe01bcaa529f7e74dbd0e1bb702a36;hb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;hp=71c7ca3a455de3687f1147152cf0f76b87f3a1f9;hpb=a2c21200f1c81b08cb55e417b68150bba439b646;p=linux-2.6.git diff --git a/fs/mpage.c b/fs/mpage.c index 71c7ca3a4..4bbf15ee9 100644 --- a/fs/mpage.c +++ b/fs/mpage.c @@ -290,7 +290,8 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages, alloc_new: if (bio == NULL) { bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9), - nr_pages, GFP_KERNEL); + min_t(int, nr_pages, bio_get_nr_vecs(bdev)), + GFP_KERNEL); if (bio == NULL) goto confused; } @@ -627,7 +628,9 @@ mpage_writepages(struct address_space *mapping, struct pagevec pvec; int nr_pages; pgoff_t index; + pgoff_t end = -1; /* Inclusive */ int scanned = 0; + int is_range = 0; if (wbc->nonblocking && bdi_write_congested(bdi)) { wbc->encountered_congestion = 1; @@ -645,9 +648,17 @@ mpage_writepages(struct address_space *mapping, index = 0; /* whole-file sweep */ scanned = 1; } + if (wbc->start || wbc->end) { + index = wbc->start >> PAGE_CACHE_SHIFT; + end = wbc->end >> PAGE_CACHE_SHIFT; + is_range = 1; + scanned = 1; + } retry: - while (!done && (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, - PAGECACHE_TAG_DIRTY, PAGEVEC_SIZE))) { + while (!done && (index <= end) && + (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, + PAGECACHE_TAG_DIRTY, + min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1))) { unsigned i; scanned = 1; @@ -664,10 +675,21 @@ retry: lock_page(page); + if (unlikely(page->mapping != mapping)) { + unlock_page(page); + continue; + } + + if (unlikely(is_range) && page->index > end) { + done = 1; + unlock_page(page); + continue; + } + if (wbc->sync_mode != WB_SYNC_NONE) wait_on_page_writeback(page); - if (page->mapping != mapping || PageWriteback(page) || + if (PageWriteback(page) || !clear_page_dirty_for_io(page)) { unlock_page(page); continue; @@ -706,7 +728,8 @@ retry: index = 0; goto retry; } - mapping->writeback_index = index; + if (!is_range) + mapping->writeback_index = index; if (bio) mpage_bio_submit(WRITE, bio); return ret;