[XFS] cleanup vnode use in dmapi calls
authorChristoph Hellwig <hch@infradead.org>
Thu, 6 Mar 2008 02:45:58 +0000 (13:45 +1100)
committerLachlan McIlroy <lachlan@redback.melbourne.sgi.com>
Fri, 18 Apr 2008 01:40:15 +0000 (11:40 +1000)
SGI-PV: 976035
SGI-Modid: xfs-linux-melb:xfs-kern:30545a

Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
fs/xfs/linux-2.6/xfs_file.c
fs/xfs/linux-2.6/xfs_lrw.c
fs/xfs/xfs_bmap.c
fs/xfs/xfs_mount.h
fs/xfs/xfs_rename.c
fs/xfs/xfs_vfsops.c
fs/xfs/xfs_vnodeops.c

index edab1ff..0590524 100644 (file)
@@ -469,16 +469,11 @@ xfs_file_open_exec(
        struct inode    *inode)
 {
        struct xfs_mount *mp = XFS_M(inode->i_sb);
+       struct xfs_inode *ip = XFS_I(inode);
 
-       if (unlikely(mp->m_flags & XFS_MOUNT_DMAPI)) {
-               if (DM_EVENT_ENABLED(XFS_I(inode), DM_EVENT_READ)) {
-                       bhv_vnode_t *vp = vn_from_inode(inode);
-
-                       return -XFS_SEND_DATA(mp, DM_EVENT_READ,
-                                               vp, 0, 0, 0, NULL);
-               }
-       }
-
+       if (unlikely(mp->m_flags & XFS_MOUNT_DMAPI) &&
+                    DM_EVENT_ENABLED(ip, DM_EVENT_READ))
+               return -XFS_SEND_DATA(mp, DM_EVENT_READ, ip, 0, 0, 0, NULL);
        return 0;
 }
 #endif /* HAVE_FOP_OPEN_EXEC */
index 3c20007..01a8f26 100644 (file)
@@ -231,7 +231,7 @@ xfs_read(
                int dmflags = FILP_DELAY_FLAG(file) | DM_SEM_FLAG_RD(ioflags);
                int iolock = XFS_IOLOCK_SHARED;
 
-               ret = -XFS_SEND_DATA(mp, DM_EVENT_READ, vp, *offset, size,
+               ret = -XFS_SEND_DATA(mp, DM_EVENT_READ, ip, *offset, size,
                                        dmflags, &iolock);
                if (ret) {
                        xfs_iunlock(ip, XFS_IOLOCK_SHARED);
@@ -276,7 +276,6 @@ xfs_splice_read(
        int                     flags,
        int                     ioflags)
 {
-       bhv_vnode_t             *vp = XFS_ITOV(ip);
        xfs_mount_t             *mp = ip->i_mount;
        ssize_t                 ret;
 
@@ -290,7 +289,7 @@ xfs_splice_read(
                int iolock = XFS_IOLOCK_SHARED;
                int error;
 
-               error = XFS_SEND_DATA(mp, DM_EVENT_READ, vp, *ppos, count,
+               error = XFS_SEND_DATA(mp, DM_EVENT_READ, ip, *ppos, count,
                                        FILP_DELAY_FLAG(infilp), &iolock);
                if (error) {
                        xfs_iunlock(ip, XFS_IOLOCK_SHARED);
@@ -317,7 +316,6 @@ xfs_splice_write(
        int                     flags,
        int                     ioflags)
 {
-       bhv_vnode_t             *vp = XFS_ITOV(ip);
        xfs_mount_t             *mp = ip->i_mount;
        ssize_t                 ret;
        struct inode            *inode = outfilp->f_mapping->host;
@@ -333,7 +331,7 @@ xfs_splice_write(
                int iolock = XFS_IOLOCK_EXCL;
                int error;
 
-               error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, vp, *ppos, count,
+               error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, ip, *ppos, count,
                                        FILP_DELAY_FLAG(outfilp), &iolock);
                if (error) {
                        xfs_iunlock(ip, XFS_IOLOCK_EXCL);
@@ -631,7 +629,7 @@ start:
                        dmflags |= DM_FLAGS_IMUX;
 
                xfs_iunlock(xip, XFS_ILOCK_EXCL);
-               error = XFS_SEND_DATA(xip->i_mount, DM_EVENT_WRITE, vp,
+               error = XFS_SEND_DATA(xip->i_mount, DM_EVENT_WRITE, xip,
                                      pos, count, dmflags, &iolock);
                if (error) {
                        goto out_unlock_internal;
@@ -778,8 +776,8 @@ retry:
                xfs_iunlock(xip, iolock);
                if (need_i_mutex)
                        mutex_unlock(&inode->i_mutex);
-               error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp,
-                               DM_RIGHT_NULL, vp, DM_RIGHT_NULL, NULL, NULL,
+               error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, xip,
+                               DM_RIGHT_NULL, xip, DM_RIGHT_NULL, NULL, NULL,
                                0, 0, 0); /* Delay flag intentionally  unused */
                if (need_i_mutex)
                        mutex_lock(&inode->i_mutex);
index 87f6467..19aae13 100644 (file)
@@ -5811,7 +5811,7 @@ xfs_getbmap(
        if ((interface & BMV_IF_NO_DMAPI_READ) == 0 &&
            DM_EVENT_ENABLED(ip, DM_EVENT_READ) &&
            whichfork == XFS_DATA_FORK) {
-               error = XFS_SEND_DATA(mp, DM_EVENT_READ, vp, 0, 0, 0, NULL);
+               error = XFS_SEND_DATA(mp, DM_EVENT_READ, ip, 0, 0, 0, NULL);
                if (error)
                        return XFS_ERROR(error);
        }
index 110ee83..7b37fa0 100644 (file)
@@ -66,17 +66,17 @@ struct xfs_mru_cache;
  * Prototypes and functions for the Data Migration subsystem.
  */
 
-typedef int    (*xfs_send_data_t)(int, bhv_vnode_t *,
+typedef int    (*xfs_send_data_t)(int, struct xfs_inode *,
                        xfs_off_t, size_t, int, int *);
 typedef int    (*xfs_send_mmap_t)(struct vm_area_struct *, uint);
-typedef int    (*xfs_send_destroy_t)(bhv_vnode_t *, dm_right_t);
+typedef int    (*xfs_send_destroy_t)(struct xfs_inode *, dm_right_t);
 typedef int    (*xfs_send_namesp_t)(dm_eventtype_t, struct xfs_mount *,
-                       bhv_vnode_t *,
-                       dm_right_t, bhv_vnode_t *, dm_right_t,
+                       struct xfs_inode *, dm_right_t,
+                       struct xfs_inode *, dm_right_t,
                        char *, char *, mode_t, int, int);
 typedef int    (*xfs_send_mount_t)(struct xfs_mount *, dm_right_t,
                        char *, char *);
-typedef void   (*xfs_send_unmount_t)(struct xfs_mount *, bhv_vnode_t *,
+typedef void   (*xfs_send_unmount_t)(struct xfs_mount *, struct xfs_inode *,
                        dm_right_t, mode_t, int, int);
 
 typedef struct xfs_dmops {
@@ -88,20 +88,20 @@ typedef struct xfs_dmops {
        xfs_send_unmount_t      xfs_send_unmount;
 } xfs_dmops_t;
 
-#define XFS_SEND_DATA(mp, ev,vp,off,len,fl,lock) \
-       (*(mp)->m_dm_ops->xfs_send_data)(ev,vp,off,len,fl,lock)
+#define XFS_SEND_DATA(mp, ev,ip,off,len,fl,lock) \
+       (*(mp)->m_dm_ops->xfs_send_data)(ev,ip,off,len,fl,lock)
 #define XFS_SEND_MMAP(mp, vma,fl) \
        (*(mp)->m_dm_ops->xfs_send_mmap)(vma,fl)
-#define XFS_SEND_DESTROY(mp, vp,right) \
-       (*(mp)->m_dm_ops->xfs_send_destroy)(vp,right)
+#define XFS_SEND_DESTROY(mp, ip,right) \
+       (*(mp)->m_dm_ops->xfs_send_destroy)(ip,right)
 #define XFS_SEND_NAMESP(mp, ev,b1,r1,b2,r2,n1,n2,mode,rval,fl) \
        (*(mp)->m_dm_ops->xfs_send_namesp)(ev,NULL,b1,r1,b2,r2,n1,n2,mode,rval,fl)
 #define XFS_SEND_PREUNMOUNT(mp,b1,r1,b2,r2,n1,n2,mode,rval,fl) \
        (*(mp)->m_dm_ops->xfs_send_namesp)(DM_EVENT_PREUNMOUNT,mp,b1,r1,b2,r2,n1,n2,mode,rval,fl)
 #define XFS_SEND_MOUNT(mp,right,path,name) \
        (*(mp)->m_dm_ops->xfs_send_mount)(mp,right,path,name)
-#define XFS_SEND_UNMOUNT(mp, vp,right,mode,rval,fl) \
-       (*(mp)->m_dm_ops->xfs_send_unmount)(mp,vp,right,mode,rval,fl)
+#define XFS_SEND_UNMOUNT(mp, ip,right,mode,rval,fl) \
+       (*(mp)->m_dm_ops->xfs_send_unmount)(mp,ip,right,mode,rval,fl)
 
 
 /*
index fd1244c..6f80cfd 100644 (file)
@@ -258,8 +258,8 @@ xfs_rename(
        if (DM_EVENT_ENABLED(src_dp, DM_EVENT_RENAME) ||
            DM_EVENT_ENABLED(target_dp, DM_EVENT_RENAME)) {
                error = XFS_SEND_NAMESP(mp, DM_EVENT_RENAME,
-                                       src_dir_vp, DM_RIGHT_NULL,
-                                       target_dir_vp, DM_RIGHT_NULL,
+                                       src_dp, DM_RIGHT_NULL,
+                                       target_dp, DM_RIGHT_NULL,
                                        src_name, target_name,
                                        0, 0, 0);
                if (error) {
@@ -591,8 +591,8 @@ std_return:
        if (DM_EVENT_ENABLED(src_dp, DM_EVENT_POSTRENAME) ||
            DM_EVENT_ENABLED(target_dp, DM_EVENT_POSTRENAME)) {
                (void) XFS_SEND_NAMESP (mp, DM_EVENT_POSTRENAME,
-                                       src_dir_vp, DM_RIGHT_NULL,
-                                       target_dir_vp, DM_RIGHT_NULL,
+                                       src_dp, DM_RIGHT_NULL,
+                                       target_dp, DM_RIGHT_NULL,
                                        src_name, target_name,
                                        0, error, 0);
        }
index 3ec27bf..4c132a8 100644 (file)
@@ -566,7 +566,7 @@ xfs_unmount(
 #ifdef HAVE_DMAPI
        if (mp->m_flags & XFS_MOUNT_DMAPI) {
                error = XFS_SEND_PREUNMOUNT(mp,
-                               rvp, DM_RIGHT_NULL, rvp, DM_RIGHT_NULL,
+                               rip, DM_RIGHT_NULL, rip, DM_RIGHT_NULL,
                                NULL, NULL, 0, 0,
                                (mp->m_dmevmask & (1<<DM_EVENT_PREUNMOUNT))?
                                        0:DM_FLAGS_UNWANTED);
@@ -617,7 +617,7 @@ out:
                /* Note: mp structure must still exist for
                 * XFS_SEND_UNMOUNT() call.
                 */
-               XFS_SEND_UNMOUNT(mp, error == 0 ? rvp : NULL,
+               XFS_SEND_UNMOUNT(mp, error == 0 ? rip : NULL,
                        DM_RIGHT_NULL, 0, error, unmount_event_flags);
        }
        if (xfs_unmountfs_needed) {
index b77dede..7e124b5 100644 (file)
@@ -326,7 +326,7 @@ xfs_setattr(
                if (DM_EVENT_ENABLED(ip, DM_EVENT_TRUNCATE) &&
                    !(flags & ATTR_DMI)) {
                        int dmflags = AT_DELAY_FLAG(flags) | DM_SEM_FLAG_WR;
-                       code = XFS_SEND_DATA(mp, DM_EVENT_TRUNCATE, vp,
+                       code = XFS_SEND_DATA(mp, DM_EVENT_TRUNCATE, ip,
                                vap->va_size, 0, dmflags, NULL);
                        if (code) {
                                lock_flags = 0;
@@ -881,7 +881,7 @@ xfs_setattr(
 
        if (DM_EVENT_ENABLED(ip, DM_EVENT_ATTRIBUTE) &&
            !(flags & ATTR_DMI)) {
-               (void) XFS_SEND_NAMESP(mp, DM_EVENT_ATTRIBUTE, vp, DM_RIGHT_NULL,
+               (void) XFS_SEND_NAMESP(mp, DM_EVENT_ATTRIBUTE, ip, DM_RIGHT_NULL,
                                        NULL, DM_RIGHT_NULL, NULL, NULL,
                                        0, 0, AT_DELAY_FLAG(flags));
        }
@@ -1586,9 +1586,8 @@ xfs_inactive(
 
        mp = ip->i_mount;
 
-       if (ip->i_d.di_nlink == 0 && DM_EVENT_ENABLED(ip, DM_EVENT_DESTROY)) {
-               (void) XFS_SEND_DESTROY(mp, vp, DM_RIGHT_NULL);
-       }
+       if (ip->i_d.di_nlink == 0 && DM_EVENT_ENABLED(ip, DM_EVENT_DESTROY))
+               XFS_SEND_DESTROY(mp, ip, DM_RIGHT_NULL);
 
        error = 0;
 
@@ -1820,7 +1819,7 @@ xfs_create(
 
        if (DM_EVENT_ENABLED(dp, DM_EVENT_CREATE)) {
                error = XFS_SEND_NAMESP(mp, DM_EVENT_CREATE,
-                               dir_vp, DM_RIGHT_NULL, NULL,
+                               dp, DM_RIGHT_NULL, NULL,
                                DM_RIGHT_NULL, name, NULL,
                                mode, 0, 0);
 
@@ -1976,8 +1975,8 @@ std_return:
        if ((*vpp || (error != 0 && dm_event_sent != 0)) &&
            DM_EVENT_ENABLED(dp, DM_EVENT_POSTCREATE)) {
                (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTCREATE,
-                       dir_vp, DM_RIGHT_NULL,
-                       *vpp ? vp:NULL,
+                       dp, DM_RIGHT_NULL,
+                       *vpp ? ip : NULL,
                        DM_RIGHT_NULL, name, NULL,
                        mode, error, 0);
        }
@@ -2272,7 +2271,6 @@ xfs_remove(
        xfs_inode_t             *dp,
        bhv_vname_t             *dentry)
 {
-       bhv_vnode_t             *dir_vp = XFS_ITOV(dp);
        char                    *name = VNAME(dentry);
        xfs_mount_t             *mp = dp->i_mount;
        xfs_inode_t             *ip = VNAME_TO_INODE(dentry);
@@ -2292,7 +2290,7 @@ xfs_remove(
                return XFS_ERROR(EIO);
 
        if (DM_EVENT_ENABLED(dp, DM_EVENT_REMOVE)) {
-               error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE, dir_vp,
+               error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE, dp,
                                        DM_RIGHT_NULL, NULL, DM_RIGHT_NULL,
                                        name, NULL, ip->i_d.di_mode, 0, 0);
                if (error)
@@ -2445,7 +2443,7 @@ xfs_remove(
  std_return:
        if (DM_EVENT_ENABLED(dp, DM_EVENT_POSTREMOVE)) {
                (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE,
-                               dir_vp, DM_RIGHT_NULL,
+                               dp, DM_RIGHT_NULL,
                                NULL, DM_RIGHT_NULL,
                                name, NULL, ip->i_d.di_mode, error, 0);
        }
@@ -2504,8 +2502,8 @@ xfs_link(
 
        if (DM_EVENT_ENABLED(tdp, DM_EVENT_LINK)) {
                error = XFS_SEND_NAMESP(mp, DM_EVENT_LINK,
-                                       target_dir_vp, DM_RIGHT_NULL,
-                                       src_vp, DM_RIGHT_NULL,
+                                       tdp, DM_RIGHT_NULL,
+                                       sip, DM_RIGHT_NULL,
                                        target_name, NULL, 0, 0, 0);
                if (error)
                        return error;
@@ -2615,8 +2613,8 @@ xfs_link(
 std_return:
        if (DM_EVENT_ENABLED(sip, DM_EVENT_POSTLINK)) {
                (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTLINK,
-                               target_dir_vp, DM_RIGHT_NULL,
-                               src_vp, DM_RIGHT_NULL,
+                               tdp, DM_RIGHT_NULL,
+                               sip, DM_RIGHT_NULL,
                                target_name, NULL, 0, error, 0);
        }
        return error;
@@ -2665,7 +2663,7 @@ xfs_mkdir(
 
        if (DM_EVENT_ENABLED(dp, DM_EVENT_CREATE)) {
                error = XFS_SEND_NAMESP(mp, DM_EVENT_CREATE,
-                                       dir_vp, DM_RIGHT_NULL, NULL,
+                                       dp, DM_RIGHT_NULL, NULL,
                                        DM_RIGHT_NULL, dir_name, NULL,
                                        mode, 0, 0);
                if (error)
@@ -2823,8 +2821,8 @@ std_return:
        if ((created || (error != 0 && dm_event_sent != 0)) &&
            DM_EVENT_ENABLED(dp, DM_EVENT_POSTCREATE)) {
                (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTCREATE,
-                                       dir_vp, DM_RIGHT_NULL,
-                                       created ? XFS_ITOV(cdp):NULL,
+                                       dp, DM_RIGHT_NULL,
+                                       created ? cdp : NULL,
                                        DM_RIGHT_NULL,
                                        dir_name, NULL,
                                        mode, error, 0);
@@ -2873,7 +2871,7 @@ xfs_rmdir(
 
        if (DM_EVENT_ENABLED(dp, DM_EVENT_REMOVE)) {
                error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE,
-                                       dir_vp, DM_RIGHT_NULL,
+                                       dp, DM_RIGHT_NULL,
                                        NULL, DM_RIGHT_NULL,
                                        name, NULL, cdp->i_d.di_mode, 0, 0);
                if (error)
@@ -3047,7 +3045,7 @@ xfs_rmdir(
  std_return:
        if (DM_EVENT_ENABLED(dp, DM_EVENT_POSTREMOVE)) {
                (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE,
-                                       dir_vp, DM_RIGHT_NULL,
+                                       dp, DM_RIGHT_NULL,
                                        NULL, DM_RIGHT_NULL,
                                        name, NULL, cdp->i_d.di_mode,
                                        error, 0);
@@ -3144,7 +3142,7 @@ xfs_symlink(
        }
 
        if (DM_EVENT_ENABLED(dp, DM_EVENT_SYMLINK)) {
-               error = XFS_SEND_NAMESP(mp, DM_EVENT_SYMLINK, dir_vp,
+               error = XFS_SEND_NAMESP(mp, DM_EVENT_SYMLINK, dp,
                                        DM_RIGHT_NULL, NULL, DM_RIGHT_NULL,
                                        link_name, target_path, 0, 0, 0);
                if (error)
@@ -3348,8 +3346,8 @@ xfs_symlink(
 std_return:
        if (DM_EVENT_ENABLED(dp, DM_EVENT_POSTSYMLINK)) {
                (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTSYMLINK,
-                                       dir_vp, DM_RIGHT_NULL,
-                                       error ? NULL : XFS_ITOV(ip),
+                                       dp, DM_RIGHT_NULL,
+                                       error ? NULL : ip,
                                        DM_RIGHT_NULL, link_name, target_path,
                                        0, error, 0);
        }
@@ -3707,9 +3705,8 @@ xfs_alloc_file_space(
                end_dmi_offset = offset+len;
                if (end_dmi_offset > ip->i_size)
                        end_dmi_offset = ip->i_size;
-               error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, XFS_ITOV(ip),
-                       offset, end_dmi_offset - offset,
-                       0, NULL);
+               error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, ip, offset,
+                                     end_dmi_offset - offset, 0, NULL);
                if (error)
                        return error;
        }
@@ -3818,8 +3815,8 @@ dmapi_enospc_check:
        if (error == ENOSPC && (attr_flags & ATTR_DMI) == 0 &&
            DM_EVENT_ENABLED(ip, DM_EVENT_NOSPACE)) {
                error = XFS_SEND_NAMESP(mp, DM_EVENT_NOSPACE,
-                               XFS_ITOV(ip), DM_RIGHT_NULL,
-                               XFS_ITOV(ip), DM_RIGHT_NULL,
+                               ip, DM_RIGHT_NULL,
+                               ip, DM_RIGHT_NULL,
                                NULL, NULL, 0, 0, 0); /* Delay flag intentionally unused */
                if (error == 0)
                        goto retry;     /* Maybe DMAPI app. has made space */
@@ -3964,7 +3961,7 @@ xfs_free_file_space(
            DM_EVENT_ENABLED(ip, DM_EVENT_WRITE)) {
                if (end_dmi_offset > ip->i_size)
                        end_dmi_offset = ip->i_size;
-               error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, vp,
+               error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, ip,
                                offset, end_dmi_offset - offset,
                                AT_DELAY_FLAG(attr_flags), NULL);
                if (error)