Skip to content

Commit 8e8877e

Browse files
committed
xfs: return the hash value of a leaf1 directory block
Modify the existing dir leafn lasthash function to enable us to calculate the highest hash value of a leaf1 block. This will be used by the directory scrubbing code to check the sanity of hashes in leaf1 directory blocks. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Brian Foster <[email protected]>
1 parent e7f5d5c commit 8e8877e

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

fs/xfs/libxfs/xfs_da_btree.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ xfs_da3_fixhashpath(
12821282
return;
12831283
break;
12841284
case XFS_DIR2_LEAFN_MAGIC:
1285-
lasthash = xfs_dir2_leafn_lasthash(dp, blk->bp, &count);
1285+
lasthash = xfs_dir2_leaf_lasthash(dp, blk->bp, &count);
12861286
if (count == 0)
12871287
return;
12881288
break;
@@ -1502,8 +1502,8 @@ xfs_da3_node_lookup_int(
15021502
if (blk->magic == XFS_DIR2_LEAFN_MAGIC ||
15031503
blk->magic == XFS_DIR3_LEAFN_MAGIC) {
15041504
blk->magic = XFS_DIR2_LEAFN_MAGIC;
1505-
blk->hashval = xfs_dir2_leafn_lasthash(args->dp,
1506-
blk->bp, NULL);
1505+
blk->hashval = xfs_dir2_leaf_lasthash(args->dp,
1506+
blk->bp, NULL);
15071507
break;
15081508
}
15091509

@@ -1929,8 +1929,8 @@ xfs_da3_path_shift(
19291929
blk->magic = XFS_DIR2_LEAFN_MAGIC;
19301930
ASSERT(level == path->active-1);
19311931
blk->index = 0;
1932-
blk->hashval = xfs_dir2_leafn_lasthash(args->dp,
1933-
blk->bp, NULL);
1932+
blk->hashval = xfs_dir2_leaf_lasthash(args->dp,
1933+
blk->bp, NULL);
19341934
break;
19351935
default:
19361936
ASSERT(0);

fs/xfs/libxfs/xfs_dir2_node.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ xfs_dir2_free_hdr_check(
528528
* Stale entries are ok.
529529
*/
530530
xfs_dahash_t /* hash value */
531-
xfs_dir2_leafn_lasthash(
531+
xfs_dir2_leaf_lasthash(
532532
struct xfs_inode *dp,
533533
struct xfs_buf *bp, /* leaf buffer */
534534
int *count) /* count of entries in leaf */
@@ -540,7 +540,9 @@ xfs_dir2_leafn_lasthash(
540540
dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
541541

542542
ASSERT(leafhdr.magic == XFS_DIR2_LEAFN_MAGIC ||
543-
leafhdr.magic == XFS_DIR3_LEAFN_MAGIC);
543+
leafhdr.magic == XFS_DIR3_LEAFN_MAGIC ||
544+
leafhdr.magic == XFS_DIR2_LEAF1_MAGIC ||
545+
leafhdr.magic == XFS_DIR3_LEAF1_MAGIC);
544546

545547
if (count)
546548
*count = leafhdr.count;
@@ -1405,8 +1407,8 @@ xfs_dir2_leafn_split(
14051407
/*
14061408
* Update last hashval in each block since we added the name.
14071409
*/
1408-
oldblk->hashval = xfs_dir2_leafn_lasthash(dp, oldblk->bp, NULL);
1409-
newblk->hashval = xfs_dir2_leafn_lasthash(dp, newblk->bp, NULL);
1410+
oldblk->hashval = xfs_dir2_leaf_lasthash(dp, oldblk->bp, NULL);
1411+
newblk->hashval = xfs_dir2_leaf_lasthash(dp, newblk->bp, NULL);
14101412
xfs_dir3_leaf_check(dp, oldblk->bp);
14111413
xfs_dir3_leaf_check(dp, newblk->bp);
14121414
return error;

fs/xfs/libxfs/xfs_dir2_priv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ extern bool xfs_dir3_leaf_check_int(struct xfs_mount *mp, struct xfs_inode *dp,
9595
/* xfs_dir2_node.c */
9696
extern int xfs_dir2_leaf_to_node(struct xfs_da_args *args,
9797
struct xfs_buf *lbp);
98-
extern xfs_dahash_t xfs_dir2_leafn_lasthash(struct xfs_inode *dp,
98+
extern xfs_dahash_t xfs_dir2_leaf_lasthash(struct xfs_inode *dp,
9999
struct xfs_buf *bp, int *count);
100100
extern int xfs_dir2_leafn_lookup_int(struct xfs_buf *bp,
101101
struct xfs_da_args *args, int *indexp,

0 commit comments

Comments
 (0)