1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32#ifndef __XFS_VFS_H__
33#define __XFS_VFS_H__
34
35#include <linux/vfs.h>
36#include "xfs_fs.h"
37
38struct fid;
39struct vfs;
40struct cred;
41struct vnode;
42struct kstatfs;
43struct seq_file;
44struct super_block;
45struct xfs_mount_args;
46
47typedef struct kstatfs xfs_statfs_t;
48
49typedef struct vfs_sync_work {
50 struct list_head w_list;
51 struct vfs *w_vfs;
52 void *w_data;
53 void (*w_syncer)(struct vfs *, void *);
54} vfs_sync_work_t;
55
56typedef struct vfs {
57 u_int vfs_flag;
58 xfs_fsid_t vfs_fsid;
59 xfs_fsid_t *vfs_altfsid;
60 bhv_head_t vfs_bh;
61 struct super_block *vfs_super;
62 struct task_struct *vfs_sync_task;
63 vfs_sync_work_t vfs_sync_work;
64 struct list_head vfs_sync_list;
65 spinlock_t vfs_sync_lock;
66 int vfs_sync_seq;
67 wait_queue_head_t vfs_wait_single_sync_task;
68 wait_queue_head_t vfs_wait_sync_task;
69} vfs_t;
70
71#define vfs_fbhv vfs_bh.bh_first
72
73#define bhvtovfs(bdp) ( (struct vfs *)BHV_VOBJ(bdp) )
74#define bhvtovfsops(bdp) ( (struct vfsops *)BHV_OPS(bdp) )
75#define VFS_BHVHEAD(vfs) ( &(vfs)->vfs_bh )
76#define VFS_REMOVEBHV(vfs, bdp) ( bhv_remove(VFS_BHVHEAD(vfs), bdp) )
77
78#define VFS_POSITION_BASE BHV_POSITION_BASE
79#define VFS_POSITION_TOP BHV_POSITION_TOP
80#define VFS_POSITION_INVALID BHV_POSITION_INVALID
81
82typedef enum {
83 VFS_BHV_UNKNOWN,
84 VFS_BHV_XFS,
85 VFS_BHV_DM,
86 VFS_BHV_QM,
87 VFS_BHV_IO,
88 VFS_BHV_END
89} vfs_bhv_t;
90
91#define VFS_POSITION_XFS (BHV_POSITION_BASE)
92#define VFS_POSITION_DM (VFS_POSITION_BASE+10)
93#define VFS_POSITION_QM (VFS_POSITION_BASE+20)
94#define VFS_POSITION_IO (VFS_POSITION_BASE+30)
95
96#define VFS_RDONLY 0x0001
97#define VFS_GRPID 0x0002
98#define VFS_DMI 0x0004
99#define VFS_UMOUNT 0x0008
100#define VFS_END 0x0008
101
102#define SYNC_ATTR 0x0001
103#define SYNC_CLOSE 0x0002
104#define SYNC_DELWRI 0x0004
105#define SYNC_WAIT 0x0008
106#define SYNC_BDFLUSH 0x0010
107#define SYNC_FSDATA 0x0020
108#define SYNC_REFCACHE 0x0040
109#define SYNC_REMOUNT 0x0080
110
111typedef int (*vfs_mount_t)(bhv_desc_t *,
112 struct xfs_mount_args *, struct cred *);
113typedef int (*vfs_parseargs_t)(bhv_desc_t *, char *,
114 struct xfs_mount_args *, int);
115typedef int (*vfs_showargs_t)(bhv_desc_t *, struct seq_file *);
116typedef int (*vfs_unmount_t)(bhv_desc_t *, int, struct cred *);
117typedef int (*vfs_mntupdate_t)(bhv_desc_t *, int *,
118 struct xfs_mount_args *);
119typedef int (*vfs_root_t)(bhv_desc_t *, struct vnode **);
120typedef int (*vfs_statvfs_t)(bhv_desc_t *, xfs_statfs_t *, struct vnode *);
121typedef int (*vfs_sync_t)(bhv_desc_t *, int, struct cred *);
122typedef int (*vfs_vget_t)(bhv_desc_t *, struct vnode **, struct fid *);
123typedef int (*vfs_dmapiops_t)(bhv_desc_t *, caddr_t);
124typedef int (*vfs_quotactl_t)(bhv_desc_t *, int, int, caddr_t);
125typedef void (*vfs_init_vnode_t)(bhv_desc_t *,
126 struct vnode *, bhv_desc_t *, int);
127typedef void (*vfs_force_shutdown_t)(bhv_desc_t *, int, char *, int);
128typedef void (*vfs_freeze_t)(bhv_desc_t *);
129
130typedef struct vfsops {
131 bhv_position_t vf_position;
132 vfs_mount_t vfs_mount;
133 vfs_parseargs_t vfs_parseargs;
134 vfs_showargs_t vfs_showargs;
135 vfs_unmount_t vfs_unmount;
136 vfs_mntupdate_t vfs_mntupdate;
137 vfs_root_t vfs_root;
138 vfs_statvfs_t vfs_statvfs;
139 vfs_sync_t vfs_sync;
140 vfs_vget_t vfs_vget;
141 vfs_dmapiops_t vfs_dmapiops;
142 vfs_quotactl_t vfs_quotactl;
143 vfs_init_vnode_t vfs_init_vnode;
144 vfs_force_shutdown_t vfs_force_shutdown;
145 vfs_freeze_t vfs_freeze;
146} vfsops_t;
147
148
149
150
151#define VHEAD(v) ((v)->vfs_fbhv)
152#define VFS_MOUNT(v, ma,cr, rv) ((rv) = vfs_mount(VHEAD(v), ma,cr))
153#define VFS_PARSEARGS(v, o,ma,f, rv) ((rv) = vfs_parseargs(VHEAD(v), o,ma,f))
154#define VFS_SHOWARGS(v, m, rv) ((rv) = vfs_showargs(VHEAD(v), m))
155#define VFS_UNMOUNT(v, f, cr, rv) ((rv) = vfs_unmount(VHEAD(v), f,cr))
156#define VFS_MNTUPDATE(v, fl, args, rv) ((rv) = vfs_mntupdate(VHEAD(v), fl, args))
157#define VFS_ROOT(v, vpp, rv) ((rv) = vfs_root(VHEAD(v), vpp))
158#define VFS_STATVFS(v, sp,vp, rv) ((rv) = vfs_statvfs(VHEAD(v), sp,vp))
159#define VFS_SYNC(v, flag,cr, rv) ((rv) = vfs_sync(VHEAD(v), flag,cr))
160#define VFS_VGET(v, vpp,fidp, rv) ((rv) = vfs_vget(VHEAD(v), vpp,fidp))
161#define VFS_DMAPIOPS(v, p, rv) ((rv) = vfs_dmapiops(VHEAD(v), p))
162#define VFS_QUOTACTL(v, c,id,p, rv) ((rv) = vfs_quotactl(VHEAD(v), c,id,p))
163#define VFS_INIT_VNODE(v, vp,b,ul) ( vfs_init_vnode(VHEAD(v), vp,b,ul) )
164#define VFS_FORCE_SHUTDOWN(v, fl,f,l) ( vfs_force_shutdown(VHEAD(v), fl,f,l) )
165#define VFS_FREEZE(v) ( vfs_freeze(VHEAD(v)) )
166
167
168
169
170#define PVFS_MOUNT(b, ma,cr, rv) ((rv) = vfs_mount(b, ma,cr))
171#define PVFS_PARSEARGS(b, o,ma,f, rv) ((rv) = vfs_parseargs(b, o,ma,f))
172#define PVFS_SHOWARGS(b, m, rv) ((rv) = vfs_showargs(b, m))
173#define PVFS_UNMOUNT(b, f,cr, rv) ((rv) = vfs_unmount(b, f,cr))
174#define PVFS_MNTUPDATE(b, fl, args, rv) ((rv) = vfs_mntupdate(b, fl, args))
175#define PVFS_ROOT(b, vpp, rv) ((rv) = vfs_root(b, vpp))
176#define PVFS_STATVFS(b, sp,vp, rv) ((rv) = vfs_statvfs(b, sp,vp))
177#define PVFS_SYNC(b, flag,cr, rv) ((rv) = vfs_sync(b, flag,cr))
178#define PVFS_VGET(b, vpp,fidp, rv) ((rv) = vfs_vget(b, vpp,fidp))
179#define PVFS_DMAPIOPS(b, p, rv) ((rv) = vfs_dmapiops(b, p))
180#define PVFS_QUOTACTL(b, c,id,p, rv) ((rv) = vfs_quotactl(b, c,id,p))
181#define PVFS_INIT_VNODE(b, vp,b2,ul) ( vfs_init_vnode(b, vp,b2,ul) )
182#define PVFS_FORCE_SHUTDOWN(b, fl,f,l) ( vfs_force_shutdown(b, fl,f,l) )
183#define PVFS_FREEZE(b) ( vfs_freeze(b) )
184
185extern int vfs_mount(bhv_desc_t *, struct xfs_mount_args *, struct cred *);
186extern int vfs_parseargs(bhv_desc_t *, char *, struct xfs_mount_args *, int);
187extern int vfs_showargs(bhv_desc_t *, struct seq_file *);
188extern int vfs_unmount(bhv_desc_t *, int, struct cred *);
189extern int vfs_mntupdate(bhv_desc_t *, int *, struct xfs_mount_args *);
190extern int vfs_root(bhv_desc_t *, struct vnode **);
191extern int vfs_statvfs(bhv_desc_t *, xfs_statfs_t *, struct vnode *);
192extern int vfs_sync(bhv_desc_t *, int, struct cred *);
193extern int vfs_vget(bhv_desc_t *, struct vnode **, struct fid *);
194extern int vfs_dmapiops(bhv_desc_t *, caddr_t);
195extern int vfs_quotactl(bhv_desc_t *, int, int, caddr_t);
196extern void vfs_init_vnode(bhv_desc_t *, struct vnode *, bhv_desc_t *, int);
197extern void vfs_force_shutdown(bhv_desc_t *, int, char *, int);
198extern void vfs_freeze(bhv_desc_t *);
199
200typedef struct bhv_vfsops {
201 struct vfsops bhv_common;
202 void * bhv_custom;
203} bhv_vfsops_t;
204
205#define vfs_bhv_lookup(v, id) ( bhv_lookup_range(&(v)->vfs_bh, (id), (id)) )
206#define vfs_bhv_custom(b) ( ((bhv_vfsops_t *)BHV_OPS(b))->bhv_custom )
207#define vfs_bhv_set_custom(b,o) ( (b)->bhv_custom = (void *)(o))
208#define vfs_bhv_clr_custom(b) ( (b)->bhv_custom = NULL )
209
210extern vfs_t *vfs_allocate(void);
211extern void vfs_deallocate(vfs_t *);
212extern void vfs_insertops(vfs_t *, bhv_vfsops_t *);
213extern void vfs_insertbhv(vfs_t *, bhv_desc_t *, vfsops_t *, void *);
214
215extern void bhv_insert_all_vfsops(struct vfs *);
216extern void bhv_remove_all_vfsops(struct vfs *, int);
217extern void bhv_remove_vfsops(struct vfs *, int);
218
219#define fs_frozen(vfsp) ((vfsp)->vfs_super->s_frozen)
220#define fs_check_frozen(vfsp, level) \
221 vfs_check_frozen(vfsp->vfs_super, level);
222
223#endif
224