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