Commit c9fb86a917640d66ba2e0613a12f3a76eda8a30f

Authored by Eric Sandeen
Committed by Lachlan McIlroy
1 parent 9800b55035

[XFS] Remove macro-to-function indirections in attr code

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Reviewed-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>

Showing 2 changed files with 36 additions and 48 deletions Side-by-side Diff

fs/xfs/xfs_attr_leaf.c
... ... @@ -736,7 +736,7 @@
736 736 continue; /* don't copy partial entries */
737 737 if (!(entry->flags & XFS_ATTR_LOCAL))
738 738 return(0);
739   - name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, i);
  739 + name_loc = xfs_attr_leaf_name_local(leaf, i);
740 740 if (name_loc->namelen >= XFS_ATTR_SF_ENTSIZE_MAX)
741 741 return(0);
742 742 if (be16_to_cpu(name_loc->valuelen) >= XFS_ATTR_SF_ENTSIZE_MAX)
... ... @@ -823,7 +823,7 @@
823 823 if (!entry->nameidx)
824 824 continue;
825 825 ASSERT(entry->flags & XFS_ATTR_LOCAL);
826   - name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, i);
  826 + name_loc = xfs_attr_leaf_name_local(leaf, i);
827 827 nargs.name = (char *)name_loc->nameval;
828 828 nargs.namelen = name_loc->namelen;
829 829 nargs.value = (char *)&name_loc->nameval[nargs.namelen];
830 830  
... ... @@ -1141,14 +1141,14 @@
1141 1141 * as part of this transaction (a split operation for example).
1142 1142 */
1143 1143 if (entry->flags & XFS_ATTR_LOCAL) {
1144   - name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, args->index);
  1144 + name_loc = xfs_attr_leaf_name_local(leaf, args->index);
1145 1145 name_loc->namelen = args->namelen;
1146 1146 name_loc->valuelen = cpu_to_be16(args->valuelen);
1147 1147 memcpy((char *)name_loc->nameval, args->name, args->namelen);
1148 1148 memcpy((char *)&name_loc->nameval[args->namelen], args->value,
1149 1149 be16_to_cpu(name_loc->valuelen));
1150 1150 } else {
1151   - name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index);
  1151 + name_rmt = xfs_attr_leaf_name_remote(leaf, args->index);
1152 1152 name_rmt->namelen = args->namelen;
1153 1153 memcpy((char *)name_rmt->name, args->name, args->namelen);
1154 1154 entry->flags |= XFS_ATTR_INCOMPLETE;
... ... @@ -1159,7 +1159,7 @@
1159 1159 args->rmtblkcnt = XFS_B_TO_FSB(mp, args->valuelen);
1160 1160 }
1161 1161 xfs_da_log_buf(args->trans, bp,
1162   - XFS_DA_LOGRANGE(leaf, XFS_ATTR_LEAF_NAME(leaf, args->index),
  1162 + XFS_DA_LOGRANGE(leaf, xfs_attr_leaf_name(leaf, args->index),
1163 1163 xfs_attr_leaf_entsize(leaf, args->index)));
1164 1164  
1165 1165 /*
1166 1166  
... ... @@ -1749,10 +1749,10 @@
1749 1749 /*
1750 1750 * Compress the remaining entries and zero out the removed stuff.
1751 1751 */
1752   - memset(XFS_ATTR_LEAF_NAME(leaf, args->index), 0, entsize);
  1752 + memset(xfs_attr_leaf_name(leaf, args->index), 0, entsize);
1753 1753 be16_add_cpu(&hdr->usedbytes, -entsize);
1754 1754 xfs_da_log_buf(args->trans, bp,
1755   - XFS_DA_LOGRANGE(leaf, XFS_ATTR_LEAF_NAME(leaf, args->index),
  1755 + XFS_DA_LOGRANGE(leaf, xfs_attr_leaf_name(leaf, args->index),
1756 1756 entsize));
1757 1757  
1758 1758 tmp = (be16_to_cpu(hdr->count) - args->index)
... ... @@ -1985,7 +1985,7 @@
1985 1985 continue;
1986 1986 }
1987 1987 if (entry->flags & XFS_ATTR_LOCAL) {
1988   - name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, probe);
  1988 + name_loc = xfs_attr_leaf_name_local(leaf, probe);
1989 1989 if (name_loc->namelen != args->namelen)
1990 1990 continue;
1991 1991 if (memcmp(args->name, (char *)name_loc->nameval, args->namelen) != 0)
... ... @@ -1995,7 +1995,7 @@
1995 1995 args->index = probe;
1996 1996 return(XFS_ERROR(EEXIST));
1997 1997 } else {
1998   - name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, probe);
  1998 + name_rmt = xfs_attr_leaf_name_remote(leaf, probe);
1999 1999 if (name_rmt->namelen != args->namelen)
2000 2000 continue;
2001 2001 if (memcmp(args->name, (char *)name_rmt->name,
... ... @@ -2035,7 +2035,7 @@
2035 2035  
2036 2036 entry = &leaf->entries[args->index];
2037 2037 if (entry->flags & XFS_ATTR_LOCAL) {
2038   - name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, args->index);
  2038 + name_loc = xfs_attr_leaf_name_local(leaf, args->index);
2039 2039 ASSERT(name_loc->namelen == args->namelen);
2040 2040 ASSERT(memcmp(args->name, name_loc->nameval, args->namelen) == 0);
2041 2041 valuelen = be16_to_cpu(name_loc->valuelen);
... ... @@ -2050,7 +2050,7 @@
2050 2050 args->valuelen = valuelen;
2051 2051 memcpy(args->value, &name_loc->nameval[args->namelen], valuelen);
2052 2052 } else {
2053   - name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index);
  2053 + name_rmt = xfs_attr_leaf_name_remote(leaf, args->index);
2054 2054 ASSERT(name_rmt->namelen == args->namelen);
2055 2055 ASSERT(memcmp(args->name, name_rmt->name, args->namelen) == 0);
2056 2056 valuelen = be32_to_cpu(name_rmt->valuelen);
... ... @@ -2143,7 +2143,7 @@
2143 2143 * off for 6.2, should be revisited later.
2144 2144 */
2145 2145 if (entry_s->flags & XFS_ATTR_INCOMPLETE) { /* skip partials? */
2146   - memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp);
  2146 + memset(xfs_attr_leaf_name(leaf_s, start_s + i), 0, tmp);
2147 2147 be16_add_cpu(&hdr_s->usedbytes, -tmp);
2148 2148 be16_add_cpu(&hdr_s->count, -1);
2149 2149 entry_d--; /* to compensate for ++ in loop hdr */
2150 2150  
... ... @@ -2160,11 +2160,11 @@
2160 2160 entry_d->flags = entry_s->flags;
2161 2161 ASSERT(be16_to_cpu(entry_d->nameidx) + tmp
2162 2162 <= XFS_LBSIZE(mp));
2163   - memmove(XFS_ATTR_LEAF_NAME(leaf_d, desti),
2164   - XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), tmp);
  2163 + memmove(xfs_attr_leaf_name(leaf_d, desti),
  2164 + xfs_attr_leaf_name(leaf_s, start_s + i), tmp);
2165 2165 ASSERT(be16_to_cpu(entry_s->nameidx) + tmp
2166 2166 <= XFS_LBSIZE(mp));
2167   - memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp);
  2167 + memset(xfs_attr_leaf_name(leaf_s, start_s + i), 0, tmp);
2168 2168 be16_add_cpu(&hdr_s->usedbytes, -tmp);
2169 2169 be16_add_cpu(&hdr_d->usedbytes, tmp);
2170 2170 be16_add_cpu(&hdr_s->count, -1);
2171 2171  
... ... @@ -2276,12 +2276,12 @@
2276 2276  
2277 2277 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
2278 2278 if (leaf->entries[index].flags & XFS_ATTR_LOCAL) {
2279   - name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, index);
2280   - size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(name_loc->namelen,
  2279 + name_loc = xfs_attr_leaf_name_local(leaf, index);
  2280 + size = xfs_attr_leaf_entsize_local(name_loc->namelen,
2281 2281 be16_to_cpu(name_loc->valuelen));
2282 2282 } else {
2283   - name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, index);
2284   - size = XFS_ATTR_LEAF_ENTSIZE_REMOTE(name_rmt->namelen);
  2283 + name_rmt = xfs_attr_leaf_name_remote(leaf, index);
  2284 + size = xfs_attr_leaf_entsize_remote(name_rmt->namelen);
2285 2285 }
2286 2286 return(size);
2287 2287 }
2288 2288  
... ... @@ -2297,13 +2297,13 @@
2297 2297 {
2298 2298 int size;
2299 2299  
2300   - size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(namelen, valuelen);
2301   - if (size < XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(blocksize)) {
  2300 + size = xfs_attr_leaf_entsize_local(namelen, valuelen);
  2301 + if (size < xfs_attr_leaf_entsize_local_max(blocksize)) {
2302 2302 if (local) {
2303 2303 *local = 1;
2304 2304 }
2305 2305 } else {
2306   - size = XFS_ATTR_LEAF_ENTSIZE_REMOTE(namelen);
  2306 + size = xfs_attr_leaf_entsize_remote(namelen);
2307 2307 if (local) {
2308 2308 *local = 0;
2309 2309 }
... ... @@ -2372,7 +2372,7 @@
2372 2372  
2373 2373 if (entry->flags & XFS_ATTR_LOCAL) {
2374 2374 xfs_attr_leaf_name_local_t *name_loc =
2375   - XFS_ATTR_LEAF_NAME_LOCAL(leaf, i);
  2375 + xfs_attr_leaf_name_local(leaf, i);
2376 2376  
2377 2377 retval = context->put_listent(context,
2378 2378 entry->flags,
... ... @@ -2384,7 +2384,7 @@
2384 2384 return retval;
2385 2385 } else {
2386 2386 xfs_attr_leaf_name_remote_t *name_rmt =
2387   - XFS_ATTR_LEAF_NAME_REMOTE(leaf, i);
  2387 + xfs_attr_leaf_name_remote(leaf, i);
2388 2388  
2389 2389 int valuelen = be32_to_cpu(name_rmt->valuelen);
2390 2390  
2391 2391  
... ... @@ -2468,11 +2468,11 @@
2468 2468  
2469 2469 #ifdef DEBUG
2470 2470 if (entry->flags & XFS_ATTR_LOCAL) {
2471   - name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, args->index);
  2471 + name_loc = xfs_attr_leaf_name_local(leaf, args->index);
2472 2472 namelen = name_loc->namelen;
2473 2473 name = (char *)name_loc->nameval;
2474 2474 } else {
2475   - name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index);
  2475 + name_rmt = xfs_attr_leaf_name_remote(leaf, args->index);
2476 2476 namelen = name_rmt->namelen;
2477 2477 name = (char *)name_rmt->name;
2478 2478 }
... ... @@ -2487,7 +2487,7 @@
2487 2487  
2488 2488 if (args->rmtblkno) {
2489 2489 ASSERT((entry->flags & XFS_ATTR_LOCAL) == 0);
2490   - name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index);
  2490 + name_rmt = xfs_attr_leaf_name_remote(leaf, args->index);
2491 2491 name_rmt->valueblk = cpu_to_be32(args->rmtblkno);
2492 2492 name_rmt->valuelen = cpu_to_be32(args->valuelen);
2493 2493 xfs_da_log_buf(args->trans, bp,
... ... @@ -2534,7 +2534,7 @@
2534 2534 xfs_da_log_buf(args->trans, bp,
2535 2535 XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry)));
2536 2536 if ((entry->flags & XFS_ATTR_LOCAL) == 0) {
2537   - name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index);
  2537 + name_rmt = xfs_attr_leaf_name_remote(leaf, args->index);
2538 2538 name_rmt->valueblk = 0;
2539 2539 name_rmt->valuelen = 0;
2540 2540 xfs_da_log_buf(args->trans, bp,
2541 2541  
2542 2542  
2543 2543  
... ... @@ -2607,20 +2607,20 @@
2607 2607  
2608 2608 #ifdef DEBUG
2609 2609 if (entry1->flags & XFS_ATTR_LOCAL) {
2610   - name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf1, args->index);
  2610 + name_loc = xfs_attr_leaf_name_local(leaf1, args->index);
2611 2611 namelen1 = name_loc->namelen;
2612 2612 name1 = (char *)name_loc->nameval;
2613 2613 } else {
2614   - name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf1, args->index);
  2614 + name_rmt = xfs_attr_leaf_name_remote(leaf1, args->index);
2615 2615 namelen1 = name_rmt->namelen;
2616 2616 name1 = (char *)name_rmt->name;
2617 2617 }
2618 2618 if (entry2->flags & XFS_ATTR_LOCAL) {
2619   - name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf2, args->index2);
  2619 + name_loc = xfs_attr_leaf_name_local(leaf2, args->index2);
2620 2620 namelen2 = name_loc->namelen;
2621 2621 name2 = (char *)name_loc->nameval;
2622 2622 } else {
2623   - name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf2, args->index2);
  2623 + name_rmt = xfs_attr_leaf_name_remote(leaf2, args->index2);
2624 2624 namelen2 = name_rmt->namelen;
2625 2625 name2 = (char *)name_rmt->name;
2626 2626 }
... ... @@ -2637,7 +2637,7 @@
2637 2637 XFS_DA_LOGRANGE(leaf1, entry1, sizeof(*entry1)));
2638 2638 if (args->rmtblkno) {
2639 2639 ASSERT((entry1->flags & XFS_ATTR_LOCAL) == 0);
2640   - name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf1, args->index);
  2640 + name_rmt = xfs_attr_leaf_name_remote(leaf1, args->index);
2641 2641 name_rmt->valueblk = cpu_to_be32(args->rmtblkno);
2642 2642 name_rmt->valuelen = cpu_to_be32(args->valuelen);
2643 2643 xfs_da_log_buf(args->trans, bp1,
... ... @@ -2648,7 +2648,7 @@
2648 2648 xfs_da_log_buf(args->trans, bp2,
2649 2649 XFS_DA_LOGRANGE(leaf2, entry2, sizeof(*entry2)));
2650 2650 if ((entry2->flags & XFS_ATTR_LOCAL) == 0) {
2651   - name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf2, args->index2);
  2651 + name_rmt = xfs_attr_leaf_name_remote(leaf2, args->index2);
2652 2652 name_rmt->valueblk = 0;
2653 2653 name_rmt->valuelen = 0;
2654 2654 xfs_da_log_buf(args->trans, bp2,
... ... @@ -2855,7 +2855,7 @@
2855 2855 for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) {
2856 2856 if (be16_to_cpu(entry->nameidx) &&
2857 2857 ((entry->flags & XFS_ATTR_LOCAL) == 0)) {
2858   - name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i);
  2858 + name_rmt = xfs_attr_leaf_name_remote(leaf, i);
2859 2859 if (name_rmt->valueblk)
2860 2860 count++;
2861 2861 }
... ... @@ -2883,7 +2883,7 @@
2883 2883 for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) {
2884 2884 if (be16_to_cpu(entry->nameidx) &&
2885 2885 ((entry->flags & XFS_ATTR_LOCAL) == 0)) {
2886   - name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i);
  2886 + name_rmt = xfs_attr_leaf_name_remote(leaf, i);
2887 2887 if (name_rmt->valueblk) {
2888 2888 lp->valueblk = be32_to_cpu(name_rmt->valueblk);
2889 2889 lp->valuelen = XFS_B_TO_FSB(dp->i_mount,
fs/xfs/xfs_attr_leaf.h
... ... @@ -151,8 +151,6 @@
151 151 /*
152 152 * Cast typed pointers for "local" and "remote" name/value structs.
153 153 */
154   -#define XFS_ATTR_LEAF_NAME_REMOTE(leafp,idx) \
155   - xfs_attr_leaf_name_remote(leafp,idx)
156 154 static inline xfs_attr_leaf_name_remote_t *
157 155 xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx)
158 156 {
... ... @@ -160,8 +158,6 @@
160 158 &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)];
161 159 }
162 160  
163   -#define XFS_ATTR_LEAF_NAME_LOCAL(leafp,idx) \
164   - xfs_attr_leaf_name_local(leafp,idx)
165 161 static inline xfs_attr_leaf_name_local_t *
166 162 xfs_attr_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx)
167 163 {
... ... @@ -169,8 +165,6 @@
169 165 &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)];
170 166 }
171 167  
172   -#define XFS_ATTR_LEAF_NAME(leafp,idx) \
173   - xfs_attr_leaf_name(leafp,idx)
174 168 static inline char *xfs_attr_leaf_name(xfs_attr_leafblock_t *leafp, int idx)
175 169 {
176 170 return &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)];
177 171  
178 172  
... ... @@ -181,24 +175,18 @@
181 175 * a "local" name/value structure, a "remote" name/value structure, and
182 176 * a pointer which might be either.
183 177 */
184   -#define XFS_ATTR_LEAF_ENTSIZE_REMOTE(nlen) \
185   - xfs_attr_leaf_entsize_remote(nlen)
186 178 static inline int xfs_attr_leaf_entsize_remote(int nlen)
187 179 {
188 180 return ((uint)sizeof(xfs_attr_leaf_name_remote_t) - 1 + (nlen) + \
189 181 XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
190 182 }
191 183  
192   -#define XFS_ATTR_LEAF_ENTSIZE_LOCAL(nlen,vlen) \
193   - xfs_attr_leaf_entsize_local(nlen,vlen)
194 184 static inline int xfs_attr_leaf_entsize_local(int nlen, int vlen)
195 185 {
196 186 return ((uint)sizeof(xfs_attr_leaf_name_local_t) - 1 + (nlen) + (vlen) +
197 187 XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
198 188 }
199 189  
200   -#define XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(bsize) \
201   - xfs_attr_leaf_entsize_local_max(bsize)
202 190 static inline int xfs_attr_leaf_entsize_local_max(int bsize)
203 191 {
204 192 return (((bsize) >> 1) + ((bsize) >> 2));