aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fs/xfs/xfs_dir2_block.c27
-rw-r--r--fs/xfs/xfs_dir2_data.c68
-rw-r--r--fs/xfs/xfs_dir2_data.h8
-rw-r--r--fs/xfs/xfs_dir2_leaf.c12
-rw-r--r--fs/xfs/xfs_dir2_sf.c4
5 files changed, 58 insertions, 61 deletions
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c
index f70640c6b70..8b8aed77acd 100644
--- a/fs/xfs/xfs_dir2_block.c
+++ b/fs/xfs/xfs_dir2_block.c
@@ -130,7 +130,7 @@ xfs_dir2_block_addname(
* the space before the first leaf entry needs to be free so it
* can be expanded to hold the pointer to the new entry.
*/
- if (INT_GET(enddup->freetag, ARCH_CONVERT) != XFS_DIR2_DATA_FREE_TAG)
+ if (be16_to_cpu(enddup->freetag) != XFS_DIR2_DATA_FREE_TAG)
dup = enddup = NULL;
/*
* Check out the biggest freespace and see if it's the same one.
@@ -143,7 +143,7 @@ xfs_dir2_block_addname(
* It is the biggest freespace, is it too small
* to hold the new leaf too?
*/
- if (INT_GET(dup->length, ARCH_CONVERT) < len + (uint)sizeof(*blp)) {
+ if (be16_to_cpu(dup->length) < len + (uint)sizeof(*blp)) {
/*
* Yes, we use the second-largest
* entry instead if it works.
@@ -160,7 +160,7 @@ xfs_dir2_block_addname(
* Not the same free entry,
* just check its length.
*/
- if (INT_GET(dup->length, ARCH_CONVERT) < len) {
+ if (be16_to_cpu(dup->length) < len) {
dup = NULL;
}
}
@@ -192,8 +192,8 @@ xfs_dir2_block_addname(
* If it's not free then the data will go where the
* leaf data starts now, if it works at all.
*/
- if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) {
- if (INT_GET(dup->length, ARCH_CONVERT) + (INT_GET(btp->stale, ARCH_CONVERT) - 1) *
+ if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
+ if (be16_to_cpu(dup->length) + (INT_GET(btp->stale, ARCH_CONVERT) - 1) *
(uint)sizeof(*blp) < len)
dup = NULL;
} else if ((INT_GET(btp->stale, ARCH_CONVERT) - 1) * (uint)sizeof(*blp) < len)
@@ -310,7 +310,7 @@ xfs_dir2_block_addname(
*/
xfs_dir2_data_use_free(tp, bp, enddup,
(xfs_dir2_data_aoff_t)
- ((char *)enddup - (char *)block + INT_GET(enddup->length, ARCH_CONVERT) -
+ ((char *)enddup - (char *)block + be16_to_cpu(enddup->length) -
sizeof(*blp)),
(xfs_dir2_data_aoff_t)sizeof(*blp),
&needlog, &needscan);
@@ -484,8 +484,8 @@ xfs_dir2_block_getdents(
/*
* Unused, skip it.
*/
- if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) {
- ptr += INT_GET(dup->length, ARCH_CONVERT);
+ if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
+ ptr += be16_to_cpu(dup->length);
continue;
}
@@ -948,7 +948,8 @@ xfs_dir2_leaf_to_block(
/*
* If it's not free or is too short we can't do it.
*/
- if (INT_GET(dup->freetag, ARCH_CONVERT) != XFS_DIR2_DATA_FREE_TAG || INT_GET(dup->length, ARCH_CONVERT) < size) {
+ if (be16_to_cpu(dup->freetag) != XFS_DIR2_DATA_FREE_TAG ||
+ be16_to_cpu(dup->length) < size) {
error = 0;
goto out;
}
@@ -1122,7 +1123,7 @@ xfs_dir2_sf_to_block(
*/
xfs_dir2_data_use_free(tp, bp, dup,
(xfs_dir2_data_aoff_t)((char *)dup - (char *)block),
- INT_GET(dup->length, ARCH_CONVERT), &needlog, &needscan);
+ be16_to_cpu(dup->length), &needlog, &needscan);
/*
* Create entry for .
*/
@@ -1175,15 +1176,15 @@ xfs_dir2_sf_to_block(
if (offset < newoffset) {
dup = (xfs_dir2_data_unused_t *)
((char *)block + offset);
- INT_SET(dup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG);
- INT_SET(dup->length, ARCH_CONVERT, newoffset - offset);
+ dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
+ dup->length = cpu_to_be16(newoffset - offset);
INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT,
(xfs_dir2_data_off_t)
((char *)dup - (char *)block));
xfs_dir2_data_log_unused(tp, bp, dup);
(void)xfs_dir2_data_freeinsert((xfs_dir2_data_t *)block,
dup, &dummy);
- offset += INT_GET(dup->length, ARCH_CONVERT);
+ offset += be16_to_cpu(dup->length);
continue;
}
/*
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c
index fd6b7c03018..48b4906c8e8 100644
--- a/fs/xfs/xfs_dir2_data.c
+++ b/fs/xfs/xfs_dir2_data.c
@@ -108,7 +108,7 @@ xfs_dir2_data_check(
* If we find it, account for that, else make sure it
* doesn't need to be there.
*/
- if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) {
+ if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
ASSERT(lastfree == 0);
ASSERT(INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT) ==
(char *)dup - (char *)d);
@@ -118,10 +118,10 @@ xfs_dir2_data_check(
ASSERT((freeseen & (1 << i)) == 0);
freeseen |= 1 << i;
} else {
- ASSERT(INT_GET(dup->length, ARCH_CONVERT) <=
+ ASSERT(be16_to_cpu(dup->length) <=
be16_to_cpu(bf[2].length));
}
- p += INT_GET(dup->length, ARCH_CONVERT);
+ p += be16_to_cpu(dup->length);
lastfree = 1;
continue;
}
@@ -205,12 +205,12 @@ xfs_dir2_data_freefind(
ASSERT(seenzero == 0);
if (be16_to_cpu(dfp->offset) == off) {
matched = 1;
- ASSERT(be16_to_cpu(dfp->length) == INT_GET(dup->length, ARCH_CONVERT));
+ ASSERT(dfp->length == dup->length);
} else if (off < be16_to_cpu(dfp->offset))
- ASSERT(off + INT_GET(dup->length, ARCH_CONVERT) <= be16_to_cpu(dfp->offset));
+ ASSERT(off + be16_to_cpu(dup->length) <= be16_to_cpu(dfp->offset));
else
ASSERT(be16_to_cpu(dfp->offset) + be16_to_cpu(dfp->length) <= off);
- ASSERT(matched || be16_to_cpu(dfp->length) >= INT_GET(dup->length, ARCH_CONVERT));
+ ASSERT(matched || be16_to_cpu(dfp->length) >= be16_to_cpu(dup->length));
if (dfp > &d->hdr.bestfree[0])
ASSERT(be16_to_cpu(dfp[-1].length) >= be16_to_cpu(dfp[0].length));
}
@@ -219,7 +219,7 @@ xfs_dir2_data_freefind(
* If this is smaller than the smallest bestfree entry,
* it can't be there since they're sorted.
*/
- if (INT_GET(dup->length, ARCH_CONVERT) <
+ if (be16_to_cpu(dup->length) <
be16_to_cpu(d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT - 1].length))
return NULL;
/*
@@ -364,11 +364,11 @@ xfs_dir2_data_freescan(
/*
* If it's a free entry, insert it.
*/
- if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) {
+ if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
ASSERT((char *)dup - (char *)d ==
INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT));
xfs_dir2_data_freeinsert(d, dup, loghead);
- p += INT_GET(dup->length, ARCH_CONVERT);
+ p += be16_to_cpu(dup->length);
}
/*
* For active entries, check their tags and skip them.
@@ -428,11 +428,11 @@ xfs_dir2_data_init(
* Set up an unused entry for the block's body.
*/
dup = &d->u[0].unused;
- INT_SET(dup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG);
+ dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
t=mp->m_dirblksize - (uint)sizeof(d->hdr);
d->hdr.bestfree[0].length = cpu_to_be16(t);
- INT_SET(dup->length, ARCH_CONVERT, t);
+ dup->length = cpu_to_be16(t);
INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT,
(xfs_dir2_data_off_t)((char *)dup - (char *)d));
/*
@@ -554,7 +554,7 @@ xfs_dir2_data_make_free(
tagp = (xfs_dir2_data_off_t *)((char *)d + offset) - 1;
prevdup = (xfs_dir2_data_unused_t *)((char *)d + INT_GET(*tagp, ARCH_CONVERT));
- if (INT_GET(prevdup->freetag, ARCH_CONVERT) != XFS_DIR2_DATA_FREE_TAG)
+ if (be16_to_cpu(prevdup->freetag) != XFS_DIR2_DATA_FREE_TAG)
prevdup = NULL;
} else
prevdup = NULL;
@@ -565,7 +565,7 @@ xfs_dir2_data_make_free(
if ((char *)d + offset + len < endptr) {
postdup =
(xfs_dir2_data_unused_t *)((char *)d + offset + len);
- if (INT_GET(postdup->freetag, ARCH_CONVERT) != XFS_DIR2_DATA_FREE_TAG)
+ if (be16_to_cpu(postdup->freetag) != XFS_DIR2_DATA_FREE_TAG)
postdup = NULL;
} else
postdup = NULL;
@@ -593,7 +593,7 @@ xfs_dir2_data_make_free(
/*
* Fix up the new big freespace.
*/
- INT_MOD(prevdup->length, ARCH_CONVERT, len + INT_GET(postdup->length, ARCH_CONVERT));
+ be16_add(&prevdup->length, len + be16_to_cpu(postdup->length));
INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(prevdup), ARCH_CONVERT,
(xfs_dir2_data_off_t)((char *)prevdup - (char *)d));
xfs_dir2_data_log_unused(tp, bp, prevdup);
@@ -617,7 +617,7 @@ xfs_dir2_data_make_free(
*/
dfp = xfs_dir2_data_freeinsert(d, prevdup, needlogp);
ASSERT(dfp == &d->hdr.bestfree[0]);
- ASSERT(be16_to_cpu(dfp->length) == INT_GET(prevdup->length, ARCH_CONVERT));
+ ASSERT(dfp->length == prevdup->length);
ASSERT(!dfp[1].length);
ASSERT(!dfp[2].length);
}
@@ -627,7 +627,7 @@ xfs_dir2_data_make_free(
*/
else if (prevdup) {
dfp = xfs_dir2_data_freefind(d, prevdup);
- INT_MOD(prevdup->length, ARCH_CONVERT, len);
+ be16_add(&prevdup->length, len);
INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(prevdup), ARCH_CONVERT,
(xfs_dir2_data_off_t)((char *)prevdup - (char *)d));
xfs_dir2_data_log_unused(tp, bp, prevdup);
@@ -644,7 +644,7 @@ xfs_dir2_data_make_free(
* Otherwise we need a scan if the new entry is big enough.
*/
else {
- needscan = INT_GET(prevdup->length, ARCH_CONVERT) >
+ needscan = be16_to_cpu(prevdup->length) >
be16_to_cpu(d->hdr.bestfree[2].length);
}
}
@@ -654,8 +654,8 @@ xfs_dir2_data_make_free(
else if (postdup) {
dfp = xfs_dir2_data_freefind(d, postdup);
newdup = (xfs_dir2_data_unused_t *)((char *)d + offset);
- INT_SET(newdup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG);
- INT_SET(newdup->length, ARCH_CONVERT, len + INT_GET(postdup->length, ARCH_CONVERT));
+ newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
+ newdup->length = cpu_to_be16(len + be16_to_cpu(postdup->length));
INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT,
(xfs_dir2_data_off_t)((char *)newdup - (char *)d));
xfs_dir2_data_log_unused(tp, bp, newdup);
@@ -672,7 +672,7 @@ xfs_dir2_data_make_free(
* Otherwise we need a scan if the new entry is big enough.
*/
else {
- needscan = INT_GET(newdup->length, ARCH_CONVERT) >
+ needscan = be16_to_cpu(newdup->length) >
be16_to_cpu(d->hdr.bestfree[2].length);
}
}
@@ -681,8 +681,8 @@ xfs_dir2_data_make_free(
*/
else {
newdup = (xfs_dir2_data_unused_t *)((char *)d + offset);
- INT_SET(newdup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG);
- INT_SET(newdup->length, ARCH_CONVERT, len);
+ newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
+ newdup->length = cpu_to_be16(len);
INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT,
(xfs_dir2_data_off_t)((char *)newdup - (char *)d));
xfs_dir2_data_log_unused(tp, bp, newdup);
@@ -716,15 +716,15 @@ xfs_dir2_data_use_free(
d = bp->data;
ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
- ASSERT(INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG);
+ ASSERT(be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG);
ASSERT(offset >= (char *)dup - (char *)d);
- ASSERT(offset + len <= (char *)dup + INT_GET(dup->length, ARCH_CONVERT) - (char *)d);
+ ASSERT(offset + len <= (char *)dup + be16_to_cpu(dup->length) - (char *)d);
ASSERT((char *)dup - (char *)d == INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT));
/*
* Look up the entry in the bestfree table.
*/
dfp = xfs_dir2_data_freefind(d, dup);
- oldlen = INT_GET(dup->length, ARCH_CONVERT);
+ oldlen = be16_to_cpu(dup->length);
ASSERT(dfp || oldlen <= be16_to_cpu(d->hdr.bestfree[2].length));
/*
* Check for alignment with front and back of the entry.
@@ -750,8 +750,8 @@ xfs_dir2_data_use_free(
*/
else if (matchfront) {
newdup = (xfs_dir2_data_unused_t *)((char *)d + offset + len);
- INT_SET(newdup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG);
- INT_SET(newdup->length, ARCH_CONVERT, oldlen - len);
+ newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
+ newdup->length = cpu_to_be16(oldlen - len);
INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT,
(xfs_dir2_data_off_t)((char *)newdup - (char *)d));
xfs_dir2_data_log_unused(tp, bp, newdup);
@@ -762,7 +762,7 @@ xfs_dir2_data_use_free(
xfs_dir2_data_freeremove(d, dfp, needlogp);
dfp = xfs_dir2_data_freeinsert(d, newdup, needlogp);
ASSERT(dfp != NULL);
- ASSERT(be16_to_cpu(dfp->length) == INT_GET(newdup->length, ARCH_CONVERT));
+ ASSERT(dfp->length == newdup->length);
ASSERT(be16_to_cpu(dfp->offset) == (char *)newdup - (char *)d);
/*
* If we got inserted at the last slot,
@@ -778,8 +778,7 @@ xfs_dir2_data_use_free(
*/
else if (matchback) {
newdup = dup;
- INT_SET(newdup->length, ARCH_CONVERT, (xfs_dir2_data_off_t)
- (((char *)d + offset) - (char *)newdup));
+ newdup->length = cpu_to_be16(((char *)d + offset) - (char *)newdup);
INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT,
(xfs_dir2_data_off_t)((char *)newdup - (char *)d));
xfs_dir2_data_log_unused(tp, bp, newdup);
@@ -790,7 +789,7 @@ xfs_dir2_data_use_free(
xfs_dir2_data_freeremove(d, dfp, needlogp);
dfp = xfs_dir2_data_freeinsert(d, newdup, needlogp);
ASSERT(dfp != NULL);
- ASSERT(be16_to_cpu(dfp->length) == INT_GET(newdup->length, ARCH_CONVERT));
+ ASSERT(dfp->length == newdup->length);
ASSERT(be16_to_cpu(dfp->offset) == (char *)newdup - (char *)d);
/*
* If we got inserted at the last slot,
@@ -806,14 +805,13 @@ xfs_dir2_data_use_free(
*/
else {
newdup = dup;
- INT_SET(newdup->length, ARCH_CONVERT, (xfs_dir2_data_off_t)
- (((char *)d + offset) - (char *)newdup));
+ newdup->length = cpu_to_be16(((char *)d + offset) - (char *)newdup);
INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT,
(xfs_dir2_data_off_t)((char *)newdup - (char *)d));
xfs_dir2_data_log_unused(tp, bp, newdup);
newdup2 = (xfs_dir2_data_unused_t *)((char *)d + offset + len);
- INT_SET(newdup2->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG);
- INT_SET(newdup2->length, ARCH_CONVERT, oldlen - len - INT_GET(newdup->length, ARCH_CONVERT));
+ newdup2->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
+ newdup2->length = cpu_to_be16(oldlen - len - be16_to_cpu(newdup->length));
INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup2), ARCH_CONVERT,
(xfs_dir2_data_off_t)((char *)newdup2 - (char *)d));
xfs_dir2_data_log_unused(tp, bp, newdup2);
diff --git a/fs/xfs/xfs_dir2_data.h b/fs/xfs/xfs_dir2_data.h
index dd8b8652363..28adddb48e8 100644
--- a/fs/xfs/xfs_dir2_data.h
+++ b/fs/xfs/xfs_dir2_data.h
@@ -97,10 +97,10 @@ typedef struct xfs_dir2_data_entry {
* Tag appears as the last 2 bytes.
*/
typedef struct xfs_dir2_data_unused {
- __uint16_t freetag; /* XFS_DIR2_DATA_FREE_TAG */
- xfs_dir2_data_off_t length; /* total free length */
+ __be16 freetag; /* XFS_DIR2_DATA_FREE_TAG */
+ __be16 length; /* total free length */
/* variable offset */
- xfs_dir2_data_off_t tag; /* starting offset of us */
+ __be16 tag; /* starting offset of us */
} xfs_dir2_data_unused_t;
typedef union {
@@ -151,7 +151,7 @@ static inline xfs_dir2_data_off_t *
xfs_dir2_data_unused_tag_p(xfs_dir2_data_unused_t *dup)
{
return (xfs_dir2_data_off_t *) \
- ((char *)(dup) + INT_GET((dup)->length, ARCH_CONVERT) \
+ ((char *)(dup) + be16_to_cpu((dup)->length) \
- (uint)sizeof(xfs_dir2_data_off_t));
}
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index 9abecd207c4..cbd371d9e98 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -395,7 +395,7 @@ xfs_dir2_leaf_addname(
*/
dup = (xfs_dir2_data_unused_t *)
((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset));
- ASSERT(INT_GET(dup->length, ARCH_CONVERT) >= length);
+ ASSERT(be16_to_cpu(dup->length) >= length);
needscan = needlog = 0;
/*
* Mark the initial part of our freespace in use for the new entry.
@@ -1047,11 +1047,10 @@ xfs_dir2_leaf_getdents(
while ((char *)ptr - (char *)data < byteoff) {
dup = (xfs_dir2_data_unused_t *)ptr;
- if (INT_GET(dup->freetag, ARCH_CONVERT)
+ if (be16_to_cpu(dup->freetag)
== XFS_DIR2_DATA_FREE_TAG) {
- length = INT_GET(dup->length,
- ARCH_CONVERT);
+ length = be16_to_cpu(dup->length);
ptr += length;
continue;
}
@@ -1080,9 +1079,8 @@ xfs_dir2_leaf_getdents(
/*
* No, it's unused, skip over it.
*/
- if (INT_GET(dup->freetag, ARCH_CONVERT)
- == XFS_DIR2_DATA_FREE_TAG) {
- length = INT_GET(dup->length, ARCH_CONVERT);
+ if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
+ length = be16_to_cpu(dup->length);
ptr += length;
curoff += length;
continue;
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
index ec8e7476c8b..3a571d8cf1f 100644
--- a/fs/xfs/xfs_dir2_sf.c
+++ b/fs/xfs/xfs_dir2_sf.c
@@ -220,8 +220,8 @@ xfs_dir2_block_to_sf(
* If it's unused, just skip over it.
*/
dup = (xfs_dir2_data_unused_t *)ptr;
- if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) {
- ptr += INT_GET(dup->length, ARCH_CONVERT);
+ if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
+ ptr += be16_to_cpu(dup->length);
continue;
}
dep = (xfs_dir2_data_entry_t *)ptr;