From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wu Fengguang Subject: [PATCH 11/45] writeback: quit on wrap for .range_cyclic (cifs) Date: Wed, 07 Oct 2009 15:38:29 +0800 Message-ID: <20091007074902.518009147@intel.com> References: <20091007073818.318088777@intel.com> Cc: Theodore Tso , Christoph Hellwig , Dave Chinner , Chris Mason , Peter Zijlstra , "Li Shaohua" , "Myklebust Trond" , "jens.axboe@oracle.com" , Jan Kara , Nick Piggin , , Steve French , Wu Fengguang To: Andrew Morton Return-path: Cc: LKML Content-Disposition: inline; filename=linux_fs_cifs_file.c Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Convert wbc.range_cyclic to new behavior: when past EOF, abort writeback of the inode, which instructs writeback_single_inode() to delay it for a while if necessary. It removes one inefficient .range_cyclic IO pattern when writeback_index wraps: submit [10000-10100], (wrap), submit [0-100] In which the submitted pages may be consisted of two distant ranges. It also prevents submitting pointless IO for busy overwriters. CC: Steve French Signed-off-by: Wu Fengguang --- fs/cifs/file.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) --- linux.orig/fs/cifs/file.c 2009-10-06 23:37:49.000000000 +0800 +++ linux/fs/cifs/file.c 2009-10-06 23:38:33.000000000 +0800 @@ -1337,7 +1337,6 @@ static int cifs_partialpagewrite(struct static int cifs_writepages(struct address_space *mapping, struct writeback_control *wbc) { - struct backing_dev_info *bdi = mapping->backing_dev_info; unsigned int bytes_to_write; unsigned int bytes_written; struct cifs_sb_info *cifs_sb; @@ -1349,14 +1348,13 @@ static int cifs_writepages(struct addres int len; int n_iov = 0; pgoff_t next; - int nr_pages; + int nr_pages = 1; __u64 offset = 0; struct cifsFileInfo *open_file; struct cifsInodeInfo *cifsi = CIFS_I(mapping->host); struct page *page; struct pagevec pvec; int rc = 0; - int scanned = 0; int xid, long_op; cifs_sb = CIFS_SB(mapping->host->i_sb); @@ -1390,9 +1388,8 @@ static int cifs_writepages(struct addres end = wbc->range_end >> PAGE_CACHE_SHIFT; if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) range_whole = 1; - scanned = 1; } -retry: + while (!done && (index <= end) && (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, PAGECACHE_TAG_DIRTY, @@ -1425,7 +1422,7 @@ retry: break; } - if (!wbc->range_cyclic && page->index > end) { + if (page->index > end) { done = 1; unlock_page(page); break; @@ -1537,15 +1534,8 @@ retry: pagevec_release(&pvec); } - if (!scanned && !done) { - /* - * We hit the last page and there is more work to be done: wrap - * back to the start of the file - */ - scanned = 1; + if (!nr_pages) index = 0; - goto retry; - } if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) mapping->writeback_index = index;