Skip to content

Commit

Permalink
xfs: directory bestfree check should release buffers
Browse files Browse the repository at this point in the history
When we're checking bestfree information in directory blocks, always
drop the block buffer at the end of the function.  We should always
release resources when we're done using them.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
  • Loading branch information
Darrick J. Wong committed Mar 26, 2020
1 parent afbabf5 commit d59f44d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions fs/xfs/scrub/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ xchk_directory_leaf1_bestfree(
/* Read the free space block. */
error = xfs_dir3_leaf_read(sc->tp, sc->ip, lblk, &bp);
if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, lblk, &error))
goto out;
return error;
xchk_buffer_recheck(sc, bp);

leaf = bp->b_addr;
Expand Down Expand Up @@ -568,9 +568,10 @@ xchk_directory_leaf1_bestfree(
xchk_directory_check_freesp(sc, lblk, dbp, best);
xfs_trans_brelse(sc->tp, dbp);
if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
goto out;
break;
}
out:
xfs_trans_brelse(sc->tp, bp);
return error;
}

Expand All @@ -592,7 +593,7 @@ xchk_directory_free_bestfree(
/* Read the free space block */
error = xfs_dir2_free_read(sc->tp, sc->ip, lblk, &bp);
if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, lblk, &error))
goto out;
return error;
xchk_buffer_recheck(sc, bp);

if (xfs_sb_version_hascrc(&sc->mp->m_sb)) {
Expand All @@ -615,14 +616,15 @@ xchk_directory_free_bestfree(
0, &dbp);
if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, lblk,
&error))
break;
goto out;
xchk_directory_check_freesp(sc, lblk, dbp, best);
xfs_trans_brelse(sc->tp, dbp);
}

if (freehdr.nused + stale != freehdr.nvalid)
xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, lblk);
out:
xfs_trans_brelse(sc->tp, bp);
return error;
}

Expand Down

0 comments on commit d59f44d

Please sign in to comment.