On Fri, Oct 02, 2020 at 12:27:54PM -0400, Brian Foster wrote: > On Tue, Sep 29, 2020 at 10:44:00AM -0700, Darrick J. Wong wrote: > > From: Darrick J. Wong <darrick.wong@xxxxxxxxxx> > > > > In most places in XFS, we have a specific order in which we gather > > resources: grab the inode, allocate a transaction, then lock the inode. > > xfs_bui_item_recover doesn't do it in that order, so fix it to be more > > consistent. This also makes the error bailout code a bit less weird. > > > > Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> > > Reviewed-by: Dave Chinner <dchinner@xxxxxxxxxx> > > Reviewed-by: Christoph Hellwig <hch@xxxxxx> > > --- > > fs/xfs/xfs_bmap_item.c | 42 ++++++++++++++++++++++-------------------- > > 1 file changed, 22 insertions(+), 20 deletions(-) > > > > > > diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c > > index c1f2cc3c42cb..1c9cb5a04bb5 100644 > > --- a/fs/xfs/xfs_bmap_item.c > > +++ b/fs/xfs/xfs_bmap_item.c > ... > > @@ -512,18 +513,19 @@ xfs_bui_item_recover( > > xfs_bmap_unmap_extent(tp, ip, &irec); > > } > > > > + /* Commit transaction, which frees tp. */ > > error = xfs_defer_ops_capture_and_commit(tp, capture_list); > > + if (error) > > + goto err_unlock; > > + return 0; > > + > > +err_cancel: > > + xfs_trans_cancel(tp); > > +err_unlock: > > xfs_iunlock(ip, XFS_ILOCK_EXCL); > > +err_rele: > > xfs_irele(ip); > > What happened to the unlock and irele in the non-error path? xfs_defer_capture_and_consume did that, but see christoph's reply. --D > Brian > > > return error; > > - > > -err_inode: > > - xfs_trans_cancel(tp); > > - if (ip) { > > - xfs_iunlock(ip, XFS_ILOCK_EXCL); > > - xfs_irele(ip); > > - } > > - return error; > > } > > > > STATIC bool > > >