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

xfs: move the max dir2 free bests count to struct xfs_da_geometry

Move the max free bests count towards our structure for dir/attr
geometry parameters.
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 ed1d612f
...@@ -30,6 +30,7 @@ struct xfs_da_geometry { ...@@ -30,6 +30,7 @@ struct xfs_da_geometry {
unsigned int leaf_max_ents; /* # of entries in dir2 leaf */ unsigned int leaf_max_ents; /* # of entries in dir2 leaf */
xfs_dablk_t leafblk; /* blockno of leaf data v2 */ xfs_dablk_t leafblk; /* blockno of leaf data v2 */
unsigned int free_hdr_size; /* dir2 free header size */ unsigned int free_hdr_size; /* dir2 free header size */
unsigned int free_max_bests; /* # of bests entries in dir2 free */
xfs_dablk_t freeblk; /* blockno of free data v2 */ xfs_dablk_t freeblk; /* blockno of free data v2 */
}; };
......
...@@ -400,17 +400,6 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr) ...@@ -400,17 +400,6 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr)
((char *)hdr + sizeof(struct xfs_dir3_data_hdr)); ((char *)hdr + sizeof(struct xfs_dir3_data_hdr));
} }
/*
* Directory free space block operations
*/
static int
xfs_dir2_free_max_bests(struct xfs_da_geometry *geo)
{
return (geo->blksize - sizeof(struct xfs_dir2_free_hdr)) /
sizeof(xfs_dir2_data_off_t);
}
/* /*
* Convert data space db to the corresponding free db. * Convert data space db to the corresponding free db.
*/ */
...@@ -418,7 +407,7 @@ static xfs_dir2_db_t ...@@ -418,7 +407,7 @@ static xfs_dir2_db_t
xfs_dir2_db_to_fdb(struct xfs_da_geometry *geo, xfs_dir2_db_t db) xfs_dir2_db_to_fdb(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
{ {
return xfs_dir2_byte_to_db(geo, XFS_DIR2_FREE_OFFSET) + return xfs_dir2_byte_to_db(geo, XFS_DIR2_FREE_OFFSET) +
(db / xfs_dir2_free_max_bests(geo)); (db / geo->free_max_bests);
} }
/* /*
...@@ -427,14 +416,7 @@ xfs_dir2_db_to_fdb(struct xfs_da_geometry *geo, xfs_dir2_db_t db) ...@@ -427,14 +416,7 @@ xfs_dir2_db_to_fdb(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
static int static int
xfs_dir2_db_to_fdindex(struct xfs_da_geometry *geo, xfs_dir2_db_t db) xfs_dir2_db_to_fdindex(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
{ {
return db % xfs_dir2_free_max_bests(geo); return db % geo->free_max_bests;
}
static int
xfs_dir3_free_max_bests(struct xfs_da_geometry *geo)
{
return (geo->blksize - sizeof(struct xfs_dir3_free_hdr)) /
sizeof(xfs_dir2_data_off_t);
} }
/* /*
...@@ -444,7 +426,7 @@ static xfs_dir2_db_t ...@@ -444,7 +426,7 @@ static xfs_dir2_db_t
xfs_dir3_db_to_fdb(struct xfs_da_geometry *geo, xfs_dir2_db_t db) xfs_dir3_db_to_fdb(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
{ {
return xfs_dir2_byte_to_db(geo, XFS_DIR2_FREE_OFFSET) + return xfs_dir2_byte_to_db(geo, XFS_DIR2_FREE_OFFSET) +
(db / xfs_dir3_free_max_bests(geo)); (db / geo->free_max_bests);
} }
/* /*
...@@ -453,7 +435,7 @@ xfs_dir3_db_to_fdb(struct xfs_da_geometry *geo, xfs_dir2_db_t db) ...@@ -453,7 +435,7 @@ xfs_dir3_db_to_fdb(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
static int static int
xfs_dir3_db_to_fdindex(struct xfs_da_geometry *geo, xfs_dir2_db_t db) xfs_dir3_db_to_fdindex(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
{ {
return db % xfs_dir3_free_max_bests(geo); return db % geo->free_max_bests;
} }
static const struct xfs_dir_ops xfs_dir2_ops = { static const struct xfs_dir_ops xfs_dir2_ops = {
...@@ -486,7 +468,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { ...@@ -486,7 +468,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = {
.data_entry_p = xfs_dir2_data_entry_p, .data_entry_p = xfs_dir2_data_entry_p,
.data_unused_p = xfs_dir2_data_unused_p, .data_unused_p = xfs_dir2_data_unused_p,
.free_max_bests = xfs_dir2_free_max_bests,
.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,
}; };
...@@ -521,7 +502,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { ...@@ -521,7 +502,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = {
.data_entry_p = xfs_dir2_data_entry_p, .data_entry_p = xfs_dir2_data_entry_p,
.data_unused_p = xfs_dir2_data_unused_p, .data_unused_p = xfs_dir2_data_unused_p,
.free_max_bests = xfs_dir2_free_max_bests,
.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,
}; };
...@@ -556,7 +536,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = { ...@@ -556,7 +536,6 @@ static const struct xfs_dir_ops xfs_dir3_ops = {
.data_entry_p = xfs_dir3_data_entry_p, .data_entry_p = xfs_dir3_data_entry_p,
.data_unused_p = xfs_dir3_data_unused_p, .data_unused_p = xfs_dir3_data_unused_p,
.free_max_bests = xfs_dir3_free_max_bests,
.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,
}; };
......
...@@ -133,6 +133,8 @@ xfs_da_mount( ...@@ -133,6 +133,8 @@ xfs_da_mount(
} }
dageo->leaf_max_ents = (dageo->blksize - dageo->leaf_hdr_size) / dageo->leaf_max_ents = (dageo->blksize - dageo->leaf_hdr_size) /
sizeof(struct xfs_dir2_leaf_entry); sizeof(struct xfs_dir2_leaf_entry);
dageo->free_max_bests = (dageo->blksize - dageo->free_hdr_size) /
sizeof(xfs_dir2_data_off_t);
/* /*
* Now we've set up the block conversion variables, we can calculate the * Now we've set up the block conversion variables, we can calculate the
......
...@@ -72,7 +72,6 @@ struct xfs_dir_ops { ...@@ -72,7 +72,6 @@ struct xfs_dir_ops {
struct xfs_dir2_data_unused * struct xfs_dir2_data_unused *
(*data_unused_p)(struct xfs_dir2_data_hdr *hdr); (*data_unused_p)(struct xfs_dir2_data_hdr *hdr);
int (*free_max_bests)(struct xfs_da_geometry *geo);
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,
......
...@@ -160,10 +160,9 @@ xfs_dir3_free_header_check( ...@@ -160,10 +160,9 @@ xfs_dir3_free_header_check(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
struct xfs_mount *mp = dp->i_mount; struct xfs_mount *mp = dp->i_mount;
int maxbests = mp->m_dir_geo->free_max_bests;
unsigned int firstdb; unsigned int firstdb;
int maxbests;
maxbests = dp->d_ops->free_max_bests(mp->m_dir_geo);
firstdb = (xfs_dir2_da_to_db(mp->m_dir_geo, fbno) - firstdb = (xfs_dir2_da_to_db(mp->m_dir_geo, fbno) -
xfs_dir2_byte_to_db(mp->m_dir_geo, XFS_DIR2_FREE_OFFSET)) * xfs_dir2_byte_to_db(mp->m_dir_geo, XFS_DIR2_FREE_OFFSET)) *
maxbests; maxbests;
...@@ -562,8 +561,7 @@ xfs_dir2_free_hdr_check( ...@@ -562,8 +561,7 @@ xfs_dir2_free_hdr_check(
xfs_dir2_free_hdr_from_disk(dp->i_mount, &hdr, bp->b_addr); xfs_dir2_free_hdr_from_disk(dp->i_mount, &hdr, bp->b_addr);
ASSERT((hdr.firstdb % ASSERT((hdr.firstdb % dp->i_mount->m_dir_geo->free_max_bests) == 0);
dp->d_ops->free_max_bests(dp->i_mount->m_dir_geo)) == 0);
ASSERT(hdr.firstdb <= db); ASSERT(hdr.firstdb <= db);
ASSERT(db < hdr.firstdb + hdr.nvalid); ASSERT(db < hdr.firstdb + hdr.nvalid);
} }
...@@ -1340,7 +1338,7 @@ xfs_dir2_leafn_remove( ...@@ -1340,7 +1338,7 @@ xfs_dir2_leafn_remove(
struct xfs_dir3_icfree_hdr freehdr; struct xfs_dir3_icfree_hdr freehdr;
xfs_dir2_free_hdr_from_disk(dp->i_mount, &freehdr, free); xfs_dir2_free_hdr_from_disk(dp->i_mount, &freehdr, free);
ASSERT(freehdr.firstdb == dp->d_ops->free_max_bests(args->geo) * ASSERT(freehdr.firstdb == args->geo->free_max_bests *
(fdb - xfs_dir2_byte_to_db(args->geo, (fdb - xfs_dir2_byte_to_db(args->geo,
XFS_DIR2_FREE_OFFSET))); XFS_DIR2_FREE_OFFSET)));
} }
...@@ -1733,7 +1731,7 @@ xfs_dir2_node_add_datablk( ...@@ -1733,7 +1731,7 @@ xfs_dir2_node_add_datablk(
/* Remember the first slot as our empty slot. */ /* Remember the first slot as our empty slot. */
hdr->firstdb = (fbno - xfs_dir2_byte_to_db(args->geo, hdr->firstdb = (fbno - xfs_dir2_byte_to_db(args->geo,
XFS_DIR2_FREE_OFFSET)) * XFS_DIR2_FREE_OFFSET)) *
dp->d_ops->free_max_bests(args->geo); args->geo->free_max_bests;
} else { } else {
xfs_dir2_free_hdr_from_disk(mp, hdr, fbp->b_addr); xfs_dir2_free_hdr_from_disk(mp, hdr, fbp->b_addr);
} }
...@@ -1743,7 +1741,7 @@ xfs_dir2_node_add_datablk( ...@@ -1743,7 +1741,7 @@ xfs_dir2_node_add_datablk(
/* Extend the freespace table if the new data block is off the end. */ /* Extend the freespace table if the new data block is off the end. */
if (*findex >= hdr->nvalid) { if (*findex >= hdr->nvalid) {
ASSERT(*findex < dp->d_ops->free_max_bests(args->geo)); ASSERT(*findex < args->geo->free_max_bests);
hdr->nvalid = *findex + 1; hdr->nvalid = *findex + 1;
hdr->bests[*findex] = cpu_to_be16(NULLDATAOFF); hdr->bests[*findex] = cpu_to_be16(NULLDATAOFF);
} }
......
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