Skip to contentSkip to conversation

Lock both inodes in rpdfs_unlink()

PATCH Applied Chris Kirby 2 participants 2 messages Oct 19 – Oct 23

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Lock both inodes in rpdfs_unlink()

The code was only locking the parent directory inode. We also need to lock the inode being unlinked using rpdfs_inode_rlock_refresh_many().

---
 fs/rpdfs/dir.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
fs/rpdfs/dir.c +7 -3
index dab183a07325..8a48817699d7 100644
@@ -436,13 +436,16 @@ static int rpdfs_unlink(struct inode *dir, struct dentry *dentry)
 {
 	struct rpdfs_fs_info *rfi = RPDFS_INODE_FS(dir);
 	struct inode *inode = d_inode(dentry);
-	DECLARE_RPDFS_RLOCK_HOLD(hold);
+	DECLARE_RPDFS_RLOCK_HOLD(dir_hold);
+	DECLARE_RPDFS_RLOCK_HOLD(inode_hold);
 	struct dent_args da;
 	int ret;
 
 	init_dent_args(&da, dentry, inode);
 
-	ret = rpdfs_inode_rlock_refresh(dir, RPDFS_RLOCK_MODE_EX_WR, &hold);
+	ret = rpdfs_inode_rlock_refresh_many(dir, &dir_hold, inode, &inode_hold,
+					     NULL, NULL, NULL, NULL,
+					     RPDFS_RLOCK_MODE_EX_WR);
 	if (ret < 0) {
 		inode = ERR_PTR(ret);
 		goto out;
@@ -469,7 +472,8 @@ static int rpdfs_unlink(struct inode *dir, struct dentry *dentry)
 	ret = 0;
 out:
 	rpdfs_inode_update(rfi, dir);
-	rpdfs_rlock_unlock(rfi, &hold);
+	rpdfs_rlock_unlock(rfi, &inode_hold);
+	rpdfs_rlock_unlock(rfi, &dir_hold);
 
 	return ret;
 }
Signature · 1 line
2.55.0
Applied
#1 lore raw
Quoted 2 lines · Chris Kirby

The code was only locking the parent directory inode. We also need to lock the inode being unlinked using rpdfs_inode_rlock_refresh_many().

Applied, thanks!

- z