aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_inode.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2011-07-08 08:36:05 -0400
committerChristoph Hellwig <hch@lst.de>2011-07-08 08:36:05 -0400
commit69ef921b55cc3788d1d2a27b33b27d04acd0090a (patch)
treebcc7c1f4b7f15628f122dfdb96f8d4d37f587e92 /fs/xfs/xfs_inode.c
parent218106a1104c598011e5df9d9aac7e0416be03e6 (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_inode.c')
-rw-r--r--fs/xfs/xfs_inode.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index db310f8fb76a..d04ea6a2dfaf 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -167,7 +167,7 @@ xfs_imap_to_bp(
167 167
168 dip = (xfs_dinode_t *)xfs_buf_offset(bp, 168 dip = (xfs_dinode_t *)xfs_buf_offset(bp,
169 (i << mp->m_sb.sb_inodelog)); 169 (i << mp->m_sb.sb_inodelog));
170 di_ok = be16_to_cpu(dip->di_magic) == XFS_DINODE_MAGIC && 170 di_ok = dip->di_magic == cpu_to_be16(XFS_DINODE_MAGIC) &&
171 XFS_DINODE_GOOD_VERSION(dip->di_version); 171 XFS_DINODE_GOOD_VERSION(dip->di_version);
172 if (unlikely(XFS_TEST_ERROR(!di_ok, mp, 172 if (unlikely(XFS_TEST_ERROR(!di_ok, mp,
173 XFS_ERRTAG_ITOBP_INOTOBP, 173 XFS_ERRTAG_ITOBP_INOTOBP,
@@ -802,7 +802,7 @@ xfs_iread(
802 * If we got something that isn't an inode it means someone 802 * If we got something that isn't an inode it means someone
803 * (nfs or dmi) has a stale handle. 803 * (nfs or dmi) has a stale handle.
804 */ 804 */
805 if (be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC) { 805 if (dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC)) {
806#ifdef DEBUG 806#ifdef DEBUG
807 xfs_alert(mp, 807 xfs_alert(mp,
808 "%s: dip->di_magic (0x%x) != XFS_DINODE_MAGIC (0x%x)", 808 "%s: dip->di_magic (0x%x) != XFS_DINODE_MAGIC (0x%x)",
@@ -1457,7 +1457,7 @@ xfs_iunlink(
1457 ASSERT(agi->agi_unlinked[bucket_index]); 1457 ASSERT(agi->agi_unlinked[bucket_index]);
1458 ASSERT(be32_to_cpu(agi->agi_unlinked[bucket_index]) != agino); 1458 ASSERT(be32_to_cpu(agi->agi_unlinked[bucket_index]) != agino);
1459 1459
1460 if (be32_to_cpu(agi->agi_unlinked[bucket_index]) != NULLAGINO) { 1460 if (agi->agi_unlinked[bucket_index] != cpu_to_be32(NULLAGINO)) {
1461 /* 1461 /*
1462 * There is already another inode in the bucket we need 1462 * There is already another inode in the bucket we need
1463 * to add ourselves to. Add us at the front of the list. 1463 * to add ourselves to. Add us at the front of the list.
@@ -1468,8 +1468,7 @@ xfs_iunlink(
1468 if (error) 1468 if (error)
1469 return error; 1469 return error;
1470 1470
1471 ASSERT(be32_to_cpu(dip->di_next_unlinked) == NULLAGINO); 1471 ASSERT(dip->di_next_unlinked == cpu_to_be32(NULLAGINO));
1472 /* both on-disk, don't endian flip twice */
1473 dip->di_next_unlinked = agi->agi_unlinked[bucket_index]; 1472 dip->di_next_unlinked = agi->agi_unlinked[bucket_index];
1474 offset = ip->i_imap.im_boffset + 1473 offset = ip->i_imap.im_boffset +
1475 offsetof(xfs_dinode_t, di_next_unlinked); 1474 offsetof(xfs_dinode_t, di_next_unlinked);
@@ -1534,7 +1533,7 @@ xfs_iunlink_remove(
1534 agino = XFS_INO_TO_AGINO(mp, ip->i_ino); 1533 agino = XFS_INO_TO_AGINO(mp, ip->i_ino);
1535 ASSERT(agino != 0); 1534 ASSERT(agino != 0);
1536 bucket_index = agino % XFS_AGI_UNLINKED_BUCKETS; 1535 bucket_index = agino % XFS_AGI_UNLINKED_BUCKETS;
1537 ASSERT(be32_to_cpu(agi->agi_unlinked[bucket_index]) != NULLAGINO); 1536 ASSERT(agi->agi_unlinked[bucket_index] != cpu_to_be32(NULLAGINO));
1538 ASSERT(agi->agi_unlinked[bucket_index]); 1537 ASSERT(agi->agi_unlinked[bucket_index]);
1539 1538
1540 if (be32_to_cpu(agi->agi_unlinked[bucket_index]) == agino) { 1539 if (be32_to_cpu(agi->agi_unlinked[bucket_index]) == agino) {
@@ -2659,7 +2658,7 @@ xfs_iflush_int(
2659 */ 2658 */
2660 xfs_synchronize_times(ip); 2659 xfs_synchronize_times(ip);
2661 2660
2662 if (XFS_TEST_ERROR(be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC, 2661 if (XFS_TEST_ERROR(dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC),
2663 mp, XFS_ERRTAG_IFLUSH_1, XFS_RANDOM_IFLUSH_1)) { 2662 mp, XFS_ERRTAG_IFLUSH_1, XFS_RANDOM_IFLUSH_1)) {
2664 xfs_alert_tag(mp, XFS_PTAG_IFLUSH, 2663 xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
2665 "%s: Bad inode %Lu magic number 0x%x, ptr 0x%p", 2664 "%s: Bad inode %Lu magic number 0x%x, ptr 0x%p",