diff options
Diffstat (limited to 'fs/xfs/xfs_attr_leaf.c')
-rw-r--r-- | fs/xfs/xfs_attr_leaf.c | 729 |
1 files changed, 315 insertions, 414 deletions
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c index fe91eac4e2a7..717682747bd2 100644 --- a/fs/xfs/xfs_attr_leaf.c +++ b/fs/xfs/xfs_attr_leaf.c | |||
@@ -194,7 +194,7 @@ xfs_attr_shortform_create(xfs_da_args_t *args) | |||
194 | xfs_idata_realloc(dp, sizeof(*hdr), XFS_ATTR_FORK); | 194 | xfs_idata_realloc(dp, sizeof(*hdr), XFS_ATTR_FORK); |
195 | hdr = (xfs_attr_sf_hdr_t *)ifp->if_u1.if_data; | 195 | hdr = (xfs_attr_sf_hdr_t *)ifp->if_u1.if_data; |
196 | hdr->count = 0; | 196 | hdr->count = 0; |
197 | INT_SET(hdr->totsize, ARCH_CONVERT, sizeof(*hdr)); | 197 | hdr->totsize = cpu_to_be16(sizeof(*hdr)); |
198 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); | 198 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); |
199 | } | 199 | } |
200 | 200 | ||
@@ -224,8 +224,7 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) | |||
224 | ASSERT(ifp->if_flags & XFS_IFINLINE); | 224 | ASSERT(ifp->if_flags & XFS_IFINLINE); |
225 | sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; | 225 | sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; |
226 | sfe = &sf->list[0]; | 226 | sfe = &sf->list[0]; |
227 | for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); | 227 | for (i = 0; i < sf->hdr.count; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { |
228 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { | ||
229 | #ifdef DEBUG | 228 | #ifdef DEBUG |
230 | if (sfe->namelen != args->namelen) | 229 | if (sfe->namelen != args->namelen) |
231 | continue; | 230 | continue; |
@@ -248,13 +247,13 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) | |||
248 | sfe = (xfs_attr_sf_entry_t *)((char *)sf + offset); | 247 | sfe = (xfs_attr_sf_entry_t *)((char *)sf + offset); |
249 | 248 | ||
250 | sfe->namelen = args->namelen; | 249 | sfe->namelen = args->namelen; |
251 | INT_SET(sfe->valuelen, ARCH_CONVERT, args->valuelen); | 250 | sfe->valuelen = args->valuelen; |
252 | sfe->flags = (args->flags & ATTR_SECURE) ? XFS_ATTR_SECURE : | 251 | sfe->flags = (args->flags & ATTR_SECURE) ? XFS_ATTR_SECURE : |
253 | ((args->flags & ATTR_ROOT) ? XFS_ATTR_ROOT : 0); | 252 | ((args->flags & ATTR_ROOT) ? XFS_ATTR_ROOT : 0); |
254 | memcpy(sfe->nameval, args->name, args->namelen); | 253 | memcpy(sfe->nameval, args->name, args->namelen); |
255 | memcpy(&sfe->nameval[args->namelen], args->value, args->valuelen); | 254 | memcpy(&sfe->nameval[args->namelen], args->value, args->valuelen); |
256 | INT_MOD(sf->hdr.count, ARCH_CONVERT, 1); | 255 | sf->hdr.count++; |
257 | INT_MOD(sf->hdr.totsize, ARCH_CONVERT, size); | 256 | be16_add(&sf->hdr.totsize, size); |
258 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); | 257 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); |
259 | 258 | ||
260 | xfs_sbversion_add_attr2(mp, args->trans); | 259 | xfs_sbversion_add_attr2(mp, args->trans); |
@@ -277,7 +276,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args) | |||
277 | base = sizeof(xfs_attr_sf_hdr_t); | 276 | base = sizeof(xfs_attr_sf_hdr_t); |
278 | sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data; | 277 | sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data; |
279 | sfe = &sf->list[0]; | 278 | sfe = &sf->list[0]; |
280 | end = INT_GET(sf->hdr.count, ARCH_CONVERT); | 279 | end = sf->hdr.count; |
281 | for (i = 0; i < end; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), | 280 | for (i = 0; i < end; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), |
282 | base += size, i++) { | 281 | base += size, i++) { |
283 | size = XFS_ATTR_SF_ENTSIZE(sfe); | 282 | size = XFS_ATTR_SF_ENTSIZE(sfe); |
@@ -300,11 +299,11 @@ xfs_attr_shortform_remove(xfs_da_args_t *args) | |||
300 | * Fix up the attribute fork data, covering the hole | 299 | * Fix up the attribute fork data, covering the hole |
301 | */ | 300 | */ |
302 | end = base + size; | 301 | end = base + size; |
303 | totsize = INT_GET(sf->hdr.totsize, ARCH_CONVERT); | 302 | totsize = be16_to_cpu(sf->hdr.totsize); |
304 | if (end != totsize) | 303 | if (end != totsize) |
305 | memmove(&((char *)sf)[base], &((char *)sf)[end], totsize - end); | 304 | memmove(&((char *)sf)[base], &((char *)sf)[end], totsize - end); |
306 | INT_MOD(sf->hdr.count, ARCH_CONVERT, -1); | 305 | sf->hdr.count--; |
307 | INT_MOD(sf->hdr.totsize, ARCH_CONVERT, -size); | 306 | be16_add(&sf->hdr.totsize, -size); |
308 | 307 | ||
309 | /* | 308 | /* |
310 | * Fix up the start offset of the attribute fork | 309 | * Fix up the start offset of the attribute fork |
@@ -360,7 +359,7 @@ xfs_attr_shortform_lookup(xfs_da_args_t *args) | |||
360 | ASSERT(ifp->if_flags & XFS_IFINLINE); | 359 | ASSERT(ifp->if_flags & XFS_IFINLINE); |
361 | sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; | 360 | sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; |
362 | sfe = &sf->list[0]; | 361 | sfe = &sf->list[0]; |
363 | for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); | 362 | for (i = 0; i < sf->hdr.count; |
364 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { | 363 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { |
365 | if (sfe->namelen != args->namelen) | 364 | if (sfe->namelen != args->namelen) |
366 | continue; | 365 | continue; |
@@ -391,7 +390,7 @@ xfs_attr_shortform_getvalue(xfs_da_args_t *args) | |||
391 | ASSERT(args->dp->i_d.di_aformat == XFS_IFINLINE); | 390 | ASSERT(args->dp->i_d.di_aformat == XFS_IFINLINE); |
392 | sf = (xfs_attr_shortform_t *)args->dp->i_afp->if_u1.if_data; | 391 | sf = (xfs_attr_shortform_t *)args->dp->i_afp->if_u1.if_data; |
393 | sfe = &sf->list[0]; | 392 | sfe = &sf->list[0]; |
394 | for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); | 393 | for (i = 0; i < sf->hdr.count; |
395 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { | 394 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { |
396 | if (sfe->namelen != args->namelen) | 395 | if (sfe->namelen != args->namelen) |
397 | continue; | 396 | continue; |
@@ -404,14 +403,14 @@ xfs_attr_shortform_getvalue(xfs_da_args_t *args) | |||
404 | ((sfe->flags & XFS_ATTR_ROOT) != 0)) | 403 | ((sfe->flags & XFS_ATTR_ROOT) != 0)) |
405 | continue; | 404 | continue; |
406 | if (args->flags & ATTR_KERNOVAL) { | 405 | if (args->flags & ATTR_KERNOVAL) { |
407 | args->valuelen = INT_GET(sfe->valuelen, ARCH_CONVERT); | 406 | args->valuelen = sfe->valuelen; |
408 | return(XFS_ERROR(EEXIST)); | 407 | return(XFS_ERROR(EEXIST)); |
409 | } | 408 | } |
410 | if (args->valuelen < INT_GET(sfe->valuelen, ARCH_CONVERT)) { | 409 | if (args->valuelen < sfe->valuelen) { |
411 | args->valuelen = INT_GET(sfe->valuelen, ARCH_CONVERT); | 410 | args->valuelen = sfe->valuelen; |
412 | return(XFS_ERROR(ERANGE)); | 411 | return(XFS_ERROR(ERANGE)); |
413 | } | 412 | } |
414 | args->valuelen = INT_GET(sfe->valuelen, ARCH_CONVERT); | 413 | args->valuelen = sfe->valuelen; |
415 | memcpy(args->value, &sfe->nameval[args->namelen], | 414 | memcpy(args->value, &sfe->nameval[args->namelen], |
416 | args->valuelen); | 415 | args->valuelen); |
417 | return(XFS_ERROR(EEXIST)); | 416 | return(XFS_ERROR(EEXIST)); |
@@ -438,7 +437,7 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args) | |||
438 | dp = args->dp; | 437 | dp = args->dp; |
439 | ifp = dp->i_afp; | 438 | ifp = dp->i_afp; |
440 | sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; | 439 | sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; |
441 | size = INT_GET(sf->hdr.totsize, ARCH_CONVERT); | 440 | size = be16_to_cpu(sf->hdr.totsize); |
442 | tmpbuffer = kmem_alloc(size, KM_SLEEP); | 441 | tmpbuffer = kmem_alloc(size, KM_SLEEP); |
443 | ASSERT(tmpbuffer != NULL); | 442 | ASSERT(tmpbuffer != NULL); |
444 | memcpy(tmpbuffer, ifp->if_u1.if_data, size); | 443 | memcpy(tmpbuffer, ifp->if_u1.if_data, size); |
@@ -481,11 +480,11 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args) | |||
481 | nargs.oknoent = 1; | 480 | nargs.oknoent = 1; |
482 | 481 | ||
483 | sfe = &sf->list[0]; | 482 | sfe = &sf->list[0]; |
484 | for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) { | 483 | for (i = 0; i < sf->hdr.count; i++) { |
485 | nargs.name = (char *)sfe->nameval; | 484 | nargs.name = (char *)sfe->nameval; |
486 | nargs.namelen = sfe->namelen; | 485 | nargs.namelen = sfe->namelen; |
487 | nargs.value = (char *)&sfe->nameval[nargs.namelen]; | 486 | nargs.value = (char *)&sfe->nameval[nargs.namelen]; |
488 | nargs.valuelen = INT_GET(sfe->valuelen, ARCH_CONVERT); | 487 | nargs.valuelen = sfe->valuelen; |
489 | nargs.hashval = xfs_da_hashname((char *)sfe->nameval, | 488 | nargs.hashval = xfs_da_hashname((char *)sfe->nameval, |
490 | sfe->namelen); | 489 | sfe->namelen); |
491 | nargs.flags = (sfe->flags & XFS_ATTR_SECURE) ? ATTR_SECURE : | 490 | nargs.flags = (sfe->flags & XFS_ATTR_SECURE) ? ATTR_SECURE : |
@@ -514,11 +513,9 @@ xfs_attr_shortform_compare(const void *a, const void *b) | |||
514 | 513 | ||
515 | sa = (xfs_attr_sf_sort_t *)a; | 514 | sa = (xfs_attr_sf_sort_t *)a; |
516 | sb = (xfs_attr_sf_sort_t *)b; | 515 | sb = (xfs_attr_sf_sort_t *)b; |
517 | if (INT_GET(sa->hash, ARCH_CONVERT) | 516 | if (sa->hash < sb->hash) { |
518 | < INT_GET(sb->hash, ARCH_CONVERT)) { | ||
519 | return(-1); | 517 | return(-1); |
520 | } else if (INT_GET(sa->hash, ARCH_CONVERT) | 518 | } else if (sa->hash > sb->hash) { |
521 | > INT_GET(sb->hash, ARCH_CONVERT)) { | ||
522 | return(1); | 519 | return(1); |
523 | } else { | 520 | } else { |
524 | return(sa->entno - sb->entno); | 521 | return(sa->entno - sb->entno); |
@@ -560,10 +557,8 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
560 | * If the buffer is large enough, do not bother with sorting. | 557 | * If the buffer is large enough, do not bother with sorting. |
561 | * Note the generous fudge factor of 16 overhead bytes per entry. | 558 | * Note the generous fudge factor of 16 overhead bytes per entry. |
562 | */ | 559 | */ |
563 | if ((dp->i_afp->if_bytes + INT_GET(sf->hdr.count, ARCH_CONVERT) * 16) | 560 | if ((dp->i_afp->if_bytes + sf->hdr.count * 16) < context->bufsize) { |
564 | < context->bufsize) { | 561 | for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) { |
565 | for (i = 0, sfe = &sf->list[0]; | ||
566 | i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) { | ||
567 | attrnames_t *namesp; | 562 | attrnames_t *namesp; |
568 | 563 | ||
569 | if (((context->flags & ATTR_SECURE) != 0) != | 564 | if (((context->flags & ATTR_SECURE) != 0) != |
@@ -584,14 +579,13 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
584 | if (context->flags & ATTR_KERNOVAL) { | 579 | if (context->flags & ATTR_KERNOVAL) { |
585 | ASSERT(context->flags & ATTR_KERNAMELS); | 580 | ASSERT(context->flags & ATTR_KERNAMELS); |
586 | context->count += namesp->attr_namelen + | 581 | context->count += namesp->attr_namelen + |
587 | INT_GET(sfe->namelen, ARCH_CONVERT) + 1; | 582 | sfe->namelen + 1; |
588 | } | 583 | } |
589 | else { | 584 | else { |
590 | if (xfs_attr_put_listent(context, namesp, | 585 | if (xfs_attr_put_listent(context, namesp, |
591 | (char *)sfe->nameval, | 586 | (char *)sfe->nameval, |
592 | (int)sfe->namelen, | 587 | (int)sfe->namelen, |
593 | (int)INT_GET(sfe->valuelen, | 588 | (int)sfe->valuelen)) |
594 | ARCH_CONVERT))) | ||
595 | break; | 589 | break; |
596 | } | 590 | } |
597 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe); | 591 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe); |
@@ -603,7 +597,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
603 | /* | 597 | /* |
604 | * It didn't all fit, so we have to sort everything on hashval. | 598 | * It didn't all fit, so we have to sort everything on hashval. |
605 | */ | 599 | */ |
606 | sbsize = INT_GET(sf->hdr.count, ARCH_CONVERT) * sizeof(*sbuf); | 600 | sbsize = sf->hdr.count * sizeof(*sbuf); |
607 | sbp = sbuf = kmem_alloc(sbsize, KM_SLEEP); | 601 | sbp = sbuf = kmem_alloc(sbsize, KM_SLEEP); |
608 | 602 | ||
609 | /* | 603 | /* |
@@ -611,8 +605,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
611 | * the relevant info from only those that match into a buffer. | 605 | * the relevant info from only those that match into a buffer. |
612 | */ | 606 | */ |
613 | nsbuf = 0; | 607 | nsbuf = 0; |
614 | for (i = 0, sfe = &sf->list[0]; | 608 | for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) { |
615 | i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) { | ||
616 | if (unlikely( | 609 | if (unlikely( |
617 | ((char *)sfe < (char *)sf) || | 610 | ((char *)sfe < (char *)sf) || |
618 | ((char *)sfe >= ((char *)sf + dp->i_afp->if_bytes)))) { | 611 | ((char *)sfe >= ((char *)sf + dp->i_afp->if_bytes)))) { |
@@ -636,8 +629,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
636 | continue; | 629 | continue; |
637 | } | 630 | } |
638 | sbp->entno = i; | 631 | sbp->entno = i; |
639 | INT_SET(sbp->hash, ARCH_CONVERT, | 632 | sbp->hash = xfs_da_hashname((char *)sfe->nameval, sfe->namelen); |
640 | xfs_da_hashname((char *)sfe->nameval, sfe->namelen)); | ||
641 | sbp->name = (char *)sfe->nameval; | 633 | sbp->name = (char *)sfe->nameval; |
642 | sbp->namelen = sfe->namelen; | 634 | sbp->namelen = sfe->namelen; |
643 | /* These are bytes, and both on-disk, don't endian-flip */ | 635 | /* These are bytes, and both on-disk, don't endian-flip */ |
@@ -660,12 +652,12 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
660 | cursor->initted = 1; | 652 | cursor->initted = 1; |
661 | cursor->blkno = 0; | 653 | cursor->blkno = 0; |
662 | for (sbp = sbuf, i = 0; i < nsbuf; i++, sbp++) { | 654 | for (sbp = sbuf, i = 0; i < nsbuf; i++, sbp++) { |
663 | if (INT_GET(sbp->hash, ARCH_CONVERT) == cursor->hashval) { | 655 | if (sbp->hash == cursor->hashval) { |
664 | if (cursor->offset == count) { | 656 | if (cursor->offset == count) { |
665 | break; | 657 | break; |
666 | } | 658 | } |
667 | count++; | 659 | count++; |
668 | } else if (INT_GET(sbp->hash, ARCH_CONVERT) > cursor->hashval) { | 660 | } else if (sbp->hash > cursor->hashval) { |
669 | break; | 661 | break; |
670 | } | 662 | } |
671 | } | 663 | } |
@@ -685,8 +677,8 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
685 | ((sbp->flags & XFS_ATTR_ROOT) ? &attr_trusted : | 677 | ((sbp->flags & XFS_ATTR_ROOT) ? &attr_trusted : |
686 | &attr_user); | 678 | &attr_user); |
687 | 679 | ||
688 | if (cursor->hashval != INT_GET(sbp->hash, ARCH_CONVERT)) { | 680 | if (cursor->hashval != sbp->hash) { |
689 | cursor->hashval = INT_GET(sbp->hash, ARCH_CONVERT); | 681 | cursor->hashval = sbp->hash; |
690 | cursor->offset = 0; | 682 | cursor->offset = 0; |
691 | } | 683 | } |
692 | if (context->flags & ATTR_KERNOVAL) { | 684 | if (context->flags & ATTR_KERNOVAL) { |
@@ -696,7 +688,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
696 | } else { | 688 | } else { |
697 | if (xfs_attr_put_listent(context, namesp, | 689 | if (xfs_attr_put_listent(context, namesp, |
698 | sbp->name, sbp->namelen, | 690 | sbp->name, sbp->namelen, |
699 | INT_GET(sbp->valuelen, ARCH_CONVERT))) | 691 | sbp->valuelen)) |
700 | break; | 692 | break; |
701 | } | 693 | } |
702 | cursor->offset++; | 694 | cursor->offset++; |
@@ -720,12 +712,11 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp) | |||
720 | int bytes, i; | 712 | int bytes, i; |
721 | 713 | ||
722 | leaf = bp->data; | 714 | leaf = bp->data; |
723 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 715 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
724 | == XFS_ATTR_LEAF_MAGIC); | ||
725 | 716 | ||
726 | entry = &leaf->entries[0]; | 717 | entry = &leaf->entries[0]; |
727 | bytes = sizeof(struct xfs_attr_sf_hdr); | 718 | bytes = sizeof(struct xfs_attr_sf_hdr); |
728 | for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); entry++, i++) { | 719 | for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) { |
729 | if (entry->flags & XFS_ATTR_INCOMPLETE) | 720 | if (entry->flags & XFS_ATTR_INCOMPLETE) |
730 | continue; /* don't copy partial entries */ | 721 | continue; /* don't copy partial entries */ |
731 | if (!(entry->flags & XFS_ATTR_LOCAL)) | 722 | if (!(entry->flags & XFS_ATTR_LOCAL)) |
@@ -733,11 +724,11 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp) | |||
733 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, i); | 724 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, i); |
734 | if (name_loc->namelen >= XFS_ATTR_SF_ENTSIZE_MAX) | 725 | if (name_loc->namelen >= XFS_ATTR_SF_ENTSIZE_MAX) |
735 | return(0); | 726 | return(0); |
736 | if (INT_GET(name_loc->valuelen, ARCH_CONVERT) >= XFS_ATTR_SF_ENTSIZE_MAX) | 727 | if (be16_to_cpu(name_loc->valuelen) >= XFS_ATTR_SF_ENTSIZE_MAX) |
737 | return(0); | 728 | return(0); |
738 | bytes += sizeof(struct xfs_attr_sf_entry)-1 | 729 | bytes += sizeof(struct xfs_attr_sf_entry)-1 |
739 | + name_loc->namelen | 730 | + name_loc->namelen |
740 | + INT_GET(name_loc->valuelen, ARCH_CONVERT); | 731 | + be16_to_cpu(name_loc->valuelen); |
741 | } | 732 | } |
742 | if ((dp->i_mount->m_flags & XFS_MOUNT_ATTR2) && | 733 | if ((dp->i_mount->m_flags & XFS_MOUNT_ATTR2) && |
743 | (bytes == sizeof(struct xfs_attr_sf_hdr))) | 734 | (bytes == sizeof(struct xfs_attr_sf_hdr))) |
@@ -766,8 +757,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff) | |||
766 | ASSERT(bp != NULL); | 757 | ASSERT(bp != NULL); |
767 | memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount)); | 758 | memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount)); |
768 | leaf = (xfs_attr_leafblock_t *)tmpbuffer; | 759 | leaf = (xfs_attr_leafblock_t *)tmpbuffer; |
769 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 760 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
770 | == XFS_ATTR_LEAF_MAGIC); | ||
771 | memset(bp->data, 0, XFS_LBSIZE(dp->i_mount)); | 761 | memset(bp->data, 0, XFS_LBSIZE(dp->i_mount)); |
772 | 762 | ||
773 | /* | 763 | /* |
@@ -810,7 +800,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff) | |||
810 | nargs.trans = args->trans; | 800 | nargs.trans = args->trans; |
811 | nargs.oknoent = 1; | 801 | nargs.oknoent = 1; |
812 | entry = &leaf->entries[0]; | 802 | entry = &leaf->entries[0]; |
813 | for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); entry++, i++) { | 803 | for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) { |
814 | if (entry->flags & XFS_ATTR_INCOMPLETE) | 804 | if (entry->flags & XFS_ATTR_INCOMPLETE) |
815 | continue; /* don't copy partial entries */ | 805 | continue; /* don't copy partial entries */ |
816 | if (!entry->nameidx) | 806 | if (!entry->nameidx) |
@@ -820,8 +810,8 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff) | |||
820 | nargs.name = (char *)name_loc->nameval; | 810 | nargs.name = (char *)name_loc->nameval; |
821 | nargs.namelen = name_loc->namelen; | 811 | nargs.namelen = name_loc->namelen; |
822 | nargs.value = (char *)&name_loc->nameval[nargs.namelen]; | 812 | nargs.value = (char *)&name_loc->nameval[nargs.namelen]; |
823 | nargs.valuelen = INT_GET(name_loc->valuelen, ARCH_CONVERT); | 813 | nargs.valuelen = be16_to_cpu(name_loc->valuelen); |
824 | nargs.hashval = INT_GET(entry->hashval, ARCH_CONVERT); | 814 | nargs.hashval = be32_to_cpu(entry->hashval); |
825 | nargs.flags = (entry->flags & XFS_ATTR_SECURE) ? ATTR_SECURE : | 815 | nargs.flags = (entry->flags & XFS_ATTR_SECURE) ? ATTR_SECURE : |
826 | ((entry->flags & XFS_ATTR_ROOT) ? ATTR_ROOT : 0); | 816 | ((entry->flags & XFS_ATTR_ROOT) ? ATTR_ROOT : 0); |
827 | xfs_attr_shortform_add(&nargs, forkoff); | 817 | xfs_attr_shortform_add(&nargs, forkoff); |
@@ -875,13 +865,12 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args) | |||
875 | goto out; | 865 | goto out; |
876 | node = bp1->data; | 866 | node = bp1->data; |
877 | leaf = bp2->data; | 867 | leaf = bp2->data; |
878 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 868 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
879 | == XFS_ATTR_LEAF_MAGIC); | ||
880 | /* both on-disk, don't endian-flip twice */ | 869 | /* both on-disk, don't endian-flip twice */ |
881 | node->btree[0].hashval = | 870 | node->btree[0].hashval = |
882 | leaf->entries[INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval; | 871 | leaf->entries[be16_to_cpu(leaf->hdr.count)-1 ].hashval; |
883 | INT_SET(node->btree[0].before, ARCH_CONVERT, blkno); | 872 | node->btree[0].before = cpu_to_be32(blkno); |
884 | INT_SET(node->hdr.count, ARCH_CONVERT, 1); | 873 | node->hdr.count = cpu_to_be16(1); |
885 | xfs_da_log_buf(args->trans, bp1, 0, XFS_LBSIZE(dp->i_mount) - 1); | 874 | xfs_da_log_buf(args->trans, bp1, 0, XFS_LBSIZE(dp->i_mount) - 1); |
886 | error = 0; | 875 | error = 0; |
887 | out: | 876 | out: |
@@ -920,19 +909,16 @@ xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp) | |||
920 | leaf = bp->data; | 909 | leaf = bp->data; |
921 | memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount)); | 910 | memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount)); |
922 | hdr = &leaf->hdr; | 911 | hdr = &leaf->hdr; |
923 | INT_SET(hdr->info.magic, ARCH_CONVERT, XFS_ATTR_LEAF_MAGIC); | 912 | hdr->info.magic = cpu_to_be16(XFS_ATTR_LEAF_MAGIC); |
924 | INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount)); | 913 | hdr->firstused = cpu_to_be16(XFS_LBSIZE(dp->i_mount)); |
925 | if (!hdr->firstused) { | 914 | if (!hdr->firstused) { |
926 | INT_SET(hdr->firstused, ARCH_CONVERT, | 915 | hdr->firstused = cpu_to_be16( |
927 | XFS_LBSIZE(dp->i_mount) - XFS_ATTR_LEAF_NAME_ALIGN); | 916 | XFS_LBSIZE(dp->i_mount) - XFS_ATTR_LEAF_NAME_ALIGN); |
928 | } | 917 | } |
929 | 918 | ||
930 | INT_SET(hdr->freemap[0].base, ARCH_CONVERT, | 919 | hdr->freemap[0].base = cpu_to_be16(sizeof(xfs_attr_leaf_hdr_t)); |
931 | sizeof(xfs_attr_leaf_hdr_t)); | 920 | hdr->freemap[0].size = cpu_to_be16(be16_to_cpu(hdr->firstused) - |
932 | INT_SET(hdr->freemap[0].size, ARCH_CONVERT, | 921 | sizeof(xfs_attr_leaf_hdr_t)); |
933 | INT_GET(hdr->firstused, ARCH_CONVERT) | ||
934 | - INT_GET(hdr->freemap[0].base, | ||
935 | ARCH_CONVERT)); | ||
936 | 922 | ||
937 | xfs_da_log_buf(args->trans, bp, 0, XFS_LBSIZE(dp->i_mount) - 1); | 923 | xfs_da_log_buf(args->trans, bp, 0, XFS_LBSIZE(dp->i_mount) - 1); |
938 | 924 | ||
@@ -1004,10 +990,9 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1004 | int tablesize, entsize, sum, tmp, i; | 990 | int tablesize, entsize, sum, tmp, i; |
1005 | 991 | ||
1006 | leaf = bp->data; | 992 | leaf = bp->data; |
1007 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 993 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1008 | == XFS_ATTR_LEAF_MAGIC); | ||
1009 | ASSERT((args->index >= 0) | 994 | ASSERT((args->index >= 0) |
1010 | && (args->index <= INT_GET(leaf->hdr.count, ARCH_CONVERT))); | 995 | && (args->index <= be16_to_cpu(leaf->hdr.count))); |
1011 | hdr = &leaf->hdr; | 996 | hdr = &leaf->hdr; |
1012 | entsize = xfs_attr_leaf_newentsize(args->namelen, args->valuelen, | 997 | entsize = xfs_attr_leaf_newentsize(args->namelen, args->valuelen, |
1013 | args->trans->t_mountp->m_sb.sb_blocksize, NULL); | 998 | args->trans->t_mountp->m_sb.sb_blocksize, NULL); |
@@ -1016,26 +1001,25 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1016 | * Search through freemap for first-fit on new name length. | 1001 | * Search through freemap for first-fit on new name length. |
1017 | * (may need to figure in size of entry struct too) | 1002 | * (may need to figure in size of entry struct too) |
1018 | */ | 1003 | */ |
1019 | tablesize = (INT_GET(hdr->count, ARCH_CONVERT) + 1) | 1004 | tablesize = (be16_to_cpu(hdr->count) + 1) |
1020 | * sizeof(xfs_attr_leaf_entry_t) | 1005 | * sizeof(xfs_attr_leaf_entry_t) |
1021 | + sizeof(xfs_attr_leaf_hdr_t); | 1006 | + sizeof(xfs_attr_leaf_hdr_t); |
1022 | map = &hdr->freemap[XFS_ATTR_LEAF_MAPSIZE-1]; | 1007 | map = &hdr->freemap[XFS_ATTR_LEAF_MAPSIZE-1]; |
1023 | for (sum = 0, i = XFS_ATTR_LEAF_MAPSIZE-1; i >= 0; map--, i--) { | 1008 | for (sum = 0, i = XFS_ATTR_LEAF_MAPSIZE-1; i >= 0; map--, i--) { |
1024 | if (tablesize > INT_GET(hdr->firstused, ARCH_CONVERT)) { | 1009 | if (tablesize > be16_to_cpu(hdr->firstused)) { |
1025 | sum += INT_GET(map->size, ARCH_CONVERT); | 1010 | sum += be16_to_cpu(map->size); |
1026 | continue; | 1011 | continue; |
1027 | } | 1012 | } |
1028 | if (!map->size) | 1013 | if (!map->size) |
1029 | continue; /* no space in this map */ | 1014 | continue; /* no space in this map */ |
1030 | tmp = entsize; | 1015 | tmp = entsize; |
1031 | if (INT_GET(map->base, ARCH_CONVERT) | 1016 | if (be16_to_cpu(map->base) < be16_to_cpu(hdr->firstused)) |
1032 | < INT_GET(hdr->firstused, ARCH_CONVERT)) | ||
1033 | tmp += sizeof(xfs_attr_leaf_entry_t); | 1017 | tmp += sizeof(xfs_attr_leaf_entry_t); |
1034 | if (INT_GET(map->size, ARCH_CONVERT) >= tmp) { | 1018 | if (be16_to_cpu(map->size) >= tmp) { |
1035 | tmp = xfs_attr_leaf_add_work(bp, args, i); | 1019 | tmp = xfs_attr_leaf_add_work(bp, args, i); |
1036 | return(tmp); | 1020 | return(tmp); |
1037 | } | 1021 | } |
1038 | sum += INT_GET(map->size, ARCH_CONVERT); | 1022 | sum += be16_to_cpu(map->size); |
1039 | } | 1023 | } |
1040 | 1024 | ||
1041 | /* | 1025 | /* |
@@ -1056,7 +1040,7 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1056 | * After compaction, the block is guaranteed to have only one | 1040 | * After compaction, the block is guaranteed to have only one |
1057 | * free region, in freemap[0]. If it is not big enough, give up. | 1041 | * free region, in freemap[0]. If it is not big enough, give up. |
1058 | */ | 1042 | */ |
1059 | if (INT_GET(hdr->freemap[0].size, ARCH_CONVERT) | 1043 | if (be16_to_cpu(hdr->freemap[0].size) |
1060 | < (entsize + sizeof(xfs_attr_leaf_entry_t))) | 1044 | < (entsize + sizeof(xfs_attr_leaf_entry_t))) |
1061 | return(XFS_ERROR(ENOSPC)); | 1045 | return(XFS_ERROR(ENOSPC)); |
1062 | 1046 | ||
@@ -1079,45 +1063,42 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex) | |||
1079 | int tmp, i; | 1063 | int tmp, i; |
1080 | 1064 | ||
1081 | leaf = bp->data; | 1065 | leaf = bp->data; |
1082 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 1066 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1083 | == XFS_ATTR_LEAF_MAGIC); | ||
1084 | hdr = &leaf->hdr; | 1067 | hdr = &leaf->hdr; |
1085 | ASSERT((mapindex >= 0) && (mapindex < XFS_ATTR_LEAF_MAPSIZE)); | 1068 | ASSERT((mapindex >= 0) && (mapindex < XFS_ATTR_LEAF_MAPSIZE)); |
1086 | ASSERT((args->index >= 0) | 1069 | ASSERT((args->index >= 0) && (args->index <= be16_to_cpu(hdr->count))); |
1087 | && (args->index <= INT_GET(hdr->count, ARCH_CONVERT))); | ||
1088 | 1070 | ||
1089 | /* | 1071 | /* |
1090 | * Force open some space in the entry array and fill it in. | 1072 | * Force open some space in the entry array and fill it in. |
1091 | */ | 1073 | */ |
1092 | entry = &leaf->entries[args->index]; | 1074 | entry = &leaf->entries[args->index]; |
1093 | if (args->index < INT_GET(hdr->count, ARCH_CONVERT)) { | 1075 | if (args->index < be16_to_cpu(hdr->count)) { |
1094 | tmp = INT_GET(hdr->count, ARCH_CONVERT) - args->index; | 1076 | tmp = be16_to_cpu(hdr->count) - args->index; |
1095 | tmp *= sizeof(xfs_attr_leaf_entry_t); | 1077 | tmp *= sizeof(xfs_attr_leaf_entry_t); |
1096 | memmove((char *)(entry+1), (char *)entry, tmp); | 1078 | memmove((char *)(entry+1), (char *)entry, tmp); |
1097 | xfs_da_log_buf(args->trans, bp, | 1079 | xfs_da_log_buf(args->trans, bp, |
1098 | XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry))); | 1080 | XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry))); |
1099 | } | 1081 | } |
1100 | INT_MOD(hdr->count, ARCH_CONVERT, 1); | 1082 | be16_add(&hdr->count, 1); |
1101 | 1083 | ||
1102 | /* | 1084 | /* |
1103 | * Allocate space for the new string (at the end of the run). | 1085 | * Allocate space for the new string (at the end of the run). |
1104 | */ | 1086 | */ |
1105 | map = &hdr->freemap[mapindex]; | 1087 | map = &hdr->freemap[mapindex]; |
1106 | mp = args->trans->t_mountp; | 1088 | mp = args->trans->t_mountp; |
1107 | ASSERT(INT_GET(map->base, ARCH_CONVERT) < XFS_LBSIZE(mp)); | 1089 | ASSERT(be16_to_cpu(map->base) < XFS_LBSIZE(mp)); |
1108 | ASSERT((INT_GET(map->base, ARCH_CONVERT) & 0x3) == 0); | 1090 | ASSERT((be16_to_cpu(map->base) & 0x3) == 0); |
1109 | ASSERT(INT_GET(map->size, ARCH_CONVERT) >= | 1091 | ASSERT(be16_to_cpu(map->size) >= |
1110 | xfs_attr_leaf_newentsize(args->namelen, args->valuelen, | 1092 | xfs_attr_leaf_newentsize(args->namelen, args->valuelen, |
1111 | mp->m_sb.sb_blocksize, NULL)); | 1093 | mp->m_sb.sb_blocksize, NULL)); |
1112 | ASSERT(INT_GET(map->size, ARCH_CONVERT) < XFS_LBSIZE(mp)); | 1094 | ASSERT(be16_to_cpu(map->size) < XFS_LBSIZE(mp)); |
1113 | ASSERT((INT_GET(map->size, ARCH_CONVERT) & 0x3) == 0); | 1095 | ASSERT((be16_to_cpu(map->size) & 0x3) == 0); |
1114 | INT_MOD(map->size, ARCH_CONVERT, | 1096 | be16_add(&map->size, |
1115 | -xfs_attr_leaf_newentsize(args->namelen, args->valuelen, | 1097 | -xfs_attr_leaf_newentsize(args->namelen, args->valuelen, |
1116 | mp->m_sb.sb_blocksize, &tmp)); | 1098 | mp->m_sb.sb_blocksize, &tmp)); |
1117 | INT_SET(entry->nameidx, ARCH_CONVERT, | 1099 | entry->nameidx = cpu_to_be16(be16_to_cpu(map->base) + |
1118 | INT_GET(map->base, ARCH_CONVERT) | 1100 | be16_to_cpu(map->size)); |
1119 | + INT_GET(map->size, ARCH_CONVERT)); | 1101 | entry->hashval = cpu_to_be32(args->hashval); |
1120 | INT_SET(entry->hashval, ARCH_CONVERT, args->hashval); | ||
1121 | entry->flags = tmp ? XFS_ATTR_LOCAL : 0; | 1102 | entry->flags = tmp ? XFS_ATTR_LOCAL : 0; |
1122 | entry->flags |= (args->flags & ATTR_SECURE) ? XFS_ATTR_SECURE : | 1103 | entry->flags |= (args->flags & ATTR_SECURE) ? XFS_ATTR_SECURE : |
1123 | ((args->flags & ATTR_ROOT) ? XFS_ATTR_ROOT : 0); | 1104 | ((args->flags & ATTR_ROOT) ? XFS_ATTR_ROOT : 0); |
@@ -1130,12 +1111,10 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex) | |||
1130 | } | 1111 | } |
1131 | xfs_da_log_buf(args->trans, bp, | 1112 | xfs_da_log_buf(args->trans, bp, |
1132 | XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry))); | 1113 | XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry))); |
1133 | ASSERT((args->index == 0) || (INT_GET(entry->hashval, ARCH_CONVERT) | 1114 | ASSERT((args->index == 0) || |
1134 | >= INT_GET((entry-1)->hashval, | 1115 | (be32_to_cpu(entry->hashval) >= be32_to_cpu((entry-1)->hashval))); |
1135 | ARCH_CONVERT))); | 1116 | ASSERT((args->index == be16_to_cpu(hdr->count)-1) || |
1136 | ASSERT((args->index == INT_GET(hdr->count, ARCH_CONVERT)-1) || | 1117 | (be32_to_cpu(entry->hashval) <= be32_to_cpu((entry+1)->hashval))); |
1137 | (INT_GET(entry->hashval, ARCH_CONVERT) | ||
1138 | <= (INT_GET((entry+1)->hashval, ARCH_CONVERT)))); | ||
1139 | 1118 | ||
1140 | /* | 1119 | /* |
1141 | * Copy the attribute name and value into the new space. | 1120 | * Copy the attribute name and value into the new space. |
@@ -1149,10 +1128,10 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex) | |||
1149 | if (entry->flags & XFS_ATTR_LOCAL) { | 1128 | if (entry->flags & XFS_ATTR_LOCAL) { |
1150 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, args->index); | 1129 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, args->index); |
1151 | name_loc->namelen = args->namelen; | 1130 | name_loc->namelen = args->namelen; |
1152 | INT_SET(name_loc->valuelen, ARCH_CONVERT, args->valuelen); | 1131 | name_loc->valuelen = cpu_to_be16(args->valuelen); |
1153 | memcpy((char *)name_loc->nameval, args->name, args->namelen); | 1132 | memcpy((char *)name_loc->nameval, args->name, args->namelen); |
1154 | memcpy((char *)&name_loc->nameval[args->namelen], args->value, | 1133 | memcpy((char *)&name_loc->nameval[args->namelen], args->value, |
1155 | INT_GET(name_loc->valuelen, ARCH_CONVERT)); | 1134 | be16_to_cpu(name_loc->valuelen)); |
1156 | } else { | 1135 | } else { |
1157 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index); | 1136 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index); |
1158 | name_rmt->namelen = args->namelen; | 1137 | name_rmt->namelen = args->namelen; |
@@ -1171,28 +1150,23 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex) | |||
1171 | /* | 1150 | /* |
1172 | * Update the control info for this leaf node | 1151 | * Update the control info for this leaf node |
1173 | */ | 1152 | */ |
1174 | if (INT_GET(entry->nameidx, ARCH_CONVERT) | 1153 | if (be16_to_cpu(entry->nameidx) < be16_to_cpu(hdr->firstused)) { |
1175 | < INT_GET(hdr->firstused, ARCH_CONVERT)) { | ||
1176 | /* both on-disk, don't endian-flip twice */ | 1154 | /* both on-disk, don't endian-flip twice */ |
1177 | hdr->firstused = entry->nameidx; | 1155 | hdr->firstused = entry->nameidx; |
1178 | } | 1156 | } |
1179 | ASSERT(INT_GET(hdr->firstused, ARCH_CONVERT) | 1157 | ASSERT(be16_to_cpu(hdr->firstused) >= |
1180 | >= ((INT_GET(hdr->count, ARCH_CONVERT) | 1158 | ((be16_to_cpu(hdr->count) * sizeof(*entry)) + sizeof(*hdr))); |
1181 | * sizeof(*entry))+sizeof(*hdr))); | 1159 | tmp = (be16_to_cpu(hdr->count)-1) * sizeof(xfs_attr_leaf_entry_t) |
1182 | tmp = (INT_GET(hdr->count, ARCH_CONVERT)-1) | ||
1183 | * sizeof(xfs_attr_leaf_entry_t) | ||
1184 | + sizeof(xfs_attr_leaf_hdr_t); | 1160 | + sizeof(xfs_attr_leaf_hdr_t); |
1185 | map = &hdr->freemap[0]; | 1161 | map = &hdr->freemap[0]; |
1186 | for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; map++, i++) { | 1162 | for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; map++, i++) { |
1187 | if (INT_GET(map->base, ARCH_CONVERT) == tmp) { | 1163 | if (be16_to_cpu(map->base) == tmp) { |
1188 | INT_MOD(map->base, ARCH_CONVERT, | 1164 | be16_add(&map->base, sizeof(xfs_attr_leaf_entry_t)); |
1189 | sizeof(xfs_attr_leaf_entry_t)); | 1165 | be16_add(&map->size, |
1190 | INT_MOD(map->size, ARCH_CONVERT, | 1166 | -((int)sizeof(xfs_attr_leaf_entry_t))); |
1191 | -sizeof(xfs_attr_leaf_entry_t)); | ||
1192 | } | 1167 | } |
1193 | } | 1168 | } |
1194 | INT_MOD(hdr->usedbytes, ARCH_CONVERT, | 1169 | be16_add(&hdr->usedbytes, xfs_attr_leaf_entsize(leaf, args->index)); |
1195 | xfs_attr_leaf_entsize(leaf, args->index)); | ||
1196 | xfs_da_log_buf(args->trans, bp, | 1170 | xfs_da_log_buf(args->trans, bp, |
1197 | XFS_DA_LOGRANGE(leaf, hdr, sizeof(*hdr))); | 1171 | XFS_DA_LOGRANGE(leaf, hdr, sizeof(*hdr))); |
1198 | return(0); | 1172 | return(0); |
@@ -1223,28 +1197,25 @@ xfs_attr_leaf_compact(xfs_trans_t *trans, xfs_dabuf_t *bp) | |||
1223 | hdr_s = &leaf_s->hdr; | 1197 | hdr_s = &leaf_s->hdr; |
1224 | hdr_d = &leaf_d->hdr; | 1198 | hdr_d = &leaf_d->hdr; |
1225 | hdr_d->info = hdr_s->info; /* struct copy */ | 1199 | hdr_d->info = hdr_s->info; /* struct copy */ |
1226 | INT_SET(hdr_d->firstused, ARCH_CONVERT, XFS_LBSIZE(mp)); | 1200 | hdr_d->firstused = cpu_to_be16(XFS_LBSIZE(mp)); |
1227 | /* handle truncation gracefully */ | 1201 | /* handle truncation gracefully */ |
1228 | if (!hdr_d->firstused) { | 1202 | if (!hdr_d->firstused) { |
1229 | INT_SET(hdr_d->firstused, ARCH_CONVERT, | 1203 | hdr_d->firstused = cpu_to_be16( |
1230 | XFS_LBSIZE(mp) - XFS_ATTR_LEAF_NAME_ALIGN); | 1204 | XFS_LBSIZE(mp) - XFS_ATTR_LEAF_NAME_ALIGN); |
1231 | } | 1205 | } |
1232 | hdr_d->usedbytes = 0; | 1206 | hdr_d->usedbytes = 0; |
1233 | hdr_d->count = 0; | 1207 | hdr_d->count = 0; |
1234 | hdr_d->holes = 0; | 1208 | hdr_d->holes = 0; |
1235 | INT_SET(hdr_d->freemap[0].base, ARCH_CONVERT, | 1209 | hdr_d->freemap[0].base = cpu_to_be16(sizeof(xfs_attr_leaf_hdr_t)); |
1236 | sizeof(xfs_attr_leaf_hdr_t)); | 1210 | hdr_d->freemap[0].size = cpu_to_be16(be16_to_cpu(hdr_d->firstused) - |
1237 | INT_SET(hdr_d->freemap[0].size, ARCH_CONVERT, | 1211 | sizeof(xfs_attr_leaf_hdr_t)); |
1238 | INT_GET(hdr_d->firstused, ARCH_CONVERT) | ||
1239 | - INT_GET(hdr_d->freemap[0].base, ARCH_CONVERT)); | ||
1240 | 1212 | ||
1241 | /* | 1213 | /* |
1242 | * Copy all entry's in the same (sorted) order, | 1214 | * Copy all entry's in the same (sorted) order, |
1243 | * but allocate name/value pairs packed and in sequence. | 1215 | * but allocate name/value pairs packed and in sequence. |
1244 | */ | 1216 | */ |
1245 | xfs_attr_leaf_moveents(leaf_s, 0, leaf_d, 0, | 1217 | xfs_attr_leaf_moveents(leaf_s, 0, leaf_d, 0, |
1246 | (int)INT_GET(hdr_s->count, ARCH_CONVERT), mp); | 1218 | be16_to_cpu(hdr_s->count), mp); |
1247 | |||
1248 | xfs_da_log_buf(trans, bp, 0, XFS_LBSIZE(mp) - 1); | 1219 | xfs_da_log_buf(trans, bp, 0, XFS_LBSIZE(mp) - 1); |
1249 | 1220 | ||
1250 | kmem_free(tmpbuffer, XFS_LBSIZE(mp)); | 1221 | kmem_free(tmpbuffer, XFS_LBSIZE(mp)); |
@@ -1279,10 +1250,8 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
1279 | ASSERT(blk2->magic == XFS_ATTR_LEAF_MAGIC); | 1250 | ASSERT(blk2->magic == XFS_ATTR_LEAF_MAGIC); |
1280 | leaf1 = blk1->bp->data; | 1251 | leaf1 = blk1->bp->data; |
1281 | leaf2 = blk2->bp->data; | 1252 | leaf2 = blk2->bp->data; |
1282 | ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) | 1253 | ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1283 | == XFS_ATTR_LEAF_MAGIC); | 1254 | ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1284 | ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) | ||
1285 | == XFS_ATTR_LEAF_MAGIC); | ||
1286 | args = state->args; | 1255 | args = state->args; |
1287 | 1256 | ||
1288 | /* | 1257 | /* |
@@ -1319,22 +1288,21 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
1319 | /* | 1288 | /* |
1320 | * Move any entries required from leaf to leaf: | 1289 | * Move any entries required from leaf to leaf: |
1321 | */ | 1290 | */ |
1322 | if (count < INT_GET(hdr1->count, ARCH_CONVERT)) { | 1291 | if (count < be16_to_cpu(hdr1->count)) { |
1323 | /* | 1292 | /* |
1324 | * Figure the total bytes to be added to the destination leaf. | 1293 | * Figure the total bytes to be added to the destination leaf. |
1325 | */ | 1294 | */ |
1326 | /* number entries being moved */ | 1295 | /* number entries being moved */ |
1327 | count = INT_GET(hdr1->count, ARCH_CONVERT) - count; | 1296 | count = be16_to_cpu(hdr1->count) - count; |
1328 | space = INT_GET(hdr1->usedbytes, ARCH_CONVERT) - totallen; | 1297 | space = be16_to_cpu(hdr1->usedbytes) - totallen; |
1329 | space += count * sizeof(xfs_attr_leaf_entry_t); | 1298 | space += count * sizeof(xfs_attr_leaf_entry_t); |
1330 | 1299 | ||
1331 | /* | 1300 | /* |
1332 | * leaf2 is the destination, compact it if it looks tight. | 1301 | * leaf2 is the destination, compact it if it looks tight. |
1333 | */ | 1302 | */ |
1334 | max = INT_GET(hdr2->firstused, ARCH_CONVERT) | 1303 | max = be16_to_cpu(hdr2->firstused) |
1335 | - sizeof(xfs_attr_leaf_hdr_t); | 1304 | - sizeof(xfs_attr_leaf_hdr_t); |
1336 | max -= INT_GET(hdr2->count, ARCH_CONVERT) | 1305 | max -= be16_to_cpu(hdr2->count) * sizeof(xfs_attr_leaf_entry_t); |
1337 | * sizeof(xfs_attr_leaf_entry_t); | ||
1338 | if (space > max) { | 1306 | if (space > max) { |
1339 | xfs_attr_leaf_compact(args->trans, blk2->bp); | 1307 | xfs_attr_leaf_compact(args->trans, blk2->bp); |
1340 | } | 1308 | } |
@@ -1342,13 +1310,12 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
1342 | /* | 1310 | /* |
1343 | * Move high entries from leaf1 to low end of leaf2. | 1311 | * Move high entries from leaf1 to low end of leaf2. |
1344 | */ | 1312 | */ |
1345 | xfs_attr_leaf_moveents(leaf1, | 1313 | xfs_attr_leaf_moveents(leaf1, be16_to_cpu(hdr1->count) - count, |
1346 | INT_GET(hdr1->count, ARCH_CONVERT)-count, | ||
1347 | leaf2, 0, count, state->mp); | 1314 | leaf2, 0, count, state->mp); |
1348 | 1315 | ||
1349 | xfs_da_log_buf(args->trans, blk1->bp, 0, state->blocksize-1); | 1316 | xfs_da_log_buf(args->trans, blk1->bp, 0, state->blocksize-1); |
1350 | xfs_da_log_buf(args->trans, blk2->bp, 0, state->blocksize-1); | 1317 | xfs_da_log_buf(args->trans, blk2->bp, 0, state->blocksize-1); |
1351 | } else if (count > INT_GET(hdr1->count, ARCH_CONVERT)) { | 1318 | } else if (count > be16_to_cpu(hdr1->count)) { |
1352 | /* | 1319 | /* |
1353 | * I assert that since all callers pass in an empty | 1320 | * I assert that since all callers pass in an empty |
1354 | * second buffer, this code should never execute. | 1321 | * second buffer, this code should never execute. |
@@ -1358,17 +1325,16 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
1358 | * Figure the total bytes to be added to the destination leaf. | 1325 | * Figure the total bytes to be added to the destination leaf. |
1359 | */ | 1326 | */ |
1360 | /* number entries being moved */ | 1327 | /* number entries being moved */ |
1361 | count -= INT_GET(hdr1->count, ARCH_CONVERT); | 1328 | count -= be16_to_cpu(hdr1->count); |
1362 | space = totallen - INT_GET(hdr1->usedbytes, ARCH_CONVERT); | 1329 | space = totallen - be16_to_cpu(hdr1->usedbytes); |
1363 | space += count * sizeof(xfs_attr_leaf_entry_t); | 1330 | space += count * sizeof(xfs_attr_leaf_entry_t); |
1364 | 1331 | ||
1365 | /* | 1332 | /* |
1366 | * leaf1 is the destination, compact it if it looks tight. | 1333 | * leaf1 is the destination, compact it if it looks tight. |
1367 | */ | 1334 | */ |
1368 | max = INT_GET(hdr1->firstused, ARCH_CONVERT) | 1335 | max = be16_to_cpu(hdr1->firstused) |
1369 | - sizeof(xfs_attr_leaf_hdr_t); | 1336 | - sizeof(xfs_attr_leaf_hdr_t); |
1370 | max -= INT_GET(hdr1->count, ARCH_CONVERT) | 1337 | max -= be16_to_cpu(hdr1->count) * sizeof(xfs_attr_leaf_entry_t); |
1371 | * sizeof(xfs_attr_leaf_entry_t); | ||
1372 | if (space > max) { | 1338 | if (space > max) { |
1373 | xfs_attr_leaf_compact(args->trans, blk1->bp); | 1339 | xfs_attr_leaf_compact(args->trans, blk1->bp); |
1374 | } | 1340 | } |
@@ -1377,8 +1343,7 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
1377 | * Move low entries from leaf2 to high end of leaf1. | 1343 | * Move low entries from leaf2 to high end of leaf1. |
1378 | */ | 1344 | */ |
1379 | xfs_attr_leaf_moveents(leaf2, 0, leaf1, | 1345 | xfs_attr_leaf_moveents(leaf2, 0, leaf1, |
1380 | (int)INT_GET(hdr1->count, ARCH_CONVERT), count, | 1346 | be16_to_cpu(hdr1->count), count, state->mp); |
1381 | state->mp); | ||
1382 | 1347 | ||
1383 | xfs_da_log_buf(args->trans, blk1->bp, 0, state->blocksize-1); | 1348 | xfs_da_log_buf(args->trans, blk1->bp, 0, state->blocksize-1); |
1384 | xfs_da_log_buf(args->trans, blk2->bp, 0, state->blocksize-1); | 1349 | xfs_da_log_buf(args->trans, blk2->bp, 0, state->blocksize-1); |
@@ -1387,12 +1352,10 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
1387 | /* | 1352 | /* |
1388 | * Copy out last hashval in each block for B-tree code. | 1353 | * Copy out last hashval in each block for B-tree code. |
1389 | */ | 1354 | */ |
1390 | blk1->hashval = | 1355 | blk1->hashval = be32_to_cpu( |
1391 | INT_GET(leaf1->entries[INT_GET(leaf1->hdr.count, | 1356 | leaf1->entries[be16_to_cpu(leaf1->hdr.count)-1].hashval); |
1392 | ARCH_CONVERT)-1].hashval, ARCH_CONVERT); | 1357 | blk2->hashval = be32_to_cpu( |
1393 | blk2->hashval = | 1358 | leaf2->entries[be16_to_cpu(leaf2->hdr.count)-1].hashval); |
1394 | INT_GET(leaf2->entries[INT_GET(leaf2->hdr.count, | ||
1395 | ARCH_CONVERT)-1].hashval, ARCH_CONVERT); | ||
1396 | 1359 | ||
1397 | /* | 1360 | /* |
1398 | * Adjust the expected index for insertion. | 1361 | * Adjust the expected index for insertion. |
@@ -1406,13 +1369,12 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
1406 | * inserting. The index/blkno fields refer to the "old" entry, | 1369 | * inserting. The index/blkno fields refer to the "old" entry, |
1407 | * while the index2/blkno2 fields refer to the "new" entry. | 1370 | * while the index2/blkno2 fields refer to the "new" entry. |
1408 | */ | 1371 | */ |
1409 | if (blk1->index > INT_GET(leaf1->hdr.count, ARCH_CONVERT)) { | 1372 | if (blk1->index > be16_to_cpu(leaf1->hdr.count)) { |
1410 | ASSERT(state->inleaf == 0); | 1373 | ASSERT(state->inleaf == 0); |
1411 | blk2->index = blk1->index | 1374 | blk2->index = blk1->index - be16_to_cpu(leaf1->hdr.count); |
1412 | - INT_GET(leaf1->hdr.count, ARCH_CONVERT); | ||
1413 | args->index = args->index2 = blk2->index; | 1375 | args->index = args->index2 = blk2->index; |
1414 | args->blkno = args->blkno2 = blk2->blkno; | 1376 | args->blkno = args->blkno2 = blk2->blkno; |
1415 | } else if (blk1->index == INT_GET(leaf1->hdr.count, ARCH_CONVERT)) { | 1377 | } else if (blk1->index == be16_to_cpu(leaf1->hdr.count)) { |
1416 | if (state->inleaf) { | 1378 | if (state->inleaf) { |
1417 | args->index = blk1->index; | 1379 | args->index = blk1->index; |
1418 | args->blkno = blk1->blkno; | 1380 | args->blkno = blk1->blkno; |
@@ -1420,7 +1382,7 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
1420 | args->blkno2 = blk2->blkno; | 1382 | args->blkno2 = blk2->blkno; |
1421 | } else { | 1383 | } else { |
1422 | blk2->index = blk1->index | 1384 | blk2->index = blk1->index |
1423 | - INT_GET(leaf1->hdr.count, ARCH_CONVERT); | 1385 | - be16_to_cpu(leaf1->hdr.count); |
1424 | args->index = args->index2 = blk2->index; | 1386 | args->index = args->index2 = blk2->index; |
1425 | args->blkno = args->blkno2 = blk2->blkno; | 1387 | args->blkno = args->blkno2 = blk2->blkno; |
1426 | } | 1388 | } |
@@ -1464,15 +1426,14 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state, | |||
1464 | * Examine entries until we reduce the absolute difference in | 1426 | * Examine entries until we reduce the absolute difference in |
1465 | * byte usage between the two blocks to a minimum. | 1427 | * byte usage between the two blocks to a minimum. |
1466 | */ | 1428 | */ |
1467 | max = INT_GET(hdr1->count, ARCH_CONVERT) | 1429 | max = be16_to_cpu(hdr1->count) + be16_to_cpu(hdr2->count); |
1468 | + INT_GET(hdr2->count, ARCH_CONVERT); | ||
1469 | half = (max+1) * sizeof(*entry); | 1430 | half = (max+1) * sizeof(*entry); |
1470 | half += INT_GET(hdr1->usedbytes, ARCH_CONVERT) | 1431 | half += be16_to_cpu(hdr1->usedbytes) + |
1471 | + INT_GET(hdr2->usedbytes, ARCH_CONVERT) | 1432 | be16_to_cpu(hdr2->usedbytes) + |
1472 | + xfs_attr_leaf_newentsize( | 1433 | xfs_attr_leaf_newentsize( |
1473 | state->args->namelen, | 1434 | state->args->namelen, |
1474 | state->args->valuelen, | 1435 | state->args->valuelen, |
1475 | state->blocksize, NULL); | 1436 | state->blocksize, NULL); |
1476 | half /= 2; | 1437 | half /= 2; |
1477 | lastdelta = state->blocksize; | 1438 | lastdelta = state->blocksize; |
1478 | entry = &leaf1->entries[0]; | 1439 | entry = &leaf1->entries[0]; |
@@ -1498,7 +1459,7 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state, | |||
1498 | /* | 1459 | /* |
1499 | * Wrap around into the second block if necessary. | 1460 | * Wrap around into the second block if necessary. |
1500 | */ | 1461 | */ |
1501 | if (count == INT_GET(hdr1->count, ARCH_CONVERT)) { | 1462 | if (count == be16_to_cpu(hdr1->count)) { |
1502 | leaf1 = leaf2; | 1463 | leaf1 = leaf2; |
1503 | entry = &leaf1->entries[0]; | 1464 | entry = &leaf1->entries[0]; |
1504 | index = 0; | 1465 | index = 0; |
@@ -1566,12 +1527,12 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1566 | */ | 1527 | */ |
1567 | blk = &state->path.blk[ state->path.active-1 ]; | 1528 | blk = &state->path.blk[ state->path.active-1 ]; |
1568 | info = blk->bp->data; | 1529 | info = blk->bp->data; |
1569 | ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC); | 1530 | ASSERT(be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC); |
1570 | leaf = (xfs_attr_leafblock_t *)info; | 1531 | leaf = (xfs_attr_leafblock_t *)info; |
1571 | count = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 1532 | count = be16_to_cpu(leaf->hdr.count); |
1572 | bytes = sizeof(xfs_attr_leaf_hdr_t) + | 1533 | bytes = sizeof(xfs_attr_leaf_hdr_t) + |
1573 | count * sizeof(xfs_attr_leaf_entry_t) + | 1534 | count * sizeof(xfs_attr_leaf_entry_t) + |
1574 | INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT); | 1535 | be16_to_cpu(leaf->hdr.usedbytes); |
1575 | if (bytes > (state->blocksize >> 1)) { | 1536 | if (bytes > (state->blocksize >> 1)) { |
1576 | *action = 0; /* blk over 50%, don't try to join */ | 1537 | *action = 0; /* blk over 50%, don't try to join */ |
1577 | return(0); | 1538 | return(0); |
@@ -1588,7 +1549,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1588 | * Make altpath point to the block we want to keep and | 1549 | * Make altpath point to the block we want to keep and |
1589 | * path point to the block we want to drop (this one). | 1550 | * path point to the block we want to drop (this one). |
1590 | */ | 1551 | */ |
1591 | forward = info->forw; | 1552 | forward = (info->forw != 0); |
1592 | memcpy(&state->altpath, &state->path, sizeof(state->path)); | 1553 | memcpy(&state->altpath, &state->path, sizeof(state->path)); |
1593 | error = xfs_da_path_shift(state, &state->altpath, forward, | 1554 | error = xfs_da_path_shift(state, &state->altpath, forward, |
1594 | 0, &retval); | 1555 | 0, &retval); |
@@ -1610,13 +1571,12 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1610 | * to shrink an attribute list over time. | 1571 | * to shrink an attribute list over time. |
1611 | */ | 1572 | */ |
1612 | /* start with smaller blk num */ | 1573 | /* start with smaller blk num */ |
1613 | forward = (INT_GET(info->forw, ARCH_CONVERT) | 1574 | forward = (be32_to_cpu(info->forw) < be32_to_cpu(info->back)); |
1614 | < INT_GET(info->back, ARCH_CONVERT)); | ||
1615 | for (i = 0; i < 2; forward = !forward, i++) { | 1575 | for (i = 0; i < 2; forward = !forward, i++) { |
1616 | if (forward) | 1576 | if (forward) |
1617 | blkno = INT_GET(info->forw, ARCH_CONVERT); | 1577 | blkno = be32_to_cpu(info->forw); |
1618 | else | 1578 | else |
1619 | blkno = INT_GET(info->back, ARCH_CONVERT); | 1579 | blkno = be32_to_cpu(info->back); |
1620 | if (blkno == 0) | 1580 | if (blkno == 0) |
1621 | continue; | 1581 | continue; |
1622 | error = xfs_da_read_buf(state->args->trans, state->args->dp, | 1582 | error = xfs_da_read_buf(state->args->trans, state->args->dp, |
@@ -1626,14 +1586,13 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1626 | ASSERT(bp != NULL); | 1586 | ASSERT(bp != NULL); |
1627 | 1587 | ||
1628 | leaf = (xfs_attr_leafblock_t *)info; | 1588 | leaf = (xfs_attr_leafblock_t *)info; |
1629 | count = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 1589 | count = be16_to_cpu(leaf->hdr.count); |
1630 | bytes = state->blocksize - (state->blocksize>>2); | 1590 | bytes = state->blocksize - (state->blocksize>>2); |
1631 | bytes -= INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT); | 1591 | bytes -= be16_to_cpu(leaf->hdr.usedbytes); |
1632 | leaf = bp->data; | 1592 | leaf = bp->data; |
1633 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 1593 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1634 | == XFS_ATTR_LEAF_MAGIC); | 1594 | count += be16_to_cpu(leaf->hdr.count); |
1635 | count += INT_GET(leaf->hdr.count, ARCH_CONVERT); | 1595 | bytes -= be16_to_cpu(leaf->hdr.usedbytes); |
1636 | bytes -= INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT); | ||
1637 | bytes -= count * sizeof(xfs_attr_leaf_entry_t); | 1596 | bytes -= count * sizeof(xfs_attr_leaf_entry_t); |
1638 | bytes -= sizeof(xfs_attr_leaf_hdr_t); | 1597 | bytes -= sizeof(xfs_attr_leaf_hdr_t); |
1639 | xfs_da_brelse(state->args->trans, bp); | 1598 | xfs_da_brelse(state->args->trans, bp); |
@@ -1685,21 +1644,18 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1685 | xfs_mount_t *mp; | 1644 | xfs_mount_t *mp; |
1686 | 1645 | ||
1687 | leaf = bp->data; | 1646 | leaf = bp->data; |
1688 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 1647 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1689 | == XFS_ATTR_LEAF_MAGIC); | ||
1690 | hdr = &leaf->hdr; | 1648 | hdr = &leaf->hdr; |
1691 | mp = args->trans->t_mountp; | 1649 | mp = args->trans->t_mountp; |
1692 | ASSERT((INT_GET(hdr->count, ARCH_CONVERT) > 0) | 1650 | ASSERT((be16_to_cpu(hdr->count) > 0) |
1693 | && (INT_GET(hdr->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8))); | 1651 | && (be16_to_cpu(hdr->count) < (XFS_LBSIZE(mp)/8))); |
1694 | ASSERT((args->index >= 0) | 1652 | ASSERT((args->index >= 0) |
1695 | && (args->index < INT_GET(hdr->count, ARCH_CONVERT))); | 1653 | && (args->index < be16_to_cpu(hdr->count))); |
1696 | ASSERT(INT_GET(hdr->firstused, ARCH_CONVERT) | 1654 | ASSERT(be16_to_cpu(hdr->firstused) >= |
1697 | >= ((INT_GET(hdr->count, ARCH_CONVERT) | 1655 | ((be16_to_cpu(hdr->count) * sizeof(*entry)) + sizeof(*hdr))); |
1698 | * sizeof(*entry))+sizeof(*hdr))); | ||
1699 | entry = &leaf->entries[args->index]; | 1656 | entry = &leaf->entries[args->index]; |
1700 | ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) | 1657 | ASSERT(be16_to_cpu(entry->nameidx) >= be16_to_cpu(hdr->firstused)); |
1701 | >= INT_GET(hdr->firstused, ARCH_CONVERT)); | 1658 | ASSERT(be16_to_cpu(entry->nameidx) < XFS_LBSIZE(mp)); |
1702 | ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) < XFS_LBSIZE(mp)); | ||
1703 | 1659 | ||
1704 | /* | 1660 | /* |
1705 | * Scan through free region table: | 1661 | * Scan through free region table: |
@@ -1707,33 +1663,30 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1707 | * find smallest free region in case we need to replace it, | 1663 | * find smallest free region in case we need to replace it, |
1708 | * adjust any map that borders the entry table, | 1664 | * adjust any map that borders the entry table, |
1709 | */ | 1665 | */ |
1710 | tablesize = INT_GET(hdr->count, ARCH_CONVERT) | 1666 | tablesize = be16_to_cpu(hdr->count) * sizeof(xfs_attr_leaf_entry_t) |
1711 | * sizeof(xfs_attr_leaf_entry_t) | ||
1712 | + sizeof(xfs_attr_leaf_hdr_t); | 1667 | + sizeof(xfs_attr_leaf_hdr_t); |
1713 | map = &hdr->freemap[0]; | 1668 | map = &hdr->freemap[0]; |
1714 | tmp = INT_GET(map->size, ARCH_CONVERT); | 1669 | tmp = be16_to_cpu(map->size); |
1715 | before = after = -1; | 1670 | before = after = -1; |
1716 | smallest = XFS_ATTR_LEAF_MAPSIZE - 1; | 1671 | smallest = XFS_ATTR_LEAF_MAPSIZE - 1; |
1717 | entsize = xfs_attr_leaf_entsize(leaf, args->index); | 1672 | entsize = xfs_attr_leaf_entsize(leaf, args->index); |
1718 | for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; map++, i++) { | 1673 | for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; map++, i++) { |
1719 | ASSERT(INT_GET(map->base, ARCH_CONVERT) < XFS_LBSIZE(mp)); | 1674 | ASSERT(be16_to_cpu(map->base) < XFS_LBSIZE(mp)); |
1720 | ASSERT(INT_GET(map->size, ARCH_CONVERT) < XFS_LBSIZE(mp)); | 1675 | ASSERT(be16_to_cpu(map->size) < XFS_LBSIZE(mp)); |
1721 | if (INT_GET(map->base, ARCH_CONVERT) == tablesize) { | 1676 | if (be16_to_cpu(map->base) == tablesize) { |
1722 | INT_MOD(map->base, ARCH_CONVERT, | 1677 | be16_add(&map->base, |
1723 | -sizeof(xfs_attr_leaf_entry_t)); | 1678 | -((int)sizeof(xfs_attr_leaf_entry_t))); |
1724 | INT_MOD(map->size, ARCH_CONVERT, | 1679 | be16_add(&map->size, sizeof(xfs_attr_leaf_entry_t)); |
1725 | sizeof(xfs_attr_leaf_entry_t)); | ||
1726 | } | 1680 | } |
1727 | 1681 | ||
1728 | if ((INT_GET(map->base, ARCH_CONVERT) | 1682 | if ((be16_to_cpu(map->base) + be16_to_cpu(map->size)) |
1729 | + INT_GET(map->size, ARCH_CONVERT)) | 1683 | == be16_to_cpu(entry->nameidx)) { |
1730 | == INT_GET(entry->nameidx, ARCH_CONVERT)) { | ||
1731 | before = i; | 1684 | before = i; |
1732 | } else if (INT_GET(map->base, ARCH_CONVERT) | 1685 | } else if (be16_to_cpu(map->base) |
1733 | == (INT_GET(entry->nameidx, ARCH_CONVERT) + entsize)) { | 1686 | == (be16_to_cpu(entry->nameidx) + entsize)) { |
1734 | after = i; | 1687 | after = i; |
1735 | } else if (INT_GET(map->size, ARCH_CONVERT) < tmp) { | 1688 | } else if (be16_to_cpu(map->size) < tmp) { |
1736 | tmp = INT_GET(map->size, ARCH_CONVERT); | 1689 | tmp = be16_to_cpu(map->size); |
1737 | smallest = i; | 1690 | smallest = i; |
1738 | } | 1691 | } |
1739 | } | 1692 | } |
@@ -1745,38 +1698,35 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1745 | if ((before >= 0) || (after >= 0)) { | 1698 | if ((before >= 0) || (after >= 0)) { |
1746 | if ((before >= 0) && (after >= 0)) { | 1699 | if ((before >= 0) && (after >= 0)) { |
1747 | map = &hdr->freemap[before]; | 1700 | map = &hdr->freemap[before]; |
1748 | INT_MOD(map->size, ARCH_CONVERT, entsize); | 1701 | be16_add(&map->size, entsize); |
1749 | INT_MOD(map->size, ARCH_CONVERT, | 1702 | be16_add(&map->size, |
1750 | INT_GET(hdr->freemap[after].size, | 1703 | be16_to_cpu(hdr->freemap[after].size)); |
1751 | ARCH_CONVERT)); | ||
1752 | hdr->freemap[after].base = 0; | 1704 | hdr->freemap[after].base = 0; |
1753 | hdr->freemap[after].size = 0; | 1705 | hdr->freemap[after].size = 0; |
1754 | } else if (before >= 0) { | 1706 | } else if (before >= 0) { |
1755 | map = &hdr->freemap[before]; | 1707 | map = &hdr->freemap[before]; |
1756 | INT_MOD(map->size, ARCH_CONVERT, entsize); | 1708 | be16_add(&map->size, entsize); |
1757 | } else { | 1709 | } else { |
1758 | map = &hdr->freemap[after]; | 1710 | map = &hdr->freemap[after]; |
1759 | /* both on-disk, don't endian flip twice */ | 1711 | /* both on-disk, don't endian flip twice */ |
1760 | map->base = entry->nameidx; | 1712 | map->base = entry->nameidx; |
1761 | INT_MOD(map->size, ARCH_CONVERT, entsize); | 1713 | be16_add(&map->size, entsize); |
1762 | } | 1714 | } |
1763 | } else { | 1715 | } else { |
1764 | /* | 1716 | /* |
1765 | * Replace smallest region (if it is smaller than free'd entry) | 1717 | * Replace smallest region (if it is smaller than free'd entry) |
1766 | */ | 1718 | */ |
1767 | map = &hdr->freemap[smallest]; | 1719 | map = &hdr->freemap[smallest]; |
1768 | if (INT_GET(map->size, ARCH_CONVERT) < entsize) { | 1720 | if (be16_to_cpu(map->size) < entsize) { |
1769 | INT_SET(map->base, ARCH_CONVERT, | 1721 | map->base = cpu_to_be16(be16_to_cpu(entry->nameidx)); |
1770 | INT_GET(entry->nameidx, ARCH_CONVERT)); | 1722 | map->size = cpu_to_be16(entsize); |
1771 | INT_SET(map->size, ARCH_CONVERT, entsize); | ||
1772 | } | 1723 | } |
1773 | } | 1724 | } |
1774 | 1725 | ||
1775 | /* | 1726 | /* |
1776 | * Did we remove the first entry? | 1727 | * Did we remove the first entry? |
1777 | */ | 1728 | */ |
1778 | if (INT_GET(entry->nameidx, ARCH_CONVERT) | 1729 | if (be16_to_cpu(entry->nameidx) == be16_to_cpu(hdr->firstused)) |
1779 | == INT_GET(hdr->firstused, ARCH_CONVERT)) | ||
1780 | smallest = 1; | 1730 | smallest = 1; |
1781 | else | 1731 | else |
1782 | smallest = 0; | 1732 | smallest = 0; |
@@ -1785,18 +1735,18 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1785 | * Compress the remaining entries and zero out the removed stuff. | 1735 | * Compress the remaining entries and zero out the removed stuff. |
1786 | */ | 1736 | */ |
1787 | memset(XFS_ATTR_LEAF_NAME(leaf, args->index), 0, entsize); | 1737 | memset(XFS_ATTR_LEAF_NAME(leaf, args->index), 0, entsize); |
1788 | INT_MOD(hdr->usedbytes, ARCH_CONVERT, -entsize); | 1738 | be16_add(&hdr->usedbytes, -entsize); |
1789 | xfs_da_log_buf(args->trans, bp, | 1739 | xfs_da_log_buf(args->trans, bp, |
1790 | XFS_DA_LOGRANGE(leaf, XFS_ATTR_LEAF_NAME(leaf, args->index), | 1740 | XFS_DA_LOGRANGE(leaf, XFS_ATTR_LEAF_NAME(leaf, args->index), |
1791 | entsize)); | 1741 | entsize)); |
1792 | 1742 | ||
1793 | tmp = (INT_GET(hdr->count, ARCH_CONVERT) - args->index) | 1743 | tmp = (be16_to_cpu(hdr->count) - args->index) |
1794 | * sizeof(xfs_attr_leaf_entry_t); | 1744 | * sizeof(xfs_attr_leaf_entry_t); |
1795 | memmove((char *)entry, (char *)(entry+1), tmp); | 1745 | memmove((char *)entry, (char *)(entry+1), tmp); |
1796 | INT_MOD(hdr->count, ARCH_CONVERT, -1); | 1746 | be16_add(&hdr->count, -1); |
1797 | xfs_da_log_buf(args->trans, bp, | 1747 | xfs_da_log_buf(args->trans, bp, |
1798 | XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry))); | 1748 | XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry))); |
1799 | entry = &leaf->entries[INT_GET(hdr->count, ARCH_CONVERT)]; | 1749 | entry = &leaf->entries[be16_to_cpu(hdr->count)]; |
1800 | memset((char *)entry, 0, sizeof(xfs_attr_leaf_entry_t)); | 1750 | memset((char *)entry, 0, sizeof(xfs_attr_leaf_entry_t)); |
1801 | 1751 | ||
1802 | /* | 1752 | /* |
@@ -1808,18 +1758,17 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1808 | if (smallest) { | 1758 | if (smallest) { |
1809 | tmp = XFS_LBSIZE(mp); | 1759 | tmp = XFS_LBSIZE(mp); |
1810 | entry = &leaf->entries[0]; | 1760 | entry = &leaf->entries[0]; |
1811 | for (i = INT_GET(hdr->count, ARCH_CONVERT)-1; | 1761 | for (i = be16_to_cpu(hdr->count)-1; i >= 0; entry++, i--) { |
1812 | i >= 0; entry++, i--) { | 1762 | ASSERT(be16_to_cpu(entry->nameidx) >= |
1813 | ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) | 1763 | be16_to_cpu(hdr->firstused)); |
1814 | >= INT_GET(hdr->firstused, ARCH_CONVERT)); | 1764 | ASSERT(be16_to_cpu(entry->nameidx) < XFS_LBSIZE(mp)); |
1815 | ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) | 1765 | |
1816 | < XFS_LBSIZE(mp)); | 1766 | if (be16_to_cpu(entry->nameidx) < tmp) |
1817 | if (INT_GET(entry->nameidx, ARCH_CONVERT) < tmp) | 1767 | tmp = be16_to_cpu(entry->nameidx); |
1818 | tmp = INT_GET(entry->nameidx, ARCH_CONVERT); | ||
1819 | } | 1768 | } |
1820 | INT_SET(hdr->firstused, ARCH_CONVERT, tmp); | 1769 | hdr->firstused = cpu_to_be16(tmp); |
1821 | if (!hdr->firstused) { | 1770 | if (!hdr->firstused) { |
1822 | INT_SET(hdr->firstused, ARCH_CONVERT, | 1771 | hdr->firstused = cpu_to_be16( |
1823 | tmp - XFS_ATTR_LEAF_NAME_ALIGN); | 1772 | tmp - XFS_ATTR_LEAF_NAME_ALIGN); |
1824 | } | 1773 | } |
1825 | } else { | 1774 | } else { |
@@ -1833,9 +1782,8 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1833 | * "join" the leaf with a sibling if so. | 1782 | * "join" the leaf with a sibling if so. |
1834 | */ | 1783 | */ |
1835 | tmp = sizeof(xfs_attr_leaf_hdr_t); | 1784 | tmp = sizeof(xfs_attr_leaf_hdr_t); |
1836 | tmp += INT_GET(leaf->hdr.count, ARCH_CONVERT) | 1785 | tmp += be16_to_cpu(leaf->hdr.count) * sizeof(xfs_attr_leaf_entry_t); |
1837 | * sizeof(xfs_attr_leaf_entry_t); | 1786 | tmp += be16_to_cpu(leaf->hdr.usedbytes); |
1838 | tmp += INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT); | ||
1839 | return(tmp < mp->m_attr_magicpct); /* leaf is < 37% full */ | 1787 | return(tmp < mp->m_attr_magicpct); /* leaf is < 37% full */ |
1840 | } | 1788 | } |
1841 | 1789 | ||
@@ -1859,20 +1807,16 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, | |||
1859 | ASSERT(save_blk->magic == XFS_ATTR_LEAF_MAGIC); | 1807 | ASSERT(save_blk->magic == XFS_ATTR_LEAF_MAGIC); |
1860 | drop_leaf = drop_blk->bp->data; | 1808 | drop_leaf = drop_blk->bp->data; |
1861 | save_leaf = save_blk->bp->data; | 1809 | save_leaf = save_blk->bp->data; |
1862 | ASSERT(INT_GET(drop_leaf->hdr.info.magic, ARCH_CONVERT) | 1810 | ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1863 | == XFS_ATTR_LEAF_MAGIC); | 1811 | ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1864 | ASSERT(INT_GET(save_leaf->hdr.info.magic, ARCH_CONVERT) | ||
1865 | == XFS_ATTR_LEAF_MAGIC); | ||
1866 | drop_hdr = &drop_leaf->hdr; | 1812 | drop_hdr = &drop_leaf->hdr; |
1867 | save_hdr = &save_leaf->hdr; | 1813 | save_hdr = &save_leaf->hdr; |
1868 | 1814 | ||
1869 | /* | 1815 | /* |
1870 | * Save last hashval from dying block for later Btree fixup. | 1816 | * Save last hashval from dying block for later Btree fixup. |
1871 | */ | 1817 | */ |
1872 | drop_blk->hashval = | 1818 | drop_blk->hashval = be32_to_cpu( |
1873 | INT_GET(drop_leaf->entries[INT_GET(drop_leaf->hdr.count, | 1819 | drop_leaf->entries[be16_to_cpu(drop_leaf->hdr.count)-1].hashval); |
1874 | ARCH_CONVERT)-1].hashval, | ||
1875 | ARCH_CONVERT); | ||
1876 | 1820 | ||
1877 | /* | 1821 | /* |
1878 | * Check if we need a temp buffer, or can we do it in place. | 1822 | * Check if we need a temp buffer, or can we do it in place. |
@@ -1886,12 +1830,11 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, | |||
1886 | */ | 1830 | */ |
1887 | if (xfs_attr_leaf_order(save_blk->bp, drop_blk->bp)) { | 1831 | if (xfs_attr_leaf_order(save_blk->bp, drop_blk->bp)) { |
1888 | xfs_attr_leaf_moveents(drop_leaf, 0, save_leaf, 0, | 1832 | xfs_attr_leaf_moveents(drop_leaf, 0, save_leaf, 0, |
1889 | (int)INT_GET(drop_hdr->count, ARCH_CONVERT), mp); | 1833 | be16_to_cpu(drop_hdr->count), mp); |
1890 | } else { | 1834 | } else { |
1891 | xfs_attr_leaf_moveents(drop_leaf, 0, save_leaf, | 1835 | xfs_attr_leaf_moveents(drop_leaf, 0, save_leaf, |
1892 | INT_GET(save_hdr->count, ARCH_CONVERT), | 1836 | be16_to_cpu(save_hdr->count), |
1893 | (int)INT_GET(drop_hdr->count, ARCH_CONVERT), | 1837 | be16_to_cpu(drop_hdr->count), mp); |
1894 | mp); | ||
1895 | } | 1838 | } |
1896 | } else { | 1839 | } else { |
1897 | /* | 1840 | /* |
@@ -1905,28 +1848,24 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, | |||
1905 | tmp_hdr = &tmp_leaf->hdr; | 1848 | tmp_hdr = &tmp_leaf->hdr; |
1906 | tmp_hdr->info = save_hdr->info; /* struct copy */ | 1849 | tmp_hdr->info = save_hdr->info; /* struct copy */ |
1907 | tmp_hdr->count = 0; | 1850 | tmp_hdr->count = 0; |
1908 | INT_SET(tmp_hdr->firstused, ARCH_CONVERT, state->blocksize); | 1851 | tmp_hdr->firstused = cpu_to_be16(state->blocksize); |
1909 | if (!tmp_hdr->firstused) { | 1852 | if (!tmp_hdr->firstused) { |
1910 | INT_SET(tmp_hdr->firstused, ARCH_CONVERT, | 1853 | tmp_hdr->firstused = cpu_to_be16( |
1911 | state->blocksize - XFS_ATTR_LEAF_NAME_ALIGN); | 1854 | state->blocksize - XFS_ATTR_LEAF_NAME_ALIGN); |
1912 | } | 1855 | } |
1913 | tmp_hdr->usedbytes = 0; | 1856 | tmp_hdr->usedbytes = 0; |
1914 | if (xfs_attr_leaf_order(save_blk->bp, drop_blk->bp)) { | 1857 | if (xfs_attr_leaf_order(save_blk->bp, drop_blk->bp)) { |
1915 | xfs_attr_leaf_moveents(drop_leaf, 0, tmp_leaf, 0, | 1858 | xfs_attr_leaf_moveents(drop_leaf, 0, tmp_leaf, 0, |
1916 | (int)INT_GET(drop_hdr->count, ARCH_CONVERT), | 1859 | be16_to_cpu(drop_hdr->count), mp); |
1917 | mp); | ||
1918 | xfs_attr_leaf_moveents(save_leaf, 0, tmp_leaf, | 1860 | xfs_attr_leaf_moveents(save_leaf, 0, tmp_leaf, |
1919 | INT_GET(tmp_leaf->hdr.count, ARCH_CONVERT), | 1861 | be16_to_cpu(tmp_leaf->hdr.count), |
1920 | (int)INT_GET(save_hdr->count, ARCH_CONVERT), | 1862 | be16_to_cpu(save_hdr->count), mp); |
1921 | mp); | ||
1922 | } else { | 1863 | } else { |
1923 | xfs_attr_leaf_moveents(save_leaf, 0, tmp_leaf, 0, | 1864 | xfs_attr_leaf_moveents(save_leaf, 0, tmp_leaf, 0, |
1924 | (int)INT_GET(save_hdr->count, ARCH_CONVERT), | 1865 | be16_to_cpu(save_hdr->count), mp); |
1925 | mp); | ||
1926 | xfs_attr_leaf_moveents(drop_leaf, 0, tmp_leaf, | 1866 | xfs_attr_leaf_moveents(drop_leaf, 0, tmp_leaf, |
1927 | INT_GET(tmp_leaf->hdr.count, ARCH_CONVERT), | 1867 | be16_to_cpu(tmp_leaf->hdr.count), |
1928 | (int)INT_GET(drop_hdr->count, ARCH_CONVERT), | 1868 | be16_to_cpu(drop_hdr->count), mp); |
1929 | mp); | ||
1930 | } | 1869 | } |
1931 | memcpy((char *)save_leaf, (char *)tmp_leaf, state->blocksize); | 1870 | memcpy((char *)save_leaf, (char *)tmp_leaf, state->blocksize); |
1932 | kmem_free(tmpbuffer, state->blocksize); | 1871 | kmem_free(tmpbuffer, state->blocksize); |
@@ -1938,10 +1877,8 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, | |||
1938 | /* | 1877 | /* |
1939 | * Copy out last hashval in each block for B-tree code. | 1878 | * Copy out last hashval in each block for B-tree code. |
1940 | */ | 1879 | */ |
1941 | save_blk->hashval = | 1880 | save_blk->hashval = be32_to_cpu( |
1942 | INT_GET(save_leaf->entries[INT_GET(save_leaf->hdr.count, | 1881 | save_leaf->entries[be16_to_cpu(save_leaf->hdr.count)-1].hashval); |
1943 | ARCH_CONVERT)-1].hashval, | ||
1944 | ARCH_CONVERT); | ||
1945 | } | 1882 | } |
1946 | 1883 | ||
1947 | /*======================================================================== | 1884 | /*======================================================================== |
@@ -1972,48 +1909,45 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1972 | xfs_dahash_t hashval; | 1909 | xfs_dahash_t hashval; |
1973 | 1910 | ||
1974 | leaf = bp->data; | 1911 | leaf = bp->data; |
1975 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 1912 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1976 | == XFS_ATTR_LEAF_MAGIC); | 1913 | ASSERT(be16_to_cpu(leaf->hdr.count) |
1977 | ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) | ||
1978 | < (XFS_LBSIZE(args->dp->i_mount)/8)); | 1914 | < (XFS_LBSIZE(args->dp->i_mount)/8)); |
1979 | 1915 | ||
1980 | /* | 1916 | /* |
1981 | * Binary search. (note: small blocks will skip this loop) | 1917 | * Binary search. (note: small blocks will skip this loop) |
1982 | */ | 1918 | */ |
1983 | hashval = args->hashval; | 1919 | hashval = args->hashval; |
1984 | probe = span = INT_GET(leaf->hdr.count, ARCH_CONVERT) / 2; | 1920 | probe = span = be16_to_cpu(leaf->hdr.count) / 2; |
1985 | for (entry = &leaf->entries[probe]; span > 4; | 1921 | for (entry = &leaf->entries[probe]; span > 4; |
1986 | entry = &leaf->entries[probe]) { | 1922 | entry = &leaf->entries[probe]) { |
1987 | span /= 2; | 1923 | span /= 2; |
1988 | if (INT_GET(entry->hashval, ARCH_CONVERT) < hashval) | 1924 | if (be32_to_cpu(entry->hashval) < hashval) |
1989 | probe += span; | 1925 | probe += span; |
1990 | else if (INT_GET(entry->hashval, ARCH_CONVERT) > hashval) | 1926 | else if (be32_to_cpu(entry->hashval) > hashval) |
1991 | probe -= span; | 1927 | probe -= span; |
1992 | else | 1928 | else |
1993 | break; | 1929 | break; |
1994 | } | 1930 | } |
1995 | ASSERT((probe >= 0) && | 1931 | ASSERT((probe >= 0) && |
1996 | (!leaf->hdr.count | 1932 | (!leaf->hdr.count |
1997 | || (probe < INT_GET(leaf->hdr.count, ARCH_CONVERT)))); | 1933 | || (probe < be16_to_cpu(leaf->hdr.count)))); |
1998 | ASSERT((span <= 4) || (INT_GET(entry->hashval, ARCH_CONVERT) | 1934 | ASSERT((span <= 4) || (be32_to_cpu(entry->hashval) == hashval)); |
1999 | == hashval)); | ||
2000 | 1935 | ||
2001 | /* | 1936 | /* |
2002 | * Since we may have duplicate hashval's, find the first matching | 1937 | * Since we may have duplicate hashval's, find the first matching |
2003 | * hashval in the leaf. | 1938 | * hashval in the leaf. |
2004 | */ | 1939 | */ |
2005 | while ((probe > 0) && (INT_GET(entry->hashval, ARCH_CONVERT) | 1940 | while ((probe > 0) && (be32_to_cpu(entry->hashval) >= hashval)) { |
2006 | >= hashval)) { | ||
2007 | entry--; | 1941 | entry--; |
2008 | probe--; | 1942 | probe--; |
2009 | } | 1943 | } |
2010 | while ((probe < INT_GET(leaf->hdr.count, ARCH_CONVERT)) | 1944 | while ((probe < be16_to_cpu(leaf->hdr.count)) && |
2011 | && (INT_GET(entry->hashval, ARCH_CONVERT) < hashval)) { | 1945 | (be32_to_cpu(entry->hashval) < hashval)) { |
2012 | entry++; | 1946 | entry++; |
2013 | probe++; | 1947 | probe++; |
2014 | } | 1948 | } |
2015 | if ((probe == INT_GET(leaf->hdr.count, ARCH_CONVERT)) | 1949 | if ((probe == be16_to_cpu(leaf->hdr.count)) || |
2016 | || (INT_GET(entry->hashval, ARCH_CONVERT) != hashval)) { | 1950 | (be32_to_cpu(entry->hashval) != hashval)) { |
2017 | args->index = probe; | 1951 | args->index = probe; |
2018 | return(XFS_ERROR(ENOATTR)); | 1952 | return(XFS_ERROR(ENOATTR)); |
2019 | } | 1953 | } |
@@ -2021,8 +1955,8 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
2021 | /* | 1955 | /* |
2022 | * Duplicate keys may be present, so search all of them for a match. | 1956 | * Duplicate keys may be present, so search all of them for a match. |
2023 | */ | 1957 | */ |
2024 | for ( ; (probe < INT_GET(leaf->hdr.count, ARCH_CONVERT)) | 1958 | for ( ; (probe < be16_to_cpu(leaf->hdr.count)) && |
2025 | && (INT_GET(entry->hashval, ARCH_CONVERT) == hashval); | 1959 | (be32_to_cpu(entry->hashval) == hashval); |
2026 | entry++, probe++) { | 1960 | entry++, probe++) { |
2027 | /* | 1961 | /* |
2028 | * GROT: Add code to remove incomplete entries. | 1962 | * GROT: Add code to remove incomplete entries. |
@@ -2064,11 +1998,9 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
2064 | ((entry->flags & XFS_ATTR_ROOT) != 0)) | 1998 | ((entry->flags & XFS_ATTR_ROOT) != 0)) |
2065 | continue; | 1999 | continue; |
2066 | args->index = probe; | 2000 | args->index = probe; |
2067 | args->rmtblkno | 2001 | args->rmtblkno = be32_to_cpu(name_rmt->valueblk); |
2068 | = INT_GET(name_rmt->valueblk, ARCH_CONVERT); | ||
2069 | args->rmtblkcnt = XFS_B_TO_FSB(args->dp->i_mount, | 2002 | args->rmtblkcnt = XFS_B_TO_FSB(args->dp->i_mount, |
2070 | INT_GET(name_rmt->valuelen, | 2003 | be32_to_cpu(name_rmt->valuelen)); |
2071 | ARCH_CONVERT)); | ||
2072 | return(XFS_ERROR(EEXIST)); | 2004 | return(XFS_ERROR(EEXIST)); |
2073 | } | 2005 | } |
2074 | } | 2006 | } |
@@ -2090,18 +2022,17 @@ xfs_attr_leaf_getvalue(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
2090 | xfs_attr_leaf_name_remote_t *name_rmt; | 2022 | xfs_attr_leaf_name_remote_t *name_rmt; |
2091 | 2023 | ||
2092 | leaf = bp->data; | 2024 | leaf = bp->data; |
2093 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 2025 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2094 | == XFS_ATTR_LEAF_MAGIC); | 2026 | ASSERT(be16_to_cpu(leaf->hdr.count) |
2095 | ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) | ||
2096 | < (XFS_LBSIZE(args->dp->i_mount)/8)); | 2027 | < (XFS_LBSIZE(args->dp->i_mount)/8)); |
2097 | ASSERT(args->index < ((int)INT_GET(leaf->hdr.count, ARCH_CONVERT))); | 2028 | ASSERT(args->index < be16_to_cpu(leaf->hdr.count)); |
2098 | 2029 | ||
2099 | entry = &leaf->entries[args->index]; | 2030 | entry = &leaf->entries[args->index]; |
2100 | if (entry->flags & XFS_ATTR_LOCAL) { | 2031 | if (entry->flags & XFS_ATTR_LOCAL) { |
2101 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, args->index); | 2032 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, args->index); |
2102 | ASSERT(name_loc->namelen == args->namelen); | 2033 | ASSERT(name_loc->namelen == args->namelen); |
2103 | ASSERT(memcmp(args->name, name_loc->nameval, args->namelen) == 0); | 2034 | ASSERT(memcmp(args->name, name_loc->nameval, args->namelen) == 0); |
2104 | valuelen = INT_GET(name_loc->valuelen, ARCH_CONVERT); | 2035 | valuelen = be16_to_cpu(name_loc->valuelen); |
2105 | if (args->flags & ATTR_KERNOVAL) { | 2036 | if (args->flags & ATTR_KERNOVAL) { |
2106 | args->valuelen = valuelen; | 2037 | args->valuelen = valuelen; |
2107 | return(0); | 2038 | return(0); |
@@ -2116,8 +2047,8 @@ xfs_attr_leaf_getvalue(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
2116 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index); | 2047 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index); |
2117 | ASSERT(name_rmt->namelen == args->namelen); | 2048 | ASSERT(name_rmt->namelen == args->namelen); |
2118 | ASSERT(memcmp(args->name, name_rmt->name, args->namelen) == 0); | 2049 | ASSERT(memcmp(args->name, name_rmt->name, args->namelen) == 0); |
2119 | valuelen = INT_GET(name_rmt->valuelen, ARCH_CONVERT); | 2050 | valuelen = be32_to_cpu(name_rmt->valuelen); |
2120 | args->rmtblkno = INT_GET(name_rmt->valueblk, ARCH_CONVERT); | 2051 | args->rmtblkno = be32_to_cpu(name_rmt->valueblk); |
2121 | args->rmtblkcnt = XFS_B_TO_FSB(args->dp->i_mount, valuelen); | 2052 | args->rmtblkcnt = XFS_B_TO_FSB(args->dp->i_mount, valuelen); |
2122 | if (args->flags & ATTR_KERNOVAL) { | 2053 | if (args->flags & ATTR_KERNOVAL) { |
2123 | args->valuelen = valuelen; | 2054 | args->valuelen = valuelen; |
@@ -2159,32 +2090,29 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s, | |||
2159 | /* | 2090 | /* |
2160 | * Set up environment. | 2091 | * Set up environment. |
2161 | */ | 2092 | */ |
2162 | ASSERT(INT_GET(leaf_s->hdr.info.magic, ARCH_CONVERT) | 2093 | ASSERT(be16_to_cpu(leaf_s->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2163 | == XFS_ATTR_LEAF_MAGIC); | 2094 | ASSERT(be16_to_cpu(leaf_d->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2164 | ASSERT(INT_GET(leaf_d->hdr.info.magic, ARCH_CONVERT) | ||
2165 | == XFS_ATTR_LEAF_MAGIC); | ||
2166 | hdr_s = &leaf_s->hdr; | 2095 | hdr_s = &leaf_s->hdr; |
2167 | hdr_d = &leaf_d->hdr; | 2096 | hdr_d = &leaf_d->hdr; |
2168 | ASSERT((INT_GET(hdr_s->count, ARCH_CONVERT) > 0) | 2097 | ASSERT((be16_to_cpu(hdr_s->count) > 0) && |
2169 | && (INT_GET(hdr_s->count, ARCH_CONVERT) | 2098 | (be16_to_cpu(hdr_s->count) < (XFS_LBSIZE(mp)/8))); |
2170 | < (XFS_LBSIZE(mp)/8))); | 2099 | ASSERT(be16_to_cpu(hdr_s->firstused) >= |
2171 | ASSERT(INT_GET(hdr_s->firstused, ARCH_CONVERT) >= | 2100 | ((be16_to_cpu(hdr_s->count) |
2172 | ((INT_GET(hdr_s->count, ARCH_CONVERT) | ||
2173 | * sizeof(*entry_s))+sizeof(*hdr_s))); | 2101 | * sizeof(*entry_s))+sizeof(*hdr_s))); |
2174 | ASSERT(INT_GET(hdr_d->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8)); | 2102 | ASSERT(be16_to_cpu(hdr_d->count) < (XFS_LBSIZE(mp)/8)); |
2175 | ASSERT(INT_GET(hdr_d->firstused, ARCH_CONVERT) >= | 2103 | ASSERT(be16_to_cpu(hdr_d->firstused) >= |
2176 | ((INT_GET(hdr_d->count, ARCH_CONVERT) | 2104 | ((be16_to_cpu(hdr_d->count) |
2177 | * sizeof(*entry_d))+sizeof(*hdr_d))); | 2105 | * sizeof(*entry_d))+sizeof(*hdr_d))); |
2178 | 2106 | ||
2179 | ASSERT(start_s < INT_GET(hdr_s->count, ARCH_CONVERT)); | 2107 | ASSERT(start_s < be16_to_cpu(hdr_s->count)); |
2180 | ASSERT(start_d <= INT_GET(hdr_d->count, ARCH_CONVERT)); | 2108 | ASSERT(start_d <= be16_to_cpu(hdr_d->count)); |
2181 | ASSERT(count <= INT_GET(hdr_s->count, ARCH_CONVERT)); | 2109 | ASSERT(count <= be16_to_cpu(hdr_s->count)); |
2182 | 2110 | ||
2183 | /* | 2111 | /* |
2184 | * Move the entries in the destination leaf up to make a hole? | 2112 | * Move the entries in the destination leaf up to make a hole? |
2185 | */ | 2113 | */ |
2186 | if (start_d < INT_GET(hdr_d->count, ARCH_CONVERT)) { | 2114 | if (start_d < be16_to_cpu(hdr_d->count)) { |
2187 | tmp = INT_GET(hdr_d->count, ARCH_CONVERT) - start_d; | 2115 | tmp = be16_to_cpu(hdr_d->count) - start_d; |
2188 | tmp *= sizeof(xfs_attr_leaf_entry_t); | 2116 | tmp *= sizeof(xfs_attr_leaf_entry_t); |
2189 | entry_s = &leaf_d->entries[start_d]; | 2117 | entry_s = &leaf_d->entries[start_d]; |
2190 | entry_d = &leaf_d->entries[start_d + count]; | 2118 | entry_d = &leaf_d->entries[start_d + count]; |
@@ -2199,8 +2127,8 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s, | |||
2199 | entry_d = &leaf_d->entries[start_d]; | 2127 | entry_d = &leaf_d->entries[start_d]; |
2200 | desti = start_d; | 2128 | desti = start_d; |
2201 | for (i = 0; i < count; entry_s++, entry_d++, desti++, i++) { | 2129 | for (i = 0; i < count; entry_s++, entry_d++, desti++, i++) { |
2202 | ASSERT(INT_GET(entry_s->nameidx, ARCH_CONVERT) | 2130 | ASSERT(be16_to_cpu(entry_s->nameidx) |
2203 | >= INT_GET(hdr_s->firstused, ARCH_CONVERT)); | 2131 | >= be16_to_cpu(hdr_s->firstused)); |
2204 | tmp = xfs_attr_leaf_entsize(leaf_s, start_s + i); | 2132 | tmp = xfs_attr_leaf_entsize(leaf_s, start_s + i); |
2205 | #ifdef GROT | 2133 | #ifdef GROT |
2206 | /* | 2134 | /* |
@@ -2210,35 +2138,35 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s, | |||
2210 | */ | 2138 | */ |
2211 | if (entry_s->flags & XFS_ATTR_INCOMPLETE) { /* skip partials? */ | 2139 | if (entry_s->flags & XFS_ATTR_INCOMPLETE) { /* skip partials? */ |
2212 | memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp); | 2140 | memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp); |
2213 | INT_MOD(hdr_s->usedbytes, ARCH_CONVERT, -tmp); | 2141 | be16_add(&hdr_s->usedbytes, -tmp); |
2214 | INT_MOD(hdr_s->count, ARCH_CONVERT, -1); | 2142 | be16_add(&hdr_s->count, -1); |
2215 | entry_d--; /* to compensate for ++ in loop hdr */ | 2143 | entry_d--; /* to compensate for ++ in loop hdr */ |
2216 | desti--; | 2144 | desti--; |
2217 | if ((start_s + i) < offset) | 2145 | if ((start_s + i) < offset) |
2218 | result++; /* insertion index adjustment */ | 2146 | result++; /* insertion index adjustment */ |
2219 | } else { | 2147 | } else { |
2220 | #endif /* GROT */ | 2148 | #endif /* GROT */ |
2221 | INT_MOD(hdr_d->firstused, ARCH_CONVERT, -tmp); | 2149 | be16_add(&hdr_d->firstused, -tmp); |
2222 | /* both on-disk, don't endian flip twice */ | 2150 | /* both on-disk, don't endian flip twice */ |
2223 | entry_d->hashval = entry_s->hashval; | 2151 | entry_d->hashval = entry_s->hashval; |
2224 | /* both on-disk, don't endian flip twice */ | 2152 | /* both on-disk, don't endian flip twice */ |
2225 | entry_d->nameidx = hdr_d->firstused; | 2153 | entry_d->nameidx = hdr_d->firstused; |
2226 | entry_d->flags = entry_s->flags; | 2154 | entry_d->flags = entry_s->flags; |
2227 | ASSERT(INT_GET(entry_d->nameidx, ARCH_CONVERT) + tmp | 2155 | ASSERT(be16_to_cpu(entry_d->nameidx) + tmp |
2228 | <= XFS_LBSIZE(mp)); | 2156 | <= XFS_LBSIZE(mp)); |
2229 | memmove(XFS_ATTR_LEAF_NAME(leaf_d, desti), | 2157 | memmove(XFS_ATTR_LEAF_NAME(leaf_d, desti), |
2230 | XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), tmp); | 2158 | XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), tmp); |
2231 | ASSERT(INT_GET(entry_s->nameidx, ARCH_CONVERT) + tmp | 2159 | ASSERT(be16_to_cpu(entry_s->nameidx) + tmp |
2232 | <= XFS_LBSIZE(mp)); | 2160 | <= XFS_LBSIZE(mp)); |
2233 | memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp); | 2161 | memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp); |
2234 | INT_MOD(hdr_s->usedbytes, ARCH_CONVERT, -tmp); | 2162 | be16_add(&hdr_s->usedbytes, -tmp); |
2235 | INT_MOD(hdr_d->usedbytes, ARCH_CONVERT, tmp); | 2163 | be16_add(&hdr_d->usedbytes, tmp); |
2236 | INT_MOD(hdr_s->count, ARCH_CONVERT, -1); | 2164 | be16_add(&hdr_s->count, -1); |
2237 | INT_MOD(hdr_d->count, ARCH_CONVERT, 1); | 2165 | be16_add(&hdr_d->count, 1); |
2238 | tmp = INT_GET(hdr_d->count, ARCH_CONVERT) | 2166 | tmp = be16_to_cpu(hdr_d->count) |
2239 | * sizeof(xfs_attr_leaf_entry_t) | 2167 | * sizeof(xfs_attr_leaf_entry_t) |
2240 | + sizeof(xfs_attr_leaf_hdr_t); | 2168 | + sizeof(xfs_attr_leaf_hdr_t); |
2241 | ASSERT(INT_GET(hdr_d->firstused, ARCH_CONVERT) >= tmp); | 2169 | ASSERT(be16_to_cpu(hdr_d->firstused) >= tmp); |
2242 | #ifdef GROT | 2170 | #ifdef GROT |
2243 | } | 2171 | } |
2244 | #endif /* GROT */ | 2172 | #endif /* GROT */ |
@@ -2247,7 +2175,7 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s, | |||
2247 | /* | 2175 | /* |
2248 | * Zero out the entries we just copied. | 2176 | * Zero out the entries we just copied. |
2249 | */ | 2177 | */ |
2250 | if (start_s == INT_GET(hdr_s->count, ARCH_CONVERT)) { | 2178 | if (start_s == be16_to_cpu(hdr_s->count)) { |
2251 | tmp = count * sizeof(xfs_attr_leaf_entry_t); | 2179 | tmp = count * sizeof(xfs_attr_leaf_entry_t); |
2252 | entry_s = &leaf_s->entries[start_s]; | 2180 | entry_s = &leaf_s->entries[start_s]; |
2253 | ASSERT(((char *)entry_s + tmp) <= | 2181 | ASSERT(((char *)entry_s + tmp) <= |
@@ -2258,15 +2186,14 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s, | |||
2258 | * Move the remaining entries down to fill the hole, | 2186 | * Move the remaining entries down to fill the hole, |
2259 | * then zero the entries at the top. | 2187 | * then zero the entries at the top. |
2260 | */ | 2188 | */ |
2261 | tmp = INT_GET(hdr_s->count, ARCH_CONVERT) - count; | 2189 | tmp = be16_to_cpu(hdr_s->count) - count; |
2262 | tmp *= sizeof(xfs_attr_leaf_entry_t); | 2190 | tmp *= sizeof(xfs_attr_leaf_entry_t); |
2263 | entry_s = &leaf_s->entries[start_s + count]; | 2191 | entry_s = &leaf_s->entries[start_s + count]; |
2264 | entry_d = &leaf_s->entries[start_s]; | 2192 | entry_d = &leaf_s->entries[start_s]; |
2265 | memmove((char *)entry_d, (char *)entry_s, tmp); | 2193 | memmove((char *)entry_d, (char *)entry_s, tmp); |
2266 | 2194 | ||
2267 | tmp = count * sizeof(xfs_attr_leaf_entry_t); | 2195 | tmp = count * sizeof(xfs_attr_leaf_entry_t); |
2268 | entry_s = &leaf_s->entries[INT_GET(hdr_s->count, | 2196 | entry_s = &leaf_s->entries[be16_to_cpu(hdr_s->count)]; |
2269 | ARCH_CONVERT)]; | ||
2270 | ASSERT(((char *)entry_s + tmp) <= | 2197 | ASSERT(((char *)entry_s + tmp) <= |
2271 | ((char *)leaf_s + XFS_LBSIZE(mp))); | 2198 | ((char *)leaf_s + XFS_LBSIZE(mp))); |
2272 | memset((char *)entry_s, 0, tmp); | 2199 | memset((char *)entry_s, 0, tmp); |
@@ -2275,14 +2202,11 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s, | |||
2275 | /* | 2202 | /* |
2276 | * Fill in the freemap information | 2203 | * Fill in the freemap information |
2277 | */ | 2204 | */ |
2278 | INT_SET(hdr_d->freemap[0].base, ARCH_CONVERT, | 2205 | hdr_d->freemap[0].base = cpu_to_be16(sizeof(xfs_attr_leaf_hdr_t)); |
2279 | sizeof(xfs_attr_leaf_hdr_t)); | 2206 | be16_add(&hdr_d->freemap[0].base, be16_to_cpu(hdr_d->count) * |
2280 | INT_MOD(hdr_d->freemap[0].base, ARCH_CONVERT, | 2207 | sizeof(xfs_attr_leaf_entry_t)); |
2281 | INT_GET(hdr_d->count, ARCH_CONVERT) | 2208 | hdr_d->freemap[0].size = cpu_to_be16(be16_to_cpu(hdr_d->firstused) |
2282 | * sizeof(xfs_attr_leaf_entry_t)); | 2209 | - be16_to_cpu(hdr_d->freemap[0].base)); |
2283 | INT_SET(hdr_d->freemap[0].size, ARCH_CONVERT, | ||
2284 | INT_GET(hdr_d->firstused, ARCH_CONVERT) | ||
2285 | - INT_GET(hdr_d->freemap[0].base, ARCH_CONVERT)); | ||
2286 | hdr_d->freemap[1].base = 0; | 2210 | hdr_d->freemap[1].base = 0; |
2287 | hdr_d->freemap[2].base = 0; | 2211 | hdr_d->freemap[2].base = 0; |
2288 | hdr_d->freemap[1].size = 0; | 2212 | hdr_d->freemap[1].size = 0; |
@@ -2301,18 +2225,16 @@ xfs_attr_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp) | |||
2301 | 2225 | ||
2302 | leaf1 = leaf1_bp->data; | 2226 | leaf1 = leaf1_bp->data; |
2303 | leaf2 = leaf2_bp->data; | 2227 | leaf2 = leaf2_bp->data; |
2304 | ASSERT((INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) | 2228 | ASSERT((be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC) && |
2305 | == XFS_ATTR_LEAF_MAGIC) && | 2229 | (be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC)); |
2306 | (INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) | 2230 | if ((be16_to_cpu(leaf1->hdr.count) > 0) && |
2307 | == XFS_ATTR_LEAF_MAGIC)); | 2231 | (be16_to_cpu(leaf2->hdr.count) > 0) && |
2308 | if ( (INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0) | 2232 | ((be32_to_cpu(leaf2->entries[0].hashval) < |
2309 | && (INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0) | 2233 | be32_to_cpu(leaf1->entries[0].hashval)) || |
2310 | && ( (INT_GET(leaf2->entries[ 0 ].hashval, ARCH_CONVERT) < | 2234 | (be32_to_cpu(leaf2->entries[ |
2311 | INT_GET(leaf1->entries[ 0 ].hashval, ARCH_CONVERT)) | 2235 | be16_to_cpu(leaf2->hdr.count)-1].hashval) < |
2312 | || (INT_GET(leaf2->entries[INT_GET(leaf2->hdr.count, | 2236 | be32_to_cpu(leaf1->entries[ |
2313 | ARCH_CONVERT)-1].hashval, ARCH_CONVERT) < | 2237 | be16_to_cpu(leaf1->hdr.count)-1].hashval)))) { |
2314 | INT_GET(leaf1->entries[INT_GET(leaf1->hdr.count, | ||
2315 | ARCH_CONVERT)-1].hashval, ARCH_CONVERT))) ) { | ||
2316 | return(1); | 2238 | return(1); |
2317 | } | 2239 | } |
2318 | return(0); | 2240 | return(0); |
@@ -2327,14 +2249,12 @@ xfs_attr_leaf_lasthash(xfs_dabuf_t *bp, int *count) | |||
2327 | xfs_attr_leafblock_t *leaf; | 2249 | xfs_attr_leafblock_t *leaf; |
2328 | 2250 | ||
2329 | leaf = bp->data; | 2251 | leaf = bp->data; |
2330 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 2252 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2331 | == XFS_ATTR_LEAF_MAGIC); | ||
2332 | if (count) | 2253 | if (count) |
2333 | *count = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 2254 | *count = be16_to_cpu(leaf->hdr.count); |
2334 | if (!leaf->hdr.count) | 2255 | if (!leaf->hdr.count) |
2335 | return(0); | 2256 | return(0); |
2336 | return(INT_GET(leaf->entries[INT_GET(leaf->hdr.count, | 2257 | return be32_to_cpu(leaf->entries[be16_to_cpu(leaf->hdr.count)-1].hashval); |
2337 | ARCH_CONVERT)-1].hashval, ARCH_CONVERT)); | ||
2338 | } | 2258 | } |
2339 | 2259 | ||
2340 | /* | 2260 | /* |
@@ -2348,13 +2268,11 @@ xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index) | |||
2348 | xfs_attr_leaf_name_remote_t *name_rmt; | 2268 | xfs_attr_leaf_name_remote_t *name_rmt; |
2349 | int size; | 2269 | int size; |
2350 | 2270 | ||
2351 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 2271 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2352 | == XFS_ATTR_LEAF_MAGIC); | ||
2353 | if (leaf->entries[index].flags & XFS_ATTR_LOCAL) { | 2272 | if (leaf->entries[index].flags & XFS_ATTR_LOCAL) { |
2354 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, index); | 2273 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, index); |
2355 | size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(name_loc->namelen, | 2274 | size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(name_loc->namelen, |
2356 | INT_GET(name_loc->valuelen, | 2275 | be16_to_cpu(name_loc->valuelen)); |
2357 | ARCH_CONVERT)); | ||
2358 | } else { | 2276 | } else { |
2359 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, index); | 2277 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, index); |
2360 | size = XFS_ATTR_LEAF_ENTSIZE_REMOTE(name_rmt->namelen); | 2278 | size = XFS_ATTR_LEAF_ENTSIZE_REMOTE(name_rmt->namelen); |
@@ -2412,22 +2330,20 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context) | |||
2412 | */ | 2330 | */ |
2413 | if (context->resynch) { | 2331 | if (context->resynch) { |
2414 | entry = &leaf->entries[0]; | 2332 | entry = &leaf->entries[0]; |
2415 | for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); | 2333 | for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) { |
2416 | entry++, i++) { | 2334 | if (be32_to_cpu(entry->hashval) == cursor->hashval) { |
2417 | if (INT_GET(entry->hashval, ARCH_CONVERT) | ||
2418 | == cursor->hashval) { | ||
2419 | if (cursor->offset == context->dupcnt) { | 2335 | if (cursor->offset == context->dupcnt) { |
2420 | context->dupcnt = 0; | 2336 | context->dupcnt = 0; |
2421 | break; | 2337 | break; |
2422 | } | 2338 | } |
2423 | context->dupcnt++; | 2339 | context->dupcnt++; |
2424 | } else if (INT_GET(entry->hashval, ARCH_CONVERT) | 2340 | } else if (be32_to_cpu(entry->hashval) > |
2425 | > cursor->hashval) { | 2341 | cursor->hashval) { |
2426 | context->dupcnt = 0; | 2342 | context->dupcnt = 0; |
2427 | break; | 2343 | break; |
2428 | } | 2344 | } |
2429 | } | 2345 | } |
2430 | if (i == INT_GET(leaf->hdr.count, ARCH_CONVERT)) { | 2346 | if (i == be16_to_cpu(leaf->hdr.count)) { |
2431 | xfs_attr_trace_l_c("not found", context); | 2347 | xfs_attr_trace_l_c("not found", context); |
2432 | return(0); | 2348 | return(0); |
2433 | } | 2349 | } |
@@ -2441,12 +2357,12 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context) | |||
2441 | * We have found our place, start copying out the new attributes. | 2357 | * We have found our place, start copying out the new attributes. |
2442 | */ | 2358 | */ |
2443 | retval = 0; | 2359 | retval = 0; |
2444 | for ( ; (i < INT_GET(leaf->hdr.count, ARCH_CONVERT)) | 2360 | for ( ; (i < be16_to_cpu(leaf->hdr.count)) |
2445 | && (retval == 0); entry++, i++) { | 2361 | && (retval == 0); entry++, i++) { |
2446 | attrnames_t *namesp; | 2362 | attrnames_t *namesp; |
2447 | 2363 | ||
2448 | if (INT_GET(entry->hashval, ARCH_CONVERT) != cursor->hashval) { | 2364 | if (be32_to_cpu(entry->hashval) != cursor->hashval) { |
2449 | cursor->hashval = INT_GET(entry->hashval, ARCH_CONVERT); | 2365 | cursor->hashval = be32_to_cpu(entry->hashval); |
2450 | cursor->offset = 0; | 2366 | cursor->offset = 0; |
2451 | } | 2367 | } |
2452 | 2368 | ||
@@ -2475,8 +2391,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context) | |||
2475 | retval = xfs_attr_put_listent(context, namesp, | 2391 | retval = xfs_attr_put_listent(context, namesp, |
2476 | (char *)name_loc->nameval, | 2392 | (char *)name_loc->nameval, |
2477 | (int)name_loc->namelen, | 2393 | (int)name_loc->namelen, |
2478 | (int)INT_GET(name_loc->valuelen, | 2394 | be16_to_cpu(name_loc->valuelen)); |
2479 | ARCH_CONVERT)); | ||
2480 | } | 2395 | } |
2481 | } else { | 2396 | } else { |
2482 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i); | 2397 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i); |
@@ -2488,8 +2403,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context) | |||
2488 | retval = xfs_attr_put_listent(context, namesp, | 2403 | retval = xfs_attr_put_listent(context, namesp, |
2489 | (char *)name_rmt->name, | 2404 | (char *)name_rmt->name, |
2490 | (int)name_rmt->namelen, | 2405 | (int)name_rmt->namelen, |
2491 | (int)INT_GET(name_rmt->valuelen, | 2406 | be32_to_cpu(name_rmt->valuelen)); |
2492 | ARCH_CONVERT)); | ||
2493 | } | 2407 | } |
2494 | } | 2408 | } |
2495 | if (retval == 0) { | 2409 | if (retval == 0) { |
@@ -2596,9 +2510,8 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args) | |||
2596 | ASSERT(bp != NULL); | 2510 | ASSERT(bp != NULL); |
2597 | 2511 | ||
2598 | leaf = bp->data; | 2512 | leaf = bp->data; |
2599 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 2513 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2600 | == XFS_ATTR_LEAF_MAGIC); | 2514 | ASSERT(args->index < be16_to_cpu(leaf->hdr.count)); |
2601 | ASSERT(args->index < INT_GET(leaf->hdr.count, ARCH_CONVERT)); | ||
2602 | ASSERT(args->index >= 0); | 2515 | ASSERT(args->index >= 0); |
2603 | entry = &leaf->entries[ args->index ]; | 2516 | entry = &leaf->entries[ args->index ]; |
2604 | ASSERT(entry->flags & XFS_ATTR_INCOMPLETE); | 2517 | ASSERT(entry->flags & XFS_ATTR_INCOMPLETE); |
@@ -2613,7 +2526,7 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args) | |||
2613 | namelen = name_rmt->namelen; | 2526 | namelen = name_rmt->namelen; |
2614 | name = (char *)name_rmt->name; | 2527 | name = (char *)name_rmt->name; |
2615 | } | 2528 | } |
2616 | ASSERT(INT_GET(entry->hashval, ARCH_CONVERT) == args->hashval); | 2529 | ASSERT(be32_to_cpu(entry->hashval) == args->hashval); |
2617 | ASSERT(namelen == args->namelen); | 2530 | ASSERT(namelen == args->namelen); |
2618 | ASSERT(memcmp(name, args->name, namelen) == 0); | 2531 | ASSERT(memcmp(name, args->name, namelen) == 0); |
2619 | #endif /* DEBUG */ | 2532 | #endif /* DEBUG */ |
@@ -2625,8 +2538,8 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args) | |||
2625 | if (args->rmtblkno) { | 2538 | if (args->rmtblkno) { |
2626 | ASSERT((entry->flags & XFS_ATTR_LOCAL) == 0); | 2539 | ASSERT((entry->flags & XFS_ATTR_LOCAL) == 0); |
2627 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index); | 2540 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index); |
2628 | INT_SET(name_rmt->valueblk, ARCH_CONVERT, args->rmtblkno); | 2541 | name_rmt->valueblk = cpu_to_be32(args->rmtblkno); |
2629 | INT_SET(name_rmt->valuelen, ARCH_CONVERT, args->valuelen); | 2542 | name_rmt->valuelen = cpu_to_be32(args->valuelen); |
2630 | xfs_da_log_buf(args->trans, bp, | 2543 | xfs_da_log_buf(args->trans, bp, |
2631 | XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt))); | 2544 | XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt))); |
2632 | } | 2545 | } |
@@ -2663,9 +2576,8 @@ xfs_attr_leaf_setflag(xfs_da_args_t *args) | |||
2663 | ASSERT(bp != NULL); | 2576 | ASSERT(bp != NULL); |
2664 | 2577 | ||
2665 | leaf = bp->data; | 2578 | leaf = bp->data; |
2666 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 2579 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2667 | == XFS_ATTR_LEAF_MAGIC); | 2580 | ASSERT(args->index < be16_to_cpu(leaf->hdr.count)); |
2668 | ASSERT(args->index < INT_GET(leaf->hdr.count, ARCH_CONVERT)); | ||
2669 | ASSERT(args->index >= 0); | 2581 | ASSERT(args->index >= 0); |
2670 | entry = &leaf->entries[ args->index ]; | 2582 | entry = &leaf->entries[ args->index ]; |
2671 | 2583 | ||
@@ -2736,16 +2648,14 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args) | |||
2736 | } | 2648 | } |
2737 | 2649 | ||
2738 | leaf1 = bp1->data; | 2650 | leaf1 = bp1->data; |
2739 | ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) | 2651 | ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2740 | == XFS_ATTR_LEAF_MAGIC); | 2652 | ASSERT(args->index < be16_to_cpu(leaf1->hdr.count)); |
2741 | ASSERT(args->index < INT_GET(leaf1->hdr.count, ARCH_CONVERT)); | ||
2742 | ASSERT(args->index >= 0); | 2653 | ASSERT(args->index >= 0); |
2743 | entry1 = &leaf1->entries[ args->index ]; | 2654 | entry1 = &leaf1->entries[ args->index ]; |
2744 | 2655 | ||
2745 | leaf2 = bp2->data; | 2656 | leaf2 = bp2->data; |
2746 | ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) | 2657 | ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2747 | == XFS_ATTR_LEAF_MAGIC); | 2658 | ASSERT(args->index2 < be16_to_cpu(leaf2->hdr.count)); |
2748 | ASSERT(args->index2 < INT_GET(leaf2->hdr.count, ARCH_CONVERT)); | ||
2749 | ASSERT(args->index2 >= 0); | 2659 | ASSERT(args->index2 >= 0); |
2750 | entry2 = &leaf2->entries[ args->index2 ]; | 2660 | entry2 = &leaf2->entries[ args->index2 ]; |
2751 | 2661 | ||
@@ -2768,7 +2678,7 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args) | |||
2768 | namelen2 = name_rmt->namelen; | 2678 | namelen2 = name_rmt->namelen; |
2769 | name2 = (char *)name_rmt->name; | 2679 | name2 = (char *)name_rmt->name; |
2770 | } | 2680 | } |
2771 | ASSERT(INT_GET(entry1->hashval, ARCH_CONVERT) == INT_GET(entry2->hashval, ARCH_CONVERT)); | 2681 | ASSERT(be32_to_cpu(entry1->hashval) == be32_to_cpu(entry2->hashval)); |
2772 | ASSERT(namelen1 == namelen2); | 2682 | ASSERT(namelen1 == namelen2); |
2773 | ASSERT(memcmp(name1, name2, namelen1) == 0); | 2683 | ASSERT(memcmp(name1, name2, namelen1) == 0); |
2774 | #endif /* DEBUG */ | 2684 | #endif /* DEBUG */ |
@@ -2782,8 +2692,8 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args) | |||
2782 | if (args->rmtblkno) { | 2692 | if (args->rmtblkno) { |
2783 | ASSERT((entry1->flags & XFS_ATTR_LOCAL) == 0); | 2693 | ASSERT((entry1->flags & XFS_ATTR_LOCAL) == 0); |
2784 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf1, args->index); | 2694 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf1, args->index); |
2785 | INT_SET(name_rmt->valueblk, ARCH_CONVERT, args->rmtblkno); | 2695 | name_rmt->valueblk = cpu_to_be32(args->rmtblkno); |
2786 | INT_SET(name_rmt->valuelen, ARCH_CONVERT, args->valuelen); | 2696 | name_rmt->valuelen = cpu_to_be32(args->valuelen); |
2787 | xfs_da_log_buf(args->trans, bp1, | 2697 | xfs_da_log_buf(args->trans, bp1, |
2788 | XFS_DA_LOGRANGE(leaf1, name_rmt, sizeof(*name_rmt))); | 2698 | XFS_DA_LOGRANGE(leaf1, name_rmt, sizeof(*name_rmt))); |
2789 | } | 2699 | } |
@@ -2842,9 +2752,9 @@ xfs_attr_root_inactive(xfs_trans_t **trans, xfs_inode_t *dp) | |||
2842 | * This is a depth-first traversal! | 2752 | * This is a depth-first traversal! |
2843 | */ | 2753 | */ |
2844 | info = bp->data; | 2754 | info = bp->data; |
2845 | if (INT_GET(info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) { | 2755 | if (be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC) { |
2846 | error = xfs_attr_node_inactive(trans, dp, bp, 1); | 2756 | error = xfs_attr_node_inactive(trans, dp, bp, 1); |
2847 | } else if (INT_GET(info->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC) { | 2757 | } else if (be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC) { |
2848 | error = xfs_attr_leaf_inactive(trans, dp, bp); | 2758 | error = xfs_attr_leaf_inactive(trans, dp, bp); |
2849 | } else { | 2759 | } else { |
2850 | error = XFS_ERROR(EIO); | 2760 | error = XFS_ERROR(EIO); |
@@ -2892,15 +2802,14 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp, | |||
2892 | } | 2802 | } |
2893 | 2803 | ||
2894 | node = bp->data; | 2804 | node = bp->data; |
2895 | ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) | 2805 | ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
2896 | == XFS_DA_NODE_MAGIC); | ||
2897 | parent_blkno = xfs_da_blkno(bp); /* save for re-read later */ | 2806 | parent_blkno = xfs_da_blkno(bp); /* save for re-read later */ |
2898 | count = INT_GET(node->hdr.count, ARCH_CONVERT); | 2807 | count = be16_to_cpu(node->hdr.count); |
2899 | if (!count) { | 2808 | if (!count) { |
2900 | xfs_da_brelse(*trans, bp); | 2809 | xfs_da_brelse(*trans, bp); |
2901 | return(0); | 2810 | return(0); |
2902 | } | 2811 | } |
2903 | child_fsb = INT_GET(node->btree[0].before, ARCH_CONVERT); | 2812 | child_fsb = be32_to_cpu(node->btree[0].before); |
2904 | xfs_da_brelse(*trans, bp); /* no locks for later trans */ | 2813 | xfs_da_brelse(*trans, bp); /* no locks for later trans */ |
2905 | 2814 | ||
2906 | /* | 2815 | /* |
@@ -2927,12 +2836,10 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp, | |||
2927 | * Invalidate the subtree, however we have to. | 2836 | * Invalidate the subtree, however we have to. |
2928 | */ | 2837 | */ |
2929 | info = child_bp->data; | 2838 | info = child_bp->data; |
2930 | if (INT_GET(info->magic, ARCH_CONVERT) | 2839 | if (be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC) { |
2931 | == XFS_DA_NODE_MAGIC) { | ||
2932 | error = xfs_attr_node_inactive(trans, dp, | 2840 | error = xfs_attr_node_inactive(trans, dp, |
2933 | child_bp, level+1); | 2841 | child_bp, level+1); |
2934 | } else if (INT_GET(info->magic, ARCH_CONVERT) | 2842 | } else if (be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC) { |
2935 | == XFS_ATTR_LEAF_MAGIC) { | ||
2936 | error = xfs_attr_leaf_inactive(trans, dp, | 2843 | error = xfs_attr_leaf_inactive(trans, dp, |
2937 | child_bp); | 2844 | child_bp); |
2938 | } else { | 2845 | } else { |
@@ -2962,7 +2869,7 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp, | |||
2962 | &bp, XFS_ATTR_FORK); | 2869 | &bp, XFS_ATTR_FORK); |
2963 | if (error) | 2870 | if (error) |
2964 | return(error); | 2871 | return(error); |
2965 | child_fsb = INT_GET(node->btree[i+1].before, ARCH_CONVERT); | 2872 | child_fsb = be32_to_cpu(node->btree[i+1].before); |
2966 | xfs_da_brelse(*trans, bp); | 2873 | xfs_da_brelse(*trans, bp); |
2967 | } | 2874 | } |
2968 | /* | 2875 | /* |
@@ -2991,17 +2898,16 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp) | |||
2991 | int error, count, size, tmp, i; | 2898 | int error, count, size, tmp, i; |
2992 | 2899 | ||
2993 | leaf = bp->data; | 2900 | leaf = bp->data; |
2994 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 2901 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2995 | == XFS_ATTR_LEAF_MAGIC); | ||
2996 | 2902 | ||
2997 | /* | 2903 | /* |
2998 | * Count the number of "remote" value extents. | 2904 | * Count the number of "remote" value extents. |
2999 | */ | 2905 | */ |
3000 | count = 0; | 2906 | count = 0; |
3001 | entry = &leaf->entries[0]; | 2907 | entry = &leaf->entries[0]; |
3002 | for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); entry++, i++) { | 2908 | for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) { |
3003 | if ( INT_GET(entry->nameidx, ARCH_CONVERT) | 2909 | if (be16_to_cpu(entry->nameidx) && |
3004 | && ((entry->flags & XFS_ATTR_LOCAL) == 0)) { | 2910 | ((entry->flags & XFS_ATTR_LOCAL) == 0)) { |
3005 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i); | 2911 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i); |
3006 | if (name_rmt->valueblk) | 2912 | if (name_rmt->valueblk) |
3007 | count++; | 2913 | count++; |
@@ -3027,17 +2933,14 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp) | |||
3027 | */ | 2933 | */ |
3028 | lp = list; | 2934 | lp = list; |
3029 | entry = &leaf->entries[0]; | 2935 | entry = &leaf->entries[0]; |
3030 | for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); entry++, i++) { | 2936 | for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) { |
3031 | if ( INT_GET(entry->nameidx, ARCH_CONVERT) | 2937 | if (be16_to_cpu(entry->nameidx) && |
3032 | && ((entry->flags & XFS_ATTR_LOCAL) == 0)) { | 2938 | ((entry->flags & XFS_ATTR_LOCAL) == 0)) { |
3033 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i); | 2939 | name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i); |
3034 | if (name_rmt->valueblk) { | 2940 | if (name_rmt->valueblk) { |
3035 | /* both on-disk, don't endian flip twice */ | 2941 | lp->valueblk = be32_to_cpu(name_rmt->valueblk); |
3036 | lp->valueblk = name_rmt->valueblk; | 2942 | lp->valuelen = XFS_B_TO_FSB(dp->i_mount, |
3037 | INT_SET(lp->valuelen, ARCH_CONVERT, | 2943 | be32_to_cpu(name_rmt->valuelen)); |
3038 | XFS_B_TO_FSB(dp->i_mount, | ||
3039 | INT_GET(name_rmt->valuelen, | ||
3040 | ARCH_CONVERT))); | ||
3041 | lp++; | 2944 | lp++; |
3042 | } | 2945 | } |
3043 | } | 2946 | } |
@@ -3050,10 +2953,8 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp) | |||
3050 | error = 0; | 2953 | error = 0; |
3051 | for (lp = list, i = 0; i < count; i++, lp++) { | 2954 | for (lp = list, i = 0; i < count; i++, lp++) { |
3052 | tmp = xfs_attr_leaf_freextent(trans, dp, | 2955 | tmp = xfs_attr_leaf_freextent(trans, dp, |
3053 | INT_GET(lp->valueblk, | 2956 | lp->valueblk, lp->valuelen); |
3054 | ARCH_CONVERT), | 2957 | |
3055 | INT_GET(lp->valuelen, | ||
3056 | ARCH_CONVERT)); | ||
3057 | if (error == 0) | 2958 | if (error == 0) |
3058 | error = tmp; /* save only the 1st errno */ | 2959 | error = tmp; /* save only the 1st errno */ |
3059 | } | 2960 | } |