[XFS] decontaminate vfs operations from behavior details

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>
This commit is contained in:
Christoph Hellwig 2007-08-30 17:20:31 +10:00 committed by Tim Shimmin
parent b09cc77109
commit 48c872a9f3
8 changed files with 207 additions and 68 deletions

View File

@ -88,6 +88,7 @@ xfs-y += xfs_alloc.o \
xfs_trans_item.o \ xfs_trans_item.o \
xfs_utils.o \ xfs_utils.o \
xfs_vfsops.o \ xfs_vfsops.o \
xfs_vfsops_bhv.o \
xfs_vnodeops.o \ xfs_vnodeops.o \
xfs_rw.o \ xfs_rw.o \
xfs_dmops.o \ xfs_dmops.o \

View File

@ -202,7 +202,7 @@ xfs_revalidate_inode(
void void
xfs_initialize_vnode( xfs_initialize_vnode(
bhv_desc_t *bdp, struct xfs_mount *mp,
bhv_vnode_t *vp, bhv_vnode_t *vp,
struct xfs_inode *ip, struct xfs_inode *ip,
int unlock) int unlock)
@ -222,7 +222,7 @@ xfs_initialize_vnode(
* finish our work. * finish our work.
*/ */
if (ip->i_d.di_mode != 0 && unlock && (inode->i_state & I_NEW)) { 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_set_inodeops(inode);
xfs_iflags_clear(ip, XFS_INEW); xfs_iflags_clear(ip, XFS_INEW);

View File

@ -107,8 +107,6 @@ struct block_device;
extern __uint64_t xfs_max_file_offset(unsigned int); 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_inode(struct xfs_inode *);
extern void xfs_flush_device(struct xfs_inode *); extern void xfs_flush_device(struct xfs_inode *);

View File

@ -650,7 +650,6 @@ extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int);
extern int xfs_readsb(xfs_mount_t *, int); extern int xfs_readsb(xfs_mount_t *, int);
extern void xfs_freesb(xfs_mount_t *); extern void xfs_freesb(xfs_mount_t *);
extern int xfs_fs_writable(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_syncsub(xfs_mount_t *, int, int *);
extern int xfs_sync_inodes(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 *, extern xfs_agnumber_t xfs_initialize_perag(struct bhv_vfs *, xfs_mount_t *,

View File

@ -178,18 +178,15 @@ xfs_write_sync_logforce(
* the shop, make sure that absolutely nothing persistent happens to * the shop, make sure that absolutely nothing persistent happens to
* this filesystem after this point. * this filesystem after this point.
*/ */
void void
xfs_do_force_shutdown( xfs_do_force_shutdown(
bhv_desc_t *bdp, xfs_mount_t *mp,
int flags, int flags,
char *fname, char *fname,
int lnnum) int lnnum)
{ {
int logerror; int logerror;
xfs_mount_t *mp;
mp = XFS_BHVTOM(bdp);
logerror = flags & SHUTDOWN_LOG_IO_ERROR; logerror = flags & SHUTDOWN_LOG_IO_ERROR;
if (!(flags & SHUTDOWN_FORCE_UMOUNT)) { if (!(flags & SHUTDOWN_FORCE_UMOUNT)) {

View File

@ -55,10 +55,9 @@
#include "xfs_filestream.h" #include "xfs_filestream.h"
#include "xfs_fsops.h" #include "xfs_fsops.h"
#include "xfs_vnodeops.h" #include "xfs_vnodeops.h"
#include "xfs_vfsops.h"
STATIC int xfs_sync(bhv_desc_t *, int, cred_t *);
int int
xfs_init(void) xfs_init(void)
{ {
@ -433,15 +432,14 @@ xfs_finish_flags(
* they are present. The data subvolume has already been opened by * they are present. The data subvolume has already been opened by
* get_sb_bdev() and is stored in vfsp->vfs_super->s_bdev. * get_sb_bdev() and is stored in vfsp->vfs_super->s_bdev.
*/ */
STATIC int int
xfs_mount( xfs_mount(
struct bhv_desc *bhvp, struct xfs_mount *mp,
struct xfs_mount_args *args, struct xfs_mount_args *args,
cred_t *credp) cred_t *credp)
{ {
struct bhv_vfs *vfsp = bhvtovfs(bhvp); struct bhv_vfs *vfsp = XFS_MTOVFS(mp);
struct bhv_desc *p; struct bhv_desc *p;
struct xfs_mount *mp = XFS_BHVTOM(bhvp);
struct block_device *ddev, *logdev, *rtdev; struct block_device *ddev, *logdev, *rtdev;
int flags = 0, error; int flags = 0, error;
@ -578,14 +576,13 @@ error0:
return error; return error;
} }
STATIC int int
xfs_unmount( xfs_unmount(
bhv_desc_t *bdp, xfs_mount_t *mp,
int flags, int flags,
cred_t *credp) cred_t *credp)
{ {
bhv_vfs_t *vfsp = bhvtovfs(bdp); bhv_vfs_t *vfsp = XFS_MTOVFS(mp);
xfs_mount_t *mp = XFS_BHVTOM(bdp);
xfs_inode_t *rip; xfs_inode_t *rip;
bhv_vnode_t *rvp; bhv_vnode_t *rvp;
int unmount_event_wanted = 0; int unmount_event_wanted = 0;
@ -641,8 +638,7 @@ xfs_unmount(
* referenced vnodes as well. * referenced vnodes as well.
*/ */
if (XFS_FORCED_SHUTDOWN(mp)) { if (XFS_FORCED_SHUTDOWN(mp)) {
error = xfs_sync(&mp->m_bhv, error = xfs_sync(mp, SYNC_WAIT | SYNC_CLOSE);
(SYNC_WAIT | SYNC_CLOSE), credp);
ASSERT(error != EFSCORRUPTED); ASSERT(error != EFSCORRUPTED);
} }
xfs_unmountfs_needed = 1; xfs_unmountfs_needed = 1;
@ -726,14 +722,13 @@ xfs_attr_quiesce(
xfs_unmountfs_writesb(mp); xfs_unmountfs_writesb(mp);
} }
STATIC int int
xfs_mntupdate( xfs_mntupdate(
bhv_desc_t *bdp, struct xfs_mount *mp,
int *flags, int *flags,
struct xfs_mount_args *args) struct xfs_mount_args *args)
{ {
bhv_vfs_t *vfsp = bhvtovfs(bdp); struct bhv_vfs *vfsp = XFS_MTOVFS(mp);
xfs_mount_t *mp = XFS_BHVTOM(bdp);
if (!(*flags & MS_RDONLY)) { /* rw/ro -> rw */ if (!(*flags & MS_RDONLY)) { /* rw/ro -> rw */
if (vfsp->vfs_flag & VFS_RDONLY) if (vfsp->vfs_flag & VFS_RDONLY)
@ -843,14 +838,14 @@ fscorrupt_out2:
* vpp -- address of the caller's vnode pointer which should be * vpp -- address of the caller's vnode pointer which should be
* set to the desired fs root vnode * set to the desired fs root vnode
*/ */
STATIC int int
xfs_root( xfs_root(
bhv_desc_t *bdp, xfs_mount_t *mp,
bhv_vnode_t **vpp) bhv_vnode_t **vpp)
{ {
bhv_vnode_t *vp; bhv_vnode_t *vp;
vp = XFS_ITOV((XFS_BHVTOM(bdp))->m_rootip); vp = XFS_ITOV(mp->m_rootip);
VN_HOLD(vp); VN_HOLD(vp);
*vpp = vp; *vpp = vp;
return 0; return 0;
@ -863,19 +858,17 @@ xfs_root(
* the superblock lock in the mount structure to ensure a consistent * the superblock lock in the mount structure to ensure a consistent
* snapshot of the counters returned. * snapshot of the counters returned.
*/ */
STATIC int int
xfs_statvfs( xfs_statvfs(
bhv_desc_t *bdp, xfs_mount_t *mp,
bhv_statvfs_t *statp, bhv_statvfs_t *statp,
bhv_vnode_t *vp) bhv_vnode_t *vp)
{ {
__uint64_t fakeinos; __uint64_t fakeinos;
xfs_extlen_t lsize; xfs_extlen_t lsize;
xfs_mount_t *mp;
xfs_sb_t *sbp; xfs_sb_t *sbp;
unsigned long s; unsigned long s;
mp = XFS_BHVTOM(bdp);
sbp = &(mp->m_sb); sbp = &(mp->m_sb);
statp->f_type = XFS_SB_MAGIC; statp->f_type = XFS_SB_MAGIC;
@ -954,14 +947,11 @@ xfs_statvfs(
* filesystem. * filesystem.
* *
*/ */
/*ARGSUSED*/ int
STATIC int
xfs_sync( xfs_sync(
bhv_desc_t *bdp, xfs_mount_t *mp,
int flags, int flags)
cred_t *credp)
{ {
xfs_mount_t *mp = XFS_BHVTOM(bdp);
int error; int error;
/* /*
@ -1652,13 +1642,12 @@ xfs_syncsub(
/* /*
* xfs_vget - called by DMAPI and NFSD to get vnode from file handle * xfs_vget - called by DMAPI and NFSD to get vnode from file handle
*/ */
STATIC int int
xfs_vget( xfs_vget(
bhv_desc_t *bdp, xfs_mount_t *mp,
bhv_vnode_t **vpp, bhv_vnode_t **vpp,
fid_t *fidp) fid_t *fidp)
{ {
xfs_mount_t *mp = XFS_BHVTOM(bdp);
xfs_fid_t *xfid = (struct xfs_fid *)fidp; xfs_fid_t *xfid = (struct xfs_fid *)fidp;
xfs_inode_t *ip; xfs_inode_t *ip;
int error; 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; return simple_strtoul((const char *)s, endp, base) << shift_left_factor;
} }
STATIC int int
xfs_parseargs( xfs_parseargs(
struct bhv_desc *bhv, struct xfs_mount *mp,
char *options, char *options,
struct xfs_mount_args *args, struct xfs_mount_args *args,
int update) int update)
{ {
bhv_vfs_t *vfsp = bhvtovfs(bhv); bhv_vfs_t *vfsp = XFS_MTOVFS(mp);
char *this_char, *value, *eov; char *this_char, *value, *eov;
int dsunit, dswidth, vol_dsunit, vol_dswidth; int dsunit, dswidth, vol_dsunit, vol_dswidth;
int iosize; int iosize;
@ -2047,9 +2036,9 @@ done:
return 0; return 0;
} }
STATIC int int
xfs_showargs( xfs_showargs(
struct bhv_desc *bhv, struct xfs_mount *mp,
struct seq_file *m) struct seq_file *m)
{ {
static struct proc_xfs_info { static struct proc_xfs_info {
@ -2067,7 +2056,6 @@ xfs_showargs(
{ 0, NULL } { 0, NULL }
}; };
struct proc_xfs_info *xfs_infop; struct proc_xfs_info *xfs_infop;
struct xfs_mount *mp = XFS_BHVTOM(bhv);
struct bhv_vfs *vfsp = XFS_MTOVFS(mp); struct bhv_vfs *vfsp = XFS_MTOVFS(mp);
for (xfs_infop = xfs_info; xfs_infop->flag; xfs_infop++) { for (xfs_infop = xfs_info; xfs_infop->flag; xfs_infop++) {
@ -2142,28 +2130,8 @@ xfs_showargs(
*/ */
STATIC void STATIC void
xfs_freeze( xfs_freeze(
bhv_desc_t *bdp) xfs_mount_t *mp)
{ {
xfs_mount_t *mp = XFS_BHVTOM(bdp);
xfs_attr_quiesce(mp); xfs_attr_quiesce(mp);
xfs_fs_log_dummy(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,
};

31
fs/xfs/xfs_vfsops.h Normal file
View File

@ -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 */

145
fs/xfs/xfs_vfsops_bhv.c Normal file
View File

@ -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,
};