blob: 55f0afd3e794091692a4954ce033b3dff8561df5 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scottb83bd132006-06-09 16:48:30 +10002 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
Nathan Scott7b718762005-11-02 14:58:39 +11003 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott7b718762005-11-02 14:58:39 +11005 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott7b718762005-11-02 14:58:39 +11009 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott7b718762005-11-02 14:58:39 +110014 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 */
18#ifndef __XFS_VFS_H__
19#define __XFS_VFS_H__
20
21#include <linux/vfs.h>
22#include "xfs_fs.h"
23
Nathan Scottb83bd132006-06-09 16:48:30 +100024struct bhv_vfs;
Linus Torvalds1da177e2005-04-16 15:20:36 -070025struct fid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070026struct cred;
27struct vnode;
Nathan Scottb83bd132006-06-09 16:48:30 +100028struct statfs;
Linus Torvalds1da177e2005-04-16 15:20:36 -070029struct seq_file;
30struct super_block;
31struct xfs_mount_args;
32
33typedef struct kstatfs xfs_statfs_t;
34
Nathan Scottb83bd132006-06-09 16:48:30 +100035typedef struct bhv_vfs_sync_work {
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 struct list_head w_list;
Nathan Scottb83bd132006-06-09 16:48:30 +100037 struct bhv_vfs *w_vfs;
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 void *w_data; /* syncer routine argument */
Nathan Scottb83bd132006-06-09 16:48:30 +100039 void (*w_syncer)(struct bhv_vfs *, void *);
40} bhv_vfs_sync_work_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
Nathan Scottb83bd132006-06-09 16:48:30 +100042typedef struct bhv_vfs {
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 u_int vfs_flag; /* flags */
44 xfs_fsid_t vfs_fsid; /* file system ID */
45 xfs_fsid_t *vfs_altfsid; /* An ID fixed for life of FS */
46 bhv_head_t vfs_bh; /* head of vfs behavior chain */
47 struct super_block *vfs_super; /* generic superblock pointer */
48 struct task_struct *vfs_sync_task; /* generalised sync thread */
Nathan Scottb83bd132006-06-09 16:48:30 +100049 bhv_vfs_sync_work_t vfs_sync_work; /* work item for VFS_SYNC */
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 struct list_head vfs_sync_list; /* sync thread work item list */
51 spinlock_t vfs_sync_lock; /* work item list lock */
Nathan Scottb83bd132006-06-09 16:48:30 +100052 int vfs_sync_seq; /* sync thread generation no. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 wait_queue_head_t vfs_wait_single_sync_task;
Nathan Scottb83bd132006-06-09 16:48:30 +100054} bhv_vfs_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56#define vfs_fbhv vfs_bh.bh_first /* 1st on vfs behavior chain */
57
Nathan Scottb83bd132006-06-09 16:48:30 +100058#define bhvtovfs(bdp) ( (struct bhv_vfs *)BHV_VOBJ(bdp) )
59#define bhvtovfsops(bdp) ( (struct bhv_vfsops *)BHV_OPS(bdp) )
Linus Torvalds1da177e2005-04-16 15:20:36 -070060#define VFS_BHVHEAD(vfs) ( &(vfs)->vfs_bh )
61#define VFS_REMOVEBHV(vfs, bdp) ( bhv_remove(VFS_BHVHEAD(vfs), bdp) )
62
63#define VFS_POSITION_BASE BHV_POSITION_BASE /* chain bottom */
64#define VFS_POSITION_TOP BHV_POSITION_TOP /* chain top */
65#define VFS_POSITION_INVALID BHV_POSITION_INVALID /* invalid pos. num */
66
67typedef enum {
68 VFS_BHV_UNKNOWN, /* not specified */
69 VFS_BHV_XFS, /* xfs */
70 VFS_BHV_DM, /* data migration */
71 VFS_BHV_QM, /* quota manager */
72 VFS_BHV_IO, /* IO path */
73 VFS_BHV_END /* housekeeping end-of-range */
Nathan Scottb83bd132006-06-09 16:48:30 +100074} bhv_vfs_type_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
76#define VFS_POSITION_XFS (BHV_POSITION_BASE)
77#define VFS_POSITION_DM (VFS_POSITION_BASE+10)
78#define VFS_POSITION_QM (VFS_POSITION_BASE+20)
79#define VFS_POSITION_IO (VFS_POSITION_BASE+30)
80
81#define VFS_RDONLY 0x0001 /* read-only vfs */
82#define VFS_GRPID 0x0002 /* group-ID assigned from directory */
83#define VFS_DMI 0x0004 /* filesystem has the DMI enabled */
Nathan Scottb83bd132006-06-09 16:48:30 +100084#define VFS_UMOUNT 0x0008 /* unmount in progress */
85#define VFS_32BITINODES 0x0010 /* do not use inums above 32 bits */
86#define VFS_END 0x0010 /* max flag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
88#define SYNC_ATTR 0x0001 /* sync attributes */
89#define SYNC_CLOSE 0x0002 /* close file system down */
90#define SYNC_DELWRI 0x0004 /* look at delayed writes */
91#define SYNC_WAIT 0x0008 /* wait for i/o to complete */
92#define SYNC_BDFLUSH 0x0010 /* BDFLUSH is calling -- don't block */
93#define SYNC_FSDATA 0x0020 /* flush fs data (e.g. superblocks) */
94#define SYNC_REFCACHE 0x0040 /* prune some of the nfs ref cache */
95#define SYNC_REMOUNT 0x0080 /* remount readonly, no dummy LRs */
Nathan Scottb83bd132006-06-09 16:48:30 +100096#define SYNC_QUIESCE 0x0100 /* quiesce fileystem for a snapshot */
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
Nathan Scott7d04a332006-06-09 14:58:38 +100098#define SHUTDOWN_META_IO_ERROR 0x0001 /* write attempt to metadata failed */
99#define SHUTDOWN_LOG_IO_ERROR 0x0002 /* write attempt to the log failed */
100#define SHUTDOWN_FORCE_UMOUNT 0x0004 /* shutdown from a forced unmount */
101#define SHUTDOWN_CORRUPT_INCORE 0x0008 /* corrupt in-memory data structures */
102#define SHUTDOWN_REMOTE_REQ 0x0010 /* shutdown came from remote cell */
103#define SHUTDOWN_DEVICE_REQ 0x0020 /* failed all paths to the device */
104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105typedef int (*vfs_mount_t)(bhv_desc_t *,
106 struct xfs_mount_args *, struct cred *);
107typedef int (*vfs_parseargs_t)(bhv_desc_t *, char *,
108 struct xfs_mount_args *, int);
109typedef int (*vfs_showargs_t)(bhv_desc_t *, struct seq_file *);
110typedef int (*vfs_unmount_t)(bhv_desc_t *, int, struct cred *);
111typedef int (*vfs_mntupdate_t)(bhv_desc_t *, int *,
112 struct xfs_mount_args *);
113typedef int (*vfs_root_t)(bhv_desc_t *, struct vnode **);
114typedef int (*vfs_statvfs_t)(bhv_desc_t *, xfs_statfs_t *, struct vnode *);
115typedef int (*vfs_sync_t)(bhv_desc_t *, int, struct cred *);
116typedef int (*vfs_vget_t)(bhv_desc_t *, struct vnode **, struct fid *);
117typedef int (*vfs_dmapiops_t)(bhv_desc_t *, caddr_t);
118typedef int (*vfs_quotactl_t)(bhv_desc_t *, int, int, caddr_t);
119typedef void (*vfs_init_vnode_t)(bhv_desc_t *,
120 struct vnode *, bhv_desc_t *, int);
121typedef void (*vfs_force_shutdown_t)(bhv_desc_t *, int, char *, int);
122typedef void (*vfs_freeze_t)(bhv_desc_t *);
123
Nathan Scottb83bd132006-06-09 16:48:30 +1000124typedef struct bhv_vfsops {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 bhv_position_t vf_position; /* behavior chain position */
126 vfs_mount_t vfs_mount; /* mount file system */
127 vfs_parseargs_t vfs_parseargs; /* parse mount options */
128 vfs_showargs_t vfs_showargs; /* unparse mount options */
129 vfs_unmount_t vfs_unmount; /* unmount file system */
130 vfs_mntupdate_t vfs_mntupdate; /* update file system options */
131 vfs_root_t vfs_root; /* get root vnode */
132 vfs_statvfs_t vfs_statvfs; /* file system statistics */
133 vfs_sync_t vfs_sync; /* flush files */
134 vfs_vget_t vfs_vget; /* get vnode from fid */
135 vfs_dmapiops_t vfs_dmapiops; /* data migration */
136 vfs_quotactl_t vfs_quotactl; /* disk quota */
137 vfs_init_vnode_t vfs_init_vnode; /* initialize a new vnode */
138 vfs_force_shutdown_t vfs_force_shutdown; /* crash and burn */
139 vfs_freeze_t vfs_freeze; /* freeze fs for snapshot */
Nathan Scottb83bd132006-06-09 16:48:30 +1000140} bhv_vfsops_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141
142/*
143 * VFS's. Operates on vfs structure pointers (starts at bhv head).
144 */
145#define VHEAD(v) ((v)->vfs_fbhv)
Nathan Scottb83bd132006-06-09 16:48:30 +1000146#define bhv_vfs_mount(v, ma,cr) vfs_mount(VHEAD(v), ma,cr)
147#define bhv_vfs_parseargs(v, o,ma,f) vfs_parseargs(VHEAD(v), o,ma,f)
148#define bhv_vfs_showargs(v, m) vfs_showargs(VHEAD(v), m)
149#define bhv_vfs_unmount(v, f,cr) vfs_unmount(VHEAD(v), f,cr)
150#define bhv_vfs_mntupdate(v, fl,args) vfs_mntupdate(VHEAD(v), fl,args)
151#define bhv_vfs_root(v, vpp) vfs_root(VHEAD(v), vpp)
152#define bhv_vfs_statvfs(v, sp,vp) vfs_statvfs(VHEAD(v), sp,vp)
153#define bhv_vfs_sync(v, flag,cr) vfs_sync(VHEAD(v), flag,cr)
154#define bhv_vfs_vget(v, vpp,fidp) vfs_vget(VHEAD(v), vpp,fidp)
155#define bhv_vfs_dmapiops(v, p) vfs_dmapiops(VHEAD(v), p)
156#define bhv_vfs_quotactl(v, c,id,p) vfs_quotactl(VHEAD(v), c,id,p)
157#define bhv_vfs_init_vnode(v, vp,b,ul) vfs_init_vnode(VHEAD(v), vp,b,ul)
158#define bhv_vfs_force_shutdown(v,u,f,l) vfs_force_shutdown(VHEAD(v), u,f,l)
159#define bhv_vfs_freeze(v) vfs_freeze(VHEAD(v))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160
161/*
162 * PVFS's. Operates on behavior descriptor pointers.
163 */
Nathan Scottb83bd132006-06-09 16:48:30 +1000164#define bhv_next_vfs_mount(b, ma,cr) vfs_mount(b, ma,cr)
165#define bhv_next_vfs_parseargs(b, o,ma,f) vfs_parseargs(b, o,ma,f)
166#define bhv_next_vfs_showargs(b, m) vfs_showargs(b, m)
167#define bhv_next_vfs_unmount(b, f,cr) vfs_unmount(b, f,cr)
168#define bhv_next_vfs_mntupdate(b, fl,args) vfs_mntupdate(b, fl, args)
169#define bhv_next_vfs_root(b, vpp) vfs_root(b, vpp)
170#define bhv_next_vfs_statvfs(b, sp,vp) vfs_statvfs(b, sp,vp)
171#define bhv_next_vfs_sync(b, flag,cr) vfs_sync(b, flag,cr)
172#define bhv_next_vfs_vget(b, vpp,fidp) vfs_vget(b, vpp,fidp)
173#define bhv_next_vfs_dmapiops(b, p) vfs_dmapiops(b, p)
174#define bhv_next_vfs_quotactl(b, c,id,p) vfs_quotactl(b, c,id,p)
175#define bhv_next_vfs_init_vnode(b, vp,b2,ul) vfs_init_vnode(b, vp,b2,ul)
176#define bhv_next_force_shutdown(b, fl,f,l) vfs_force_shutdown(b, fl,f,l)
177#define bhv_next_vfs_freeze(b) vfs_freeze(b)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178
179extern int vfs_mount(bhv_desc_t *, struct xfs_mount_args *, struct cred *);
180extern int vfs_parseargs(bhv_desc_t *, char *, struct xfs_mount_args *, int);
181extern int vfs_showargs(bhv_desc_t *, struct seq_file *);
182extern int vfs_unmount(bhv_desc_t *, int, struct cred *);
183extern int vfs_mntupdate(bhv_desc_t *, int *, struct xfs_mount_args *);
184extern int vfs_root(bhv_desc_t *, struct vnode **);
185extern int vfs_statvfs(bhv_desc_t *, xfs_statfs_t *, struct vnode *);
186extern int vfs_sync(bhv_desc_t *, int, struct cred *);
187extern int vfs_vget(bhv_desc_t *, struct vnode **, struct fid *);
188extern int vfs_dmapiops(bhv_desc_t *, caddr_t);
189extern int vfs_quotactl(bhv_desc_t *, int, int, caddr_t);
190extern void vfs_init_vnode(bhv_desc_t *, struct vnode *, bhv_desc_t *, int);
191extern void vfs_force_shutdown(bhv_desc_t *, int, char *, int);
192extern void vfs_freeze(bhv_desc_t *);
193
Nathan Scottb83bd132006-06-09 16:48:30 +1000194typedef struct bhv_module_vfsops {
195 struct bhv_vfsops bhv_common;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 void * bhv_custom;
Nathan Scottb83bd132006-06-09 16:48:30 +1000197} bhv_module_vfsops_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
Nathan Scottb83bd132006-06-09 16:48:30 +1000199#define vfs_bhv_lookup(v, id) (bhv_lookup_range(&(v)->vfs_bh, (id), (id)))
200#define vfs_bhv_custom(b) (((bhv_module_vfsops_t*)BHV_OPS(b))->bhv_custom)
201#define vfs_bhv_set_custom(b,o) ((b)->bhv_custom = (void *)(o))
202#define vfs_bhv_clr_custom(b) ((b)->bhv_custom = NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203
Nathan Scottb83bd132006-06-09 16:48:30 +1000204extern bhv_vfs_t *vfs_allocate(struct super_block *);
205extern bhv_vfs_t *vfs_from_sb(struct super_block *);
206extern void vfs_deallocate(bhv_vfs_t *);
207extern void vfs_insertbhv(bhv_vfs_t *, bhv_desc_t *, bhv_vfsops_t *, void *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208
Nathan Scottb83bd132006-06-09 16:48:30 +1000209extern void vfs_insertops(bhv_vfs_t *, bhv_module_vfsops_t *);
210
211extern void bhv_insert_all_vfsops(struct bhv_vfs *);
212extern void bhv_remove_all_vfsops(struct bhv_vfs *, int);
213extern void bhv_remove_vfsops(struct bhv_vfs *, int);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214
215#define fs_frozen(vfsp) ((vfsp)->vfs_super->s_frozen)
216#define fs_check_frozen(vfsp, level) \
217 vfs_check_frozen(vfsp->vfs_super, level);
218
219#endif /* __XFS_VFS_H__ */