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