diff options
author | Jiro SEKIBA <jir@unicus.jp> | 2009-11-27 13:41:10 +0300 |
---|---|---|
committer | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2009-11-27 14:05:15 +0300 |
commit | 4cd76c3c930993cf70657775bb521cad006e37b4 (patch) | |
tree | f29b80420e2214d08785580f11e400728750d10a /fs/nilfs2/namei.c | |
parent | 17491472769abbf4dac694d96c65eed5a7e1c81c (diff) | |
download | linux-4cd76c3c930993cf70657775bb521cad006e37b4.tar.xz |
nilfs2: split nilfs_unlink as nilfs_do_unlink and nilfs_unlink
Split nilfs_unlink() to reduce nested transaction and duplicate
mark_inode_dirty() calls when calling nilfs_unlink() from nilfs_rmdir().
nilfs_do_unlink() is an actual unlink functionality which is not
in transaction and does not call mark_inode_dirty() for dentry argument.
nilfs_unlink() is a wrapper function for do_nilfs_unlink() with
transaction and mark_inode_dirty() for dentry argument.
Signed-off-by: Jiro SEKIBA <jir@unicus.jp>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2/namei.c')
-rw-r--r-- | fs/nilfs2/namei.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c index 35f59da16bbf..d92e83905f01 100644 --- a/fs/nilfs2/namei.c +++ b/fs/nilfs2/namei.c @@ -288,18 +288,13 @@ out_dir: goto out; } -static int nilfs_unlink(struct inode *dir, struct dentry *dentry) +static int nilfs_do_unlink(struct inode *dir, struct dentry *dentry) { struct inode *inode; struct nilfs_dir_entry *de; struct page *page; - struct nilfs_transaction_info ti; int err; - err = nilfs_transaction_begin(dir->i_sb, &ti, 0); - if (err) - return err; - err = -ENOENT; de = nilfs_find_entry(dir, dentry, &page); if (!de) @@ -322,12 +317,26 @@ static int nilfs_unlink(struct inode *dir, struct dentry *dentry) inode->i_ctime = dir->i_ctime; drop_nlink(inode); - mark_inode_dirty(inode); err = 0; out: - if (!err) + return err; +} + +static int nilfs_unlink(struct inode *dir, struct dentry *dentry) +{ + struct nilfs_transaction_info ti; + int err; + + err = nilfs_transaction_begin(dir->i_sb, &ti, 0); + if (err) + return err; + + err = nilfs_do_unlink(dir, dentry); + + if (!err) { + mark_inode_dirty(dentry->d_inode); err = nilfs_transaction_commit(dir->i_sb); - else + } else nilfs_transaction_abort(dir->i_sb); return err; @@ -345,7 +354,7 @@ static int nilfs_rmdir(struct inode *dir, struct dentry *dentry) err = -ENOTEMPTY; if (nilfs_empty_dir(inode)) { - err = nilfs_unlink(dir, dentry); + err = nilfs_do_unlink(dir, dentry); if (!err) { inode->i_size = 0; drop_nlink(inode); |