Commit 8f66193c authored by Dave Chinner's avatar Dave Chinner Committed by Dave Chinner

xfs: convert m_dirblksize to xfs_da_geometry

Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent d6cf1305
...@@ -2169,8 +2169,8 @@ xfs_da3_swap_lastblock( ...@@ -2169,8 +2169,8 @@ xfs_da3_swap_lastblock(
/* /*
* Copy the last block into the dead buffer and log it. * Copy the last block into the dead buffer and log it.
*/ */
memcpy(dead_buf->b_addr, last_buf->b_addr, mp->m_dirblksize); memcpy(dead_buf->b_addr, last_buf->b_addr, args->geo->blksize);
xfs_trans_log_buf(tp, dead_buf, 0, mp->m_dirblksize - 1); xfs_trans_log_buf(tp, dead_buf, 0, args->geo->blksize - 1);
dead_info = dead_buf->b_addr; dead_info = dead_buf->b_addr;
/* /*
* Get values from the moved block. * Get values from the moved block.
......
...@@ -427,9 +427,9 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr) ...@@ -427,9 +427,9 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr)
* Directory Leaf block operations * Directory Leaf block operations
*/ */
static int static int
xfs_dir2_max_leaf_ents(struct xfs_mount *mp) xfs_dir2_max_leaf_ents(struct xfs_da_geometry *geo)
{ {
return (mp->m_dirblksize - sizeof(struct xfs_dir2_leaf_hdr)) / return (geo->blksize - sizeof(struct xfs_dir2_leaf_hdr)) /
(uint)sizeof(struct xfs_dir2_leaf_entry); (uint)sizeof(struct xfs_dir2_leaf_entry);
} }
...@@ -440,9 +440,9 @@ xfs_dir2_leaf_ents_p(struct xfs_dir2_leaf *lp) ...@@ -440,9 +440,9 @@ xfs_dir2_leaf_ents_p(struct xfs_dir2_leaf *lp)
} }
static int static int
xfs_dir3_max_leaf_ents(struct xfs_mount *mp) xfs_dir3_max_leaf_ents(struct xfs_da_geometry *geo)
{ {
return (mp->m_dirblksize - sizeof(struct xfs_dir3_leaf_hdr)) / return (geo->blksize - sizeof(struct xfs_dir3_leaf_hdr)) /
(uint)sizeof(struct xfs_dir2_leaf_entry); (uint)sizeof(struct xfs_dir2_leaf_entry);
} }
...@@ -593,9 +593,9 @@ xfs_da3_node_hdr_to_disk( ...@@ -593,9 +593,9 @@ xfs_da3_node_hdr_to_disk(
* Directory free space block operations * Directory free space block operations
*/ */
static int static int
xfs_dir2_free_max_bests(struct xfs_mount *mp) xfs_dir2_free_max_bests(struct xfs_da_geometry *geo)
{ {
return (mp->m_dirblksize - sizeof(struct xfs_dir2_free_hdr)) / return (geo->blksize - sizeof(struct xfs_dir2_free_hdr)) /
sizeof(xfs_dir2_data_off_t); sizeof(xfs_dir2_data_off_t);
} }
...@@ -609,25 +609,25 @@ xfs_dir2_free_bests_p(struct xfs_dir2_free *free) ...@@ -609,25 +609,25 @@ xfs_dir2_free_bests_p(struct xfs_dir2_free *free)
* Convert data space db to the corresponding free db. * Convert data space db to the corresponding free db.
*/ */
static xfs_dir2_db_t static xfs_dir2_db_t
xfs_dir2_db_to_fdb(struct xfs_mount *mp, 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(mp->m_dir_geo, XFS_DIR2_FREE_OFFSET) + return xfs_dir2_byte_to_db(geo, XFS_DIR2_FREE_OFFSET) +
(db / xfs_dir2_free_max_bests(mp)); (db / xfs_dir2_free_max_bests(geo));
} }
/* /*
* Convert data space db to the corresponding index in a free db. * Convert data space db to the corresponding index in a free db.
*/ */
static int static int
xfs_dir2_db_to_fdindex(struct xfs_mount *mp, 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(mp); return db % xfs_dir2_free_max_bests(geo);
} }
static int static int
xfs_dir3_free_max_bests(struct xfs_mount *mp) xfs_dir3_free_max_bests(struct xfs_da_geometry *geo)
{ {
return (mp->m_dirblksize - sizeof(struct xfs_dir3_free_hdr)) / return (geo->blksize - sizeof(struct xfs_dir3_free_hdr)) /
sizeof(xfs_dir2_data_off_t); sizeof(xfs_dir2_data_off_t);
} }
...@@ -641,19 +641,19 @@ xfs_dir3_free_bests_p(struct xfs_dir2_free *free) ...@@ -641,19 +641,19 @@ xfs_dir3_free_bests_p(struct xfs_dir2_free *free)
* Convert data space db to the corresponding free db. * Convert data space db to the corresponding free db.
*/ */
static xfs_dir2_db_t static xfs_dir2_db_t
xfs_dir3_db_to_fdb(struct xfs_mount *mp, 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(mp->m_dir_geo, XFS_DIR2_FREE_OFFSET) + return xfs_dir2_byte_to_db(geo, XFS_DIR2_FREE_OFFSET) +
(db / xfs_dir3_free_max_bests(mp)); (db / xfs_dir3_free_max_bests(geo));
} }
/* /*
* Convert data space db to the corresponding index in a free db. * Convert data space db to the corresponding index in a free db.
*/ */
static int static int
xfs_dir3_db_to_fdindex(struct xfs_mount *mp, 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(mp); return db % xfs_dir3_free_max_bests(geo);
} }
static void static void
......
...@@ -145,7 +145,6 @@ xfs_da_mount( ...@@ -145,7 +145,6 @@ xfs_da_mount(
mp->m_dirnameops = &xfs_default_nameops; mp->m_dirnameops = &xfs_default_nameops;
/* XXX: these are to be removed as code is converted to use geo */ /* XXX: these are to be removed as code is converted to use geo */
mp->m_dirblksize = mp->m_dir_geo->blksize;
mp->m_dir_node_ents = mp->m_dir_geo->node_ents; mp->m_dir_node_ents = mp->m_dir_geo->node_ents;
mp->m_dir_magicpct = mp->m_dir_geo->magicpct; mp->m_dir_magicpct = mp->m_dir_geo->magicpct;
mp->m_attr_node_ents = mp->m_attr_geo->node_ents; mp->m_attr_node_ents = mp->m_attr_geo->node_ents;
...@@ -665,8 +664,8 @@ xfs_dir2_isblock( ...@@ -665,8 +664,8 @@ xfs_dir2_isblock(
mp = dp->i_mount; mp = dp->i_mount;
if ((rval = xfs_bmap_last_offset(dp, &last, XFS_DATA_FORK))) if ((rval = xfs_bmap_last_offset(dp, &last, XFS_DATA_FORK)))
return rval; return rval;
rval = XFS_FSB_TO_B(mp, last) == mp->m_dirblksize; rval = XFS_FSB_TO_B(mp, last) == mp->m_dir_geo->blksize;
ASSERT(rval == 0 || dp->i_d.di_size == mp->m_dirblksize); ASSERT(rval == 0 || dp->i_d.di_size == mp->m_dir_geo->blksize);
*vp = rval; *vp = rval;
return 0; return 0;
} }
......
...@@ -80,7 +80,7 @@ struct xfs_dir_ops { ...@@ -80,7 +80,7 @@ struct xfs_dir_ops {
struct xfs_dir3_icleaf_hdr *from); struct xfs_dir3_icleaf_hdr *from);
void (*leaf_hdr_from_disk)(struct xfs_dir3_icleaf_hdr *to, void (*leaf_hdr_from_disk)(struct xfs_dir3_icleaf_hdr *to,
struct xfs_dir2_leaf *from); struct xfs_dir2_leaf *from);
int (*leaf_max_ents)(struct xfs_mount *mp); int (*leaf_max_ents)(struct xfs_da_geometry *geo);
struct xfs_dir2_leaf_entry * struct xfs_dir2_leaf_entry *
(*leaf_ents_p)(struct xfs_dir2_leaf *lp); (*leaf_ents_p)(struct xfs_dir2_leaf *lp);
...@@ -97,10 +97,12 @@ struct xfs_dir_ops { ...@@ -97,10 +97,12 @@ struct xfs_dir_ops {
struct xfs_dir3_icfree_hdr *from); struct xfs_dir3_icfree_hdr *from);
void (*free_hdr_from_disk)(struct xfs_dir3_icfree_hdr *to, void (*free_hdr_from_disk)(struct xfs_dir3_icfree_hdr *to,
struct xfs_dir2_free *from); struct xfs_dir2_free *from);
int (*free_max_bests)(struct xfs_mount *mp); int (*free_max_bests)(struct xfs_da_geometry *geo);
__be16 * (*free_bests_p)(struct xfs_dir2_free *free); __be16 * (*free_bests_p)(struct xfs_dir2_free *free);
xfs_dir2_db_t (*db_to_fdb)(struct xfs_mount *mp, xfs_dir2_db_t db); xfs_dir2_db_t (*db_to_fdb)(struct xfs_da_geometry *geo,
int (*db_to_fdindex)(struct xfs_mount *mp, xfs_dir2_db_t db); xfs_dir2_db_t db);
int (*db_to_fdindex)(struct xfs_da_geometry *geo,
xfs_dir2_db_t db);
}; };
extern const struct xfs_dir_ops * extern const struct xfs_dir_ops *
......
...@@ -377,7 +377,7 @@ xfs_dir2_block_addname( ...@@ -377,7 +377,7 @@ xfs_dir2_block_addname(
* Set up pointers to parts of the block. * Set up pointers to parts of the block.
*/ */
hdr = bp->b_addr; hdr = bp->b_addr;
btp = xfs_dir2_block_tail_p(mp, hdr); btp = xfs_dir2_block_tail_p(args->geo, hdr);
blp = xfs_dir2_block_leaf_p(btp); blp = xfs_dir2_block_leaf_p(btp);
/* /*
...@@ -581,7 +581,7 @@ xfs_dir2_block_log_leaf( ...@@ -581,7 +581,7 @@ xfs_dir2_block_log_leaf(
xfs_dir2_leaf_entry_t *blp; xfs_dir2_leaf_entry_t *blp;
xfs_dir2_block_tail_t *btp; xfs_dir2_block_tail_t *btp;
btp = xfs_dir2_block_tail_p(tp->t_mountp, hdr); btp = xfs_dir2_block_tail_p(tp->t_mountp->m_dir_geo, hdr);
blp = xfs_dir2_block_leaf_p(btp); blp = xfs_dir2_block_leaf_p(btp);
xfs_trans_log_buf(tp, bp, (uint)((char *)&blp[first] - (char *)hdr), xfs_trans_log_buf(tp, bp, (uint)((char *)&blp[first] - (char *)hdr),
(uint)((char *)&blp[last + 1] - (char *)hdr - 1)); (uint)((char *)&blp[last + 1] - (char *)hdr - 1));
...@@ -598,7 +598,7 @@ xfs_dir2_block_log_tail( ...@@ -598,7 +598,7 @@ xfs_dir2_block_log_tail(
xfs_dir2_data_hdr_t *hdr = bp->b_addr; xfs_dir2_data_hdr_t *hdr = bp->b_addr;
xfs_dir2_block_tail_t *btp; xfs_dir2_block_tail_t *btp;
btp = xfs_dir2_block_tail_p(tp->t_mountp, hdr); btp = xfs_dir2_block_tail_p(tp->t_mountp->m_dir_geo, hdr);
xfs_trans_log_buf(tp, bp, (uint)((char *)btp - (char *)hdr), xfs_trans_log_buf(tp, bp, (uint)((char *)btp - (char *)hdr),
(uint)((char *)(btp + 1) - (char *)hdr - 1)); (uint)((char *)(btp + 1) - (char *)hdr - 1));
} }
...@@ -633,7 +633,7 @@ xfs_dir2_block_lookup( ...@@ -633,7 +633,7 @@ xfs_dir2_block_lookup(
mp = dp->i_mount; mp = dp->i_mount;
hdr = bp->b_addr; hdr = bp->b_addr;
xfs_dir3_data_check(dp, bp); xfs_dir3_data_check(dp, bp);
btp = xfs_dir2_block_tail_p(mp, hdr); btp = xfs_dir2_block_tail_p(args->geo, hdr);
blp = xfs_dir2_block_leaf_p(btp); blp = xfs_dir2_block_leaf_p(btp);
/* /*
* Get the offset from the leaf entry, to point to the data. * Get the offset from the leaf entry, to point to the data.
...@@ -686,7 +686,7 @@ xfs_dir2_block_lookup_int( ...@@ -686,7 +686,7 @@ xfs_dir2_block_lookup_int(
hdr = bp->b_addr; hdr = bp->b_addr;
xfs_dir3_data_check(dp, bp); xfs_dir3_data_check(dp, bp);
btp = xfs_dir2_block_tail_p(mp, hdr); btp = xfs_dir2_block_tail_p(args->geo, hdr);
blp = xfs_dir2_block_leaf_p(btp); blp = xfs_dir2_block_leaf_p(btp);
/* /*
* Loop doing a binary search for our hash value. * Loop doing a binary search for our hash value.
...@@ -791,7 +791,7 @@ xfs_dir2_block_removename( ...@@ -791,7 +791,7 @@ xfs_dir2_block_removename(
tp = args->trans; tp = args->trans;
mp = dp->i_mount; mp = dp->i_mount;
hdr = bp->b_addr; hdr = bp->b_addr;
btp = xfs_dir2_block_tail_p(mp, hdr); btp = xfs_dir2_block_tail_p(args->geo, hdr);
blp = xfs_dir2_block_leaf_p(btp); blp = xfs_dir2_block_leaf_p(btp);
/* /*
* Point to the data entry using the leaf entry. * Point to the data entry using the leaf entry.
...@@ -867,7 +867,7 @@ xfs_dir2_block_replace( ...@@ -867,7 +867,7 @@ xfs_dir2_block_replace(
dp = args->dp; dp = args->dp;
mp = dp->i_mount; mp = dp->i_mount;
hdr = bp->b_addr; hdr = bp->b_addr;
btp = xfs_dir2_block_tail_p(mp, hdr); btp = xfs_dir2_block_tail_p(args->geo, hdr);
blp = xfs_dir2_block_leaf_p(btp); blp = xfs_dir2_block_leaf_p(btp);
/* /*
* Point to the data entry we need to change. * Point to the data entry we need to change.
...@@ -941,7 +941,7 @@ xfs_dir2_leaf_to_block( ...@@ -941,7 +941,7 @@ xfs_dir2_leaf_to_block(
leaf = lbp->b_addr; leaf = lbp->b_addr;
dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf); dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
ents = dp->d_ops->leaf_ents_p(leaf); ents = dp->d_ops->leaf_ents_p(leaf);
ltp = xfs_dir2_leaf_tail_p(mp, leaf); ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
ASSERT(leafhdr.magic == XFS_DIR2_LEAF1_MAGIC || ASSERT(leafhdr.magic == XFS_DIR2_LEAF1_MAGIC ||
leafhdr.magic == XFS_DIR3_LEAF1_MAGIC); leafhdr.magic == XFS_DIR3_LEAF1_MAGIC);
...@@ -951,13 +951,13 @@ xfs_dir2_leaf_to_block( ...@@ -951,13 +951,13 @@ xfs_dir2_leaf_to_block(
* been left behind during no-space-reservation operations. * been left behind during no-space-reservation operations.
* These will show up in the leaf bests table. * These will show up in the leaf bests table.
*/ */
while (dp->i_d.di_size > mp->m_dirblksize) { while (dp->i_d.di_size > args->geo->blksize) {
int hdrsz; int hdrsz;
hdrsz = dp->d_ops->data_entry_offset; hdrsz = dp->d_ops->data_entry_offset;
bestsp = xfs_dir2_leaf_bests_p(ltp); bestsp = xfs_dir2_leaf_bests_p(ltp);
if (be16_to_cpu(bestsp[be32_to_cpu(ltp->bestcount) - 1]) == if (be16_to_cpu(bestsp[be32_to_cpu(ltp->bestcount) - 1]) ==
mp->m_dirblksize - hdrsz) { args->geo->blksize - hdrsz) {
if ((error = if ((error =
xfs_dir2_leaf_trim_data(args, lbp, xfs_dir2_leaf_trim_data(args, lbp,
(xfs_dir2_db_t)(be32_to_cpu(ltp->bestcount) - 1)))) (xfs_dir2_db_t)(be32_to_cpu(ltp->bestcount) - 1))))
...@@ -985,7 +985,7 @@ xfs_dir2_leaf_to_block( ...@@ -985,7 +985,7 @@ xfs_dir2_leaf_to_block(
/* /*
* Look at the last data entry. * Look at the last data entry.
*/ */
tagp = (__be16 *)((char *)hdr + mp->m_dirblksize) - 1; tagp = (__be16 *)((char *)hdr + args->geo->blksize) - 1;
dup = (xfs_dir2_data_unused_t *)((char *)hdr + be16_to_cpu(*tagp)); dup = (xfs_dir2_data_unused_t *)((char *)hdr + be16_to_cpu(*tagp));
/* /*
* If it's not free or is too short we can't do it. * If it's not free or is too short we can't do it.
...@@ -1004,12 +1004,12 @@ xfs_dir2_leaf_to_block( ...@@ -1004,12 +1004,12 @@ xfs_dir2_leaf_to_block(
/* /*
* Use up the space at the end of the block (blp/btp). * Use up the space at the end of the block (blp/btp).
*/ */
xfs_dir2_data_use_free(tp, dp, dbp, dup, mp->m_dirblksize - size, size, xfs_dir2_data_use_free(tp, dp, dbp, dup, args->geo->blksize - size, size,
&needlog, &needscan); &needlog, &needscan);
/* /*
* Initialize the block tail. * Initialize the block tail.
*/ */
btp = xfs_dir2_block_tail_p(mp, hdr); btp = xfs_dir2_block_tail_p(args->geo, hdr);
btp->count = cpu_to_be32(leafhdr.count - leafhdr.stale); btp->count = cpu_to_be32(leafhdr.count - leafhdr.stale);
btp->stale = 0; btp->stale = 0;
xfs_dir2_block_log_tail(tp, dbp); xfs_dir2_block_log_tail(tp, dbp);
...@@ -1143,13 +1143,13 @@ xfs_dir2_sf_to_block( ...@@ -1143,13 +1143,13 @@ xfs_dir2_sf_to_block(
*/ */
dup = dp->d_ops->data_unused_p(hdr); dup = dp->d_ops->data_unused_p(hdr);
needlog = needscan = 0; needlog = needscan = 0;
xfs_dir2_data_use_free(tp, dp, bp, dup, mp->m_dirblksize - i, i, &needlog, xfs_dir2_data_use_free(tp, dp, bp, dup, args->geo->blksize - i,
&needscan); i, &needlog, &needscan);
ASSERT(needscan == 0); ASSERT(needscan == 0);
/* /*
* Fill in the tail. * Fill in the tail.
*/ */
btp = xfs_dir2_block_tail_p(mp, hdr); btp = xfs_dir2_block_tail_p(args->geo, hdr);
btp->count = cpu_to_be32(sfp->count + 2); /* ., .. */ btp->count = cpu_to_be32(sfp->count + 2); /* ., .. */
btp->stale = 0; btp->stale = 0;
blp = xfs_dir2_block_leaf_p(btp); blp = xfs_dir2_block_leaf_p(btp);
......
...@@ -80,7 +80,7 @@ __xfs_dir3_data_check( ...@@ -80,7 +80,7 @@ __xfs_dir3_data_check(
switch (hdr->magic) { switch (hdr->magic) {
case cpu_to_be32(XFS_DIR3_BLOCK_MAGIC): case cpu_to_be32(XFS_DIR3_BLOCK_MAGIC):
case cpu_to_be32(XFS_DIR2_BLOCK_MAGIC): case cpu_to_be32(XFS_DIR2_BLOCK_MAGIC):
btp = xfs_dir2_block_tail_p(mp, hdr); btp = xfs_dir2_block_tail_p(geo, hdr);
lep = xfs_dir2_block_leaf_p(btp); lep = xfs_dir2_block_leaf_p(btp);
endp = (char *)lep; endp = (char *)lep;
...@@ -96,7 +96,7 @@ __xfs_dir3_data_check( ...@@ -96,7 +96,7 @@ __xfs_dir3_data_check(
break; break;
case cpu_to_be32(XFS_DIR3_DATA_MAGIC): case cpu_to_be32(XFS_DIR3_DATA_MAGIC):
case cpu_to_be32(XFS_DIR2_DATA_MAGIC): case cpu_to_be32(XFS_DIR2_DATA_MAGIC):
endp = (char *)hdr + mp->m_dirblksize; endp = (char *)hdr + geo->blksize;
break; break;
default: default:
XFS_ERROR_REPORT("Bad Magic", XFS_ERRLEVEL_LOW, mp); XFS_ERROR_REPORT("Bad Magic", XFS_ERRLEVEL_LOW, mp);
...@@ -511,6 +511,7 @@ xfs_dir2_data_freescan( ...@@ -511,6 +511,7 @@ xfs_dir2_data_freescan(
struct xfs_dir2_data_free *bf; struct xfs_dir2_data_free *bf;
char *endp; /* end of block's data */ char *endp; /* end of block's data */
char *p; /* current entry pointer */ char *p; /* current entry pointer */
struct xfs_da_geometry *geo = dp->i_mount->m_dir_geo;
ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) || hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) ||
...@@ -529,10 +530,10 @@ xfs_dir2_data_freescan( ...@@ -529,10 +530,10 @@ xfs_dir2_data_freescan(
p = (char *)dp->d_ops->data_entry_p(hdr); p = (char *)dp->d_ops->data_entry_p(hdr);
if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) || if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) { hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) {
btp = xfs_dir2_block_tail_p(dp->i_mount, hdr); btp = xfs_dir2_block_tail_p(geo, hdr);
endp = (char *)xfs_dir2_block_leaf_p(btp); endp = (char *)xfs_dir2_block_leaf_p(btp);
} else } else
endp = (char *)hdr + dp->i_mount->m_dirblksize; endp = (char *)hdr + geo->blksize;
/* /*
* Loop over the block's entries. * Loop over the block's entries.
*/ */
...@@ -622,7 +623,7 @@ xfs_dir3_data_init( ...@@ -622,7 +623,7 @@ xfs_dir3_data_init(
dup = dp->d_ops->data_unused_p(hdr); dup = dp->d_ops->data_unused_p(hdr);
dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
t = mp->m_dirblksize - (uint)dp->d_ops->data_entry_offset; t = args->geo->blksize - (uint)dp->d_ops->data_entry_offset;
bf[0].length = cpu_to_be16(t); bf[0].length = cpu_to_be16(t);
dup->length = cpu_to_be16(t); dup->length = cpu_to_be16(t);
*xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16((char *)dup - (char *)hdr); *xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16((char *)dup - (char *)hdr);
...@@ -732,22 +733,24 @@ xfs_dir2_data_make_free( ...@@ -732,22 +733,24 @@ xfs_dir2_data_make_free(
xfs_dir2_data_unused_t *postdup; /* unused entry after us */ xfs_dir2_data_unused_t *postdup; /* unused entry after us */
xfs_dir2_data_unused_t *prevdup; /* unused entry before us */ xfs_dir2_data_unused_t *prevdup; /* unused entry before us */
struct xfs_dir2_data_free *bf; struct xfs_dir2_data_free *bf;
struct xfs_da_geometry *geo;
mp = tp->t_mountp; mp = tp->t_mountp;
hdr = bp->b_addr; hdr = bp->b_addr;
geo = mp->m_dir_geo;
/* /*
* Figure out where the end of the data area is. * Figure out where the end of the data area is.
*/ */
if (hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || if (hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC)) hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC))
endptr = (char *)hdr + mp->m_dirblksize; endptr = (char *)hdr + geo->blksize;
else { else {
xfs_dir2_block_tail_t *btp; /* block tail */ xfs_dir2_block_tail_t *btp; /* block tail */
ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) || ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)); hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC));
btp = xfs_dir2_block_tail_p(mp, hdr); btp = xfs_dir2_block_tail_p(geo, hdr);
endptr = (char *)xfs_dir2_block_leaf_p(btp); endptr = (char *)xfs_dir2_block_leaf_p(btp);
} }
/* /*
......
...@@ -92,6 +92,7 @@ xfs_dir3_leaf_check_int( ...@@ -92,6 +92,7 @@ xfs_dir3_leaf_check_int(
int i; int i;
const struct xfs_dir_ops *ops; const struct xfs_dir_ops *ops;
struct xfs_dir3_icleaf_hdr leafhdr; struct xfs_dir3_icleaf_hdr leafhdr;
struct xfs_da_geometry *geo = mp->m_dir_geo;
/* /*
* we can be passed a null dp here from a verifier, so we need to go the * we can be passed a null dp here from a verifier, so we need to go the
...@@ -105,14 +106,14 @@ xfs_dir3_leaf_check_int( ...@@ -105,14 +106,14 @@ xfs_dir3_leaf_check_int(
} }
ents = ops->leaf_ents_p(leaf); ents = ops->leaf_ents_p(leaf);
ltp = xfs_dir2_leaf_tail_p(mp, leaf); ltp = xfs_dir2_leaf_tail_p(geo, leaf);
/* /*
* XXX (dgc): This value is not restrictive enough. * XXX (dgc): This value is not restrictive enough.
* Should factor in the size of the bests table as well. * Should factor in the size of the bests table as well.
* We can deduce a value for that from di_size. * We can deduce a value for that from di_size.
*/ */
if (hdr->count > ops->leaf_max_ents(mp)) if (hdr->count > ops->leaf_max_ents(geo))
return false; return false;
/* Leaves and bests don't overlap in leaf format. */ /* Leaves and bests don't overlap in leaf format. */
...@@ -323,7 +324,7 @@ xfs_dir3_leaf_init( ...@@ -323,7 +324,7 @@ xfs_dir3_leaf_init(
if (type == XFS_DIR2_LEAF1_MAGIC) { if (type == XFS_DIR2_LEAF1_MAGIC) {
struct xfs_dir2_leaf_tail *ltp; struct xfs_dir2_leaf_tail *ltp;
ltp = xfs_dir2_leaf_tail_p(mp, leaf); ltp = xfs_dir2_leaf_tail_p(mp->m_dir_geo, leaf);
ltp->bestcount = 0; ltp->bestcount = 0;
bp->b_ops = &xfs_dir3_leaf1_buf_ops; bp->b_ops = &xfs_dir3_leaf1_buf_ops;
xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DIR_LEAF1_BUF); xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DIR_LEAF1_BUF);
...@@ -415,7 +416,7 @@ xfs_dir2_block_to_leaf( ...@@ -415,7 +416,7 @@ xfs_dir2_block_to_leaf(
leaf = lbp->b_addr; leaf = lbp->b_addr;
hdr = dbp->b_addr; hdr = dbp->b_addr;
xfs_dir3_data_check(dp, dbp); xfs_dir3_data_check(dp, dbp);
btp = xfs_dir2_block_tail_p(mp, hdr); btp = xfs_dir2_block_tail_p(args->geo, hdr);
blp = xfs_dir2_block_leaf_p(btp); blp = xfs_dir2_block_leaf_p(btp);
bf = dp->d_ops->data_bestfree_p(hdr); bf = dp->d_ops->data_bestfree_p(hdr);
ents = dp->d_ops->leaf_ents_p(leaf); ents = dp->d_ops->leaf_ents_p(leaf);
...@@ -443,7 +444,7 @@ xfs_dir2_block_to_leaf( ...@@ -443,7 +444,7 @@ xfs_dir2_block_to_leaf(
*/ */
xfs_dir2_data_make_free(tp, dp, dbp, xfs_dir2_data_make_free(tp, dp, dbp,
(xfs_dir2_data_aoff_t)((char *)blp - (char *)hdr), (xfs_dir2_data_aoff_t)((char *)blp - (char *)hdr),
(xfs_dir2_data_aoff_t)((char *)hdr + mp->m_dirblksize - (xfs_dir2_data_aoff_t)((char *)hdr + args->geo->blksize -
(char *)blp), (char *)blp),
&needlog, &needscan); &needlog, &needscan);
/* /*
...@@ -461,7 +462,7 @@ xfs_dir2_block_to_leaf( ...@@ -461,7 +462,7 @@ xfs_dir2_block_to_leaf(
/* /*
* Set up leaf tail and bests table. * Set up leaf tail and bests table.
*/ */
ltp = xfs_dir2_leaf_tail_p(mp, leaf); ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
ltp->bestcount = cpu_to_be32(1); ltp->bestcount = cpu_to_be32(1);
bestsp = xfs_dir2_leaf_bests_p(ltp); bestsp = xfs_dir2_leaf_bests_p(ltp);
bestsp[0] = bf[0].length; bestsp[0] = bf[0].length;
...@@ -653,7 +654,7 @@ xfs_dir2_leaf_addname( ...@@ -653,7 +654,7 @@ xfs_dir2_leaf_addname(
*/ */
index = xfs_dir2_leaf_search_hash(args, lbp); index = xfs_dir2_leaf_search_hash(args, lbp);
leaf = lbp->b_addr; leaf = lbp->b_addr;
ltp = xfs_dir2_leaf_tail_p(mp, leaf); ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
ents = dp->d_ops->leaf_ents_p(leaf); ents = dp->d_ops->leaf_ents_p(leaf);
dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf); dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
bestsp = xfs_dir2_leaf_bests_p(ltp); bestsp = xfs_dir2_leaf_bests_p(ltp);
...@@ -1066,7 +1067,7 @@ xfs_dir3_leaf_log_bests( ...@@ -1066,7 +1067,7 @@ xfs_dir3_leaf_log_bests(
ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) || ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) ||
leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAF1_MAGIC)); leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAF1_MAGIC));
ltp = xfs_dir2_leaf_tail_p(tp->t_mountp, leaf); ltp = xfs_dir2_leaf_tail_p(tp->t_mountp->m_dir_geo, leaf);
firstb = xfs_dir2_leaf_bests_p(ltp) + first; firstb = xfs_dir2_leaf_bests_p(ltp) + first;
lastb = xfs_dir2_leaf_bests_p(ltp) + last; lastb = xfs_dir2_leaf_bests_p(ltp) + last;
xfs_trans_log_buf(tp, bp, (uint)((char *)firstb - (char *)leaf), xfs_trans_log_buf(tp, bp, (uint)((char *)firstb - (char *)leaf),
...@@ -1138,9 +1139,9 @@ xfs_dir3_leaf_log_tail( ...@@ -1138,9 +1139,9 @@ xfs_dir3_leaf_log_tail(
leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) || leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)); leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC));
ltp = xfs_dir2_leaf_tail_p(mp, leaf); ltp = xfs_dir2_leaf_tail_p(mp->m_dir_geo, leaf);
xfs_trans_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf), xfs_trans_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf),
(uint)(mp->m_dirblksize - 1)); (uint)(mp->m_dir_geo->blksize - 1));
} }
/* /*
...@@ -1388,7 +1389,7 @@ xfs_dir2_leaf_removename( ...@@ -1388,7 +1389,7 @@ xfs_dir2_leaf_removename(
xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address))); xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address)));
needscan = needlog = 0; needscan = needlog = 0;
oldbest = be16_to_cpu(bf[0].length); oldbest = be16_to_cpu(bf[0].length);
ltp = xfs_dir2_leaf_tail_p(mp, leaf); ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
bestsp = xfs_dir2_leaf_bests_p(ltp); bestsp = xfs_dir2_leaf_bests_p(ltp);
ASSERT(be16_to_cpu(bestsp[db]) == oldbest); ASSERT(be16_to_cpu(bestsp[db]) == oldbest);
/* /*
...@@ -1428,7 +1429,7 @@ xfs_dir2_leaf_removename( ...@@ -1428,7 +1429,7 @@ xfs_dir2_leaf_removename(
* If the data block is now empty then get rid of the data block. * If the data block is now empty then get rid of the data block.
*/ */
if (be16_to_cpu(bf[0].length) == if (be16_to_cpu(bf[0].length) ==
mp->m_dirblksize - dp->d_ops->data_entry_offset) { args->geo->blksize - dp->d_ops->data_entry_offset) {
ASSERT(db != args->geo->datablk); ASSERT(db != args->geo->datablk);
if ((error = xfs_dir2_shrink_inode(args, db, dbp))) { if ((error = xfs_dir2_shrink_inode(args, db, dbp))) {
/* /*
...@@ -1618,7 +1619,7 @@ xfs_dir2_leaf_trim_data( ...@@ -1618,7 +1619,7 @@ xfs_dir2_leaf_trim_data(
return error; return error;
leaf = lbp->b_addr; leaf = lbp->b_addr;
ltp = xfs_dir2_leaf_tail_p(mp, leaf); ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
#ifdef DEBUG #ifdef DEBUG
{ {
...@@ -1628,7 +1629,7 @@ xfs_dir2_leaf_trim_data( ...@@ -1628,7 +1629,7 @@ xfs_dir2_leaf_trim_data(
ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC)); hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC));
ASSERT(be16_to_cpu(bf[0].length) == ASSERT(be16_to_cpu(bf[0].length) ==
mp->m_dirblksize - dp->d_ops->data_entry_offset); args->geo->blksize - dp->d_ops->data_entry_offset);
ASSERT(db == be32_to_cpu(ltp->bestcount) - 1); ASSERT(db == be32_to_cpu(ltp->bestcount) - 1);
} }
#endif #endif
...@@ -1740,7 +1741,7 @@ xfs_dir2_node_to_leaf( ...@@ -1740,7 +1741,7 @@ xfs_dir2_node_to_leaf(
/* /*
* If it's not the single leaf block, give up. * If it's not the single leaf block, give up.
*/ */
if (XFS_FSB_TO_B(mp, fo) > XFS_DIR2_LEAF_OFFSET + mp->m_dirblksize) if (XFS_FSB_TO_B(mp, fo) > XFS_DIR2_LEAF_OFFSET + args->geo->blksize)
return 0; return 0;
lbp = state->path.blk[0].bp; lbp = state->path.blk[0].bp;
leaf = lbp->b_addr; leaf = lbp->b_addr;
...@@ -1764,7 +1765,7 @@ xfs_dir2_node_to_leaf( ...@@ -1764,7 +1765,7 @@ xfs_dir2_node_to_leaf(
* Now see if the leafn and free data will fit in a leaf1. * Now see if the leafn and free data will fit in a leaf1.
* If not, release the buffer and give up. * If not, release the buffer and give up.
*/ */
if (xfs_dir3_leaf_size(&leafhdr, freehdr.nvalid) > mp->m_dirblksize) { if (xfs_dir3_leaf_size(&leafhdr, freehdr.nvalid) > args->geo->blksize) {
xfs_trans_brelse(tp, fbp); xfs_trans_brelse(tp, fbp);
return 0; return 0;
} }
...@@ -1784,7 +1785,7 @@ xfs_dir2_node_to_leaf( ...@@ -1784,7 +1785,7 @@ xfs_dir2_node_to_leaf(
/* /*
* Set up the leaf tail from the freespace block. * Set up the leaf tail from the freespace block.
*/ */
ltp = xfs_dir2_leaf_tail_p(mp, leaf); ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
ltp->bestcount = cpu_to_be32(freehdr.nvalid); ltp->bestcount = cpu_to_be32(freehdr.nvalid);
/* /*
......
...@@ -327,9 +327,9 @@ xfs_dir2_leaf_to_node( ...@@ -327,9 +327,9 @@ xfs_dir2_leaf_to_node(
free = fbp->b_addr; free = fbp->b_addr;
dp->d_ops->free_hdr_from_disk(&freehdr, free); dp->d_ops->free_hdr_from_disk(&freehdr, free);
leaf = lbp->b_addr; leaf = lbp->b_addr;
ltp = xfs_dir2_leaf_tail_p(mp, leaf); ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
ASSERT(be32_to_cpu(ltp->bestcount) <= ASSERT(be32_to_cpu(ltp->bestcount) <=
(uint)dp->i_d.di_size / mp->m_dirblksize); (uint)dp->i_d.di_size / args->geo->blksize);
/* /*
* Copy freespace entries from the leaf block to the new block. * Copy freespace entries from the leaf block to the new block.
...@@ -416,7 +416,7 @@ xfs_dir2_leafn_add( ...@@ -416,7 +416,7 @@ xfs_dir2_leafn_add(
* a compact. * a compact.
*/ */
if (leafhdr.count == dp->d_ops->leaf_max_ents(mp)) { if (leafhdr.count == dp->d_ops->leaf_max_ents(args->geo)) {
if (!leafhdr.stale) if (!leafhdr.stale)
return XFS_ERROR(ENOSPC); return XFS_ERROR(ENOSPC);
compact = leafhdr.stale > 1; compact = leafhdr.stale > 1;
...@@ -472,7 +472,8 @@ xfs_dir2_free_hdr_check( ...@@ -472,7 +472,8 @@ xfs_dir2_free_hdr_check(
dp->d_ops->free_hdr_from_disk(&hdr, bp->b_addr); dp->d_ops->free_hdr_from_disk(&hdr, bp->b_addr);
ASSERT((hdr.firstdb % dp->d_ops->free_max_bests(dp->i_mount)) == 0); ASSERT((hdr.firstdb %
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);
} }
...@@ -595,7 +596,7 @@ xfs_dir2_leafn_lookup_for_addname( ...@@ -595,7 +596,7 @@ xfs_dir2_leafn_lookup_for_addname(
* Convert the data block to the free block * Convert the data block to the free block
* holding its freespace information. * holding its freespace information.
*/ */
newfdb = dp->d_ops->db_to_fdb(mp, newdb); newfdb = dp->d_ops->db_to_fdb(args->geo, newdb);
/* /*
* If it's not the one we have in hand, read it in. * If it's not the one we have in hand, read it in.
*/ */
...@@ -619,7 +620,7 @@ xfs_dir2_leafn_lookup_for_addname( ...@@ -619,7 +620,7 @@ xfs_dir2_leafn_lookup_for_addname(
/* /*
* Get the index for our entry. * Get the index for our entry.
*/ */
fi = dp->d_ops->db_to_fdindex(mp, curdb); fi = dp->d_ops->db_to_fdindex(args->geo, curdb);
/* /*
* If it has room, return it. * If it has room, return it.
*/ */
...@@ -1251,7 +1252,7 @@ xfs_dir2_leafn_remove( ...@@ -1251,7 +1252,7 @@ xfs_dir2_leafn_remove(
* Convert the data block number to a free block, * Convert the data block number to a free block,
* read in the free block. * read in the free block.
*/ */
fdb = dp->d_ops->db_to_fdb(mp, db); fdb = dp->d_ops->db_to_fdb(args->geo, db);
error = xfs_dir2_free_read(tp, dp, error = xfs_dir2_free_read(tp, dp,
xfs_dir2_db_to_da(args->geo, fdb), xfs_dir2_db_to_da(args->geo, fdb),
&fbp); &fbp);
...@@ -1262,7 +1263,7 @@ xfs_dir2_leafn_remove( ...@@ -1262,7 +1263,7 @@ xfs_dir2_leafn_remove(
{ {
struct xfs_dir3_icfree_hdr freehdr; struct xfs_dir3_icfree_hdr freehdr;
dp->d_ops->free_hdr_from_disk(&freehdr, free); dp->d_ops->free_hdr_from_disk(&freehdr, free);
ASSERT(freehdr.firstdb == dp->d_ops->free_max_bests(mp) * ASSERT(freehdr.firstdb == dp->d_ops->free_max_bests(args->geo) *
(fdb - xfs_dir2_byte_to_db(args->geo, (fdb - xfs_dir2_byte_to_db(args->geo,
XFS_DIR2_FREE_OFFSET))); XFS_DIR2_FREE_OFFSET)));
} }
...@@ -1270,13 +1271,13 @@ xfs_dir2_leafn_remove( ...@@ -1270,13 +1271,13 @@ xfs_dir2_leafn_remove(
/* /*
* Calculate which entry we need to fix. * Calculate which entry we need to fix.
*/ */
findex = dp->d_ops->db_to_fdindex(mp, db); findex = dp->d_ops->db_to_fdindex(args->geo, db);
longest = be16_to_cpu(bf[0].length); longest = be16_to_cpu(bf[0].length);
/* /*
* If the data block is now empty we can get rid of it * If the data block is now empty we can get rid of it
* (usually). * (usually).
*/ */
if (longest == mp->m_dirblksize - if (longest == args->geo->blksize -
dp->d_ops->data_entry_offset) { dp->d_ops->data_entry_offset) {
/* /*
* Try to punch out the data block. * Try to punch out the data block.
...@@ -1595,7 +1596,7 @@ xfs_dir2_node_addname( ...@@ -1595,7 +1596,7 @@ xfs_dir2_node_addname(
state = xfs_da_state_alloc(); state = xfs_da_state_alloc();
state->args = args; state->args = args;
state->mp = args->dp->i_mount; state->mp = args->dp->i_mount;
state->blocksize = state->mp->m_dirblksize; state->blocksize = state->args->geo->blksize;
state->node_ents = state->mp->m_dir_node_ents; state->node_ents = state->mp->m_dir_node_ents;
/* /*
* Look up the name. We're not supposed to find it, but * Look up the name. We're not supposed to find it, but
...@@ -1843,7 +1844,7 @@ xfs_dir2_node_addname_int( ...@@ -1843,7 +1844,7 @@ xfs_dir2_node_addname_int(
* Get the freespace block corresponding to the data block * Get the freespace block corresponding to the data block
* that was just allocated. * that was just allocated.
*/ */
fbno = dp->d_ops->db_to_fdb(mp, dbno); fbno = dp->d_ops->db_to_fdb(args->geo, dbno);
error = xfs_dir2_free_try_read(tp, dp, error = xfs_dir2_free_try_read(tp, dp,
xfs_dir2_db_to_da(args->geo, fbno), xfs_dir2_db_to_da(args->geo, fbno),
&fbp); &fbp);
...@@ -1860,12 +1861,13 @@ xfs_dir2_node_addname_int( ...@@ -1860,12 +1861,13 @@ xfs_dir2_node_addname_int(
if (error) if (error)
return error; return error;
if (unlikely(dp->d_ops->db_to_fdb(mp, dbno) != fbno)) { if (dp->d_ops->db_to_fdb(args->geo, dbno) != fbno) {
xfs_alert(mp, xfs_alert(mp,
"%s: dir ino %llu needed freesp block %lld for\n" "%s: dir ino %llu needed freesp block %lld for\n"
" data block %lld, got %lld ifbno %llu lastfbno %d", " data block %lld, got %lld ifbno %llu lastfbno %d",
__func__, (unsigned long long)dp->i_ino, __func__, (unsigned long long)dp->i_ino,
(long long)dp->d_ops->db_to_fdb(mp, dbno), (long long)dp->d_ops->db_to_fdb(
args->geo, dbno),
(long long)dbno, (long long)fbno, (long long)dbno, (long long)fbno,
(unsigned long long)ifbno, lastfbno); (unsigned long long)ifbno, lastfbno);
if (fblk) { if (fblk) {
...@@ -1899,7 +1901,7 @@ xfs_dir2_node_addname_int( ...@@ -1899,7 +1901,7 @@ xfs_dir2_node_addname_int(
freehdr.firstdb = freehdr.firstdb =
(fbno - xfs_dir2_byte_to_db(args->geo, (fbno - xfs_dir2_byte_to_db(args->geo,
XFS_DIR2_FREE_OFFSET)) * XFS_DIR2_FREE_OFFSET)) *
dp->d_ops->free_max_bests(mp); dp->d_ops->free_max_bests(args->geo);
} else { } else {
free = fbp->b_addr; free = fbp->b_addr;
bests = dp->d_ops->free_bests_p(free); bests = dp->d_ops->free_bests_p(free);
...@@ -1909,13 +1911,13 @@ xfs_dir2_node_addname_int( ...@@ -1909,13 +1911,13 @@ xfs_dir2_node_addname_int(
/* /*
* Set the freespace block index from the data block number. * Set the freespace block index from the data block number.
*/ */
findex = dp->d_ops->db_to_fdindex(mp, dbno); findex = dp->d_ops->db_to_fdindex(args->geo, dbno);
/* /*
* If it's after the end of the current entries in the * If it's after the end of the current entries in the
* freespace block, extend that table. * freespace block, extend that table.
*/ */
if (findex >= freehdr.nvalid) { if (findex >= freehdr.nvalid) {
ASSERT(findex < dp->d_ops->free_max_bests(mp)); ASSERT(findex < dp->d_ops->free_max_bests(args->geo));
freehdr.nvalid = findex + 1; freehdr.nvalid = findex + 1;
/* /*
* Tag new entry so nused will go up. * Tag new entry so nused will go up.
...@@ -2040,7 +2042,7 @@ xfs_dir2_node_lookup( ...@@ -2040,7 +2042,7 @@ xfs_dir2_node_lookup(
state = xfs_da_state_alloc(); state = xfs_da_state_alloc();
state->args = args; state->args = args;
state->mp = args->dp->i_mount; state->mp = args->dp->i_mount;
state->blocksize = state->mp->m_dirblksize; state->blocksize = args->geo->blksize;
state->node_ents = state->mp->m_dir_node_ents; state->node_ents = state->mp->m_dir_node_ents;
/* /*
* Fill in the path to the entry in the cursor. * Fill in the path to the entry in the cursor.
...@@ -2095,7 +2097,7 @@ xfs_dir2_node_removename( ...@@ -2095,7 +2097,7 @@ xfs_dir2_node_removename(
state = xfs_da_state_alloc(); state = xfs_da_state_alloc();
state->args = args; state->args = args;
state->mp = args->dp->i_mount; state->mp = args->dp->i_mount;
state->blocksize = state->mp->m_dirblksize; state->blocksize = args->geo->blksize;
state->node_ents = state->mp->m_dir_node_ents; state->node_ents = state->mp->m_dir_node_ents;
/* Look up the entry we're deleting, set up the cursor. */ /* Look up the entry we're deleting, set up the cursor. */
...@@ -2165,7 +2167,7 @@ xfs_dir2_node_replace( ...@@ -2165,7 +2167,7 @@ xfs_dir2_node_replace(
state = xfs_da_state_alloc(); state = xfs_da_state_alloc();
state->args = args; state->args = args;
state->mp = args->dp->i_mount; state->mp = args->dp->i_mount;
state->blocksize = state->mp->m_dirblksize; state->blocksize = args->geo->blksize;
state->node_ents = state->mp->m_dir_node_ents; state->node_ents = state->mp->m_dir_node_ents;
inum = args->inumber; inum = args->inumber;
/* /*
......
...@@ -140,17 +140,17 @@ xfs_dir2_da_to_byte(struct xfs_da_geometry *geo, xfs_dablk_t da) ...@@ -140,17 +140,17 @@ xfs_dir2_da_to_byte(struct xfs_da_geometry *geo, xfs_dablk_t da)
* Directory tail pointer accessor functions. Based on block geometry. * Directory tail pointer accessor functions. Based on block geometry.
*/ */
static inline struct xfs_dir2_block_tail * static inline struct xfs_dir2_block_tail *
xfs_dir2_block_tail_p(struct xfs_mount *mp, struct xfs_dir2_data_hdr *hdr) xfs_dir2_block_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_data_hdr *hdr)
{ {
return ((struct xfs_dir2_block_tail *) return ((struct xfs_dir2_block_tail *)
((char *)hdr + mp->m_dirblksize)) - 1; ((char *)hdr + geo->blksize)) - 1;
} }
static inline struct xfs_dir2_leaf_tail * static inline struct xfs_dir2_leaf_tail *
xfs_dir2_leaf_tail_p(struct xfs_mount *mp, struct xfs_dir2_leaf *lp) xfs_dir2_leaf_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_leaf *lp)
{ {
return (struct xfs_dir2_leaf_tail *) return (struct xfs_dir2_leaf_tail *)
((char *)lp + mp->m_dirblksize - ((char *)lp + geo->blksize -
sizeof(struct xfs_dir2_leaf_tail)); sizeof(struct xfs_dir2_leaf_tail));
} }
......
...@@ -216,7 +216,7 @@ xfs_dir2_block_getdents( ...@@ -216,7 +216,7 @@ xfs_dir2_block_getdents(
/* /*
* Set up values for the loop. * Set up values for the loop.
*/ */
btp = xfs_dir2_block_tail_p(mp, hdr); btp = xfs_dir2_block_tail_p(geo, hdr);
ptr = (char *)dp->d_ops->data_entry_p(hdr); ptr = (char *)dp->d_ops->data_entry_p(hdr);
endptr = (char *)xfs_dir2_block_leaf_p(btp); endptr = (char *)xfs_dir2_block_leaf_p(btp);
...@@ -338,7 +338,7 @@ xfs_dir2_leaf_readbuf( ...@@ -338,7 +338,7 @@ xfs_dir2_leaf_readbuf(
/* /*
* Recalculate the readahead blocks wanted. * Recalculate the readahead blocks wanted.
*/ */
mip->ra_want = howmany(bufsize + mp->m_dirblksize, mip->ra_want = howmany(bufsize + geo->blksize,
mp->m_sb.sb_blocksize) - 1; mp->m_sb.sb_blocksize) - 1;
ASSERT(mip->ra_want >= 0); ASSERT(mip->ra_want >= 0);
...@@ -526,8 +526,7 @@ xfs_dir2_leaf_getdents( ...@@ -526,8 +526,7 @@ xfs_dir2_leaf_getdents(
* buffer size, the directory block size, and the filesystem * buffer size, the directory block size, and the filesystem
* block size. * block size.
*/ */
length = howmany(bufsize + mp->m_dirblksize, length = howmany(bufsize + geo->blksize, mp->m_sb.sb_blocksize);
mp->m_sb.sb_blocksize);
map_info = kmem_zalloc(offsetof(struct xfs_dir2_leaf_map_info, map) + map_info = kmem_zalloc(offsetof(struct xfs_dir2_leaf_map_info, map) +
(length * sizeof(struct xfs_bmbt_irec)), (length * sizeof(struct xfs_bmbt_irec)),
KM_SLEEP | KM_NOFS); KM_SLEEP | KM_NOFS);
...@@ -557,7 +556,7 @@ xfs_dir2_leaf_getdents( ...@@ -557,7 +556,7 @@ xfs_dir2_leaf_getdents(
* If we have no buffer, or we're off the end of the * If we have no buffer, or we're off the end of the
* current buffer, need to get another one. * current buffer, need to get another one.
*/ */
if (!bp || ptr >= (char *)bp->b_addr + mp->m_dirblksize) { if (!bp || ptr >= (char *)bp->b_addr + geo->blksize) {
error = xfs_dir2_leaf_readbuf(dp, bufsize, map_info, error = xfs_dir2_leaf_readbuf(dp, bufsize, map_info,
&curoff, &bp); &curoff, &bp);
...@@ -618,7 +617,7 @@ xfs_dir2_leaf_getdents( ...@@ -618,7 +617,7 @@ xfs_dir2_leaf_getdents(
xfs_dir2_db_off_to_byte(geo, xfs_dir2_db_off_to_byte(geo,
xfs_dir2_byte_to_db(geo, curoff), xfs_dir2_byte_to_db(geo, curoff),
(char *)ptr - (char *)hdr); (char *)ptr - (char *)hdr);
if (ptr >= (char *)hdr + mp->m_dirblksize) { if (ptr >= (char *)hdr + geo->blksize) {
continue; continue;
} }
} }
......
...@@ -82,8 +82,10 @@ xfs_dir2_block_sfsize( ...@@ -82,8 +82,10 @@ xfs_dir2_block_sfsize(
xfs_ino_t parent = 0; /* parent inode number */ xfs_ino_t parent = 0; /* parent inode number */
int size=0; /* total computed size */ int size=0; /* total computed size */
int has_ftype; int has_ftype;
struct xfs_da_geometry *geo;
mp = dp->i_mount; mp = dp->i_mount;
geo = mp->m_dir_geo;
/* /*
* if there is a filetype field, add the extra byte to the namelen * if there is a filetype field, add the extra byte to the namelen
...@@ -92,7 +94,7 @@ xfs_dir2_block_sfsize( ...@@ -92,7 +94,7 @@ xfs_dir2_block_sfsize(
has_ftype = xfs_sb_version_hasftype(&mp->m_sb) ? 1 : 0; has_ftype = xfs_sb_version_hasftype(&mp->m_sb) ? 1 : 0;
count = i8count = namelen = 0; count = i8count = namelen = 0;
btp = xfs_dir2_block_tail_p(mp, hdr); btp = xfs_dir2_block_tail_p(geo, hdr);
blp = xfs_dir2_block_leaf_p(btp); blp = xfs_dir2_block_leaf_p(btp);
/* /*
...@@ -105,7 +107,7 @@ xfs_dir2_block_sfsize( ...@@ -105,7 +107,7 @@ xfs_dir2_block_sfsize(
* Calculate the pointer to the entry at hand. * Calculate the pointer to the entry at hand.
*/ */
dep = (xfs_dir2_data_entry_t *)((char *)hdr + dep = (xfs_dir2_data_entry_t *)((char *)hdr +
xfs_dir2_dataptr_to_off(mp->m_dir_geo, addr)); xfs_dir2_dataptr_to_off(geo, addr));
/* /*
* Detect . and .., so we can special-case them. * Detect . and .., so we can special-case them.
* . is not included in sf directories. * . is not included in sf directories.
...@@ -195,7 +197,7 @@ xfs_dir2_block_to_sf( ...@@ -195,7 +197,7 @@ xfs_dir2_block_to_sf(
/* /*
* Set up to loop over the block's entries. * Set up to loop over the block's entries.
*/ */
btp = xfs_dir2_block_tail_p(mp, hdr); btp = xfs_dir2_block_tail_p(args->geo, hdr);
ptr = (char *)dp->d_ops->data_entry_p(hdr); ptr = (char *)dp->d_ops->data_entry_p(hdr);
endptr = (char *)xfs_dir2_block_leaf_p(btp); endptr = (char *)xfs_dir2_block_leaf_p(btp);
sfep = xfs_dir2_sf_firstentry(sfp); sfep = xfs_dir2_sf_firstentry(sfp);
...@@ -586,7 +588,7 @@ xfs_dir2_sf_addname_pick( ...@@ -586,7 +588,7 @@ xfs_dir2_sf_addname_pick(
* we'll go back, convert to block, then try the insert and convert * we'll go back, convert to block, then try the insert and convert
* to leaf. * to leaf.
*/ */
if (used + (holefit ? 0 : size) > mp->m_dirblksize) if (used + (holefit ? 0 : size) > args->geo->blksize)
return 0; return 0;
/* /*
* If changing the inode number size, do it the hard way. * If changing the inode number size, do it the hard way.
...@@ -601,7 +603,7 @@ xfs_dir2_sf_addname_pick( ...@@ -601,7 +603,7 @@ xfs_dir2_sf_addname_pick(
/* /*
* If it won't fit at the end then do it the hard way (use the hole). * If it won't fit at the end then do it the hard way (use the hole).
*/ */
if (used + size > mp->m_dirblksize) if (used + size > args->geo->blksize)
return 2; return 2;
/* /*
* Do it the easy way. * Do it the easy way.
...@@ -652,7 +654,7 @@ xfs_dir2_sf_check( ...@@ -652,7 +654,7 @@ xfs_dir2_sf_check(
ASSERT((char *)sfep - (char *)sfp == dp->i_d.di_size); ASSERT((char *)sfep - (char *)sfp == dp->i_d.di_size);
ASSERT(offset + ASSERT(offset +
(sfp->count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t) + (sfp->count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t) +
(uint)sizeof(xfs_dir2_block_tail_t) <= mp->m_dirblksize); (uint)sizeof(xfs_dir2_block_tail_t) <= args->geo->blksize);
} }
#endif /* DEBUG */ #endif /* DEBUG */
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h" #include "xfs_ag.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_da_format.h"
#include "xfs_da_btree.h"
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_inode_item.h" #include "xfs_inode_item.h"
...@@ -110,7 +112,7 @@ xfs_fs_geometry( ...@@ -110,7 +112,7 @@ xfs_fs_geometry(
geo->logsectsize = xfs_sb_version_hassector(&mp->m_sb) ? geo->logsectsize = xfs_sb_version_hassector(&mp->m_sb) ?
mp->m_sb.sb_logsectsize : BBSIZE; mp->m_sb.sb_logsectsize : BBSIZE;
geo->rtsectsize = mp->m_sb.sb_blocksize; geo->rtsectsize = mp->m_sb.sb_blocksize;
geo->dirblocksize = mp->m_dirblksize; geo->dirblocksize = mp->m_dir_geo->blksize;
} }
if (new_version >= 4) { if (new_version >= 4) {
geo->flags |= geo->flags |=
......
...@@ -154,7 +154,6 @@ typedef struct xfs_mount { ...@@ -154,7 +154,6 @@ typedef struct xfs_mount {
const struct xfs_nameops *m_dirnameops; /* vector of dir name ops */ const struct xfs_nameops *m_dirnameops; /* vector of dir name ops */
const struct xfs_dir_ops *m_dir_inode_ops; /* vector of dir inode ops */ const struct xfs_dir_ops *m_dir_inode_ops; /* vector of dir inode ops */
const struct xfs_dir_ops *m_nondir_inode_ops; /* !dir inode ops */ const struct xfs_dir_ops *m_nondir_inode_ops; /* !dir inode ops */
int m_dirblksize; /* directory block sz--bytes */
uint m_chsize; /* size of next field */ uint m_chsize; /* size of next field */
atomic_t m_active_trans; /* number trans frozen */ atomic_t m_active_trans; /* number trans frozen */
#ifdef HAVE_PERCPU_SB #ifdef HAVE_PERCPU_SB
......
...@@ -610,7 +610,7 @@ xfs_calc_addafork_reservation( ...@@ -610,7 +610,7 @@ xfs_calc_addafork_reservation(
return XFS_DQUOT_LOGRES(mp) + return XFS_DQUOT_LOGRES(mp) +
xfs_calc_inode_res(mp, 1) + xfs_calc_inode_res(mp, 1) +
xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) + xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) +
xfs_calc_buf_res(1, mp->m_dirblksize) + xfs_calc_buf_res(1, mp->m_dir_geo->blksize) +
xfs_calc_buf_res(XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK) + 1, xfs_calc_buf_res(XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK) + 1,
XFS_FSB_TO_B(mp, 1)) + XFS_FSB_TO_B(mp, 1)) +
xfs_calc_buf_res(XFS_ALLOCFREE_LOG_COUNT(mp, 1), xfs_calc_buf_res(XFS_ALLOCFREE_LOG_COUNT(mp, 1),
......
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