aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/xfs/xfs_da_btree.c2
-rw-r--r--fs/xfs/xfs_dir2_block.c19
-rw-r--r--fs/xfs/xfs_dir2_data.c123
-rw-r--r--fs/xfs/xfs_dir2_data.h6
-rw-r--r--fs/xfs/xfs_dir2_leaf.c24
-rw-r--r--fs/xfs/xfs_dir2_node.c18
6 files changed, 99 insertions, 93 deletions
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index 473671fa5c1..96517d29e22 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -2204,7 +2204,7 @@ xfs_da_do_buf(
2204 data = rbp->data; 2204 data = rbp->data;
2205 free = rbp->data; 2205 free = rbp->data;
2206 magic = INT_GET(info->magic, ARCH_CONVERT); 2206 magic = INT_GET(info->magic, ARCH_CONVERT);
2207 magic1 = INT_GET(data->hdr.magic, ARCH_CONVERT); 2207 magic1 = be32_to_cpu(data->hdr.magic);
2208 if (unlikely( 2208 if (unlikely(
2209 XFS_TEST_ERROR((magic != XFS_DA_NODE_MAGIC) && 2209 XFS_TEST_ERROR((magic != XFS_DA_NODE_MAGIC) &&
2210 (magic != XFS_DIR_LEAF_MAGIC) && 2210 (magic != XFS_DIR_LEAF_MAGIC) &&
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c
index 31bc99faa70..35a03f29b2f 100644
--- a/fs/xfs/xfs_dir2_block.c
+++ b/fs/xfs/xfs_dir2_block.c
@@ -100,8 +100,7 @@ xfs_dir2_block_addname(
100 /* 100 /*
101 * Check the magic number, corrupted if wrong. 101 * Check the magic number, corrupted if wrong.
102 */ 102 */
103 if (unlikely(INT_GET(block->hdr.magic, ARCH_CONVERT) 103 if (unlikely(be32_to_cpu(block->hdr.magic) != XFS_DIR2_BLOCK_MAGIC)) {
104 != XFS_DIR2_BLOCK_MAGIC)) {
105 XFS_CORRUPTION_ERROR("xfs_dir2_block_addname", 104 XFS_CORRUPTION_ERROR("xfs_dir2_block_addname",
106 XFS_ERRLEVEL_LOW, mp, block); 105 XFS_ERRLEVEL_LOW, mp, block);
107 xfs_da_brelse(tp, bp); 106 xfs_da_brelse(tp, bp);
@@ -138,7 +137,7 @@ xfs_dir2_block_addname(
138 */ 137 */
139 else { 138 else {
140 dup = (xfs_dir2_data_unused_t *) 139 dup = (xfs_dir2_data_unused_t *)
141 ((char *)block + INT_GET(bf[0].offset, ARCH_CONVERT)); 140 ((char *)block + be16_to_cpu(bf[0].offset));
142 if (dup == enddup) { 141 if (dup == enddup) {
143 /* 142 /*
144 * It is the biggest freespace, is it too small 143 * It is the biggest freespace, is it too small
@@ -149,10 +148,10 @@ xfs_dir2_block_addname(
149 * Yes, we use the second-largest 148 * Yes, we use the second-largest
150 * entry instead if it works. 149 * entry instead if it works.
151 */ 150 */
152 if (INT_GET(bf[1].length, ARCH_CONVERT) >= len) 151 if (be16_to_cpu(bf[1].length) >= len)
153 dup = (xfs_dir2_data_unused_t *) 152 dup = (xfs_dir2_data_unused_t *)
154 ((char *)block + 153 ((char *)block +
155 INT_GET(bf[1].offset, ARCH_CONVERT)); 154 be16_to_cpu(bf[1].offset));
156 else 155 else
157 dup = NULL; 156 dup = NULL;
158 } 157 }
@@ -172,9 +171,9 @@ xfs_dir2_block_addname(
172 * If there are stale entries we'll use one for the leaf. 171 * If there are stale entries we'll use one for the leaf.
173 * Is the biggest entry enough to avoid compaction? 172 * Is the biggest entry enough to avoid compaction?
174 */ 173 */
175 else if (INT_GET(bf[0].length, ARCH_CONVERT) >= len) { 174 else if (be16_to_cpu(bf[0].length) >= len) {
176 dup = (xfs_dir2_data_unused_t *) 175 dup = (xfs_dir2_data_unused_t *)
177 ((char *)block + INT_GET(bf[0].offset, ARCH_CONVERT)); 176 ((char *)block + be16_to_cpu(bf[0].offset));
178 compact = 0; 177 compact = 0;
179 } 178 }
180 /* 179 /*
@@ -935,7 +934,7 @@ xfs_dir2_leaf_to_block(
935 goto out; 934 goto out;
936 } 935 }
937 block = dbp->data; 936 block = dbp->data;
938 ASSERT(INT_GET(block->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC); 937 ASSERT(be32_to_cpu(block->hdr.magic) == XFS_DIR2_DATA_MAGIC);
939 /* 938 /*
940 * Size of the "leaf" area in the block. 939 * Size of the "leaf" area in the block.
941 */ 940 */
@@ -956,7 +955,7 @@ xfs_dir2_leaf_to_block(
956 /* 955 /*
957 * Start converting it to block form. 956 * Start converting it to block form.
958 */ 957 */
959 INT_SET(block->hdr.magic, ARCH_CONVERT, XFS_DIR2_BLOCK_MAGIC); 958 block->hdr.magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC);
960 needlog = 1; 959 needlog = 1;
961 needscan = 0; 960 needscan = 0;
962 /* 961 /*
@@ -1095,7 +1094,7 @@ xfs_dir2_sf_to_block(
1095 return error; 1094 return error;
1096 } 1095 }
1097 block = bp->data; 1096 block = bp->data;
1098 INT_SET(block->hdr.magic, ARCH_CONVERT, XFS_DIR2_BLOCK_MAGIC); 1097 block->hdr.magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC);
1099 /* 1098 /*
1100 * Compute size of block "tail" area. 1099 * Compute size of block "tail" area.
1101 */ 1100 */
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c
index 5b7c47e2f14..fd6b7c03018 100644
--- a/fs/xfs/xfs_dir2_data.c
+++ b/fs/xfs/xfs_dir2_data.c
@@ -70,11 +70,11 @@ xfs_dir2_data_check(
70 70
71 mp = dp->i_mount; 71 mp = dp->i_mount;
72 d = bp->data; 72 d = bp->data;
73 ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || 73 ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
74 INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); 74 be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
75 bf = d->hdr.bestfree; 75 bf = d->hdr.bestfree;
76 p = (char *)d->u; 76 p = (char *)d->u;
77 if (INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC) { 77 if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) {
78 btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d); 78 btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d);
79 lep = XFS_DIR2_BLOCK_LEAF_P(btp); 79 lep = XFS_DIR2_BLOCK_LEAF_P(btp);
80 endp = (char *)lep; 80 endp = (char *)lep;
@@ -96,8 +96,8 @@ xfs_dir2_data_check(
96 ASSERT(!bf[2].offset); 96 ASSERT(!bf[2].offset);
97 freeseen |= 1 << 2; 97 freeseen |= 1 << 2;
98 } 98 }
99 ASSERT(INT_GET(bf[0].length, ARCH_CONVERT) >= INT_GET(bf[1].length, ARCH_CONVERT)); 99 ASSERT(be16_to_cpu(bf[0].length) >= be16_to_cpu(bf[1].length));
100 ASSERT(INT_GET(bf[1].length, ARCH_CONVERT) >= INT_GET(bf[2].length, ARCH_CONVERT)); 100 ASSERT(be16_to_cpu(bf[1].length) >= be16_to_cpu(bf[2].length));
101 /* 101 /*
102 * Loop over the data/unused entries. 102 * Loop over the data/unused entries.
103 */ 103 */
@@ -117,8 +117,10 @@ xfs_dir2_data_check(
117 i = (int)(dfp - bf); 117 i = (int)(dfp - bf);
118 ASSERT((freeseen & (1 << i)) == 0); 118 ASSERT((freeseen & (1 << i)) == 0);
119 freeseen |= 1 << i; 119 freeseen |= 1 << i;
120 } else 120 } else {
121 ASSERT(INT_GET(dup->length, ARCH_CONVERT) <= INT_GET(bf[2].length, ARCH_CONVERT)); 121 ASSERT(INT_GET(dup->length, ARCH_CONVERT) <=
122 be16_to_cpu(bf[2].length));
123 }
122 p += INT_GET(dup->length, ARCH_CONVERT); 124 p += INT_GET(dup->length, ARCH_CONVERT);
123 lastfree = 1; 125 lastfree = 1;
124 continue; 126 continue;
@@ -136,7 +138,7 @@ xfs_dir2_data_check(
136 (char *)dep - (char *)d); 138 (char *)dep - (char *)d);
137 count++; 139 count++;
138 lastfree = 0; 140 lastfree = 0;
139 if (INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC) { 141 if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) {
140 addr = XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk, 142 addr = XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk,
141 (xfs_dir2_data_aoff_t) 143 (xfs_dir2_data_aoff_t)
142 ((char *)dep - (char *)d)); 144 ((char *)dep - (char *)d));
@@ -154,7 +156,7 @@ xfs_dir2_data_check(
154 * Need to have seen all the entries and all the bestfree slots. 156 * Need to have seen all the entries and all the bestfree slots.
155 */ 157 */
156 ASSERT(freeseen == 7); 158 ASSERT(freeseen == 7);
157 if (INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC) { 159 if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) {
158 for (i = stale = 0; i < INT_GET(btp->count, ARCH_CONVERT); i++) { 160 for (i = stale = 0; i < INT_GET(btp->count, ARCH_CONVERT); i++) {
159 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)
160 stale++; 162 stale++;
@@ -190,8 +192,8 @@ xfs_dir2_data_freefind(
190 * Check order, non-overlapping entries, and if we find the 192 * Check order, non-overlapping entries, and if we find the
191 * one we're looking for it has to be exact. 193 * one we're looking for it has to be exact.
192 */ 194 */
193 ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || 195 ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
194 INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); 196 be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
195 for (dfp = &d->hdr.bestfree[0], seenzero = matched = 0; 197 for (dfp = &d->hdr.bestfree[0], seenzero = matched = 0;
196 dfp < &d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT]; 198 dfp < &d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT];
197 dfp++) { 199 dfp++) {
@@ -201,23 +203,24 @@ xfs_dir2_data_freefind(
201 continue; 203 continue;
202 } 204 }
203 ASSERT(seenzero == 0); 205 ASSERT(seenzero == 0);
204 if (INT_GET(dfp->offset, ARCH_CONVERT) == off) { 206 if (be16_to_cpu(dfp->offset) == off) {
205 matched = 1; 207 matched = 1;
206 ASSERT(INT_GET(dfp->length, ARCH_CONVERT) == INT_GET(dup->length, ARCH_CONVERT)); 208 ASSERT(be16_to_cpu(dfp->length) == INT_GET(dup->length, ARCH_CONVERT));
207 } else if (off < INT_GET(dfp->offset, ARCH_CONVERT)) 209 } else if (off < be16_to_cpu(dfp->offset))
208 ASSERT(off + INT_GET(dup->length, ARCH_CONVERT) <= INT_GET(dfp->offset, ARCH_CONVERT)); 210 ASSERT(off + INT_GET(dup->length, ARCH_CONVERT) <= be16_to_cpu(dfp->offset));
209 else 211 else
210 ASSERT(INT_GET(dfp->offset, ARCH_CONVERT) + INT_GET(dfp->length, ARCH_CONVERT) <= off); 212 ASSERT(be16_to_cpu(dfp->offset) + be16_to_cpu(dfp->length) <= off);
211 ASSERT(matched || INT_GET(dfp->length, ARCH_CONVERT) >= INT_GET(dup->length, ARCH_CONVERT)); 213 ASSERT(matched || be16_to_cpu(dfp->length) >= INT_GET(dup->length, ARCH_CONVERT));
212 if (dfp > &d->hdr.bestfree[0]) 214 if (dfp > &d->hdr.bestfree[0])
213 ASSERT(INT_GET(dfp[-1].length, ARCH_CONVERT) >= INT_GET(dfp[0].length, ARCH_CONVERT)); 215 ASSERT(be16_to_cpu(dfp[-1].length) >= be16_to_cpu(dfp[0].length));
214 } 216 }
215#endif 217#endif
216 /* 218 /*
217 * If this is smaller than the smallest bestfree entry, 219 * If this is smaller than the smallest bestfree entry,
218 * it can't be there since they're sorted. 220 * it can't be there since they're sorted.
219 */ 221 */
220 if (INT_GET(dup->length, ARCH_CONVERT) < INT_GET(d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT - 1].length, ARCH_CONVERT)) 222 if (INT_GET(dup->length, ARCH_CONVERT) <
223 be16_to_cpu(d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT - 1].length))
221 return NULL; 224 return NULL;
222 /* 225 /*
223 * Look at the three bestfree entries for our guy. 226 * Look at the three bestfree entries for our guy.
@@ -227,7 +230,7 @@ xfs_dir2_data_freefind(
227 dfp++) { 230 dfp++) {
228 if (!dfp->offset) 231 if (!dfp->offset)
229 return NULL; 232 return NULL;
230 if (INT_GET(dfp->offset, ARCH_CONVERT) == off) 233 if (be16_to_cpu(dfp->offset) == off)
231 return dfp; 234 return dfp;
232 } 235 }
233 /* 236 /*
@@ -249,29 +252,29 @@ xfs_dir2_data_freeinsert(
249 xfs_dir2_data_free_t new; /* new bestfree entry */ 252 xfs_dir2_data_free_t new; /* new bestfree entry */
250 253
251#ifdef __KERNEL__ 254#ifdef __KERNEL__
252 ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || 255 ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
253 INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); 256 be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
254#endif 257#endif
255 dfp = d->hdr.bestfree; 258 dfp = d->hdr.bestfree;
256 INT_COPY(new.length, dup->length, ARCH_CONVERT); 259 new.length = dup->length;
257 INT_SET(new.offset, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dup - (char *)d)); 260 new.offset = cpu_to_be16((char *)dup - (char *)d);
258 /* 261 /*
259 * Insert at position 0, 1, or 2; or not at all. 262 * Insert at position 0, 1, or 2; or not at all.
260 */ 263 */
261 if (INT_GET(new.length, ARCH_CONVERT) > INT_GET(dfp[0].length, ARCH_CONVERT)) { 264 if (be16_to_cpu(new.length) > be16_to_cpu(dfp[0].length)) {
262 dfp[2] = dfp[1]; 265 dfp[2] = dfp[1];
263 dfp[1] = dfp[0]; 266 dfp[1] = dfp[0];
264 dfp[0] = new; 267 dfp[0] = new;
265 *loghead = 1; 268 *loghead = 1;
266 return &dfp[0]; 269 return &dfp[0];
267 } 270 }
268 if (INT_GET(new.length, ARCH_CONVERT) > INT_GET(dfp[1].length, ARCH_CONVERT)) { 271 if (be16_to_cpu(new.length) > be16_to_cpu(dfp[1].length)) {
269 dfp[2] = dfp[1]; 272 dfp[2] = dfp[1];
270 dfp[1] = new; 273 dfp[1] = new;
271 *loghead = 1; 274 *loghead = 1;
272 return &dfp[1]; 275 return &dfp[1];
273 } 276 }
274 if (INT_GET(new.length, ARCH_CONVERT) > INT_GET(dfp[2].length, ARCH_CONVERT)) { 277 if (be16_to_cpu(new.length) > be16_to_cpu(dfp[2].length)) {
275 dfp[2] = new; 278 dfp[2] = new;
276 *loghead = 1; 279 *loghead = 1;
277 return &dfp[2]; 280 return &dfp[2];
@@ -289,8 +292,8 @@ xfs_dir2_data_freeremove(
289 int *loghead) /* out: log data header */ 292 int *loghead) /* out: log data header */
290{ 293{
291#ifdef __KERNEL__ 294#ifdef __KERNEL__
292 ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || 295 ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
293 INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); 296 be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
294#endif 297#endif
295 /* 298 /*
296 * It's the first entry, slide the next 2 up. 299 * It's the first entry, slide the next 2 up.
@@ -334,8 +337,8 @@ xfs_dir2_data_freescan(
334 char *p; /* current entry pointer */ 337 char *p; /* current entry pointer */
335 338
336#ifdef __KERNEL__ 339#ifdef __KERNEL__
337 ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || 340 ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
338 INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); 341 be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
339#endif 342#endif
340 /* 343 /*
341 * Start by clearing the table. 344 * Start by clearing the table.
@@ -348,7 +351,7 @@ xfs_dir2_data_freescan(
348 p = (char *)d->u; 351 p = (char *)d->u;
349 if (aendp) 352 if (aendp)
350 endp = aendp; 353 endp = aendp;
351 else if (INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC) { 354 else if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) {
352 btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d); 355 btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d);
353 endp = (char *)XFS_DIR2_BLOCK_LEAF_P(btp); 356 endp = (char *)XFS_DIR2_BLOCK_LEAF_P(btp);
354 } else 357 } else
@@ -415,8 +418,8 @@ xfs_dir2_data_init(
415 * Initialize the header. 418 * Initialize the header.
416 */ 419 */
417 d = bp->data; 420 d = bp->data;
418 INT_SET(d->hdr.magic, ARCH_CONVERT, XFS_DIR2_DATA_MAGIC); 421 d->hdr.magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC);
419 INT_SET(d->hdr.bestfree[0].offset, ARCH_CONVERT, (xfs_dir2_data_off_t)sizeof(d->hdr)); 422 d->hdr.bestfree[0].offset = cpu_to_be16(sizeof(d->hdr));
420 for (i = 1; i < XFS_DIR2_DATA_FD_COUNT; i++) { 423 for (i = 1; i < XFS_DIR2_DATA_FD_COUNT; i++) {
421 d->hdr.bestfree[i].length = 0; 424 d->hdr.bestfree[i].length = 0;
422 d->hdr.bestfree[i].offset = 0; 425 d->hdr.bestfree[i].offset = 0;
@@ -428,7 +431,7 @@ xfs_dir2_data_init(
428 INT_SET(dup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG); 431 INT_SET(dup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG);
429 432
430 t=mp->m_dirblksize - (uint)sizeof(d->hdr); 433 t=mp->m_dirblksize - (uint)sizeof(d->hdr);
431 INT_SET(d->hdr.bestfree[0].length, ARCH_CONVERT, t); 434 d->hdr.bestfree[0].length = cpu_to_be16(t);
432 INT_SET(dup->length, ARCH_CONVERT, t); 435 INT_SET(dup->length, ARCH_CONVERT, t);
433 INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT, 436 INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT,
434 (xfs_dir2_data_off_t)((char *)dup - (char *)d)); 437 (xfs_dir2_data_off_t)((char *)dup - (char *)d));
@@ -453,8 +456,8 @@ xfs_dir2_data_log_entry(
453 xfs_dir2_data_t *d; /* data block pointer */ 456 xfs_dir2_data_t *d; /* data block pointer */
454 457
455 d = bp->data; 458 d = bp->data;
456 ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || 459 ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
457 INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); 460 be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
458 xfs_da_log_buf(tp, bp, (uint)((char *)dep - (char *)d), 461 xfs_da_log_buf(tp, bp, (uint)((char *)dep - (char *)d),
459 (uint)((char *)(XFS_DIR2_DATA_ENTRY_TAG_P(dep) + 1) - 462 (uint)((char *)(XFS_DIR2_DATA_ENTRY_TAG_P(dep) + 1) -
460 (char *)d - 1)); 463 (char *)d - 1));
@@ -471,8 +474,8 @@ xfs_dir2_data_log_header(
471 xfs_dir2_data_t *d; /* data block pointer */ 474 xfs_dir2_data_t *d; /* data block pointer */
472 475
473 d = bp->data; 476 d = bp->data;
474 ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || 477 ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
475 INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); 478 be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
476 xfs_da_log_buf(tp, bp, (uint)((char *)&d->hdr - (char *)d), 479 xfs_da_log_buf(tp, bp, (uint)((char *)&d->hdr - (char *)d),
477 (uint)(sizeof(d->hdr) - 1)); 480 (uint)(sizeof(d->hdr) - 1));
478} 481}
@@ -489,8 +492,8 @@ xfs_dir2_data_log_unused(
489 xfs_dir2_data_t *d; /* data block pointer */ 492 xfs_dir2_data_t *d; /* data block pointer */
490 493
491 d = bp->data; 494 d = bp->data;
492 ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || 495 ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
493 INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); 496 be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
494 /* 497 /*
495 * Log the first part of the unused entry. 498 * Log the first part of the unused entry.
496 */ 499 */
@@ -533,12 +536,12 @@ xfs_dir2_data_make_free(
533 /* 536 /*
534 * Figure out where the end of the data area is. 537 * Figure out where the end of the data area is.
535 */ 538 */
536 if (INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC) 539 if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC)
537 endptr = (char *)d + mp->m_dirblksize; 540 endptr = (char *)d + mp->m_dirblksize;
538 else { 541 else {
539 xfs_dir2_block_tail_t *btp; /* block tail */ 542 xfs_dir2_block_tail_t *btp; /* block tail */
540 543
541 ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); 544 ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
542 btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d); 545 btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d);
543 endptr = (char *)XFS_DIR2_BLOCK_LEAF_P(btp); 546 endptr = (char *)XFS_DIR2_BLOCK_LEAF_P(btp);
544 } 547 }
@@ -586,7 +589,7 @@ xfs_dir2_data_make_free(
586 * since the third bestfree is there, there might be more 589 * since the third bestfree is there, there might be more
587 * entries. 590 * entries.
588 */ 591 */
589 needscan = d->hdr.bestfree[2].length; 592 needscan = (d->hdr.bestfree[2].length != 0);
590 /* 593 /*
591 * Fix up the new big freespace. 594 * Fix up the new big freespace.
592 */ 595 */
@@ -614,7 +617,7 @@ xfs_dir2_data_make_free(
614 */ 617 */
615 dfp = xfs_dir2_data_freeinsert(d, prevdup, needlogp); 618 dfp = xfs_dir2_data_freeinsert(d, prevdup, needlogp);
616 ASSERT(dfp == &d->hdr.bestfree[0]); 619 ASSERT(dfp == &d->hdr.bestfree[0]);
617 ASSERT(INT_GET(dfp->length, ARCH_CONVERT) == INT_GET(prevdup->length, ARCH_CONVERT)); 620 ASSERT(be16_to_cpu(dfp->length) == INT_GET(prevdup->length, ARCH_CONVERT));
618 ASSERT(!dfp[1].length); 621 ASSERT(!dfp[1].length);
619 ASSERT(!dfp[2].length); 622 ASSERT(!dfp[2].length);
620 } 623 }
@@ -640,8 +643,10 @@ xfs_dir2_data_make_free(
640 /* 643 /*
641 * Otherwise we need a scan if the new entry is big enough. 644 * Otherwise we need a scan if the new entry is big enough.
642 */ 645 */
643 else 646 else {
644 needscan = INT_GET(prevdup->length, ARCH_CONVERT) > INT_GET(d->hdr.bestfree[2].length, ARCH_CONVERT); 647 needscan = INT_GET(prevdup->length, ARCH_CONVERT) >
648 be16_to_cpu(d->hdr.bestfree[2].length);
649 }
645 } 650 }
646 /* 651 /*
647 * The following entry is free, merge with it. 652 * The following entry is free, merge with it.
@@ -666,8 +671,10 @@ xfs_dir2_data_make_free(
666 /* 671 /*
667 * Otherwise we need a scan if the new entry is big enough. 672 * Otherwise we need a scan if the new entry is big enough.
668 */ 673 */
669 else 674 else {
670 needscan = INT_GET(newdup->length, ARCH_CONVERT) > INT_GET(d->hdr.bestfree[2].length, ARCH_CONVERT); 675 needscan = INT_GET(newdup->length, ARCH_CONVERT) >
676 be16_to_cpu(d->hdr.bestfree[2].length);
677 }
671 } 678 }
672 /* 679 /*
673 * Neither neighbor is free. Make a new entry. 680 * Neither neighbor is free. Make a new entry.
@@ -707,8 +714,8 @@ xfs_dir2_data_use_free(
707 int oldlen; /* old unused entry's length */ 714 int oldlen; /* old unused entry's length */
708 715
709 d = bp->data; 716 d = bp->data;
710 ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || 717 ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
711 INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); 718 be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
712 ASSERT(INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG); 719 ASSERT(INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG);
713 ASSERT(offset >= (char *)dup - (char *)d); 720 ASSERT(offset >= (char *)dup - (char *)d);
714 ASSERT(offset + len <= (char *)dup + INT_GET(dup->length, ARCH_CONVERT) - (char *)d); 721 ASSERT(offset + len <= (char *)dup + INT_GET(dup->length, ARCH_CONVERT) - (char *)d);
@@ -718,7 +725,7 @@ xfs_dir2_data_use_free(
718 */ 725 */
719 dfp = xfs_dir2_data_freefind(d, dup); 726 dfp = xfs_dir2_data_freefind(d, dup);
720 oldlen = INT_GET(dup->length, ARCH_CONVERT); 727 oldlen = INT_GET(dup->length, ARCH_CONVERT);
721 ASSERT(dfp || oldlen <= INT_GET(d->hdr.bestfree[2].length, ARCH_CONVERT)); 728 ASSERT(dfp || oldlen <= be16_to_cpu(d->hdr.bestfree[2].length));
722 /* 729 /*
723 * Check for alignment with front and back of the entry. 730 * Check for alignment with front and back of the entry.
724 */ 731 */
@@ -732,7 +739,7 @@ xfs_dir2_data_use_free(
732 */ 739 */
733 if (matchfront && matchback) { 740 if (matchfront && matchback) {
734 if (dfp) { 741 if (dfp) {
735 needscan = d->hdr.bestfree[2].offset; 742 needscan = (d->hdr.bestfree[2].offset != 0);
736 if (!needscan) 743 if (!needscan)
737 xfs_dir2_data_freeremove(d, dfp, needlogp); 744 xfs_dir2_data_freeremove(d, dfp, needlogp);
738 } 745 }
@@ -755,8 +762,8 @@ xfs_dir2_data_use_free(
755 xfs_dir2_data_freeremove(d, dfp, needlogp); 762 xfs_dir2_data_freeremove(d, dfp, needlogp);
756 dfp = xfs_dir2_data_freeinsert(d, newdup, needlogp); 763 dfp = xfs_dir2_data_freeinsert(d, newdup, needlogp);
757 ASSERT(dfp != NULL); 764 ASSERT(dfp != NULL);
758 ASSERT(INT_GET(dfp->length, ARCH_CONVERT) == INT_GET(newdup->length, ARCH_CONVERT)); 765 ASSERT(be16_to_cpu(dfp->length) == INT_GET(newdup->length, ARCH_CONVERT));
759 ASSERT(INT_GET(dfp->offset, ARCH_CONVERT) == (char *)newdup - (char *)d); 766 ASSERT(be16_to_cpu(dfp->offset) == (char *)newdup - (char *)d);
760 /* 767 /*
761 * If we got inserted at the last slot, 768 * If we got inserted at the last slot,
762 * that means we don't know if there was a better 769 * that means we don't know if there was a better
@@ -783,8 +790,8 @@ xfs_dir2_data_use_free(
783 xfs_dir2_data_freeremove(d, dfp, needlogp); 790 xfs_dir2_data_freeremove(d, dfp, needlogp);
784 dfp = xfs_dir2_data_freeinsert(d, newdup, needlogp); 791 dfp = xfs_dir2_data_freeinsert(d, newdup, needlogp);
785 ASSERT(dfp != NULL); 792 ASSERT(dfp != NULL);
786 ASSERT(INT_GET(dfp->length, ARCH_CONVERT) == INT_GET(newdup->length, ARCH_CONVERT)); 793 ASSERT(be16_to_cpu(dfp->length) == INT_GET(newdup->length, ARCH_CONVERT));
787 ASSERT(INT_GET(dfp->offset, ARCH_CONVERT) == (char *)newdup - (char *)d); 794 ASSERT(be16_to_cpu(dfp->offset) == (char *)newdup - (char *)d);
788 /* 795 /*
789 * If we got inserted at the last slot, 796 * If we got inserted at the last slot,
790 * that means we don't know if there was a better 797 * that means we don't know if there was a better
@@ -819,7 +826,7 @@ xfs_dir2_data_use_free(
819 * the 2 new will work. 826 * the 2 new will work.
820 */ 827 */
821 if (dfp) { 828 if (dfp) {
822 needscan = d->hdr.bestfree[2].length; 829 needscan = (d->hdr.bestfree[2].length != 0);
823 if (!needscan) { 830 if (!needscan) {
824 xfs_dir2_data_freeremove(d, dfp, needlogp); 831 xfs_dir2_data_freeremove(d, dfp, needlogp);
825 (void)xfs_dir2_data_freeinsert(d, newdup, 832 (void)xfs_dir2_data_freeinsert(d, newdup,
diff --git a/fs/xfs/xfs_dir2_data.h b/fs/xfs/xfs_dir2_data.h
index 5e3a7f9ec73..dd8b8652363 100644
--- a/fs/xfs/xfs_dir2_data.h
+++ b/fs/xfs/xfs_dir2_data.h
@@ -65,8 +65,8 @@ struct xfs_trans;
65 * The freespace will be formatted as a xfs_dir2_data_unused_t. 65 * The freespace will be formatted as a xfs_dir2_data_unused_t.
66 */ 66 */
67typedef struct xfs_dir2_data_free { 67typedef struct xfs_dir2_data_free {
68 xfs_dir2_data_off_t offset; /* start of freespace */ 68 __be16 offset; /* start of freespace */
69 xfs_dir2_data_off_t length; /* length of freespace */ 69 __be16 length; /* length of freespace */
70} xfs_dir2_data_free_t; 70} xfs_dir2_data_free_t;
71 71
72/* 72/*
@@ -75,7 +75,7 @@ typedef struct xfs_dir2_data_free {
75 * The code knows that XFS_DIR2_DATA_FD_COUNT is 3. 75 * The code knows that XFS_DIR2_DATA_FD_COUNT is 3.
76 */ 76 */
77typedef struct xfs_dir2_data_hdr { 77typedef struct xfs_dir2_data_hdr {
78 __uint32_t magic; /* XFS_DIR2_DATA_MAGIC */ 78 __be32 magic; /* XFS_DIR2_DATA_MAGIC */
79 /* or XFS_DIR2_BLOCK_MAGIC */ 79 /* or XFS_DIR2_BLOCK_MAGIC */
80 xfs_dir2_data_free_t bestfree[XFS_DIR2_DATA_FD_COUNT]; 80 xfs_dir2_data_free_t bestfree[XFS_DIR2_DATA_FD_COUNT];
81} xfs_dir2_data_hdr_t; 81} xfs_dir2_data_hdr_t;
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index e4e07c8f7a7..8d7f154d190 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -133,7 +133,7 @@ xfs_dir2_block_to_leaf(
133 /* 133 /*
134 * Fix up the block header, make it a data block. 134 * Fix up the block header, make it a data block.
135 */ 135 */
136 INT_SET(block->hdr.magic, ARCH_CONVERT, XFS_DIR2_DATA_MAGIC); 136 block->hdr.magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC);
137 if (needscan) 137 if (needscan)
138 xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)block, &needlog, 138 xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)block, &needlog,
139 NULL); 139 NULL);
@@ -143,7 +143,7 @@ xfs_dir2_block_to_leaf(
143 ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); 143 ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf);
144 INT_SET(ltp->bestcount, ARCH_CONVERT, 1); 144 INT_SET(ltp->bestcount, ARCH_CONVERT, 1);
145 bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); 145 bestsp = XFS_DIR2_LEAF_BESTS_P(ltp);
146 INT_COPY(bestsp[0], block->hdr.bestfree[0].length, ARCH_CONVERT); 146 bestsp[0] = block->hdr.bestfree[0].length;
147 /* 147 /*
148 * Log the data header and leaf bests table. 148 * Log the data header and leaf bests table.
149 */ 149 */
@@ -372,7 +372,7 @@ xfs_dir2_leaf_addname(
372 else 372 else
373 xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); 373 xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block);
374 data = dbp->data; 374 data = dbp->data;
375 INT_COPY(bestsp[use_block], data->hdr.bestfree[0].length, ARCH_CONVERT); 375 bestsp[use_block] = data->hdr.bestfree[0].length;
376 grown = 1; 376 grown = 1;
377 } 377 }
378 /* 378 /*
@@ -394,7 +394,7 @@ xfs_dir2_leaf_addname(
394 * Point to the biggest freespace in our data block. 394 * Point to the biggest freespace in our data block.
395 */ 395 */
396 dup = (xfs_dir2_data_unused_t *) 396 dup = (xfs_dir2_data_unused_t *)
397 ((char *)data + INT_GET(data->hdr.bestfree[0].offset, ARCH_CONVERT)); 397 ((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset));
398 ASSERT(INT_GET(dup->length, ARCH_CONVERT) >= length); 398 ASSERT(INT_GET(dup->length, ARCH_CONVERT) >= length);
399 needscan = needlog = 0; 399 needscan = needlog = 0;
400 /* 400 /*
@@ -427,8 +427,8 @@ xfs_dir2_leaf_addname(
427 * If the bests table needs to be changed, do it. 427 * If the bests table needs to be changed, do it.
428 * Log the change unless we've already done that. 428 * Log the change unless we've already done that.
429 */ 429 */
430 if (INT_GET(bestsp[use_block], ARCH_CONVERT) != INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT)) { 430 if (INT_GET(bestsp[use_block], ARCH_CONVERT) != be16_to_cpu(data->hdr.bestfree[0].length)) {
431 INT_COPY(bestsp[use_block], data->hdr.bestfree[0].length, ARCH_CONVERT); 431 bestsp[use_block] = data->hdr.bestfree[0].length;
432 if (!grown) 432 if (!grown)
433 xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); 433 xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block);
434 } 434 }
@@ -1477,7 +1477,7 @@ xfs_dir2_leaf_removename(
1477 dep = (xfs_dir2_data_entry_t *) 1477 dep = (xfs_dir2_data_entry_t *)
1478 ((char *)data + XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT))); 1478 ((char *)data + XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT)));
1479 needscan = needlog = 0; 1479 needscan = needlog = 0;
1480 oldbest = INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT); 1480 oldbest = be16_to_cpu(data->hdr.bestfree[0].length);
1481 ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); 1481 ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf);
1482 bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); 1482 bestsp = XFS_DIR2_LEAF_BESTS_P(ltp);
1483 ASSERT(INT_GET(bestsp[db], ARCH_CONVERT) == oldbest); 1483 ASSERT(INT_GET(bestsp[db], ARCH_CONVERT) == oldbest);
@@ -1506,15 +1506,15 @@ xfs_dir2_leaf_removename(
1506 * If the longest freespace in the data block has changed, 1506 * If the longest freespace in the data block has changed,
1507 * put the new value in the bests table and log that. 1507 * put the new value in the bests table and log that.
1508 */ 1508 */
1509 if (INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) != oldbest) { 1509 if (be16_to_cpu(data->hdr.bestfree[0].length) != oldbest) {
1510 INT_COPY(bestsp[db], data->hdr.bestfree[0].length, ARCH_CONVERT); 1510 bestsp[db] = data->hdr.bestfree[0].length;
1511 xfs_dir2_leaf_log_bests(tp, lbp, db, db); 1511 xfs_dir2_leaf_log_bests(tp, lbp, db, db);
1512 } 1512 }
1513 xfs_dir2_data_check(dp, dbp); 1513 xfs_dir2_data_check(dp, dbp);
1514 /* 1514 /*
1515 * If the data block is now empty then get rid of the data block. 1515 * If the data block is now empty then get rid of the data block.
1516 */ 1516 */
1517 if (INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) == 1517 if (be16_to_cpu(data->hdr.bestfree[0].length) ==
1518 mp->m_dirblksize - (uint)sizeof(data->hdr)) { 1518 mp->m_dirblksize - (uint)sizeof(data->hdr)) {
1519 ASSERT(db != mp->m_dirdatablk); 1519 ASSERT(db != mp->m_dirdatablk);
1520 if ((error = xfs_dir2_shrink_inode(args, db, dbp))) { 1520 if ((error = xfs_dir2_shrink_inode(args, db, dbp))) {
@@ -1708,7 +1708,7 @@ xfs_dir2_leaf_trim_data(
1708 } 1708 }
1709#ifdef DEBUG 1709#ifdef DEBUG
1710 data = dbp->data; 1710 data = dbp->data;
1711 ASSERT(INT_GET(data->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC); 1711 ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC);
1712#endif 1712#endif
1713 /* this seems to be an error 1713 /* this seems to be an error
1714 * data is only valid if DEBUG is defined? 1714 * data is only valid if DEBUG is defined?
@@ -1717,7 +1717,7 @@ xfs_dir2_leaf_trim_data(
1717 1717
1718 leaf = lbp->data; 1718 leaf = lbp->data;
1719 ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); 1719 ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf);
1720 ASSERT(INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) == 1720 ASSERT(be16_to_cpu(data->hdr.bestfree[0].length) ==
1721 mp->m_dirblksize - (uint)sizeof(data->hdr)); 1721 mp->m_dirblksize - (uint)sizeof(data->hdr));
1722 ASSERT(db == INT_GET(ltp->bestcount, ARCH_CONVERT) - 1); 1722 ASSERT(db == INT_GET(ltp->bestcount, ARCH_CONVERT) - 1);
1723 /* 1723 /*
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index 641f8633d25..e47bde74eec 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -894,7 +894,7 @@ xfs_dir2_leafn_remove(
894 dbp = dblk->bp; 894 dbp = dblk->bp;
895 data = dbp->data; 895 data = dbp->data;
896 dep = (xfs_dir2_data_entry_t *)((char *)data + off); 896 dep = (xfs_dir2_data_entry_t *)((char *)data + off);
897 longest = INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT); 897 longest = be16_to_cpu(data->hdr.bestfree[0].length);
898 needlog = needscan = 0; 898 needlog = needscan = 0;
899 xfs_dir2_data_make_free(tp, dbp, off, 899 xfs_dir2_data_make_free(tp, dbp, off,
900 XFS_DIR2_DATA_ENTSIZE(dep->namelen), &needlog, &needscan); 900 XFS_DIR2_DATA_ENTSIZE(dep->namelen), &needlog, &needscan);
@@ -911,7 +911,7 @@ xfs_dir2_leafn_remove(
911 * If the longest data block freespace changes, need to update 911 * If the longest data block freespace changes, need to update
912 * the corresponding freeblock entry. 912 * the corresponding freeblock entry.
913 */ 913 */
914 if (longest < INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT)) { 914 if (longest < be16_to_cpu(data->hdr.bestfree[0].length)) {
915 int error; /* error return value */ 915 int error; /* error return value */
916 xfs_dabuf_t *fbp; /* freeblock buffer */ 916 xfs_dabuf_t *fbp; /* freeblock buffer */
917 xfs_dir2_db_t fdb; /* freeblock block number */ 917 xfs_dir2_db_t fdb; /* freeblock block number */
@@ -937,7 +937,7 @@ xfs_dir2_leafn_remove(
937 * Calculate which entry we need to fix. 937 * Calculate which entry we need to fix.
938 */ 938 */
939 findex = XFS_DIR2_DB_TO_FDINDEX(mp, db); 939 findex = XFS_DIR2_DB_TO_FDINDEX(mp, db);
940 longest = INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT); 940 longest = be16_to_cpu(data->hdr.bestfree[0].length);
941 /* 941 /*
942 * If the data block is now empty we can get rid of it 942 * If the data block is now empty we can get rid of it
943 * (usually). 943 * (usually).
@@ -1649,7 +1649,7 @@ xfs_dir2_node_addname_int(
1649 * change again. 1649 * change again.
1650 */ 1650 */
1651 data = dbp->data; 1651 data = dbp->data;
1652 INT_COPY(free->bests[findex], data->hdr.bestfree[0].length, ARCH_CONVERT); 1652 free->bests[findex] = data->hdr.bestfree[0].length;
1653 logfree = 1; 1653 logfree = 1;
1654 } 1654 }
1655 /* 1655 /*
@@ -1677,12 +1677,12 @@ xfs_dir2_node_addname_int(
1677 data = dbp->data; 1677 data = dbp->data;
1678 logfree = 0; 1678 logfree = 0;
1679 } 1679 }
1680 ASSERT(INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) >= length); 1680 ASSERT(be16_to_cpu(data->hdr.bestfree[0].length) >= length);
1681 /* 1681 /*
1682 * Point to the existing unused space. 1682 * Point to the existing unused space.
1683 */ 1683 */
1684 dup = (xfs_dir2_data_unused_t *) 1684 dup = (xfs_dir2_data_unused_t *)
1685 ((char *)data + INT_GET(data->hdr.bestfree[0].offset, ARCH_CONVERT)); 1685 ((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset));
1686 needscan = needlog = 0; 1686 needscan = needlog = 0;
1687 /* 1687 /*
1688 * Mark the first part of the unused space, inuse for us. 1688 * Mark the first part of the unused space, inuse for us.
@@ -1713,8 +1713,8 @@ xfs_dir2_node_addname_int(
1713 /* 1713 /*
1714 * If the freespace entry is now wrong, update it. 1714 * If the freespace entry is now wrong, update it.
1715 */ 1715 */
1716 if (INT_GET(free->bests[findex], ARCH_CONVERT) != INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT)) { 1716 if (INT_GET(free->bests[findex], ARCH_CONVERT) != be16_to_cpu(data->hdr.bestfree[0].length)) {
1717 INT_COPY(free->bests[findex], data->hdr.bestfree[0].length, ARCH_CONVERT); 1717 free->bests[findex] = data->hdr.bestfree[0].length;
1718 logfree = 1; 1718 logfree = 1;
1719 } 1719 }
1720 /* 1720 /*
@@ -1900,7 +1900,7 @@ xfs_dir2_node_replace(
1900 * Point to the data entry. 1900 * Point to the data entry.
1901 */ 1901 */
1902 data = state->extrablk.bp->data; 1902 data = state->extrablk.bp->data;
1903 ASSERT(INT_GET(data->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC); 1903 ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC);
1904 dep = (xfs_dir2_data_entry_t *) 1904 dep = (xfs_dir2_data_entry_t *)
1905 ((char *)data + 1905 ((char *)data +
1906 XFS_DIR2_DATAPTR_TO_OFF(state->mp, INT_GET(lep->address, ARCH_CONVERT))); 1906 XFS_DIR2_DATAPTR_TO_OFF(state->mp, INT_GET(lep->address, ARCH_CONVERT)));