Message ID | 20220611094200.129502-3-allison.henderson@oracle.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | Return of the Parent Pointers | expand |
On Sat, Jun 11, 2022 at 02:41:45AM -0700, Allison Henderson wrote: > 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: Allison Henderson <allison.henderson@oracle.com> Looks pretty straightforward, Reviewed-by: Darrick J. Wong <djwong@kernel.org> --D > --- > fs/xfs/xfs_inode.c | 6 +++++- > fs/xfs/xfs_qm.c | 4 +++- > fs/xfs/xfs_symlink.c | 3 +++ > 3 files changed, 11 insertions(+), 2 deletions(-) > > diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c > index 52d6f2c7d58b..23b93403a330 100644 > --- a/fs/xfs/xfs_inode.c > +++ b/fs/xfs/xfs_inode.c > @@ -787,6 +787,8 @@ xfs_inode_inherit_flags2( > /* > * Initialise a newly allocated inode and return the in-core inode to the > * caller locked exclusively. > + * > + * Caller is responsible for unlocking the inode manually upon return > */ > int > xfs_init_new_inode( > @@ -913,7 +915,7 @@ xfs_init_new_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); > > /* now that we have an i_mode we can setup the inode structure */ > @@ -1090,6 +1092,7 @@ xfs_create( > xfs_qm_dqrele(pdqp); > > *ipp = ip; > + xfs_iunlock(ip, XFS_ILOCK_EXCL); > return 0; > > out_trans_cancel: > @@ -1186,6 +1189,7 @@ xfs_create_tmpfile( > xfs_qm_dqrele(pdqp); > > *ipp = ip; > + xfs_iunlock(ip, XFS_ILOCK_EXCL); > return 0; > > out_trans_cancel: > diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c > index abf08bbf34a9..fa8321f74c13 100644 > --- a/fs/xfs/xfs_qm.c > +++ b/fs/xfs/xfs_qm.c > @@ -817,8 +817,10 @@ xfs_qm_qino_alloc( > ASSERT(xfs_is_shutdown(mp)); > xfs_alert(mp, "%s failed (error %d)!", __func__, error); > } > - if (need_alloc) > + if (need_alloc) { > xfs_finish_inode_setup(*ipp); > + xfs_iunlock(*ipp, XFS_ILOCK_EXCL); > + } > return error; > } > > diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c > index 4145ba872547..18f71fc90dd0 100644 > --- a/fs/xfs/xfs_symlink.c > +++ b/fs/xfs/xfs_symlink.c > @@ -337,6 +337,7 @@ xfs_symlink( > xfs_qm_dqrele(pdqp); > > *ipp = ip; > + xfs_iunlock(ip, XFS_ILOCK_EXCL); > return 0; > > out_trans_cancel: > @@ -358,6 +359,8 @@ xfs_symlink( > > if (unlock_dp_on_error) > xfs_iunlock(dp, XFS_ILOCK_EXCL); > + if (ip) > + xfs_iunlock(ip, XFS_ILOCK_EXCL); > return error; > } > > -- > 2.25.1 >
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 52d6f2c7d58b..23b93403a330 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -787,6 +787,8 @@ xfs_inode_inherit_flags2( /* * Initialise a newly allocated inode and return the in-core inode to the * caller locked exclusively. + * + * Caller is responsible for unlocking the inode manually upon return */ int xfs_init_new_inode( @@ -913,7 +915,7 @@ xfs_init_new_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); /* now that we have an i_mode we can setup the inode structure */ @@ -1090,6 +1092,7 @@ xfs_create( xfs_qm_dqrele(pdqp); *ipp = ip; + xfs_iunlock(ip, XFS_ILOCK_EXCL); return 0; out_trans_cancel: @@ -1186,6 +1189,7 @@ xfs_create_tmpfile( xfs_qm_dqrele(pdqp); *ipp = ip; + xfs_iunlock(ip, XFS_ILOCK_EXCL); return 0; out_trans_cancel: diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index abf08bbf34a9..fa8321f74c13 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -817,8 +817,10 @@ xfs_qm_qino_alloc( ASSERT(xfs_is_shutdown(mp)); xfs_alert(mp, "%s failed (error %d)!", __func__, error); } - if (need_alloc) + if (need_alloc) { xfs_finish_inode_setup(*ipp); + xfs_iunlock(*ipp, XFS_ILOCK_EXCL); + } return error; } diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c index 4145ba872547..18f71fc90dd0 100644 --- a/fs/xfs/xfs_symlink.c +++ b/fs/xfs/xfs_symlink.c @@ -337,6 +337,7 @@ xfs_symlink( xfs_qm_dqrele(pdqp); *ipp = ip; + xfs_iunlock(ip, XFS_ILOCK_EXCL); return 0; out_trans_cancel: @@ -358,6 +359,8 @@ xfs_symlink( if (unlock_dp_on_error) xfs_iunlock(dp, XFS_ILOCK_EXCL); + if (ip) + xfs_iunlock(ip, XFS_ILOCK_EXCL); return error; }
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: Allison Henderson <allison.henderson@oracle.com> --- fs/xfs/xfs_inode.c | 6 +++++- fs/xfs/xfs_qm.c | 4 +++- fs/xfs/xfs_symlink.c | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-)