1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#ifndef __XFS_MOUNT_H__
19#define __XFS_MOUNT_H__
20
21typedef struct xfs_trans_reservations {
22 uint tr_write;
23 uint tr_itruncate;
24 uint tr_rename;
25 uint tr_link;
26 uint tr_remove;
27 uint tr_symlink;
28 uint tr_create;
29 uint tr_mkdir;
30 uint tr_ifree;
31 uint tr_ichange;
32 uint tr_growdata;
33 uint tr_swrite;
34 uint tr_addafork;
35 uint tr_writeid;
36 uint tr_attrinval;
37 uint tr_attrset;
38 uint tr_attrrm;
39 uint tr_clearagi;
40 uint tr_growrtalloc;
41 uint tr_growrtzero;
42 uint tr_growrtfree;
43} xfs_trans_reservations_t;
44
45#ifndef __KERNEL__
46
47#define xfs_daddr_to_agno(mp,d) \
48 ((xfs_agnumber_t)(XFS_BB_TO_FSBT(mp, d) / (mp)->m_sb.sb_agblocks))
49#define xfs_daddr_to_agbno(mp,d) \
50 ((xfs_agblock_t)(XFS_BB_TO_FSBT(mp, d) % (mp)->m_sb.sb_agblocks))
51
52#else
53
54#include "xfs_sync.h"
55
56struct xlog;
57struct xfs_mount_args;
58struct xfs_inode;
59struct xfs_bmbt_irec;
60struct xfs_bmap_free;
61struct xfs_extdelta;
62struct xfs_swapext;
63struct xfs_mru_cache;
64struct xfs_nameops;
65struct xfs_ail;
66struct xfs_quotainfo;
67
68#ifdef HAVE_PERCPU_SB
69
70
71
72
73
74
75
76
77typedef struct xfs_icsb_cnts {
78 uint64_t icsb_fdblocks;
79 uint64_t icsb_ifree;
80 uint64_t icsb_icount;
81 unsigned long icsb_flags;
82} xfs_icsb_cnts_t;
83
84#define XFS_ICSB_FLAG_LOCK (1 << 0)
85
86#define XFS_ICSB_LAZY_COUNT (1 << 1)
87
88extern int xfs_icsb_init_counters(struct xfs_mount *);
89extern void xfs_icsb_reinit_counters(struct xfs_mount *);
90extern void xfs_icsb_destroy_counters(struct xfs_mount *);
91extern void xfs_icsb_sync_counters(struct xfs_mount *, int);
92extern void xfs_icsb_sync_counters_locked(struct xfs_mount *, int);
93extern int xfs_icsb_modify_counters(struct xfs_mount *, xfs_sb_field_t,
94 int64_t, int);
95
96#else
97#define xfs_icsb_init_counters(mp) (0)
98#define xfs_icsb_destroy_counters(mp) do { } while (0)
99#define xfs_icsb_reinit_counters(mp) do { } while (0)
100#define xfs_icsb_sync_counters(mp, flags) do { } while (0)
101#define xfs_icsb_sync_counters_locked(mp, flags) do { } while (0)
102#define xfs_icsb_modify_counters(mp, field, delta, rsvd) \
103 xfs_mod_incore_sb(mp, field, delta, rsvd)
104#endif
105
106
107enum {
108 XFS_LOWSP_1_PCNT = 0,
109 XFS_LOWSP_2_PCNT,
110 XFS_LOWSP_3_PCNT,
111 XFS_LOWSP_4_PCNT,
112 XFS_LOWSP_5_PCNT,
113 XFS_LOWSP_MAX,
114};
115
116typedef struct xfs_mount {
117 struct super_block *m_super;
118 xfs_tid_t m_tid;
119 struct xfs_ail *m_ail;
120 xfs_sb_t m_sb;
121 spinlock_t m_sb_lock;
122 struct xfs_buf *m_sb_bp;
123 char *m_fsname;
124 int m_fsname_len;
125 char *m_rtname;
126 char *m_logname;
127 int m_bsize;
128 xfs_agnumber_t m_agfrotor;
129 xfs_agnumber_t m_agirotor;
130 spinlock_t m_agirotor_lock;
131 xfs_agnumber_t m_maxagi;
132 uint m_readio_log;
133 uint m_readio_blocks;
134 uint m_writeio_log;
135 uint m_writeio_blocks;
136 struct xlog *m_log;
137 int m_logbufs;
138 int m_logbsize;
139 uint m_rsumlevels;
140 uint m_rsumsize;
141 struct xfs_inode *m_rbmip;
142 struct xfs_inode *m_rsumip;
143 struct xfs_inode *m_rootip;
144 struct xfs_quotainfo *m_quotainfo;
145 xfs_buftarg_t *m_ddev_targp;
146 xfs_buftarg_t *m_logdev_targp;
147 xfs_buftarg_t *m_rtdev_targp;
148 __uint8_t m_blkbit_log;
149 __uint8_t m_blkbb_log;
150 __uint8_t m_agno_log;
151 __uint8_t m_agino_log;
152 __uint16_t m_inode_cluster_size;
153 uint m_blockmask;
154 uint m_blockwsize;
155 uint m_blockwmask;
156 uint m_alloc_mxr[2];
157 uint m_alloc_mnr[2];
158 uint m_bmap_dmxr[2];
159 uint m_bmap_dmnr[2];
160 uint m_inobt_mxr[2];
161 uint m_inobt_mnr[2];
162 uint m_ag_maxlevels;
163 uint m_bm_maxlevels[2];
164 uint m_in_maxlevels;
165 struct radix_tree_root m_perag_tree;
166 spinlock_t m_perag_lock;
167 struct mutex m_growlock;
168 int m_fixedfsid[2];
169 uint m_dmevmask;
170 __uint64_t m_flags;
171 uint m_dir_node_ents;
172 uint m_attr_node_ents;
173 int m_ialloc_inos;
174 int m_ialloc_blks;
175 int m_inoalign_mask;
176 uint m_qflags;
177 xfs_trans_reservations_t m_reservations;
178 __uint64_t m_maxicount;
179 __uint64_t m_resblks;
180 __uint64_t m_resblks_avail;
181 __uint64_t m_resblks_save;
182 int m_dalign;
183 int m_swidth;
184 int m_sinoalign;
185 int m_attr_magicpct;
186 int m_dir_magicpct;
187 __uint8_t m_sectbb_log;
188 const struct xfs_nameops *m_dirnameops;
189 int m_dirblksize;
190 int m_dirblkfsbs;
191 xfs_dablk_t m_dirdatablk;
192 xfs_dablk_t m_dirleafblk;
193 xfs_dablk_t m_dirfreeblk;
194 uint m_chsize;
195 struct xfs_chash *m_chash;
196
197 atomic_t m_active_trans;
198#ifdef HAVE_PERCPU_SB
199 xfs_icsb_cnts_t __percpu *m_sb_cnts;
200 unsigned long m_icsb_counters;
201 struct notifier_block m_icsb_notifier;
202 struct mutex m_icsb_mutex;
203#endif
204 struct xfs_mru_cache *m_filestream;
205 struct delayed_work m_sync_work;
206 struct delayed_work m_reclaim_work;
207 struct work_struct m_flush_work;
208 __int64_t m_update_flags;
209
210 struct shrinker m_inode_shrink;
211 int64_t m_low_space[XFS_LOWSP_MAX];
212
213
214 struct workqueue_struct *m_data_workqueue;
215 struct workqueue_struct *m_unwritten_workqueue;
216 struct workqueue_struct *m_cil_workqueue;
217} xfs_mount_t;
218
219
220
221
222#define XFS_MOUNT_WSYNC (1ULL << 0)
223
224
225#define XFS_MOUNT_WAS_CLEAN (1ULL << 3)
226#define XFS_MOUNT_FS_SHUTDOWN (1ULL << 4)
227
228
229#define XFS_MOUNT_DISCARD (1ULL << 5)
230#define XFS_MOUNT_RETERR (1ULL << 6)
231
232#define XFS_MOUNT_NOALIGN (1ULL << 7)
233
234#define XFS_MOUNT_ATTR2 (1ULL << 8)
235#define XFS_MOUNT_GRPID (1ULL << 9)
236#define XFS_MOUNT_NORECOVERY (1ULL << 10)
237#define XFS_MOUNT_DFLT_IOSIZE (1ULL << 12)
238#define XFS_MOUNT_32BITINODES (1ULL << 14)
239
240#define XFS_MOUNT_SMALL_INUMS (1ULL << 15)
241#define XFS_MOUNT_NOUUID (1ULL << 16)
242#define XFS_MOUNT_BARRIER (1ULL << 17)
243#define XFS_MOUNT_IKEEP (1ULL << 18)
244#define XFS_MOUNT_SWALLOC (1ULL << 19)
245
246#define XFS_MOUNT_RDONLY (1ULL << 20)
247#define XFS_MOUNT_DIRSYNC (1ULL << 21)
248#define XFS_MOUNT_COMPAT_IOSIZE (1ULL << 22)
249
250#define XFS_MOUNT_FILESTREAMS (1ULL << 24)
251
252#define XFS_MOUNT_NOATTR2 (1ULL << 25)
253
254
255
256
257
258#define XFS_READIO_LOG_LARGE 16
259#define XFS_WRITEIO_LOG_LARGE 16
260
261
262
263
264
265#define XFS_MAX_IO_LOG 30
266#define XFS_MIN_IO_LOG PAGE_SHIFT
267
268
269
270
271
272#define XFS_WSYNC_READIO_LOG 15
273#define XFS_WSYNC_WRITEIO_LOG 14
274
275
276
277
278
279
280
281
282
283
284
285
286
287static inline unsigned long
288xfs_preferred_iosize(xfs_mount_t *mp)
289{
290 if (mp->m_flags & XFS_MOUNT_COMPAT_IOSIZE)
291 return PAGE_CACHE_SIZE;
292 return (mp->m_swidth ?
293 (mp->m_swidth << mp->m_sb.sb_blocklog) :
294 ((mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) ?
295 (1 << (int)MAX(mp->m_readio_log, mp->m_writeio_log)) :
296 PAGE_CACHE_SIZE));
297}
298
299#define XFS_LAST_UNMOUNT_WAS_CLEAN(mp) \
300 ((mp)->m_flags & XFS_MOUNT_WAS_CLEAN)
301#define XFS_FORCED_SHUTDOWN(mp) ((mp)->m_flags & XFS_MOUNT_FS_SHUTDOWN)
302void xfs_do_force_shutdown(struct xfs_mount *mp, int flags, char *fname,
303 int lnnum);
304#define xfs_force_shutdown(m,f) \
305 xfs_do_force_shutdown(m, f, __FILE__, __LINE__)
306
307#define SHUTDOWN_META_IO_ERROR 0x0001
308#define SHUTDOWN_LOG_IO_ERROR 0x0002
309#define SHUTDOWN_FORCE_UMOUNT 0x0004
310#define SHUTDOWN_CORRUPT_INCORE 0x0008
311#define SHUTDOWN_REMOTE_REQ 0x0010
312#define SHUTDOWN_DEVICE_REQ 0x0020
313
314
315
316
317#define XFS_MFSI_QUIET 0x40
318
319static inline xfs_agnumber_t
320xfs_daddr_to_agno(struct xfs_mount *mp, xfs_daddr_t d)
321{
322 xfs_daddr_t ld = XFS_BB_TO_FSBT(mp, d);
323 do_div(ld, mp->m_sb.sb_agblocks);
324 return (xfs_agnumber_t) ld;
325}
326
327static inline xfs_agblock_t
328xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d)
329{
330 xfs_daddr_t ld = XFS_BB_TO_FSBT(mp, d);
331 return (xfs_agblock_t) do_div(ld, mp->m_sb.sb_agblocks);
332}
333
334
335
336
337struct xfs_perag *xfs_perag_get(struct xfs_mount *mp, xfs_agnumber_t agno);
338struct xfs_perag *xfs_perag_get_tag(struct xfs_mount *mp, xfs_agnumber_t agno,
339 int tag);
340void xfs_perag_put(struct xfs_perag *pag);
341
342
343
344
345#ifdef HAVE_PERCPU_SB
346static inline void
347xfs_icsb_lock(xfs_mount_t *mp)
348{
349 mutex_lock(&mp->m_icsb_mutex);
350}
351
352static inline void
353xfs_icsb_unlock(xfs_mount_t *mp)
354{
355 mutex_unlock(&mp->m_icsb_mutex);
356}
357#else
358#define xfs_icsb_lock(mp)
359#define xfs_icsb_unlock(mp)
360#endif
361
362
363
364
365
366typedef struct xfs_mod_sb {
367 xfs_sb_field_t msb_field;
368 int64_t msb_delta;
369} xfs_mod_sb_t;
370
371extern int xfs_log_sbcount(xfs_mount_t *);
372extern __uint64_t xfs_default_resblks(xfs_mount_t *mp);
373extern int xfs_mountfs(xfs_mount_t *mp);
374
375extern void xfs_unmountfs(xfs_mount_t *);
376extern int xfs_mod_incore_sb(xfs_mount_t *, xfs_sb_field_t, int64_t, int);
377extern int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *,
378 uint, int);
379extern int xfs_mount_log_sb(xfs_mount_t *, __int64_t);
380extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int);
381extern int xfs_readsb(xfs_mount_t *, int);
382extern void xfs_freesb(xfs_mount_t *);
383extern int xfs_fs_writable(xfs_mount_t *);
384extern int xfs_sb_validate_fsb_count(struct xfs_sb *, __uint64_t);
385
386extern int xfs_dev_is_read_only(struct xfs_mount *, char *);
387
388extern void xfs_set_low_space_thresholds(struct xfs_mount *);
389
390#endif
391
392extern void xfs_mod_sb(struct xfs_trans *, __int64_t);
393extern int xfs_initialize_perag(struct xfs_mount *, xfs_agnumber_t,
394 xfs_agnumber_t *);
395extern void xfs_sb_from_disk(struct xfs_mount *, struct xfs_dsb *);
396extern void xfs_sb_to_disk(struct xfs_dsb *, struct xfs_sb *, __int64_t);
397
398#endif
399