Commit c2066e26 authored by Christoph Hellwig's avatar Christoph Hellwig

xfs: avoid usage of struct xfs_dir2_data

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_data 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 a64b0417
...@@ -2079,16 +2079,13 @@ xfs_da_do_buf( ...@@ -2079,16 +2079,13 @@ xfs_da_do_buf(
* For read_buf, check the magic number. * For read_buf, check the magic number.
*/ */
if (caller == 1) { if (caller == 1) {
xfs_dir2_data_t *data; xfs_dir2_data_hdr_t *hdr = rbp->data;
xfs_dir2_free_t *free; xfs_dir2_free_t *free = rbp->data;
xfs_da_blkinfo_t *info; xfs_da_blkinfo_t *info = rbp->data;
uint magic, magic1; uint magic, magic1;
info = rbp->data;
data = rbp->data;
free = rbp->data;
magic = be16_to_cpu(info->magic); magic = be16_to_cpu(info->magic);
magic1 = be32_to_cpu(data->hdr.magic); magic1 = be32_to_cpu(hdr->magic);
if (unlikely( if (unlikely(
XFS_TEST_ERROR((magic != XFS_DA_NODE_MAGIC) && XFS_TEST_ERROR((magic != XFS_DA_NODE_MAGIC) &&
(magic != XFS_ATTR_LEAF_MAGIC) && (magic != XFS_ATTR_LEAF_MAGIC) &&
......
...@@ -282,7 +282,7 @@ xfs_dir2_block_addname( ...@@ -282,7 +282,7 @@ xfs_dir2_block_addname(
* This needs to happen before the next call to use_free. * This needs to happen before the next call to use_free.
*/ */
if (needscan) { if (needscan) {
xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)hdr, &needlog); xfs_dir2_data_freescan(mp, hdr, &needlog);
needscan = 0; needscan = 0;
} }
} }
...@@ -331,8 +331,7 @@ xfs_dir2_block_addname( ...@@ -331,8 +331,7 @@ xfs_dir2_block_addname(
* This needs to happen before the next call to use_free. * This needs to happen before the next call to use_free.
*/ */
if (needscan) { if (needscan) {
xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)hdr, xfs_dir2_data_freescan(mp, hdr, &needlog);
&needlog);
needscan = 0; needscan = 0;
} }
/* /*
...@@ -417,7 +416,7 @@ xfs_dir2_block_addname( ...@@ -417,7 +416,7 @@ xfs_dir2_block_addname(
* Clean up the bestfree array and log the header, tail, and entry. * Clean up the bestfree array and log the header, tail, and entry.
*/ */
if (needscan) if (needscan)
xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)hdr, &needlog); xfs_dir2_data_freescan(mp, hdr, &needlog);
if (needlog) if (needlog)
xfs_dir2_data_log_header(tp, bp); xfs_dir2_data_log_header(tp, bp);
xfs_dir2_block_log_tail(tp, bp); xfs_dir2_block_log_tail(tp, bp);
...@@ -783,7 +782,7 @@ xfs_dir2_block_removename( ...@@ -783,7 +782,7 @@ xfs_dir2_block_removename(
* Fix up bestfree, log the header if necessary. * Fix up bestfree, log the header if necessary.
*/ */
if (needscan) if (needscan)
xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)hdr, &needlog); xfs_dir2_data_freescan(mp, hdr, &needlog);
if (needlog) if (needlog)
xfs_dir2_data_log_header(tp, bp); xfs_dir2_data_log_header(tp, bp);
xfs_dir2_data_check(dp, bp); xfs_dir2_data_check(dp, bp);
...@@ -982,7 +981,7 @@ xfs_dir2_leaf_to_block( ...@@ -982,7 +981,7 @@ xfs_dir2_leaf_to_block(
* Scan the bestfree if we need it and log the data block header. * Scan the bestfree if we need it and log the data block header.
*/ */
if (needscan) if (needscan)
xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)hdr, &needlog); xfs_dir2_data_freescan(mp, hdr, &needlog);
if (needlog) if (needlog)
xfs_dir2_data_log_header(tp, dbp); xfs_dir2_data_log_header(tp, dbp);
/* /*
...@@ -1177,8 +1176,7 @@ xfs_dir2_sf_to_block( ...@@ -1177,8 +1176,7 @@ xfs_dir2_sf_to_block(
*xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16( *xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16(
((char *)dup - (char *)hdr)); ((char *)dup - (char *)hdr));
xfs_dir2_data_log_unused(tp, bp, dup); xfs_dir2_data_log_unused(tp, bp, dup);
(void)xfs_dir2_data_freeinsert((xfs_dir2_data_t *)hdr, xfs_dir2_data_freeinsert(hdr, dup, &dummy);
dup, &dummy);
offset += be16_to_cpu(dup->length); offset += be16_to_cpu(dup->length);
continue; continue;
} }
......
This diff is collapsed.
...@@ -157,12 +157,10 @@ extern void xfs_dir2_data_check(struct xfs_inode *dp, struct xfs_dabuf *bp); ...@@ -157,12 +157,10 @@ extern void xfs_dir2_data_check(struct xfs_inode *dp, struct xfs_dabuf *bp);
#else #else
#define xfs_dir2_data_check(dp,bp) #define xfs_dir2_data_check(dp,bp)
#endif #endif
extern xfs_dir2_data_free_t *xfs_dir2_data_freefind(xfs_dir2_data_t *d, extern xfs_dir2_data_free_t *xfs_dir2_data_freeinsert(xfs_dir2_data_hdr_t *hdr,
xfs_dir2_data_unused_t *dup);
extern xfs_dir2_data_free_t *xfs_dir2_data_freeinsert(xfs_dir2_data_t *d,
xfs_dir2_data_unused_t *dup, int *loghead); xfs_dir2_data_unused_t *dup, int *loghead);
extern void xfs_dir2_data_freescan(struct xfs_mount *mp, xfs_dir2_data_t *d, extern void xfs_dir2_data_freescan(struct xfs_mount *mp,
int *loghead); xfs_dir2_data_hdr_t *hdr, int *loghead);
extern int xfs_dir2_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno, extern int xfs_dir2_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno,
struct xfs_dabuf **bpp); struct xfs_dabuf **bpp);
extern void xfs_dir2_data_log_entry(struct xfs_trans *tp, struct xfs_dabuf *bp, extern void xfs_dir2_data_log_entry(struct xfs_trans *tp, struct xfs_dabuf *bp,
......
...@@ -132,7 +132,7 @@ xfs_dir2_block_to_leaf( ...@@ -132,7 +132,7 @@ xfs_dir2_block_to_leaf(
*/ */
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 *)hdr, &needlog); xfs_dir2_data_freescan(mp, hdr, &needlog);
/* /*
* Set up leaf tail and bests table. * Set up leaf tail and bests table.
*/ */
...@@ -278,7 +278,7 @@ xfs_dir2_leaf_addname( ...@@ -278,7 +278,7 @@ xfs_dir2_leaf_addname(
{ {
__be16 *bestsp; /* freespace table in leaf */ __be16 *bestsp; /* freespace table in leaf */
int compact; /* need to compact leaves */ int compact; /* need to compact leaves */
xfs_dir2_data_t *data; /* data block structure */ xfs_dir2_data_hdr_t *hdr; /* data block header */
xfs_dabuf_t *dbp; /* data block buffer */ xfs_dabuf_t *dbp; /* data block buffer */
xfs_dir2_data_entry_t *dep; /* data block entry */ xfs_dir2_data_entry_t *dep; /* data block entry */
xfs_inode_t *dp; /* incore directory inode */ xfs_inode_t *dp; /* incore directory inode */
...@@ -486,8 +486,8 @@ xfs_dir2_leaf_addname( ...@@ -486,8 +486,8 @@ xfs_dir2_leaf_addname(
*/ */
else else
xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block);
data = dbp->data; hdr = dbp->data;
bestsp[use_block] = data->hdr.bestfree[0].length; bestsp[use_block] = hdr->bestfree[0].length;
grown = 1; grown = 1;
} }
/* /*
...@@ -501,7 +501,7 @@ xfs_dir2_leaf_addname( ...@@ -501,7 +501,7 @@ xfs_dir2_leaf_addname(
xfs_da_brelse(tp, lbp); xfs_da_brelse(tp, lbp);
return error; return error;
} }
data = dbp->data; hdr = dbp->data;
grown = 0; grown = 0;
} }
xfs_dir2_data_check(dp, dbp); xfs_dir2_data_check(dp, dbp);
...@@ -509,14 +509,14 @@ xfs_dir2_leaf_addname( ...@@ -509,14 +509,14 @@ xfs_dir2_leaf_addname(
* Point to the biggest freespace in our data block. * Point to the biggest freespace in our data block.
*/ */
dup = (xfs_dir2_data_unused_t *) dup = (xfs_dir2_data_unused_t *)
((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset)); ((char *)hdr + be16_to_cpu(hdr->bestfree[0].offset));
ASSERT(be16_to_cpu(dup->length) >= length); ASSERT(be16_to_cpu(dup->length) >= length);
needscan = needlog = 0; needscan = needlog = 0;
/* /*
* Mark the initial part of our freespace in use for the new entry. * Mark the initial part of our freespace in use for the new entry.
*/ */
xfs_dir2_data_use_free(tp, dbp, dup, xfs_dir2_data_use_free(tp, dbp, dup,
(xfs_dir2_data_aoff_t)((char *)dup - (char *)data), length, (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), length,
&needlog, &needscan); &needlog, &needscan);
/* /*
* Initialize our new entry (at last). * Initialize our new entry (at last).
...@@ -526,12 +526,12 @@ xfs_dir2_leaf_addname( ...@@ -526,12 +526,12 @@ xfs_dir2_leaf_addname(
dep->namelen = args->namelen; dep->namelen = args->namelen;
memcpy(dep->name, args->name, dep->namelen); memcpy(dep->name, args->name, dep->namelen);
tagp = xfs_dir2_data_entry_tag_p(dep); tagp = xfs_dir2_data_entry_tag_p(dep);
*tagp = cpu_to_be16((char *)dep - (char *)data); *tagp = cpu_to_be16((char *)dep - (char *)hdr);
/* /*
* Need to scan fix up the bestfree table. * Need to scan fix up the bestfree table.
*/ */
if (needscan) if (needscan)
xfs_dir2_data_freescan(mp, data, &needlog); xfs_dir2_data_freescan(mp, hdr, &needlog);
/* /*
* Need to log the data block's header. * Need to log the data block's header.
*/ */
...@@ -542,8 +542,8 @@ xfs_dir2_leaf_addname( ...@@ -542,8 +542,8 @@ xfs_dir2_leaf_addname(
* If the bests table needs to be changed, do it. * If the bests table needs to be changed, do it.
* Log the change unless we've already done that. * Log the change unless we've already done that.
*/ */
if (be16_to_cpu(bestsp[use_block]) != be16_to_cpu(data->hdr.bestfree[0].length)) { if (be16_to_cpu(bestsp[use_block]) != be16_to_cpu(hdr->bestfree[0].length)) {
bestsp[use_block] = data->hdr.bestfree[0].length; bestsp[use_block] = hdr->bestfree[0].length;
if (!grown) if (!grown)
xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block);
} }
...@@ -786,6 +786,7 @@ xfs_dir2_leaf_getdents( ...@@ -786,6 +786,7 @@ xfs_dir2_leaf_getdents(
xfs_dir2_db_t curdb; /* db for current block */ xfs_dir2_db_t curdb; /* db for current block */
xfs_dir2_off_t curoff; /* current overall offset */ xfs_dir2_off_t curoff; /* current overall offset */
xfs_dir2_data_t *data; /* data block structure */ xfs_dir2_data_t *data; /* data block structure */
xfs_dir2_data_hdr_t *hdr; /* data block header */
xfs_dir2_data_entry_t *dep; /* data entry */ xfs_dir2_data_entry_t *dep; /* data entry */
xfs_dir2_data_unused_t *dup; /* unused entry */ xfs_dir2_data_unused_t *dup; /* unused entry */
int error = 0; /* error return value */ int error = 0; /* error return value */
...@@ -1044,6 +1045,7 @@ xfs_dir2_leaf_getdents( ...@@ -1044,6 +1045,7 @@ xfs_dir2_leaf_getdents(
ASSERT(xfs_dir2_byte_to_db(mp, curoff) == ASSERT(xfs_dir2_byte_to_db(mp, curoff) ==
curdb); curdb);
data = bp->data; data = bp->data;
hdr = &data->hdr;
xfs_dir2_data_check(dp, bp); xfs_dir2_data_check(dp, bp);
/* /*
* Find our position in the block. * Find our position in the block.
...@@ -1054,12 +1056,12 @@ xfs_dir2_leaf_getdents( ...@@ -1054,12 +1056,12 @@ xfs_dir2_leaf_getdents(
* Skip past the header. * Skip past the header.
*/ */
if (byteoff == 0) if (byteoff == 0)
curoff += (uint)sizeof(data->hdr); curoff += (uint)sizeof(*hdr);
/* /*
* Skip past entries until we reach our offset. * Skip past entries until we reach our offset.
*/ */
else { else {
while ((char *)ptr - (char *)data < byteoff) { while ((char *)ptr - (char *)hdr < byteoff) {
dup = (xfs_dir2_data_unused_t *)ptr; dup = (xfs_dir2_data_unused_t *)ptr;
if (be16_to_cpu(dup->freetag) if (be16_to_cpu(dup->freetag)
...@@ -1080,8 +1082,8 @@ xfs_dir2_leaf_getdents( ...@@ -1080,8 +1082,8 @@ xfs_dir2_leaf_getdents(
curoff = curoff =
xfs_dir2_db_off_to_byte(mp, xfs_dir2_db_off_to_byte(mp,
xfs_dir2_byte_to_db(mp, curoff), xfs_dir2_byte_to_db(mp, curoff),
(char *)ptr - (char *)data); (char *)ptr - (char *)hdr);
if (ptr >= (char *)data + mp->m_dirblksize) { if (ptr >= (char *)hdr + mp->m_dirblksize) {
continue; continue;
} }
} }
...@@ -1462,7 +1464,7 @@ xfs_dir2_leaf_removename( ...@@ -1462,7 +1464,7 @@ xfs_dir2_leaf_removename(
xfs_da_args_t *args) /* operation arguments */ xfs_da_args_t *args) /* operation arguments */
{ {
__be16 *bestsp; /* leaf block best freespace */ __be16 *bestsp; /* leaf block best freespace */
xfs_dir2_data_t *data; /* data block structure */ xfs_dir2_data_hdr_t *hdr; /* data block header */
xfs_dir2_db_t db; /* data block number */ xfs_dir2_db_t db; /* data block number */
xfs_dabuf_t *dbp; /* data block buffer */ xfs_dabuf_t *dbp; /* data block buffer */
xfs_dir2_data_entry_t *dep; /* data entry structure */ xfs_dir2_data_entry_t *dep; /* data entry structure */
...@@ -1492,7 +1494,7 @@ xfs_dir2_leaf_removename( ...@@ -1492,7 +1494,7 @@ xfs_dir2_leaf_removename(
tp = args->trans; tp = args->trans;
mp = dp->i_mount; mp = dp->i_mount;
leaf = lbp->data; leaf = lbp->data;
data = dbp->data; hdr = dbp->data;
xfs_dir2_data_check(dp, dbp); xfs_dir2_data_check(dp, dbp);
/* /*
* Point to the leaf entry, use that to point to the data entry. * Point to the leaf entry, use that to point to the data entry.
...@@ -1500,9 +1502,9 @@ xfs_dir2_leaf_removename( ...@@ -1500,9 +1502,9 @@ xfs_dir2_leaf_removename(
lep = &leaf->ents[index]; lep = &leaf->ents[index];
db = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address)); db = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address));
dep = (xfs_dir2_data_entry_t *) dep = (xfs_dir2_data_entry_t *)
((char *)data + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address))); ((char *)hdr + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address)));
needscan = needlog = 0; needscan = needlog = 0;
oldbest = be16_to_cpu(data->hdr.bestfree[0].length); oldbest = be16_to_cpu(hdr->bestfree[0].length);
ltp = xfs_dir2_leaf_tail_p(mp, leaf); ltp = xfs_dir2_leaf_tail_p(mp, 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);
...@@ -1510,7 +1512,7 @@ xfs_dir2_leaf_removename( ...@@ -1510,7 +1512,7 @@ xfs_dir2_leaf_removename(
* Mark the former data entry unused. * Mark the former data entry unused.
*/ */
xfs_dir2_data_make_free(tp, dbp, xfs_dir2_data_make_free(tp, dbp,
(xfs_dir2_data_aoff_t)((char *)dep - (char *)data), (xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr),
xfs_dir2_data_entsize(dep->namelen), &needlog, &needscan); xfs_dir2_data_entsize(dep->namelen), &needlog, &needscan);
/* /*
* We just mark the leaf entry stale by putting a null in it. * We just mark the leaf entry stale by putting a null in it.
...@@ -1524,23 +1526,23 @@ xfs_dir2_leaf_removename( ...@@ -1524,23 +1526,23 @@ xfs_dir2_leaf_removename(
* log the data block header if necessary. * log the data block header if necessary.
*/ */
if (needscan) if (needscan)
xfs_dir2_data_freescan(mp, data, &needlog); xfs_dir2_data_freescan(mp, hdr, &needlog);
if (needlog) if (needlog)
xfs_dir2_data_log_header(tp, dbp); xfs_dir2_data_log_header(tp, dbp);
/* /*
* If the longest freespace in the data block has changed, * If the longest freespace in the data block has changed,
* put the new value in the bests table and log that. * put the new value in the bests table and log that.
*/ */
if (be16_to_cpu(data->hdr.bestfree[0].length) != oldbest) { if (be16_to_cpu(hdr->bestfree[0].length) != oldbest) {
bestsp[db] = data->hdr.bestfree[0].length; bestsp[db] = hdr->bestfree[0].length;
xfs_dir2_leaf_log_bests(tp, lbp, db, db); xfs_dir2_leaf_log_bests(tp, lbp, db, db);
} }
xfs_dir2_data_check(dp, dbp); xfs_dir2_data_check(dp, dbp);
/* /*
* 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(data->hdr.bestfree[0].length) == if (be16_to_cpu(hdr->bestfree[0].length) ==
mp->m_dirblksize - (uint)sizeof(data->hdr)) { mp->m_dirblksize - (uint)sizeof(*hdr)) {
ASSERT(db != mp->m_dirdatablk); ASSERT(db != mp->m_dirdatablk);
if ((error = xfs_dir2_shrink_inode(args, db, dbp))) { if ((error = xfs_dir2_shrink_inode(args, db, dbp))) {
/* /*
...@@ -1711,9 +1713,6 @@ xfs_dir2_leaf_trim_data( ...@@ -1711,9 +1713,6 @@ xfs_dir2_leaf_trim_data(
xfs_dir2_db_t db) /* data block number */ xfs_dir2_db_t db) /* data block number */
{ {
__be16 *bestsp; /* leaf bests table */ __be16 *bestsp; /* leaf bests table */
#ifdef DEBUG
xfs_dir2_data_t *data; /* data block structure */
#endif
xfs_dabuf_t *dbp; /* data block buffer */ xfs_dabuf_t *dbp; /* data block buffer */
xfs_inode_t *dp; /* incore directory inode */ xfs_inode_t *dp; /* incore directory inode */
int error; /* error return value */ int error; /* error return value */
...@@ -1732,20 +1731,21 @@ xfs_dir2_leaf_trim_data( ...@@ -1732,20 +1731,21 @@ xfs_dir2_leaf_trim_data(
XFS_DATA_FORK))) { XFS_DATA_FORK))) {
return error; return error;
} }
#ifdef DEBUG
data = dbp->data;
ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC);
#endif
/* this seems to be an error
* data is only valid if DEBUG is defined?
* RMC 09/08/1999
*/
leaf = lbp->data; leaf = lbp->data;
ltp = xfs_dir2_leaf_tail_p(mp, leaf); ltp = xfs_dir2_leaf_tail_p(mp, leaf);
ASSERT(be16_to_cpu(data->hdr.bestfree[0].length) ==
mp->m_dirblksize - (uint)sizeof(data->hdr)); #ifdef DEBUG
{
struct xfs_dir2_data_hdr *hdr = dbp->data;
ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC);
ASSERT(be16_to_cpu(hdr->bestfree[0].length) ==
mp->m_dirblksize - (uint)sizeof(*hdr));
ASSERT(db == be32_to_cpu(ltp->bestcount) - 1); ASSERT(db == be32_to_cpu(ltp->bestcount) - 1);
}
#endif
/* /*
* Get rid of the data block. * Get rid of the data block.
*/ */
......
...@@ -842,7 +842,7 @@ xfs_dir2_leafn_remove( ...@@ -842,7 +842,7 @@ xfs_dir2_leafn_remove(
xfs_da_state_blk_t *dblk, /* data block */ xfs_da_state_blk_t *dblk, /* data block */
int *rval) /* resulting block needs join */ int *rval) /* resulting block needs join */
{ {
xfs_dir2_data_t *data; /* data block structure */ xfs_dir2_data_hdr_t *hdr; /* data block header */
xfs_dir2_db_t db; /* data block number */ xfs_dir2_db_t db; /* data block number */
xfs_dabuf_t *dbp; /* data block buffer */ xfs_dabuf_t *dbp; /* data block buffer */
xfs_dir2_data_entry_t *dep; /* data block entry */ xfs_dir2_data_entry_t *dep; /* data block entry */
...@@ -887,9 +887,9 @@ xfs_dir2_leafn_remove( ...@@ -887,9 +887,9 @@ xfs_dir2_leafn_remove(
* in the data block in case it changes. * in the data block in case it changes.
*/ */
dbp = dblk->bp; dbp = dblk->bp;
data = dbp->data; hdr = dbp->data;
dep = (xfs_dir2_data_entry_t *)((char *)data + off); dep = (xfs_dir2_data_entry_t *)((char *)hdr + off);
longest = be16_to_cpu(data->hdr.bestfree[0].length); longest = be16_to_cpu(hdr->bestfree[0].length);
needlog = needscan = 0; needlog = needscan = 0;
xfs_dir2_data_make_free(tp, dbp, off, xfs_dir2_data_make_free(tp, dbp, off,
xfs_dir2_data_entsize(dep->namelen), &needlog, &needscan); xfs_dir2_data_entsize(dep->namelen), &needlog, &needscan);
...@@ -898,7 +898,7 @@ xfs_dir2_leafn_remove( ...@@ -898,7 +898,7 @@ xfs_dir2_leafn_remove(
* Log the data block header if needed. * Log the data block header if needed.
*/ */
if (needscan) if (needscan)
xfs_dir2_data_freescan(mp, data, &needlog); xfs_dir2_data_freescan(mp, hdr, &needlog);
if (needlog) if (needlog)
xfs_dir2_data_log_header(tp, dbp); xfs_dir2_data_log_header(tp, dbp);
xfs_dir2_data_check(dp, dbp); xfs_dir2_data_check(dp, dbp);
...@@ -906,7 +906,7 @@ xfs_dir2_leafn_remove( ...@@ -906,7 +906,7 @@ xfs_dir2_leafn_remove(
* If the longest data block freespace changes, need to update * If the longest data block freespace changes, need to update
* the corresponding freeblock entry. * the corresponding freeblock entry.
*/ */
if (longest < be16_to_cpu(data->hdr.bestfree[0].length)) { if (longest < be16_to_cpu(hdr->bestfree[0].length)) {
int error; /* error return value */ int error; /* error return value */
xfs_dabuf_t *fbp; /* freeblock buffer */ xfs_dabuf_t *fbp; /* freeblock buffer */
xfs_dir2_db_t fdb; /* freeblock block number */ xfs_dir2_db_t fdb; /* freeblock block number */
...@@ -932,19 +932,19 @@ xfs_dir2_leafn_remove( ...@@ -932,19 +932,19 @@ xfs_dir2_leafn_remove(
* Calculate which entry we need to fix. * Calculate which entry we need to fix.
*/ */
findex = xfs_dir2_db_to_fdindex(mp, db); findex = xfs_dir2_db_to_fdindex(mp, db);
longest = be16_to_cpu(data->hdr.bestfree[0].length); longest = be16_to_cpu(hdr->bestfree[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 - (uint)sizeof(data->hdr)) { if (longest == mp->m_dirblksize - (uint)sizeof(*hdr)) {
/* /*
* Try to punch out the data block. * Try to punch out the data block.
*/ */
error = xfs_dir2_shrink_inode(args, db, dbp); error = xfs_dir2_shrink_inode(args, db, dbp);
if (error == 0) { if (error == 0) {
dblk->bp = NULL; dblk->bp = NULL;
data = NULL; hdr = NULL;
} }
/* /*
* We can get ENOSPC if there's no space reservation. * We can get ENOSPC if there's no space reservation.
...@@ -960,7 +960,7 @@ xfs_dir2_leafn_remove( ...@@ -960,7 +960,7 @@ xfs_dir2_leafn_remove(
* If we got rid of the data block, we can eliminate that entry * If we got rid of the data block, we can eliminate that entry
* in the free block. * in the free block.
*/ */
if (data == NULL) { if (hdr == NULL) {
/* /*
* One less used entry in the free table. * One less used entry in the free table.
*/ */
...@@ -1356,7 +1356,7 @@ xfs_dir2_node_addname_int( ...@@ -1356,7 +1356,7 @@ xfs_dir2_node_addname_int(
xfs_da_args_t *args, /* operation arguments */ xfs_da_args_t *args, /* operation arguments */
xfs_da_state_blk_t *fblk) /* optional freespace block */ xfs_da_state_blk_t *fblk) /* optional freespace block */
{ {
xfs_dir2_data_t *data; /* data block structure */ xfs_dir2_data_hdr_t *hdr; /* data block header */
xfs_dir2_db_t dbno; /* data block number */ xfs_dir2_db_t dbno; /* data block number */
xfs_dabuf_t *dbp; /* data block buffer */ xfs_dabuf_t *dbp; /* data block buffer */
xfs_dir2_data_entry_t *dep; /* data entry pointer */ xfs_dir2_data_entry_t *dep; /* data entry pointer */
...@@ -1641,8 +1641,8 @@ xfs_dir2_node_addname_int( ...@@ -1641,8 +1641,8 @@ xfs_dir2_node_addname_int(
* We haven't allocated the data entry yet so this will * We haven't allocated the data entry yet so this will
* change again. * change again.
*/ */
data = dbp->data; hdr = dbp->data;
free->bests[findex] = data->hdr.bestfree[0].length; free->bests[findex] = hdr->bestfree[0].length;
logfree = 1; logfree = 1;
} }
/* /*
...@@ -1667,21 +1667,21 @@ xfs_dir2_node_addname_int( ...@@ -1667,21 +1667,21 @@ xfs_dir2_node_addname_int(
xfs_da_buf_done(fbp); xfs_da_buf_done(fbp);
return error; return error;
} }
data = dbp->data; hdr = dbp->data;
logfree = 0; logfree = 0;
} }
ASSERT(be16_to_cpu(data->hdr.bestfree[0].length) >= length); ASSERT(be16_to_cpu(hdr->bestfree[0].length) >= length);
/* /*
* Point to the existing unused space. * Point to the existing unused space.
*/ */
dup = (xfs_dir2_data_unused_t *) dup = (xfs_dir2_data_unused_t *)
((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset)); ((char *)hdr + be16_to_cpu(hdr->bestfree[0].offset));
needscan = needlog = 0; needscan = needlog = 0;
/* /*
* Mark the first part of the unused space, inuse for us. * Mark the first part of the unused space, inuse for us.
*/ */
xfs_dir2_data_use_free(tp, dbp, dup, xfs_dir2_data_use_free(tp, dbp, dup,
(xfs_dir2_data_aoff_t)((char *)dup - (char *)data), length, (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), length,
&needlog, &needscan); &needlog, &needscan);
/* /*
* Fill in the new entry and log it. * Fill in the new entry and log it.
...@@ -1691,13 +1691,13 @@ xfs_dir2_node_addname_int( ...@@ -1691,13 +1691,13 @@ xfs_dir2_node_addname_int(
dep->namelen = args->namelen; dep->namelen = args->namelen;
memcpy(dep->name, args->name, dep->namelen); memcpy(dep->name, args->name, dep->namelen);
tagp = xfs_dir2_data_entry_tag_p(dep); tagp = xfs_dir2_data_entry_tag_p(dep);
*tagp = cpu_to_be16((char *)dep - (char *)data); *tagp = cpu_to_be16((char *)dep - (char *)hdr);
xfs_dir2_data_log_entry(tp, dbp, dep); xfs_dir2_data_log_entry(tp, dbp, dep);
/* /*
* Rescan the block for bestfree if needed. * Rescan the block for bestfree if needed.
*/ */
if (needscan) if (needscan)
xfs_dir2_data_freescan(mp, data, &needlog); xfs_dir2_data_freescan(mp, hdr, &needlog);
/* /*
* Log the data block header if needed. * Log the data block header if needed.
*/ */
...@@ -1706,8 +1706,8 @@ xfs_dir2_node_addname_int( ...@@ -1706,8 +1706,8 @@ xfs_dir2_node_addname_int(
/* /*
* If the freespace entry is now wrong, update it. * If the freespace entry is now wrong, update it.
*/ */
if (be16_to_cpu(free->bests[findex]) != be16_to_cpu(data->hdr.bestfree[0].length)) { if (be16_to_cpu(free->bests[findex]) != be16_to_cpu(hdr->bestfree[0].length)) {
free->bests[findex] = data->hdr.bestfree[0].length; free->bests[findex] = hdr->bestfree[0].length;
logfree = 1; logfree = 1;
} }
/* /*
...@@ -1857,7 +1857,7 @@ xfs_dir2_node_replace( ...@@ -1857,7 +1857,7 @@ xfs_dir2_node_replace(
xfs_da_args_t *args) /* operation arguments */ xfs_da_args_t *args) /* operation arguments */
{ {
xfs_da_state_blk_t *blk; /* leaf block */ xfs_da_state_blk_t *blk; /* leaf block */
xfs_dir2_data_t *data; /* data block structure */ xfs_dir2_data_hdr_t *hdr; /* data block header */
xfs_dir2_data_entry_t *dep; /* data entry changed */ xfs_dir2_data_entry_t *dep; /* data entry changed */
int error; /* error return value */ int error; /* error return value */
int i; /* btree level */ int i; /* btree level */
...@@ -1901,10 +1901,10 @@ xfs_dir2_node_replace( ...@@ -1901,10 +1901,10 @@ xfs_dir2_node_replace(
/* /*
* Point to the data entry. * Point to the data entry.
*/ */
data = state->extrablk.bp->data; hdr = state->extrablk.bp->data;
ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC); ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC);
dep = (xfs_dir2_data_entry_t *) dep = (xfs_dir2_data_entry_t *)
((char *)data + ((char *)hdr +
xfs_dir2_dataptr_to_off(state->mp, be32_to_cpu(lep->address))); xfs_dir2_dataptr_to_off(state->mp, be32_to_cpu(lep->address)));
ASSERT(inum != be64_to_cpu(dep->inumber)); ASSERT(inum != be64_to_cpu(dep->inumber));
/* /*
......
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