summaryrefslogtreecommitdiff
path: root/fs/xfs/scrub
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2017-11-06 11:37:46 -0800
committerDarrick J. Wong <darrick.wong@oracle.com>2017-11-09 09:10:45 -0800
commit35ce85233412354d6737b8407738174eb251fd32 (patch)
tree80a0903afd25b95c5196a5bfc4006af3c43da158 /fs/xfs/scrub
parent181fdfe662716450ce64be4134157d7152e6402e (diff)
xfs: refactor the directory data block bestfree checks
In a directory data block, the zeroth bestfree item must point to the longest free space. Therefore, when we check the bestfree block's records against the data blocks, we only need to compare with bf[0] and don't need the loop. The weird loop was most probably the result of an earlier refactoring gone bad. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/scrub')
-rw-r--r--fs/xfs/scrub/dir.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/fs/xfs/scrub/dir.c b/fs/xfs/scrub/dir.c
index d4cd7661633d..c8ca3fd67445 100644
--- a/fs/xfs/scrub/dir.c
+++ b/fs/xfs/scrub/dir.c
@@ -435,25 +435,15 @@ xfs_scrub_directory_check_freesp(
struct xfs_buf *dbp,
unsigned int len)
{
- struct xfs_dir2_data_free *bf;
struct xfs_dir2_data_free *dfp;
- int offset;
- if (len == 0)
- return;
+ dfp = sc->ip->d_ops->data_bestfree_p(dbp->b_addr);
- bf = sc->ip->d_ops->data_bestfree_p(dbp->b_addr);
- for (dfp = &bf[0]; dfp < &bf[XFS_DIR2_DATA_FD_COUNT]; dfp++) {
- offset = be16_to_cpu(dfp->offset);
- if (offset == 0)
- break;
- if (len == be16_to_cpu(dfp->length))
- return;
- /* Didn't find the best length in the bestfree data */
- break;
- }
+ if (len != be16_to_cpu(dfp->length))
+ xfs_scrub_fblock_set_corrupt(sc, XFS_DATA_FORK, lblk);
- xfs_scrub_fblock_set_corrupt(sc, XFS_DATA_FORK, lblk);
+ if (len > 0 && be16_to_cpu(dfp->offset) == 0)
+ xfs_scrub_fblock_set_corrupt(sc, XFS_DATA_FORK, lblk);
}
/* Check free space info in a directory leaf1 block. */