From: Jan Kara Subject: Re: [PATCH 4/6] vfs: Reorder operations during sys_sync Date: Fri, 21 Oct 2011 01:57:04 +0200 Message-ID: <20111020235704.GJ20542@quack.suse.cz> References: <1318020055-4450-1-git-send-email-jack@suse.cz> <1318020055-4450-5-git-send-email-jack@suse.cz> <20111020095344.GD11291@infradead.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Jan Kara , Curt Wohlgemuth , linux-fsdevel@vger.kernel.org, Al Viro To: Christoph Hellwig Return-path: Received: from cantor2.suse.de ([195.135.220.15]:48432 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752017Ab1JTX5H (ORCPT ); Thu, 20 Oct 2011 19:57:07 -0400 Content-Disposition: inline In-Reply-To: <20111020095344.GD11291@infradead.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu 20-10-11 05:53:44, Christoph Hellwig wrote: > > diff --git a/fs/sync.c b/fs/sync.c > > index 3367d04..5fbeee6 100644 > > --- a/fs/sync.c > > +++ b/fs/sync.c > > @@ -68,18 +68,26 @@ int sync_filesystem(struct super_block *sb) > > } > > EXPORT_SYMBOL_GPL(sync_filesystem); > > > > -static void sync_one_sb(struct super_block *sb, void *arg) > > +static void sync_inodes_one_sb(struct super_block *sb, void *arg) > > { > > - if (!(sb->s_flags & MS_RDONLY)) > > - __sync_filesystem(sb, *(int *)arg); > > + if (!(sb->s_flags & MS_RDONLY)) { > > + if (!*(int *)arg) > > + writeback_inodes_sb(sb); > > + else > > + sync_inodes_sb(sb); > > + } > > This would be a lot cleaner if you split it into two functions for > the writeback_inodes_sb and sync_inodes_sb cases. OK, split to writeback_inodes_one_sb() and sync_inodes_one_sb(). > > -/* > > - * Sync all the data for all the filesystems (called by sys_sync() and > > - * emergency sync) > > - */ > > -static void sync_filesystems(int wait) > > + > > +static void sync_fs_one_sb(struct super_block *sb, void *arg) > > { > > - iterate_supers(sync_one_sb, &wait); > > + if (!(sb->s_flags & MS_RDONLY) && sb->s_op->sync_fs) > > + sb->s_op->sync_fs(sb, *(int *)arg); > > +} > > + > > +static void sync_blkdev_one_sb(struct super_block *sb, void *arg) > > +{ > > + if (!(sb->s_flags & MS_RDONLY)) > > + __sync_blockdev(sb->s_bdev, *(int *)arg); > > } > > Same here, not having these odd wait/nowait arguments whos address > is taken in the caller would make the thing a lot more readable. > > It would also allow to kill of that nasty __sync_blockdev interface > eventually. So you prefer I directly call: filemap_flush(bdev->bd_inode->i_mapping) and filemap_write_and_wait(bdev->bd_inode->i_mapping) respectively? Honza -- Jan Kara SUSE Labs, CR