]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[XFS] optimize XFS_IS_REALTIME_INODE w/o realtime config
authorEric Sandeen <sandeen@sandeen.net>
Fri, 23 Nov 2007 05:29:42 +0000 (16:29 +1100)
committerLachlan McIlroy <lachlan@redback.melbourne.sgi.com>
Thu, 7 Feb 2008 07:16:43 +0000 (18:16 +1100)
Use XFS_IS_REALTIME_INODE in more places, and #define it to 0 if
CONFIG_XFS_RT is off. This should be safe because mount checks in
xfs_rtmount_init:

so if we get mounted w/o CONFIG_XFS_RT, no realtime inodes should be
encountered after that.

Defining XFS_IS_REALTIME_INODE to 0 saves a bit of stack space,
presumeably gcc can optimize around the various "if (0)" type checks:

xfs_alloc_file_space -8 xfs_bmap_adjacent -16 xfs_bmapi -8
xfs_bmap_rtalloc -16 xfs_bunmapi -28 xfs_free_file_space -64 xfs_imap +8
<-- ? hmm. xfs_iomap_write_direct -12 xfs_qm_dqusage_adjust -4
xfs_qm_vop_chown_reserve -4

SGI-PV: 971186
SGI-Modid: xfs-linux-melb:xfs-kern:30014a

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Signed-off-by: David Chinner <dgc@sgi.com>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
13 files changed:
fs/xfs/linux-2.6/xfs_aops.c
fs/xfs/linux-2.6/xfs_ioctl.c
fs/xfs/linux-2.6/xfs_iops.c
fs/xfs/linux-2.6/xfs_lrw.c
fs/xfs/xfs_bmap.c
fs/xfs/xfs_bmap_btree.c
fs/xfs/xfs_dfrag.c
fs/xfs/xfs_dinode.h
fs/xfs/xfs_inode.c
fs/xfs/xfs_iomap.c
fs/xfs/xfs_rtalloc.h
fs/xfs/xfs_rw.h
fs/xfs/xfs_vnodeops.c

index 36dadc4ff22c30177d402aed50b76d5d12233e2c..e0519529c26cca838a9c65cfb370eb593fef16a6 100644 (file)
@@ -113,7 +113,7 @@ xfs_find_bdev_for_inode(
 {
        struct xfs_mount        *mp = ip->i_mount;
 
-       if (ip->i_d.di_flags & XFS_DIFLAG_REALTIME)
+       if (XFS_IS_REALTIME_INODE(ip))
                return mp->m_rtdev_targp->bt_bdev;
        else
                return mp->m_ddev_targp->bt_bdev;
index daa351a0a03d5edd33adcd9542879d01fb76b89a..4c82a050a3a8be848ec8177edce521618a38398c 100644 (file)
@@ -741,7 +741,7 @@ xfs_ioctl(
        case XFS_IOC_DIOINFO: {
                struct dioattr  da;
                xfs_buftarg_t   *target =
-                       (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) ?
+                       XFS_IS_REALTIME_INODE(ip) ?
                        mp->m_rtdev_targp : mp->m_ddev_targp;
 
                da.d_mem = da.d_miniosz = 1 << target->bt_sshift;
index 9ddef91a436d1fd09d3a9dfd8a6c2281c810ec46..1ecd86a8c6e684515506a9dda6e62bc5dd8ab07c 100644 (file)
@@ -612,7 +612,7 @@ xfs_vn_getattr(
                                   sysv_minor(ip->i_df.if_u2.if_rdev));
                break;
        default:
-               if (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) {
+               if (XFS_IS_REALTIME_INODE(ip)) {
                        /*
                         * If the file blocks are being allocated from a
                         * realtime volume, then return the inode's realtime
index 459d36480b16daf6c0dd1a8b0f0e98b8f837e18d..19a1f077dbd6fbd3bc2725241f691bd8dc576ea2 100644 (file)
@@ -202,7 +202,7 @@ xfs_read(
 
        if (unlikely(ioflags & IO_ISDIRECT)) {
                xfs_buftarg_t   *target =
-                       (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) ?
+                       XFS_IS_REALTIME_INODE(ip) ?
                                mp->m_rtdev_targp : mp->m_ddev_targp;
                if ((*offset & target->bt_smask) ||
                    (size & target->bt_smask)) {
@@ -657,7 +657,7 @@ start:
 
        if (ioflags & IO_ISDIRECT) {
                xfs_buftarg_t   *target =
-                       (xip->i_d.di_flags & XFS_DIFLAG_REALTIME) ?
+                       XFS_IS_REALTIME_INODE(xip) ?
                                mp->m_rtdev_targp : mp->m_ddev_targp;
 
                if ((pos & target->bt_smask) || (count & target->bt_smask)) {
index b02452b1145687884c8a48510bb56d09b56b8342..aca51e7e5c5a62ab3691ce913e7069028b36eb1f 100644 (file)
@@ -2969,7 +2969,7 @@ STATIC int
 xfs_bmap_alloc(
        xfs_bmalloca_t  *ap)            /* bmap alloc argument struct */
 {
-       if ((ap->ip->i_d.di_flags & XFS_DIFLAG_REALTIME) && ap->userdata)
+       if (XFS_IS_REALTIME_INODE(ap->ip) && ap->userdata)
                return xfs_bmap_rtalloc(ap);
        return xfs_bmap_btalloc(ap);
 }
@@ -3096,8 +3096,7 @@ xfs_bmap_del_extent(
                /*
                 * Realtime allocation.  Free it and record di_nblocks update.
                 */
-               if (whichfork == XFS_DATA_FORK &&
-                   (ip->i_d.di_flags & XFS_DIFLAG_REALTIME)) {
+               if (whichfork == XFS_DATA_FORK && XFS_IS_REALTIME_INODE(ip)) {
                        xfs_fsblock_t   bno;
                        xfs_filblks_t   len;
 
index 32b49ec00fb521510b888cab245d06653acfed17..c4181d85605cb646e94c55afd5d4bb49d43f1dd3 100644 (file)
@@ -2062,8 +2062,7 @@ xfs_bmbt_insert(
                                pcur->bc_private.b.allocated;
                        pcur->bc_private.b.allocated = 0;
                        ASSERT((cur->bc_private.b.firstblock != NULLFSBLOCK) ||
-                              (cur->bc_private.b.ip->i_d.di_flags &
-                               XFS_DIFLAG_REALTIME));
+                              XFS_IS_REALTIME_INODE(cur->bc_private.b.ip));
                        cur->bc_private.b.firstblock =
                                pcur->bc_private.b.firstblock;
                        ASSERT(cur->bc_private.b.flist ==
index 4ad29cbb4233ccac5cafb39abebf40b35b154e18..03a42d21610aabe41ec35a52a82017e928288970 100644 (file)
@@ -185,8 +185,7 @@ xfs_swap_extents(
        }
 
        /* Verify both files are either real-time or non-realtime */
-       if ((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) !=
-           (tip->i_d.di_flags & XFS_DIFLAG_REALTIME)) {
+       if (XFS_IS_REALTIME_INODE(ip) != XFS_IS_REALTIME_INODE(tip)) {
                error = XFS_ERROR(EINVAL);
                goto error0;
        }
index dedd713574e130b8b2a3e449a8cffb5b529ca12a..85030cbcdd87f5be32fab641178af1bec0d57563 100644 (file)
@@ -273,6 +273,12 @@ typedef enum xfs_dinode_fmt
 #define XFS_DIFLAG_NODEFRAG      (1 << XFS_DIFLAG_NODEFRAG_BIT)
 #define XFS_DIFLAG_FILESTREAM    (1 << XFS_DIFLAG_FILESTREAM_BIT)
 
+#ifdef CONFIG_XFS_RT
+#define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
+#else
+#define XFS_IS_REALTIME_INODE(ip) (0)
+#endif
+
 #define XFS_DIFLAG_ANY \
        (XFS_DIFLAG_REALTIME | XFS_DIFLAG_PREALLOC | XFS_DIFLAG_NEWRTBM | \
         XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
index 805cab7b2770942dcc26407f7623fd085ecedbc8..815ae978e3bdf3029f51d33535fa152f2cea93f6 100644 (file)
@@ -1296,7 +1296,10 @@ xfs_isize_check(
        if ((ip->i_d.di_mode & S_IFMT) != S_IFREG)
                return;
 
-       if (ip->i_d.di_flags & (XFS_DIFLAG_REALTIME | XFS_DIFLAG_EXTSIZE))
+       if (XFS_IS_REALTIME_INODE(ip))
+               return;
+
+       if (ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE)
                return;
 
        nimaps = 2;
index 637a24473f9be6a1ec34e92c8bf3f58a9b4ebb86..fde37f87d52faa9a87674b0d95a9f813a2330820 100644 (file)
@@ -141,7 +141,7 @@ xfs_imap_to_bmap(
                iomapp->iomap_bsize = XFS_FSB_TO_B(mp, imap->br_blockcount);
                iomapp->iomap_flags = flags;
 
-               if (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) {
+               if (XFS_IS_REALTIME_INODE(ip)) {
                        iomapp->iomap_flags |= IOMAP_REALTIME;
                        iomapp->iomap_target = mp->m_rtdev_targp;
                } else {
@@ -298,7 +298,7 @@ xfs_iomap_eof_align_last_fsb(
        xfs_extlen_t    align;
        int             eof, error;
 
-       if (ip->i_d.di_flags & XFS_DIFLAG_REALTIME)
+       if (XFS_IS_REALTIME_INODE(ip))
                ;
        /*
         * If mounted with the "-o swalloc" option, roundup the allocation
@@ -524,7 +524,7 @@ xfs_iomap_write_direct(
        }
 
        if (unlikely(!imap.br_startblock &&
-                    !(ip->i_d.di_flags & XFS_DIFLAG_REALTIME))) {
+                    !(XFS_IS_REALTIME_INODE(ip)))) {
                error = xfs_cmn_err_fsblock_zero(ip, &imap);
                goto error_out;
        }
@@ -687,7 +687,7 @@ retry:
        }
 
        if (unlikely(!imap[0].br_startblock &&
-                    !(ip->i_d.di_flags & XFS_DIFLAG_REALTIME)))
+                    !(XFS_IS_REALTIME_INODE(ip))))
                return xfs_cmn_err_fsblock_zero(ip, &imap[0]);
 
        *ret_imap = imap[0];
@@ -932,7 +932,7 @@ xfs_iomap_write_unwritten(
                        return XFS_ERROR(error);
 
                if (unlikely(!imap.br_startblock &&
-                            !(ip->i_d.di_flags & XFS_DIFLAG_REALTIME)))
+                            !(XFS_IS_REALTIME_INODE(ip))))
                        return xfs_cmn_err_fsblock_zero(ip, &imap);
 
                if ((numblks_fsb = imap.br_blockcount) == 0) {
index 799c1f87126318bf54e0fcf9b4f59c088a9ee2fd..8d8dcd215716262d5a9bdb2a46e6c7b359604769 100644 (file)
@@ -21,8 +21,6 @@
 struct xfs_mount;
 struct xfs_trans;
 
-#define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
-
 /* Min and max rt extent sizes, specified in bytes */
 #define        XFS_MAX_RTEXTSIZE       (1024 * 1024 * 1024)    /* 1GB */
 #define        XFS_DFL_RTEXTSIZE       (64 * 1024)             /* 64KB */
index bcfe07aa7e6bbc75e02e75aa69328c5aadc20c06..f87db5344ce61145857566ec0a54c116e37b7482 100644 (file)
@@ -32,7 +32,7 @@ struct xfs_mount;
 static inline xfs_daddr_t
 xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb)
 {
-       return (((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) ? \
+       return (XFS_IS_REALTIME_INODE(ip) ? \
                 (xfs_daddr_t)XFS_FSB_TO_BB((ip)->i_mount, (fsb)) : \
                 XFS_FSB_TO_DADDR((ip)->i_mount, (fsb)));
 }
@@ -53,7 +53,7 @@ xfs_get_extsz_hint(
 {
        xfs_extlen_t    extsz;
 
-       if (unlikely(ip->i_d.di_flags & XFS_DIFLAG_REALTIME)) {
+       if (unlikely(XFS_IS_REALTIME_INODE(ip))) {
                extsz = (ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE)
                                ? ip->i_d.di_extsize
                                : ip->i_mount->m_sb.sb_rextsize;
index d964e21521ab764a8f520af8db155825345a930e..5322d9fb532150fe9177dfdfc841ed7c2b64c1cf 100644 (file)
@@ -136,7 +136,7 @@ xfs_getattr(
        default:
                vap->va_rdev = 0;
 
-               if (!(ip->i_d.di_flags & XFS_DIFLAG_REALTIME)) {
+               if (!(XFS_IS_REALTIME_INODE(ip))) {
                        vap->va_blocksize = xfs_preferred_iosize(mp);
                } else {
 
@@ -508,7 +508,7 @@ xfs_setattr(
                 */
                if ((ip->i_d.di_nextents || ip->i_delayed_blks) &&
                    (mask & XFS_AT_XFLAGS) &&
-                   (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) !=
+                   (XFS_IS_REALTIME_INODE(ip)) !=
                    (vap->va_xflags & XFS_XFLAG_REALTIME)) {
                        code = XFS_ERROR(EINVAL);       /* EFBIG? */
                        goto error_return;
@@ -520,7 +520,7 @@ xfs_setattr(
                if ((mask & XFS_AT_EXTSIZE) && vap->va_extsize != 0) {
                        xfs_extlen_t    size;
 
-                       if ((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) ||
+                       if (XFS_IS_REALTIME_INODE(ip) ||
                            ((mask & XFS_AT_XFLAGS) &&
                            (vap->va_xflags & XFS_XFLAG_REALTIME))) {
                                size = mp->m_sb.sb_rextsize <<
@@ -1144,7 +1144,7 @@ xfs_fsync(
                 * If this inode is on the RT dev we need to flush that
                 * cache as well.
                 */
-               if (ip->i_d.di_flags & XFS_DIFLAG_REALTIME)
+               if (XFS_IS_REALTIME_INODE(ip))
                        xfs_blkdev_issue_flush(ip->i_mount->m_rtdev_targp);
        }
 
@@ -4044,7 +4044,7 @@ xfs_zero_remaining_bytes(
        int                     error = 0;
 
        bp = xfs_buf_get_noaddr(mp->m_sb.sb_blocksize,
-                               ip->i_d.di_flags & XFS_DIFLAG_REALTIME ?
+                               XFS_IS_REALTIME_INODE(ip) ?
                                mp->m_rtdev_targp : mp->m_ddev_targp);
 
        for (offset = startoff; offset <= endoff; offset = lastoffset + 1) {
@@ -4141,7 +4141,7 @@ xfs_free_file_space(
        error = 0;
        if (len <= 0)   /* if nothing being freed */
                return error;
-       rt = (ip->i_d.di_flags & XFS_DIFLAG_REALTIME);
+       rt = XFS_IS_REALTIME_INODE(ip);
        startoffset_fsb = XFS_B_TO_FSB(mp, offset);
        end_dmi_offset = offset + len;
        endoffset_fsb = XFS_B_TO_FSBT(mp, end_dmi_offset);