Commit 4f6ae1a4 authored by Christoph Hellwig's avatar Christoph Hellwig

xfs: avoid usage of struct xfs_dir2_block

In most places we can simply pass around and use the struct xfs_dir2_data_hdr,
which is the first and most important member of struct xfs_dir2_block instead
of the full structure.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarAlex Elder <aelder@sgi.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
parent 78f70cd7
This diff is collapsed.
...@@ -61,10 +61,9 @@ typedef struct xfs_dir2_block { ...@@ -61,10 +61,9 @@ typedef struct xfs_dir2_block {
* Pointer to the leaf header embedded in a data block (1-block format) * Pointer to the leaf header embedded in a data block (1-block format)
*/ */
static inline xfs_dir2_block_tail_t * static inline xfs_dir2_block_tail_t *
xfs_dir2_block_tail_p(struct xfs_mount *mp, xfs_dir2_block_t *block) xfs_dir2_block_tail_p(struct xfs_mount *mp, xfs_dir2_data_hdr_t *hdr)
{ {
return (((xfs_dir2_block_tail_t *) return ((xfs_dir2_block_tail_t *)((char *)hdr + mp->m_dirblksize)) - 1;
((char *)(block) + (mp)->m_dirblksize)) - 1);
} }
/* /*
......
...@@ -72,7 +72,7 @@ xfs_dir2_data_check( ...@@ -72,7 +72,7 @@ xfs_dir2_data_check(
bf = d->hdr.bestfree; bf = d->hdr.bestfree;
p = (char *)d->u; p = (char *)d->u;
if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) {
btp = xfs_dir2_block_tail_p(mp, (xfs_dir2_block_t *)d); btp = xfs_dir2_block_tail_p(mp, &d->hdr);
lep = xfs_dir2_block_leaf_p(btp); lep = xfs_dir2_block_leaf_p(btp);
endp = (char *)lep; endp = (char *)lep;
} else } else
...@@ -348,7 +348,7 @@ xfs_dir2_data_freescan( ...@@ -348,7 +348,7 @@ xfs_dir2_data_freescan(
*/ */
p = (char *)d->u; p = (char *)d->u;
if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) {
btp = xfs_dir2_block_tail_p(mp, (xfs_dir2_block_t *)d); btp = xfs_dir2_block_tail_p(mp, &d->hdr);
endp = (char *)xfs_dir2_block_leaf_p(btp); endp = (char *)xfs_dir2_block_leaf_p(btp);
} else } else
endp = (char *)d + mp->m_dirblksize; endp = (char *)d + mp->m_dirblksize;
...@@ -537,7 +537,7 @@ xfs_dir2_data_make_free( ...@@ -537,7 +537,7 @@ xfs_dir2_data_make_free(
xfs_dir2_block_tail_t *btp; /* block tail */ xfs_dir2_block_tail_t *btp; /* block tail */
ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
btp = xfs_dir2_block_tail_p(mp, (xfs_dir2_block_t *)d); btp = xfs_dir2_block_tail_p(mp, &d->hdr);
endptr = (char *)xfs_dir2_block_leaf_p(btp); endptr = (char *)xfs_dir2_block_leaf_p(btp);
} }
/* /*
......
...@@ -64,7 +64,7 @@ xfs_dir2_block_to_leaf( ...@@ -64,7 +64,7 @@ xfs_dir2_block_to_leaf(
{ {
__be16 *bestsp; /* leaf's bestsp entries */ __be16 *bestsp; /* leaf's bestsp entries */
xfs_dablk_t blkno; /* leaf block's bno */ xfs_dablk_t blkno; /* leaf block's bno */
xfs_dir2_block_t *block; /* block structure */ xfs_dir2_data_hdr_t *hdr; /* block header */
xfs_dir2_leaf_entry_t *blp; /* block's leaf entries */ xfs_dir2_leaf_entry_t *blp; /* block's leaf entries */
xfs_dir2_block_tail_t *btp; /* block's tail */ xfs_dir2_block_tail_t *btp; /* block's tail */
xfs_inode_t *dp; /* incore directory inode */ xfs_inode_t *dp; /* incore directory inode */
...@@ -101,9 +101,9 @@ xfs_dir2_block_to_leaf( ...@@ -101,9 +101,9 @@ xfs_dir2_block_to_leaf(
} }
ASSERT(lbp != NULL); ASSERT(lbp != NULL);
leaf = lbp->data; leaf = lbp->data;
block = dbp->data; hdr = dbp->data;
xfs_dir2_data_check(dp, dbp); xfs_dir2_data_check(dp, dbp);
btp = xfs_dir2_block_tail_p(mp, block); btp = xfs_dir2_block_tail_p(mp, hdr);
blp = xfs_dir2_block_leaf_p(btp); blp = xfs_dir2_block_leaf_p(btp);
/* /*
* Set the counts in the leaf header. * Set the counts in the leaf header.
...@@ -123,23 +123,23 @@ xfs_dir2_block_to_leaf( ...@@ -123,23 +123,23 @@ xfs_dir2_block_to_leaf(
* tail be free. * tail be free.
*/ */
xfs_dir2_data_make_free(tp, dbp, xfs_dir2_data_make_free(tp, dbp,
(xfs_dir2_data_aoff_t)((char *)blp - (char *)block), (xfs_dir2_data_aoff_t)((char *)blp - (char *)hdr),
(xfs_dir2_data_aoff_t)((char *)block + mp->m_dirblksize - (xfs_dir2_data_aoff_t)((char *)hdr + mp->m_dirblksize -
(char *)blp), (char *)blp),
&needlog, &needscan); &needlog, &needscan);
/* /*
* Fix up the block header, make it a data block. * Fix up the block header, make it a data block.
*/ */
block->hdr.magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC); hdr->magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC);
if (needscan) if (needscan)
xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)block, &needlog); xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)hdr, &needlog);
/* /*
* 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(mp, 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] = block->hdr.bestfree[0].length; bestsp[0] = hdr->bestfree[0].length;
/* /*
* Log the data header and leaf bests table. * Log the data header and leaf bests table.
*/ */
......
...@@ -141,7 +141,7 @@ xfs_dir2_sfe_put_ino( ...@@ -141,7 +141,7 @@ xfs_dir2_sfe_put_ino(
int /* size for sf form */ int /* size for sf form */
xfs_dir2_block_sfsize( xfs_dir2_block_sfsize(
xfs_inode_t *dp, /* incore inode pointer */ xfs_inode_t *dp, /* incore inode pointer */
xfs_dir2_block_t *block, /* block directory data */ xfs_dir2_data_hdr_t *hdr, /* block directory data */
xfs_dir2_sf_hdr_t *sfhp) /* output: header for sf form */ xfs_dir2_sf_hdr_t *sfhp) /* output: header for sf form */
{ {
xfs_dir2_dataptr_t addr; /* data entry address */ xfs_dir2_dataptr_t addr; /* data entry address */
...@@ -161,7 +161,7 @@ xfs_dir2_block_sfsize( ...@@ -161,7 +161,7 @@ xfs_dir2_block_sfsize(
mp = dp->i_mount; mp = dp->i_mount;
count = i8count = namelen = 0; count = i8count = namelen = 0;
btp = xfs_dir2_block_tail_p(mp, block); btp = xfs_dir2_block_tail_p(mp, hdr);
blp = xfs_dir2_block_leaf_p(btp); blp = xfs_dir2_block_leaf_p(btp);
/* /*
...@@ -174,7 +174,7 @@ xfs_dir2_block_sfsize( ...@@ -174,7 +174,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 *) dep = (xfs_dir2_data_entry_t *)
((char *)block + xfs_dir2_dataptr_to_off(mp, addr)); ((char *)hdr + xfs_dir2_dataptr_to_off(mp, 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.
...@@ -255,6 +255,7 @@ xfs_dir2_block_to_sf( ...@@ -255,6 +255,7 @@ xfs_dir2_block_to_sf(
ASSERT(error != ENOSPC); ASSERT(error != ENOSPC);
goto out; goto out;
} }
/* /*
* The buffer is now unconditionally gone, whether * The buffer is now unconditionally gone, whether
* xfs_dir2_shrink_inode worked or not. * xfs_dir2_shrink_inode worked or not.
...@@ -276,7 +277,7 @@ xfs_dir2_block_to_sf( ...@@ -276,7 +277,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, block); btp = xfs_dir2_block_tail_p(mp, &block->hdr);
ptr = (char *)block->u; ptr = (char *)block->u;
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);
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
struct uio; struct uio;
struct xfs_dabuf; struct xfs_dabuf;
struct xfs_da_args; struct xfs_da_args;
struct xfs_dir2_block; struct xfs_dir2_data_hdr;
struct xfs_inode; struct xfs_inode;
struct xfs_mount; struct xfs_mount;
struct xfs_trans; struct xfs_trans;
...@@ -136,7 +136,7 @@ extern xfs_ino_t xfs_dir2_sf_get_parent_ino(struct xfs_dir2_sf_hdr *sfp); ...@@ -136,7 +136,7 @@ extern xfs_ino_t xfs_dir2_sf_get_parent_ino(struct xfs_dir2_sf_hdr *sfp);
extern xfs_ino_t xfs_dir2_sfe_get_ino(struct xfs_dir2_sf_hdr *sfp, extern xfs_ino_t xfs_dir2_sfe_get_ino(struct xfs_dir2_sf_hdr *sfp,
struct xfs_dir2_sf_entry *sfep); struct xfs_dir2_sf_entry *sfep);
extern int xfs_dir2_block_sfsize(struct xfs_inode *dp, extern int xfs_dir2_block_sfsize(struct xfs_inode *dp,
struct xfs_dir2_block *block, struct xfs_dir2_data_hdr *block,
xfs_dir2_sf_hdr_t *sfhp); xfs_dir2_sf_hdr_t *sfhp);
extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_dabuf *bp, extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_dabuf *bp,
int size, xfs_dir2_sf_hdr_t *sfhp); int size, xfs_dir2_sf_hdr_t *sfhp);
......
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