aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorNathan Scott <nathans@sgi.com>2006-03-17 01:27:56 -0500
committerNathan Scott <nathans@sgi.com>2006-03-17 01:27:56 -0500
commite922fffa4188ef6207cd3afef7f4d33bf4a9ca64 (patch)
tree8943e3d4e7113bb8fba85ce7de937138ebe1b6da /fs
parent1fba9f7fe2164553557e26583e6feb5299cf9f76 (diff)
[XFS] endianess annotations for xfs_dir2_block_tail_t
SGI-PV: 943272 SGI-Modid: xfs-linux-melb:xfs-kern:25491a Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nathan Scott <nathans@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_dir2_block.c52
-rw-r--r--fs/xfs/xfs_dir2_block.h7
-rw-r--r--fs/xfs/xfs_dir2_data.c10
-rw-r--r--fs/xfs/xfs_dir2_leaf.c6
-rw-r--r--fs/xfs/xfs_dir2_sf.c2
5 files changed, 38 insertions, 39 deletions
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c
index 2c1fcdc7a762..6f3b99dfe55c 100644
--- a/fs/xfs/xfs_dir2_block.c
+++ b/fs/xfs/xfs_dir2_block.c
@@ -193,10 +193,10 @@ xfs_dir2_block_addname(
193 * leaf data starts now, if it works at all. 193 * leaf data starts now, if it works at all.
194 */ 194 */
195 if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { 195 if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
196 if (be16_to_cpu(dup->length) + (INT_GET(btp->stale, ARCH_CONVERT) - 1) * 196 if (be16_to_cpu(dup->length) + (be32_to_cpu(btp->stale) - 1) *
197 (uint)sizeof(*blp) < len) 197 (uint)sizeof(*blp) < len)
198 dup = NULL; 198 dup = NULL;
199 } else if ((INT_GET(btp->stale, ARCH_CONVERT) - 1) * (uint)sizeof(*blp) < len) 199 } else if ((be32_to_cpu(btp->stale) - 1) * (uint)sizeof(*blp) < len)
200 dup = NULL; 200 dup = NULL;
201 else 201 else
202 dup = (xfs_dir2_data_unused_t *)blp; 202 dup = (xfs_dir2_data_unused_t *)blp;
@@ -242,7 +242,7 @@ xfs_dir2_block_addname(
242 int fromidx; /* source leaf index */ 242 int fromidx; /* source leaf index */
243 int toidx; /* target leaf index */ 243 int toidx; /* target leaf index */
244 244
245 for (fromidx = toidx = INT_GET(btp->count, ARCH_CONVERT) - 1, 245 for (fromidx = toidx = be32_to_cpu(btp->count) - 1,
246 highstale = lfloghigh = -1; 246 highstale = lfloghigh = -1;
247 fromidx >= 0; 247 fromidx >= 0;
248 fromidx--) { 248 fromidx--) {
@@ -259,15 +259,15 @@ xfs_dir2_block_addname(
259 blp[toidx] = blp[fromidx]; 259 blp[toidx] = blp[fromidx];
260 toidx--; 260 toidx--;
261 } 261 }
262 lfloglow = toidx + 1 - (INT_GET(btp->stale, ARCH_CONVERT) - 1); 262 lfloglow = toidx + 1 - (be32_to_cpu(btp->stale) - 1);
263 lfloghigh -= INT_GET(btp->stale, ARCH_CONVERT) - 1; 263 lfloghigh -= be32_to_cpu(btp->stale) - 1;
264 INT_MOD(btp->count, ARCH_CONVERT, -(INT_GET(btp->stale, ARCH_CONVERT) - 1)); 264 be32_add(&btp->count, -(be32_to_cpu(btp->stale) - 1));
265 xfs_dir2_data_make_free(tp, bp, 265 xfs_dir2_data_make_free(tp, bp,
266 (xfs_dir2_data_aoff_t)((char *)blp - (char *)block), 266 (xfs_dir2_data_aoff_t)((char *)blp - (char *)block),
267 (xfs_dir2_data_aoff_t)((INT_GET(btp->stale, ARCH_CONVERT) - 1) * sizeof(*blp)), 267 (xfs_dir2_data_aoff_t)((be32_to_cpu(btp->stale) - 1) * sizeof(*blp)),
268 &needlog, &needscan); 268 &needlog, &needscan);
269 blp += INT_GET(btp->stale, ARCH_CONVERT) - 1; 269 blp += be32_to_cpu(btp->stale) - 1;
270 INT_SET(btp->stale, ARCH_CONVERT, 1); 270 btp->stale = cpu_to_be32(1);
271 /* 271 /*
272 * If we now need to rebuild the bestfree map, do so. 272 * If we now need to rebuild the bestfree map, do so.
273 * This needs to happen before the next call to use_free. 273 * This needs to happen before the next call to use_free.
@@ -282,14 +282,14 @@ xfs_dir2_block_addname(
282 * Set leaf logging boundaries to impossible state. 282 * Set leaf logging boundaries to impossible state.
283 * For the no-stale case they're set explicitly. 283 * For the no-stale case they're set explicitly.
284 */ 284 */
285 else if (INT_GET(btp->stale, ARCH_CONVERT)) { 285 else if (btp->stale) {
286 lfloglow = INT_GET(btp->count, ARCH_CONVERT); 286 lfloglow = be32_to_cpu(btp->count);
287 lfloghigh = -1; 287 lfloghigh = -1;
288 } 288 }
289 /* 289 /*
290 * Find the slot that's first lower than our hash value, -1 if none. 290 * Find the slot that's first lower than our hash value, -1 if none.
291 */ 291 */
292 for (low = 0, high = INT_GET(btp->count, ARCH_CONVERT) - 1; low <= high; ) { 292 for (low = 0, high = be32_to_cpu(btp->count) - 1; low <= high; ) {
293 mid = (low + high) >> 1; 293 mid = (low + high) >> 1;
294 if ((hash = INT_GET(blp[mid].hashval, ARCH_CONVERT)) == args->hashval) 294 if ((hash = INT_GET(blp[mid].hashval, ARCH_CONVERT)) == args->hashval)
295 break; 295 break;
@@ -317,7 +317,7 @@ xfs_dir2_block_addname(
317 /* 317 /*
318 * Update the tail (entry count). 318 * Update the tail (entry count).
319 */ 319 */
320 INT_MOD(btp->count, ARCH_CONVERT, +1); 320 be32_add(&btp->count, 1);
321 /* 321 /*
322 * If we now need to rebuild the bestfree map, do so. 322 * If we now need to rebuild the bestfree map, do so.
323 * This needs to happen before the next call to use_free. 323 * This needs to happen before the next call to use_free.
@@ -349,7 +349,7 @@ xfs_dir2_block_addname(
349 lowstale--) 349 lowstale--)
350 continue; 350 continue;
351 for (highstale = mid + 1; 351 for (highstale = mid + 1;
352 highstale < INT_GET(btp->count, ARCH_CONVERT) && 352 highstale < be32_to_cpu(btp->count) &&
353 INT_GET(blp[highstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR && 353 INT_GET(blp[highstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR &&
354 (lowstale < 0 || mid - lowstale > highstale - mid); 354 (lowstale < 0 || mid - lowstale > highstale - mid);
355 highstale++) 355 highstale++)
@@ -358,7 +358,7 @@ xfs_dir2_block_addname(
358 * Move entries toward the low-numbered stale entry. 358 * Move entries toward the low-numbered stale entry.
359 */ 359 */
360 if (lowstale >= 0 && 360 if (lowstale >= 0 &&
361 (highstale == INT_GET(btp->count, ARCH_CONVERT) || 361 (highstale == be32_to_cpu(btp->count) ||
362 mid - lowstale <= highstale - mid)) { 362 mid - lowstale <= highstale - mid)) {
363 if (mid - lowstale) 363 if (mid - lowstale)
364 memmove(&blp[lowstale], &blp[lowstale + 1], 364 memmove(&blp[lowstale], &blp[lowstale + 1],
@@ -370,7 +370,7 @@ xfs_dir2_block_addname(
370 * Move entries toward the high-numbered stale entry. 370 * Move entries toward the high-numbered stale entry.
371 */ 371 */
372 else { 372 else {
373 ASSERT(highstale < INT_GET(btp->count, ARCH_CONVERT)); 373 ASSERT(highstale < be32_to_cpu(btp->count));
374 mid++; 374 mid++;
375 if (highstale - mid) 375 if (highstale - mid)
376 memmove(&blp[mid + 1], &blp[mid], 376 memmove(&blp[mid + 1], &blp[mid],
@@ -378,7 +378,7 @@ xfs_dir2_block_addname(
378 lfloglow = MIN(mid, lfloglow); 378 lfloglow = MIN(mid, lfloglow);
379 lfloghigh = MAX(highstale, lfloghigh); 379 lfloghigh = MAX(highstale, lfloghigh);
380 } 380 }
381 INT_MOD(btp->stale, ARCH_CONVERT, -1); 381 be32_add(&btp->stale, -1);
382 } 382 }
383 /* 383 /*
384 * Point to the new data entry. 384 * Point to the new data entry.
@@ -673,7 +673,7 @@ xfs_dir2_block_lookup_int(
673 * Loop doing a binary search for our hash value. 673 * Loop doing a binary search for our hash value.
674 * Find our entry, ENOENT if it's not there. 674 * Find our entry, ENOENT if it's not there.
675 */ 675 */
676 for (low = 0, high = INT_GET(btp->count, ARCH_CONVERT) - 1; ; ) { 676 for (low = 0, high = be32_to_cpu(btp->count) - 1; ; ) {
677 ASSERT(low <= high); 677 ASSERT(low <= high);
678 mid = (low + high) >> 1; 678 mid = (low + high) >> 1;
679 if ((hash = INT_GET(blp[mid].hashval, ARCH_CONVERT)) == args->hashval) 679 if ((hash = INT_GET(blp[mid].hashval, ARCH_CONVERT)) == args->hashval)
@@ -716,7 +716,7 @@ xfs_dir2_block_lookup_int(
716 *entno = mid; 716 *entno = mid;
717 return 0; 717 return 0;
718 } 718 }
719 } while (++mid < INT_GET(btp->count, ARCH_CONVERT) && INT_GET(blp[mid].hashval, ARCH_CONVERT) == hash); 719 } while (++mid < be32_to_cpu(btp->count) && INT_GET(blp[mid].hashval, ARCH_CONVERT) == hash);
720 /* 720 /*
721 * No match, release the buffer and return ENOENT. 721 * No match, release the buffer and return ENOENT.
722 */ 722 */
@@ -777,7 +777,7 @@ xfs_dir2_block_removename(
777 /* 777 /*
778 * Fix up the block tail. 778 * Fix up the block tail.
779 */ 779 */
780 INT_MOD(btp->stale, ARCH_CONVERT, +1); 780 be32_add(&btp->stale, 1);
781 xfs_dir2_block_log_tail(tp, bp); 781 xfs_dir2_block_log_tail(tp, bp);
782 /* 782 /*
783 * Remove the leaf entry by marking it stale. 783 * Remove the leaf entry by marking it stale.
@@ -968,7 +968,7 @@ xfs_dir2_leaf_to_block(
968 * Initialize the block tail. 968 * Initialize the block tail.
969 */ 969 */
970 btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); 970 btp = XFS_DIR2_BLOCK_TAIL_P(mp, block);
971 INT_SET(btp->count, ARCH_CONVERT, INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT)); 971 btp->count = cpu_to_be32(INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT));
972 btp->stale = 0; 972 btp->stale = 0;
973 xfs_dir2_block_log_tail(tp, dbp); 973 xfs_dir2_block_log_tail(tp, dbp);
974 /* 974 /*
@@ -980,8 +980,8 @@ xfs_dir2_leaf_to_block(
980 continue; 980 continue;
981 lep[to++] = leaf->ents[from]; 981 lep[to++] = leaf->ents[from];
982 } 982 }
983 ASSERT(to == INT_GET(btp->count, ARCH_CONVERT)); 983 ASSERT(to == be32_to_cpu(btp->count));
984 xfs_dir2_block_log_leaf(tp, dbp, 0, INT_GET(btp->count, ARCH_CONVERT) - 1); 984 xfs_dir2_block_log_leaf(tp, dbp, 0, be32_to_cpu(btp->count) - 1);
985 /* 985 /*
986 * Scan the bestfree if we need it and log the data block header. 986 * Scan the bestfree if we need it and log the data block header.
987 */ 987 */
@@ -1114,7 +1114,7 @@ xfs_dir2_sf_to_block(
1114 * Fill in the tail. 1114 * Fill in the tail.
1115 */ 1115 */
1116 btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); 1116 btp = XFS_DIR2_BLOCK_TAIL_P(mp, block);
1117 INT_SET(btp->count, ARCH_CONVERT, INT_GET(sfp->hdr.count, ARCH_CONVERT) + 2); /* ., .. */ 1117 btp->count = cpu_to_be32(INT_GET(sfp->hdr.count, ARCH_CONVERT) + 2); /* ., .. */
1118 btp->stale = 0; 1118 btp->stale = 0;
1119 blp = XFS_DIR2_BLOCK_LEAF_P(btp); 1119 blp = XFS_DIR2_BLOCK_LEAF_P(btp);
1120 endoffset = (uint)((char *)blp - (char *)block); 1120 endoffset = (uint)((char *)blp - (char *)block);
@@ -1211,13 +1211,13 @@ xfs_dir2_sf_to_block(
1211 /* 1211 /*
1212 * Sort the leaf entries by hash value. 1212 * Sort the leaf entries by hash value.
1213 */ 1213 */
1214 xfs_sort(blp, INT_GET(btp->count, ARCH_CONVERT), sizeof(*blp), xfs_dir2_block_sort); 1214 xfs_sort(blp, be32_to_cpu(btp->count), sizeof(*blp), xfs_dir2_block_sort);
1215 /* 1215 /*
1216 * Log the leaf entry area and tail. 1216 * Log the leaf entry area and tail.
1217 * Already logged the header in data_init, ignore needlog. 1217 * Already logged the header in data_init, ignore needlog.
1218 */ 1218 */
1219 ASSERT(needscan == 0); 1219 ASSERT(needscan == 0);
1220 xfs_dir2_block_log_leaf(tp, bp, 0, INT_GET(btp->count, ARCH_CONVERT) - 1); 1220 xfs_dir2_block_log_leaf(tp, bp, 0, be32_to_cpu(btp->count) - 1);
1221 xfs_dir2_block_log_tail(tp, bp); 1221 xfs_dir2_block_log_tail(tp, bp);
1222 xfs_dir2_data_check(dp, bp); 1222 xfs_dir2_data_check(dp, bp);
1223 xfs_da_buf_done(bp); 1223 xfs_da_buf_done(bp);
diff --git a/fs/xfs/xfs_dir2_block.h b/fs/xfs/xfs_dir2_block.h
index a2e5cb98a838..6722effd0b20 100644
--- a/fs/xfs/xfs_dir2_block.h
+++ b/fs/xfs/xfs_dir2_block.h
@@ -43,8 +43,8 @@ struct xfs_trans;
43#define XFS_DIR2_BLOCK_MAGIC 0x58443242 /* XD2B: for one block dirs */ 43#define XFS_DIR2_BLOCK_MAGIC 0x58443242 /* XD2B: for one block dirs */
44 44
45typedef struct xfs_dir2_block_tail { 45typedef struct xfs_dir2_block_tail {
46 __uint32_t count; /* count of leaf entries */ 46 __be32 count; /* count of leaf entries */
47 __uint32_t stale; /* count of stale lf entries */ 47 __be32 stale; /* count of stale lf entries */
48} xfs_dir2_block_tail_t; 48} xfs_dir2_block_tail_t;
49 49
50/* 50/*
@@ -75,8 +75,7 @@ xfs_dir2_block_tail_p(struct xfs_mount *mp, xfs_dir2_block_t *block)
75static inline struct xfs_dir2_leaf_entry * 75static inline struct xfs_dir2_leaf_entry *
76xfs_dir2_block_leaf_p(xfs_dir2_block_tail_t *btp) 76xfs_dir2_block_leaf_p(xfs_dir2_block_tail_t *btp)
77{ 77{
78 return (((struct xfs_dir2_leaf_entry *) 78 return ((struct xfs_dir2_leaf_entry *)btp) - be32_to_cpu(btp->count);
79 (btp)) - INT_GET((btp)->count, ARCH_CONVERT));
80} 79}
81 80
82/* 81/*
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c
index acb61132dec4..0af757873be5 100644
--- a/fs/xfs/xfs_dir2_data.c
+++ b/fs/xfs/xfs_dir2_data.c
@@ -143,12 +143,12 @@ xfs_dir2_data_check(
143 (xfs_dir2_data_aoff_t) 143 (xfs_dir2_data_aoff_t)
144 ((char *)dep - (char *)d)); 144 ((char *)dep - (char *)d));
145 hash = xfs_da_hashname((char *)dep->name, dep->namelen); 145 hash = xfs_da_hashname((char *)dep->name, dep->namelen);
146 for (i = 0; i < INT_GET(btp->count, ARCH_CONVERT); i++) { 146 for (i = 0; i < be32_to_cpu(btp->count); i++) {
147 if (INT_GET(lep[i].address, ARCH_CONVERT) == addr && 147 if (INT_GET(lep[i].address, ARCH_CONVERT) == addr &&
148 INT_GET(lep[i].hashval, ARCH_CONVERT) == hash) 148 INT_GET(lep[i].hashval, ARCH_CONVERT) == hash)
149 break; 149 break;
150 } 150 }
151 ASSERT(i < INT_GET(btp->count, ARCH_CONVERT)); 151 ASSERT(i < be32_to_cpu(btp->count));
152 } 152 }
153 p += XFS_DIR2_DATA_ENTSIZE(dep->namelen); 153 p += XFS_DIR2_DATA_ENTSIZE(dep->namelen);
154 } 154 }
@@ -157,14 +157,14 @@ xfs_dir2_data_check(
157 */ 157 */
158 ASSERT(freeseen == 7); 158 ASSERT(freeseen == 7);
159 if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { 159 if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) {
160 for (i = stale = 0; i < INT_GET(btp->count, ARCH_CONVERT); i++) { 160 for (i = stale = 0; i < be32_to_cpu(btp->count); i++) {
161 if (INT_GET(lep[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) 161 if (INT_GET(lep[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
162 stale++; 162 stale++;
163 if (i > 0) 163 if (i > 0)
164 ASSERT(INT_GET(lep[i].hashval, ARCH_CONVERT) >= INT_GET(lep[i - 1].hashval, ARCH_CONVERT)); 164 ASSERT(INT_GET(lep[i].hashval, ARCH_CONVERT) >= INT_GET(lep[i - 1].hashval, ARCH_CONVERT));
165 } 165 }
166 ASSERT(count == INT_GET(btp->count, ARCH_CONVERT) - INT_GET(btp->stale, ARCH_CONVERT)); 166 ASSERT(count == be32_to_cpu(btp->count) - be32_to_cpu(btp->stale));
167 ASSERT(stale == INT_GET(btp->stale, ARCH_CONVERT)); 167 ASSERT(stale == be32_to_cpu(btp->stale));
168 } 168 }
169} 169}
170#endif 170#endif
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index cbd371d9e98d..63e81dc2737e 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -111,13 +111,13 @@ xfs_dir2_block_to_leaf(
111 /* 111 /*
112 * Set the counts in the leaf header. 112 * Set the counts in the leaf header.
113 */ 113 */
114 INT_COPY(leaf->hdr.count, btp->count, ARCH_CONVERT); /* INT_: type change */ 114 leaf->hdr.count = btp->count;
115 INT_COPY(leaf->hdr.stale, btp->stale, ARCH_CONVERT); /* INT_: type change */ 115 leaf->hdr.stale = btp->stale;
116 /* 116 /*
117 * Could compact these but I think we always do the conversion 117 * Could compact these but I think we always do the conversion
118 * after squeezing out stale entries. 118 * after squeezing out stale entries.
119 */ 119 */
120 memcpy(leaf->ents, blp, INT_GET(btp->count, ARCH_CONVERT) * sizeof(xfs_dir2_leaf_entry_t)); 120 memcpy(leaf->ents, blp, be32_to_cpu(btp->count) * sizeof(xfs_dir2_leaf_entry_t));
121 xfs_dir2_leaf_log_ents(tp, lbp, 0, INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1); 121 xfs_dir2_leaf_log_ents(tp, lbp, 0, INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1);
122 needscan = 0; 122 needscan = 0;
123 needlog = 1; 123 needlog = 1;
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
index 3a571d8cf1f3..35dd003051c5 100644
--- a/fs/xfs/xfs_dir2_sf.c
+++ b/fs/xfs/xfs_dir2_sf.c
@@ -98,7 +98,7 @@ xfs_dir2_block_sfsize(
98 /* 98 /*
99 * Iterate over the block's data entries by using the leaf pointers. 99 * Iterate over the block's data entries by using the leaf pointers.
100 */ 100 */
101 for (i = 0; i < INT_GET(btp->count, ARCH_CONVERT); i++) { 101 for (i = 0; i < be32_to_cpu(btp->count); i++) {
102 if ((addr = INT_GET(blp[i].address, ARCH_CONVERT)) == XFS_DIR2_NULL_DATAPTR) 102 if ((addr = INT_GET(blp[i].address, ARCH_CONVERT)) == XFS_DIR2_NULL_DATAPTR)
103 continue; 103 continue;
104 /* 104 /*