diff options
Diffstat (limited to 'fs/xfs/xfs_dir2_block.c')
-rw-r--r-- | fs/xfs/xfs_dir2_block.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c index 2c1fcdc7a762..6f3b99dfe55c 100644 --- a/fs/xfs/xfs_dir2_block.c +++ b/fs/xfs/xfs_dir2_block.c | |||
@@ -193,10 +193,10 @@ xfs_dir2_block_addname( | |||
193 | * leaf data starts now, if it works at all. | 193 | * leaf data starts now, if it works at all. |
194 | */ | 194 | */ |
195 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { | 195 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { |
196 | if (be16_to_cpu(dup->length) + (INT_GET(btp->stale, ARCH_CONVERT) - 1) * | 196 | if (be16_to_cpu(dup->length) + (be32_to_cpu(btp->stale) - 1) * |
197 | (uint)sizeof(*blp) < len) | 197 | (uint)sizeof(*blp) < len) |
198 | dup = NULL; | 198 | dup = NULL; |
199 | } else if ((INT_GET(btp->stale, ARCH_CONVERT) - 1) * (uint)sizeof(*blp) < len) | 199 | } else if ((be32_to_cpu(btp->stale) - 1) * (uint)sizeof(*blp) < len) |
200 | dup = NULL; | 200 | dup = NULL; |
201 | else | 201 | else |
202 | dup = (xfs_dir2_data_unused_t *)blp; | 202 | dup = (xfs_dir2_data_unused_t *)blp; |
@@ -242,7 +242,7 @@ xfs_dir2_block_addname( | |||
242 | int fromidx; /* source leaf index */ | 242 | int fromidx; /* source leaf index */ |
243 | int toidx; /* target leaf index */ | 243 | int toidx; /* target leaf index */ |
244 | 244 | ||
245 | for (fromidx = toidx = INT_GET(btp->count, ARCH_CONVERT) - 1, | 245 | for (fromidx = toidx = be32_to_cpu(btp->count) - 1, |
246 | highstale = lfloghigh = -1; | 246 | highstale = lfloghigh = -1; |
247 | fromidx >= 0; | 247 | fromidx >= 0; |
248 | fromidx--) { | 248 | fromidx--) { |
@@ -259,15 +259,15 @@ xfs_dir2_block_addname( | |||
259 | blp[toidx] = blp[fromidx]; | 259 | blp[toidx] = blp[fromidx]; |
260 | toidx--; | 260 | toidx--; |
261 | } | 261 | } |
262 | lfloglow = toidx + 1 - (INT_GET(btp->stale, ARCH_CONVERT) - 1); | 262 | lfloglow = toidx + 1 - (be32_to_cpu(btp->stale) - 1); |
263 | lfloghigh -= INT_GET(btp->stale, ARCH_CONVERT) - 1; | 263 | lfloghigh -= be32_to_cpu(btp->stale) - 1; |
264 | INT_MOD(btp->count, ARCH_CONVERT, -(INT_GET(btp->stale, ARCH_CONVERT) - 1)); | 264 | be32_add(&btp->count, -(be32_to_cpu(btp->stale) - 1)); |
265 | xfs_dir2_data_make_free(tp, bp, | 265 | xfs_dir2_data_make_free(tp, bp, |
266 | (xfs_dir2_data_aoff_t)((char *)blp - (char *)block), | 266 | (xfs_dir2_data_aoff_t)((char *)blp - (char *)block), |
267 | (xfs_dir2_data_aoff_t)((INT_GET(btp->stale, ARCH_CONVERT) - 1) * sizeof(*blp)), | 267 | (xfs_dir2_data_aoff_t)((be32_to_cpu(btp->stale) - 1) * sizeof(*blp)), |
268 | &needlog, &needscan); | 268 | &needlog, &needscan); |
269 | blp += INT_GET(btp->stale, ARCH_CONVERT) - 1; | 269 | blp += be32_to_cpu(btp->stale) - 1; |
270 | INT_SET(btp->stale, ARCH_CONVERT, 1); | 270 | btp->stale = cpu_to_be32(1); |
271 | /* | 271 | /* |
272 | * If we now need to rebuild the bestfree map, do so. | 272 | * If we now need to rebuild the bestfree map, do so. |
273 | * This needs to happen before the next call to use_free. | 273 | * This needs to happen before the next call to use_free. |
@@ -282,14 +282,14 @@ xfs_dir2_block_addname( | |||
282 | * Set leaf logging boundaries to impossible state. | 282 | * Set leaf logging boundaries to impossible state. |
283 | * For the no-stale case they're set explicitly. | 283 | * For the no-stale case they're set explicitly. |
284 | */ | 284 | */ |
285 | else if (INT_GET(btp->stale, ARCH_CONVERT)) { | 285 | else if (btp->stale) { |
286 | lfloglow = INT_GET(btp->count, ARCH_CONVERT); | 286 | lfloglow = be32_to_cpu(btp->count); |
287 | lfloghigh = -1; | 287 | lfloghigh = -1; |
288 | } | 288 | } |
289 | /* | 289 | /* |
290 | * Find the slot that's first lower than our hash value, -1 if none. | 290 | * Find the slot that's first lower than our hash value, -1 if none. |
291 | */ | 291 | */ |
292 | for (low = 0, high = INT_GET(btp->count, ARCH_CONVERT) - 1; low <= high; ) { | 292 | for (low = 0, high = be32_to_cpu(btp->count) - 1; low <= high; ) { |
293 | mid = (low + high) >> 1; | 293 | mid = (low + high) >> 1; |
294 | if ((hash = INT_GET(blp[mid].hashval, ARCH_CONVERT)) == args->hashval) | 294 | if ((hash = INT_GET(blp[mid].hashval, ARCH_CONVERT)) == args->hashval) |
295 | break; | 295 | break; |
@@ -317,7 +317,7 @@ xfs_dir2_block_addname( | |||
317 | /* | 317 | /* |
318 | * Update the tail (entry count). | 318 | * Update the tail (entry count). |
319 | */ | 319 | */ |
320 | INT_MOD(btp->count, ARCH_CONVERT, +1); | 320 | be32_add(&btp->count, 1); |
321 | /* | 321 | /* |
322 | * If we now need to rebuild the bestfree map, do so. | 322 | * If we now need to rebuild the bestfree map, do so. |
323 | * This needs to happen before the next call to use_free. | 323 | * This needs to happen before the next call to use_free. |
@@ -349,7 +349,7 @@ xfs_dir2_block_addname( | |||
349 | lowstale--) | 349 | lowstale--) |
350 | continue; | 350 | continue; |
351 | for (highstale = mid + 1; | 351 | for (highstale = mid + 1; |
352 | highstale < INT_GET(btp->count, ARCH_CONVERT) && | 352 | highstale < be32_to_cpu(btp->count) && |
353 | INT_GET(blp[highstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR && | 353 | INT_GET(blp[highstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR && |
354 | (lowstale < 0 || mid - lowstale > highstale - mid); | 354 | (lowstale < 0 || mid - lowstale > highstale - mid); |
355 | highstale++) | 355 | highstale++) |
@@ -358,7 +358,7 @@ xfs_dir2_block_addname( | |||
358 | * Move entries toward the low-numbered stale entry. | 358 | * Move entries toward the low-numbered stale entry. |
359 | */ | 359 | */ |
360 | if (lowstale >= 0 && | 360 | if (lowstale >= 0 && |
361 | (highstale == INT_GET(btp->count, ARCH_CONVERT) || | 361 | (highstale == be32_to_cpu(btp->count) || |
362 | mid - lowstale <= highstale - mid)) { | 362 | mid - lowstale <= highstale - mid)) { |
363 | if (mid - lowstale) | 363 | if (mid - lowstale) |
364 | memmove(&blp[lowstale], &blp[lowstale + 1], | 364 | memmove(&blp[lowstale], &blp[lowstale + 1], |
@@ -370,7 +370,7 @@ xfs_dir2_block_addname( | |||
370 | * Move entries toward the high-numbered stale entry. | 370 | * Move entries toward the high-numbered stale entry. |
371 | */ | 371 | */ |
372 | else { | 372 | else { |
373 | ASSERT(highstale < INT_GET(btp->count, ARCH_CONVERT)); | 373 | ASSERT(highstale < be32_to_cpu(btp->count)); |
374 | mid++; | 374 | mid++; |
375 | if (highstale - mid) | 375 | if (highstale - mid) |
376 | memmove(&blp[mid + 1], &blp[mid], | 376 | memmove(&blp[mid + 1], &blp[mid], |
@@ -378,7 +378,7 @@ xfs_dir2_block_addname( | |||
378 | lfloglow = MIN(mid, lfloglow); | 378 | lfloglow = MIN(mid, lfloglow); |
379 | lfloghigh = MAX(highstale, lfloghigh); | 379 | lfloghigh = MAX(highstale, lfloghigh); |
380 | } | 380 | } |
381 | INT_MOD(btp->stale, ARCH_CONVERT, -1); | 381 | be32_add(&btp->stale, -1); |
382 | } | 382 | } |
383 | /* | 383 | /* |
384 | * Point to the new data entry. | 384 | * Point to the new data entry. |
@@ -673,7 +673,7 @@ xfs_dir2_block_lookup_int( | |||
673 | * Loop doing a binary search for our hash value. | 673 | * Loop doing a binary search for our hash value. |
674 | * Find our entry, ENOENT if it's not there. | 674 | * Find our entry, ENOENT if it's not there. |
675 | */ | 675 | */ |
676 | for (low = 0, high = INT_GET(btp->count, ARCH_CONVERT) - 1; ; ) { | 676 | for (low = 0, high = be32_to_cpu(btp->count) - 1; ; ) { |
677 | ASSERT(low <= high); | 677 | ASSERT(low <= high); |
678 | mid = (low + high) >> 1; | 678 | mid = (low + high) >> 1; |
679 | if ((hash = INT_GET(blp[mid].hashval, ARCH_CONVERT)) == args->hashval) | 679 | if ((hash = INT_GET(blp[mid].hashval, ARCH_CONVERT)) == args->hashval) |
@@ -716,7 +716,7 @@ xfs_dir2_block_lookup_int( | |||
716 | *entno = mid; | 716 | *entno = mid; |
717 | return 0; | 717 | return 0; |
718 | } | 718 | } |
719 | } while (++mid < INT_GET(btp->count, ARCH_CONVERT) && INT_GET(blp[mid].hashval, ARCH_CONVERT) == hash); | 719 | } while (++mid < be32_to_cpu(btp->count) && INT_GET(blp[mid].hashval, ARCH_CONVERT) == hash); |
720 | /* | 720 | /* |
721 | * No match, release the buffer and return ENOENT. | 721 | * No match, release the buffer and return ENOENT. |
722 | */ | 722 | */ |
@@ -777,7 +777,7 @@ xfs_dir2_block_removename( | |||
777 | /* | 777 | /* |
778 | * Fix up the block tail. | 778 | * Fix up the block tail. |
779 | */ | 779 | */ |
780 | INT_MOD(btp->stale, ARCH_CONVERT, +1); | 780 | be32_add(&btp->stale, 1); |
781 | xfs_dir2_block_log_tail(tp, bp); | 781 | xfs_dir2_block_log_tail(tp, bp); |
782 | /* | 782 | /* |
783 | * Remove the leaf entry by marking it stale. | 783 | * Remove the leaf entry by marking it stale. |
@@ -968,7 +968,7 @@ xfs_dir2_leaf_to_block( | |||
968 | * Initialize the block tail. | 968 | * Initialize the block tail. |
969 | */ | 969 | */ |
970 | btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); | 970 | btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); |
971 | INT_SET(btp->count, ARCH_CONVERT, INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT)); | 971 | btp->count = cpu_to_be32(INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT)); |
972 | btp->stale = 0; | 972 | btp->stale = 0; |
973 | xfs_dir2_block_log_tail(tp, dbp); | 973 | xfs_dir2_block_log_tail(tp, dbp); |
974 | /* | 974 | /* |
@@ -980,8 +980,8 @@ xfs_dir2_leaf_to_block( | |||
980 | continue; | 980 | continue; |
981 | lep[to++] = leaf->ents[from]; | 981 | lep[to++] = leaf->ents[from]; |
982 | } | 982 | } |
983 | ASSERT(to == INT_GET(btp->count, ARCH_CONVERT)); | 983 | ASSERT(to == be32_to_cpu(btp->count)); |
984 | xfs_dir2_block_log_leaf(tp, dbp, 0, INT_GET(btp->count, ARCH_CONVERT) - 1); | 984 | xfs_dir2_block_log_leaf(tp, dbp, 0, be32_to_cpu(btp->count) - 1); |
985 | /* | 985 | /* |
986 | * Scan the bestfree if we need it and log the data block header. | 986 | * Scan the bestfree if we need it and log the data block header. |
987 | */ | 987 | */ |
@@ -1114,7 +1114,7 @@ xfs_dir2_sf_to_block( | |||
1114 | * Fill in the tail. | 1114 | * Fill in the tail. |
1115 | */ | 1115 | */ |
1116 | btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); | 1116 | btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); |
1117 | INT_SET(btp->count, ARCH_CONVERT, INT_GET(sfp->hdr.count, ARCH_CONVERT) + 2); /* ., .. */ | 1117 | btp->count = cpu_to_be32(INT_GET(sfp->hdr.count, ARCH_CONVERT) + 2); /* ., .. */ |
1118 | btp->stale = 0; | 1118 | btp->stale = 0; |
1119 | blp = XFS_DIR2_BLOCK_LEAF_P(btp); | 1119 | blp = XFS_DIR2_BLOCK_LEAF_P(btp); |
1120 | endoffset = (uint)((char *)blp - (char *)block); | 1120 | endoffset = (uint)((char *)blp - (char *)block); |
@@ -1211,13 +1211,13 @@ xfs_dir2_sf_to_block( | |||
1211 | /* | 1211 | /* |
1212 | * Sort the leaf entries by hash value. | 1212 | * Sort the leaf entries by hash value. |
1213 | */ | 1213 | */ |
1214 | xfs_sort(blp, INT_GET(btp->count, ARCH_CONVERT), sizeof(*blp), xfs_dir2_block_sort); | 1214 | xfs_sort(blp, be32_to_cpu(btp->count), sizeof(*blp), xfs_dir2_block_sort); |
1215 | /* | 1215 | /* |
1216 | * Log the leaf entry area and tail. | 1216 | * Log the leaf entry area and tail. |
1217 | * Already logged the header in data_init, ignore needlog. | 1217 | * Already logged the header in data_init, ignore needlog. |
1218 | */ | 1218 | */ |
1219 | ASSERT(needscan == 0); | 1219 | ASSERT(needscan == 0); |
1220 | xfs_dir2_block_log_leaf(tp, bp, 0, INT_GET(btp->count, ARCH_CONVERT) - 1); | 1220 | xfs_dir2_block_log_leaf(tp, bp, 0, be32_to_cpu(btp->count) - 1); |
1221 | xfs_dir2_block_log_tail(tp, bp); | 1221 | xfs_dir2_block_log_tail(tp, bp); |
1222 | xfs_dir2_data_check(dp, bp); | 1222 | xfs_dir2_data_check(dp, bp); |
1223 | xfs_da_buf_done(bp); | 1223 | xfs_da_buf_done(bp); |