[PATCH] f2fs: remove unnecessary dentry locks
From: Jaegeuk Kim
Date: Tue May 05 2020 - 14:08:58 EST
As Eric commented, let's kill unnecessary dentry ops when recovering
parent inode number.
Suggested-by: Eric Biggers <ebiggers@xxxxxxxxxx>
Signed-off-by: Jaegeuk Kim <jaegeuk@xxxxxxxxxx>
---
fs/f2fs/file.c | 26 ++++++--------------------
1 file changed, 6 insertions(+), 20 deletions(-)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index a0a4413d6083b..711cebad36fc5 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -165,21 +165,6 @@ static const struct vm_operations_struct f2fs_file_vm_ops = {
.page_mkwrite = f2fs_vm_page_mkwrite,
};
-static int get_parent_ino(struct inode *inode, nid_t *pino)
-{
- struct dentry *dentry;
-
- inode = igrab(inode);
- dentry = d_find_any_alias(inode);
- iput(inode);
- if (!dentry)
- return 0;
-
- *pino = parent_ino(dentry);
- dput(dentry);
- return 1;
-}
-
static inline enum cp_reason_type need_do_checkpoint(struct inode *inode)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
@@ -223,14 +208,15 @@ static bool need_inode_page_update(struct f2fs_sb_info *sbi, nid_t ino)
return ret;
}
-static void try_to_fix_pino(struct inode *inode)
+static void try_to_fix_pino(struct dentry *dentry)
{
+ struct inode *inode = d_inode(dentry);
struct f2fs_inode_info *fi = F2FS_I(inode);
- nid_t pino;
down_write(&fi->i_sem);
- if (file_wrong_pino(inode) && inode->i_nlink == 1 &&
- get_parent_ino(inode, &pino)) {
+ if (file_wrong_pino(inode) && inode->i_nlink == 1) {
+ nid_t pino = parent_ino(dentry);
+
f2fs_i_pino_write(inode, pino);
file_got_pino(inode);
}
@@ -310,7 +296,7 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
* We've secured consistency through sync_fs. Following pino
* will be used only for fsynced inodes after checkpoint.
*/
- try_to_fix_pino(inode);
+ try_to_fix_pino(file_dentry(file));
clear_inode_flag(inode, FI_APPEND_WRITE);
clear_inode_flag(inode, FI_UPDATE_WRITE);
goto out;
--
2.26.2.526.g744177e7f7-goog