hfsplus: simplify fsync

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 <hch@tuxera.com>
This commit is contained in:
Christoph Hellwig 2010-11-23 14:38:06 +01:00 committed by Christoph Hellwig
parent f02e26f8d9
commit 281469766b
1 changed files with 19 additions and 20 deletions

View File

@ -302,29 +302,28 @@ static int hfsplus_setattr(struct dentry *dentry, struct iattr *attr)
return 0; 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 inode *inode = file->f_mapping->host;
struct super_block * sb; struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
int ret, err; 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; * And explicitly write out the btrees.
if (sb->s_dirt) { */
if (!(sb->s_flags & MS_RDONLY)) error = filemap_write_and_wait(sbi->cat_tree->inode->i_mapping);
hfsplus_sync_fs(sb, 1); error2 = filemap_write_and_wait(sbi->ext_tree->inode->i_mapping);
else if (!error)
sb->s_dirt = 0; error = error2;
} error2 = filemap_write_and_wait(sbi->alloc_file->i_mapping);
if (!error)
/* .. finally sync the buffers to disk */ error = error2;
err = sync_blockdev(sb->s_bdev); return error;
if (!ret)
ret = err;
return ret;
} }
static const struct inode_operations hfsplus_file_inode_operations = { static const struct inode_operations hfsplus_file_inode_operations = {