diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-03-23 23:44:19 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-03-23 23:44:19 -0500 |
commit | 1ebbe2b20091d306453a5cf480a87e6cd28ae76f (patch) | |
tree | f5cd7a0fa69b8b1938cb5a0faed2e7b0628072a5 /fs/xfs/xfs_dir2_leaf.c | |
parent | ac58c9059da8886b5e8cde012a80266b18ca146e (diff) | |
parent | 674a396c6d2ba0341ebdd7c1c9950f32f018e2dd (diff) |
Merge branch 'linus'
Diffstat (limited to 'fs/xfs/xfs_dir2_leaf.c')
-rw-r--r-- | fs/xfs/xfs_dir2_leaf.c | 285 |
1 files changed, 143 insertions, 142 deletions
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c index d342b6b55239..08648b18265c 100644 --- a/fs/xfs/xfs_dir2_leaf.c +++ b/fs/xfs/xfs_dir2_leaf.c | |||
@@ -66,7 +66,7 @@ xfs_dir2_block_to_leaf( | |||
66 | xfs_da_args_t *args, /* operation arguments */ | 66 | xfs_da_args_t *args, /* operation arguments */ |
67 | xfs_dabuf_t *dbp) /* input block's buffer */ | 67 | xfs_dabuf_t *dbp) /* input block's buffer */ |
68 | { | 68 | { |
69 | xfs_dir2_data_off_t *bestsp; /* leaf's bestsp entries */ | 69 | __be16 *bestsp; /* leaf's bestsp entries */ |
70 | xfs_dablk_t blkno; /* leaf block's bno */ | 70 | xfs_dablk_t blkno; /* leaf block's bno */ |
71 | xfs_dir2_block_t *block; /* block structure */ | 71 | xfs_dir2_block_t *block; /* block structure */ |
72 | xfs_dir2_leaf_entry_t *blp; /* block's leaf entries */ | 72 | xfs_dir2_leaf_entry_t *blp; /* block's leaf entries */ |
@@ -111,14 +111,14 @@ xfs_dir2_block_to_leaf( | |||
111 | /* | 111 | /* |
112 | * Set the counts in the leaf header. | 112 | * Set the counts in the leaf header. |
113 | */ | 113 | */ |
114 | INT_COPY(leaf->hdr.count, btp->count, ARCH_CONVERT); /* INT_: type change */ | 114 | leaf->hdr.count = cpu_to_be16(be32_to_cpu(btp->count)); |
115 | INT_COPY(leaf->hdr.stale, btp->stale, ARCH_CONVERT); /* INT_: type change */ | 115 | leaf->hdr.stale = cpu_to_be16(be32_to_cpu(btp->stale)); |
116 | /* | 116 | /* |
117 | * Could compact these but I think we always do the conversion | 117 | * Could compact these but I think we always do the conversion |
118 | * after squeezing out stale entries. | 118 | * after squeezing out stale entries. |
119 | */ | 119 | */ |
120 | memcpy(leaf->ents, blp, INT_GET(btp->count, ARCH_CONVERT) * sizeof(xfs_dir2_leaf_entry_t)); | 120 | memcpy(leaf->ents, blp, be32_to_cpu(btp->count) * sizeof(xfs_dir2_leaf_entry_t)); |
121 | xfs_dir2_leaf_log_ents(tp, lbp, 0, INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1); | 121 | xfs_dir2_leaf_log_ents(tp, lbp, 0, be16_to_cpu(leaf->hdr.count) - 1); |
122 | needscan = 0; | 122 | needscan = 0; |
123 | needlog = 1; | 123 | needlog = 1; |
124 | /* | 124 | /* |
@@ -133,7 +133,7 @@ xfs_dir2_block_to_leaf( | |||
133 | /* | 133 | /* |
134 | * Fix up the block header, make it a data block. | 134 | * Fix up the block header, make it a data block. |
135 | */ | 135 | */ |
136 | INT_SET(block->hdr.magic, ARCH_CONVERT, XFS_DIR2_DATA_MAGIC); | 136 | block->hdr.magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC); |
137 | if (needscan) | 137 | if (needscan) |
138 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)block, &needlog, | 138 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)block, &needlog, |
139 | NULL); | 139 | NULL); |
@@ -141,9 +141,9 @@ xfs_dir2_block_to_leaf( | |||
141 | * Set up leaf tail and bests table. | 141 | * Set up leaf tail and bests table. |
142 | */ | 142 | */ |
143 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); | 143 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); |
144 | INT_SET(ltp->bestcount, ARCH_CONVERT, 1); | 144 | ltp->bestcount = cpu_to_be32(1); |
145 | bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); | 145 | bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); |
146 | INT_COPY(bestsp[0], block->hdr.bestfree[0].length, ARCH_CONVERT); | 146 | bestsp[0] = block->hdr.bestfree[0].length; |
147 | /* | 147 | /* |
148 | * Log the data header and leaf bests table. | 148 | * Log the data header and leaf bests table. |
149 | */ | 149 | */ |
@@ -163,7 +163,7 @@ int /* error */ | |||
163 | xfs_dir2_leaf_addname( | 163 | xfs_dir2_leaf_addname( |
164 | xfs_da_args_t *args) /* operation arguments */ | 164 | xfs_da_args_t *args) /* operation arguments */ |
165 | { | 165 | { |
166 | xfs_dir2_data_off_t *bestsp; /* freespace table in leaf */ | 166 | __be16 *bestsp; /* freespace table in leaf */ |
167 | int compact; /* need to compact leaves */ | 167 | int compact; /* need to compact leaves */ |
168 | xfs_dir2_data_t *data; /* data block structure */ | 168 | xfs_dir2_data_t *data; /* data block structure */ |
169 | xfs_dabuf_t *dbp; /* data block buffer */ | 169 | xfs_dabuf_t *dbp; /* data block buffer */ |
@@ -187,7 +187,7 @@ xfs_dir2_leaf_addname( | |||
187 | int needbytes; /* leaf block bytes needed */ | 187 | int needbytes; /* leaf block bytes needed */ |
188 | int needlog; /* need to log data header */ | 188 | int needlog; /* need to log data header */ |
189 | int needscan; /* need to rescan data free */ | 189 | int needscan; /* need to rescan data free */ |
190 | xfs_dir2_data_off_t *tagp; /* end of data entry */ | 190 | __be16 *tagp; /* end of data entry */ |
191 | xfs_trans_t *tp; /* transaction pointer */ | 191 | xfs_trans_t *tp; /* transaction pointer */ |
192 | xfs_dir2_db_t use_block; /* data block number */ | 192 | xfs_dir2_db_t use_block; /* data block number */ |
193 | 193 | ||
@@ -222,14 +222,14 @@ xfs_dir2_leaf_addname( | |||
222 | * in a data block, improving the lookup of those entries. | 222 | * in a data block, improving the lookup of those entries. |
223 | */ | 223 | */ |
224 | for (use_block = -1, lep = &leaf->ents[index]; | 224 | for (use_block = -1, lep = &leaf->ents[index]; |
225 | index < INT_GET(leaf->hdr.count, ARCH_CONVERT) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval; | 225 | index < be16_to_cpu(leaf->hdr.count) && be32_to_cpu(lep->hashval) == args->hashval; |
226 | index++, lep++) { | 226 | index++, lep++) { |
227 | if (INT_GET(lep->address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 227 | if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR) |
228 | continue; | 228 | continue; |
229 | i = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT)); | 229 | i = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address)); |
230 | ASSERT(i < INT_GET(ltp->bestcount, ARCH_CONVERT)); | 230 | ASSERT(i < be32_to_cpu(ltp->bestcount)); |
231 | ASSERT(INT_GET(bestsp[i], ARCH_CONVERT) != NULLDATAOFF); | 231 | ASSERT(be16_to_cpu(bestsp[i]) != NULLDATAOFF); |
232 | if (INT_GET(bestsp[i], ARCH_CONVERT) >= length) { | 232 | if (be16_to_cpu(bestsp[i]) >= length) { |
233 | use_block = i; | 233 | use_block = i; |
234 | break; | 234 | break; |
235 | } | 235 | } |
@@ -238,13 +238,13 @@ xfs_dir2_leaf_addname( | |||
238 | * Didn't find a block yet, linear search all the data blocks. | 238 | * Didn't find a block yet, linear search all the data blocks. |
239 | */ | 239 | */ |
240 | if (use_block == -1) { | 240 | if (use_block == -1) { |
241 | for (i = 0; i < INT_GET(ltp->bestcount, ARCH_CONVERT); i++) { | 241 | for (i = 0; i < be32_to_cpu(ltp->bestcount); i++) { |
242 | /* | 242 | /* |
243 | * Remember a block we see that's missing. | 243 | * Remember a block we see that's missing. |
244 | */ | 244 | */ |
245 | if (INT_GET(bestsp[i], ARCH_CONVERT) == NULLDATAOFF && use_block == -1) | 245 | if (be16_to_cpu(bestsp[i]) == NULLDATAOFF && use_block == -1) |
246 | use_block = i; | 246 | use_block = i; |
247 | else if (INT_GET(bestsp[i], ARCH_CONVERT) >= length) { | 247 | else if (be16_to_cpu(bestsp[i]) >= length) { |
248 | use_block = i; | 248 | use_block = i; |
249 | break; | 249 | break; |
250 | } | 250 | } |
@@ -260,21 +260,21 @@ xfs_dir2_leaf_addname( | |||
260 | * Now kill use_block if it refers to a missing block, so we | 260 | * Now kill use_block if it refers to a missing block, so we |
261 | * can use it as an indication of allocation needed. | 261 | * can use it as an indication of allocation needed. |
262 | */ | 262 | */ |
263 | if (use_block != -1 && INT_GET(bestsp[use_block], ARCH_CONVERT) == NULLDATAOFF) | 263 | if (use_block != -1 && be16_to_cpu(bestsp[use_block]) == NULLDATAOFF) |
264 | use_block = -1; | 264 | use_block = -1; |
265 | /* | 265 | /* |
266 | * If we don't have enough free bytes but we can make enough | 266 | * If we don't have enough free bytes but we can make enough |
267 | * by compacting out stale entries, we'll do that. | 267 | * by compacting out stale entries, we'll do that. |
268 | */ | 268 | */ |
269 | if ((char *)bestsp - (char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] < needbytes && | 269 | if ((char *)bestsp - (char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] < needbytes && |
270 | INT_GET(leaf->hdr.stale, ARCH_CONVERT) > 1) { | 270 | be16_to_cpu(leaf->hdr.stale) > 1) { |
271 | compact = 1; | 271 | compact = 1; |
272 | } | 272 | } |
273 | /* | 273 | /* |
274 | * Otherwise if we don't have enough free bytes we need to | 274 | * Otherwise if we don't have enough free bytes we need to |
275 | * convert to node form. | 275 | * convert to node form. |
276 | */ | 276 | */ |
277 | else if ((char *)bestsp - (char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] < | 277 | else if ((char *)bestsp - (char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] < |
278 | needbytes) { | 278 | needbytes) { |
279 | /* | 279 | /* |
280 | * Just checking or no space reservation, give up. | 280 | * Just checking or no space reservation, give up. |
@@ -330,8 +330,8 @@ xfs_dir2_leaf_addname( | |||
330 | * There are stale entries, so we'll need log-low and log-high | 330 | * There are stale entries, so we'll need log-low and log-high |
331 | * impossibly bad values later. | 331 | * impossibly bad values later. |
332 | */ | 332 | */ |
333 | else if (INT_GET(leaf->hdr.stale, ARCH_CONVERT)) { | 333 | else if (be16_to_cpu(leaf->hdr.stale)) { |
334 | lfloglow = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 334 | lfloglow = be16_to_cpu(leaf->hdr.count); |
335 | lfloghigh = -1; | 335 | lfloghigh = -1; |
336 | } | 336 | } |
337 | /* | 337 | /* |
@@ -358,13 +358,13 @@ xfs_dir2_leaf_addname( | |||
358 | * If we're adding a new data block on the end we need to | 358 | * If we're adding a new data block on the end we need to |
359 | * extend the bests table. Copy it up one entry. | 359 | * extend the bests table. Copy it up one entry. |
360 | */ | 360 | */ |
361 | if (use_block >= INT_GET(ltp->bestcount, ARCH_CONVERT)) { | 361 | if (use_block >= be32_to_cpu(ltp->bestcount)) { |
362 | bestsp--; | 362 | bestsp--; |
363 | memmove(&bestsp[0], &bestsp[1], | 363 | memmove(&bestsp[0], &bestsp[1], |
364 | INT_GET(ltp->bestcount, ARCH_CONVERT) * sizeof(bestsp[0])); | 364 | be32_to_cpu(ltp->bestcount) * sizeof(bestsp[0])); |
365 | INT_MOD(ltp->bestcount, ARCH_CONVERT, +1); | 365 | be32_add(<p->bestcount, 1); |
366 | xfs_dir2_leaf_log_tail(tp, lbp); | 366 | xfs_dir2_leaf_log_tail(tp, lbp); |
367 | xfs_dir2_leaf_log_bests(tp, lbp, 0, INT_GET(ltp->bestcount, ARCH_CONVERT) - 1); | 367 | xfs_dir2_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1); |
368 | } | 368 | } |
369 | /* | 369 | /* |
370 | * If we're filling in a previously empty block just log it. | 370 | * If we're filling in a previously empty block just log it. |
@@ -372,7 +372,7 @@ xfs_dir2_leaf_addname( | |||
372 | else | 372 | else |
373 | xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); | 373 | xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); |
374 | data = dbp->data; | 374 | data = dbp->data; |
375 | INT_COPY(bestsp[use_block], data->hdr.bestfree[0].length, ARCH_CONVERT); | 375 | bestsp[use_block] = data->hdr.bestfree[0].length; |
376 | grown = 1; | 376 | grown = 1; |
377 | } | 377 | } |
378 | /* | 378 | /* |
@@ -394,8 +394,8 @@ xfs_dir2_leaf_addname( | |||
394 | * Point to the biggest freespace in our data block. | 394 | * Point to the biggest freespace in our data block. |
395 | */ | 395 | */ |
396 | dup = (xfs_dir2_data_unused_t *) | 396 | dup = (xfs_dir2_data_unused_t *) |
397 | ((char *)data + INT_GET(data->hdr.bestfree[0].offset, ARCH_CONVERT)); | 397 | ((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset)); |
398 | ASSERT(INT_GET(dup->length, ARCH_CONVERT) >= length); | 398 | ASSERT(be16_to_cpu(dup->length) >= length); |
399 | needscan = needlog = 0; | 399 | needscan = needlog = 0; |
400 | /* | 400 | /* |
401 | * Mark the initial part of our freespace in use for the new entry. | 401 | * Mark the initial part of our freespace in use for the new entry. |
@@ -411,7 +411,7 @@ xfs_dir2_leaf_addname( | |||
411 | dep->namelen = args->namelen; | 411 | dep->namelen = args->namelen; |
412 | memcpy(dep->name, args->name, dep->namelen); | 412 | memcpy(dep->name, args->name, dep->namelen); |
413 | tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); | 413 | tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); |
414 | INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)data)); | 414 | *tagp = cpu_to_be16((char *)dep - (char *)data); |
415 | /* | 415 | /* |
416 | * Need to scan fix up the bestfree table. | 416 | * Need to scan fix up the bestfree table. |
417 | */ | 417 | */ |
@@ -427,8 +427,8 @@ xfs_dir2_leaf_addname( | |||
427 | * If the bests table needs to be changed, do it. | 427 | * If the bests table needs to be changed, do it. |
428 | * Log the change unless we've already done that. | 428 | * Log the change unless we've already done that. |
429 | */ | 429 | */ |
430 | if (INT_GET(bestsp[use_block], ARCH_CONVERT) != INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT)) { | 430 | if (be16_to_cpu(bestsp[use_block]) != be16_to_cpu(data->hdr.bestfree[0].length)) { |
431 | INT_COPY(bestsp[use_block], data->hdr.bestfree[0].length, ARCH_CONVERT); | 431 | bestsp[use_block] = data->hdr.bestfree[0].length; |
432 | if (!grown) | 432 | if (!grown) |
433 | xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); | 433 | xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); |
434 | } | 434 | } |
@@ -440,15 +440,15 @@ xfs_dir2_leaf_addname( | |||
440 | /* | 440 | /* |
441 | * lep is still good as the index leaf entry. | 441 | * lep is still good as the index leaf entry. |
442 | */ | 442 | */ |
443 | if (index < INT_GET(leaf->hdr.count, ARCH_CONVERT)) | 443 | if (index < be16_to_cpu(leaf->hdr.count)) |
444 | memmove(lep + 1, lep, | 444 | memmove(lep + 1, lep, |
445 | (INT_GET(leaf->hdr.count, ARCH_CONVERT) - index) * sizeof(*lep)); | 445 | (be16_to_cpu(leaf->hdr.count) - index) * sizeof(*lep)); |
446 | /* | 446 | /* |
447 | * Record low and high logging indices for the leaf. | 447 | * Record low and high logging indices for the leaf. |
448 | */ | 448 | */ |
449 | lfloglow = index; | 449 | lfloglow = index; |
450 | lfloghigh = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 450 | lfloghigh = be16_to_cpu(leaf->hdr.count); |
451 | INT_MOD(leaf->hdr.count, ARCH_CONVERT, +1); | 451 | be16_add(&leaf->hdr.count, 1); |
452 | } | 452 | } |
453 | /* | 453 | /* |
454 | * There are stale entries. | 454 | * There are stale entries. |
@@ -468,7 +468,7 @@ xfs_dir2_leaf_addname( | |||
468 | */ | 468 | */ |
469 | for (lowstale = index - 1; | 469 | for (lowstale = index - 1; |
470 | lowstale >= 0 && | 470 | lowstale >= 0 && |
471 | INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) != | 471 | be32_to_cpu(leaf->ents[lowstale].address) != |
472 | XFS_DIR2_NULL_DATAPTR; | 472 | XFS_DIR2_NULL_DATAPTR; |
473 | lowstale--) | 473 | lowstale--) |
474 | continue; | 474 | continue; |
@@ -478,8 +478,8 @@ xfs_dir2_leaf_addname( | |||
478 | * lowstale entry would be better. | 478 | * lowstale entry would be better. |
479 | */ | 479 | */ |
480 | for (highstale = index; | 480 | for (highstale = index; |
481 | highstale < INT_GET(leaf->hdr.count, ARCH_CONVERT) && | 481 | highstale < be16_to_cpu(leaf->hdr.count) && |
482 | INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != | 482 | be32_to_cpu(leaf->ents[highstale].address) != |
483 | XFS_DIR2_NULL_DATAPTR && | 483 | XFS_DIR2_NULL_DATAPTR && |
484 | (lowstale < 0 || | 484 | (lowstale < 0 || |
485 | index - lowstale - 1 >= highstale - index); | 485 | index - lowstale - 1 >= highstale - index); |
@@ -490,10 +490,10 @@ xfs_dir2_leaf_addname( | |||
490 | * If the low one is better, use it. | 490 | * If the low one is better, use it. |
491 | */ | 491 | */ |
492 | if (lowstale >= 0 && | 492 | if (lowstale >= 0 && |
493 | (highstale == INT_GET(leaf->hdr.count, ARCH_CONVERT) || | 493 | (highstale == be16_to_cpu(leaf->hdr.count) || |
494 | index - lowstale - 1 < highstale - index)) { | 494 | index - lowstale - 1 < highstale - index)) { |
495 | ASSERT(index - lowstale - 1 >= 0); | 495 | ASSERT(index - lowstale - 1 >= 0); |
496 | ASSERT(INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) == | 496 | ASSERT(be32_to_cpu(leaf->ents[lowstale].address) == |
497 | XFS_DIR2_NULL_DATAPTR); | 497 | XFS_DIR2_NULL_DATAPTR); |
498 | /* | 498 | /* |
499 | * Copy entries up to cover the stale entry | 499 | * Copy entries up to cover the stale entry |
@@ -512,7 +512,7 @@ xfs_dir2_leaf_addname( | |||
512 | */ | 512 | */ |
513 | else { | 513 | else { |
514 | ASSERT(highstale - index >= 0); | 514 | ASSERT(highstale - index >= 0); |
515 | ASSERT(INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) == | 515 | ASSERT(be32_to_cpu(leaf->ents[highstale].address) == |
516 | XFS_DIR2_NULL_DATAPTR); | 516 | XFS_DIR2_NULL_DATAPTR); |
517 | /* | 517 | /* |
518 | * Copy entries down to copver the stale entry | 518 | * Copy entries down to copver the stale entry |
@@ -526,13 +526,14 @@ xfs_dir2_leaf_addname( | |||
526 | lfloglow = MIN(index, lfloglow); | 526 | lfloglow = MIN(index, lfloglow); |
527 | lfloghigh = MAX(highstale, lfloghigh); | 527 | lfloghigh = MAX(highstale, lfloghigh); |
528 | } | 528 | } |
529 | INT_MOD(leaf->hdr.stale, ARCH_CONVERT, -1); | 529 | be16_add(&leaf->hdr.stale, -1); |
530 | } | 530 | } |
531 | /* | 531 | /* |
532 | * Fill in the new leaf entry. | 532 | * Fill in the new leaf entry. |
533 | */ | 533 | */ |
534 | INT_SET(lep->hashval, ARCH_CONVERT, args->hashval); | 534 | lep->hashval = cpu_to_be32(args->hashval); |
535 | INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_DB_OFF_TO_DATAPTR(mp, use_block, INT_GET(*tagp, ARCH_CONVERT))); | 535 | lep->address = cpu_to_be32(XFS_DIR2_DB_OFF_TO_DATAPTR(mp, use_block, |
536 | be16_to_cpu(*tagp))); | ||
536 | /* | 537 | /* |
537 | * Log the leaf fields and give up the buffers. | 538 | * Log the leaf fields and give up the buffers. |
538 | */ | 539 | */ |
@@ -563,30 +564,30 @@ xfs_dir2_leaf_check( | |||
563 | 564 | ||
564 | leaf = bp->data; | 565 | leaf = bp->data; |
565 | mp = dp->i_mount; | 566 | mp = dp->i_mount; |
566 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC); | 567 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC); |
567 | /* | 568 | /* |
568 | * This value is not restrictive enough. | 569 | * This value is not restrictive enough. |
569 | * Should factor in the size of the bests table as well. | 570 | * Should factor in the size of the bests table as well. |
570 | * We can deduce a value for that from di_size. | 571 | * We can deduce a value for that from di_size. |
571 | */ | 572 | */ |
572 | ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) <= XFS_DIR2_MAX_LEAF_ENTS(mp)); | 573 | ASSERT(be16_to_cpu(leaf->hdr.count) <= XFS_DIR2_MAX_LEAF_ENTS(mp)); |
573 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); | 574 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); |
574 | /* | 575 | /* |
575 | * Leaves and bests don't overlap. | 576 | * Leaves and bests don't overlap. |
576 | */ | 577 | */ |
577 | ASSERT((char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] <= | 578 | ASSERT((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] <= |
578 | (char *)XFS_DIR2_LEAF_BESTS_P(ltp)); | 579 | (char *)XFS_DIR2_LEAF_BESTS_P(ltp)); |
579 | /* | 580 | /* |
580 | * Check hash value order, count stale entries. | 581 | * Check hash value order, count stale entries. |
581 | */ | 582 | */ |
582 | for (i = stale = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); i++) { | 583 | for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) { |
583 | if (i + 1 < INT_GET(leaf->hdr.count, ARCH_CONVERT)) | 584 | if (i + 1 < be16_to_cpu(leaf->hdr.count)) |
584 | ASSERT(INT_GET(leaf->ents[i].hashval, ARCH_CONVERT) <= | 585 | ASSERT(be32_to_cpu(leaf->ents[i].hashval) <= |
585 | INT_GET(leaf->ents[i + 1].hashval, ARCH_CONVERT)); | 586 | be32_to_cpu(leaf->ents[i + 1].hashval)); |
586 | if (INT_GET(leaf->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 587 | if (be32_to_cpu(leaf->ents[i].address) == XFS_DIR2_NULL_DATAPTR) |
587 | stale++; | 588 | stale++; |
588 | } | 589 | } |
589 | ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) == stale); | 590 | ASSERT(be16_to_cpu(leaf->hdr.stale) == stale); |
590 | } | 591 | } |
591 | #endif /* DEBUG */ | 592 | #endif /* DEBUG */ |
592 | 593 | ||
@@ -611,8 +612,8 @@ xfs_dir2_leaf_compact( | |||
611 | /* | 612 | /* |
612 | * Compress out the stale entries in place. | 613 | * Compress out the stale entries in place. |
613 | */ | 614 | */ |
614 | for (from = to = 0, loglow = -1; from < INT_GET(leaf->hdr.count, ARCH_CONVERT); from++) { | 615 | for (from = to = 0, loglow = -1; from < be16_to_cpu(leaf->hdr.count); from++) { |
615 | if (INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 616 | if (be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR) |
616 | continue; | 617 | continue; |
617 | /* | 618 | /* |
618 | * Only actually copy the entries that are different. | 619 | * Only actually copy the entries that are different. |
@@ -627,8 +628,8 @@ xfs_dir2_leaf_compact( | |||
627 | /* | 628 | /* |
628 | * Update and log the header, log the leaf entries. | 629 | * Update and log the header, log the leaf entries. |
629 | */ | 630 | */ |
630 | ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) == from - to); | 631 | ASSERT(be16_to_cpu(leaf->hdr.stale) == from - to); |
631 | INT_MOD(leaf->hdr.count, ARCH_CONVERT, -(INT_GET(leaf->hdr.stale, ARCH_CONVERT))); | 632 | be16_add(&leaf->hdr.count, -(be16_to_cpu(leaf->hdr.stale))); |
632 | leaf->hdr.stale = 0; | 633 | leaf->hdr.stale = 0; |
633 | xfs_dir2_leaf_log_header(args->trans, bp); | 634 | xfs_dir2_leaf_log_header(args->trans, bp); |
634 | if (loglow != -1) | 635 | if (loglow != -1) |
@@ -662,14 +663,14 @@ xfs_dir2_leaf_compact_x1( | |||
662 | int to; /* destination copy index */ | 663 | int to; /* destination copy index */ |
663 | 664 | ||
664 | leaf = bp->data; | 665 | leaf = bp->data; |
665 | ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) > 1); | 666 | ASSERT(be16_to_cpu(leaf->hdr.stale) > 1); |
666 | index = *indexp; | 667 | index = *indexp; |
667 | /* | 668 | /* |
668 | * Find the first stale entry before our index, if any. | 669 | * Find the first stale entry before our index, if any. |
669 | */ | 670 | */ |
670 | for (lowstale = index - 1; | 671 | for (lowstale = index - 1; |
671 | lowstale >= 0 && | 672 | lowstale >= 0 && |
672 | INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR; | 673 | be32_to_cpu(leaf->ents[lowstale].address) != XFS_DIR2_NULL_DATAPTR; |
673 | lowstale--) | 674 | lowstale--) |
674 | continue; | 675 | continue; |
675 | /* | 676 | /* |
@@ -677,8 +678,8 @@ xfs_dir2_leaf_compact_x1( | |||
677 | * Stop if the answer would be worse than lowstale. | 678 | * Stop if the answer would be worse than lowstale. |
678 | */ | 679 | */ |
679 | for (highstale = index; | 680 | for (highstale = index; |
680 | highstale < INT_GET(leaf->hdr.count, ARCH_CONVERT) && | 681 | highstale < be16_to_cpu(leaf->hdr.count) && |
681 | INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR && | 682 | be32_to_cpu(leaf->ents[highstale].address) != XFS_DIR2_NULL_DATAPTR && |
682 | (lowstale < 0 || index - lowstale > highstale - index); | 683 | (lowstale < 0 || index - lowstale > highstale - index); |
683 | highstale++) | 684 | highstale++) |
684 | continue; | 685 | continue; |
@@ -686,7 +687,7 @@ xfs_dir2_leaf_compact_x1( | |||
686 | * Pick the better of lowstale and highstale. | 687 | * Pick the better of lowstale and highstale. |
687 | */ | 688 | */ |
688 | if (lowstale >= 0 && | 689 | if (lowstale >= 0 && |
689 | (highstale == INT_GET(leaf->hdr.count, ARCH_CONVERT) || | 690 | (highstale == be16_to_cpu(leaf->hdr.count) || |
690 | index - lowstale <= highstale - index)) | 691 | index - lowstale <= highstale - index)) |
691 | keepstale = lowstale; | 692 | keepstale = lowstale; |
692 | else | 693 | else |
@@ -695,14 +696,14 @@ xfs_dir2_leaf_compact_x1( | |||
695 | * Copy the entries in place, removing all the stale entries | 696 | * Copy the entries in place, removing all the stale entries |
696 | * except keepstale. | 697 | * except keepstale. |
697 | */ | 698 | */ |
698 | for (from = to = 0; from < INT_GET(leaf->hdr.count, ARCH_CONVERT); from++) { | 699 | for (from = to = 0; from < be16_to_cpu(leaf->hdr.count); from++) { |
699 | /* | 700 | /* |
700 | * Notice the new value of index. | 701 | * Notice the new value of index. |
701 | */ | 702 | */ |
702 | if (index == from) | 703 | if (index == from) |
703 | newindex = to; | 704 | newindex = to; |
704 | if (from != keepstale && | 705 | if (from != keepstale && |
705 | INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) { | 706 | be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR) { |
706 | if (from == to) | 707 | if (from == to) |
707 | *lowlogp = to; | 708 | *lowlogp = to; |
708 | continue; | 709 | continue; |
@@ -730,8 +731,8 @@ xfs_dir2_leaf_compact_x1( | |||
730 | /* | 731 | /* |
731 | * Adjust the leaf header values. | 732 | * Adjust the leaf header values. |
732 | */ | 733 | */ |
733 | INT_MOD(leaf->hdr.count, ARCH_CONVERT, -(from - to)); | 734 | be16_add(&leaf->hdr.count, -(from - to)); |
734 | INT_SET(leaf->hdr.stale, ARCH_CONVERT, 1); | 735 | leaf->hdr.stale = cpu_to_be16(1); |
735 | /* | 736 | /* |
736 | * Remember the low/high stale value only in the "right" | 737 | * Remember the low/high stale value only in the "right" |
737 | * direction. | 738 | * direction. |
@@ -739,8 +740,8 @@ xfs_dir2_leaf_compact_x1( | |||
739 | if (lowstale >= newindex) | 740 | if (lowstale >= newindex) |
740 | lowstale = -1; | 741 | lowstale = -1; |
741 | else | 742 | else |
742 | highstale = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 743 | highstale = be16_to_cpu(leaf->hdr.count); |
743 | *highlogp = INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1; | 744 | *highlogp = be16_to_cpu(leaf->hdr.count) - 1; |
744 | *lowstalep = lowstale; | 745 | *lowstalep = lowstale; |
745 | *highstalep = highstale; | 746 | *highstalep = highstale; |
746 | } | 747 | } |
@@ -766,7 +767,7 @@ xfs_dir2_leaf_getdents( | |||
766 | xfs_dir2_data_entry_t *dep; /* data entry */ | 767 | xfs_dir2_data_entry_t *dep; /* data entry */ |
767 | xfs_dir2_data_unused_t *dup; /* unused entry */ | 768 | xfs_dir2_data_unused_t *dup; /* unused entry */ |
768 | int eof; /* reached end of directory */ | 769 | int eof; /* reached end of directory */ |
769 | int error=0; /* error return value */ | 770 | int error = 0; /* error return value */ |
770 | int i; /* temporary loop index */ | 771 | int i; /* temporary loop index */ |
771 | int j; /* temporary loop index */ | 772 | int j; /* temporary loop index */ |
772 | int length; /* temporary length value */ | 773 | int length; /* temporary length value */ |
@@ -778,8 +779,8 @@ xfs_dir2_leaf_getdents( | |||
778 | xfs_mount_t *mp; /* filesystem mount point */ | 779 | xfs_mount_t *mp; /* filesystem mount point */ |
779 | xfs_dir2_off_t newoff; /* new curoff after new blk */ | 780 | xfs_dir2_off_t newoff; /* new curoff after new blk */ |
780 | int nmap; /* mappings to ask xfs_bmapi */ | 781 | int nmap; /* mappings to ask xfs_bmapi */ |
781 | xfs_dir2_put_args_t p; /* formatting arg bundle */ | 782 | xfs_dir2_put_args_t *p; /* formatting arg bundle */ |
782 | char *ptr=NULL; /* pointer to current data */ | 783 | char *ptr = NULL; /* pointer to current data */ |
783 | int ra_current; /* number of read-ahead blks */ | 784 | int ra_current; /* number of read-ahead blks */ |
784 | int ra_index; /* *map index for read-ahead */ | 785 | int ra_index; /* *map index for read-ahead */ |
785 | int ra_offset; /* map entry offset for ra */ | 786 | int ra_offset; /* map entry offset for ra */ |
@@ -797,9 +798,10 @@ xfs_dir2_leaf_getdents( | |||
797 | /* | 798 | /* |
798 | * Setup formatting arguments. | 799 | * Setup formatting arguments. |
799 | */ | 800 | */ |
800 | p.dbp = dbp; | 801 | p = kmem_alloc(sizeof(*p), KM_SLEEP); |
801 | p.put = put; | 802 | p->dbp = dbp; |
802 | p.uio = uio; | 803 | p->put = put; |
804 | p->uio = uio; | ||
803 | /* | 805 | /* |
804 | * Set up to bmap a number of blocks based on the caller's | 806 | * Set up to bmap a number of blocks based on the caller's |
805 | * buffer size, the directory block size, and the filesystem | 807 | * buffer size, the directory block size, and the filesystem |
@@ -1046,11 +1048,10 @@ xfs_dir2_leaf_getdents( | |||
1046 | while ((char *)ptr - (char *)data < byteoff) { | 1048 | while ((char *)ptr - (char *)data < byteoff) { |
1047 | dup = (xfs_dir2_data_unused_t *)ptr; | 1049 | dup = (xfs_dir2_data_unused_t *)ptr; |
1048 | 1050 | ||
1049 | if (INT_GET(dup->freetag, ARCH_CONVERT) | 1051 | if (be16_to_cpu(dup->freetag) |
1050 | == XFS_DIR2_DATA_FREE_TAG) { | 1052 | == XFS_DIR2_DATA_FREE_TAG) { |
1051 | 1053 | ||
1052 | length = INT_GET(dup->length, | 1054 | length = be16_to_cpu(dup->length); |
1053 | ARCH_CONVERT); | ||
1054 | ptr += length; | 1055 | ptr += length; |
1055 | continue; | 1056 | continue; |
1056 | } | 1057 | } |
@@ -1079,9 +1080,8 @@ xfs_dir2_leaf_getdents( | |||
1079 | /* | 1080 | /* |
1080 | * No, it's unused, skip over it. | 1081 | * No, it's unused, skip over it. |
1081 | */ | 1082 | */ |
1082 | if (INT_GET(dup->freetag, ARCH_CONVERT) | 1083 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { |
1083 | == XFS_DIR2_DATA_FREE_TAG) { | 1084 | length = be16_to_cpu(dup->length); |
1084 | length = INT_GET(dup->length, ARCH_CONVERT); | ||
1085 | ptr += length; | 1085 | ptr += length; |
1086 | curoff += length; | 1086 | curoff += length; |
1087 | continue; | 1087 | continue; |
@@ -1092,24 +1092,24 @@ xfs_dir2_leaf_getdents( | |||
1092 | */ | 1092 | */ |
1093 | dep = (xfs_dir2_data_entry_t *)ptr; | 1093 | dep = (xfs_dir2_data_entry_t *)ptr; |
1094 | 1094 | ||
1095 | p.namelen = dep->namelen; | 1095 | p->namelen = dep->namelen; |
1096 | 1096 | ||
1097 | length = XFS_DIR2_DATA_ENTSIZE(p.namelen); | 1097 | length = XFS_DIR2_DATA_ENTSIZE(p->namelen); |
1098 | 1098 | ||
1099 | p.cook = XFS_DIR2_BYTE_TO_DATAPTR(mp, curoff + length); | 1099 | p->cook = XFS_DIR2_BYTE_TO_DATAPTR(mp, curoff + length); |
1100 | 1100 | ||
1101 | p.ino = INT_GET(dep->inumber, ARCH_CONVERT); | 1101 | p->ino = INT_GET(dep->inumber, ARCH_CONVERT); |
1102 | #if XFS_BIG_INUMS | 1102 | #if XFS_BIG_INUMS |
1103 | p.ino += mp->m_inoadd; | 1103 | p->ino += mp->m_inoadd; |
1104 | #endif | 1104 | #endif |
1105 | p.name = (char *)dep->name; | 1105 | p->name = (char *)dep->name; |
1106 | 1106 | ||
1107 | error = p.put(&p); | 1107 | error = p->put(p); |
1108 | 1108 | ||
1109 | /* | 1109 | /* |
1110 | * Won't fit. Return to caller. | 1110 | * Won't fit. Return to caller. |
1111 | */ | 1111 | */ |
1112 | if (!p.done) { | 1112 | if (!p->done) { |
1113 | eof = 0; | 1113 | eof = 0; |
1114 | break; | 1114 | break; |
1115 | } | 1115 | } |
@@ -1129,6 +1129,7 @@ xfs_dir2_leaf_getdents( | |||
1129 | else | 1129 | else |
1130 | uio->uio_offset = XFS_DIR2_BYTE_TO_DATAPTR(mp, curoff); | 1130 | uio->uio_offset = XFS_DIR2_BYTE_TO_DATAPTR(mp, curoff); |
1131 | kmem_free(map, map_size * sizeof(*map)); | 1131 | kmem_free(map, map_size * sizeof(*map)); |
1132 | kmem_free(p, sizeof(*p)); | ||
1132 | if (bp) | 1133 | if (bp) |
1133 | xfs_da_brelse(tp, bp); | 1134 | xfs_da_brelse(tp, bp); |
1134 | return error; | 1135 | return error; |
@@ -1171,7 +1172,7 @@ xfs_dir2_leaf_init( | |||
1171 | /* | 1172 | /* |
1172 | * Initialize the header. | 1173 | * Initialize the header. |
1173 | */ | 1174 | */ |
1174 | INT_SET(leaf->hdr.info.magic, ARCH_CONVERT, magic); | 1175 | leaf->hdr.info.magic = cpu_to_be16(magic); |
1175 | leaf->hdr.info.forw = 0; | 1176 | leaf->hdr.info.forw = 0; |
1176 | leaf->hdr.info.back = 0; | 1177 | leaf->hdr.info.back = 0; |
1177 | leaf->hdr.count = 0; | 1178 | leaf->hdr.count = 0; |
@@ -1201,13 +1202,13 @@ xfs_dir2_leaf_log_bests( | |||
1201 | int first, /* first entry to log */ | 1202 | int first, /* first entry to log */ |
1202 | int last) /* last entry to log */ | 1203 | int last) /* last entry to log */ |
1203 | { | 1204 | { |
1204 | xfs_dir2_data_off_t *firstb; /* pointer to first entry */ | 1205 | __be16 *firstb; /* pointer to first entry */ |
1205 | xfs_dir2_data_off_t *lastb; /* pointer to last entry */ | 1206 | __be16 *lastb; /* pointer to last entry */ |
1206 | xfs_dir2_leaf_t *leaf; /* leaf structure */ | 1207 | xfs_dir2_leaf_t *leaf; /* leaf structure */ |
1207 | xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ | 1208 | xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ |
1208 | 1209 | ||
1209 | leaf = bp->data; | 1210 | leaf = bp->data; |
1210 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC); | 1211 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC); |
1211 | ltp = XFS_DIR2_LEAF_TAIL_P(tp->t_mountp, leaf); | 1212 | ltp = XFS_DIR2_LEAF_TAIL_P(tp->t_mountp, leaf); |
1212 | firstb = XFS_DIR2_LEAF_BESTS_P(ltp) + first; | 1213 | firstb = XFS_DIR2_LEAF_BESTS_P(ltp) + first; |
1213 | lastb = XFS_DIR2_LEAF_BESTS_P(ltp) + last; | 1214 | lastb = XFS_DIR2_LEAF_BESTS_P(ltp) + last; |
@@ -1230,8 +1231,8 @@ xfs_dir2_leaf_log_ents( | |||
1230 | xfs_dir2_leaf_t *leaf; /* leaf structure */ | 1231 | xfs_dir2_leaf_t *leaf; /* leaf structure */ |
1231 | 1232 | ||
1232 | leaf = bp->data; | 1233 | leaf = bp->data; |
1233 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC || | 1234 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC || |
1234 | INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 1235 | be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
1235 | firstlep = &leaf->ents[first]; | 1236 | firstlep = &leaf->ents[first]; |
1236 | lastlep = &leaf->ents[last]; | 1237 | lastlep = &leaf->ents[last]; |
1237 | xfs_da_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf), | 1238 | xfs_da_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf), |
@@ -1249,8 +1250,8 @@ xfs_dir2_leaf_log_header( | |||
1249 | xfs_dir2_leaf_t *leaf; /* leaf structure */ | 1250 | xfs_dir2_leaf_t *leaf; /* leaf structure */ |
1250 | 1251 | ||
1251 | leaf = bp->data; | 1252 | leaf = bp->data; |
1252 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC || | 1253 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC || |
1253 | INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 1254 | be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
1254 | xfs_da_log_buf(tp, bp, (uint)((char *)&leaf->hdr - (char *)leaf), | 1255 | xfs_da_log_buf(tp, bp, (uint)((char *)&leaf->hdr - (char *)leaf), |
1255 | (uint)(sizeof(leaf->hdr) - 1)); | 1256 | (uint)(sizeof(leaf->hdr) - 1)); |
1256 | } | 1257 | } |
@@ -1269,7 +1270,7 @@ xfs_dir2_leaf_log_tail( | |||
1269 | 1270 | ||
1270 | mp = tp->t_mountp; | 1271 | mp = tp->t_mountp; |
1271 | leaf = bp->data; | 1272 | leaf = bp->data; |
1272 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC); | 1273 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC); |
1273 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); | 1274 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); |
1274 | xfs_da_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf), | 1275 | xfs_da_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf), |
1275 | (uint)(mp->m_dirblksize - 1)); | 1276 | (uint)(mp->m_dirblksize - 1)); |
@@ -1314,7 +1315,7 @@ xfs_dir2_leaf_lookup( | |||
1314 | */ | 1315 | */ |
1315 | dep = (xfs_dir2_data_entry_t *) | 1316 | dep = (xfs_dir2_data_entry_t *) |
1316 | ((char *)dbp->data + | 1317 | ((char *)dbp->data + |
1317 | XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, INT_GET(lep->address, ARCH_CONVERT))); | 1318 | XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, be32_to_cpu(lep->address))); |
1318 | /* | 1319 | /* |
1319 | * Return the found inode number. | 1320 | * Return the found inode number. |
1320 | */ | 1321 | */ |
@@ -1373,17 +1374,17 @@ xfs_dir2_leaf_lookup_int( | |||
1373 | * looking to match the name. | 1374 | * looking to match the name. |
1374 | */ | 1375 | */ |
1375 | for (lep = &leaf->ents[index], dbp = NULL, curdb = -1; | 1376 | for (lep = &leaf->ents[index], dbp = NULL, curdb = -1; |
1376 | index < INT_GET(leaf->hdr.count, ARCH_CONVERT) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval; | 1377 | index < be16_to_cpu(leaf->hdr.count) && be32_to_cpu(lep->hashval) == args->hashval; |
1377 | lep++, index++) { | 1378 | lep++, index++) { |
1378 | /* | 1379 | /* |
1379 | * Skip over stale leaf entries. | 1380 | * Skip over stale leaf entries. |
1380 | */ | 1381 | */ |
1381 | if (INT_GET(lep->address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 1382 | if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR) |
1382 | continue; | 1383 | continue; |
1383 | /* | 1384 | /* |
1384 | * Get the new data block number. | 1385 | * Get the new data block number. |
1385 | */ | 1386 | */ |
1386 | newdb = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT)); | 1387 | newdb = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address)); |
1387 | /* | 1388 | /* |
1388 | * If it's not the same as the old data block number, | 1389 | * If it's not the same as the old data block number, |
1389 | * need to pitch the old one and read the new one. | 1390 | * need to pitch the old one and read the new one. |
@@ -1406,7 +1407,7 @@ xfs_dir2_leaf_lookup_int( | |||
1406 | */ | 1407 | */ |
1407 | dep = (xfs_dir2_data_entry_t *) | 1408 | dep = (xfs_dir2_data_entry_t *) |
1408 | ((char *)dbp->data + | 1409 | ((char *)dbp->data + |
1409 | XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT))); | 1410 | XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address))); |
1410 | /* | 1411 | /* |
1411 | * If it matches then return it. | 1412 | * If it matches then return it. |
1412 | */ | 1413 | */ |
@@ -1435,7 +1436,7 @@ int /* error */ | |||
1435 | xfs_dir2_leaf_removename( | 1436 | xfs_dir2_leaf_removename( |
1436 | xfs_da_args_t *args) /* operation arguments */ | 1437 | xfs_da_args_t *args) /* operation arguments */ |
1437 | { | 1438 | { |
1438 | xfs_dir2_data_off_t *bestsp; /* leaf block best freespace */ | 1439 | __be16 *bestsp; /* leaf block best freespace */ |
1439 | xfs_dir2_data_t *data; /* data block structure */ | 1440 | xfs_dir2_data_t *data; /* data block structure */ |
1440 | xfs_dir2_db_t db; /* data block number */ | 1441 | xfs_dir2_db_t db; /* data block number */ |
1441 | xfs_dabuf_t *dbp; /* data block buffer */ | 1442 | xfs_dabuf_t *dbp; /* data block buffer */ |
@@ -1471,14 +1472,14 @@ xfs_dir2_leaf_removename( | |||
1471 | * Point to the leaf entry, use that to point to the data entry. | 1472 | * Point to the leaf entry, use that to point to the data entry. |
1472 | */ | 1473 | */ |
1473 | lep = &leaf->ents[index]; | 1474 | lep = &leaf->ents[index]; |
1474 | db = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT)); | 1475 | db = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address)); |
1475 | dep = (xfs_dir2_data_entry_t *) | 1476 | dep = (xfs_dir2_data_entry_t *) |
1476 | ((char *)data + XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT))); | 1477 | ((char *)data + XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address))); |
1477 | needscan = needlog = 0; | 1478 | needscan = needlog = 0; |
1478 | oldbest = INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT); | 1479 | oldbest = be16_to_cpu(data->hdr.bestfree[0].length); |
1479 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); | 1480 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); |
1480 | bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); | 1481 | bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); |
1481 | ASSERT(INT_GET(bestsp[db], ARCH_CONVERT) == oldbest); | 1482 | ASSERT(be16_to_cpu(bestsp[db]) == oldbest); |
1482 | /* | 1483 | /* |
1483 | * Mark the former data entry unused. | 1484 | * Mark the former data entry unused. |
1484 | */ | 1485 | */ |
@@ -1488,9 +1489,9 @@ xfs_dir2_leaf_removename( | |||
1488 | /* | 1489 | /* |
1489 | * We just mark the leaf entry stale by putting a null in it. | 1490 | * We just mark the leaf entry stale by putting a null in it. |
1490 | */ | 1491 | */ |
1491 | INT_MOD(leaf->hdr.stale, ARCH_CONVERT, +1); | 1492 | be16_add(&leaf->hdr.stale, 1); |
1492 | xfs_dir2_leaf_log_header(tp, lbp); | 1493 | xfs_dir2_leaf_log_header(tp, lbp); |
1493 | INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR); | 1494 | lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR); |
1494 | xfs_dir2_leaf_log_ents(tp, lbp, index, index); | 1495 | xfs_dir2_leaf_log_ents(tp, lbp, index, index); |
1495 | /* | 1496 | /* |
1496 | * Scan the freespace in the data block again if necessary, | 1497 | * Scan the freespace in the data block again if necessary, |
@@ -1504,15 +1505,15 @@ xfs_dir2_leaf_removename( | |||
1504 | * If the longest freespace in the data block has changed, | 1505 | * If the longest freespace in the data block has changed, |
1505 | * put the new value in the bests table and log that. | 1506 | * put the new value in the bests table and log that. |
1506 | */ | 1507 | */ |
1507 | if (INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) != oldbest) { | 1508 | if (be16_to_cpu(data->hdr.bestfree[0].length) != oldbest) { |
1508 | INT_COPY(bestsp[db], data->hdr.bestfree[0].length, ARCH_CONVERT); | 1509 | bestsp[db] = data->hdr.bestfree[0].length; |
1509 | xfs_dir2_leaf_log_bests(tp, lbp, db, db); | 1510 | xfs_dir2_leaf_log_bests(tp, lbp, db, db); |
1510 | } | 1511 | } |
1511 | xfs_dir2_data_check(dp, dbp); | 1512 | xfs_dir2_data_check(dp, dbp); |
1512 | /* | 1513 | /* |
1513 | * If the data block is now empty then get rid of the data block. | 1514 | * If the data block is now empty then get rid of the data block. |
1514 | */ | 1515 | */ |
1515 | if (INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) == | 1516 | if (be16_to_cpu(data->hdr.bestfree[0].length) == |
1516 | mp->m_dirblksize - (uint)sizeof(data->hdr)) { | 1517 | mp->m_dirblksize - (uint)sizeof(data->hdr)) { |
1517 | ASSERT(db != mp->m_dirdatablk); | 1518 | ASSERT(db != mp->m_dirdatablk); |
1518 | if ((error = xfs_dir2_shrink_inode(args, db, dbp))) { | 1519 | if ((error = xfs_dir2_shrink_inode(args, db, dbp))) { |
@@ -1535,12 +1536,12 @@ xfs_dir2_leaf_removename( | |||
1535 | * If this is the last data block then compact the | 1536 | * If this is the last data block then compact the |
1536 | * bests table by getting rid of entries. | 1537 | * bests table by getting rid of entries. |
1537 | */ | 1538 | */ |
1538 | if (db == INT_GET(ltp->bestcount, ARCH_CONVERT) - 1) { | 1539 | if (db == be32_to_cpu(ltp->bestcount) - 1) { |
1539 | /* | 1540 | /* |
1540 | * Look for the last active entry (i). | 1541 | * Look for the last active entry (i). |
1541 | */ | 1542 | */ |
1542 | for (i = db - 1; i > 0; i--) { | 1543 | for (i = db - 1; i > 0; i--) { |
1543 | if (INT_GET(bestsp[i], ARCH_CONVERT) != NULLDATAOFF) | 1544 | if (be16_to_cpu(bestsp[i]) != NULLDATAOFF) |
1544 | break; | 1545 | break; |
1545 | } | 1546 | } |
1546 | /* | 1547 | /* |
@@ -1548,12 +1549,12 @@ xfs_dir2_leaf_removename( | |||
1548 | * end are removed. | 1549 | * end are removed. |
1549 | */ | 1550 | */ |
1550 | memmove(&bestsp[db - i], bestsp, | 1551 | memmove(&bestsp[db - i], bestsp, |
1551 | (INT_GET(ltp->bestcount, ARCH_CONVERT) - (db - i)) * sizeof(*bestsp)); | 1552 | (be32_to_cpu(ltp->bestcount) - (db - i)) * sizeof(*bestsp)); |
1552 | INT_MOD(ltp->bestcount, ARCH_CONVERT, -(db - i)); | 1553 | be32_add(<p->bestcount, -(db - i)); |
1553 | xfs_dir2_leaf_log_tail(tp, lbp); | 1554 | xfs_dir2_leaf_log_tail(tp, lbp); |
1554 | xfs_dir2_leaf_log_bests(tp, lbp, 0, INT_GET(ltp->bestcount, ARCH_CONVERT) - 1); | 1555 | xfs_dir2_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1); |
1555 | } else | 1556 | } else |
1556 | INT_SET(bestsp[db], ARCH_CONVERT, NULLDATAOFF); | 1557 | bestsp[db] = cpu_to_be16(NULLDATAOFF); |
1557 | } | 1558 | } |
1558 | /* | 1559 | /* |
1559 | * If the data block was not the first one, drop it. | 1560 | * If the data block was not the first one, drop it. |
@@ -1604,7 +1605,7 @@ xfs_dir2_leaf_replace( | |||
1604 | */ | 1605 | */ |
1605 | dep = (xfs_dir2_data_entry_t *) | 1606 | dep = (xfs_dir2_data_entry_t *) |
1606 | ((char *)dbp->data + | 1607 | ((char *)dbp->data + |
1607 | XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, INT_GET(lep->address, ARCH_CONVERT))); | 1608 | XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, be32_to_cpu(lep->address))); |
1608 | ASSERT(args->inumber != INT_GET(dep->inumber, ARCH_CONVERT)); | 1609 | ASSERT(args->inumber != INT_GET(dep->inumber, ARCH_CONVERT)); |
1609 | /* | 1610 | /* |
1610 | * Put the new inode number in, log it. | 1611 | * Put the new inode number in, log it. |
@@ -1645,11 +1646,11 @@ xfs_dir2_leaf_search_hash( | |||
1645 | * Note, the table cannot be empty, so we have to go through the loop. | 1646 | * Note, the table cannot be empty, so we have to go through the loop. |
1646 | * Binary search the leaf entries looking for our hash value. | 1647 | * Binary search the leaf entries looking for our hash value. |
1647 | */ | 1648 | */ |
1648 | for (lep = leaf->ents, low = 0, high = INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1, | 1649 | for (lep = leaf->ents, low = 0, high = be16_to_cpu(leaf->hdr.count) - 1, |
1649 | hashwant = args->hashval; | 1650 | hashwant = args->hashval; |
1650 | low <= high; ) { | 1651 | low <= high; ) { |
1651 | mid = (low + high) >> 1; | 1652 | mid = (low + high) >> 1; |
1652 | if ((hash = INT_GET(lep[mid].hashval, ARCH_CONVERT)) == hashwant) | 1653 | if ((hash = be32_to_cpu(lep[mid].hashval)) == hashwant) |
1653 | break; | 1654 | break; |
1654 | if (hash < hashwant) | 1655 | if (hash < hashwant) |
1655 | low = mid + 1; | 1656 | low = mid + 1; |
@@ -1660,7 +1661,7 @@ xfs_dir2_leaf_search_hash( | |||
1660 | * Found one, back up through all the equal hash values. | 1661 | * Found one, back up through all the equal hash values. |
1661 | */ | 1662 | */ |
1662 | if (hash == hashwant) { | 1663 | if (hash == hashwant) { |
1663 | while (mid > 0 && INT_GET(lep[mid - 1].hashval, ARCH_CONVERT) == hashwant) { | 1664 | while (mid > 0 && be32_to_cpu(lep[mid - 1].hashval) == hashwant) { |
1664 | mid--; | 1665 | mid--; |
1665 | } | 1666 | } |
1666 | } | 1667 | } |
@@ -1682,7 +1683,7 @@ xfs_dir2_leaf_trim_data( | |||
1682 | xfs_dabuf_t *lbp, /* leaf buffer */ | 1683 | xfs_dabuf_t *lbp, /* leaf buffer */ |
1683 | xfs_dir2_db_t db) /* data block number */ | 1684 | xfs_dir2_db_t db) /* data block number */ |
1684 | { | 1685 | { |
1685 | xfs_dir2_data_off_t *bestsp; /* leaf bests table */ | 1686 | __be16 *bestsp; /* leaf bests table */ |
1686 | #ifdef DEBUG | 1687 | #ifdef DEBUG |
1687 | xfs_dir2_data_t *data; /* data block structure */ | 1688 | xfs_dir2_data_t *data; /* data block structure */ |
1688 | #endif | 1689 | #endif |
@@ -1706,7 +1707,7 @@ xfs_dir2_leaf_trim_data( | |||
1706 | } | 1707 | } |
1707 | #ifdef DEBUG | 1708 | #ifdef DEBUG |
1708 | data = dbp->data; | 1709 | data = dbp->data; |
1709 | ASSERT(INT_GET(data->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC); | 1710 | ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC); |
1710 | #endif | 1711 | #endif |
1711 | /* this seems to be an error | 1712 | /* this seems to be an error |
1712 | * data is only valid if DEBUG is defined? | 1713 | * data is only valid if DEBUG is defined? |
@@ -1715,9 +1716,9 @@ xfs_dir2_leaf_trim_data( | |||
1715 | 1716 | ||
1716 | leaf = lbp->data; | 1717 | leaf = lbp->data; |
1717 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); | 1718 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); |
1718 | ASSERT(INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) == | 1719 | ASSERT(be16_to_cpu(data->hdr.bestfree[0].length) == |
1719 | mp->m_dirblksize - (uint)sizeof(data->hdr)); | 1720 | mp->m_dirblksize - (uint)sizeof(data->hdr)); |
1720 | ASSERT(db == INT_GET(ltp->bestcount, ARCH_CONVERT) - 1); | 1721 | ASSERT(db == be32_to_cpu(ltp->bestcount) - 1); |
1721 | /* | 1722 | /* |
1722 | * Get rid of the data block. | 1723 | * Get rid of the data block. |
1723 | */ | 1724 | */ |
@@ -1730,10 +1731,10 @@ xfs_dir2_leaf_trim_data( | |||
1730 | * Eliminate the last bests entry from the table. | 1731 | * Eliminate the last bests entry from the table. |
1731 | */ | 1732 | */ |
1732 | bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); | 1733 | bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); |
1733 | INT_MOD(ltp->bestcount, ARCH_CONVERT, -1); | 1734 | be32_add(<p->bestcount, -1); |
1734 | memmove(&bestsp[1], &bestsp[0], INT_GET(ltp->bestcount, ARCH_CONVERT) * sizeof(*bestsp)); | 1735 | memmove(&bestsp[1], &bestsp[0], be32_to_cpu(ltp->bestcount) * sizeof(*bestsp)); |
1735 | xfs_dir2_leaf_log_tail(tp, lbp); | 1736 | xfs_dir2_leaf_log_tail(tp, lbp); |
1736 | xfs_dir2_leaf_log_bests(tp, lbp, 0, INT_GET(ltp->bestcount, ARCH_CONVERT) - 1); | 1737 | xfs_dir2_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1); |
1737 | return 0; | 1738 | return 0; |
1738 | } | 1739 | } |
1739 | 1740 | ||
@@ -1805,7 +1806,7 @@ xfs_dir2_node_to_leaf( | |||
1805 | return 0; | 1806 | return 0; |
1806 | lbp = state->path.blk[0].bp; | 1807 | lbp = state->path.blk[0].bp; |
1807 | leaf = lbp->data; | 1808 | leaf = lbp->data; |
1808 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 1809 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
1809 | /* | 1810 | /* |
1810 | * Read the freespace block. | 1811 | * Read the freespace block. |
1811 | */ | 1812 | */ |
@@ -1814,15 +1815,15 @@ xfs_dir2_node_to_leaf( | |||
1814 | return error; | 1815 | return error; |
1815 | } | 1816 | } |
1816 | free = fbp->data; | 1817 | free = fbp->data; |
1817 | ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC); | 1818 | ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); |
1818 | ASSERT(!free->hdr.firstdb); | 1819 | ASSERT(!free->hdr.firstdb); |
1819 | /* | 1820 | /* |
1820 | * Now see if the leafn and free data will fit in a leaf1. | 1821 | * Now see if the leafn and free data will fit in a leaf1. |
1821 | * If not, release the buffer and give up. | 1822 | * If not, release the buffer and give up. |
1822 | */ | 1823 | */ |
1823 | if ((uint)sizeof(leaf->hdr) + | 1824 | if ((uint)sizeof(leaf->hdr) + |
1824 | (INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT)) * (uint)sizeof(leaf->ents[0]) + | 1825 | (be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale)) * (uint)sizeof(leaf->ents[0]) + |
1825 | INT_GET(free->hdr.nvalid, ARCH_CONVERT) * (uint)sizeof(leaf->bests[0]) + | 1826 | be32_to_cpu(free->hdr.nvalid) * (uint)sizeof(leaf->bests[0]) + |
1826 | (uint)sizeof(leaf->tail) > | 1827 | (uint)sizeof(leaf->tail) > |
1827 | mp->m_dirblksize) { | 1828 | mp->m_dirblksize) { |
1828 | xfs_da_brelse(tp, fbp); | 1829 | xfs_da_brelse(tp, fbp); |
@@ -1832,22 +1833,22 @@ xfs_dir2_node_to_leaf( | |||
1832 | * If the leaf has any stale entries in it, compress them out. | 1833 | * If the leaf has any stale entries in it, compress them out. |
1833 | * The compact routine will log the header. | 1834 | * The compact routine will log the header. |
1834 | */ | 1835 | */ |
1835 | if (INT_GET(leaf->hdr.stale, ARCH_CONVERT)) | 1836 | if (be16_to_cpu(leaf->hdr.stale)) |
1836 | xfs_dir2_leaf_compact(args, lbp); | 1837 | xfs_dir2_leaf_compact(args, lbp); |
1837 | else | 1838 | else |
1838 | xfs_dir2_leaf_log_header(tp, lbp); | 1839 | xfs_dir2_leaf_log_header(tp, lbp); |
1839 | INT_SET(leaf->hdr.info.magic, ARCH_CONVERT, XFS_DIR2_LEAF1_MAGIC); | 1840 | leaf->hdr.info.magic = cpu_to_be16(XFS_DIR2_LEAF1_MAGIC); |
1840 | /* | 1841 | /* |
1841 | * Set up the leaf tail from the freespace block. | 1842 | * Set up the leaf tail from the freespace block. |
1842 | */ | 1843 | */ |
1843 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); | 1844 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); |
1844 | INT_COPY(ltp->bestcount, free->hdr.nvalid, ARCH_CONVERT); | 1845 | ltp->bestcount = free->hdr.nvalid; |
1845 | /* | 1846 | /* |
1846 | * Set up the leaf bests table. | 1847 | * Set up the leaf bests table. |
1847 | */ | 1848 | */ |
1848 | memcpy(XFS_DIR2_LEAF_BESTS_P(ltp), free->bests, | 1849 | memcpy(XFS_DIR2_LEAF_BESTS_P(ltp), free->bests, |
1849 | INT_GET(ltp->bestcount, ARCH_CONVERT) * sizeof(leaf->bests[0])); | 1850 | be32_to_cpu(ltp->bestcount) * sizeof(leaf->bests[0])); |
1850 | xfs_dir2_leaf_log_bests(tp, lbp, 0, INT_GET(ltp->bestcount, ARCH_CONVERT) - 1); | 1851 | xfs_dir2_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1); |
1851 | xfs_dir2_leaf_log_tail(tp, lbp); | 1852 | xfs_dir2_leaf_log_tail(tp, lbp); |
1852 | xfs_dir2_leaf_check(dp, lbp); | 1853 | xfs_dir2_leaf_check(dp, lbp); |
1853 | /* | 1854 | /* |