From 5ce1d1f778739e27bfab992437d25d89a96a8bf5 Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Wed, 17 Apr 2002 05:34:30 +0000 Subject: [PATCH] bump minor version for minor change - sync with recent kernel changes (mainly do less endian swabbing on some code paths). --- VERSION | 2 +- debian/changelog | 6 ++++++ doc/CHANGES | 4 ++++ include/xfs_dinode.h | 2 +- include/xfs_log.h | 2 ++ libxfs/xfs.h | 2 +- libxfs/xfs_alloc.c | 2 +- libxfs/xfs_attr_leaf.c | 45 +++++++++++++++++++-------------------- libxfs/xfs_btree.c | 12 +++++------ libxfs/xfs_da_btree.c | 8 +++---- libxfs/xfs_dir2_block.c | 6 +++--- libxfs/xfs_dir2_data.c | 28 ++++++++++++------------ libxfs/xfs_dir2_leaf.c | 12 +++++------ libxfs/xfs_dir2_node.c | 2 +- libxfs/xfs_dir_leaf.c | 14 ++++++------ libxfs/xfs_ialloc.c | 11 ++++++---- libxlog/xfs_log_recover.c | 3 ++- 17 files changed, 88 insertions(+), 73 deletions(-) diff --git a/VERSION b/VERSION index a5c287cb1..d6fb318cb 100644 --- a/VERSION +++ b/VERSION @@ -3,5 +3,5 @@ # PKG_MAJOR=2 PKG_MINOR=0 -PKG_REVISION=3 +PKG_REVISION=4 PKG_BUILD=0 diff --git a/debian/changelog b/debian/changelog index be8dec815..066785d69 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +xfsprogs (2.0.4-1) unstable; urgency=low + + * New upstream release, minor changes only + + -- Nathan Scott Wed, 17 Apr 2002 15:30:52 +1000 + xfsprogs (2.0.3-1) unstable; urgency=low * New upstream bugfix release diff --git a/doc/CHANGES b/doc/CHANGES index ba1eff256..91c11469c 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,3 +1,7 @@ +xfsprogs-2.0.4 (17 April 2002) + - Minor update sync'ing with kernel changes (less endian + swabbing in libxfs code) + xfsprogs-2.0.3 (13 April 2002) - Important build system update, was causing libxfs to be built incorrectly, which can cause xfs_repair to fail by diff --git a/include/xfs_dinode.h b/include/xfs_dinode.h index 27641928a..4e5bb2a14 100644 --- a/include/xfs_dinode.h +++ b/include/xfs_dinode.h @@ -206,7 +206,7 @@ int xfs_cfork_q(xfs_dinode_core_t *dcp); #define XFS_CFORK_Q_ARCH(dcp,arch) xfs_cfork_q_arch(dcp,arch) #define XFS_CFORK_Q(dcp) xfs_cfork_q(dcp) #else -#define XFS_CFORK_Q_ARCH(dcp,arch) (INT_GET((dcp)->di_forkoff, arch) != 0) +#define XFS_CFORK_Q_ARCH(dcp,arch) (!INT_ISZERO((dcp)->di_forkoff, arch)) #define XFS_CFORK_Q(dcp) ((dcp)->di_forkoff != 0) #endif diff --git a/include/xfs_log.h b/include/xfs_log.h index 3de4125f4..535305fa7 100644 --- a/include/xfs_log.h +++ b/include/xfs_log.h @@ -44,6 +44,8 @@ #define CYCLE_LSN(lsn,arch) (INT_GET(((uint *)&(lsn))[LSN_FIELD_CYCLE(arch)], arch)) #define BLOCK_LSN(lsn,arch) (INT_GET(((uint *)&(lsn))[LSN_FIELD_BLOCK(arch)], arch)) +/* this is used in a spot where we might otherwise double-endian-flip */ +#define CYCLE_LSN_NOCONV(lsn,arch) (((uint *)&(lsn))[LSN_FIELD_CYCLE(arch)]) #ifdef __KERNEL__ /* diff --git a/libxfs/xfs.h b/libxfs/xfs.h index 6d486b7e0..10679b9a3 100644 --- a/libxfs/xfs.h +++ b/libxfs/xfs.h @@ -235,7 +235,7 @@ typedef __uint32_t inst_t; /* an instruction */ typedef enum { B_FALSE, B_TRUE } boolean_t; typedef struct { dev_t dev; } buftarg_t; #define STATIC -#define ATTR_ROOT 1 /* use attrs in root namespace */ +#define ATTR_ROOT 0x0002 /* use attrs in root namespace */ #define ENOATTR ENODATA /* Attribute not found */ #define EFSCORRUPTED 990 /* Filesystem is corrupted */ #define ktrace_t void diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c index 28fe364ff..c4caa7f09 100644 --- a/libxfs/xfs_alloc.c +++ b/libxfs/xfs_alloc.c @@ -1921,7 +1921,7 @@ xfs_alloc_get_freelist( /* * Freelist is empty, give up. */ - if (INT_GET(agf->agf_flcount, ARCH_CONVERT) == 0) { + if (INT_ISZERO(agf->agf_flcount, ARCH_CONVERT)) { *bnop = NULLAGBLOCK; return 0; } diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index f3b02e0b8..58b37a0bd 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/libxfs/xfs_attr_leaf.c @@ -67,7 +67,7 @@ xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp) hdr = &leaf->hdr; INT_SET(hdr->info.magic, ARCH_CONVERT, XFS_ATTR_LEAF_MAGIC); INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount)); - if (INT_GET(hdr->firstused, ARCH_CONVERT) == 0) { + if (INT_ISZERO(hdr->firstused, ARCH_CONVERT)) { INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount) - XFS_ATTR_LEAF_NAME_ALIGN); } @@ -170,7 +170,7 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args) sum += INT_GET(map->size, ARCH_CONVERT); continue; } - if (INT_GET(map->size, ARCH_CONVERT) == 0) + if (INT_ISZERO(map->size, ARCH_CONVERT)) continue; /* no space in this map */ tmp = entsize; if (INT_GET(map->base, ARCH_CONVERT) @@ -302,8 +302,8 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex) bcopy(args->name, (char *)name_rmt->name, args->namelen); entry->flags |= XFS_ATTR_INCOMPLETE; /* just in case */ - INT_SET(name_rmt->valuelen, ARCH_CONVERT, 0); - INT_SET(name_rmt->valueblk, ARCH_CONVERT, 0); + INT_ZERO(name_rmt->valuelen, ARCH_CONVERT); + INT_ZERO(name_rmt->valueblk, ARCH_CONVERT); args->rmtblkno = 1; args->rmtblkcnt = XFS_B_TO_FSB(mp, args->valuelen); } @@ -316,8 +316,8 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex) */ if (INT_GET(entry->nameidx, ARCH_CONVERT) < INT_GET(hdr->firstused, ARCH_CONVERT)) { - INT_SET(hdr->firstused, ARCH_CONVERT, - INT_GET(entry->nameidx, ARCH_CONVERT)); + /* both on-disk, don't endian-flip twice */ + hdr->firstused = entry->nameidx; } ASSERT(INT_GET(hdr->firstused, ARCH_CONVERT) >= ((INT_GET(hdr->count, ARCH_CONVERT) @@ -368,12 +368,12 @@ xfs_attr_leaf_compact(xfs_trans_t *trans, xfs_dabuf_t *bp) hdr_d->info = hdr_s->info; /* struct copy */ INT_SET(hdr_d->firstused, ARCH_CONVERT, XFS_LBSIZE(mp)); /* handle truncation gracefully */ - if (INT_GET(hdr_d->firstused, ARCH_CONVERT) == 0) { + if (INT_ISZERO(hdr_d->firstused, ARCH_CONVERT)) { INT_SET(hdr_d->firstused, ARCH_CONVERT, XFS_LBSIZE(mp) - XFS_ATTR_LEAF_NAME_ALIGN); } - INT_SET(hdr_d->usedbytes, ARCH_CONVERT, 0); - INT_SET(hdr_d->count, ARCH_CONVERT, 0); + INT_ZERO(hdr_d->usedbytes, ARCH_CONVERT); + INT_ZERO(hdr_d->count, ARCH_CONVERT); hdr_d->holes = 0; INT_SET(hdr_d->freemap[0].base, ARCH_CONVERT, sizeof(xfs_attr_leaf_hdr_t)); @@ -727,7 +727,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action) * Make altpath point to the block we want to keep and * path point to the block we want to drop (this one). */ - forward = (INT_GET(info->forw, ARCH_CONVERT) != 0); + forward = (!INT_ISZERO(info->forw, ARCH_CONVERT)); bcopy(&state->path, &state->altpath, sizeof(state->path)); error = xfs_da_path_shift(state, &state->altpath, forward, 0, &retval); @@ -871,13 +871,13 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, tmp_leaf = (xfs_attr_leafblock_t *)tmpbuffer; tmp_hdr = &tmp_leaf->hdr; tmp_hdr->info = save_hdr->info; /* struct copy */ - INT_SET(tmp_hdr->count, ARCH_CONVERT, 0); + INT_ZERO(tmp_hdr->count, ARCH_CONVERT); INT_SET(tmp_hdr->firstused, ARCH_CONVERT, state->blocksize); - if (INT_GET(tmp_hdr->firstused, ARCH_CONVERT) == 0) { + if (INT_ISZERO(tmp_hdr->firstused, ARCH_CONVERT)) { INT_SET(tmp_hdr->firstused, ARCH_CONVERT, state->blocksize - XFS_ATTR_LEAF_NAME_ALIGN); } - INT_SET(tmp_hdr->usedbytes, ARCH_CONVERT, 0); + INT_ZERO(tmp_hdr->usedbytes, ARCH_CONVERT); if (xfs_attr_leaf_order(save_blk->bp, drop_blk->bp)) { xfs_attr_leaf_moveents(drop_leaf, 0, tmp_leaf, 0, (int)INT_GET(drop_hdr->count, ARCH_CONVERT), @@ -999,11 +999,10 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s, } else { #endif /* GROT */ INT_MOD(hdr_d->firstused, ARCH_CONVERT, -tmp); - INT_SET(entry_d->hashval, ARCH_CONVERT, - INT_GET(entry_s->hashval, ARCH_CONVERT)); - INT_SET(entry_d->nameidx, ARCH_CONVERT, - INT_GET(hdr_d->firstused, - ARCH_CONVERT)); + /* both on-disk, don't endian flip twice */ + entry_d->hashval = entry_s->hashval; + /* both on-disk, don't endian flip twice */ + entry_d->nameidx = hdr_d->firstused; entry_d->flags = entry_s->flags; ASSERT(INT_GET(entry_d->nameidx, ARCH_CONVERT) + tmp <= XFS_LBSIZE(mp)); @@ -1064,10 +1063,10 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s, INT_SET(hdr_d->freemap[0].size, ARCH_CONVERT, INT_GET(hdr_d->firstused, ARCH_CONVERT) - INT_GET(hdr_d->freemap[0].base, ARCH_CONVERT)); - INT_SET(hdr_d->freemap[1].base, ARCH_CONVERT, 0); - INT_SET(hdr_d->freemap[2].base, ARCH_CONVERT, 0); - INT_SET(hdr_d->freemap[1].size, ARCH_CONVERT, 0); - INT_SET(hdr_d->freemap[2].size, ARCH_CONVERT, 0); + INT_ZERO(hdr_d->freemap[1].base, ARCH_CONVERT); + INT_ZERO(hdr_d->freemap[2].base, ARCH_CONVERT); + INT_ZERO(hdr_d->freemap[1].size, ARCH_CONVERT); + INT_ZERO(hdr_d->freemap[2].size, ARCH_CONVERT); hdr_s->holes = 1; /* leaf may not be compact */ } @@ -1112,7 +1111,7 @@ xfs_attr_leaf_lasthash(xfs_dabuf_t *bp, int *count) == XFS_ATTR_LEAF_MAGIC); if (count) *count = INT_GET(leaf->hdr.count, ARCH_CONVERT); - if (INT_GET(leaf->hdr.count, ARCH_CONVERT) == 0) + if (INT_ISZERO(leaf->hdr.count, ARCH_CONVERT)) return(0); return(INT_GET(leaf->entries[INT_GET(leaf->hdr.count, ARCH_CONVERT)-1].hashval, ARCH_CONVERT)); diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index 863533482..34d3f55db 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -184,10 +184,10 @@ xfs_btree_check_lblock( INT_GET(block->bb_level, ARCH_CONVERT) == level && INT_GET(block->bb_numrecs, ARCH_CONVERT) <= xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) && - INT_GET(block->bb_leftsib, ARCH_CONVERT) != 0 && + !INT_ISZERO(block->bb_leftsib, ARCH_CONVERT) && (INT_GET(block->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO || XFS_FSB_SANITY_CHECK(mp, INT_GET(block->bb_leftsib, ARCH_CONVERT))) && - INT_GET(block->bb_rightsib, ARCH_CONVERT) != 0 && + !INT_ISZERO(block->bb_rightsib, ARCH_CONVERT) && (INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO || XFS_FSB_SANITY_CHECK(mp, INT_GET(block->bb_rightsib, ARCH_CONVERT))); if (XFS_TEST_ERROR(!lblock_ok, mp, XFS_ERRTAG_BTREE_CHECK_LBLOCK, @@ -308,10 +308,10 @@ xfs_btree_check_sblock( xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) && (INT_GET(block->bb_leftsib, ARCH_CONVERT) == NULLAGBLOCK || INT_GET(block->bb_leftsib, ARCH_CONVERT) < agflen) && - INT_GET(block->bb_leftsib, ARCH_CONVERT) != 0 && + !INT_ISZERO(block->bb_leftsib, ARCH_CONVERT) && (INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK || INT_GET(block->bb_rightsib, ARCH_CONVERT) < agflen) && - INT_GET(block->bb_rightsib, ARCH_CONVERT) != 0; + !INT_ISZERO(block->bb_rightsib, ARCH_CONVERT); if (XFS_TEST_ERROR(!sblock_ok, cur->bc_mp, XFS_ERRTAG_BTREE_CHECK_SBLOCK, XFS_RANDOM_BTREE_CHECK_SBLOCK)) { @@ -472,7 +472,7 @@ xfs_btree_firstrec( /* * It's empty, there is no such record. */ - if (INT_GET(block->bb_h.bb_numrecs, ARCH_CONVERT) == 0) + if (INT_ISZERO(block->bb_h.bb_numrecs, ARCH_CONVERT)) return 0; /* * Set the ptr value to 1, that's the first record/key. @@ -686,7 +686,7 @@ xfs_btree_lastrec( /* * It's empty, there is no such record. */ - if (INT_GET(block->bb_h.bb_numrecs, ARCH_CONVERT) == 0) + if (INT_ISZERO(block->bb_h.bb_numrecs, ARCH_CONVERT)) return 0; /* * Set the ptr value to numrecs, that's the last record/key. diff --git a/libxfs/xfs_da_btree.c b/libxfs/xfs_da_btree.c index 4d7ed947f..70f60f7ff 100644 --- a/libxfs/xfs_da_btree.c +++ b/libxfs/xfs_da_btree.c @@ -738,8 +738,8 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk) } else { ASSERT(INT_GET(blkinfo->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); } - ASSERT(INT_GET(blkinfo->forw, ARCH_CONVERT) == 0); - ASSERT(INT_GET(blkinfo->back, ARCH_CONVERT) == 0); + ASSERT(INT_ISZERO(blkinfo->forw, ARCH_CONVERT)); + ASSERT(INT_ISZERO(blkinfo->back, ARCH_CONVERT)); bcopy(bp->data, root_blk->bp->data, state->blocksize); xfs_da_log_buf(args->trans, root_blk->bp, 0, state->blocksize - 1); error = xfs_da_shrink_inode(args, child, bp); @@ -1344,7 +1344,7 @@ xfs_da_node_lasthash(xfs_dabuf_t *bp, int *count) ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); if (count) *count = INT_GET(node->hdr.count, ARCH_CONVERT); - if (INT_GET(node->hdr.count, ARCH_CONVERT) == 0) + if (INT_ISZERO(node->hdr.count, ARCH_CONVERT)) return(0); return(INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT)); } @@ -2157,7 +2157,7 @@ xfs_da_do_buf( (magic != XFS_DIR2_LEAFN_MAGIC) && (magic1 != XFS_DIR2_BLOCK_MAGIC) && (magic1 != XFS_DIR2_DATA_MAGIC) && - (magic1 != XFS_DIR2_FREE_MAGIC), + (INT_GET(free->hdr.magic, ARCH_CONVERT) != XFS_DIR2_FREE_MAGIC), mp, XFS_ERRTAG_DA_READ_BUF, XFS_RANDOM_DA_READ_BUF)) { xfs_buftrace("DA READ ERROR", rbp->bps[0]); diff --git a/libxfs/xfs_dir2_block.c b/libxfs/xfs_dir2_block.c index 6508475da..a8ca760f9 100644 --- a/libxfs/xfs_dir2_block.c +++ b/libxfs/xfs_dir2_block.c @@ -101,7 +101,7 @@ xfs_dir2_block_addname( /* * No stale entries? Need space for entry and new leaf. */ - if (INT_GET(btp->stale, ARCH_CONVERT) == 0) { + if (INT_ISZERO(btp->stale, ARCH_CONVERT)) { /* * Tag just before the first leaf entry. */ @@ -289,7 +289,7 @@ xfs_dir2_block_addname( /* * No stale entries, will use enddup space to hold new leaf. */ - if (INT_GET(btp->stale, ARCH_CONVERT) == 0) { + if (INT_ISZERO(btp->stale, ARCH_CONVERT)) { /* * Mark the space needed for the new leaf entry, now in use. */ @@ -828,7 +828,7 @@ xfs_dir2_leaf_to_block( */ btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); INT_SET(btp->count, ARCH_CONVERT, INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT)); - INT_SET(btp->stale, ARCH_CONVERT, 0); + INT_ZERO(btp->stale, ARCH_CONVERT); xfs_dir2_block_log_tail(tp, dbp); /* * Initialize the block leaf area. We compact out stale entries. diff --git a/libxfs/xfs_dir2_data.c b/libxfs/xfs_dir2_data.c index 9ef50b90a..34cab2399 100644 --- a/libxfs/xfs_dir2_data.c +++ b/libxfs/xfs_dir2_data.c @@ -82,16 +82,16 @@ xfs_dir2_data_check( /* * Account for zero bestfree entries. */ - if (INT_GET(bf[0].length, ARCH_CONVERT) == 0) { - ASSERT(INT_GET(bf[0].offset, ARCH_CONVERT) == 0); + if (INT_ISZERO(bf[0].length, ARCH_CONVERT)) { + ASSERT(INT_ISZERO(bf[0].offset, ARCH_CONVERT)); freeseen |= 1 << 0; } - if (INT_GET(bf[1].length, ARCH_CONVERT) == 0) { - ASSERT(INT_GET(bf[1].offset, ARCH_CONVERT) == 0); + if (INT_ISZERO(bf[1].length, ARCH_CONVERT)) { + ASSERT(INT_ISZERO(bf[1].offset, ARCH_CONVERT)); freeseen |= 1 << 1; } - if (INT_GET(bf[2].length, ARCH_CONVERT) == 0) { - ASSERT(INT_GET(bf[2].offset, ARCH_CONVERT) == 0); + if (INT_ISZERO(bf[2].length, ARCH_CONVERT)) { + ASSERT(INT_ISZERO(bf[2].offset, ARCH_CONVERT)); freeseen |= 1 << 2; } ASSERT(INT_GET(bf[0].length, ARCH_CONVERT) >= INT_GET(bf[1].length, ARCH_CONVERT)); @@ -193,8 +193,8 @@ xfs_dir2_data_freefind( for (dfp = &d->hdr.bestfree[0], seenzero = matched = 0; dfp < &d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT]; dfp++) { - if (INT_GET(dfp->offset, ARCH_CONVERT) == 0) { - ASSERT(INT_GET(dfp->length, ARCH_CONVERT) == 0); + if (INT_ISZERO(dfp->offset, ARCH_CONVERT)) { + ASSERT(INT_ISZERO(dfp->length, ARCH_CONVERT)); seenzero = 1; continue; } @@ -223,7 +223,7 @@ xfs_dir2_data_freefind( for (dfp = &d->hdr.bestfree[0]; dfp < &d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT]; dfp++) { - if (INT_GET(dfp->offset, ARCH_CONVERT) == 0) + if (INT_ISZERO(dfp->offset, ARCH_CONVERT)) return NULL; if (INT_GET(dfp->offset, ARCH_CONVERT) == off) return dfp; @@ -584,7 +584,7 @@ xfs_dir2_data_make_free( * since the third bestfree is there, there might be more * entries. */ - needscan = INT_GET(d->hdr.bestfree[2].length, ARCH_CONVERT) != 0; + needscan = !INT_ISZERO(d->hdr.bestfree[2].length, ARCH_CONVERT); /* * Fix up the new big freespace. */ @@ -613,8 +613,8 @@ xfs_dir2_data_make_free( dfp = xfs_dir2_data_freeinsert(d, prevdup, needlogp); ASSERT(dfp == &d->hdr.bestfree[0]); ASSERT(INT_GET(dfp->length, ARCH_CONVERT) == INT_GET(prevdup->length, ARCH_CONVERT)); - ASSERT(INT_GET(dfp[1].length, ARCH_CONVERT) == 0); - ASSERT(INT_GET(dfp[2].length, ARCH_CONVERT) == 0); + ASSERT(INT_ISZERO(dfp[1].length, ARCH_CONVERT)); + ASSERT(INT_ISZERO(dfp[2].length, ARCH_CONVERT)); } } /* @@ -730,7 +730,7 @@ xfs_dir2_data_use_free( */ if (matchfront && matchback) { if (dfp) { - needscan = INT_GET(d->hdr.bestfree[2].offset, ARCH_CONVERT) != 0; + needscan = !INT_ISZERO(d->hdr.bestfree[2].offset, ARCH_CONVERT); if (!needscan) xfs_dir2_data_freeremove(d, dfp, needlogp); } @@ -817,7 +817,7 @@ xfs_dir2_data_use_free( * the 2 new will work. */ if (dfp) { - needscan = INT_GET(d->hdr.bestfree[2].length, ARCH_CONVERT) != 0; + needscan = !INT_ISZERO(d->hdr.bestfree[2].length, ARCH_CONVERT); if (!needscan) { xfs_dir2_data_freeremove(d, dfp, needlogp); (void)xfs_dir2_data_freeinsert(d, newdup, diff --git a/libxfs/xfs_dir2_leaf.c b/libxfs/xfs_dir2_leaf.c index 19a68b208..e1902936a 100644 --- a/libxfs/xfs_dir2_leaf.c +++ b/libxfs/xfs_dir2_leaf.c @@ -237,7 +237,7 @@ xfs_dir2_leaf_addname( * How many bytes do we need in the leaf block? */ needbytes = - (INT_GET(leaf->hdr.stale, ARCH_CONVERT) != 0 ? 0 : (uint)sizeof(leaf->ents[0])) + + (!INT_ISZERO(leaf->hdr.stale, ARCH_CONVERT) ? 0 : (uint)sizeof(leaf->ents[0])) + (use_block != -1 ? 0 : (uint)sizeof(leaf->bests[0])); /* * Now kill use_block if it refers to a missing block, so we @@ -419,7 +419,7 @@ xfs_dir2_leaf_addname( * Now we need to make room to insert the leaf entry. * If there are no stale entries, we just insert a hole at index. */ - if (INT_GET(leaf->hdr.stale, ARCH_CONVERT) == 0) { + if (INT_ISZERO(leaf->hdr.stale, ARCH_CONVERT)) { /* * lep is still good as the index leaf entry. */ @@ -589,7 +589,7 @@ xfs_dir2_leaf_compact( int to; /* target leaf index */ leaf = bp->data; - if (INT_GET(leaf->hdr.stale, ARCH_CONVERT) == 0) { + if (INT_ISZERO(leaf->hdr.stale, ARCH_CONVERT)) { return; } /* @@ -613,7 +613,7 @@ xfs_dir2_leaf_compact( */ ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) == from - to); INT_MOD(leaf->hdr.count, ARCH_CONVERT, -(INT_GET(leaf->hdr.stale, ARCH_CONVERT))); - INT_SET(leaf->hdr.stale, ARCH_CONVERT, 0); + INT_ZERO(leaf->hdr.stale, ARCH_CONVERT); xfs_dir2_leaf_log_header(args->trans, bp); if (loglow != -1) xfs_dir2_leaf_log_ents(args->trans, bp, loglow, to - 1); @@ -779,7 +779,7 @@ xfs_dir2_leaf_init( */ if (magic == XFS_DIR2_LEAF1_MAGIC) { ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); - INT_SET(ltp->bestcount, ARCH_CONVERT, 0); + INT_ZERO(ltp->bestcount, ARCH_CONVERT); xfs_dir2_leaf_log_tail(tp, bp); } *bpp = bp; @@ -1233,7 +1233,7 @@ xfs_dir2_leaf_search_hash( leaf = lbp->data; #ifndef __KERNEL__ - if (INT_GET(leaf->hdr.count, ARCH_CONVERT) == 0) + if (INT_ISZERO(leaf->hdr.count, ARCH_CONVERT)) return 0; #endif /* diff --git a/libxfs/xfs_dir2_node.c b/libxfs/xfs_dir2_node.c index 743923f15..2f995fd3c 100644 --- a/libxfs/xfs_dir2_node.c +++ b/libxfs/xfs_dir2_node.c @@ -950,7 +950,7 @@ xfs_dir2_leafn_remove( * If there are no useful entries left in the block, * get rid of the block if we can. */ - if (INT_GET(free->hdr.nused, ARCH_CONVERT) == 0) { + if (INT_ISZERO(free->hdr.nused, ARCH_CONVERT)) { error = xfs_dir2_shrink_inode(args, fdb, fbp); if (error == 0) { fbp = NULL; diff --git a/libxfs/xfs_dir_leaf.c b/libxfs/xfs_dir_leaf.c index f0abc762e..67a7c9d20 100644 --- a/libxfs/xfs_dir_leaf.c +++ b/libxfs/xfs_dir_leaf.c @@ -458,7 +458,7 @@ xfs_dir_leaf_to_shortform(xfs_da_args_t *iargs) args.justcheck = 0; args.addname = args.oknoent = 1; for (i = 0; i < INT_GET(hdr->count, ARCH_CONVERT); entry++, i++) { - if (INT_GET(entry->nameidx, ARCH_CONVERT) == 0) + if (INT_ISZERO(entry->nameidx, ARCH_CONVERT)) continue; namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, INT_GET(entry->nameidx, ARCH_CONVERT)); args.name = (char *)(namest->name); @@ -652,7 +652,7 @@ xfs_dir_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args, int index) sum += INT_GET(map->size, ARCH_CONVERT); continue; } - if (INT_GET(map->size, ARCH_CONVERT) == 0) + if (INT_ISZERO(map->size, ARCH_CONVERT)) continue; /* no space in this map */ tmp = entsize; if (INT_GET(map->base, ARCH_CONVERT) < INT_GET(hdr->firstused, ARCH_CONVERT)) @@ -817,7 +817,7 @@ xfs_dir_leaf_compact(xfs_trans_t *trans, xfs_dabuf_t *bp, int musthave, hdr_d = &leaf_d->hdr; hdr_d->info = hdr_s->info; /* struct copy */ INT_SET(hdr_d->firstused, ARCH_CONVERT, lbsize); - if (INT_GET(hdr_d->firstused, ARCH_CONVERT) == 0) + if (INT_ISZERO(hdr_d->firstused, ARCH_CONVERT)) INT_SET(hdr_d->firstused, ARCH_CONVERT, lbsize - 1); INT_ZERO(hdr_d->namebytes, ARCH_CONVERT); INT_ZERO(hdr_d->count, ARCH_CONVERT); @@ -1333,7 +1333,7 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index) tmp = INT_GET(entry->nameidx, ARCH_CONVERT); } INT_SET(hdr->firstused, ARCH_CONVERT, tmp); - if (INT_GET(hdr->firstused, ARCH_CONVERT) == 0) + if (INT_ISZERO(hdr->firstused, ARCH_CONVERT)) INT_SET(hdr->firstused, ARCH_CONVERT, tmp - 1); } else { hdr->holes = 1; /* mark as needing compaction */ @@ -1415,7 +1415,7 @@ xfs_dir_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, tmp_hdr->info = save_hdr->info; /* struct copy */ INT_ZERO(tmp_hdr->count, ARCH_CONVERT); INT_SET(tmp_hdr->firstused, ARCH_CONVERT, state->blocksize); - if (INT_GET(tmp_hdr->firstused, ARCH_CONVERT) == 0) + if (INT_ISZERO(tmp_hdr->firstused, ARCH_CONVERT)) INT_SET(tmp_hdr->firstused, ARCH_CONVERT, state->blocksize - 1); INT_ZERO(tmp_hdr->namebytes, ARCH_CONVERT); if (xfs_dir_leaf_order(save_blk->bp, drop_blk->bp)) { @@ -1490,7 +1490,7 @@ xfs_dir_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args, int *index) break; } ASSERT((probe >= 0) && \ - ((INT_GET(leaf->hdr.count, ARCH_CONVERT) == 0) || (probe < INT_GET(leaf->hdr.count, ARCH_CONVERT)))); + ((INT_ISZERO(leaf->hdr.count, ARCH_CONVERT)) || (probe < INT_GET(leaf->hdr.count, ARCH_CONVERT)))); ASSERT((span <= 4) || (INT_GET(entry->hashval, ARCH_CONVERT) == hashval)); /* @@ -1684,7 +1684,7 @@ xfs_dir_leaf_lasthash(xfs_dabuf_t *bp, int *count) ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); if (count) *count = INT_GET(leaf->hdr.count, ARCH_CONVERT); - if (INT_GET(leaf->hdr.count, ARCH_CONVERT) == 0) + if (INT_ISZERO(leaf->hdr.count, ARCH_CONVERT)) return(0); return(INT_GET(leaf->entries[ INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT)); } diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index cc6eb3c83..680c8b25c 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -370,8 +370,11 @@ xfs_ialloc_ag_select( agcount = mp->m_maxagi; if (S_ISDIR(mode)) pagno = atomicIncWithWrap((int *)&mp->m_agirotor, agcount); - else + else { pagno = XFS_INO_TO_AGNO(mp, parent); + if (pagno >= agcount) + pagno = 0; + } ASSERT(pagno < agcount); /* * Loop through allocation groups, looking for one with a little @@ -442,7 +445,7 @@ nextag: if (XFS_FORCED_SHUTDOWN(mp)) return (xfs_buf_t *)0; agno++; - if (agno == agcount) + if (agno >= agcount) agno = 0; if (agno == pagno) { if (flags == 0) @@ -565,7 +568,7 @@ xfs_dialloc( * allocation groups upward, wrapping at the end. */ *alloc_done = B_FALSE; - while (INT_GET(agi->agi_freecount, ARCH_CONVERT) == 0) { + while (INT_ISZERO(agi->agi_freecount, ARCH_CONVERT)) { /* * Don't do anything if we're not supposed to allocate * any blocks, just go on to the next ag. @@ -1166,7 +1169,7 @@ xfs_ialloc_read_agi( } #ifdef DEBUG for (i = 0; i < XFS_AGI_UNLINKED_BUCKETS; i++) - ASSERT(INT_GET(agi->agi_unlinked[i], ARCH_CONVERT) != 0); + ASSERT(!INT_ISZERO(agi->agi_unlinked[i], ARCH_CONVERT)); #endif XFS_BUF_SET_VTYPE_REF(bp, B_FS_AGI, XFS_AGI_REF); *bpp = bp; diff --git a/libxlog/xfs_log_recover.c b/libxlog/xfs_log_recover.c index be7e6c272..c1c31baca 100644 --- a/libxlog/xfs_log_recover.c +++ b/libxlog/xfs_log_recover.c @@ -766,7 +766,8 @@ xlog_unpack_data(xlog_rec_header_t *rhead, #endif for (i=0; ih_len, ARCH_CONVERT)); i++) { - INT_SET(*(uint *)dp, ARCH_CONVERT, INT_GET(*(uint *)&rhead->h_cycle_data[i], ARCH_CONVERT)); + /* these are both on-disk, so don't endian flip twice */ + *(uint *)dp = *(uint *)&rhead->h_cycle_data[i]; dp += BBSIZE; } #if defined(DEBUG) && defined(XFS_LOUD_RECOVERY) -- 2.47.2