diff options
Diffstat (limited to 'fs/xfs/xfs_attr_leaf.c')
-rw-r--r-- | fs/xfs/xfs_attr_leaf.c | 99 |
1 files changed, 27 insertions, 72 deletions
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c index 303d41e4217b..23ef5d7c87e1 100644 --- a/fs/xfs/xfs_attr_leaf.c +++ b/fs/xfs/xfs_attr_leaf.c | |||
@@ -94,13 +94,6 @@ STATIC int xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index); | |||
94 | * Namespace helper routines | 94 | * Namespace helper routines |
95 | *========================================================================*/ | 95 | *========================================================================*/ |
96 | 96 | ||
97 | STATIC_INLINE attrnames_t * | ||
98 | xfs_attr_flags_namesp(int flags) | ||
99 | { | ||
100 | return ((flags & XFS_ATTR_SECURE) ? &attr_secure: | ||
101 | ((flags & XFS_ATTR_ROOT) ? &attr_trusted : &attr_user)); | ||
102 | } | ||
103 | |||
104 | /* | 97 | /* |
105 | * If namespace bits don't match return 0. | 98 | * If namespace bits don't match return 0. |
106 | * If all match then return 1. | 99 | * If all match then return 1. |
@@ -111,25 +104,6 @@ xfs_attr_namesp_match(int arg_flags, int ondisk_flags) | |||
111 | return XFS_ATTR_NSP_ONDISK(ondisk_flags) == XFS_ATTR_NSP_ARGS_TO_ONDISK(arg_flags); | 104 | return XFS_ATTR_NSP_ONDISK(ondisk_flags) == XFS_ATTR_NSP_ARGS_TO_ONDISK(arg_flags); |
112 | } | 105 | } |
113 | 106 | ||
114 | /* | ||
115 | * If namespace bits don't match and we don't have an override for it | ||
116 | * then return 0. | ||
117 | * If all match or are overridable then return 1. | ||
118 | */ | ||
119 | STATIC_INLINE int | ||
120 | xfs_attr_namesp_match_overrides(int arg_flags, int ondisk_flags) | ||
121 | { | ||
122 | if (((arg_flags & ATTR_SECURE) == 0) != | ||
123 | ((ondisk_flags & XFS_ATTR_SECURE) == 0) && | ||
124 | !(arg_flags & ATTR_KERNORMALS)) | ||
125 | return 0; | ||
126 | if (((arg_flags & ATTR_ROOT) == 0) != | ||
127 | ((ondisk_flags & XFS_ATTR_ROOT) == 0) && | ||
128 | !(arg_flags & ATTR_KERNROOTLS)) | ||
129 | return 0; | ||
130 | return 1; | ||
131 | } | ||
132 | |||
133 | 107 | ||
134 | /*======================================================================== | 108 | /*======================================================================== |
135 | * External routines when attribute fork size < XFS_LITINO(mp). | 109 | * External routines when attribute fork size < XFS_LITINO(mp). |
@@ -369,9 +343,10 @@ xfs_attr_shortform_remove(xfs_da_args_t *args) | |||
369 | * Fix up the start offset of the attribute fork | 343 | * Fix up the start offset of the attribute fork |
370 | */ | 344 | */ |
371 | totsize -= size; | 345 | totsize -= size; |
372 | if (totsize == sizeof(xfs_attr_sf_hdr_t) && !args->addname && | 346 | if (totsize == sizeof(xfs_attr_sf_hdr_t) && |
373 | (mp->m_flags & XFS_MOUNT_ATTR2) && | 347 | !(args->op_flags & XFS_DA_OP_ADDNAME) && |
374 | (dp->i_d.di_format != XFS_DINODE_FMT_BTREE)) { | 348 | (mp->m_flags & XFS_MOUNT_ATTR2) && |
349 | (dp->i_d.di_format != XFS_DINODE_FMT_BTREE)) { | ||
375 | /* | 350 | /* |
376 | * Last attribute now removed, revert to original | 351 | * Last attribute now removed, revert to original |
377 | * inode format making all literal area available | 352 | * inode format making all literal area available |
@@ -389,9 +364,10 @@ xfs_attr_shortform_remove(xfs_da_args_t *args) | |||
389 | xfs_idata_realloc(dp, -size, XFS_ATTR_FORK); | 364 | xfs_idata_realloc(dp, -size, XFS_ATTR_FORK); |
390 | dp->i_d.di_forkoff = xfs_attr_shortform_bytesfit(dp, totsize); | 365 | dp->i_d.di_forkoff = xfs_attr_shortform_bytesfit(dp, totsize); |
391 | ASSERT(dp->i_d.di_forkoff); | 366 | ASSERT(dp->i_d.di_forkoff); |
392 | ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) || args->addname || | 367 | ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) || |
393 | !(mp->m_flags & XFS_MOUNT_ATTR2) || | 368 | (args->op_flags & XFS_DA_OP_ADDNAME) || |
394 | dp->i_d.di_format == XFS_DINODE_FMT_BTREE); | 369 | !(mp->m_flags & XFS_MOUNT_ATTR2) || |
370 | dp->i_d.di_format == XFS_DINODE_FMT_BTREE); | ||
395 | dp->i_afp->if_ext_max = | 371 | dp->i_afp->if_ext_max = |
396 | XFS_IFORK_ASIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t); | 372 | XFS_IFORK_ASIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t); |
397 | dp->i_df.if_ext_max = | 373 | dp->i_df.if_ext_max = |
@@ -531,7 +507,7 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args) | |||
531 | nargs.total = args->total; | 507 | nargs.total = args->total; |
532 | nargs.whichfork = XFS_ATTR_FORK; | 508 | nargs.whichfork = XFS_ATTR_FORK; |
533 | nargs.trans = args->trans; | 509 | nargs.trans = args->trans; |
534 | nargs.oknoent = 1; | 510 | nargs.op_flags = XFS_DA_OP_OKNOENT; |
535 | 511 | ||
536 | sfe = &sf->list[0]; | 512 | sfe = &sf->list[0]; |
537 | for (i = 0; i < sf->hdr.count; i++) { | 513 | for (i = 0; i < sf->hdr.count; i++) { |
@@ -555,7 +531,7 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args) | |||
555 | out: | 531 | out: |
556 | if(bp) | 532 | if(bp) |
557 | xfs_da_buf_done(bp); | 533 | xfs_da_buf_done(bp); |
558 | kmem_free(tmpbuffer, size); | 534 | kmem_free(tmpbuffer); |
559 | return(error); | 535 | return(error); |
560 | } | 536 | } |
561 | 537 | ||
@@ -624,15 +600,8 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
624 | (XFS_ISRESET_CURSOR(cursor) && | 600 | (XFS_ISRESET_CURSOR(cursor) && |
625 | (dp->i_afp->if_bytes + sf->hdr.count * 16) < context->bufsize)) { | 601 | (dp->i_afp->if_bytes + sf->hdr.count * 16) < context->bufsize)) { |
626 | for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) { | 602 | for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) { |
627 | attrnames_t *namesp; | ||
628 | |||
629 | if (!xfs_attr_namesp_match_overrides(context->flags, sfe->flags)) { | ||
630 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe); | ||
631 | continue; | ||
632 | } | ||
633 | namesp = xfs_attr_flags_namesp(sfe->flags); | ||
634 | error = context->put_listent(context, | 603 | error = context->put_listent(context, |
635 | namesp, | 604 | sfe->flags, |
636 | (char *)sfe->nameval, | 605 | (char *)sfe->nameval, |
637 | (int)sfe->namelen, | 606 | (int)sfe->namelen, |
638 | (int)sfe->valuelen, | 607 | (int)sfe->valuelen, |
@@ -676,13 +645,10 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
676 | XFS_ERRLEVEL_LOW, | 645 | XFS_ERRLEVEL_LOW, |
677 | context->dp->i_mount, sfe); | 646 | context->dp->i_mount, sfe); |
678 | xfs_attr_trace_l_c("sf corrupted", context); | 647 | xfs_attr_trace_l_c("sf corrupted", context); |
679 | kmem_free(sbuf, sbsize); | 648 | kmem_free(sbuf); |
680 | return XFS_ERROR(EFSCORRUPTED); | 649 | return XFS_ERROR(EFSCORRUPTED); |
681 | } | 650 | } |
682 | if (!xfs_attr_namesp_match_overrides(context->flags, sfe->flags)) { | 651 | |
683 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe); | ||
684 | continue; | ||
685 | } | ||
686 | sbp->entno = i; | 652 | sbp->entno = i; |
687 | sbp->hash = xfs_da_hashname((char *)sfe->nameval, sfe->namelen); | 653 | sbp->hash = xfs_da_hashname((char *)sfe->nameval, sfe->namelen); |
688 | sbp->name = (char *)sfe->nameval; | 654 | sbp->name = (char *)sfe->nameval; |
@@ -717,7 +683,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
717 | } | 683 | } |
718 | } | 684 | } |
719 | if (i == nsbuf) { | 685 | if (i == nsbuf) { |
720 | kmem_free(sbuf, sbsize); | 686 | kmem_free(sbuf); |
721 | xfs_attr_trace_l_c("blk end", context); | 687 | xfs_attr_trace_l_c("blk end", context); |
722 | return(0); | 688 | return(0); |
723 | } | 689 | } |
@@ -726,16 +692,12 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
726 | * Loop putting entries into the user buffer. | 692 | * Loop putting entries into the user buffer. |
727 | */ | 693 | */ |
728 | for ( ; i < nsbuf; i++, sbp++) { | 694 | for ( ; i < nsbuf; i++, sbp++) { |
729 | attrnames_t *namesp; | ||
730 | |||
731 | namesp = xfs_attr_flags_namesp(sbp->flags); | ||
732 | |||
733 | if (cursor->hashval != sbp->hash) { | 695 | if (cursor->hashval != sbp->hash) { |
734 | cursor->hashval = sbp->hash; | 696 | cursor->hashval = sbp->hash; |
735 | cursor->offset = 0; | 697 | cursor->offset = 0; |
736 | } | 698 | } |
737 | error = context->put_listent(context, | 699 | error = context->put_listent(context, |
738 | namesp, | 700 | sbp->flags, |
739 | sbp->name, | 701 | sbp->name, |
740 | sbp->namelen, | 702 | sbp->namelen, |
741 | sbp->valuelen, | 703 | sbp->valuelen, |
@@ -747,7 +709,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
747 | cursor->offset++; | 709 | cursor->offset++; |
748 | } | 710 | } |
749 | 711 | ||
750 | kmem_free(sbuf, sbsize); | 712 | kmem_free(sbuf); |
751 | xfs_attr_trace_l_c("sf E-O-F", context); | 713 | xfs_attr_trace_l_c("sf E-O-F", context); |
752 | return(0); | 714 | return(0); |
753 | } | 715 | } |
@@ -853,7 +815,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff) | |||
853 | nargs.total = args->total; | 815 | nargs.total = args->total; |
854 | nargs.whichfork = XFS_ATTR_FORK; | 816 | nargs.whichfork = XFS_ATTR_FORK; |
855 | nargs.trans = args->trans; | 817 | nargs.trans = args->trans; |
856 | nargs.oknoent = 1; | 818 | nargs.op_flags = XFS_DA_OP_OKNOENT; |
857 | entry = &leaf->entries[0]; | 819 | entry = &leaf->entries[0]; |
858 | for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) { | 820 | for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) { |
859 | if (entry->flags & XFS_ATTR_INCOMPLETE) | 821 | if (entry->flags & XFS_ATTR_INCOMPLETE) |
@@ -873,7 +835,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff) | |||
873 | error = 0; | 835 | error = 0; |
874 | 836 | ||
875 | out: | 837 | out: |
876 | kmem_free(tmpbuffer, XFS_LBSIZE(dp->i_mount)); | 838 | kmem_free(tmpbuffer); |
877 | return(error); | 839 | return(error); |
878 | } | 840 | } |
879 | 841 | ||
@@ -1155,7 +1117,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex) | |||
1155 | entry->hashval = cpu_to_be32(args->hashval); | 1117 | entry->hashval = cpu_to_be32(args->hashval); |
1156 | entry->flags = tmp ? XFS_ATTR_LOCAL : 0; | 1118 | entry->flags = tmp ? XFS_ATTR_LOCAL : 0; |
1157 | entry->flags |= XFS_ATTR_NSP_ARGS_TO_ONDISK(args->flags); | 1119 | entry->flags |= XFS_ATTR_NSP_ARGS_TO_ONDISK(args->flags); |
1158 | if (args->rename) { | 1120 | if (args->op_flags & XFS_DA_OP_RENAME) { |
1159 | entry->flags |= XFS_ATTR_INCOMPLETE; | 1121 | entry->flags |= XFS_ATTR_INCOMPLETE; |
1160 | if ((args->blkno2 == args->blkno) && | 1122 | if ((args->blkno2 == args->blkno) && |
1161 | (args->index2 <= args->index)) { | 1123 | (args->index2 <= args->index)) { |
@@ -1271,7 +1233,7 @@ xfs_attr_leaf_compact(xfs_trans_t *trans, xfs_dabuf_t *bp) | |||
1271 | be16_to_cpu(hdr_s->count), mp); | 1233 | be16_to_cpu(hdr_s->count), mp); |
1272 | xfs_da_log_buf(trans, bp, 0, XFS_LBSIZE(mp) - 1); | 1234 | xfs_da_log_buf(trans, bp, 0, XFS_LBSIZE(mp) - 1); |
1273 | 1235 | ||
1274 | kmem_free(tmpbuffer, XFS_LBSIZE(mp)); | 1236 | kmem_free(tmpbuffer); |
1275 | } | 1237 | } |
1276 | 1238 | ||
1277 | /* | 1239 | /* |
@@ -1921,7 +1883,7 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, | |||
1921 | be16_to_cpu(drop_hdr->count), mp); | 1883 | be16_to_cpu(drop_hdr->count), mp); |
1922 | } | 1884 | } |
1923 | memcpy((char *)save_leaf, (char *)tmp_leaf, state->blocksize); | 1885 | memcpy((char *)save_leaf, (char *)tmp_leaf, state->blocksize); |
1924 | kmem_free(tmpbuffer, state->blocksize); | 1886 | kmem_free(tmpbuffer); |
1925 | } | 1887 | } |
1926 | 1888 | ||
1927 | xfs_da_log_buf(state->args->trans, save_blk->bp, 0, | 1889 | xfs_da_log_buf(state->args->trans, save_blk->bp, 0, |
@@ -2400,8 +2362,6 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context) | |||
2400 | */ | 2362 | */ |
2401 | retval = 0; | 2363 | retval = 0; |
2402 | for ( ; (i < be16_to_cpu(leaf->hdr.count)); entry++, i++) { | 2364 | for ( ; (i < be16_to_cpu(leaf->hdr.count)); entry++, i++) { |
2403 | attrnames_t *namesp; | ||
2404 | |||
2405 | if (be32_to_cpu(entry->hashval) != cursor->hashval) { | 2365 | if (be32_to_cpu(entry->hashval) != cursor->hashval) { |
2406 | cursor->hashval = be32_to_cpu(entry->hashval); | 2366 | cursor->hashval = be32_to_cpu(entry->hashval); |
2407 | cursor->offset = 0; | 2367 | cursor->offset = 0; |
@@ -2409,17 +2369,13 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context) | |||
2409 | 2369 | ||
2410 | if (entry->flags & XFS_ATTR_INCOMPLETE) | 2370 | if (entry->flags & XFS_ATTR_INCOMPLETE) |
2411 | continue; /* skip incomplete entries */ | 2371 | continue; /* skip incomplete entries */ |
2412 | if (!xfs_attr_namesp_match_overrides(context->flags, entry->flags)) | ||
2413 | continue; | ||
2414 | |||
2415 | namesp = xfs_attr_flags_namesp(entry->flags); | ||
2416 | 2372 | ||
2417 | if (entry->flags & XFS_ATTR_LOCAL) { | 2373 | if (entry->flags & XFS_ATTR_LOCAL) { |
2418 | xfs_attr_leaf_name_local_t *name_loc = | 2374 | xfs_attr_leaf_name_local_t *name_loc = |
2419 | XFS_ATTR_LEAF_NAME_LOCAL(leaf, i); | 2375 | XFS_ATTR_LEAF_NAME_LOCAL(leaf, i); |
2420 | 2376 | ||
2421 | retval = context->put_listent(context, | 2377 | retval = context->put_listent(context, |
2422 | namesp, | 2378 | entry->flags, |
2423 | (char *)name_loc->nameval, | 2379 | (char *)name_loc->nameval, |
2424 | (int)name_loc->namelen, | 2380 | (int)name_loc->namelen, |
2425 | be16_to_cpu(name_loc->valuelen), | 2381 | be16_to_cpu(name_loc->valuelen), |
@@ -2446,16 +2402,15 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context) | |||
2446 | if (retval) | 2402 | if (retval) |
2447 | return retval; | 2403 | return retval; |
2448 | retval = context->put_listent(context, | 2404 | retval = context->put_listent(context, |
2449 | namesp, | 2405 | entry->flags, |
2450 | (char *)name_rmt->name, | 2406 | (char *)name_rmt->name, |
2451 | (int)name_rmt->namelen, | 2407 | (int)name_rmt->namelen, |
2452 | valuelen, | 2408 | valuelen, |
2453 | (char*)args.value); | 2409 | (char*)args.value); |
2454 | kmem_free(args.value, valuelen); | 2410 | kmem_free(args.value); |
2455 | } | 2411 | } else { |
2456 | else { | ||
2457 | retval = context->put_listent(context, | 2412 | retval = context->put_listent(context, |
2458 | namesp, | 2413 | entry->flags, |
2459 | (char *)name_rmt->name, | 2414 | (char *)name_rmt->name, |
2460 | (int)name_rmt->namelen, | 2415 | (int)name_rmt->namelen, |
2461 | valuelen, | 2416 | valuelen, |
@@ -2954,7 +2909,7 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp) | |||
2954 | error = tmp; /* save only the 1st errno */ | 2909 | error = tmp; /* save only the 1st errno */ |
2955 | } | 2910 | } |
2956 | 2911 | ||
2957 | kmem_free((xfs_caddr_t)list, size); | 2912 | kmem_free((xfs_caddr_t)list); |
2958 | return(error); | 2913 | return(error); |
2959 | } | 2914 | } |
2960 | 2915 | ||