f2fs:Fix concurrent access issues in the function recover_dentry
PATCH 1/1 f2fs:Fix concurrent access issues in the function recover_dentry
This fixes concurrent access issues in the function recover_dentry by locking and locking another the block labeled retry with the functions f2fs_lock_op/f2fs_unlock_op on a pointer of the superblock used by the passed inode structure pointer by this
--- fs/f2fs/recovery.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/f2fs/recovery.c +5 -1
@@ -70,6 +70,7 @@ static struct fsync_inode_entry *get_fsync_inode(struct list_head *head,static int recover_dentry (struct inode *inode,struct page *ipage) {struct f2fs_inode *raw_inode =F2FS_INODE (ipage); +struct f2fs_sb_info *sbi =F2FS_I_SB (inode);nid_t pino =le32_to_cpu (raw_inode->i_pino);struct f2fs_dir_entry *de;struct qstr name;
@@ -97,6 +98,7 @@ static int recover_dentry(struct inode *inode, struct page *ipage) goto out_err; } retry: +f2fs_lock_op (sbi); de =f2fs_find_entry (dir, &name, &page);if (de && inode->i_ino ==le32_to_cpu (de->ino)) goto out_unmap_put;
@@ -117,6 +119,7 @@ retry: }f2fs_delete_entry (de, page, dir, einode);iput (einode); +f2fs_unlock_op (sbi); goto retry; } err =__f2fs_add_link (dir, &name, inode, inode->i_ino, inode->i_mode);
@@ -129,7 +132,8 @@ retry:add_dirty_dir_inode (dir);set_inode_flag (F2FS_I (dir),FI_DELAY_IPUT ); } - + +f2fs_unlock_op (sbi); goto out; out_unmap_put:
Signature · 4 lines
2.1.4 ------------------------------------------------------------------------------
------------------------------------------------------------------------------
Quoted 6 lines · Nicholas Krause
This fixes concurrent access issues in the function
recover_dentryby locking and locking another the block labeled retry with the functions f2fs_lock_op/f2fs_unlock_op on a pointer of the superblock used by the passed inode structure pointer by this
Recovery and checkpoint will block each other with cp_mutex firstly, so f2fs_lock_all in its only caller checkpoint have no chance to race with any f2fs_lock_op in recovery procedure.
It’s not needed to call f2fs_lock_op here.
Thanks,
Quoted 43 lines
Signed-off-by Nicholas Krause <[email protected]>---
fs/f2fs/recovery.c| 6 +++++-1 file changed, 5 insertions(+), 1 deletion(-)fs/f2fs/recovery.c +1
-0@@ -70,6 +70,7 @@ static struct fsync_inode_entry *get_fsync_inode(struct list_head *head,static int recover_dentry (struct inode *inode,struct page *ipage) {struct f2fs_inode *raw_inode =F2FS_INODE (ipage); +struct f2fs_sb_info *sbi =F2FS_I_SB (inode);nid_t pino =le32_to_cpu (raw_inode->i_pino);struct f2fs_dir_entry *de;struct qstr name;@@ -97,6 +98,7 @@ static int recover_dentry(struct inode *inode, struct page *ipage) goto out_err; }retry:
fs/f2fs/recovery.c +1
-0+f2fs_lock_op (sbi);de = f2fs_find_entry(dir, &name, &page); if (de && inode->i_ino == le32_to_cpu(de->ino)) goto out_unmap_put;fs/f2fs/recovery.c +3
-1@@ -117,6 +119,7 @@ retry: }f2fs_delete_entry (de, page, dir, einode);iput (einode); +f2fs_unlock_op (sbi); goto retry; } err =__f2fs_add_link (dir, &name, inode, inode->i_ino, inode->i_mode);@@ -129,7 +132,8 @@ retry:add_dirty_dir_inode (dir);set_inode_flag (F2FS_I (dir),FI_DELAY_IPUT ); } - + +f2fs_unlock_op (sbi); goto out;
Quoted 10 lines
out_unmap_put:Signature · 8 lines
2.1.4 ------------------------------------------------------------------------------ _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
------------------------------------------------------------------------------
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel