aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_dir_leaf.c
diff options
context:
space:
mode:
authorNathan Scott <nathans@sgi.com>2006-03-17 01:28:40 -0500
committerNathan Scott <nathans@sgi.com>2006-03-17 01:28:40 -0500
commit89da054424a775b4b257556eda8a300be1134d7c (patch)
treeb7a6d19ee5baaebf2794271dabaf0f59d44f9fa6 /fs/xfs/xfs_dir_leaf.c
parent3d693c6ed7892d066e8fb3311c6b74f7699326f9 (diff)
[XFS] endianess annotations for xfs_da_blkinfo_t
SGI-PV: 943272 SGI-Modid: xfs-linux-melb:xfs-kern:25495a Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nathan Scott <nathans@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_dir_leaf.c')
-rw-r--r--fs/xfs/xfs_dir_leaf.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/fs/xfs/xfs_dir_leaf.c b/fs/xfs/xfs_dir_leaf.c
index e83074016abb..0b2eca590b36 100644
--- a/fs/xfs/xfs_dir_leaf.c
+++ b/fs/xfs/xfs_dir_leaf.c
@@ -644,7 +644,7 @@ xfs_dir_leaf_to_shortform(xfs_da_args_t *iargs)
644 ASSERT(bp != NULL); 644 ASSERT(bp != NULL);
645 memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount)); 645 memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount));
646 leaf = (xfs_dir_leafblock_t *)tmpbuffer; 646 leaf = (xfs_dir_leafblock_t *)tmpbuffer;
647 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); 647 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
648 memset(bp->data, 0, XFS_LBSIZE(dp->i_mount)); 648 memset(bp->data, 0, XFS_LBSIZE(dp->i_mount));
649 649
650 /* 650 /*
@@ -742,7 +742,7 @@ xfs_dir_leaf_to_node(xfs_da_args_t *args)
742 } 742 }
743 node = bp1->data; 743 node = bp1->data;
744 leaf = bp2->data; 744 leaf = bp2->data;
745 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); 745 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
746 INT_SET(node->btree[0].hashval, ARCH_CONVERT, INT_GET(leaf->entries[ INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT)); 746 INT_SET(node->btree[0].hashval, ARCH_CONVERT, INT_GET(leaf->entries[ INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT));
747 xfs_da_buf_done(bp2); 747 xfs_da_buf_done(bp2);
748 INT_SET(node->btree[0].before, ARCH_CONVERT, blkno); 748 INT_SET(node->btree[0].before, ARCH_CONVERT, blkno);
@@ -781,7 +781,7 @@ xfs_dir_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp)
781 leaf = bp->data; 781 leaf = bp->data;
782 memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount)); 782 memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount));
783 hdr = &leaf->hdr; 783 hdr = &leaf->hdr;
784 INT_SET(hdr->info.magic, ARCH_CONVERT, XFS_DIR_LEAF_MAGIC); 784 hdr->info.magic = cpu_to_be16(XFS_DIR_LEAF_MAGIC);
785 INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount)); 785 INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount));
786 if (!hdr->firstused) 786 if (!hdr->firstused)
787 INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount) - 1); 787 INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount) - 1);
@@ -860,7 +860,7 @@ xfs_dir_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args, int index)
860 int tablesize, entsize, sum, i, tmp, error; 860 int tablesize, entsize, sum, i, tmp, error;
861 861
862 leaf = bp->data; 862 leaf = bp->data;
863 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); 863 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
864 ASSERT((index >= 0) && (index <= INT_GET(leaf->hdr.count, ARCH_CONVERT))); 864 ASSERT((index >= 0) && (index <= INT_GET(leaf->hdr.count, ARCH_CONVERT)));
865 hdr = &leaf->hdr; 865 hdr = &leaf->hdr;
866 entsize = XFS_DIR_LEAF_ENTSIZE_BYNAME(args->namelen); 866 entsize = XFS_DIR_LEAF_ENTSIZE_BYNAME(args->namelen);
@@ -940,7 +940,7 @@ xfs_dir_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int index,
940 int tmp, i; 940 int tmp, i;
941 941
942 leaf = bp->data; 942 leaf = bp->data;
943 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); 943 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
944 hdr = &leaf->hdr; 944 hdr = &leaf->hdr;
945 ASSERT((mapindex >= 0) && (mapindex < XFS_DIR_LEAF_MAPSIZE)); 945 ASSERT((mapindex >= 0) && (mapindex < XFS_DIR_LEAF_MAPSIZE));
946 ASSERT((index >= 0) && (index <= INT_GET(hdr->count, ARCH_CONVERT))); 946 ASSERT((index >= 0) && (index <= INT_GET(hdr->count, ARCH_CONVERT)));
@@ -1097,8 +1097,8 @@ xfs_dir_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
1097 ASSERT(blk2->magic == XFS_DIR_LEAF_MAGIC); 1097 ASSERT(blk2->magic == XFS_DIR_LEAF_MAGIC);
1098 leaf1 = blk1->bp->data; 1098 leaf1 = blk1->bp->data;
1099 leaf2 = blk2->bp->data; 1099 leaf2 = blk2->bp->data;
1100 ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); 1100 ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
1101 ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); 1101 ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
1102 1102
1103 /* 1103 /*
1104 * Check ordering of blocks, reverse if it makes things simpler. 1104 * Check ordering of blocks, reverse if it makes things simpler.
@@ -1325,7 +1325,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action)
1325 */ 1325 */
1326 blk = &state->path.blk[ state->path.active-1 ]; 1326 blk = &state->path.blk[ state->path.active-1 ];
1327 info = blk->bp->data; 1327 info = blk->bp->data;
1328 ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); 1328 ASSERT(be16_to_cpu(info->magic) == XFS_DIR_LEAF_MAGIC);
1329 leaf = (xfs_dir_leafblock_t *)info; 1329 leaf = (xfs_dir_leafblock_t *)info;
1330 count = INT_GET(leaf->hdr.count, ARCH_CONVERT); 1330 count = INT_GET(leaf->hdr.count, ARCH_CONVERT);
1331 bytes = (uint)sizeof(xfs_dir_leaf_hdr_t) + 1331 bytes = (uint)sizeof(xfs_dir_leaf_hdr_t) +
@@ -1348,7 +1348,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action)
1348 * Make altpath point to the block we want to keep and 1348 * Make altpath point to the block we want to keep and
1349 * path point to the block we want to drop (this one). 1349 * path point to the block we want to drop (this one).
1350 */ 1350 */
1351 forward = info->forw; 1351 forward = (info->forw != 0);
1352 memcpy(&state->altpath, &state->path, sizeof(state->path)); 1352 memcpy(&state->altpath, &state->path, sizeof(state->path));
1353 error = xfs_da_path_shift(state, &state->altpath, forward, 1353 error = xfs_da_path_shift(state, &state->altpath, forward,
1354 0, &retval); 1354 0, &retval);
@@ -1369,12 +1369,12 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action)
1369 * We prefer coalescing with the lower numbered sibling so as 1369 * We prefer coalescing with the lower numbered sibling so as
1370 * to shrink a directory over time. 1370 * to shrink a directory over time.
1371 */ 1371 */
1372 forward = (INT_GET(info->forw, ARCH_CONVERT) < INT_GET(info->back, ARCH_CONVERT)); /* start with smaller blk num */ 1372 forward = (be32_to_cpu(info->forw) < be32_to_cpu(info->back)); /* start with smaller blk num */
1373 for (i = 0; i < 2; forward = !forward, i++) { 1373 for (i = 0; i < 2; forward = !forward, i++) {
1374 if (forward) 1374 if (forward)
1375 blkno = INT_GET(info->forw, ARCH_CONVERT); 1375 blkno = be32_to_cpu(info->forw);
1376 else 1376 else
1377 blkno = INT_GET(info->back, ARCH_CONVERT); 1377 blkno = be32_to_cpu(info->back);
1378 if (blkno == 0) 1378 if (blkno == 0)
1379 continue; 1379 continue;
1380 error = xfs_da_read_buf(state->args->trans, state->args->dp, 1380 error = xfs_da_read_buf(state->args->trans, state->args->dp,
@@ -1389,7 +1389,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action)
1389 bytes = state->blocksize - (state->blocksize>>2); 1389 bytes = state->blocksize - (state->blocksize>>2);
1390 bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT); 1390 bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT);
1391 leaf = bp->data; 1391 leaf = bp->data;
1392 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); 1392 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
1393 count += INT_GET(leaf->hdr.count, ARCH_CONVERT); 1393 count += INT_GET(leaf->hdr.count, ARCH_CONVERT);
1394 bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT); 1394 bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT);
1395 bytes -= count * ((uint)sizeof(xfs_dir_leaf_name_t) - 1); 1395 bytes -= count * ((uint)sizeof(xfs_dir_leaf_name_t) - 1);
@@ -1447,7 +1447,7 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index)
1447 xfs_mount_t *mp; 1447 xfs_mount_t *mp;
1448 1448
1449 leaf = bp->data; 1449 leaf = bp->data;
1450 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); 1450 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
1451 hdr = &leaf->hdr; 1451 hdr = &leaf->hdr;
1452 mp = trans->t_mountp; 1452 mp = trans->t_mountp;
1453 ASSERT((INT_GET(hdr->count, ARCH_CONVERT) > 0) && (INT_GET(hdr->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8))); 1453 ASSERT((INT_GET(hdr->count, ARCH_CONVERT) > 0) && (INT_GET(hdr->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8)));
@@ -1599,8 +1599,8 @@ xfs_dir_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1599 ASSERT(save_blk->magic == XFS_DIR_LEAF_MAGIC); 1599 ASSERT(save_blk->magic == XFS_DIR_LEAF_MAGIC);
1600 drop_leaf = drop_blk->bp->data; 1600 drop_leaf = drop_blk->bp->data;
1601 save_leaf = save_blk->bp->data; 1601 save_leaf = save_blk->bp->data;
1602 ASSERT(INT_GET(drop_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); 1602 ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
1603 ASSERT(INT_GET(save_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); 1603 ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
1604 drop_hdr = &drop_leaf->hdr; 1604 drop_hdr = &drop_leaf->hdr;
1605 save_hdr = &save_leaf->hdr; 1605 save_hdr = &save_leaf->hdr;
1606 1606
@@ -1695,7 +1695,7 @@ xfs_dir_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args, int *index)
1695 xfs_dahash_t hashval; 1695 xfs_dahash_t hashval;
1696 1696
1697 leaf = bp->data; 1697 leaf = bp->data;
1698 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); 1698 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
1699 ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) < (XFS_LBSIZE(args->dp->i_mount)/8)); 1699 ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) < (XFS_LBSIZE(args->dp->i_mount)/8));
1700 1700
1701 /* 1701 /*
@@ -1782,8 +1782,8 @@ xfs_dir_leaf_moveents(xfs_dir_leafblock_t *leaf_s, int start_s,
1782 /* 1782 /*
1783 * Set up environment. 1783 * Set up environment.
1784 */ 1784 */
1785 ASSERT(INT_GET(leaf_s->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); 1785 ASSERT(be16_to_cpu(leaf_s->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
1786 ASSERT(INT_GET(leaf_d->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); 1786 ASSERT(be16_to_cpu(leaf_d->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
1787 hdr_s = &leaf_s->hdr; 1787 hdr_s = &leaf_s->hdr;
1788 hdr_d = &leaf_d->hdr; 1788 hdr_d = &leaf_d->hdr;
1789 ASSERT((INT_GET(hdr_s->count, ARCH_CONVERT) > 0) && (INT_GET(hdr_s->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8))); 1789 ASSERT((INT_GET(hdr_s->count, ARCH_CONVERT) > 0) && (INT_GET(hdr_s->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8)));
@@ -1883,8 +1883,8 @@ xfs_dir_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp)
1883 1883
1884 leaf1 = leaf1_bp->data; 1884 leaf1 = leaf1_bp->data;
1885 leaf2 = leaf2_bp->data; 1885 leaf2 = leaf2_bp->data;
1886 ASSERT((INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) && 1886 ASSERT((be16_to_cpu(leaf1->hdr.info.magic) == XFS_DIR_LEAF_MAGIC) &&
1887 (INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC)); 1887 (be16_to_cpu(leaf2->hdr.info.magic) == XFS_DIR_LEAF_MAGIC));
1888 if ((INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0) && (INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0) && 1888 if ((INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0) && (INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0) &&
1889 ((INT_GET(leaf2->entries[ 0 ].hashval, ARCH_CONVERT) < 1889 ((INT_GET(leaf2->entries[ 0 ].hashval, ARCH_CONVERT) <
1890 INT_GET(leaf1->entries[ 0 ].hashval, ARCH_CONVERT)) || 1890 INT_GET(leaf1->entries[ 0 ].hashval, ARCH_CONVERT)) ||
@@ -1904,7 +1904,7 @@ xfs_dir_leaf_lasthash(xfs_dabuf_t *bp, int *count)
1904 xfs_dir_leafblock_t *leaf; 1904 xfs_dir_leafblock_t *leaf;
1905 1905
1906 leaf = bp->data; 1906 leaf = bp->data;
1907 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); 1907 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
1908 if (count) 1908 if (count)
1909 *count = INT_GET(leaf->hdr.count, ARCH_CONVERT); 1909 *count = INT_GET(leaf->hdr.count, ARCH_CONVERT);
1910 if (!leaf->hdr.count) 1910 if (!leaf->hdr.count)
@@ -1940,7 +1940,7 @@ xfs_dir_leaf_getdents_int(
1940 1940
1941 mp = dp->i_mount; 1941 mp = dp->i_mount;
1942 leaf = bp->data; 1942 leaf = bp->data;
1943 if (INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) != XFS_DIR_LEAF_MAGIC) { 1943 if (be16_to_cpu(leaf->hdr.info.magic) != XFS_DIR_LEAF_MAGIC) {
1944 *eobp = 1; 1944 *eobp = 1;
1945 return XFS_ERROR(ENOENT); /* XXX wrong code */ 1945 return XFS_ERROR(ENOENT); /* XXX wrong code */
1946 } 1946 }
@@ -1992,7 +1992,7 @@ xfs_dir_leaf_getdents_int(
1992 1992
1993 if (i == INT_GET(leaf->hdr.count, ARCH_CONVERT)) { 1993 if (i == INT_GET(leaf->hdr.count, ARCH_CONVERT)) {
1994 xfs_dir_trace_g_du("leaf: hash not found", dp, uio); 1994 xfs_dir_trace_g_du("leaf: hash not found", dp, uio);
1995 if (!INT_GET(leaf->hdr.info.forw, ARCH_CONVERT)) 1995 if (!leaf->hdr.info.forw)
1996 uio->uio_offset = 1996 uio->uio_offset =
1997 XFS_DA_MAKE_COOKIE(mp, 0, 0, XFS_DA_MAXHASH); 1997 XFS_DA_MAKE_COOKIE(mp, 0, 0, XFS_DA_MAXHASH);
1998 /* 1998 /*
@@ -2047,8 +2047,7 @@ xfs_dir_leaf_getdents_int(
2047 xfs_dir_trace_g_duc("leaf: middle cookie ", 2047 xfs_dir_trace_g_duc("leaf: middle cookie ",
2048 dp, uio, p.cook.o); 2048 dp, uio, p.cook.o);
2049 2049
2050 } else if ((thishash = INT_GET(leaf->hdr.info.forw, 2050 } else if ((thishash = be32_to_cpu(leaf->hdr.info.forw))) {
2051 ARCH_CONVERT))) {
2052 xfs_dabuf_t *bp2; 2051 xfs_dabuf_t *bp2;
2053 xfs_dir_leafblock_t *leaf2; 2052 xfs_dir_leafblock_t *leaf2;
2054 2053
@@ -2064,9 +2063,9 @@ xfs_dir_leaf_getdents_int(
2064 leaf2 = bp2->data; 2063 leaf2 = bp2->data;
2065 2064
2066 if (unlikely( 2065 if (unlikely(
2067 (INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) 2066 (be16_to_cpu(leaf2->hdr.info.magic)
2068 != XFS_DIR_LEAF_MAGIC) 2067 != XFS_DIR_LEAF_MAGIC)
2069 || (INT_GET(leaf2->hdr.info.back, ARCH_CONVERT) 2068 || (be32_to_cpu(leaf2->hdr.info.back)
2070 != bno))) { /* GROT */ 2069 != bno))) { /* GROT */
2071 XFS_CORRUPTION_ERROR("xfs_dir_leaf_getdents_int(3)", 2070 XFS_CORRUPTION_ERROR("xfs_dir_leaf_getdents_int(3)",
2072 XFS_ERRLEVEL_LOW, mp, 2071 XFS_ERRLEVEL_LOW, mp,