From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: [PATCH 7/11] hfsplus: simplify fsync Date: Wed, 17 Nov 2010 23:22:44 +0100 Message-ID: <20101117222244.GH21700@lst.de> References: <20101117222117.GA21700@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: linux-fsdevel@vger.kernel.org Return-path: Received: from verein.lst.de ([213.95.11.210]:38594 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935047Ab0KQWWp (ORCPT ); Wed, 17 Nov 2010 17:22:45 -0500 Received: from verein.lst.de (localhost [127.0.0.1]) by verein.lst.de (8.12.3/8.12.3/Debian-7.1) with ESMTP id oAHMMi88021804 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Wed, 17 Nov 2010 23:22:44 +0100 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-7.2) id oAHMMieg021803 for linux-fsdevel@vger.kernel.org; Wed, 17 Nov 2010 23:22:44 +0100 Content-Disposition: inline In-Reply-To: <20101117222117.GA21700@lst.de> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Remove lots of code we don't need from fsync, we just need to call ->write_inode on the inode if it's dirty, for which sync_inode_metadata is a lot more efficient than write_inode_now, and we need to write out the various metadata inodes, which we now do explicitly instead of by calling ->sync_fs. Signed-off-by: Christoph Hellwig Index: linux-2.6/fs/hfsplus/inode.c =================================================================== --- linux-2.6.orig/fs/hfsplus/inode.c 2010-11-17 22:43:05.733007195 +0100 +++ linux-2.6/fs/hfsplus/inode.c 2010-11-17 22:51:49.999003913 +0100 @@ -302,29 +302,28 @@ static int hfsplus_setattr(struct dentry return 0; } -static int hfsplus_file_fsync(struct file *filp, int datasync) +static int hfsplus_file_fsync(struct file *file, int datasync) { - struct inode *inode = filp->f_mapping->host; - struct super_block * sb; - int ret, err; + struct inode *inode = file->f_mapping->host; + struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb); + int error, error2; - /* sync the inode to buffers */ - ret = write_inode_now(inode, 0); + /* + * Sync inode metadata into the catalog and extent trees. + */ + sync_inode_metadata(inode, 1); - /* sync the superblock to buffers */ - sb = inode->i_sb; - if (sb->s_dirt) { - if (!(sb->s_flags & MS_RDONLY)) - hfsplus_sync_fs(sb, 1); - else - sb->s_dirt = 0; - } - - /* .. finally sync the buffers to disk */ - err = sync_blockdev(sb->s_bdev); - if (!ret) - ret = err; - return ret; + /* + * And explicitly write out the btrees. + */ + error = filemap_write_and_wait(sbi->cat_tree->inode->i_mapping); + error2 = filemap_write_and_wait(sbi->ext_tree->inode->i_mapping); + if (!error) + error = error2; + error2 = filemap_write_and_wait(sbi->alloc_file->i_mapping); + if (!error) + error = error2; + return error; } static const struct inode_operations hfsplus_file_inode_operations = {