Commit 1256010a authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: reduce region of f2fs_lock_op covered for better concurrency

In our rename process, region of f2fs_lock_op covered is too big as some of the
code like f2fs_empty_dir/f2fs_find_entry are not needed to protect by this lock.

So in the extreme case like doing checkpoint when we rename old inode to exist
inode in a large directory could cause lower concurrency.

Let's reduce the region of f2fs_lock_op to fix this.
Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent b434babf
...@@ -387,8 +387,6 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -387,8 +387,6 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
goto out_old; goto out_old;
} }
f2fs_lock_op(sbi);
if (new_inode) { if (new_inode) {
err = -ENOTEMPTY; err = -ENOTEMPTY;
...@@ -401,6 +399,8 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -401,6 +399,8 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
if (!new_entry) if (!new_entry)
goto out_dir; goto out_dir;
f2fs_lock_op(sbi);
err = acquire_orphan_inode(sbi); err = acquire_orphan_inode(sbi);
if (err) if (err)
goto put_out_dir; goto put_out_dir;
...@@ -429,9 +429,13 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -429,9 +429,13 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
update_inode_page(old_inode); update_inode_page(old_inode);
update_inode_page(new_inode); update_inode_page(new_inode);
} else { } else {
f2fs_lock_op(sbi);
err = f2fs_add_link(new_dentry, old_inode); err = f2fs_add_link(new_dentry, old_inode);
if (err) if (err) {
f2fs_unlock_op(sbi);
goto out_dir; goto out_dir;
}
if (old_dir_entry) { if (old_dir_entry) {
inc_nlink(new_dir); inc_nlink(new_dir);
...@@ -466,6 +470,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -466,6 +470,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
return 0; return 0;
put_out_dir: put_out_dir:
f2fs_unlock_op(sbi);
kunmap(new_page); kunmap(new_page);
f2fs_put_page(new_page, 0); f2fs_put_page(new_page, 0);
out_dir: out_dir:
...@@ -473,7 +478,6 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -473,7 +478,6 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
kunmap(old_dir_page); kunmap(old_dir_page);
f2fs_put_page(old_dir_page, 0); f2fs_put_page(old_dir_page, 0);
} }
f2fs_unlock_op(sbi);
out_old: out_old:
kunmap(old_page); kunmap(old_page);
f2fs_put_page(old_page, 0); f2fs_put_page(old_page, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment