Skip to contentSkip to conversation

f2fs:Fix locking requirements in the function recover_dentry

PATCH In review Nicholas Krause 2 participants 2 messages Sep 5, 2015 – Sep 6, 2015 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs:Fix locking requirements in the function recover_dentry

This fixes locking requirements in the function recover_dentry to properly lock the critical region between the labels retry and out with the read/write semaphone of the f2fs's superblock representation in order to protect against other concurrent threads of execution accessing the same regions of memory used by the code in this critical

---
 fs/f2fs/recovery.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/f2fs/recovery.c +4 -0
index faec2ca..5f1226c 100644
@@ -75,6 +75,7 @@ static int recover_dentry(struct inode *inode, struct page *ipage)
 	struct qstr name;
 	struct page *page;
 	struct inode *dir, *einode;
+	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
 	int err = 0;
 
 	dir = f2fs_iget(inode->i_sb, pino);
@@ -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);
@@ -138,6 +141,7 @@ out_unmap_put:
 out_err:
 	iput(dir);
 out:
+	f2fs_unlock_op(sbi);
 	f2fs_msg(inode->i_sb, KERN_NOTICE,
 			"%s: ino = %x, name = %s, dir = %lx, err = %d",
 			__func__, ino_of_node(ipage), raw_inode->i_name,
Signature · 4 lines
2.1.4


------------------------------------------------------------------------------
#1 lore raw
Quoted 8 lines

-----Original Message-----
From: Nicholas Krause [mailto:[email protected]]
Sent: Sunday, September 06, 2015 1:27 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH] f2fs:Fix locking requirements in the function recover_dentry

Quoted 4 lines

This fixes locking requirements in the function recover_dentry to properly lock the critical region between the labels retry and out with the read/write semaphone of the f2fs's superblock representation in order to protect against other concurrent threads of execution

The protecting is not needed, I've already relayed in last thread, please refer to the link below:

http://www.gossamer-threads.com/lists/linux/kernel/2234556?do=post_view_threaded#2234556

Thanks,