[XFS] decontaminate vfs operations from behavior details
authorChristoph Hellwig <hch@infradead.org>
Thu, 30 Aug 2007 07:20:31 +0000 (17:20 +1000)
committerTim Shimmin <tes@chook.melbourne.sgi.com>
Tue, 16 Oct 2007 01:43:55 +0000 (11:43 +1000)
All vfs ops now take struct xfs_mount pointers and the behaviour related
glue is split out into methods of its own.

SGI-PV: 969608
SGI-Modid: xfs-linux-melb:xfs-kern:29504a

Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: David Chinner <dgc@sgi.com>
Signed-off-by: Tim Shimmin <tes@sgi.com>
fs/xfs/Makefile-linux-2.6
fs/xfs/linux-2.6/xfs_super.c
fs/xfs/linux-2.6/xfs_super.h
fs/xfs/xfs_mount.h
fs/xfs/xfs_rw.c
fs/xfs/xfs_vfsops.c
fs/xfs/xfs_vfsops.h [new file with mode: 0644]
fs/xfs/xfs_vfsops_bhv.c [new file with mode: 0644]

index 6d48a5ed38f33bc503c43658041772fc1056e9ea..0e474785ebae724447d1261a16518fcb5961bad8 100644 (file)
@@ -88,6 +88,7 @@ xfs-y                         += xfs_alloc.o \
                                   xfs_trans_item.o \
                                   xfs_utils.o \
                                   xfs_vfsops.o \
+                                  xfs_vfsops_bhv.o \
                                   xfs_vnodeops.o \
                                   xfs_rw.o \
                                   xfs_dmops.o \
index 103add6eccb664c809bafe99ad14253c9d2dc9b2..0cb149ad65cca78789ca41083a6edbc72ea97bb2 100644 (file)
@@ -202,7 +202,7 @@ xfs_revalidate_inode(
 
 void
 xfs_initialize_vnode(
-       bhv_desc_t              *bdp,
+       struct xfs_mount        *mp,
        bhv_vnode_t             *vp,
        struct xfs_inode        *ip,
        int                     unlock)
@@ -222,7 +222,7 @@ xfs_initialize_vnode(
         * finish our work.
         */
        if (ip->i_d.di_mode != 0 && unlock && (inode->i_state & I_NEW)) {
-               xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip);
+               xfs_revalidate_inode(mp, vp, ip);
                xfs_set_inodeops(inode);
 
                xfs_iflags_clear(ip, XFS_INEW);
index 4bbf985a7de7e7e48e127dc8c2422ff8eefdeec3..dba6f1cc348a837afd230d1a0ec4a255e350001a 100644 (file)
@@ -107,8 +107,6 @@ struct block_device;
 
 extern __uint64_t xfs_max_file_offset(unsigned int);
 
-extern void xfs_initialize_vnode(bhv_desc_t *, bhv_vnode_t *, struct xfs_inode *, int);
-
 extern void xfs_flush_inode(struct xfs_inode *);
 extern void xfs_flush_device(struct xfs_inode *);
 
index 594d7856c77ec0f9b598ef835b47bba4f2997943..68d712574b810753bdbfa7b310e7300a16bb7da1 100644 (file)
@@ -650,7 +650,6 @@ extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int);
 extern int     xfs_readsb(xfs_mount_t *, int);
 extern void    xfs_freesb(xfs_mount_t *);
 extern int     xfs_fs_writable(xfs_mount_t *);
-extern void    xfs_do_force_shutdown(bhv_desc_t *, int, char *, int);
 extern int     xfs_syncsub(xfs_mount_t *, int, int *);
 extern int     xfs_sync_inodes(xfs_mount_t *, int, int *);
 extern xfs_agnumber_t  xfs_initialize_perag(struct bhv_vfs *, xfs_mount_t *,
index 905d1c008be73056458534b58636de0c1247946a..cd3ece6cc91826bc84fcf09d368eae0204dd024b 100644 (file)
@@ -178,18 +178,15 @@ xfs_write_sync_logforce(
  * the shop, make sure that absolutely nothing persistent happens to
  * this filesystem after this point.
  */
-
 void
 xfs_do_force_shutdown(
-       bhv_desc_t      *bdp,
+       xfs_mount_t     *mp,
        int             flags,
        char            *fname,
        int             lnnum)
 {
        int             logerror;
-       xfs_mount_t     *mp;
 
-       mp = XFS_BHVTOM(bdp);
        logerror = flags & SHUTDOWN_LOG_IO_ERROR;
 
        if (!(flags & SHUTDOWN_FORCE_UMOUNT)) {
index f62f6e486f23eeaf289eb88127b38c1baf310921..2d672f317110eceb67cf3e35c61b5fd4638f7008 100644 (file)
 #include "xfs_filestream.h"
 #include "xfs_fsops.h"
 #include "xfs_vnodeops.h"
+#include "xfs_vfsops.h"
 
 
-STATIC int     xfs_sync(bhv_desc_t *, int, cred_t *);
-
 int
 xfs_init(void)
 {
@@ -433,15 +432,14 @@ xfs_finish_flags(
  * they are present.  The data subvolume has already been opened by
  * get_sb_bdev() and is stored in vfsp->vfs_super->s_bdev.
  */
-STATIC int
+int
 xfs_mount(
-       struct bhv_desc         *bhvp,
+       struct xfs_mount        *mp,
        struct xfs_mount_args   *args,
        cred_t                  *credp)
 {
-       struct bhv_vfs          *vfsp = bhvtovfs(bhvp);
+       struct bhv_vfs          *vfsp = XFS_MTOVFS(mp);
        struct bhv_desc         *p;
-       struct xfs_mount        *mp = XFS_BHVTOM(bhvp);
        struct block_device     *ddev, *logdev, *rtdev;
        int                     flags = 0, error;
 
@@ -578,14 +576,13 @@ error0:
        return error;
 }
 
-STATIC int
+int
 xfs_unmount(
-       bhv_desc_t      *bdp,
+       xfs_mount_t     *mp,
        int             flags,
        cred_t          *credp)
 {
-       bhv_vfs_t       *vfsp = bhvtovfs(bdp);
-       xfs_mount_t     *mp = XFS_BHVTOM(bdp);
+       bhv_vfs_t       *vfsp = XFS_MTOVFS(mp);
        xfs_inode_t     *rip;
        bhv_vnode_t     *rvp;
        int             unmount_event_wanted = 0;
@@ -641,8 +638,7 @@ xfs_unmount(
         * referenced vnodes as well.
         */
        if (XFS_FORCED_SHUTDOWN(mp)) {
-               error = xfs_sync(&mp->m_bhv,
-                        (SYNC_WAIT | SYNC_CLOSE), credp);
+               error = xfs_sync(mp, SYNC_WAIT | SYNC_CLOSE);
                ASSERT(error != EFSCORRUPTED);
        }
        xfs_unmountfs_needed = 1;
@@ -726,14 +722,13 @@ xfs_attr_quiesce(
        xfs_unmountfs_writesb(mp);
 }
 
-STATIC int
+int
 xfs_mntupdate(
-       bhv_desc_t                      *bdp,
+       struct xfs_mount                *mp,
        int                             *flags,
        struct xfs_mount_args           *args)
 {
-       bhv_vfs_t       *vfsp = bhvtovfs(bdp);
-       xfs_mount_t     *mp = XFS_BHVTOM(bdp);
+       struct bhv_vfs                  *vfsp = XFS_MTOVFS(mp);
 
        if (!(*flags & MS_RDONLY)) {                    /* rw/ro -> rw */
                if (vfsp->vfs_flag & VFS_RDONLY)
@@ -843,14 +838,14 @@ fscorrupt_out2:
  * vpp  -- address of the caller's vnode pointer which should be
  *         set to the desired fs root vnode
  */
-STATIC int
+int
 xfs_root(
-       bhv_desc_t      *bdp,
+       xfs_mount_t     *mp,
        bhv_vnode_t     **vpp)
 {
        bhv_vnode_t     *vp;
 
-       vp = XFS_ITOV((XFS_BHVTOM(bdp))->m_rootip);
+       vp = XFS_ITOV(mp->m_rootip);
        VN_HOLD(vp);
        *vpp = vp;
        return 0;
@@ -863,19 +858,17 @@ xfs_root(
  * the superblock lock in the mount structure to ensure a consistent
  * snapshot of the counters returned.
  */
-STATIC int
+int
 xfs_statvfs(
-       bhv_desc_t      *bdp,
+       xfs_mount_t     *mp,
        bhv_statvfs_t   *statp,
        bhv_vnode_t     *vp)
 {
        __uint64_t      fakeinos;
        xfs_extlen_t    lsize;
-       xfs_mount_t     *mp;
        xfs_sb_t        *sbp;
        unsigned long   s;
 
-       mp = XFS_BHVTOM(bdp);
        sbp = &(mp->m_sb);
 
        statp->f_type = XFS_SB_MAGIC;
@@ -954,14 +947,11 @@ xfs_statvfs(
  *                    filesystem.
  *
  */
-/*ARGSUSED*/
-STATIC int
+int
 xfs_sync(
-       bhv_desc_t      *bdp,
-       int             flags,
-       cred_t          *credp)
+       xfs_mount_t     *mp,
+       int             flags)
 {
-       xfs_mount_t     *mp = XFS_BHVTOM(bdp);
        int             error;
 
        /*
@@ -1652,13 +1642,12 @@ xfs_syncsub(
 /*
  * xfs_vget - called by DMAPI and NFSD to get vnode from file handle
  */
-STATIC int
+int
 xfs_vget(
-       bhv_desc_t      *bdp,
+       xfs_mount_t     *mp,
        bhv_vnode_t     **vpp,
        fid_t           *fidp)
 {
-       xfs_mount_t     *mp = XFS_BHVTOM(bdp);
        xfs_fid_t       *xfid = (struct xfs_fid *)fidp;
        xfs_inode_t     *ip;
        int             error;
@@ -1775,14 +1764,14 @@ suffix_strtoul(char *s, char **endp, unsigned int base)
        return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
 }
 
-STATIC int
+int
 xfs_parseargs(
-       struct bhv_desc         *bhv,
+       struct xfs_mount        *mp,
        char                    *options,
        struct xfs_mount_args   *args,
        int                     update)
 {
-       bhv_vfs_t               *vfsp = bhvtovfs(bhv);
+       bhv_vfs_t               *vfsp = XFS_MTOVFS(mp);
        char                    *this_char, *value, *eov;
        int                     dsunit, dswidth, vol_dsunit, vol_dswidth;
        int                     iosize;
@@ -2047,9 +2036,9 @@ done:
        return 0;
 }
 
-STATIC int
+int
 xfs_showargs(
-       struct bhv_desc         *bhv,
+       struct xfs_mount        *mp,
        struct seq_file         *m)
 {
        static struct proc_xfs_info {
@@ -2067,7 +2056,6 @@ xfs_showargs(
                { 0, NULL }
        };
        struct proc_xfs_info    *xfs_infop;
-       struct xfs_mount        *mp = XFS_BHVTOM(bhv);
        struct bhv_vfs          *vfsp = XFS_MTOVFS(mp);
 
        for (xfs_infop = xfs_info; xfs_infop->flag; xfs_infop++) {
@@ -2142,28 +2130,8 @@ xfs_showargs(
  */
 STATIC void
 xfs_freeze(
-       bhv_desc_t      *bdp)
+       xfs_mount_t     *mp)
 {
-       xfs_mount_t     *mp = XFS_BHVTOM(bdp);
-
        xfs_attr_quiesce(mp);
        xfs_fs_log_dummy(mp);
 }
-
-
-bhv_vfsops_t xfs_vfsops = {
-       BHV_IDENTITY_INIT(VFS_BHV_XFS,VFS_POSITION_XFS),
-       .vfs_parseargs          = xfs_parseargs,
-       .vfs_showargs           = xfs_showargs,
-       .vfs_mount              = xfs_mount,
-       .vfs_unmount            = xfs_unmount,
-       .vfs_mntupdate          = xfs_mntupdate,
-       .vfs_root               = xfs_root,
-       .vfs_statvfs            = xfs_statvfs,
-       .vfs_sync               = xfs_sync,
-       .vfs_vget               = xfs_vget,
-       .vfs_quotactl           = (vfs_quotactl_t)fs_nosys,
-       .vfs_init_vnode         = xfs_initialize_vnode,
-       .vfs_force_shutdown     = xfs_do_force_shutdown,
-       .vfs_freeze             = xfs_freeze,
-};
diff --git a/fs/xfs/xfs_vfsops.h b/fs/xfs/xfs_vfsops.h
new file mode 100644 (file)
index 0000000..994502e
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef _XFS_VFSOPS_H
+#define _XFS_VFSOPS_H 1
+
+struct cred;
+struct fid;
+struct inode;
+struct kstatfs;
+struct xfs_mount;
+struct xfs_mount_args;
+
+int xfs_mount(struct xfs_mount *mp, struct xfs_mount_args *args,
+               struct cred *credp);
+int xfs_unmount(struct xfs_mount *mp, int flags, struct cred *credp);
+int xfs_mntupdate(struct xfs_mount *mp, int *flags,
+               struct xfs_mount_args *args);
+int xfs_root(struct xfs_mount *mp, bhv_vnode_t **vpp);
+int xfs_statvfs(struct xfs_mount *mp, struct kstatfs *statp,
+               bhv_vnode_t *vp);
+int xfs_sync(struct xfs_mount *mp, int flags);
+int xfs_vget(struct xfs_mount *mp, bhv_vnode_t **vpp, struct fid *fidp);
+int xfs_parseargs(struct xfs_mount *mp, char *options,
+               struct xfs_mount_args *args, int update);
+int xfs_showargs(struct xfs_mount *mp, struct seq_file *m);
+void xfs_freeze(struct xfs_mount *mp);
+void xfs_do_force_shutdown(struct xfs_mount *mp, int flags, char *fname,
+               int lnnum);
+struct inode *xfs_get_inode(struct xfs_mount *mp, xfs_ino_t ino, int flags);
+void xfs_initialize_vnode(struct xfs_mount *mp, bhv_vnode_t *vp,
+               struct xfs_inode *ip, int unlock);
+
+#endif /* _XFS_VFSOPS_H */
diff --git a/fs/xfs/xfs_vfsops_bhv.c b/fs/xfs/xfs_vfsops_bhv.c
new file mode 100644 (file)
index 0000000..764b2ae
--- /dev/null
@@ -0,0 +1,145 @@
+
+#include "xfs_linux.h"
+#include "xfs_vfsops.h"
+
+#include "xfs_inum.h"
+#include "xfs_dmapi.h"
+#include "xfs_sb.h"
+#include "xfs_log.h"
+#include "xfs_trans.h"
+#include "xfs_ag.h"
+#include "xfs_mount.h"
+
+
+STATIC int
+xfs_bhv_mount(
+       struct bhv_desc         *bhvp,
+       struct xfs_mount_args   *args,
+       cred_t                  *credp)
+{
+       return xfs_mount(XFS_BHVTOM(bhvp), args, credp);
+}
+
+STATIC int
+xfs_bhv_unmount(
+       bhv_desc_t      *bdp,
+       int             flags,
+       cred_t          *credp)
+{
+       return xfs_unmount(XFS_BHVTOM(bdp), flags, credp);
+}
+
+STATIC int
+xfs_bhv_mntupdate(
+       bhv_desc_t                      *bdp,
+       int                             *flags,
+       struct xfs_mount_args           *args)
+{
+       return xfs_mntupdate(XFS_BHVTOM(bdp), flags, args);
+}
+
+STATIC int
+xfs_bhv_root(
+       bhv_desc_t      *bdp,
+       bhv_vnode_t     **vpp)
+{
+       return xfs_root(XFS_BHVTOM(bdp), vpp);
+}
+
+STATIC int
+xfs_bhv_statvfs(
+       bhv_desc_t      *bdp,
+       bhv_statvfs_t   *statp,
+       bhv_vnode_t     *vp)
+{
+       return xfs_statvfs(XFS_BHVTOM(bdp), statp, vp);
+}
+
+STATIC int
+xfs_bhv_sync(
+       bhv_desc_t      *bdp,
+       int             flags,
+       cred_t          *credp)
+{
+       return xfs_sync(XFS_BHVTOM(bdp), flags);
+}
+
+STATIC int
+xfs_bhv_vget(
+       bhv_desc_t      *bdp,
+       bhv_vnode_t     **vpp,
+       fid_t           *fidp)
+{
+       return xfs_vget(XFS_BHVTOM(bdp), vpp, fidp);
+}
+
+STATIC int
+xfs_bhv_parseargs(
+       struct bhv_desc         *bhv,
+       char                    *options,
+       struct xfs_mount_args   *args,
+       int                     update)
+{
+       return xfs_parseargs(XFS_BHVTOM(bhv), options, args, update);
+}
+
+STATIC int
+xfs_bhv_showargs(
+       struct bhv_desc         *bhv,
+       struct seq_file         *m)
+{
+       return xfs_showargs(XFS_BHVTOM(bhv), m);
+}
+
+STATIC void
+xfs_bhv_freeze(
+       bhv_desc_t      *bdp)
+{
+       return xfs_freeze(XFS_BHVTOM(bdp));
+}
+
+STATIC void
+xfs_bhv_force_shutdown(
+       bhv_desc_t      *bdp,
+       int             flags,
+       char            *fname,
+       int             lnnum)
+{
+       return xfs_do_force_shutdown(XFS_BHVTOM(bdp), flags, fname, lnnum);
+}
+
+STATIC struct inode *
+xfs_bhv_get_inode(
+       bhv_desc_t      *bdp,
+       xfs_ino_t       ino,
+       int             flags)
+{
+       return xfs_get_inode(XFS_BHVTOM(bdp), ino, flags);
+}
+
+STATIC void
+xfs_bhv_initialize_vnode(
+       bhv_desc_t              *bdp,
+       bhv_vnode_t             *vp,
+       struct xfs_inode        *ip,
+       int                     unlock)
+{
+       return xfs_initialize_vnode(XFS_BHVTOM(bdp), vp, ip, unlock);
+}
+
+bhv_vfsops_t xfs_vfsops = {
+       BHV_IDENTITY_INIT(VFS_BHV_XFS,VFS_POSITION_XFS),
+       .vfs_parseargs          = xfs_bhv_parseargs,
+       .vfs_showargs           = xfs_bhv_showargs,
+       .vfs_mount              = xfs_bhv_mount,
+       .vfs_unmount            = xfs_bhv_unmount,
+       .vfs_mntupdate          = xfs_bhv_mntupdate,
+       .vfs_root               = xfs_bhv_root,
+       .vfs_statvfs            = xfs_bhv_statvfs,
+       .vfs_sync               = xfs_bhv_sync,
+       .vfs_vget               = xfs_bhv_vget,
+       .vfs_get_inode          = xfs_bhv_get_inode,
+       .vfs_init_vnode         = xfs_bhv_initialize_vnode,
+       .vfs_force_shutdown     = xfs_bhv_force_shutdown,
+       .vfs_freeze             = xfs_bhv_freeze,
+};