From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: Re: [PATCH 3/6] writeback: make nr_to_write a per-file limit Date: Wed, 4 May 2011 12:18:16 -0400 Message-ID: <20110504161816.GA8147@infradead.org> References: <20110504091707.910929441@intel.com> <20110504091909.520602641@intel.com> <20110504094221.GA20958@infradead.org> <20110504115251.GC5853@localhost> <20110504155100.GA29029@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Andrew Morton , Jan Kara , Dave Chinner , LKML , "linux-fsdevel@vger.kernel.org" To: Wu Fengguang Return-path: Content-Disposition: inline In-Reply-To: <20110504155100.GA29029@localhost> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org > - move MAX_WRITEBACK_PAGES and wb_writeback_work definitions to writeback.h I think it would be a good idea to keep this in fs/fs-writeback.c, which means we'd need a small writeback_inodes_wb wrapper for balance_dirty_pages and bdi_flush_io. But IIRC your tree already has __writeback_inodes_wb for use in wb_writeback, so writeback_inodes_wb could be that wrapper. > + long write_chunk = MAX_WRITEBACK_PAGES; > + long wrote = 0; > + bool inode_cleaned = false; > + > + /* > + * WB_SYNC_ALL mode does livelock avoidance by syncing dirty > + * inodes/pages in one big loop. Setting wbc.nr_to_write=LONG_MAX > + * here avoids calling into writeback_inodes_wb() more than once. > + * > + * The intended call sequence for WB_SYNC_ALL writeback is: > + * > + * wb_writeback() > + * writeback_sb_inodes() <== called only once > + * write_cache_pages() <== called once for each inode > + * (quickly) tag currently dirty pages > + * (maybe slowly) sync all tagged pages > + */ > + if (work->sync_mode == WB_SYNC_ALL || work->tagged_sync) > + write_chunk = LONG_MAX; I think this would be easier to read if kept as and if / else clause with the MAX_WRITEBACK_PAGES usage. > + write_chunk = min(write_chunk, work->nr_pages); Or in fact done here - for the WB_SYNC_ALL case LONG_MAX should always be larger than work->nr_pages, so the whole thing could be simplified to: if (work->sync_mode == WB_SYNC_ALL || work->tagged_sync) write_chunk = LONG_MAX; else write_chunk = min(MAX_WRITEBACK_PAGES, work->nr_pages); Other notes: - older_than_this in writeback_control shouldn't be needed anymore - is the early return for the mis-matching sb in writeback_sb_inodes handled correctly? Before it had the special 0 return value, and I'm not quite sure how that fits into your new enum scheme.