diff options
Diffstat (limited to 'fs/xfs/xfs_dir_leaf.c')
-rw-r--r-- | fs/xfs/xfs_dir_leaf.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/fs/xfs/xfs_dir_leaf.c b/fs/xfs/xfs_dir_leaf.c index e83074016abb..6d711869262f 100644 --- a/fs/xfs/xfs_dir_leaf.c +++ b/fs/xfs/xfs_dir_leaf.c | |||
@@ -176,7 +176,7 @@ xfs_dir_shortform_addname(xfs_da_args_t *args) | |||
176 | ASSERT(dp->i_df.if_u1.if_data != NULL); | 176 | ASSERT(dp->i_df.if_u1.if_data != NULL); |
177 | sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data; | 177 | sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data; |
178 | sfe = &sf->list[0]; | 178 | sfe = &sf->list[0]; |
179 | for (i = INT_GET(sf->hdr.count, ARCH_CONVERT)-1; i >= 0; i--) { | 179 | for (i = sf->hdr.count-1; i >= 0; i--) { |
180 | if (sfe->namelen == args->namelen && | 180 | if (sfe->namelen == args->namelen && |
181 | args->name[0] == sfe->name[0] && | 181 | args->name[0] == sfe->name[0] && |
182 | memcmp(args->name, sfe->name, args->namelen) == 0) | 182 | memcmp(args->name, sfe->name, args->namelen) == 0) |
@@ -193,7 +193,7 @@ xfs_dir_shortform_addname(xfs_da_args_t *args) | |||
193 | XFS_DIR_SF_PUT_DIRINO(&args->inumber, &sfe->inumber); | 193 | XFS_DIR_SF_PUT_DIRINO(&args->inumber, &sfe->inumber); |
194 | sfe->namelen = args->namelen; | 194 | sfe->namelen = args->namelen; |
195 | memcpy(sfe->name, args->name, sfe->namelen); | 195 | memcpy(sfe->name, args->name, sfe->namelen); |
196 | INT_MOD(sf->hdr.count, ARCH_CONVERT, +1); | 196 | sf->hdr.count++; |
197 | 197 | ||
198 | dp->i_d.di_size += size; | 198 | dp->i_d.di_size += size; |
199 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); | 199 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); |
@@ -227,7 +227,7 @@ xfs_dir_shortform_removename(xfs_da_args_t *args) | |||
227 | base = sizeof(xfs_dir_sf_hdr_t); | 227 | base = sizeof(xfs_dir_sf_hdr_t); |
228 | sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data; | 228 | sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data; |
229 | sfe = &sf->list[0]; | 229 | sfe = &sf->list[0]; |
230 | for (i = INT_GET(sf->hdr.count, ARCH_CONVERT)-1; i >= 0; i--) { | 230 | for (i = sf->hdr.count-1; i >= 0; i--) { |
231 | size = XFS_DIR_SF_ENTSIZE_BYENTRY(sfe); | 231 | size = XFS_DIR_SF_ENTSIZE_BYENTRY(sfe); |
232 | if (sfe->namelen == args->namelen && | 232 | if (sfe->namelen == args->namelen && |
233 | sfe->name[0] == args->name[0] && | 233 | sfe->name[0] == args->name[0] && |
@@ -245,7 +245,7 @@ xfs_dir_shortform_removename(xfs_da_args_t *args) | |||
245 | memmove(&((char *)sf)[base], &((char *)sf)[base+size], | 245 | memmove(&((char *)sf)[base], &((char *)sf)[base+size], |
246 | dp->i_d.di_size - (base+size)); | 246 | dp->i_d.di_size - (base+size)); |
247 | } | 247 | } |
248 | INT_MOD(sf->hdr.count, ARCH_CONVERT, -1); | 248 | sf->hdr.count--; |
249 | 249 | ||
250 | xfs_idata_realloc(dp, -size, XFS_DATA_FORK); | 250 | xfs_idata_realloc(dp, -size, XFS_DATA_FORK); |
251 | dp->i_d.di_size -= size; | 251 | dp->i_d.di_size -= size; |
@@ -288,7 +288,7 @@ xfs_dir_shortform_lookup(xfs_da_args_t *args) | |||
288 | return(XFS_ERROR(EEXIST)); | 288 | return(XFS_ERROR(EEXIST)); |
289 | } | 289 | } |
290 | sfe = &sf->list[0]; | 290 | sfe = &sf->list[0]; |
291 | for (i = INT_GET(sf->hdr.count, ARCH_CONVERT)-1; i >= 0; i--) { | 291 | for (i = sf->hdr.count-1; i >= 0; i--) { |
292 | if (sfe->namelen == args->namelen && | 292 | if (sfe->namelen == args->namelen && |
293 | sfe->name[0] == args->name[0] && | 293 | sfe->name[0] == args->name[0] && |
294 | memcmp(args->name, sfe->name, args->namelen) == 0) { | 294 | memcmp(args->name, sfe->name, args->namelen) == 0) { |
@@ -375,7 +375,7 @@ xfs_dir_shortform_to_leaf(xfs_da_args_t *iargs) | |||
375 | goto out; | 375 | goto out; |
376 | 376 | ||
377 | sfe = &sf->list[0]; | 377 | sfe = &sf->list[0]; |
378 | for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) { | 378 | for (i = 0; i < sf->hdr.count; i++) { |
379 | args.name = (char *)(sfe->name); | 379 | args.name = (char *)(sfe->name); |
380 | args.namelen = sfe->namelen; | 380 | args.namelen = sfe->namelen; |
381 | args.hashval = xfs_da_hashname((char *)(sfe->name), | 381 | args.hashval = xfs_da_hashname((char *)(sfe->name), |
@@ -428,7 +428,7 @@ xfs_dir_shortform_getdents(xfs_inode_t *dp, uio_t *uio, int *eofp, | |||
428 | sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data; | 428 | sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data; |
429 | cookhash = XFS_DA_COOKIE_HASH(mp, uio->uio_offset); | 429 | cookhash = XFS_DA_COOKIE_HASH(mp, uio->uio_offset); |
430 | want_entno = XFS_DA_COOKIE_ENTRY(mp, uio->uio_offset); | 430 | want_entno = XFS_DA_COOKIE_ENTRY(mp, uio->uio_offset); |
431 | nsbuf = INT_GET(sf->hdr.count, ARCH_CONVERT) + 2; | 431 | nsbuf = sf->hdr.count + 2; |
432 | sbsize = (nsbuf + 1) * sizeof(*sbuf); | 432 | sbsize = (nsbuf + 1) * sizeof(*sbuf); |
433 | sbp = sbuf = kmem_alloc(sbsize, KM_SLEEP); | 433 | sbp = sbuf = kmem_alloc(sbsize, KM_SLEEP); |
434 | 434 | ||
@@ -460,8 +460,7 @@ xfs_dir_shortform_getdents(xfs_inode_t *dp, uio_t *uio, int *eofp, | |||
460 | /* | 460 | /* |
461 | * Scan the directory data for the rest of the entries. | 461 | * Scan the directory data for the rest of the entries. |
462 | */ | 462 | */ |
463 | for (i = 0, sfe = &sf->list[0]; | 463 | for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) { |
464 | i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) { | ||
465 | 464 | ||
466 | if (unlikely( | 465 | if (unlikely( |
467 | ((char *)sfe < (char *)sf) || | 466 | ((char *)sfe < (char *)sf) || |
@@ -600,7 +599,7 @@ xfs_dir_shortform_replace(xfs_da_args_t *args) | |||
600 | } | 599 | } |
601 | ASSERT(args->namelen != 1 || args->name[0] != '.'); | 600 | ASSERT(args->namelen != 1 || args->name[0] != '.'); |
602 | sfe = &sf->list[0]; | 601 | sfe = &sf->list[0]; |
603 | for (i = INT_GET(sf->hdr.count, ARCH_CONVERT)-1; i >= 0; i--) { | 602 | for (i = sf->hdr.count-1; i >= 0; i--) { |
604 | if (sfe->namelen == args->namelen && | 603 | if (sfe->namelen == args->namelen && |
605 | sfe->name[0] == args->name[0] && | 604 | sfe->name[0] == args->name[0] && |
606 | memcmp(args->name, sfe->name, args->namelen) == 0) { | 605 | memcmp(args->name, sfe->name, args->namelen) == 0) { |
@@ -644,7 +643,7 @@ xfs_dir_leaf_to_shortform(xfs_da_args_t *iargs) | |||
644 | ASSERT(bp != NULL); | 643 | ASSERT(bp != NULL); |
645 | memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount)); | 644 | memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount)); |
646 | leaf = (xfs_dir_leafblock_t *)tmpbuffer; | 645 | leaf = (xfs_dir_leafblock_t *)tmpbuffer; |
647 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 646 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
648 | memset(bp->data, 0, XFS_LBSIZE(dp->i_mount)); | 647 | memset(bp->data, 0, XFS_LBSIZE(dp->i_mount)); |
649 | 648 | ||
650 | /* | 649 | /* |
@@ -742,11 +741,13 @@ xfs_dir_leaf_to_node(xfs_da_args_t *args) | |||
742 | } | 741 | } |
743 | node = bp1->data; | 742 | node = bp1->data; |
744 | leaf = bp2->data; | 743 | leaf = bp2->data; |
745 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 744 | 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)); | 745 | node->btree[0].hashval = cpu_to_be32( |
746 | INT_GET(leaf->entries[ | ||
747 | INT_GET(leaf->hdr.count, ARCH_CONVERT)-1].hashval, ARCH_CONVERT)); | ||
747 | xfs_da_buf_done(bp2); | 748 | xfs_da_buf_done(bp2); |
748 | INT_SET(node->btree[0].before, ARCH_CONVERT, blkno); | 749 | node->btree[0].before = cpu_to_be32(blkno); |
749 | INT_SET(node->hdr.count, ARCH_CONVERT, 1); | 750 | node->hdr.count = cpu_to_be16(1); |
750 | xfs_da_log_buf(args->trans, bp1, | 751 | xfs_da_log_buf(args->trans, bp1, |
751 | XFS_DA_LOGRANGE(node, &node->btree[0], sizeof(node->btree[0]))); | 752 | XFS_DA_LOGRANGE(node, &node->btree[0], sizeof(node->btree[0]))); |
752 | xfs_da_buf_done(bp1); | 753 | xfs_da_buf_done(bp1); |
@@ -781,7 +782,7 @@ xfs_dir_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp) | |||
781 | leaf = bp->data; | 782 | leaf = bp->data; |
782 | memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount)); | 783 | memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount)); |
783 | hdr = &leaf->hdr; | 784 | hdr = &leaf->hdr; |
784 | INT_SET(hdr->info.magic, ARCH_CONVERT, XFS_DIR_LEAF_MAGIC); | 785 | hdr->info.magic = cpu_to_be16(XFS_DIR_LEAF_MAGIC); |
785 | INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount)); | 786 | INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount)); |
786 | if (!hdr->firstused) | 787 | if (!hdr->firstused) |
787 | INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount) - 1); | 788 | INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount) - 1); |
@@ -860,7 +861,7 @@ xfs_dir_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args, int index) | |||
860 | int tablesize, entsize, sum, i, tmp, error; | 861 | int tablesize, entsize, sum, i, tmp, error; |
861 | 862 | ||
862 | leaf = bp->data; | 863 | leaf = bp->data; |
863 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 864 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
864 | ASSERT((index >= 0) && (index <= INT_GET(leaf->hdr.count, ARCH_CONVERT))); | 865 | ASSERT((index >= 0) && (index <= INT_GET(leaf->hdr.count, ARCH_CONVERT))); |
865 | hdr = &leaf->hdr; | 866 | hdr = &leaf->hdr; |
866 | entsize = XFS_DIR_LEAF_ENTSIZE_BYNAME(args->namelen); | 867 | entsize = XFS_DIR_LEAF_ENTSIZE_BYNAME(args->namelen); |
@@ -940,7 +941,7 @@ xfs_dir_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int index, | |||
940 | int tmp, i; | 941 | int tmp, i; |
941 | 942 | ||
942 | leaf = bp->data; | 943 | leaf = bp->data; |
943 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 944 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
944 | hdr = &leaf->hdr; | 945 | hdr = &leaf->hdr; |
945 | ASSERT((mapindex >= 0) && (mapindex < XFS_DIR_LEAF_MAPSIZE)); | 946 | ASSERT((mapindex >= 0) && (mapindex < XFS_DIR_LEAF_MAPSIZE)); |
946 | ASSERT((index >= 0) && (index <= INT_GET(hdr->count, ARCH_CONVERT))); | 947 | ASSERT((index >= 0) && (index <= INT_GET(hdr->count, ARCH_CONVERT))); |
@@ -1097,8 +1098,8 @@ xfs_dir_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
1097 | ASSERT(blk2->magic == XFS_DIR_LEAF_MAGIC); | 1098 | ASSERT(blk2->magic == XFS_DIR_LEAF_MAGIC); |
1098 | leaf1 = blk1->bp->data; | 1099 | leaf1 = blk1->bp->data; |
1099 | leaf2 = blk2->bp->data; | 1100 | leaf2 = blk2->bp->data; |
1100 | ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1101 | 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); | 1102 | ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1102 | 1103 | ||
1103 | /* | 1104 | /* |
1104 | * Check ordering of blocks, reverse if it makes things simpler. | 1105 | * Check ordering of blocks, reverse if it makes things simpler. |
@@ -1325,7 +1326,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1325 | */ | 1326 | */ |
1326 | blk = &state->path.blk[ state->path.active-1 ]; | 1327 | blk = &state->path.blk[ state->path.active-1 ]; |
1327 | info = blk->bp->data; | 1328 | info = blk->bp->data; |
1328 | ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1329 | ASSERT(be16_to_cpu(info->magic) == XFS_DIR_LEAF_MAGIC); |
1329 | leaf = (xfs_dir_leafblock_t *)info; | 1330 | leaf = (xfs_dir_leafblock_t *)info; |
1330 | count = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 1331 | count = INT_GET(leaf->hdr.count, ARCH_CONVERT); |
1331 | bytes = (uint)sizeof(xfs_dir_leaf_hdr_t) + | 1332 | bytes = (uint)sizeof(xfs_dir_leaf_hdr_t) + |
@@ -1340,7 +1341,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1340 | /* | 1341 | /* |
1341 | * Check for the degenerate case of the block being empty. | 1342 | * Check for the degenerate case of the block being empty. |
1342 | * If the block is empty, we'll simply delete it, no need to | 1343 | * If the block is empty, we'll simply delete it, no need to |
1343 | * coalesce it with a sibling block. We choose (aribtrarily) | 1344 | * coalesce it with a sibling block. We choose (arbitrarily) |
1344 | * to merge with the forward block unless it is NULL. | 1345 | * to merge with the forward block unless it is NULL. |
1345 | */ | 1346 | */ |
1346 | if (count == 0) { | 1347 | if (count == 0) { |
@@ -1348,7 +1349,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1348 | * Make altpath point to the block we want to keep and | 1349 | * Make altpath point to the block we want to keep and |
1349 | * path point to the block we want to drop (this one). | 1350 | * path point to the block we want to drop (this one). |
1350 | */ | 1351 | */ |
1351 | forward = info->forw; | 1352 | forward = (info->forw != 0); |
1352 | memcpy(&state->altpath, &state->path, sizeof(state->path)); | 1353 | memcpy(&state->altpath, &state->path, sizeof(state->path)); |
1353 | error = xfs_da_path_shift(state, &state->altpath, forward, | 1354 | error = xfs_da_path_shift(state, &state->altpath, forward, |
1354 | 0, &retval); | 1355 | 0, &retval); |
@@ -1369,12 +1370,12 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1369 | * We prefer coalescing with the lower numbered sibling so as | 1370 | * We prefer coalescing with the lower numbered sibling so as |
1370 | * to shrink a directory over time. | 1371 | * to shrink a directory over time. |
1371 | */ | 1372 | */ |
1372 | forward = (INT_GET(info->forw, ARCH_CONVERT) < INT_GET(info->back, ARCH_CONVERT)); /* start with smaller blk num */ | 1373 | 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++) { | 1374 | for (i = 0; i < 2; forward = !forward, i++) { |
1374 | if (forward) | 1375 | if (forward) |
1375 | blkno = INT_GET(info->forw, ARCH_CONVERT); | 1376 | blkno = be32_to_cpu(info->forw); |
1376 | else | 1377 | else |
1377 | blkno = INT_GET(info->back, ARCH_CONVERT); | 1378 | blkno = be32_to_cpu(info->back); |
1378 | if (blkno == 0) | 1379 | if (blkno == 0) |
1379 | continue; | 1380 | continue; |
1380 | error = xfs_da_read_buf(state->args->trans, state->args->dp, | 1381 | error = xfs_da_read_buf(state->args->trans, state->args->dp, |
@@ -1389,7 +1390,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1389 | bytes = state->blocksize - (state->blocksize>>2); | 1390 | bytes = state->blocksize - (state->blocksize>>2); |
1390 | bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT); | 1391 | bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT); |
1391 | leaf = bp->data; | 1392 | leaf = bp->data; |
1392 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1393 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1393 | count += INT_GET(leaf->hdr.count, ARCH_CONVERT); | 1394 | count += INT_GET(leaf->hdr.count, ARCH_CONVERT); |
1394 | bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT); | 1395 | bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT); |
1395 | bytes -= count * ((uint)sizeof(xfs_dir_leaf_name_t) - 1); | 1396 | bytes -= count * ((uint)sizeof(xfs_dir_leaf_name_t) - 1); |
@@ -1447,7 +1448,7 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index) | |||
1447 | xfs_mount_t *mp; | 1448 | xfs_mount_t *mp; |
1448 | 1449 | ||
1449 | leaf = bp->data; | 1450 | leaf = bp->data; |
1450 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1451 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1451 | hdr = &leaf->hdr; | 1452 | hdr = &leaf->hdr; |
1452 | mp = trans->t_mountp; | 1453 | mp = trans->t_mountp; |
1453 | ASSERT((INT_GET(hdr->count, ARCH_CONVERT) > 0) && (INT_GET(hdr->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8))); | 1454 | ASSERT((INT_GET(hdr->count, ARCH_CONVERT) > 0) && (INT_GET(hdr->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8))); |
@@ -1599,8 +1600,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); | 1600 | ASSERT(save_blk->magic == XFS_DIR_LEAF_MAGIC); |
1600 | drop_leaf = drop_blk->bp->data; | 1601 | drop_leaf = drop_blk->bp->data; |
1601 | save_leaf = save_blk->bp->data; | 1602 | save_leaf = save_blk->bp->data; |
1602 | ASSERT(INT_GET(drop_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1603 | 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); | 1604 | ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1604 | drop_hdr = &drop_leaf->hdr; | 1605 | drop_hdr = &drop_leaf->hdr; |
1605 | save_hdr = &save_leaf->hdr; | 1606 | save_hdr = &save_leaf->hdr; |
1606 | 1607 | ||
@@ -1695,7 +1696,7 @@ xfs_dir_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args, int *index) | |||
1695 | xfs_dahash_t hashval; | 1696 | xfs_dahash_t hashval; |
1696 | 1697 | ||
1697 | leaf = bp->data; | 1698 | leaf = bp->data; |
1698 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1699 | 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)); | 1700 | ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) < (XFS_LBSIZE(args->dp->i_mount)/8)); |
1700 | 1701 | ||
1701 | /* | 1702 | /* |
@@ -1782,8 +1783,8 @@ xfs_dir_leaf_moveents(xfs_dir_leafblock_t *leaf_s, int start_s, | |||
1782 | /* | 1783 | /* |
1783 | * Set up environment. | 1784 | * Set up environment. |
1784 | */ | 1785 | */ |
1785 | ASSERT(INT_GET(leaf_s->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1786 | 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); | 1787 | ASSERT(be16_to_cpu(leaf_d->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1787 | hdr_s = &leaf_s->hdr; | 1788 | hdr_s = &leaf_s->hdr; |
1788 | hdr_d = &leaf_d->hdr; | 1789 | 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))); | 1790 | ASSERT((INT_GET(hdr_s->count, ARCH_CONVERT) > 0) && (INT_GET(hdr_s->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8))); |
@@ -1883,8 +1884,8 @@ xfs_dir_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp) | |||
1883 | 1884 | ||
1884 | leaf1 = leaf1_bp->data; | 1885 | leaf1 = leaf1_bp->data; |
1885 | leaf2 = leaf2_bp->data; | 1886 | leaf2 = leaf2_bp->data; |
1886 | ASSERT((INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) && | 1887 | 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)); | 1888 | (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) && | 1889 | 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) < | 1890 | ((INT_GET(leaf2->entries[ 0 ].hashval, ARCH_CONVERT) < |
1890 | INT_GET(leaf1->entries[ 0 ].hashval, ARCH_CONVERT)) || | 1891 | INT_GET(leaf1->entries[ 0 ].hashval, ARCH_CONVERT)) || |
@@ -1904,7 +1905,7 @@ xfs_dir_leaf_lasthash(xfs_dabuf_t *bp, int *count) | |||
1904 | xfs_dir_leafblock_t *leaf; | 1905 | xfs_dir_leafblock_t *leaf; |
1905 | 1906 | ||
1906 | leaf = bp->data; | 1907 | leaf = bp->data; |
1907 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1908 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1908 | if (count) | 1909 | if (count) |
1909 | *count = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 1910 | *count = INT_GET(leaf->hdr.count, ARCH_CONVERT); |
1910 | if (!leaf->hdr.count) | 1911 | if (!leaf->hdr.count) |
@@ -1940,7 +1941,7 @@ xfs_dir_leaf_getdents_int( | |||
1940 | 1941 | ||
1941 | mp = dp->i_mount; | 1942 | mp = dp->i_mount; |
1942 | leaf = bp->data; | 1943 | leaf = bp->data; |
1943 | if (INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) != XFS_DIR_LEAF_MAGIC) { | 1944 | if (be16_to_cpu(leaf->hdr.info.magic) != XFS_DIR_LEAF_MAGIC) { |
1944 | *eobp = 1; | 1945 | *eobp = 1; |
1945 | return XFS_ERROR(ENOENT); /* XXX wrong code */ | 1946 | return XFS_ERROR(ENOENT); /* XXX wrong code */ |
1946 | } | 1947 | } |
@@ -1992,7 +1993,7 @@ xfs_dir_leaf_getdents_int( | |||
1992 | 1993 | ||
1993 | if (i == INT_GET(leaf->hdr.count, ARCH_CONVERT)) { | 1994 | if (i == INT_GET(leaf->hdr.count, ARCH_CONVERT)) { |
1994 | xfs_dir_trace_g_du("leaf: hash not found", dp, uio); | 1995 | xfs_dir_trace_g_du("leaf: hash not found", dp, uio); |
1995 | if (!INT_GET(leaf->hdr.info.forw, ARCH_CONVERT)) | 1996 | if (!leaf->hdr.info.forw) |
1996 | uio->uio_offset = | 1997 | uio->uio_offset = |
1997 | XFS_DA_MAKE_COOKIE(mp, 0, 0, XFS_DA_MAXHASH); | 1998 | XFS_DA_MAKE_COOKIE(mp, 0, 0, XFS_DA_MAXHASH); |
1998 | /* | 1999 | /* |
@@ -2047,8 +2048,7 @@ xfs_dir_leaf_getdents_int( | |||
2047 | xfs_dir_trace_g_duc("leaf: middle cookie ", | 2048 | xfs_dir_trace_g_duc("leaf: middle cookie ", |
2048 | dp, uio, p.cook.o); | 2049 | dp, uio, p.cook.o); |
2049 | 2050 | ||
2050 | } else if ((thishash = INT_GET(leaf->hdr.info.forw, | 2051 | } else if ((thishash = be32_to_cpu(leaf->hdr.info.forw))) { |
2051 | ARCH_CONVERT))) { | ||
2052 | xfs_dabuf_t *bp2; | 2052 | xfs_dabuf_t *bp2; |
2053 | xfs_dir_leafblock_t *leaf2; | 2053 | xfs_dir_leafblock_t *leaf2; |
2054 | 2054 | ||
@@ -2064,9 +2064,9 @@ xfs_dir_leaf_getdents_int( | |||
2064 | leaf2 = bp2->data; | 2064 | leaf2 = bp2->data; |
2065 | 2065 | ||
2066 | if (unlikely( | 2066 | if (unlikely( |
2067 | (INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) | 2067 | (be16_to_cpu(leaf2->hdr.info.magic) |
2068 | != XFS_DIR_LEAF_MAGIC) | 2068 | != XFS_DIR_LEAF_MAGIC) |
2069 | || (INT_GET(leaf2->hdr.info.back, ARCH_CONVERT) | 2069 | || (be32_to_cpu(leaf2->hdr.info.back) |
2070 | != bno))) { /* GROT */ | 2070 | != bno))) { /* GROT */ |
2071 | XFS_CORRUPTION_ERROR("xfs_dir_leaf_getdents_int(3)", | 2071 | XFS_CORRUPTION_ERROR("xfs_dir_leaf_getdents_int(3)", |
2072 | XFS_ERRLEVEL_LOW, mp, | 2072 | XFS_ERRLEVEL_LOW, mp, |