Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753006AbcCVWEi (ORCPT ); Tue, 22 Mar 2016 18:04:38 -0400 Received: from ipmail04.adl6.internode.on.net ([150.101.137.141]:37556 "EHLO ipmail04.adl6.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752946AbcCVWEf (ORCPT ); Tue, 22 Mar 2016 18:04:35 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2DSCAB2wPFWNTGaLHlegzSBTYJtg3mfYQEBAQEBAQaMCYNIghaEDYYHBAICgU5NAQEBAQEBBwEBAQFAAUCEQgEBBCcTHCMQCAMYCSUPBSUDBxoTiCbBFAEBAQcCHhmFPYUMihIFl1iNeo8TRI5DgxKBSSguigYBAQE Date: Wed, 23 Mar 2016 09:04:31 +1100 From: Dave Chinner To: Jens Axboe Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org Subject: Re: [PATCH 2/6] writeback: wb_start_writeback() should use WB_SYNC_ALL for WB_REASON_SYNC Message-ID: <20160322220431.GT11812@dastard> References: <1458669320-6819-1-git-send-email-axboe@fb.com> <1458669320-6819-3-git-send-email-axboe@fb.com> <20160322213427.GR11812@dastard> <56F1BBCC.8050004@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56F1BBCC.8050004@fb.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2276 Lines: 56 On Tue, Mar 22, 2016 at 03:40:28PM -0600, Jens Axboe wrote: > On 03/22/2016 03:34 PM, Dave Chinner wrote: > >On Tue, Mar 22, 2016 at 11:55:16AM -0600, Jens Axboe wrote: > >>If you call sync, the initial call to wakeup_flusher_threads() ends up > >>calling wb_start_writeback() with reason=WB_REASON_SYNC, but > >>wb_start_writeback() always uses WB_SYNC_NONE as the writeback mode. > >>Ensure that we use WB_SYNC_ALL for a sync operation. > > > >This seems wrong to me. We want background write to happen as > >quickly as possible and /not block/ when we first kick sync. > > It's not going to block. wakeup_flusher_threads() async queues > writeback work through wb_start_writeback(). The flusher threads block, not the initial wakeup. e.g. they will now block waiting for data writeback to complete before writing the inode. i.e. this code in __writeback_single_inode() is now triggered by the background flusher: /* * Make sure to wait on the data before writing out the metadata. * This is important for filesystems that modify metadata on data * I/O completion. We don't do it for sync(2) writeback because it has a * separate, external IO completion path and ->sync_fs for guaranteeing * inode metadata is written back correctly. */ if (wbc->sync_mode == WB_SYNC_ALL && !wbc->for_sync) { int err = filemap_fdatawait(mapping); if (ret == 0) ret = err; } It also changes the writeback chunk size in write_cache_pages(), so instead of doing a bit of writeback from all dirty inodes, it tries to write everything from each inode in turn (see writeback_chunk_size()) which will further exacerbate the wait above. > >The latter blocking passes of sync use WB_SYNC_ALL to ensure that we > >block waiting for all remaining IO to be issued and waited on, but > >the background writeback doesn't need to do this. > > That's fine, they can get to wait on the previously issued IO, which > was properly submitted with WB_SYNC_ALL. > > Maybe I'm missing your point? Making the background flusher block and wait for data makes it completely ineffective in speeding up sync() processing... Cheers, Dave. -- Dave Chinner david@fromorbit.com