Skip to contentSkip to conversation

xfs: unlock inode when xfs_ioctl_setattr_get_trans can't get transaction

PATCH In review Darrick J. Wong 3 participants 4 messages Apr 22, 2019 – Apr 23, 2019 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: unlock inode when xfs_ioctl_setattr_get_trans can't get transaction

From: Darrick J. Wong <[email protected]>

We passed an inode into xfs_ioctl_setattr_get_trans with join_flags indicating which locks are held on that inode. If we can't allocate a transaction then we need to unlock the inode before we bail out, like all the other error paths do.

---
 fs/xfs/xfs_ioctl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_ioctl.c +1 -1
index 744a55092147..272ee6f037ff 100644
@@ -1173,7 +1173,7 @@ xfs_ioctl_setattr_get_trans(
 
 	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 0, 0, 0, &tp);
 	if (error)
-		return ERR_PTR(error);
+		goto out_unlock;
 
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
 	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL | join_flags);
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

We passed an inode into xfs_ioctl_setattr_get_trans with join_flags indicating which locks are held on that inode. If we can't allocate a transaction then we need to unlock the inode before we bail out, like all the other error paths do.

Yup, that's a problem, and the function header comment says "we now take full responsibility for unlocking the inode" so this looks fine.

Signature · 2 lines
Dave Chinner
[email protected]
#2 lore raw
Quoted 8 lines · Dave Chinner
Quoted 7 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

We passed an inode into xfs_ioctl_setattr_get_trans with join_flags indicating which locks are held on that inode. If we can't allocate a transaction then we need to unlock the inode before we bail out, like all the other error paths do.

Quoted 5 lines
Quoted 1 line

Yup, that's a problem, and the function header comment says "we now take full responsibility for unlocking the inode" so this looks fine.

Cool. Thanks for the review!

--D

Quoted 5 lines
Signature · 2 lines
Dave Chinner
[email protected]
Reviewed-by on v1 1/1
#3 lore raw
In reply to Darrick J. Wong
Quoted 8 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

We passed an inode into xfs_ioctl_setattr_get_trans with join_flags indicating which locks are held on that inode. If we can't allocate a transaction then we need to unlock the inode before we bail out, like all the other error paths do.

Looks good,