xfs_vfs.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /*
  2. * Copyright (c) 2000-2006 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 bhv_vfs;
  23. struct inode;
  24. struct fid;
  25. struct cred;
  26. struct seq_file;
  27. struct super_block;
  28. struct xfs_inode;
  29. struct xfs_mount_args;
  30. typedef struct kstatfs bhv_statvfs_t;
  31. typedef struct bhv_vfs_sync_work {
  32. struct list_head w_list;
  33. struct bhv_vfs *w_vfs;
  34. void *w_data; /* syncer routine argument */
  35. void (*w_syncer)(struct bhv_vfs *, void *);
  36. } bhv_vfs_sync_work_t;
  37. typedef struct bhv_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. bhv_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. } bhv_vfs_t;
  50. #define bhvtovfs(bdp) ( (struct bhv_vfs *)BHV_VOBJ(bdp) )
  51. #define bhvtovfsops(bdp) ( (struct bhv_vfsops *)BHV_OPS(bdp) )
  52. #define VFS_BHVHEAD(vfs) ( &(vfs)->vfs_bh )
  53. #define VFS_REMOVEBHV(vfs, bdp) ( bhv_remove(VFS_BHVHEAD(vfs), bdp) )
  54. #define VFS_POSITION_BASE BHV_POSITION_BASE /* chain bottom */
  55. #define VFS_POSITION_TOP BHV_POSITION_TOP /* chain top */
  56. #define VFS_POSITION_INVALID BHV_POSITION_INVALID /* invalid pos. num */
  57. typedef enum {
  58. VFS_BHV_UNKNOWN, /* not specified */
  59. VFS_BHV_XFS, /* xfs */
  60. VFS_BHV_QM, /* quota manager */
  61. VFS_BHV_IO, /* IO path */
  62. VFS_BHV_END /* housekeeping end-of-range */
  63. } bhv_vfs_type_t;
  64. #define VFS_POSITION_XFS (BHV_POSITION_BASE)
  65. #define VFS_POSITION_QM (VFS_POSITION_BASE+20)
  66. #define VFS_POSITION_IO (VFS_POSITION_BASE+30)
  67. #define VFS_RDONLY 0x0001 /* read-only vfs */
  68. #define VFS_GRPID 0x0002 /* group-ID assigned from directory */
  69. #define VFS_DMI 0x0004 /* filesystem has the DMI enabled */
  70. /* ---- VFS_UMOUNT ---- 0x0008 -- unneeded, fixed via kthread APIs */
  71. #define VFS_32BITINODES 0x0010 /* do not use inums above 32 bits */
  72. #define VFS_END 0x0010 /* max flag */
  73. #define SYNC_ATTR 0x0001 /* sync attributes */
  74. #define SYNC_CLOSE 0x0002 /* close file system down */
  75. #define SYNC_DELWRI 0x0004 /* look at delayed writes */
  76. #define SYNC_WAIT 0x0008 /* wait for i/o to complete */
  77. #define SYNC_BDFLUSH 0x0010 /* BDFLUSH is calling -- don't block */
  78. #define SYNC_FSDATA 0x0020 /* flush fs data (e.g. superblocks) */
  79. #define SYNC_REFCACHE 0x0040 /* prune some of the nfs ref cache */
  80. #define SYNC_REMOUNT 0x0080 /* remount readonly, no dummy LRs */
  81. #define SYNC_IOWAIT 0x0100 /* wait for all I/O to complete */
  82. #define SYNC_SUPER 0x0200 /* flush superblock to disk */
  83. /*
  84. * When remounting a filesystem read-only or freezing the filesystem,
  85. * we have two phases to execute. This first phase is syncing the data
  86. * before we quiesce the fielsystem, and the second is flushing all the
  87. * inodes out after we've waited for all the transactions created by
  88. * the first phase to complete. The second phase uses SYNC_INODE_QUIESCE
  89. * to ensure that the inodes are written to their location on disk
  90. * rather than just existing in transactions in the log. This means
  91. * after a quiesce there is no log replay required to write the inodes
  92. * to disk (this is the main difference between a sync and a quiesce).
  93. */
  94. #define SYNC_DATA_QUIESCE (SYNC_DELWRI|SYNC_FSDATA|SYNC_WAIT|SYNC_IOWAIT)
  95. #define SYNC_INODE_QUIESCE (SYNC_REMOUNT|SYNC_ATTR|SYNC_WAIT)
  96. #define SHUTDOWN_META_IO_ERROR 0x0001 /* write attempt to metadata failed */
  97. #define SHUTDOWN_LOG_IO_ERROR 0x0002 /* write attempt to the log failed */
  98. #define SHUTDOWN_FORCE_UMOUNT 0x0004 /* shutdown from a forced unmount */
  99. #define SHUTDOWN_CORRUPT_INCORE 0x0008 /* corrupt in-memory data structures */
  100. #define SHUTDOWN_REMOTE_REQ 0x0010 /* shutdown came from remote cell */
  101. #define SHUTDOWN_DEVICE_REQ 0x0020 /* failed all paths to the device */
  102. typedef int (*vfs_mount_t)(bhv_desc_t *,
  103. struct xfs_mount_args *, struct cred *);
  104. typedef int (*vfs_parseargs_t)(bhv_desc_t *, char *,
  105. struct xfs_mount_args *, int);
  106. typedef int (*vfs_showargs_t)(bhv_desc_t *, struct seq_file *);
  107. typedef int (*vfs_unmount_t)(bhv_desc_t *, int, struct cred *);
  108. typedef int (*vfs_mntupdate_t)(bhv_desc_t *, int *,
  109. struct xfs_mount_args *);
  110. typedef int (*vfs_root_t)(bhv_desc_t *, struct inode **);
  111. typedef int (*vfs_statvfs_t)(bhv_desc_t *, bhv_statvfs_t *,
  112. struct inode *);
  113. typedef int (*vfs_sync_t)(bhv_desc_t *, int, struct cred *);
  114. typedef int (*vfs_vget_t)(bhv_desc_t *, struct inode **, struct fid *);
  115. typedef void (*vfs_init_vnode_t)(bhv_desc_t *,
  116. struct inode *, struct xfs_inode *, int);
  117. typedef void (*vfs_force_shutdown_t)(bhv_desc_t *, int, char *, int);
  118. typedef void (*vfs_freeze_t)(bhv_desc_t *);
  119. typedef struct bhv_vfsops {
  120. bhv_position_t vf_position; /* behavior chain position */
  121. vfs_mount_t vfs_mount; /* mount file system */
  122. vfs_parseargs_t vfs_parseargs; /* parse mount options */
  123. vfs_showargs_t vfs_showargs; /* unparse mount options */
  124. vfs_unmount_t vfs_unmount; /* unmount file system */
  125. vfs_mntupdate_t vfs_mntupdate; /* update file system options */
  126. vfs_root_t vfs_root; /* get root vnode */
  127. vfs_statvfs_t vfs_statvfs; /* file system statistics */
  128. vfs_sync_t vfs_sync; /* flush files */
  129. vfs_vget_t vfs_vget; /* get vnode from fid */
  130. vfs_init_vnode_t vfs_init_vnode; /* initialize a new vnode */
  131. vfs_force_shutdown_t vfs_force_shutdown; /* crash and burn */
  132. vfs_freeze_t vfs_freeze; /* freeze fs for snapshot */
  133. } bhv_vfsops_t;
  134. /*
  135. * Virtual filesystem operations, operating from head bhv.
  136. */
  137. #define VFSHEAD(v) ((v)->vfs_bh.bh_first)
  138. #define bhv_vfs_mount(v, ma,cr) vfs_mount(VFSHEAD(v), ma,cr)
  139. #define bhv_vfs_parseargs(v, o,ma,f) vfs_parseargs(VFSHEAD(v), o,ma,f)
  140. #define bhv_vfs_showargs(v, m) vfs_showargs(VFSHEAD(v), m)
  141. #define bhv_vfs_unmount(v, f,cr) vfs_unmount(VFSHEAD(v), f,cr)
  142. #define bhv_vfs_mntupdate(v, fl,args) vfs_mntupdate(VFSHEAD(v), fl,args)
  143. #define bhv_vfs_root(v, vpp) vfs_root(VFSHEAD(v), vpp)
  144. #define bhv_vfs_statvfs(v, sp,vp) vfs_statvfs(VFSHEAD(v), sp,vp)
  145. #define bhv_vfs_sync(v, flag,cr) vfs_sync(VFSHEAD(v), flag,cr)
  146. #define bhv_vfs_vget(v, vpp,fidp) vfs_vget(VFSHEAD(v), vpp,fidp)
  147. #define bhv_vfs_init_vnode(v, vp,b,ul) vfs_init_vnode(VFSHEAD(v), vp,b,ul)
  148. #define bhv_vfs_force_shutdown(v,u,f,l) vfs_force_shutdown(VFSHEAD(v), u,f,l)
  149. #define bhv_vfs_freeze(v) vfs_freeze(VFSHEAD(v))
  150. /*
  151. * Virtual filesystem operations, operating from next bhv.
  152. */
  153. #define bhv_next_vfs_mount(b, ma,cr) vfs_mount(b, ma,cr)
  154. #define bhv_next_vfs_parseargs(b, o,ma,f) vfs_parseargs(b, o,ma,f)
  155. #define bhv_next_vfs_showargs(b, m) vfs_showargs(b, m)
  156. #define bhv_next_vfs_unmount(b, f,cr) vfs_unmount(b, f,cr)
  157. #define bhv_next_vfs_mntupdate(b, fl,args) vfs_mntupdate(b, fl, args)
  158. #define bhv_next_vfs_root(b, vpp) vfs_root(b, vpp)
  159. #define bhv_next_vfs_statvfs(b, sp,vp) vfs_statvfs(b, sp,vp)
  160. #define bhv_next_vfs_sync(b, flag,cr) vfs_sync(b, flag,cr)
  161. #define bhv_next_vfs_vget(b, vpp,fidp) vfs_vget(b, vpp,fidp)
  162. #define bhv_next_vfs_init_vnode(b, vp,b2,ul) vfs_init_vnode(b, vp,b2,ul)
  163. #define bhv_next_force_shutdown(b, fl,f,l) vfs_force_shutdown(b, fl,f,l)
  164. #define bhv_next_vfs_freeze(b) vfs_freeze(b)
  165. extern int vfs_mount(bhv_desc_t *, struct xfs_mount_args *, struct cred *);
  166. extern int vfs_parseargs(bhv_desc_t *, char *, struct xfs_mount_args *, int);
  167. extern int vfs_showargs(bhv_desc_t *, struct seq_file *);
  168. extern int vfs_unmount(bhv_desc_t *, int, struct cred *);
  169. extern int vfs_mntupdate(bhv_desc_t *, int *, struct xfs_mount_args *);
  170. extern int vfs_root(bhv_desc_t *, struct inode **);
  171. extern int vfs_statvfs(bhv_desc_t *, bhv_statvfs_t *, struct inode *);
  172. extern int vfs_sync(bhv_desc_t *, int, struct cred *);
  173. extern int vfs_vget(bhv_desc_t *, struct inode **, struct fid *);
  174. extern void vfs_init_vnode(bhv_desc_t *, struct inode *, struct xfs_inode *, int);
  175. extern void vfs_force_shutdown(bhv_desc_t *, int, char *, int);
  176. extern void vfs_freeze(bhv_desc_t *);
  177. #define vfs_test_for_freeze(vfs) ((vfs)->vfs_super->s_frozen)
  178. #define vfs_wait_for_freeze(vfs,l) vfs_check_frozen((vfs)->vfs_super, (l))
  179. typedef struct bhv_module_vfsops {
  180. struct bhv_vfsops bhv_common;
  181. void * bhv_custom;
  182. } bhv_module_vfsops_t;
  183. #define vfs_bhv_lookup(v, id) (bhv_lookup_range(&(v)->vfs_bh, (id), (id)))
  184. #define vfs_bhv_custom(b) (((bhv_module_vfsops_t*)BHV_OPS(b))->bhv_custom)
  185. #define vfs_bhv_set_custom(b,o) ((b)->bhv_custom = (void *)(o))
  186. #define vfs_bhv_clr_custom(b) ((b)->bhv_custom = NULL)
  187. extern bhv_vfs_t *vfs_allocate(struct super_block *);
  188. extern bhv_vfs_t *vfs_from_sb(struct super_block *);
  189. extern void vfs_deallocate(bhv_vfs_t *);
  190. extern void vfs_insertbhv(bhv_vfs_t *, bhv_desc_t *, bhv_vfsops_t *, void *);
  191. extern void vfs_insertops(bhv_vfs_t *, bhv_module_vfsops_t *);
  192. extern void bhv_insert_all_vfsops(struct bhv_vfs *);
  193. extern void bhv_remove_all_vfsops(struct bhv_vfs *, int);
  194. extern void bhv_remove_vfsops(struct bhv_vfs *, int);
  195. #endif /* __XFS_VFS_H__ */