Commit 267979b4 authored by Allison Henderson's avatar Allison Henderson Committed by Darrick J. Wong

xfs: Hold inode locks in xfs_ialloc

Modify xfs_ialloc to hold locks after return.  Caller will be
responsible for manual unlock.  We will need this later to hold locks
across parent pointer operations
Signed-off-by: default avatarAllison Henderson <allison.henderson@oracle.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarCatherine Hoang <catherine.hoang@oracle.com>
[djwong: hold the parent ilocked across transaction rolls too]
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent f103df76
...@@ -747,6 +747,8 @@ xfs_inode_inherit_flags2( ...@@ -747,6 +747,8 @@ xfs_inode_inherit_flags2(
/* /*
* Initialise a newly allocated inode and return the in-core inode to the * Initialise a newly allocated inode and return the in-core inode to the
* caller locked exclusively. * caller locked exclusively.
*
* Caller is responsible for unlocking the inode manually upon return
*/ */
int int
xfs_init_new_inode( xfs_init_new_inode(
...@@ -873,7 +875,7 @@ xfs_init_new_inode( ...@@ -873,7 +875,7 @@ xfs_init_new_inode(
/* /*
* Log the new values stuffed into the inode. * Log the new values stuffed into the inode.
*/ */
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, ip, 0);
xfs_trans_log_inode(tp, ip, flags); xfs_trans_log_inode(tp, ip, flags);
/* now that we have an i_mode we can setup the inode structure */ /* now that we have an i_mode we can setup the inode structure */
...@@ -1101,8 +1103,7 @@ xfs_create( ...@@ -1101,8 +1103,7 @@ xfs_create(
* the transaction cancel unlocking dp so don't do it explicitly in the * the transaction cancel unlocking dp so don't do it explicitly in the
* error path. * error path.
*/ */
xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, dp, 0);
unlock_dp_on_error = false;
error = xfs_dir_createname(tp, dp, name, ip->i_ino, error = xfs_dir_createname(tp, dp, name, ip->i_ino,
resblks - XFS_IALLOC_SPACE_RES(mp)); resblks - XFS_IALLOC_SPACE_RES(mp));
...@@ -1151,6 +1152,8 @@ xfs_create( ...@@ -1151,6 +1152,8 @@ xfs_create(
xfs_qm_dqrele(pdqp); xfs_qm_dqrele(pdqp);
*ipp = ip; *ipp = ip;
xfs_iunlock(ip, XFS_ILOCK_EXCL);
xfs_iunlock(dp, XFS_ILOCK_EXCL);
return 0; return 0;
out_trans_cancel: out_trans_cancel:
...@@ -1162,6 +1165,7 @@ xfs_create( ...@@ -1162,6 +1165,7 @@ xfs_create(
* transactions and deadlocks from xfs_inactive. * transactions and deadlocks from xfs_inactive.
*/ */
if (ip) { if (ip) {
xfs_iunlock(ip, XFS_ILOCK_EXCL);
xfs_finish_inode_setup(ip); xfs_finish_inode_setup(ip);
xfs_irele(ip); xfs_irele(ip);
} }
...@@ -1247,6 +1251,7 @@ xfs_create_tmpfile( ...@@ -1247,6 +1251,7 @@ xfs_create_tmpfile(
xfs_qm_dqrele(pdqp); xfs_qm_dqrele(pdqp);
*ipp = ip; *ipp = ip;
xfs_iunlock(ip, XFS_ILOCK_EXCL);
return 0; return 0;
out_trans_cancel: out_trans_cancel:
...@@ -1258,6 +1263,7 @@ xfs_create_tmpfile( ...@@ -1258,6 +1263,7 @@ xfs_create_tmpfile(
* transactions and deadlocks from xfs_inactive. * transactions and deadlocks from xfs_inactive.
*/ */
if (ip) { if (ip) {
xfs_iunlock(ip, XFS_ILOCK_EXCL);
xfs_finish_inode_setup(ip); xfs_finish_inode_setup(ip);
xfs_irele(ip); xfs_irele(ip);
} }
......
...@@ -836,8 +836,10 @@ xfs_qm_qino_alloc( ...@@ -836,8 +836,10 @@ xfs_qm_qino_alloc(
ASSERT(xfs_is_shutdown(mp)); ASSERT(xfs_is_shutdown(mp));
xfs_alert(mp, "%s failed (error %d)!", __func__, error); xfs_alert(mp, "%s failed (error %d)!", __func__, error);
} }
if (need_alloc) if (need_alloc) {
xfs_iunlock(*ipp, XFS_ILOCK_EXCL);
xfs_finish_inode_setup(*ipp); xfs_finish_inode_setup(*ipp);
}
return error; return error;
} }
......
...@@ -172,8 +172,7 @@ xfs_symlink( ...@@ -172,8 +172,7 @@ xfs_symlink(
* the transaction cancel unlocking dp so don't do it explicitly in the * the transaction cancel unlocking dp so don't do it explicitly in the
* error path. * error path.
*/ */
xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, dp, 0);
unlock_dp_on_error = false;
/* /*
* Also attach the dquot(s) to it, if applicable. * Also attach the dquot(s) to it, if applicable.
...@@ -215,6 +214,8 @@ xfs_symlink( ...@@ -215,6 +214,8 @@ xfs_symlink(
xfs_qm_dqrele(pdqp); xfs_qm_dqrele(pdqp);
*ipp = ip; *ipp = ip;
xfs_iunlock(ip, XFS_ILOCK_EXCL);
xfs_iunlock(dp, XFS_ILOCK_EXCL);
return 0; return 0;
out_trans_cancel: out_trans_cancel:
...@@ -226,6 +227,7 @@ xfs_symlink( ...@@ -226,6 +227,7 @@ xfs_symlink(
* transactions and deadlocks from xfs_inactive. * transactions and deadlocks from xfs_inactive.
*/ */
if (ip) { if (ip) {
xfs_iunlock(ip, XFS_ILOCK_EXCL);
xfs_finish_inode_setup(ip); xfs_finish_inode_setup(ip);
xfs_irele(ip); xfs_irele(ip);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment