xfs: remove block number from inode lookup code
authorDave Chinner <dchinner@redhat.com>
Thu, 24 Jun 2010 01:35:17 +0000 (11:35 +1000)
committerDave Chinner <david@fromorbit.com>
Thu, 24 Jun 2010 01:35:17 +0000 (11:35 +1000)
The block number comes from bulkstat based inode lookups to shortcut
the mapping calculations. We ar enot able to trust anything from
bulkstat, so drop the block number as well so that the correct
lookups and mappings are always done.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
15 files changed:
fs/xfs/linux-2.6/xfs_export.c
fs/xfs/linux-2.6/xfs_ioctl32.c
fs/xfs/quota/xfs_qm.c
fs/xfs/quota/xfs_qm_syscalls.c
fs/xfs/xfs_ialloc.c
fs/xfs/xfs_iget.c
fs/xfs/xfs_inode.c
fs/xfs/xfs_inode.h
fs/xfs/xfs_itable.c
fs/xfs/xfs_itable.h
fs/xfs/xfs_log_recover.c
fs/xfs/xfs_mount.c
fs/xfs/xfs_rtalloc.c
fs/xfs/xfs_trans_inode.c
fs/xfs/xfs_vnodeops.c

index 92c84a19cc9e1ea26bc2a1e37b4de4cc8737369c..e7839ee49e43656d0d1edfa7011ce8d9eb0e97b2 100644 (file)
@@ -133,7 +133,7 @@ xfs_nfs_get_inode(
         * send invalid file handles and we have to handle it gracefully..
         */
        error = xfs_iget(mp, NULL, ino, XFS_IGET_UNTRUSTED,
-                        XFS_ILOCK_SHARED, &ip, 0);
+                        XFS_ILOCK_SHARED, &ip);
        if (error) {
                /*
                 * EINVAL means the inode cluster doesn't exist anymore.
index e1d8380b049d676c42069cd21552e15d65659722..52ed49e6465cff0eee12844c13b169583cc1411c 100644 (file)
@@ -237,12 +237,11 @@ xfs_bulkstat_one_compat(
        xfs_ino_t       ino,            /* inode number to get data for */
        void            __user *buffer, /* buffer to place output in */
        int             ubsize,         /* size of buffer */
-       xfs_daddr_t     bno,            /* starting bno of inode cluster */
        int             *ubused,        /* bytes used by me */
        int             *stat)          /* BULKSTAT_RV_... */
 {
        return xfs_bulkstat_one_int(mp, ino, buffer, ubsize,
-                                   xfs_bulkstat_one_fmt_compat, bno,
+                                   xfs_bulkstat_one_fmt_compat,
                                    ubused, stat);
 }
 
@@ -296,7 +295,7 @@ xfs_compat_ioc_bulkstat(
                int res;
 
                error = xfs_bulkstat_one_compat(mp, inlast, bulkreq.ubuffer,
-                               sizeof(compat_xfs_bstat_t), 0, NULL, &res);
+                               sizeof(compat_xfs_bstat_t), 0, &res);
        } else if (cmd == XFS_IOC_FSBULKSTAT_32) {
                error = xfs_bulkstat(mp, &inlast, &count,
                        xfs_bulkstat_one_compat, sizeof(compat_xfs_bstat_t),
index f19f94c4cb9ffc424c27604832da869bb16d7a0e..8c117ff2e3ab00d8939f7ec596063988faae283f 100644 (file)
@@ -1632,7 +1632,6 @@ xfs_qm_dqusage_adjust(
        xfs_ino_t       ino,            /* inode number to get data for */
        void            __user *buffer, /* not used */
        int             ubsize,         /* not used */
-       xfs_daddr_t     bno,            /* starting block of inode cluster */
        int             *ubused,        /* not used */
        int             *res)           /* result code value */
 {
@@ -1658,7 +1657,7 @@ xfs_qm_dqusage_adjust(
         * the case in all other instances. It's OK that we do this because
         * quotacheck is done only at mount time.
         */
-       if ((error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_EXCL, &ip, bno))) {
+       if ((error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_EXCL, &ip))) {
                *res = BULKSTAT_RV_NOTHING;
                return error;
        }
@@ -1888,14 +1887,14 @@ xfs_qm_init_quotainos(
                    mp->m_sb.sb_uquotino != NULLFSINO) {
                        ASSERT(mp->m_sb.sb_uquotino > 0);
                        if ((error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino,
-                                            0, 0, &uip, 0)))
+                                            0, 0, &uip)))
                                return XFS_ERROR(error);
                }
                if (XFS_IS_OQUOTA_ON(mp) &&
                    mp->m_sb.sb_gquotino != NULLFSINO) {
                        ASSERT(mp->m_sb.sb_gquotino > 0);
                        if ((error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino,
-                                            0, 0, &gip, 0))) {
+                                            0, 0, &gip))) {
                                if (uip)
                                        IRELE(uip);
                                return XFS_ERROR(error);
index 99a2d8e0f1731dbfd924ba2004d1b41dcff38d3a..b4487764e923b7c493aac813e9161764a0f0ccfb 100644 (file)
@@ -262,7 +262,7 @@ xfs_qm_scall_trunc_qfiles(
        }
 
        if ((flags & XFS_DQ_USER) && mp->m_sb.sb_uquotino != NULLFSINO) {
-               error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino, 0, 0, &qip, 0);
+               error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino, 0, 0, &qip);
                if (!error) {
                        error = xfs_truncate_file(mp, qip);
                        IRELE(qip);
@@ -271,7 +271,7 @@ xfs_qm_scall_trunc_qfiles(
 
        if ((flags & (XFS_DQ_GROUP|XFS_DQ_PROJ)) &&
            mp->m_sb.sb_gquotino != NULLFSINO) {
-               error2 = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, 0, 0, &qip, 0);
+               error2 = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, 0, 0, &qip);
                if (!error2) {
                        error2 = xfs_truncate_file(mp, qip);
                        IRELE(qip);
@@ -417,12 +417,12 @@ xfs_qm_scall_getqstat(
        }
        if (!uip && mp->m_sb.sb_uquotino != NULLFSINO) {
                if (xfs_iget(mp, NULL, mp->m_sb.sb_uquotino,
-                                       0, 0, &uip, 0) == 0)
+                                       0, 0, &uip) == 0)
                        tempuqip = B_TRUE;
        }
        if (!gip && mp->m_sb.sb_gquotino != NULLFSINO) {
                if (xfs_iget(mp, NULL, mp->m_sb.sb_gquotino,
-                                       0, 0, &gip, 0) == 0)
+                                       0, 0, &gip) == 0)
                        tempgqip = B_TRUE;
        }
        if (uip) {
@@ -1109,7 +1109,6 @@ xfs_qm_internalqcheck_adjust(
        xfs_ino_t       ino,            /* inode number to get data for */
        void            __user *buffer, /* not used */
        int             ubsize,         /* not used */
-       xfs_daddr_t     bno,            /* starting block of inode cluster */
        int             *ubused,        /* not used */
        int             *res)           /* bulkstat result code */
 {
@@ -1132,7 +1131,7 @@ xfs_qm_internalqcheck_adjust(
        ipreleased = B_FALSE;
  again:
        lock_flags = XFS_ILOCK_SHARED;
-       if ((error = xfs_iget(mp, NULL, ino, 0, lock_flags, &ip, bno))) {
+       if ((error = xfs_iget(mp, NULL, ino, 0, lock_flags, &ip))) {
                *res = BULKSTAT_RV_NOTHING;
                return (error);
        }
index d8fd36685eb9d12b4b51925e82535cb5e4e240fd..c7142a064c48d7b052d9ac0225f33562d0552386 100644 (file)
@@ -1354,22 +1354,6 @@ xfs_imap(
                return 0;
        }
 
-       /*
-        * If we get a block number passed we can use it to
-        * find the buffer easily.
-        */
-       if (imap->im_blkno) {
-               offset = XFS_INO_TO_OFFSET(mp, ino);
-               ASSERT(offset < mp->m_sb.sb_inopblock);
-
-               cluster_agbno = xfs_daddr_to_agbno(mp, imap->im_blkno);
-               offset += (agbno - cluster_agbno) * mp->m_sb.sb_inopblock;
-
-               imap->im_len = XFS_FSB_TO_BB(mp, blks_per_cluster);
-               imap->im_boffset = (ushort)(offset << mp->m_sb.sb_inodelog);
-               return 0;
-       }
-
        /*
         * If the inode chunks are aligned then use simple maths to
         * find the location. Otherwise we have to do a btree
index 75df75f43d48bf94f0e463aad56df8dc7f73dbfb..8f8b91be2c996dce5b75901038c507bb4b9ef1da 100644 (file)
@@ -259,7 +259,6 @@ xfs_iget_cache_miss(
        xfs_trans_t             *tp,
        xfs_ino_t               ino,
        struct xfs_inode        **ipp,
-       xfs_daddr_t             bno,
        int                     flags,
        int                     lock_flags)
 {
@@ -272,7 +271,7 @@ xfs_iget_cache_miss(
        if (!ip)
                return ENOMEM;
 
-       error = xfs_iread(mp, tp, ip, bno, flags);
+       error = xfs_iread(mp, tp, ip, flags);
        if (error)
                goto out_destroy;
 
@@ -358,8 +357,6 @@ out_destroy:
  *        within the file system for the inode being requested.
  * lock_flags -- flags indicating how to lock the inode.  See the comment
  *              for xfs_ilock() for a list of valid values.
- * bno -- the block number starting the buffer containing the inode,
- *       if known (as by bulkstat), else 0.
  */
 int
 xfs_iget(
@@ -368,8 +365,7 @@ xfs_iget(
        xfs_ino_t       ino,
        uint            flags,
        uint            lock_flags,
-       xfs_inode_t     **ipp,
-       xfs_daddr_t     bno)
+       xfs_inode_t     **ipp)
 {
        xfs_inode_t     *ip;
        int             error;
@@ -397,7 +393,7 @@ again:
                read_unlock(&pag->pag_ici_lock);
                XFS_STATS_INC(xs_ig_missed);
 
-               error = xfs_iget_cache_miss(mp, pag, tp, ino, &ip, bno,
+               error = xfs_iget_cache_miss(mp, pag, tp, ino, &ip,
                                                        flags, lock_flags);
                if (error)
                        goto out_error_or_again;
index 12c277a5e98acecbccdbc94452c7facdda945a42..b76a829d7e200d4ead1b9e4406faf93f1e4093e0 100644 (file)
@@ -787,7 +787,6 @@ xfs_iread(
        xfs_mount_t     *mp,
        xfs_trans_t     *tp,
        xfs_inode_t     *ip,
-       xfs_daddr_t     bno,
        uint            iget_flags)
 {
        xfs_buf_t       *bp;
@@ -797,11 +796,9 @@ xfs_iread(
        /*
         * Fill in the location information in the in-core inode.
         */
-       ip->i_imap.im_blkno = bno;
        error = xfs_imap(mp, tp, ip->i_ino, &ip->i_imap, iget_flags);
        if (error)
                return error;
-       ASSERT(bno == 0 || bno == ip->i_imap.im_blkno);
 
        /*
         * Get pointers to the on-disk inode and the buffer containing it.
index 6b31b38244abc52c8edadcf864b16cf7413cdd99..78550df13cd664ee4811447f836e9d0f8dc31405 100644 (file)
@@ -442,7 +442,7 @@ static inline void xfs_ifunlock(xfs_inode_t *ip)
  * xfs_iget.c prototypes.
  */
 int            xfs_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
-                        uint, uint, xfs_inode_t **, xfs_daddr_t);
+                        uint, uint, xfs_inode_t **);
 void           xfs_iput(xfs_inode_t *, uint);
 void           xfs_iput_new(xfs_inode_t *, uint);
 void           xfs_ilock(xfs_inode_t *, uint);
@@ -509,7 +509,7 @@ int         xfs_itobp(struct xfs_mount *, struct xfs_trans *,
                          struct xfs_inode *, struct xfs_dinode **,
                          struct xfs_buf **, uint);
 int            xfs_iread(struct xfs_mount *, struct xfs_trans *,
-                         struct xfs_inode *, xfs_daddr_t, uint);
+                         struct xfs_inode *, uint);
 void           xfs_dinode_to_disk(struct xfs_dinode *,
                                   struct xfs_icdinode *);
 void           xfs_idestroy_fork(struct xfs_inode *, int);
index 2acd12fd3f25557818b21cfb2c425bba656a412a..2b86f86105125c3869a641b68bc73b984ce69e79 100644 (file)
@@ -60,7 +60,6 @@ xfs_bulkstat_one_int(
        void __user             *buffer,        /* buffer to place output in */
        int                     ubsize,         /* size of buffer */
        bulkstat_one_fmt_pf     formatter,      /* formatter, copy to user */
-       xfs_daddr_t             bno,            /* starting bno of cluster */
        int                     *ubused,        /* bytes used by me */
        int                     *stat)          /* BULKSTAT_RV_... */
 {
@@ -80,7 +79,7 @@ xfs_bulkstat_one_int(
                return XFS_ERROR(ENOMEM);
 
        error = xfs_iget(mp, NULL, ino,
-                        XFS_IGET_UNTRUSTED, XFS_ILOCK_SHARED, &ip, bno);
+                        XFS_IGET_UNTRUSTED, XFS_ILOCK_SHARED, &ip);
        if (error) {
                *stat = BULKSTAT_RV_NOTHING;
                goto out_free;
@@ -179,13 +178,11 @@ xfs_bulkstat_one(
        xfs_ino_t       ino,            /* inode number to get data for */
        void            __user *buffer, /* buffer to place output in */
        int             ubsize,         /* size of buffer */
-       xfs_daddr_t     bno,            /* starting bno of inode cluster */
        int             *ubused,        /* bytes used by me */
        int             *stat)          /* BULKSTAT_RV_... */
 {
        return xfs_bulkstat_one_int(mp, ino, buffer, ubsize,
-                                   xfs_bulkstat_one_fmt, bno,
-                                   ubused, stat);
+                                   xfs_bulkstat_one_fmt, ubused, stat);
 }
 
 #define XFS_BULKSTAT_UBLEFT(ubleft)    ((ubleft) >= statstruct_size)
@@ -485,7 +482,7 @@ xfs_bulkstat(
                                 * Get the inode and fill in a single buffer.
                                 */
                                ubused = statstruct_size;
-                               error = formatter(mp, ino, ubufp, ubleft, bno,
+                               error = formatter(mp, ino, ubufp, ubleft,
                                                  &ubused, &fmterror);
                                if (fmterror == BULKSTAT_RV_NOTHING) {
                                        if (error && error != ENOENT &&
@@ -578,8 +575,7 @@ xfs_bulkstat_single(
         */
 
        ino = (xfs_ino_t)*lastinop;
-       error = xfs_bulkstat_one(mp, ino, buffer, sizeof(xfs_bstat_t),
-                                0, NULL, &res);
+       error = xfs_bulkstat_one(mp, ino, buffer, sizeof(xfs_bstat_t), 0, &res);
        if (error) {
                /*
                 * Special case way failed, do it the "long" way
index fea03397a3abb892af42f43704ccfe7653618233..97295d91d1703c21cbeacacc876f9eded07aeb38 100644 (file)
@@ -27,7 +27,6 @@ typedef int (*bulkstat_one_pf)(struct xfs_mount       *mp,
                               xfs_ino_t        ino,
                               void             __user *buffer,
                               int              ubsize,
-                              xfs_daddr_t      bno,
                               int              *ubused,
                               int              *stat);
 
@@ -71,7 +70,6 @@ xfs_bulkstat_one_int(
        void                    __user *buffer,
        int                     ubsize,
        bulkstat_one_fmt_pf     formatter,
-       xfs_daddr_t             bno,
        int                     *ubused,
        int                     *stat);
 
@@ -81,7 +79,6 @@ xfs_bulkstat_one(
        xfs_ino_t               ino,
        void                    __user *buffer,
        int                     ubsize,
-       xfs_daddr_t             bno,
        int                     *ubused,
        int                     *stat);
 
index ed0684cc50eeb51f15549d899f3979c40eb9c6af..9ac5cfab27b96da77ac033559229090a3c52490a 100644 (file)
@@ -3198,7 +3198,7 @@ xlog_recover_process_one_iunlink(
        int                             error;
 
        ino = XFS_AGINO_TO_INO(mp, agno, agino);
-       error = xfs_iget(mp, NULL, ino, 0, 0, &ip, 0);
+       error = xfs_iget(mp, NULL, ino, 0, 0, &ip);
        if (error)
                goto fail;
 
index d59f4e8bedcf2bfaadf2151c829605646c80e745..69f62d8b2816c52389f4947c9d86b3958ccf57a6 100644 (file)
@@ -1300,7 +1300,7 @@ xfs_mountfs(
         * Get and sanity-check the root inode.
         * Save the pointer to it in the mount structure.
         */
-       error = xfs_iget(mp, NULL, sbp->sb_rootino, 0, XFS_ILOCK_EXCL, &rip, 0);
+       error = xfs_iget(mp, NULL, sbp->sb_rootino, 0, XFS_ILOCK_EXCL, &rip);
        if (error) {
                cmn_err(CE_WARN, "XFS: failed to read root inode");
                goto out_log_dealloc;
index 16445518506df427988c64a1e53934f7cab4da18..a2d32ce335aa681c3beab111f4c844873353f6af 100644 (file)
@@ -2277,12 +2277,12 @@ xfs_rtmount_inodes(
        sbp = &mp->m_sb;
        if (sbp->sb_rbmino == NULLFSINO)
                return 0;
-       error = xfs_iget(mp, NULL, sbp->sb_rbmino, 0, 0, &mp->m_rbmip, 0);
+       error = xfs_iget(mp, NULL, sbp->sb_rbmino, 0, 0, &mp->m_rbmip);
        if (error)
                return error;
        ASSERT(mp->m_rbmip != NULL);
        ASSERT(sbp->sb_rsumino != NULLFSINO);
-       error = xfs_iget(mp, NULL, sbp->sb_rsumino, 0, 0, &mp->m_rsumip, 0);
+       error = xfs_iget(mp, NULL, sbp->sb_rsumino, 0, 0, &mp->m_rsumip);
        if (error) {
                IRELE(mp->m_rbmip);
                return error;
index 785ff101da0a66368a7c06587dd13b3c3eae2f70..2559dfec946bb990afe7e44af28ae43204d6474a 100644 (file)
@@ -62,7 +62,7 @@ xfs_trans_iget(
 {
        int                     error;
 
-       error = xfs_iget(mp, tp, ino, flags, lock_flags, ipp, 0);
+       error = xfs_iget(mp, tp, ino, flags, lock_flags, ipp);
        if (!error && tp)
                xfs_trans_ijoin(tp, *ipp, lock_flags);
        return error;
index a06bd62504fc7e1388abcf8aeac0000996c92a64..c1646838898f45120767046f0b62d43cca92dd54 100644 (file)
@@ -1269,7 +1269,7 @@ xfs_lookup(
        if (error)
                goto out;
 
-       error = xfs_iget(dp->i_mount, NULL, inum, 0, 0, ipp, 0);
+       error = xfs_iget(dp->i_mount, NULL, inum, 0, 0, ipp);
        if (error)
                goto out_free_name;