xfs_vfs.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /*
  2. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * 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.
  13. *
  14. * 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
  17. */
  18. #ifndef __XFS_VFS_H__
  19. #define __XFS_VFS_H__
  20. #include <linux/vfs.h>
  21. #include "xfs_fs.h"
  22. struct fid;
  23. struct vfs;
  24. struct cred;
  25. struct vnode;
  26. struct kstatfs;
  27. struct seq_file;
  28. struct super_block;
  29. struct xfs_mount_args;
  30. typedef struct kstatfs xfs_statfs_t;
  31. typedef struct vfs_sync_work {
  32. struct list_head w_list;
  33. struct vfs *w_vfs;
  34. void *w_data; /* syncer routine argument */
  35. void (*w_syncer)(struct vfs *, void *);
  36. } vfs_sync_work_t;
  37. typedef struct vfs {
  38. u_int vfs_flag; /* flags */
  39. xfs_fsid_t vfs_fsid; /* file system ID */
  40. xfs_fsid_t *vfs_altfsid; /* An ID fixed for life of FS */
  41. bhv_head_t vfs_bh; /* head of vfs behavior chain */
  42. struct super_block *vfs_super; /* generic superblock pointer */
  43. struct task_struct *vfs_sync_task; /* generalised sync thread */
  44. vfs_sync_work_t vfs_sync_work; /* work item for VFS_SYNC */
  45. struct list_head vfs_sync_list; /* sync thread work item list */
  46. spinlock_t vfs_sync_lock; /* work item list lock */
  47. int vfs_sync_seq; /* sync thread generation no. */
  48. wait_queue_head_t vfs_wait_single_sync_task;
  49. } vfs_t;
  50. #define vfs_fbhv vfs_bh.bh_first /* 1st on vfs behavior chain */
  51. #define bhvtovfs(bdp) ( (struct vfs *)BHV_VOBJ(bdp) )
  52. #define bhvtovfsops(bdp) ( (struct vfsops *)BHV_OPS(bdp) )
  53. #define VFS_BHVHEAD(vfs) ( &(vfs)->vfs_bh )
  54. #define VFS_REMOVEBHV(vfs, bdp) ( bhv_remove(VFS_BHVHEAD(vfs), bdp) )
  55. #define VFS_POSITION_BASE BHV_POSITION_BASE /* chain bottom */
  56. #define VFS_POSITION_TOP BHV_POSITION_TOP /* chain top */
  57. #define VFS_POSITION_INVALID BHV_POSITION_INVALID /* invalid pos. num */
  58. typedef enum {
  59. VFS_BHV_UNKNOWN, /* not specified */
  60. VFS_BHV_XFS, /* xfs */
  61. VFS_BHV_DM, /* data migration */
  62. VFS_BHV_QM, /* quota manager */
  63. VFS_BHV_IO, /* IO path */
  64. VFS_BHV_END /* housekeeping end-of-range */
  65. } vfs_bhv_t;
  66. #define VFS_POSITION_XFS (BHV_POSITION_BASE)
  67. #define VFS_POSITION_DM (VFS_POSITION_BASE+10)
  68. #define VFS_POSITION_QM (VFS_POSITION_BASE+20)
  69. #define VFS_POSITION_IO (VFS_POSITION_BASE+30)
  70. #define VFS_RDONLY 0x0001 /* read-only vfs */
  71. #define VFS_GRPID 0x0002 /* group-ID assigned from directory */
  72. #define VFS_DMI 0x0004 /* filesystem has the DMI enabled */
  73. #define VFS_32BITINODES 0x0008 /* do not use inums above 32 bits */
  74. #define VFS_END 0x0008 /* max flag */
  75. #define SYNC_ATTR 0x0001 /* sync attributes */
  76. #define SYNC_CLOSE 0x0002 /* close file system down */
  77. #define SYNC_DELWRI 0x0004 /* look at delayed writes */
  78. #define SYNC_WAIT 0x0008 /* wait for i/o to complete */
  79. #define SYNC_BDFLUSH 0x0010 /* BDFLUSH is calling -- don't block */
  80. #define SYNC_FSDATA 0x0020 /* flush fs data (e.g. superblocks) */
  81. #define SYNC_REFCACHE 0x0040 /* prune some of the nfs ref cache */
  82. #define SYNC_REMOUNT 0x0080 /* remount readonly, no dummy LRs */
  83. #define SYNC_QUIESCE 0x0100 /* quiesce filesystem for a snapshot */
  84. #define SHUTDOWN_META_IO_ERROR 0x0001 /* write attempt to metadata failed */
  85. #define SHUTDOWN_LOG_IO_ERROR 0x0002 /* write attempt to the log failed */
  86. #define SHUTDOWN_FORCE_UMOUNT 0x0004 /* shutdown from a forced unmount */
  87. #define SHUTDOWN_CORRUPT_INCORE 0x0008 /* corrupt in-memory data structures */
  88. #define SHUTDOWN_REMOTE_REQ 0x0010 /* shutdown came from remote cell */
  89. #define SHUTDOWN_DEVICE_REQ 0x0020 /* failed all paths to the device */
  90. typedef int (*vfs_mount_t)(bhv_desc_t *,
  91. struct xfs_mount_args *, struct cred *);
  92. typedef int (*vfs_parseargs_t)(bhv_desc_t *, char *,
  93. struct xfs_mount_args *, int);
  94. typedef int (*vfs_showargs_t)(bhv_desc_t *, struct seq_file *);
  95. typedef int (*vfs_unmount_t)(bhv_desc_t *, int, struct cred *);
  96. typedef int (*vfs_mntupdate_t)(bhv_desc_t *, int *,
  97. struct xfs_mount_args *);
  98. typedef int (*vfs_root_t)(bhv_desc_t *, struct vnode **);
  99. typedef int (*vfs_statvfs_t)(bhv_desc_t *, xfs_statfs_t *, struct vnode *);
  100. typedef int (*vfs_sync_t)(bhv_desc_t *, int, struct cred *);
  101. typedef int (*vfs_vget_t)(bhv_desc_t *, struct vnode **, struct fid *);
  102. typedef int (*vfs_dmapiops_t)(bhv_desc_t *, caddr_t);
  103. typedef int (*vfs_quotactl_t)(bhv_desc_t *, int, int, caddr_t);
  104. typedef void (*vfs_init_vnode_t)(bhv_desc_t *,
  105. struct vnode *, bhv_desc_t *, int);
  106. typedef void (*vfs_force_shutdown_t)(bhv_desc_t *, int, char *, int);
  107. typedef void (*vfs_freeze_t)(bhv_desc_t *);
  108. typedef struct vfsops {
  109. bhv_position_t vf_position; /* behavior chain position */
  110. vfs_mount_t vfs_mount; /* mount file system */
  111. vfs_parseargs_t vfs_parseargs; /* parse mount options */
  112. vfs_showargs_t vfs_showargs; /* unparse mount options */
  113. vfs_unmount_t vfs_unmount; /* unmount file system */
  114. vfs_mntupdate_t vfs_mntupdate; /* update file system options */
  115. vfs_root_t vfs_root; /* get root vnode */
  116. vfs_statvfs_t vfs_statvfs; /* file system statistics */
  117. vfs_sync_t vfs_sync; /* flush files */
  118. vfs_vget_t vfs_vget; /* get vnode from fid */
  119. vfs_dmapiops_t vfs_dmapiops; /* data migration */
  120. vfs_quotactl_t vfs_quotactl; /* disk quota */
  121. vfs_init_vnode_t vfs_init_vnode; /* initialize a new vnode */
  122. vfs_force_shutdown_t vfs_force_shutdown; /* crash and burn */
  123. vfs_freeze_t vfs_freeze; /* freeze fs for snapshot */
  124. } vfsops_t;
  125. /*
  126. * VFS's. Operates on vfs structure pointers (starts at bhv head).
  127. */
  128. #define VHEAD(v) ((v)->vfs_fbhv)
  129. #define VFS_MOUNT(v, ma,cr, rv) ((rv) = vfs_mount(VHEAD(v), ma,cr))
  130. #define VFS_PARSEARGS(v, o,ma,f, rv) ((rv) = vfs_parseargs(VHEAD(v), o,ma,f))
  131. #define VFS_SHOWARGS(v, m, rv) ((rv) = vfs_showargs(VHEAD(v), m))
  132. #define VFS_UNMOUNT(v, f, cr, rv) ((rv) = vfs_unmount(VHEAD(v), f,cr))
  133. #define VFS_MNTUPDATE(v, fl, args, rv) ((rv) = vfs_mntupdate(VHEAD(v), fl, args))
  134. #define VFS_ROOT(v, vpp, rv) ((rv) = vfs_root(VHEAD(v), vpp))
  135. #define VFS_STATVFS(v, sp,vp, rv) ((rv) = vfs_statvfs(VHEAD(v), sp,vp))
  136. #define VFS_SYNC(v, flag,cr, rv) ((rv) = vfs_sync(VHEAD(v), flag,cr))
  137. #define VFS_VGET(v, vpp,fidp, rv) ((rv) = vfs_vget(VHEAD(v), vpp,fidp))
  138. #define VFS_DMAPIOPS(v, p, rv) ((rv) = vfs_dmapiops(VHEAD(v), p))
  139. #define VFS_QUOTACTL(v, c,id,p, rv) ((rv) = vfs_quotactl(VHEAD(v), c,id,p))
  140. #define VFS_INIT_VNODE(v, vp,b,ul) ( vfs_init_vnode(VHEAD(v), vp,b,ul) )
  141. #define VFS_FORCE_SHUTDOWN(v, fl,f,l) ( vfs_force_shutdown(VHEAD(v), fl,f,l) )
  142. #define VFS_FREEZE(v) ( vfs_freeze(VHEAD(v)) )
  143. /*
  144. * PVFS's. Operates on behavior descriptor pointers.
  145. */
  146. #define PVFS_MOUNT(b, ma,cr, rv) ((rv) = vfs_mount(b, ma,cr))
  147. #define PVFS_PARSEARGS(b, o,ma,f, rv) ((rv) = vfs_parseargs(b, o,ma,f))
  148. #define PVFS_SHOWARGS(b, m, rv) ((rv) = vfs_showargs(b, m))
  149. #define PVFS_UNMOUNT(b, f,cr, rv) ((rv) = vfs_unmount(b, f,cr))
  150. #define PVFS_MNTUPDATE(b, fl, args, rv) ((rv) = vfs_mntupdate(b, fl, args))
  151. #define PVFS_ROOT(b, vpp, rv) ((rv) = vfs_root(b, vpp))
  152. #define PVFS_STATVFS(b, sp,vp, rv) ((rv) = vfs_statvfs(b, sp,vp))
  153. #define PVFS_SYNC(b, flag,cr, rv) ((rv) = vfs_sync(b, flag,cr))
  154. #define PVFS_VGET(b, vpp,fidp, rv) ((rv) = vfs_vget(b, vpp,fidp))
  155. #define PVFS_DMAPIOPS(b, p, rv) ((rv) = vfs_dmapiops(b, p))
  156. #define PVFS_QUOTACTL(b, c,id,p, rv) ((rv) = vfs_quotactl(b, c,id,p))
  157. #define PVFS_INIT_VNODE(b, vp,b2,ul) ( vfs_init_vnode(b, vp,b2,ul) )
  158. #define PVFS_FORCE_SHUTDOWN(b, fl,f,l) ( vfs_force_shutdown(b, fl,f,l) )
  159. #define PVFS_FREEZE(b) ( vfs_freeze(b) )
  160. extern int vfs_mount(bhv_desc_t *, struct xfs_mount_args *, struct cred *);
  161. extern int vfs_parseargs(bhv_desc_t *, char *, struct xfs_mount_args *, int);
  162. extern int vfs_showargs(bhv_desc_t *, struct seq_file *);
  163. extern int vfs_unmount(bhv_desc_t *, int, struct cred *);
  164. extern int vfs_mntupdate(bhv_desc_t *, int *, struct xfs_mount_args *);
  165. extern int vfs_root(bhv_desc_t *, struct vnode **);
  166. extern int vfs_statvfs(bhv_desc_t *, xfs_statfs_t *, struct vnode *);
  167. extern int vfs_sync(bhv_desc_t *, int, struct cred *);
  168. extern int vfs_vget(bhv_desc_t *, struct vnode **, struct fid *);
  169. extern int vfs_dmapiops(bhv_desc_t *, caddr_t);
  170. extern int vfs_quotactl(bhv_desc_t *, int, int, caddr_t);
  171. extern void vfs_init_vnode(bhv_desc_t *, struct vnode *, bhv_desc_t *, int);
  172. extern void vfs_force_shutdown(bhv_desc_t *, int, char *, int);
  173. extern void vfs_freeze(bhv_desc_t *);
  174. typedef struct bhv_vfsops {
  175. struct vfsops bhv_common;
  176. void * bhv_custom;
  177. } bhv_vfsops_t;
  178. #define vfs_bhv_lookup(v, id) ( bhv_lookup_range(&(v)->vfs_bh, (id), (id)) )
  179. #define vfs_bhv_custom(b) ( ((bhv_vfsops_t *)BHV_OPS(b))->bhv_custom )
  180. #define vfs_bhv_set_custom(b,o) ( (b)->bhv_custom = (void *)(o))
  181. #define vfs_bhv_clr_custom(b) ( (b)->bhv_custom = NULL )
  182. extern vfs_t *vfs_allocate(struct super_block *);
  183. extern vfs_t *vfs_from_sb(struct super_block *);
  184. extern void vfs_deallocate(vfs_t *);
  185. extern void vfs_insertops(vfs_t *, bhv_vfsops_t *);
  186. extern void vfs_insertbhv(vfs_t *, bhv_desc_t *, vfsops_t *, void *);
  187. extern void bhv_insert_all_vfsops(struct vfs *);
  188. extern void bhv_remove_all_vfsops(struct vfs *, int);
  189. extern void bhv_remove_vfsops(struct vfs *, int);
  190. #define fs_frozen(vfsp) ((vfsp)->vfs_super->s_frozen)
  191. #define fs_check_frozen(vfsp, level) \
  192. vfs_check_frozen(vfsp->vfs_super, level);
  193. #endif /* __XFS_VFS_H__ */