diff options
author | Christoph Hellwig <hch@lst.de> | 2011-07-08 08:36:05 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2011-07-08 08:36:05 -0400 |
commit | 69ef921b55cc3788d1d2a27b33b27d04acd0090a (patch) | |
tree | bcc7c1f4b7f15628f122dfdb96f8d4d37f587e92 /fs/xfs/xfs_dir2_data.c | |
parent | 218106a1104c598011e5df9d9aac7e0416be03e6 (diff) |
xfs: byteswap constants instead of variables
Micro-optimize various comparisms by always byteswapping the constant
instead of the variable, which allows to do the swap at compile instead
of runtime.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/xfs_dir2_data.c')
-rw-r--r-- | fs/xfs/xfs_dir2_data.c | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c index 8e47ac3a3b9d..32dca4c531a6 100644 --- a/fs/xfs/xfs_dir2_data.c +++ b/fs/xfs/xfs_dir2_data.c | |||
@@ -73,7 +73,7 @@ xfs_dir2_data_check( | |||
73 | bf = hdr->bestfree; | 73 | bf = hdr->bestfree; |
74 | p = (char *)(hdr + 1); | 74 | p = (char *)(hdr + 1); |
75 | 75 | ||
76 | if (be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC) { | 76 | if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)) { |
77 | btp = xfs_dir2_block_tail_p(mp, hdr); | 77 | btp = xfs_dir2_block_tail_p(mp, hdr); |
78 | lep = xfs_dir2_block_leaf_p(btp); | 78 | lep = xfs_dir2_block_leaf_p(btp); |
79 | endp = (char *)lep; | 79 | endp = (char *)lep; |
@@ -140,7 +140,7 @@ xfs_dir2_data_check( | |||
140 | (char *)dep - (char *)hdr); | 140 | (char *)dep - (char *)hdr); |
141 | count++; | 141 | count++; |
142 | lastfree = 0; | 142 | lastfree = 0; |
143 | if (be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC) { | 143 | if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)) { |
144 | addr = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, | 144 | addr = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, |
145 | (xfs_dir2_data_aoff_t) | 145 | (xfs_dir2_data_aoff_t) |
146 | ((char *)dep - (char *)hdr)); | 146 | ((char *)dep - (char *)hdr)); |
@@ -160,9 +160,10 @@ xfs_dir2_data_check( | |||
160 | * Need to have seen all the entries and all the bestfree slots. | 160 | * Need to have seen all the entries and all the bestfree slots. |
161 | */ | 161 | */ |
162 | ASSERT(freeseen == 7); | 162 | ASSERT(freeseen == 7); |
163 | if (be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC) { | 163 | if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)) { |
164 | for (i = stale = 0; i < be32_to_cpu(btp->count); i++) { | 164 | for (i = stale = 0; i < be32_to_cpu(btp->count); i++) { |
165 | if (be32_to_cpu(lep[i].address) == XFS_DIR2_NULL_DATAPTR) | 165 | if (lep[i].address == |
166 | cpu_to_be32(XFS_DIR2_NULL_DATAPTR)) | ||
166 | stale++; | 167 | stale++; |
167 | if (i > 0) | 168 | if (i > 0) |
168 | ASSERT(be32_to_cpu(lep[i].hashval) >= be32_to_cpu(lep[i - 1].hashval)); | 169 | ASSERT(be32_to_cpu(lep[i].hashval) >= be32_to_cpu(lep[i - 1].hashval)); |
@@ -196,8 +197,8 @@ xfs_dir2_data_freefind( | |||
196 | * Check order, non-overlapping entries, and if we find the | 197 | * Check order, non-overlapping entries, and if we find the |
197 | * one we're looking for it has to be exact. | 198 | * one we're looking for it has to be exact. |
198 | */ | 199 | */ |
199 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || | 200 | ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || |
200 | be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); | 201 | hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)); |
201 | for (dfp = &hdr->bestfree[0], seenzero = matched = 0; | 202 | for (dfp = &hdr->bestfree[0], seenzero = matched = 0; |
202 | dfp < &hdr->bestfree[XFS_DIR2_DATA_FD_COUNT]; | 203 | dfp < &hdr->bestfree[XFS_DIR2_DATA_FD_COUNT]; |
203 | dfp++) { | 204 | dfp++) { |
@@ -256,8 +257,8 @@ xfs_dir2_data_freeinsert( | |||
256 | xfs_dir2_data_free_t new; /* new bestfree entry */ | 257 | xfs_dir2_data_free_t new; /* new bestfree entry */ |
257 | 258 | ||
258 | #ifdef __KERNEL__ | 259 | #ifdef __KERNEL__ |
259 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || | 260 | ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || |
260 | be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); | 261 | hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)); |
261 | #endif | 262 | #endif |
262 | dfp = hdr->bestfree; | 263 | dfp = hdr->bestfree; |
263 | new.length = dup->length; | 264 | new.length = dup->length; |
@@ -297,8 +298,8 @@ xfs_dir2_data_freeremove( | |||
297 | int *loghead) /* out: log data header */ | 298 | int *loghead) /* out: log data header */ |
298 | { | 299 | { |
299 | #ifdef __KERNEL__ | 300 | #ifdef __KERNEL__ |
300 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || | 301 | ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || |
301 | be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); | 302 | hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)); |
302 | #endif | 303 | #endif |
303 | /* | 304 | /* |
304 | * It's the first entry, slide the next 2 up. | 305 | * It's the first entry, slide the next 2 up. |
@@ -341,8 +342,8 @@ xfs_dir2_data_freescan( | |||
341 | char *p; /* current entry pointer */ | 342 | char *p; /* current entry pointer */ |
342 | 343 | ||
343 | #ifdef __KERNEL__ | 344 | #ifdef __KERNEL__ |
344 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || | 345 | ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || |
345 | be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); | 346 | hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)); |
346 | #endif | 347 | #endif |
347 | /* | 348 | /* |
348 | * Start by clearing the table. | 349 | * Start by clearing the table. |
@@ -353,7 +354,7 @@ xfs_dir2_data_freescan( | |||
353 | * Set up pointers. | 354 | * Set up pointers. |
354 | */ | 355 | */ |
355 | p = (char *)(hdr + 1); | 356 | p = (char *)(hdr + 1); |
356 | if (be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC) { | 357 | if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)) { |
357 | btp = xfs_dir2_block_tail_p(mp, hdr); | 358 | btp = xfs_dir2_block_tail_p(mp, hdr); |
358 | endp = (char *)xfs_dir2_block_leaf_p(btp); | 359 | endp = (char *)xfs_dir2_block_leaf_p(btp); |
359 | } else | 360 | } else |
@@ -458,8 +459,8 @@ xfs_dir2_data_log_entry( | |||
458 | { | 459 | { |
459 | xfs_dir2_data_hdr_t *hdr = bp->data; | 460 | xfs_dir2_data_hdr_t *hdr = bp->data; |
460 | 461 | ||
461 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || | 462 | ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || |
462 | be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); | 463 | hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)); |
463 | 464 | ||
464 | xfs_da_log_buf(tp, bp, (uint)((char *)dep - (char *)hdr), | 465 | xfs_da_log_buf(tp, bp, (uint)((char *)dep - (char *)hdr), |
465 | (uint)((char *)(xfs_dir2_data_entry_tag_p(dep) + 1) - | 466 | (uint)((char *)(xfs_dir2_data_entry_tag_p(dep) + 1) - |
@@ -476,8 +477,8 @@ xfs_dir2_data_log_header( | |||
476 | { | 477 | { |
477 | xfs_dir2_data_hdr_t *hdr = bp->data; | 478 | xfs_dir2_data_hdr_t *hdr = bp->data; |
478 | 479 | ||
479 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || | 480 | ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || |
480 | be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); | 481 | hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)); |
481 | 482 | ||
482 | xfs_da_log_buf(tp, bp, 0, sizeof(*hdr) - 1); | 483 | xfs_da_log_buf(tp, bp, 0, sizeof(*hdr) - 1); |
483 | } | 484 | } |
@@ -493,8 +494,8 @@ xfs_dir2_data_log_unused( | |||
493 | { | 494 | { |
494 | xfs_dir2_data_hdr_t *hdr = bp->data; | 495 | xfs_dir2_data_hdr_t *hdr = bp->data; |
495 | 496 | ||
496 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || | 497 | ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || |
497 | be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); | 498 | hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)); |
498 | 499 | ||
499 | /* | 500 | /* |
500 | * Log the first part of the unused entry. | 501 | * Log the first part of the unused entry. |
@@ -539,12 +540,12 @@ xfs_dir2_data_make_free( | |||
539 | /* | 540 | /* |
540 | * Figure out where the end of the data area is. | 541 | * Figure out where the end of the data area is. |
541 | */ | 542 | */ |
542 | if (be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC) | 543 | if (hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC)) |
543 | endptr = (char *)hdr + mp->m_dirblksize; | 544 | endptr = (char *)hdr + mp->m_dirblksize; |
544 | else { | 545 | else { |
545 | xfs_dir2_block_tail_t *btp; /* block tail */ | 546 | xfs_dir2_block_tail_t *btp; /* block tail */ |
546 | 547 | ||
547 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); | 548 | ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)); |
548 | btp = xfs_dir2_block_tail_p(mp, hdr); | 549 | btp = xfs_dir2_block_tail_p(mp, hdr); |
549 | endptr = (char *)xfs_dir2_block_leaf_p(btp); | 550 | endptr = (char *)xfs_dir2_block_leaf_p(btp); |
550 | } | 551 | } |
@@ -717,8 +718,8 @@ xfs_dir2_data_use_free( | |||
717 | int oldlen; /* old unused entry's length */ | 718 | int oldlen; /* old unused entry's length */ |
718 | 719 | ||
719 | hdr = bp->data; | 720 | hdr = bp->data; |
720 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || | 721 | ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || |
721 | be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); | 722 | hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)); |
722 | ASSERT(be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG); | 723 | ASSERT(be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG); |
723 | ASSERT(offset >= (char *)dup - (char *)hdr); | 724 | ASSERT(offset >= (char *)dup - (char *)hdr); |
724 | ASSERT(offset + len <= (char *)dup + be16_to_cpu(dup->length) - (char *)hdr); | 725 | ASSERT(offset + len <= (char *)dup + be16_to_cpu(dup->length) - (char *)hdr); |