xfs_mount.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. /*
  2. * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of version 2 of the GNU General Public License as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it would be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. *
  12. * Further, this software is distributed without any warranty that it is
  13. * free of the rightful claim of any third person regarding infringement
  14. * or the like. Any license provided herein, whether implied or
  15. * otherwise, applies only to this software file. Patent licenses, if
  16. * any, provided herein do not apply to combinations of this program with
  17. * other software, or any other product whatsoever.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write the Free Software Foundation, Inc., 59
  21. * Temple Place - Suite 330, Boston MA 02111-1307, USA.
  22. *
  23. * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
  24. * Mountain View, CA 94043, or:
  25. *
  26. * http://www.sgi.com
  27. *
  28. * For further information regarding this notice, see:
  29. *
  30. * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
  31. */
  32. #ifndef __XFS_MOUNT_H__
  33. #define __XFS_MOUNT_H__
  34. typedef struct xfs_trans_reservations {
  35. uint tr_write; /* extent alloc trans */
  36. uint tr_itruncate; /* truncate trans */
  37. uint tr_rename; /* rename trans */
  38. uint tr_link; /* link trans */
  39. uint tr_remove; /* unlink trans */
  40. uint tr_symlink; /* symlink trans */
  41. uint tr_create; /* create trans */
  42. uint tr_mkdir; /* mkdir trans */
  43. uint tr_ifree; /* inode free trans */
  44. uint tr_ichange; /* inode update trans */
  45. uint tr_growdata; /* fs data section grow trans */
  46. uint tr_swrite; /* sync write inode trans */
  47. uint tr_addafork; /* cvt inode to attributed trans */
  48. uint tr_writeid; /* write setuid/setgid file */
  49. uint tr_attrinval; /* attr fork buffer invalidation */
  50. uint tr_attrset; /* set/create an attribute */
  51. uint tr_attrrm; /* remove an attribute */
  52. uint tr_clearagi; /* clear bad agi unlinked ino bucket */
  53. uint tr_growrtalloc; /* grow realtime allocations */
  54. uint tr_growrtzero; /* grow realtime zeroing */
  55. uint tr_growrtfree; /* grow realtime freeing */
  56. } xfs_trans_reservations_t;
  57. #ifndef __KERNEL__
  58. /*
  59. * Moved here from xfs_ag.h to avoid reordering header files
  60. */
  61. #define XFS_DADDR_TO_AGNO(mp,d) \
  62. ((xfs_agnumber_t)(XFS_BB_TO_FSBT(mp, d) / (mp)->m_sb.sb_agblocks))
  63. #define XFS_DADDR_TO_AGBNO(mp,d) \
  64. ((xfs_agblock_t)(XFS_BB_TO_FSBT(mp, d) % (mp)->m_sb.sb_agblocks))
  65. #else
  66. struct cred;
  67. struct log;
  68. struct vfs;
  69. struct vnode;
  70. struct xfs_mount_args;
  71. struct xfs_ihash;
  72. struct xfs_chash;
  73. struct xfs_inode;
  74. struct xfs_perag;
  75. struct xfs_iocore;
  76. struct xfs_bmbt_irec;
  77. struct xfs_bmap_free;
  78. #define AIL_LOCK_T lock_t
  79. #define AIL_LOCKINIT(x,y) spinlock_init(x,y)
  80. #define AIL_LOCK_DESTROY(x) spinlock_destroy(x)
  81. #define AIL_LOCK(mp,s) s=mutex_spinlock(&(mp)->m_ail_lock)
  82. #define AIL_UNLOCK(mp,s) mutex_spinunlock(&(mp)->m_ail_lock, s)
  83. /*
  84. * Prototypes and functions for the Data Migration subsystem.
  85. */
  86. typedef int (*xfs_send_data_t)(int, struct vnode *,
  87. xfs_off_t, size_t, int, vrwlock_t *);
  88. typedef int (*xfs_send_mmap_t)(struct vm_area_struct *, uint);
  89. typedef int (*xfs_send_destroy_t)(struct vnode *, dm_right_t);
  90. typedef int (*xfs_send_namesp_t)(dm_eventtype_t, struct vfs *,
  91. struct vnode *,
  92. dm_right_t, struct vnode *, dm_right_t,
  93. char *, char *, mode_t, int, int);
  94. typedef void (*xfs_send_unmount_t)(struct vfs *, struct vnode *,
  95. dm_right_t, mode_t, int, int);
  96. typedef struct xfs_dmops {
  97. xfs_send_data_t xfs_send_data;
  98. xfs_send_mmap_t xfs_send_mmap;
  99. xfs_send_destroy_t xfs_send_destroy;
  100. xfs_send_namesp_t xfs_send_namesp;
  101. xfs_send_unmount_t xfs_send_unmount;
  102. } xfs_dmops_t;
  103. #define XFS_SEND_DATA(mp, ev,vp,off,len,fl,lock) \
  104. (*(mp)->m_dm_ops.xfs_send_data)(ev,vp,off,len,fl,lock)
  105. #define XFS_SEND_MMAP(mp, vma,fl) \
  106. (*(mp)->m_dm_ops.xfs_send_mmap)(vma,fl)
  107. #define XFS_SEND_DESTROY(mp, vp,right) \
  108. (*(mp)->m_dm_ops.xfs_send_destroy)(vp,right)
  109. #define XFS_SEND_NAMESP(mp, ev,b1,r1,b2,r2,n1,n2,mode,rval,fl) \
  110. (*(mp)->m_dm_ops.xfs_send_namesp)(ev,NULL,b1,r1,b2,r2,n1,n2,mode,rval,fl)
  111. #define XFS_SEND_PREUNMOUNT(mp, vfs,b1,r1,b2,r2,n1,n2,mode,rval,fl) \
  112. (*(mp)->m_dm_ops.xfs_send_namesp)(DM_EVENT_PREUNMOUNT,vfs,b1,r1,b2,r2,n1,n2,mode,rval,fl)
  113. #define XFS_SEND_UNMOUNT(mp, vfsp,vp,right,mode,rval,fl) \
  114. (*(mp)->m_dm_ops.xfs_send_unmount)(vfsp,vp,right,mode,rval,fl)
  115. /*
  116. * Prototypes and functions for the Quota Management subsystem.
  117. */
  118. struct xfs_dquot;
  119. struct xfs_dqtrxops;
  120. struct xfs_quotainfo;
  121. typedef int (*xfs_qminit_t)(struct xfs_mount *, uint *, uint *);
  122. typedef int (*xfs_qmmount_t)(struct xfs_mount *, uint, uint, int);
  123. typedef int (*xfs_qmunmount_t)(struct xfs_mount *);
  124. typedef void (*xfs_qmdone_t)(struct xfs_mount *);
  125. typedef void (*xfs_dqrele_t)(struct xfs_dquot *);
  126. typedef int (*xfs_dqattach_t)(struct xfs_inode *, uint);
  127. typedef void (*xfs_dqdetach_t)(struct xfs_inode *);
  128. typedef int (*xfs_dqpurgeall_t)(struct xfs_mount *, uint);
  129. typedef int (*xfs_dqvopalloc_t)(struct xfs_mount *,
  130. struct xfs_inode *, uid_t, gid_t, prid_t, uint,
  131. struct xfs_dquot **, struct xfs_dquot **);
  132. typedef void (*xfs_dqvopcreate_t)(struct xfs_trans *, struct xfs_inode *,
  133. struct xfs_dquot *, struct xfs_dquot *);
  134. typedef int (*xfs_dqvoprename_t)(struct xfs_inode **);
  135. typedef struct xfs_dquot * (*xfs_dqvopchown_t)(
  136. struct xfs_trans *, struct xfs_inode *,
  137. struct xfs_dquot **, struct xfs_dquot *);
  138. typedef int (*xfs_dqvopchownresv_t)(struct xfs_trans *, struct xfs_inode *,
  139. struct xfs_dquot *, struct xfs_dquot *, uint);
  140. typedef struct xfs_qmops {
  141. xfs_qminit_t xfs_qminit;
  142. xfs_qmdone_t xfs_qmdone;
  143. xfs_qmmount_t xfs_qmmount;
  144. xfs_qmunmount_t xfs_qmunmount;
  145. xfs_dqrele_t xfs_dqrele;
  146. xfs_dqattach_t xfs_dqattach;
  147. xfs_dqdetach_t xfs_dqdetach;
  148. xfs_dqpurgeall_t xfs_dqpurgeall;
  149. xfs_dqvopalloc_t xfs_dqvopalloc;
  150. xfs_dqvopcreate_t xfs_dqvopcreate;
  151. xfs_dqvoprename_t xfs_dqvoprename;
  152. xfs_dqvopchown_t xfs_dqvopchown;
  153. xfs_dqvopchownresv_t xfs_dqvopchownresv;
  154. struct xfs_dqtrxops *xfs_dqtrxops;
  155. } xfs_qmops_t;
  156. #define XFS_QM_INIT(mp, mnt, fl) \
  157. (*(mp)->m_qm_ops.xfs_qminit)(mp, mnt, fl)
  158. #define XFS_QM_MOUNT(mp, mnt, fl, mfsi_flags) \
  159. (*(mp)->m_qm_ops.xfs_qmmount)(mp, mnt, fl, mfsi_flags)
  160. #define XFS_QM_UNMOUNT(mp) \
  161. (*(mp)->m_qm_ops.xfs_qmunmount)(mp)
  162. #define XFS_QM_DONE(mp) \
  163. (*(mp)->m_qm_ops.xfs_qmdone)(mp)
  164. #define XFS_QM_DQRELE(mp, dq) \
  165. (*(mp)->m_qm_ops.xfs_dqrele)(dq)
  166. #define XFS_QM_DQATTACH(mp, ip, fl) \
  167. (*(mp)->m_qm_ops.xfs_dqattach)(ip, fl)
  168. #define XFS_QM_DQDETACH(mp, ip) \
  169. (*(mp)->m_qm_ops.xfs_dqdetach)(ip)
  170. #define XFS_QM_DQPURGEALL(mp, fl) \
  171. (*(mp)->m_qm_ops.xfs_dqpurgeall)(mp, fl)
  172. #define XFS_QM_DQVOPALLOC(mp, ip, uid, gid, prid, fl, dq1, dq2) \
  173. (*(mp)->m_qm_ops.xfs_dqvopalloc)(mp, ip, uid, gid, prid, fl, dq1, dq2)
  174. #define XFS_QM_DQVOPCREATE(mp, tp, ip, dq1, dq2) \
  175. (*(mp)->m_qm_ops.xfs_dqvopcreate)(tp, ip, dq1, dq2)
  176. #define XFS_QM_DQVOPRENAME(mp, ip) \
  177. (*(mp)->m_qm_ops.xfs_dqvoprename)(ip)
  178. #define XFS_QM_DQVOPCHOWN(mp, tp, ip, dqp, dq) \
  179. (*(mp)->m_qm_ops.xfs_dqvopchown)(tp, ip, dqp, dq)
  180. #define XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, dq1, dq2, fl) \
  181. (*(mp)->m_qm_ops.xfs_dqvopchownresv)(tp, ip, dq1, dq2, fl)
  182. /*
  183. * Prototypes and functions for I/O core modularization.
  184. */
  185. typedef int (*xfs_ioinit_t)(struct vfs *,
  186. struct xfs_mount_args *, int);
  187. typedef int (*xfs_bmapi_t)(struct xfs_trans *, void *,
  188. xfs_fileoff_t, xfs_filblks_t, int,
  189. xfs_fsblock_t *, xfs_extlen_t,
  190. struct xfs_bmbt_irec *, int *,
  191. struct xfs_bmap_free *);
  192. typedef int (*xfs_bmap_eof_t)(void *, xfs_fileoff_t, int, int *);
  193. typedef int (*xfs_iomap_write_direct_t)(
  194. void *, xfs_off_t, size_t, int,
  195. struct xfs_bmbt_irec *, int *, int);
  196. typedef int (*xfs_iomap_write_delay_t)(
  197. void *, xfs_off_t, size_t, int,
  198. struct xfs_bmbt_irec *, int *);
  199. typedef int (*xfs_iomap_write_allocate_t)(
  200. void *, xfs_off_t, size_t,
  201. struct xfs_bmbt_irec *, int *);
  202. typedef int (*xfs_iomap_write_unwritten_t)(
  203. void *, xfs_off_t, size_t);
  204. typedef uint (*xfs_lck_map_shared_t)(void *);
  205. typedef void (*xfs_lock_t)(void *, uint);
  206. typedef void (*xfs_lock_demote_t)(void *, uint);
  207. typedef int (*xfs_lock_nowait_t)(void *, uint);
  208. typedef void (*xfs_unlk_t)(void *, unsigned int);
  209. typedef xfs_fsize_t (*xfs_size_t)(void *);
  210. typedef xfs_fsize_t (*xfs_iodone_t)(struct vfs *);
  211. typedef struct xfs_ioops {
  212. xfs_ioinit_t xfs_ioinit;
  213. xfs_bmapi_t xfs_bmapi_func;
  214. xfs_bmap_eof_t xfs_bmap_eof_func;
  215. xfs_iomap_write_direct_t xfs_iomap_write_direct;
  216. xfs_iomap_write_delay_t xfs_iomap_write_delay;
  217. xfs_iomap_write_allocate_t xfs_iomap_write_allocate;
  218. xfs_iomap_write_unwritten_t xfs_iomap_write_unwritten;
  219. xfs_lock_t xfs_ilock;
  220. xfs_lck_map_shared_t xfs_lck_map_shared;
  221. xfs_lock_demote_t xfs_ilock_demote;
  222. xfs_lock_nowait_t xfs_ilock_nowait;
  223. xfs_unlk_t xfs_unlock;
  224. xfs_size_t xfs_size_func;
  225. xfs_iodone_t xfs_iodone;
  226. } xfs_ioops_t;
  227. #define XFS_IOINIT(vfsp, args, flags) \
  228. (*(mp)->m_io_ops.xfs_ioinit)(vfsp, args, flags)
  229. #define XFS_BMAPI(mp, trans,io,bno,len,f,first,tot,mval,nmap,flist) \
  230. (*(mp)->m_io_ops.xfs_bmapi_func) \
  231. (trans,(io)->io_obj,bno,len,f,first,tot,mval,nmap,flist)
  232. #define XFS_BMAP_EOF(mp, io, endoff, whichfork, eof) \
  233. (*(mp)->m_io_ops.xfs_bmap_eof_func) \
  234. ((io)->io_obj, endoff, whichfork, eof)
  235. #define XFS_IOMAP_WRITE_DIRECT(mp, io, offset, count, flags, mval, nmap, found)\
  236. (*(mp)->m_io_ops.xfs_iomap_write_direct) \
  237. ((io)->io_obj, offset, count, flags, mval, nmap, found)
  238. #define XFS_IOMAP_WRITE_DELAY(mp, io, offset, count, flags, mval, nmap) \
  239. (*(mp)->m_io_ops.xfs_iomap_write_delay) \
  240. ((io)->io_obj, offset, count, flags, mval, nmap)
  241. #define XFS_IOMAP_WRITE_ALLOCATE(mp, io, offset, count, mval, nmap) \
  242. (*(mp)->m_io_ops.xfs_iomap_write_allocate) \
  243. ((io)->io_obj, offset, count, mval, nmap)
  244. #define XFS_IOMAP_WRITE_UNWRITTEN(mp, io, offset, count) \
  245. (*(mp)->m_io_ops.xfs_iomap_write_unwritten) \
  246. ((io)->io_obj, offset, count)
  247. #define XFS_LCK_MAP_SHARED(mp, io) \
  248. (*(mp)->m_io_ops.xfs_lck_map_shared)((io)->io_obj)
  249. #define XFS_ILOCK(mp, io, mode) \
  250. (*(mp)->m_io_ops.xfs_ilock)((io)->io_obj, mode)
  251. #define XFS_ILOCK_NOWAIT(mp, io, mode) \
  252. (*(mp)->m_io_ops.xfs_ilock_nowait)((io)->io_obj, mode)
  253. #define XFS_IUNLOCK(mp, io, mode) \
  254. (*(mp)->m_io_ops.xfs_unlock)((io)->io_obj, mode)
  255. #define XFS_ILOCK_DEMOTE(mp, io, mode) \
  256. (*(mp)->m_io_ops.xfs_ilock_demote)((io)->io_obj, mode)
  257. #define XFS_SIZE(mp, io) \
  258. (*(mp)->m_io_ops.xfs_size_func)((io)->io_obj)
  259. #define XFS_IODONE(vfsp) \
  260. (*(mp)->m_io_ops.xfs_iodone)(vfsp)
  261. typedef struct xfs_mount {
  262. bhv_desc_t m_bhv; /* vfs xfs behavior */
  263. xfs_tid_t m_tid; /* next unused tid for fs */
  264. AIL_LOCK_T m_ail_lock; /* fs AIL mutex */
  265. xfs_ail_entry_t m_ail; /* fs active log item list */
  266. uint m_ail_gen; /* fs AIL generation count */
  267. xfs_sb_t m_sb; /* copy of fs superblock */
  268. lock_t m_sb_lock; /* sb counter mutex */
  269. struct xfs_buf *m_sb_bp; /* buffer for superblock */
  270. char *m_fsname; /* filesystem name */
  271. int m_fsname_len; /* strlen of fs name */
  272. int m_bsize; /* fs logical block size */
  273. xfs_agnumber_t m_agfrotor; /* last ag where space found */
  274. xfs_agnumber_t m_agirotor; /* last ag dir inode alloced */
  275. lock_t m_agirotor_lock;/* .. and lock protecting it */
  276. xfs_agnumber_t m_maxagi; /* highest inode alloc group */
  277. uint m_ihsize; /* size of next field */
  278. struct xfs_ihash *m_ihash; /* fs private inode hash table*/
  279. struct xfs_inode *m_inodes; /* active inode list */
  280. struct list_head m_del_inodes; /* inodes to reclaim */
  281. mutex_t m_ilock; /* inode list mutex */
  282. uint m_ireclaims; /* count of calls to reclaim*/
  283. uint m_readio_log; /* min read size log bytes */
  284. uint m_readio_blocks; /* min read size blocks */
  285. uint m_writeio_log; /* min write size log bytes */
  286. uint m_writeio_blocks; /* min write size blocks */
  287. struct log *m_log; /* log specific stuff */
  288. int m_logbufs; /* number of log buffers */
  289. int m_logbsize; /* size of each log buffer */
  290. uint m_rsumlevels; /* rt summary levels */
  291. uint m_rsumsize; /* size of rt summary, bytes */
  292. struct xfs_inode *m_rbmip; /* pointer to bitmap inode */
  293. struct xfs_inode *m_rsumip; /* pointer to summary inode */
  294. struct xfs_inode *m_rootip; /* pointer to root directory */
  295. struct xfs_quotainfo *m_quotainfo; /* disk quota information */
  296. xfs_buftarg_t *m_ddev_targp; /* saves taking the address */
  297. xfs_buftarg_t *m_logdev_targp;/* ptr to log device */
  298. xfs_buftarg_t *m_rtdev_targp; /* ptr to rt device */
  299. #define m_dev m_ddev_targp->pbr_dev
  300. __uint8_t m_dircook_elog; /* log d-cookie entry bits */
  301. __uint8_t m_blkbit_log; /* blocklog + NBBY */
  302. __uint8_t m_blkbb_log; /* blocklog - BBSHIFT */
  303. __uint8_t m_agno_log; /* log #ag's */
  304. __uint8_t m_agino_log; /* #bits for agino in inum */
  305. __uint8_t m_nreadaheads; /* #readahead buffers */
  306. __uint16_t m_inode_cluster_size;/* min inode buf size */
  307. uint m_blockmask; /* sb_blocksize-1 */
  308. uint m_blockwsize; /* sb_blocksize in words */
  309. uint m_blockwmask; /* blockwsize-1 */
  310. uint m_alloc_mxr[2]; /* XFS_ALLOC_BLOCK_MAXRECS */
  311. uint m_alloc_mnr[2]; /* XFS_ALLOC_BLOCK_MINRECS */
  312. uint m_bmap_dmxr[2]; /* XFS_BMAP_BLOCK_DMAXRECS */
  313. uint m_bmap_dmnr[2]; /* XFS_BMAP_BLOCK_DMINRECS */
  314. uint m_inobt_mxr[2]; /* XFS_INOBT_BLOCK_MAXRECS */
  315. uint m_inobt_mnr[2]; /* XFS_INOBT_BLOCK_MINRECS */
  316. uint m_ag_maxlevels; /* XFS_AG_MAXLEVELS */
  317. uint m_bm_maxlevels[2]; /* XFS_BM_MAXLEVELS */
  318. uint m_in_maxlevels; /* XFS_IN_MAXLEVELS */
  319. struct xfs_perag *m_perag; /* per-ag accounting info */
  320. struct rw_semaphore m_peraglock; /* lock for m_perag (pointer) */
  321. sema_t m_growlock; /* growfs mutex */
  322. int m_fixedfsid[2]; /* unchanged for life of FS */
  323. uint m_dmevmask; /* DMI events for this FS */
  324. uint m_flags; /* global mount flags */
  325. uint m_attroffset; /* inode attribute offset */
  326. uint m_dir_node_ents; /* #entries in a dir danode */
  327. uint m_attr_node_ents; /* #entries in attr danode */
  328. int m_ialloc_inos; /* inodes in inode allocation */
  329. int m_ialloc_blks; /* blocks in inode allocation */
  330. int m_litino; /* size of inode union area */
  331. int m_inoalign_mask;/* mask sb_inoalignmt if used */
  332. uint m_qflags; /* quota status flags */
  333. xfs_trans_reservations_t m_reservations;/* precomputed res values */
  334. __uint64_t m_maxicount; /* maximum inode count */
  335. __uint64_t m_maxioffset; /* maximum inode offset */
  336. __uint64_t m_resblks; /* total reserved blocks */
  337. __uint64_t m_resblks_avail;/* available reserved blocks */
  338. #if XFS_BIG_INUMS
  339. xfs_ino_t m_inoadd; /* add value for ino64_offset */
  340. #endif
  341. int m_dalign; /* stripe unit */
  342. int m_swidth; /* stripe width */
  343. int m_sinoalign; /* stripe unit inode alignmnt */
  344. int m_attr_magicpct;/* 37% of the blocksize */
  345. int m_dir_magicpct; /* 37% of the dir blocksize */
  346. __uint8_t m_mk_sharedro; /* mark shared ro on unmount */
  347. __uint8_t m_inode_quiesce;/* call quiesce on new inodes.
  348. field governed by m_ilock */
  349. __uint8_t m_sectbb_log; /* sectlog - BBSHIFT */
  350. __uint8_t m_dirversion; /* 1 or 2 */
  351. xfs_dirops_t m_dirops; /* table of dir funcs */
  352. int m_dirblksize; /* directory block sz--bytes */
  353. int m_dirblkfsbs; /* directory block sz--fsbs */
  354. xfs_dablk_t m_dirdatablk; /* blockno of dir data v2 */
  355. xfs_dablk_t m_dirleafblk; /* blockno of dir non-data v2 */
  356. xfs_dablk_t m_dirfreeblk; /* blockno of dirfreeindex v2 */
  357. uint m_chsize; /* size of next field */
  358. struct xfs_chash *m_chash; /* fs private inode per-cluster
  359. * hash table */
  360. struct xfs_dmops m_dm_ops; /* vector of DMI ops */
  361. struct xfs_qmops m_qm_ops; /* vector of XQM ops */
  362. struct xfs_ioops m_io_ops; /* vector of I/O ops */
  363. atomic_t m_active_trans; /* number trans frozen */
  364. } xfs_mount_t;
  365. /*
  366. * Flags for m_flags.
  367. */
  368. #define XFS_MOUNT_WSYNC 0x00000001 /* for nfs - all metadata ops
  369. must be synchronous except
  370. for space allocations */
  371. #define XFS_MOUNT_INO64 0x00000002
  372. /* 0x00000004 -- currently unused */
  373. /* 0x00000008 -- currently unused */
  374. #define XFS_MOUNT_FS_SHUTDOWN 0x00000010 /* atomic stop of all filesystem
  375. operations, typically for
  376. disk errors in metadata */
  377. #define XFS_MOUNT_NOATIME 0x00000020 /* don't modify inode access
  378. times on reads */
  379. #define XFS_MOUNT_RETERR 0x00000040 /* return alignment errors to
  380. user */
  381. #define XFS_MOUNT_NOALIGN 0x00000080 /* turn off stripe alignment
  382. allocations */
  383. /* 0x00000100 -- currently unused */
  384. /* 0x00000200 -- currently unused */
  385. #define XFS_MOUNT_NORECOVERY 0x00000400 /* no recovery - dirty fs */
  386. #define XFS_MOUNT_SHARED 0x00000800 /* shared mount */
  387. #define XFS_MOUNT_DFLT_IOSIZE 0x00001000 /* set default i/o size */
  388. #define XFS_MOUNT_OSYNCISOSYNC 0x00002000 /* o_sync is REALLY o_sync */
  389. /* osyncisdsync is now default*/
  390. #define XFS_MOUNT_32BITINODES 0x00004000 /* do not create inodes above
  391. * 32 bits in size */
  392. #define XFS_MOUNT_32BITINOOPT 0x00008000 /* saved mount option state */
  393. #define XFS_MOUNT_NOUUID 0x00010000 /* ignore uuid during mount */
  394. #define XFS_MOUNT_NOLOGFLUSH 0x00020000
  395. #define XFS_MOUNT_IDELETE 0x00040000 /* delete empty inode clusters*/
  396. #define XFS_MOUNT_SWALLOC 0x00080000 /* turn on stripe width
  397. * allocation */
  398. #define XFS_MOUNT_IHASHSIZE 0x00100000 /* inode hash table size */
  399. #define XFS_MOUNT_DIRSYNC 0x00200000 /* synchronous directory ops */
  400. /*
  401. * Default minimum read and write sizes.
  402. */
  403. #define XFS_READIO_LOG_LARGE 16
  404. #define XFS_WRITEIO_LOG_LARGE 16
  405. /*
  406. * Max and min values for mount-option defined I/O
  407. * preallocation sizes.
  408. */
  409. #define XFS_MAX_IO_LOG 30 /* 1G */
  410. #define XFS_MIN_IO_LOG PAGE_SHIFT
  411. /*
  412. * Synchronous read and write sizes. This should be
  413. * better for NFSv2 wsync filesystems.
  414. */
  415. #define XFS_WSYNC_READIO_LOG 15 /* 32K */
  416. #define XFS_WSYNC_WRITEIO_LOG 14 /* 16K */
  417. #define XFS_MAXIOFFSET(mp) ((mp)->m_maxioffset)
  418. #define XFS_FORCED_SHUTDOWN(mp) ((mp)->m_flags & XFS_MOUNT_FS_SHUTDOWN)
  419. #define xfs_force_shutdown(m,f) \
  420. VFS_FORCE_SHUTDOWN((XFS_MTOVFS(m)), f, __FILE__, __LINE__)
  421. /*
  422. * Flags sent to xfs_force_shutdown.
  423. */
  424. #define XFS_METADATA_IO_ERROR 0x1
  425. #define XFS_LOG_IO_ERROR 0x2
  426. #define XFS_FORCE_UMOUNT 0x4
  427. #define XFS_CORRUPT_INCORE 0x8 /* Corrupt in-memory data structures */
  428. #define XFS_SHUTDOWN_REMOTE_REQ 0x10 /* Shutdown came from remote cell */
  429. /*
  430. * xflags for xfs_syncsub
  431. */
  432. #define XFS_XSYNC_RELOC 0x01
  433. /*
  434. * Flags for xfs_mountfs
  435. */
  436. #define XFS_MFSI_SECOND 0x01 /* Secondary mount -- skip stuff */
  437. #define XFS_MFSI_CLIENT 0x02 /* Is a client -- skip lots of stuff */
  438. #define XFS_MFSI_NOUNLINK 0x08 /* Skip unlinked inode processing in */
  439. /* log recovery */
  440. #define XFS_MFSI_NO_QUOTACHECK 0x10 /* Skip quotacheck processing */
  441. /*
  442. * Macros for getting from mount to vfs and back.
  443. */
  444. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MTOVFS)
  445. struct vfs *xfs_mtovfs(xfs_mount_t *mp);
  446. #define XFS_MTOVFS(mp) xfs_mtovfs(mp)
  447. #else
  448. #define XFS_MTOVFS(mp) (bhvtovfs(&(mp)->m_bhv))
  449. #endif
  450. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BHVTOM)
  451. xfs_mount_t *xfs_bhvtom(bhv_desc_t *bdp);
  452. #define XFS_BHVTOM(bdp) xfs_bhvtom(bdp)
  453. #else
  454. #define XFS_BHVTOM(bdp) ((xfs_mount_t *)BHV_PDATA(bdp))
  455. #endif
  456. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_VFSTOM)
  457. xfs_mount_t *xfs_vfstom(vfs_t *vfs);
  458. #define XFS_VFSTOM(vfs) xfs_vfstom(vfs)
  459. #else
  460. #define XFS_VFSTOM(vfs) \
  461. (XFS_BHVTOM(bhv_lookup(VFS_BHVHEAD(vfs), &xfs_vfsops)))
  462. #endif
  463. /*
  464. * Moved here from xfs_ag.h to avoid reordering header files
  465. */
  466. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DADDR_TO_AGNO)
  467. xfs_agnumber_t xfs_daddr_to_agno(struct xfs_mount *mp, xfs_daddr_t d);
  468. #define XFS_DADDR_TO_AGNO(mp,d) xfs_daddr_to_agno(mp,d)
  469. #else
  470. static inline xfs_agnumber_t XFS_DADDR_TO_AGNO(xfs_mount_t *mp, xfs_daddr_t d)
  471. {
  472. d = XFS_BB_TO_FSBT(mp, d);
  473. do_div(d, mp->m_sb.sb_agblocks);
  474. return (xfs_agnumber_t) d;
  475. }
  476. #endif
  477. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DADDR_TO_AGBNO)
  478. xfs_agblock_t xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d);
  479. #define XFS_DADDR_TO_AGBNO(mp,d) xfs_daddr_to_agbno(mp,d)
  480. #else
  481. static inline xfs_agblock_t XFS_DADDR_TO_AGBNO(xfs_mount_t *mp, xfs_daddr_t d)
  482. {
  483. d = XFS_BB_TO_FSBT(mp, d);
  484. return (xfs_agblock_t) do_div(d, mp->m_sb.sb_agblocks);
  485. }
  486. #endif
  487. /*
  488. * This structure is for use by the xfs_mod_incore_sb_batch() routine.
  489. */
  490. typedef struct xfs_mod_sb {
  491. xfs_sb_field_t msb_field; /* Field to modify, see below */
  492. int msb_delta; /* Change to make to specified field */
  493. } xfs_mod_sb_t;
  494. #define XFS_MOUNT_ILOCK(mp) mutex_lock(&((mp)->m_ilock), PINOD)
  495. #define XFS_MOUNT_IUNLOCK(mp) mutex_unlock(&((mp)->m_ilock))
  496. #define XFS_SB_LOCK(mp) mutex_spinlock(&(mp)->m_sb_lock)
  497. #define XFS_SB_UNLOCK(mp,s) mutex_spinunlock(&(mp)->m_sb_lock,(s))
  498. extern xfs_mount_t *xfs_mount_init(void);
  499. extern void xfs_mod_sb(xfs_trans_t *, __int64_t);
  500. extern void xfs_mount_free(xfs_mount_t *mp, int remove_bhv);
  501. extern int xfs_mountfs(struct vfs *, xfs_mount_t *mp, int);
  502. extern int xfs_unmountfs(xfs_mount_t *, struct cred *);
  503. extern void xfs_unmountfs_close(xfs_mount_t *, struct cred *);
  504. extern int xfs_unmountfs_writesb(xfs_mount_t *);
  505. extern int xfs_unmount_flush(xfs_mount_t *, int);
  506. extern int xfs_mod_incore_sb(xfs_mount_t *, xfs_sb_field_t, int, int);
  507. extern int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *,
  508. uint, int);
  509. extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int);
  510. extern int xfs_readsb(xfs_mount_t *mp);
  511. extern void xfs_freesb(xfs_mount_t *);
  512. extern void xfs_do_force_shutdown(bhv_desc_t *, int, char *, int);
  513. extern int xfs_syncsub(xfs_mount_t *, int, int, int *);
  514. extern xfs_agnumber_t xfs_initialize_perag(xfs_mount_t *, xfs_agnumber_t);
  515. extern void xfs_xlatesb(void *, struct xfs_sb *, int, __int64_t);
  516. extern struct vfsops xfs_vfsops;
  517. extern struct vnodeops xfs_vnodeops;
  518. extern struct xfs_dmops xfs_dmcore_stub;
  519. extern struct xfs_qmops xfs_qmcore_stub;
  520. extern struct xfs_ioops xfs_iocore_xfs;
  521. extern int xfs_init(void);
  522. extern void xfs_cleanup(void);
  523. #endif /* __KERNEL__ */
  524. #endif /* __XFS_MOUNT_H__ */