From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kara Subject: Re: [PATCH] fs: add sync_inode_metadata Date: Wed, 20 Oct 2010 12:02:43 +0200 Message-ID: <20101020100243.GA3335@quack.suse.cz> References: <20101006084820.GD8093@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org To: Christoph Hellwig Return-path: Received: from cantor.suse.de ([195.135.220.2]:53927 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752783Ab0JTKDo (ORCPT ); Wed, 20 Oct 2010 06:03:44 -0400 Content-Disposition: inline In-Reply-To: <20101006084820.GD8093@lst.de> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed 06-10-10 10:48:20, Christoph Hellwig wrote: > Add a new helper to write out the inode using the writeback code, > that is including the correct dirty bit and list manipulation. A few > of filesystems already opencode this, and a lot of others should be > using it instead of using write_inode_now which also writes out the > data. I'm reacting late but anyways: > Index: linux-2.6/fs/fs-writeback.c > =================================================================== > --- linux-2.6.orig/fs/fs-writeback.c 2010-10-05 10:51:24.611023726 +0200 > +++ linux-2.6/fs/fs-writeback.c 2010-10-05 10:53:24.684255876 +0200 > @@ -1209,3 +1209,23 @@ int sync_inode(struct inode *inode, stru > return ret; > } > EXPORT_SYMBOL(sync_inode); > + > +/** > + * sync_inode - write an inode to disk > + * @inode: the inode to sync > + * @wait: wait for I/O to complete. > + * > + * Write an inode to disk and adjust it's dirty state after completion. > + * > + * Note: only writes the actual inode, no associated data or other metadata. > + */ > +int sync_inode_metadata(struct inode *inode, int wait) > +{ > + struct writeback_control wbc = { > + .sync_mode = wait ? WB_SYNC_ALL : WB_SYNC_NONE, > + .nr_to_write = 0, /* metadata-only */ This is a catch in write_cache_pages() code. If you call it in WB_SYNC_ALL mode, they will just ignore the .nr_to_write argument. So what actually ensures that we do not write data is that .range_start and .range_end are implicitely set to 0. In fact, write_cache_pages() will write page with index 0 in that case. So setting .range_start to 1 would be even better. Otherwise the patch looks OK. Honza -- Jan Kara SUSE Labs, CR