Commit a84f3d5c authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong

xfs: add a bests pointer to struct xfs_dir3_icfree_hdr

All but two callers of the ->free_bests_p dir operation already have a
struct xfs_dir3_icfree_hdr from a previous call to
xfs_dir2_free_hdr_from_disk at hand.  Add a pointer to the bests to
struct xfs_dir3_icfree_hdr to clean up this pattern.  To optimize this
pattern, pass the struct xfs_dir3_icfree_hdr to xfs_dir2_free_log_bests
instead of recalculating the pointer there.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 195b0a44
...@@ -411,12 +411,6 @@ xfs_dir2_free_max_bests(struct xfs_da_geometry *geo) ...@@ -411,12 +411,6 @@ xfs_dir2_free_max_bests(struct xfs_da_geometry *geo)
sizeof(xfs_dir2_data_off_t); sizeof(xfs_dir2_data_off_t);
} }
static __be16 *
xfs_dir2_free_bests_p(struct xfs_dir2_free *free)
{
return (__be16 *)((char *)free + sizeof(struct xfs_dir2_free_hdr));
}
/* /*
* Convert data space db to the corresponding free db. * Convert data space db to the corresponding free db.
*/ */
...@@ -443,12 +437,6 @@ xfs_dir3_free_max_bests(struct xfs_da_geometry *geo) ...@@ -443,12 +437,6 @@ xfs_dir3_free_max_bests(struct xfs_da_geometry *geo)
sizeof(xfs_dir2_data_off_t); sizeof(xfs_dir2_data_off_t);
} }
static __be16 *
xfs_dir3_free_bests_p(struct xfs_dir2_free *free)
{
return (__be16 *)((char *)free + sizeof(struct xfs_dir3_free_hdr));
}
/* /*
* Convert data space db to the corresponding free db. * Convert data space db to the corresponding free db.
*/ */
...@@ -500,7 +488,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { ...@@ -500,7 +488,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = {
.free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_hdr_size = sizeof(struct xfs_dir2_free_hdr),
.free_max_bests = xfs_dir2_free_max_bests, .free_max_bests = xfs_dir2_free_max_bests,
.free_bests_p = xfs_dir2_free_bests_p,
.db_to_fdb = xfs_dir2_db_to_fdb, .db_to_fdb = xfs_dir2_db_to_fdb,
.db_to_fdindex = xfs_dir2_db_to_fdindex, .db_to_fdindex = xfs_dir2_db_to_fdindex,
}; };
...@@ -537,7 +524,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { ...@@ -537,7 +524,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = {
.free_hdr_size = sizeof(struct xfs_dir2_free_hdr), .free_hdr_size = sizeof(struct xfs_dir2_free_hdr),
.free_max_bests = xfs_dir2_free_max_bests, .free_max_bests = xfs_dir2_free_max_bests,
.free_bests_p = xfs_dir2_free_bests_p,
.db_to_fdb = xfs_dir2_db_to_fdb, .db_to_fdb = xfs_dir2_db_to_fdb,
.db_to_fdindex = xfs_dir2_db_to_fdindex, .db_to_fdindex = xfs_dir2_db_to_fdindex,
}; };
...@@ -574,7 +560,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { ...@@ -574,7 +560,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = {
.free_hdr_size = sizeof(struct xfs_dir3_free_hdr), .free_hdr_size = sizeof(struct xfs_dir3_free_hdr),
.free_max_bests = xfs_dir3_free_max_bests, .free_max_bests = xfs_dir3_free_max_bests,
.free_bests_p = xfs_dir3_free_bests_p,
.db_to_fdb = xfs_dir3_db_to_fdb, .db_to_fdb = xfs_dir3_db_to_fdb,
.db_to_fdindex = xfs_dir3_db_to_fdindex, .db_to_fdindex = xfs_dir3_db_to_fdindex,
}; };
......
...@@ -74,7 +74,6 @@ struct xfs_dir_ops { ...@@ -74,7 +74,6 @@ struct xfs_dir_ops {
int free_hdr_size; int free_hdr_size;
int (*free_max_bests)(struct xfs_da_geometry *geo); int (*free_max_bests)(struct xfs_da_geometry *geo);
__be16 * (*free_bests_p)(struct xfs_dir2_free *free);
xfs_dir2_db_t (*db_to_fdb)(struct xfs_da_geometry *geo, xfs_dir2_db_t (*db_to_fdb)(struct xfs_da_geometry *geo,
xfs_dir2_db_t db); xfs_dir2_db_t db);
int (*db_to_fdindex)(struct xfs_da_geometry *geo, int (*db_to_fdindex)(struct xfs_da_geometry *geo,
......
...@@ -1680,7 +1680,6 @@ xfs_dir2_node_to_leaf( ...@@ -1680,7 +1680,6 @@ xfs_dir2_node_to_leaf(
int error; /* error return code */ int error; /* error return code */
struct xfs_buf *fbp; /* buffer for freespace block */ struct xfs_buf *fbp; /* buffer for freespace block */
xfs_fileoff_t fo; /* freespace file offset */ xfs_fileoff_t fo; /* freespace file offset */
xfs_dir2_free_t *free; /* freespace structure */
struct xfs_buf *lbp; /* buffer for leaf block */ struct xfs_buf *lbp; /* buffer for leaf block */
xfs_dir2_leaf_tail_t *ltp; /* tail of leaf structure */ xfs_dir2_leaf_tail_t *ltp; /* tail of leaf structure */
xfs_dir2_leaf_t *leaf; /* leaf structure */ xfs_dir2_leaf_t *leaf; /* leaf structure */
...@@ -1749,8 +1748,7 @@ xfs_dir2_node_to_leaf( ...@@ -1749,8 +1748,7 @@ xfs_dir2_node_to_leaf(
error = xfs_dir2_free_read(tp, dp, args->geo->freeblk, &fbp); error = xfs_dir2_free_read(tp, dp, args->geo->freeblk, &fbp);
if (error) if (error)
return error; return error;
free = fbp->b_addr; xfs_dir2_free_hdr_from_disk(mp, &freehdr, fbp->b_addr);
xfs_dir2_free_hdr_from_disk(mp, &freehdr, free);
ASSERT(!freehdr.firstdb); ASSERT(!freehdr.firstdb);
...@@ -1784,7 +1782,7 @@ xfs_dir2_node_to_leaf( ...@@ -1784,7 +1782,7 @@ xfs_dir2_node_to_leaf(
/* /*
* Set up the leaf bests table. * Set up the leaf bests table.
*/ */
memcpy(xfs_dir2_leaf_bests_p(ltp), dp->d_ops->free_bests_p(free), memcpy(xfs_dir2_leaf_bests_p(ltp), freehdr.bests,
freehdr.nvalid * sizeof(xfs_dir2_data_off_t)); freehdr.nvalid * sizeof(xfs_dir2_data_off_t));
xfs_dir2_leaf_hdr_to_disk(mp, leaf, &leafhdr); xfs_dir2_leaf_hdr_to_disk(mp, leaf, &leafhdr);
......
This diff is collapsed.
...@@ -31,6 +31,12 @@ struct xfs_dir3_icfree_hdr { ...@@ -31,6 +31,12 @@ struct xfs_dir3_icfree_hdr {
uint32_t firstdb; uint32_t firstdb;
uint32_t nvalid; uint32_t nvalid;
uint32_t nused; uint32_t nused;
/*
* Pointer to the on-disk format entries, which are behind the
* variable size (v4 vs v5) header in the on-disk block.
*/
__be16 *bests;
}; };
/* xfs_dir2.c */ /* xfs_dir2.c */
......
...@@ -583,7 +583,6 @@ xchk_directory_free_bestfree( ...@@ -583,7 +583,6 @@ xchk_directory_free_bestfree(
struct xfs_dir3_icfree_hdr freehdr; struct xfs_dir3_icfree_hdr freehdr;
struct xfs_buf *dbp; struct xfs_buf *dbp;
struct xfs_buf *bp; struct xfs_buf *bp;
__be16 *bestp;
__u16 best; __u16 best;
unsigned int stale = 0; unsigned int stale = 0;
int i; int i;
...@@ -604,9 +603,8 @@ xchk_directory_free_bestfree( ...@@ -604,9 +603,8 @@ xchk_directory_free_bestfree(
/* Check all the entries. */ /* Check all the entries. */
xfs_dir2_free_hdr_from_disk(sc->ip->i_mount, &freehdr, bp->b_addr); xfs_dir2_free_hdr_from_disk(sc->ip->i_mount, &freehdr, bp->b_addr);
bestp = sc->ip->d_ops->free_bests_p(bp->b_addr); for (i = 0; i < freehdr.nvalid; i++) {
for (i = 0; i < freehdr.nvalid; i++, bestp++) { best = be16_to_cpu(freehdr.bests[i]);
best = be16_to_cpu(*bestp);
if (best == NULLDATAOFF) { if (best == NULLDATAOFF) {
stale++; stale++;
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment