]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - include/xfs_mount.h
xfsprogs update - kernel/user sync up and Ethan's Mac partition code.
[thirdparty/xfsprogs-dev.git] / include / xfs_mount.h
CommitLineData
2bd0ea18 1/*
eae766ca 2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
5000d01d 3 *
2bd0ea18
NS
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.
5000d01d 7 *
2bd0ea18
NS
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.
5000d01d 11 *
2bd0ea18
NS
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
5000d01d 14 * or the like. Any license provided herein, whether implied or
2bd0ea18
NS
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.
5000d01d 18 *
2bd0ea18
NS
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.
5000d01d 22 *
2bd0ea18
NS
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
5000d01d
SL
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
2bd0ea18
NS
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32#ifndef __XFS_MOUNT_H__
5000d01d 33#define __XFS_MOUNT_H__
2bd0ea18
NS
34
35
36typedef 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 */
5000d01d 55 uint tr_growrtalloc; /* grow realtime allocations */
2bd0ea18
NS
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
70struct cred;
2bd0ea18
NS
71struct vfs;
72struct vnode;
4542f191 73struct xfs_mount_args;
2bd0ea18
NS
74struct xfs_ihash;
75struct xfs_chash;
76struct xfs_inode;
77struct xfs_perag;
2bd0ea18 78struct xfs_iocore;
2bd0ea18
NS
79struct xfs_bmbt_irec;
80struct xfs_bmap_free;
81
5000d01d
SL
82#define SPLDECL(s) unsigned long s
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)
2bd0ea18 88
eae766ca
NS
89
90/*
91 * Prototypes and functions for the Data Migration subsystem.
92 */
93
94typedef int (*xfs_send_data_t)(int, struct bhv_desc *,
95 xfs_off_t, size_t, int, vrwlock_t *);
96typedef int (*xfs_send_mmap_t)(struct vm_area_struct *, uint);
97typedef int (*xfs_send_destroy_t)(struct bhv_desc *, dm_right_t);
98typedef int (*xfs_send_namesp_t)(dm_eventtype_t, struct bhv_desc *,
99 dm_right_t, struct bhv_desc *, dm_right_t,
100 char *, char *, mode_t, int, int);
101typedef void (*xfs_send_unmount_t)(struct vfs *, struct vnode *,
102 dm_right_t, mode_t, int, int);
103
104typedef struct xfs_dmops {
105 xfs_send_data_t xfs_send_data;
106 xfs_send_mmap_t xfs_send_mmap;
107 xfs_send_destroy_t xfs_send_destroy;
108 xfs_send_namesp_t xfs_send_namesp;
109 xfs_send_unmount_t xfs_send_unmount;
110} xfs_dmops_t;
111
112#define XFS_SEND_DATA(mp, ev,bdp,off,len,fl,lock) \
113 (*(mp)->m_dm_ops.xfs_send_data)(ev,bdp,off,len,fl,lock)
114#define XFS_SEND_MMAP(mp, vma,fl) \
115 (*(mp)->m_dm_ops.xfs_send_mmap)(vma,fl)
116#define XFS_SEND_DESTROY(mp, bdp,right) \
117 (*(mp)->m_dm_ops.xfs_send_destroy)(bdp,right)
118#define XFS_SEND_NAMESP(mp, ev,b1,r1,b2,r2,n1,n2,mode,rval,fl) \
119 (*(mp)->m_dm_ops.xfs_send_namesp)(ev,b1,r1,b2,r2,n1,n2,mode,rval,fl)
120#define XFS_SEND_UNMOUNT(mp, vfsp,vp,right,mode,rval,fl) \
121 (*(mp)->m_dm_ops.xfs_send_unmount)(vfsp,vp,right,mode,rval,fl)
122
123
124/*
125 * Prototypes and functions for the Quota Management subsystem.
126 */
127
128struct xfs_dquot;
129struct xfs_dqtrxops;
130struct xfs_quotainfo;
131
132typedef int (*xfs_qminit_t)(struct xfs_mount *, uint *, uint *);
133typedef int (*xfs_qmmount_t)(struct xfs_mount *, uint, uint);
134typedef int (*xfs_qmunmount_t)(struct xfs_mount *);
135typedef void (*xfs_qmdone_t)(struct xfs_mount *);
136typedef void (*xfs_dqrele_t)(struct xfs_dquot *);
137typedef int (*xfs_dqattach_t)(struct xfs_inode *, uint);
138typedef void (*xfs_dqdetach_t)(struct xfs_inode *);
139typedef int (*xfs_dqpurgeall_t)(struct xfs_mount *, uint);
140typedef int (*xfs_dqvopalloc_t)(struct xfs_mount *,
141 struct xfs_inode *, uid_t, gid_t, uint,
142 struct xfs_dquot **, struct xfs_dquot **);
143typedef void (*xfs_dqvopcreate_t)(struct xfs_trans *, struct xfs_inode *,
144 struct xfs_dquot *, struct xfs_dquot *);
145typedef int (*xfs_dqvoprename_t)(struct xfs_inode **);
146typedef struct xfs_dquot * (*xfs_dqvopchown_t)(
147 struct xfs_trans *, struct xfs_inode *,
148 struct xfs_dquot **, struct xfs_dquot *);
149typedef int (*xfs_dqvopchownresv_t)(struct xfs_trans *, struct xfs_inode *,
150 struct xfs_dquot *, struct xfs_dquot *, uint);
151
152typedef struct xfs_qmops {
153 xfs_qminit_t xfs_qminit;
154 xfs_qmdone_t xfs_qmdone;
155 xfs_qmmount_t xfs_qmmount;
156 xfs_qmunmount_t xfs_qmunmount;
157 xfs_dqrele_t xfs_dqrele;
158 xfs_dqattach_t xfs_dqattach;
159 xfs_dqdetach_t xfs_dqdetach;
160 xfs_dqpurgeall_t xfs_dqpurgeall;
161 xfs_dqvopalloc_t xfs_dqvopalloc;
162 xfs_dqvopcreate_t xfs_dqvopcreate;
163 xfs_dqvoprename_t xfs_dqvoprename;
164 xfs_dqvopchown_t xfs_dqvopchown;
165 xfs_dqvopchownresv_t xfs_dqvopchownresv;
166 struct xfs_dqtrxops *xfs_dqtrxops;
167} xfs_qmops_t;
168
169#define XFS_QM_INIT(mp, mnt, fl) \
170 (*(mp)->m_qm_ops.xfs_qminit)(mp, mnt, fl)
171#define XFS_QM_MOUNT(mp, mnt, fl) \
172 (*(mp)->m_qm_ops.xfs_qmmount)(mp, mnt, fl)
173#define XFS_QM_UNMOUNT(mp) \
174 (*(mp)->m_qm_ops.xfs_qmunmount)(mp)
175#define XFS_QM_DONE(mp) \
176 (*(mp)->m_qm_ops.xfs_qmdone)(mp)
177#define XFS_QM_DQRELE(mp, dq) \
178 (*(mp)->m_qm_ops.xfs_dqrele)(dq)
179#define XFS_QM_DQATTACH(mp, ip, fl) \
180 (*(mp)->m_qm_ops.xfs_dqattach)(ip, fl)
181#define XFS_QM_DQDETACH(mp, ip) \
182 (*(mp)->m_qm_ops.xfs_dqdetach)(ip)
183#define XFS_QM_DQPURGEALL(mp, fl) \
184 (*(mp)->m_qm_ops.xfs_dqpurgeall)(mp, fl)
185#define XFS_QM_DQVOPALLOC(mp, ip, uid, gid, fl, dq1, dq2) \
186 (*(mp)->m_qm_ops.xfs_dqvopalloc)(mp, ip, uid, gid, fl, dq1, dq2)
187#define XFS_QM_DQVOPCREATE(mp, tp, ip, dq1, dq2) \
188 (*(mp)->m_qm_ops.xfs_dqvopcreate)(tp, ip, dq1, dq2)
189#define XFS_QM_DQVOPRENAME(mp, ip) \
190 (*(mp)->m_qm_ops.xfs_dqvoprename)(ip)
191#define XFS_QM_DQVOPCHOWN(mp, tp, ip, dqp, dq) \
192 (*(mp)->m_qm_ops.xfs_dqvopchown)(tp, ip, dqp, dq)
193#define XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, dq1, dq2, fl) \
194 (*(mp)->m_qm_ops.xfs_dqvopchownresv)(tp, ip, dq1, dq2, fl)
195
196
f9e56f43
NS
197/*
198 * Prototypes and functions for I/O core modularization.
2bd0ea18 199 */
f9e56f43 200
f9e56f43 201typedef int (*xfs_ioinit_t)(struct vfs *,
eae766ca 202 struct xfs_mount_args *, int);
2bd0ea18
NS
203typedef int (*xfs_bmapi_t)(struct xfs_trans *, void *,
204 xfs_fileoff_t, xfs_filblks_t, int,
205 xfs_fsblock_t *, xfs_extlen_t,
206 struct xfs_bmbt_irec *, int *,
207 struct xfs_bmap_free *);
208typedef int (*xfs_bmap_eof_t)(void *, xfs_fileoff_t, int, int *);
f9e56f43
NS
209typedef int (*xfs_iomap_write_direct_t)(
210 void *, loff_t, size_t, int,
211 struct xfs_bmbt_irec *, int *, int);
212typedef int (*xfs_iomap_write_delay_t)(
213 void *, loff_t, size_t, int,
214 struct xfs_bmbt_irec *, int *);
215typedef int (*xfs_iomap_write_allocate_t)(
216 void *, struct xfs_bmbt_irec *, int *);
217typedef int (*xfs_iomap_write_unwritten_t)(
218 void *, loff_t, size_t);
219typedef uint (*xfs_lck_map_shared_t)(void *);
2bd0ea18
NS
220typedef void (*xfs_lock_t)(void *, uint);
221typedef void (*xfs_lock_demote_t)(void *, uint);
222typedef int (*xfs_lock_nowait_t)(void *, uint);
223typedef void (*xfs_unlk_t)(void *, unsigned int);
2bd0ea18 224typedef xfs_fsize_t (*xfs_size_t)(void *);
f9e56f43 225typedef xfs_fsize_t (*xfs_iodone_t)(struct vfs *);
2bd0ea18 226
2bd0ea18 227typedef struct xfs_ioops {
f9e56f43
NS
228 xfs_ioinit_t xfs_ioinit;
229 xfs_bmapi_t xfs_bmapi_func;
230 xfs_bmap_eof_t xfs_bmap_eof_func;
231 xfs_iomap_write_direct_t xfs_iomap_write_direct;
232 xfs_iomap_write_delay_t xfs_iomap_write_delay;
233 xfs_iomap_write_allocate_t xfs_iomap_write_allocate;
234 xfs_iomap_write_unwritten_t xfs_iomap_write_unwritten;
235 xfs_lock_t xfs_ilock;
236 xfs_lck_map_shared_t xfs_lck_map_shared;
237 xfs_lock_demote_t xfs_ilock_demote;
238 xfs_lock_nowait_t xfs_ilock_nowait;
239 xfs_unlk_t xfs_unlock;
240 xfs_size_t xfs_size_func;
241 xfs_iodone_t xfs_iodone;
2bd0ea18
NS
242} xfs_ioops_t;
243
f9e56f43
NS
244#define XFS_IOINIT(vfsp, args, flags) \
245 (*(mp)->m_io_ops.xfs_ioinit)(vfsp, args, flags)
2bd0ea18
NS
246#define XFS_BMAPI(mp, trans,io,bno,len,f,first,tot,mval,nmap,flist) \
247 (*(mp)->m_io_ops.xfs_bmapi_func) \
248 (trans,(io)->io_obj,bno,len,f,first,tot,mval,nmap,flist)
2bd0ea18
NS
249#define XFS_BMAP_EOF(mp, io, endoff, whichfork, eof) \
250 (*(mp)->m_io_ops.xfs_bmap_eof_func) \
251 ((io)->io_obj, endoff, whichfork, eof)
f9e56f43
NS
252#define XFS_IOMAP_WRITE_DIRECT(mp, io, offset, count, flags, mval, nmap, found)\
253 (*(mp)->m_io_ops.xfs_iomap_write_direct) \
254 ((io)->io_obj, offset, count, flags, mval, nmap, found)
f9e56f43
NS
255#define XFS_IOMAP_WRITE_DELAY(mp, io, offset, count, flags, mval, nmap) \
256 (*(mp)->m_io_ops.xfs_iomap_write_delay) \
257 ((io)->io_obj, offset, count, flags, mval, nmap)
f9e56f43
NS
258#define XFS_IOMAP_WRITE_ALLOCATE(mp, io, mval, nmap) \
259 (*(mp)->m_io_ops.xfs_iomap_write_allocate) \
260 ((io)->io_obj, mval, nmap)
f9e56f43
NS
261#define XFS_IOMAP_WRITE_UNWRITTEN(mp, io, offset, count) \
262 (*(mp)->m_io_ops.xfs_iomap_write_unwritten) \
263 ((io)->io_obj, offset, count)
f9e56f43
NS
264#define XFS_LCK_MAP_SHARED(mp, io) \
265 (*(mp)->m_io_ops.xfs_lck_map_shared)((io)->io_obj)
2bd0ea18
NS
266#define XFS_ILOCK(mp, io, mode) \
267 (*(mp)->m_io_ops.xfs_ilock)((io)->io_obj, mode)
f9e56f43
NS
268#define XFS_ILOCK_NOWAIT(mp, io, mode) \
269 (*(mp)->m_io_ops.xfs_ilock_nowait)((io)->io_obj, mode)
2bd0ea18
NS
270#define XFS_IUNLOCK(mp, io, mode) \
271 (*(mp)->m_io_ops.xfs_unlock)((io)->io_obj, mode)
2bd0ea18
NS
272#define XFS_ILOCK_DEMOTE(mp, io, mode) \
273 (*(mp)->m_io_ops.xfs_ilock_demote)((io)->io_obj, mode)
2bd0ea18
NS
274#define XFS_SIZE(mp, io) \
275 (*(mp)->m_io_ops.xfs_size_func)((io)->io_obj)
f9e56f43
NS
276#define XFS_IODONE(vfsp) \
277 (*(mp)->m_io_ops.xfs_iodone)(vfsp)
278
279
2bd0ea18
NS
280typedef struct xfs_mount {
281 bhv_desc_t m_bhv; /* vfs xfs behavior */
282 xfs_tid_t m_tid; /* next unused tid for fs */
283 AIL_LOCK_T m_ail_lock; /* fs AIL mutex */
284 xfs_ail_entry_t m_ail; /* fs active log item list */
285 uint m_ail_gen; /* fs AIL generation count */
286 xfs_sb_t m_sb; /* copy of fs superblock */
287 lock_t m_sb_lock; /* sb counter mutex */
288 struct xfs_buf *m_sb_bp; /* buffer for superblock */
5000d01d 289 char *m_fsname; /* filesystem name */
2bd0ea18
NS
290 int m_fsname_len; /* strlen of fs name */
291 int m_bsize; /* fs logical block size */
292 xfs_agnumber_t m_agfrotor; /* last ag where space found */
293 xfs_agnumber_t m_agirotor; /* last ag dir inode alloced */
6d1d29a7 294 xfs_agnumber_t m_maxagi; /* highest inode alloc group */
2bd0ea18
NS
295 int m_ihsize; /* size of next field */
296 struct xfs_ihash *m_ihash; /* fs private inode hash table*/
297 struct xfs_inode *m_inodes; /* active inode list */
298 mutex_t m_ilock; /* inode list mutex */
299 uint m_ireclaims; /* count of calls to reclaim*/
300 uint m_readio_log; /* min read size log bytes */
301 uint m_readio_blocks; /* min read size blocks */
302 uint m_writeio_log; /* min write size log bytes */
303 uint m_writeio_blocks; /* min write size blocks */
304 void *m_log; /* log specific stuff */
305 int m_logbufs; /* number of log buffers */
306 int m_logbsize; /* size of each log buffer */
307 uint m_rsumlevels; /* rt summary levels */
308 uint m_rsumsize; /* size of rt summary, bytes */
309 struct xfs_inode *m_rbmip; /* pointer to bitmap inode */
310 struct xfs_inode *m_rsumip; /* pointer to summary inode */
311 struct xfs_inode *m_rootip; /* pointer to root directory */
312 struct xfs_quotainfo *m_quotainfo; /* disk quota information */
b391b7cd
NS
313 xfs_buftarg_t *m_ddev_targp; /* saves taking the address */
314 xfs_buftarg_t *m_logdev_targp;/* ptr to log device */
315 xfs_buftarg_t *m_rtdev_targp; /* ptr to rt device */
316#define m_dev m_ddev_targp->pbr_dev
eae766ca
NS
317#define m_logdev m_logdev_targp->pbr_dev
318#define m_rtdev m_rtdev_targp->pbr_dev
5000d01d 319 __uint8_t m_dircook_elog; /* log d-cookie entry bits */
2bd0ea18
NS
320 __uint8_t m_blkbit_log; /* blocklog + NBBY */
321 __uint8_t m_blkbb_log; /* blocklog - BBSHIFT */
322 __uint8_t m_agno_log; /* log #ag's */
323 __uint8_t m_agino_log; /* #bits for agino in inum */
324 __uint8_t m_nreadaheads; /* #readahead buffers */
325 __uint16_t m_inode_cluster_size;/* min inode buf size */
326 uint m_blockmask; /* sb_blocksize-1 */
327 uint m_blockwsize; /* sb_blocksize in words */
328 uint m_blockwmask; /* blockwsize-1 */
5000d01d
SL
329 uint m_alloc_mxr[2]; /* XFS_ALLOC_BLOCK_MAXRECS */
330 uint m_alloc_mnr[2]; /* XFS_ALLOC_BLOCK_MINRECS */
331 uint m_bmap_dmxr[2]; /* XFS_BMAP_BLOCK_DMAXRECS */
332 uint m_bmap_dmnr[2]; /* XFS_BMAP_BLOCK_DMINRECS */
333 uint m_inobt_mxr[2]; /* XFS_INOBT_BLOCK_MAXRECS */
334 uint m_inobt_mnr[2]; /* XFS_INOBT_BLOCK_MINRECS */
335 uint m_ag_maxlevels; /* XFS_AG_MAXLEVELS */
2bd0ea18 336 uint m_bm_maxlevels[2]; /* XFS_BM_MAXLEVELS */
5000d01d 337 uint m_in_maxlevels; /* XFS_IN_MAXLEVELS */
2bd0ea18 338 struct xfs_perag *m_perag; /* per-ag accounting info */
e56fcdce 339 struct rw_semaphore m_peraglock; /* lock for m_perag (pointer) */
2bd0ea18 340 sema_t m_growlock; /* growfs mutex */
5000d01d 341 int m_fixedfsid[2]; /* unchanged for life of FS */
2bd0ea18
NS
342 uint m_dmevmask; /* DMI events for this FS */
343 uint m_flags; /* global mount flags */
344 uint m_attroffset; /* inode attribute offset */
6bef826c
NS
345 uint m_dir_node_ents; /* #entries in a dir danode */
346 uint m_attr_node_ents; /* #entries in attr danode */
2bd0ea18
NS
347 int m_ialloc_inos; /* inodes in inode allocation */
348 int m_ialloc_blks; /* blocks in inode allocation */
349 int m_litino; /* size of inode union area */
350 int m_inoalign_mask;/* mask sb_inoalignmt if used */
351 uint m_qflags; /* quota status flags */
352 xfs_trans_reservations_t m_reservations;/* precomputed res values */
353 __uint64_t m_maxicount; /* maximum inode count */
354 __uint64_t m_resblks; /* total reserved blocks */
355 __uint64_t m_resblks_avail;/* available reserved blocks */
356#if XFS_BIG_FILESYSTEMS
357 xfs_ino_t m_inoadd; /* add value for ino64_offset */
358#endif
359 int m_dalign; /* stripe unit */
360 int m_swidth; /* stripe width */
73bf5988 361 int m_lstripemask; /* log stripe mask */
2bd0ea18
NS
362 int m_sinoalign; /* stripe unit inode alignmnt */
363 int m_attr_magicpct;/* 37% of the blocksize */
5000d01d 364 int m_dir_magicpct; /* 37% of the dir blocksize */
2bd0ea18 365 __uint8_t m_mk_sharedro; /* mark shared ro on unmount */
5000d01d
SL
366 __uint8_t m_inode_quiesce;/* call quiesce on new inodes.
367 field governed by m_ilock */
9440d84d 368 __uint8_t m_sectbb_log; /* sectlog - BBSHIFT */
2bd0ea18
NS
369 __uint8_t m_dirversion; /* 1 or 2 */
370 xfs_dirops_t m_dirops; /* table of dir funcs */
371 int m_dirblksize; /* directory block sz--bytes */
372 int m_dirblkfsbs; /* directory block sz--fsbs */
373 xfs_dablk_t m_dirdatablk; /* blockno of dir data v2 */
374 xfs_dablk_t m_dirleafblk; /* blockno of dir non-data v2 */
375 xfs_dablk_t m_dirfreeblk; /* blockno of dirfreeindex v2 */
376 int m_chsize; /* size of next field */
377 struct xfs_chash *m_chash; /* fs private inode per-cluster
378 * hash table */
eae766ca
NS
379 struct xfs_dmops m_dm_ops; /* vector of DMI ops */
380 struct xfs_qmops m_qm_ops; /* vector of XQM ops */
2bd0ea18 381 struct xfs_ioops m_io_ops; /* vector of I/O ops */
0ddd9902
NS
382 lock_t m_freeze_lock; /* Lock for m_frozen */
383 uint m_frozen; /* FS frozen for shutdown or
384 * snapshot */
385 sv_t m_wait_unfreeze;/* waiting to unfreeze */
5000d01d 386 atomic_t m_active_trans; /* number trans frozen */
933d7884
ES
387 struct timer_list m_sbdirty_timer;/* superblock dirty timer
388 * for nfs refcache */
2bd0ea18
NS
389} xfs_mount_t;
390
391/*
392 * Flags for m_flags.
393 */
5000d01d 394#define XFS_MOUNT_WSYNC 0x00000001 /* for nfs - all metadata ops
2bd0ea18
NS
395 must be synchronous except
396 for space allocations */
397#if XFS_BIG_FILESYSTEMS
5000d01d 398#define XFS_MOUNT_INO64 0x00000002
2bd0ea18 399#endif
f9e56f43 400 /* 0x00000004 -- currently unused */
2bd0ea18
NS
401 /* 0x00000008 -- currently unused */
402#define XFS_MOUNT_FS_SHUTDOWN 0x00000010 /* atomic stop of all filesystem
403 operations, typically for
404 disk errors in metadata */
405#define XFS_MOUNT_NOATIME 0x00000020 /* don't modify inode access
406 times on reads */
5000d01d
SL
407#define XFS_MOUNT_RETERR 0x00000040 /* return alignment errors to
408 user */
409#define XFS_MOUNT_NOALIGN 0x00000080 /* turn off stripe alignment
2bd0ea18 410 allocations */
5000d01d 411 /* 0x00000100 -- currently unused */
eae766ca 412 /* 0x00000200 -- currently unused */
5000d01d
SL
413#define XFS_MOUNT_NORECOVERY 0x00000400 /* no recovery - dirty fs */
414#define XFS_MOUNT_SHARED 0x00000800 /* shared mount */
415#define XFS_MOUNT_DFLT_IOSIZE 0x00001000 /* set default i/o size */
416#define XFS_MOUNT_OSYNCISOSYNC 0x00002000 /* o_sync is REALLY o_sync */
5ffc734a 417 /* osyncisdsync is now default*/
fc8202ba 418#define XFS_MOUNT_NOUUID 0x00004000 /* ignore uuid during mount */
6d1d29a7
NS
419#define XFS_MOUNT_32BITINODES 0x00008000 /* do not create inodes above
420 * 32 bits in size */
32181a02 421#define XFS_MOUNT_NOLOGFLUSH 0x00010000
2bd0ea18 422
5000d01d 423#define XFS_FORCED_SHUTDOWN(mp) ((mp)->m_flags & XFS_MOUNT_FS_SHUTDOWN)
2bd0ea18
NS
424
425/*
426 * Default minimum read and write sizes.
427 */
f9e56f43
NS
428#define XFS_READIO_LOG_LARGE 16
429#define XFS_WRITEIO_LOG_LARGE 16
2e72c460
ES
430/*
431 * Default allocation size
432 */
433#define XFS_WRITE_IO_LOG 16
2bd0ea18
NS
434
435/*
13f0b353 436 * Max and min values for UIO and mount-option defined I/O sizes;
5000d01d 437 * min value can't be less than a page. Currently unused.
2bd0ea18
NS
438 */
439#define XFS_MAX_IO_LOG 16 /* 64K */
13f0b353 440#define XFS_MIN_IO_LOG PAGE_SHIFT
2bd0ea18
NS
441
442/*
443 * Synchronous read and write sizes. This should be
444 * better for NFSv2 wsync filesystems.
445 */
5000d01d
SL
446#define XFS_WSYNC_READIO_LOG 15 /* 32K */
447#define XFS_WSYNC_WRITEIO_LOG 14 /* 16K */
2bd0ea18 448
eae766ca
NS
449#define xfs_force_shutdown(m,f) \
450 VFS_FORCE_SHUTDOWN((XFS_MTOVFS(m)), f, __FILE__, __LINE__)
451
5000d01d 452/*
2bd0ea18
NS
453 * Flags sent to xfs_force_shutdown.
454 */
455#define XFS_METADATA_IO_ERROR 0x1
456#define XFS_LOG_IO_ERROR 0x2
457#define XFS_FORCE_UMOUNT 0x4
eae766ca
NS
458#define XFS_CORRUPT_INCORE 0x8 /* Corrupt in-memory data structures */
459#define XFS_SHUTDOWN_REMOTE_REQ 0x10 /* Shutdown came from remote cell */
2bd0ea18
NS
460
461/*
462 * xflags for xfs_syncsub
463 */
464#define XFS_XSYNC_RELOC 0x01
465
466/*
467 * Flags for xfs_mountfs
468 */
eae766ca 469#define XFS_MFSI_SECOND 0x01 /* Secondary mount -- skip stuff */
5000d01d 470#define XFS_MFSI_CLIENT 0x02 /* Is a client -- skip lots of stuff */
2bd0ea18
NS
471#define XFS_MFSI_NOUNLINK 0x08 /* Skip unlinked inode processing in */
472 /* log recovery */
473
474/*
475 * Macros for getting from mount to vfs and back.
476 */
477#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MTOVFS)
478struct vfs *xfs_mtovfs(xfs_mount_t *mp);
5000d01d 479#define XFS_MTOVFS(mp) xfs_mtovfs(mp)
2bd0ea18 480#else
5000d01d 481#define XFS_MTOVFS(mp) (bhvtovfs(&(mp)->m_bhv))
2bd0ea18
NS
482#endif
483#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BHVTOM)
484xfs_mount_t *xfs_bhvtom(bhv_desc_t *bdp);
5000d01d 485#define XFS_BHVTOM(bdp) xfs_bhvtom(bdp)
2bd0ea18 486#else
5000d01d 487#define XFS_BHVTOM(bdp) ((xfs_mount_t *)BHV_PDATA(bdp))
2bd0ea18 488#endif
eae766ca
NS
489#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_VFSTOM)
490xfs_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
5000d01d 496
2bd0ea18
NS
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)
503xfs_agnumber_t xfs_daddr_to_agno(struct xfs_mount *mp, xfs_daddr_t d);
5000d01d 504#define XFS_DADDR_TO_AGNO(mp,d) xfs_daddr_to_agno(mp,d)
2bd0ea18
NS
505#else
506
507static inline xfs_agnumber_t XFS_DADDR_TO_AGNO(xfs_mount_t *mp, xfs_daddr_t d)
508{
5000d01d
SL
509 d = XFS_BB_TO_FSBT(mp, d);
510 do_div(d, mp->m_sb.sb_agblocks);
511 return (xfs_agnumber_t) d;
2bd0ea18
NS
512}
513
514#endif
515#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DADDR_TO_AGBNO)
516xfs_agblock_t xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d);
5000d01d 517#define XFS_DADDR_TO_AGBNO(mp,d) xfs_daddr_to_agbno(mp,d)
2bd0ea18
NS
518#else
519
520static inline xfs_agblock_t XFS_DADDR_TO_AGBNO(xfs_mount_t *mp, xfs_daddr_t d)
521{
5000d01d
SL
522 d = XFS_BB_TO_FSBT(mp, d);
523 return (xfs_agblock_t) do_div(d, mp->m_sb.sb_agblocks);
2bd0ea18
NS
524}
525
526#endif
527
528/*
529 * This structure is for use by the xfs_mod_incore_sb_batch() routine.
530 */
531typedef struct xfs_mod_sb {
532 xfs_sb_field_t msb_field; /* Field to modify, see below */
eae766ca 533 int msb_delta; /* Change to make to specified field */
2bd0ea18
NS
534} xfs_mod_sb_t;
535
5000d01d
SL
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))
2bd0ea18 540
eae766ca
NS
541extern xfs_mount_t *xfs_mount_init(void);
542extern void xfs_mod_sb(xfs_trans_t *, __int64_t);
543extern void xfs_mount_free(xfs_mount_t *mp, int remove_bhv);
544extern int xfs_mountfs(struct vfs *, xfs_mount_t *mp, dev_t, int);
545
546extern int xfs_unmountfs(xfs_mount_t *, struct cred *);
547extern void xfs_uuid_unmount(xfs_mount_t *mp);
548extern void xfs_unmountfs_close(xfs_mount_t *, struct cred *);
549extern int xfs_unmountfs_writesb(xfs_mount_t *);
550extern int xfs_unmount_flush(xfs_mount_t *, int);
551extern int xfs_mod_incore_sb(xfs_mount_t *, xfs_sb_field_t, int, int);
552extern int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *,
553 uint, int);
554extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int);
555extern int xfs_readsb(xfs_mount_t *mp);
556extern void xfs_freesb(xfs_mount_t *);
557extern void xfs_do_force_shutdown(bhv_desc_t *, int, char *, int);
558extern int xfs_syncsub(xfs_mount_t *, int, int, int *);
559extern void xfs_initialize_perag(xfs_mount_t *, int);
560extern void xfs_xlatesb(void *, struct xfs_sb *, int, xfs_arch_t,
561 __int64_t);
d9eab45c 562
0ddd9902
NS
563/*
564 * Flags for freeze operations.
565 */
d9eab45c
SL
566#define XFS_FREEZE_WRITE 1
567#define XFS_FREEZE_TRANS 2
568
eae766ca
NS
569extern void xfs_start_freeze(xfs_mount_t *, int);
570extern void xfs_finish_freeze(xfs_mount_t *);
571extern void xfs_check_frozen(xfs_mount_t *, bhv_desc_t *, int);
572
573extern struct vfsops xfs_vfsops;
574extern struct vnodeops xfs_vnodeops;
575
576extern struct xfs_dmops xfs_dmcore_xfs;
577extern struct xfs_qmops xfs_qmcore_xfs;
578extern struct xfs_ioops xfs_iocore_xfs;
d9eab45c 579
eae766ca
NS
580extern int xfs_init(void);
581extern void xfs_cleanup(void);
2bd0ea18
NS
582
583#endif /* __KERNEL__ */
584
585#endif /* __XFS_MOUNT_H__ */