提交 4cd76c3c 编写于 作者: J Jiro SEKIBA 提交者: Ryusuke Konishi

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: NJiro SEKIBA <jir@unicus.jp>
Signed-off-by: NRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
上级 17491472
...@@ -288,18 +288,13 @@ static int nilfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -288,18 +288,13 @@ static int nilfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
goto out; 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 inode *inode;
struct nilfs_dir_entry *de; struct nilfs_dir_entry *de;
struct page *page; struct page *page;
struct nilfs_transaction_info ti;
int err; int err;
err = nilfs_transaction_begin(dir->i_sb, &ti, 0);
if (err)
return err;
err = -ENOENT; err = -ENOENT;
de = nilfs_find_entry(dir, dentry, &page); de = nilfs_find_entry(dir, dentry, &page);
if (!de) if (!de)
...@@ -322,12 +317,26 @@ static int nilfs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -322,12 +317,26 @@ static int nilfs_unlink(struct inode *dir, struct dentry *dentry)
inode->i_ctime = dir->i_ctime; inode->i_ctime = dir->i_ctime;
drop_nlink(inode); drop_nlink(inode);
mark_inode_dirty(inode);
err = 0; err = 0;
out: 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); err = nilfs_transaction_commit(dir->i_sb);
else } else
nilfs_transaction_abort(dir->i_sb); nilfs_transaction_abort(dir->i_sb);
return err; return err;
...@@ -345,7 +354,7 @@ static int nilfs_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -345,7 +354,7 @@ static int nilfs_rmdir(struct inode *dir, struct dentry *dentry)
err = -ENOTEMPTY; err = -ENOTEMPTY;
if (nilfs_empty_dir(inode)) { if (nilfs_empty_dir(inode)) {
err = nilfs_unlink(dir, dentry); err = nilfs_do_unlink(dir, dentry);
if (!err) { if (!err) {
inode->i_size = 0; inode->i_size = 0;
drop_nlink(inode); drop_nlink(inode);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册