From: Nick Piggin Subject: Re: [PATCH, RFC] add a vfs_fsync helper Date: Mon, 22 Dec 2008 13:35:34 +0100 Message-ID: <20081222123534.GE13406@wotan.suse.de> References: <20081222090357.GA27399@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: viro@zeniv.linux.org.uk, dbrownell@users.sourceforge.net, agl@us.ibm.com, ebiederm@xmission.com, linux-fsdevel@vger.kernel.org, ecryptfs-devel@lists.launchpad.net, jaharkes@cs.cmu.edu To: Christoph Hellwig Return-path: Received: from ns1.suse.de ([195.135.220.2]:60833 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751453AbYLVMfh (ORCPT ); Mon, 22 Dec 2008 07:35:37 -0500 Content-Disposition: inline In-Reply-To: <20081222090357.GA27399@lst.de> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Mon, Dec 22, 2008 at 10:03:57AM +0100, Christoph Hellwig wrote: > Fsync currently has a fdatawrite/fdatawait pair around the method call, > and a mutex_lock/unlock of the inode mutex. All callers of fsync have > to duplicate this, but we have a few and most of them don't quite get > it right. This patch adds a new vfs_fsync that takes care of this. > It's a little more complicated as usual as ->fsync might get a NULL file > pointer and just a dentry from nfsd, but otherwise gets afile and we > want to take the mapping and file operations from it when it is there. > > Notes on the fsync callers: > > - ecryptfs wasn't calling filemap_fdatawrite / filemap_fdatawait on the > lower file > - coda wasn't calling filemap_fdatawrite / filemap_fdatawait on the host > file, and returning 0 when ->fsync was missing > - shm wasn't calling either filemap_fdatawrite / filemap_fdatawait nor > taking i_mutex. Now given that shared memory doesn't have disk > backing not doing anything in fsync seems fine and I left it out of > the vfs_fsync conversion for now, but in that case we might just > not pass it through to the lower file at all but just call the no-op > simple_sync_file directly. Seems like an improvement.. I've wanted to know, though, what do we need i_mutex for? Is it just convention, or is there some good reason to have it in generic code?