1
2
3
4
5
6#ifndef __XFS_MOUNT_H__
7#define __XFS_MOUNT_H__
8
9struct xlog;
10struct xfs_inode;
11struct xfs_mru_cache;
12struct xfs_ail;
13struct xfs_quotainfo;
14struct xfs_da_geometry;
15struct xfs_perag;
16
17
18enum {
19 XFS_LOWSP_1_PCNT = 0,
20 XFS_LOWSP_2_PCNT,
21 XFS_LOWSP_3_PCNT,
22 XFS_LOWSP_4_PCNT,
23 XFS_LOWSP_5_PCNT,
24 XFS_LOWSP_MAX,
25};
26
27
28
29
30
31
32
33enum {
34 XFS_ERR_METADATA,
35 XFS_ERR_CLASS_MAX,
36};
37enum {
38 XFS_ERR_DEFAULT,
39 XFS_ERR_EIO,
40 XFS_ERR_ENOSPC,
41 XFS_ERR_ENODEV,
42 XFS_ERR_ERRNO_MAX,
43};
44
45#define XFS_ERR_RETRY_FOREVER -1
46
47
48
49
50
51
52
53struct xfs_error_cfg {
54 struct xfs_kobj kobj;
55 int max_retries;
56 long retry_timeout;
57};
58
59
60
61
62struct xfs_inodegc {
63 struct llist_head list;
64 struct work_struct work;
65
66
67 unsigned int items;
68 unsigned int shrinker_hits;
69};
70
71
72
73
74
75
76
77
78
79
80typedef struct xfs_mount {
81 struct xfs_sb m_sb;
82 struct super_block *m_super;
83 struct xfs_ail *m_ail;
84 struct xfs_buf *m_sb_bp;
85 char *m_rtname;
86 char *m_logname;
87 struct xfs_da_geometry *m_dir_geo;
88 struct xfs_da_geometry *m_attr_geo;
89 struct xlog *m_log;
90 struct xfs_inode *m_rbmip;
91 struct xfs_inode *m_rsumip;
92 struct xfs_inode *m_rootip;
93 struct xfs_quotainfo *m_quotainfo;
94 xfs_buftarg_t *m_ddev_targp;
95 xfs_buftarg_t *m_logdev_targp;
96 xfs_buftarg_t *m_rtdev_targp;
97 struct list_head m_mount_list;
98 void __percpu *m_inodegc;
99
100
101
102
103
104
105
106 uint8_t *m_rsum_cache;
107 struct xfs_mru_cache *m_filestream;
108 struct workqueue_struct *m_buf_workqueue;
109 struct workqueue_struct *m_unwritten_workqueue;
110 struct workqueue_struct *m_reclaim_workqueue;
111 struct workqueue_struct *m_sync_workqueue;
112 struct workqueue_struct *m_blockgc_wq;
113 struct workqueue_struct *m_inodegc_wq;
114
115 int m_bsize;
116 uint8_t m_blkbit_log;
117 uint8_t m_blkbb_log;
118 uint8_t m_agno_log;
119 uint8_t m_sectbb_log;
120 uint m_blockmask;
121 uint m_blockwsize;
122 uint m_blockwmask;
123 uint m_alloc_mxr[2];
124 uint m_alloc_mnr[2];
125 uint m_bmap_dmxr[2];
126 uint m_bmap_dmnr[2];
127 uint m_rmap_mxr[2];
128 uint m_rmap_mnr[2];
129 uint m_refc_mxr[2];
130 uint m_refc_mnr[2];
131 uint m_ag_maxlevels;
132 uint m_bm_maxlevels[2];
133 uint m_rmap_maxlevels;
134 uint m_refc_maxlevels;
135 xfs_extlen_t m_ag_prealloc_blocks;
136 uint m_alloc_set_aside;
137 uint m_ag_max_usable;
138 int m_dalign;
139 int m_swidth;
140 xfs_agnumber_t m_maxagi;
141 uint m_allocsize_log;
142 uint m_allocsize_blocks;
143 int m_logbufs;
144 int m_logbsize;
145 uint m_rsumlevels;
146 uint m_rsumsize;
147 int m_fixedfsid[2];
148 uint m_qflags;
149 uint64_t m_features;
150 uint64_t m_low_space[XFS_LOWSP_MAX];
151 uint64_t m_low_rtexts[XFS_LOWSP_MAX];
152 struct xfs_ino_geometry m_ino_geo;
153 struct xfs_trans_resv m_resv;
154
155 unsigned long m_opstate;
156 bool m_always_cow;
157 bool m_fail_unmount;
158 bool m_finobt_nores;
159 bool m_update_sb;
160
161
162
163
164
165 uint8_t m_fs_checked;
166 uint8_t m_fs_sick;
167
168
169
170
171 uint8_t m_rt_checked;
172 uint8_t m_rt_sick;
173
174
175
176
177
178
179
180
181 spinlock_t ____cacheline_aligned m_sb_lock;
182 struct percpu_counter m_icount;
183 struct percpu_counter m_ifree;
184 struct percpu_counter m_fdblocks;
185
186
187
188
189
190 struct percpu_counter m_delalloc_blks;
191
192
193
194
195
196 atomic64_t m_allocbt_blks;
197
198 struct radix_tree_root m_perag_tree;
199 spinlock_t m_perag_lock;
200 uint64_t m_resblks;
201 uint64_t m_resblks_avail;
202 uint64_t m_resblks_save;
203 struct delayed_work m_reclaim_work;
204 struct xfs_kobj m_kobj;
205 struct xfs_kobj m_error_kobj;
206 struct xfs_kobj m_error_meta_kobj;
207 struct xfs_error_cfg m_error_cfg[XFS_ERR_CLASS_MAX][XFS_ERR_ERRNO_MAX];
208 struct xstats m_stats;
209 xfs_agnumber_t m_agfrotor;
210 xfs_agnumber_t m_agirotor;
211 spinlock_t m_agirotor_lock;
212
213
214 struct shrinker m_inodegc_shrinker;
215
216
217
218
219 struct work_struct m_flush_inodes_work;
220
221
222
223
224
225
226
227
228
229
230 uint32_t m_generation;
231 struct mutex m_growlock;
232
233#ifdef DEBUG
234
235
236
237
238
239 unsigned int *m_errortag;
240 struct xfs_kobj m_errortag_kobj;
241#endif
242} xfs_mount_t;
243
244#define M_IGEO(mp) (&(mp)->m_ino_geo)
245
246
247
248
249
250
251
252#define XFS_FEAT_ATTR (1ULL << 0)
253#define XFS_FEAT_NLINK (1ULL << 1)
254#define XFS_FEAT_QUOTA (1ULL << 2)
255#define XFS_FEAT_ALIGN (1ULL << 3)
256#define XFS_FEAT_DALIGN (1ULL << 4)
257#define XFS_FEAT_LOGV2 (1ULL << 5)
258#define XFS_FEAT_SECTOR (1ULL << 6)
259#define XFS_FEAT_EXTFLG (1ULL << 7)
260#define XFS_FEAT_ASCIICI (1ULL << 8)
261#define XFS_FEAT_LAZYSBCOUNT (1ULL << 9)
262#define XFS_FEAT_ATTR2 (1ULL << 10)
263#define XFS_FEAT_PARENT (1ULL << 11)
264#define XFS_FEAT_PROJID32 (1ULL << 12)
265#define XFS_FEAT_CRC (1ULL << 13)
266#define XFS_FEAT_V3INODES (1ULL << 14)
267#define XFS_FEAT_PQUOTINO (1ULL << 15)
268#define XFS_FEAT_FTYPE (1ULL << 16)
269#define XFS_FEAT_FINOBT (1ULL << 17)
270#define XFS_FEAT_RMAPBT (1ULL << 18)
271#define XFS_FEAT_REFLINK (1ULL << 19)
272#define XFS_FEAT_SPINODES (1ULL << 20)
273#define XFS_FEAT_META_UUID (1ULL << 21)
274#define XFS_FEAT_REALTIME (1ULL << 22)
275#define XFS_FEAT_INOBTCNT (1ULL << 23)
276#define XFS_FEAT_BIGTIME (1ULL << 24)
277#define XFS_FEAT_NEEDSREPAIR (1ULL << 25)
278
279
280#define XFS_FEAT_NOATTR2 (1ULL << 48)
281#define XFS_FEAT_NOALIGN (1ULL << 49)
282#define XFS_FEAT_ALLOCSIZE (1ULL << 50)
283#define XFS_FEAT_LARGE_IOSIZE (1ULL << 51)
284
285#define XFS_FEAT_WSYNC (1ULL << 52)
286#define XFS_FEAT_DIRSYNC (1ULL << 53)
287#define XFS_FEAT_DISCARD (1ULL << 54)
288#define XFS_FEAT_GRPID (1ULL << 55)
289#define XFS_FEAT_SMALL_INUMS (1ULL << 56)
290#define XFS_FEAT_IKEEP (1ULL << 57)
291#define XFS_FEAT_SWALLOC (1ULL << 58)
292#define XFS_FEAT_FILESTREAMS (1ULL << 59)
293#define XFS_FEAT_DAX_ALWAYS (1ULL << 60)
294#define XFS_FEAT_DAX_NEVER (1ULL << 61)
295#define XFS_FEAT_NORECOVERY (1ULL << 62)
296#define XFS_FEAT_NOUUID (1ULL << 63)
297
298#define __XFS_HAS_FEAT(name, NAME) \
299static inline bool xfs_has_ ## name (struct xfs_mount *mp) \
300{ \
301 return mp->m_features & XFS_FEAT_ ## NAME; \
302}
303
304
305#define __XFS_ADD_FEAT(name, NAME) \
306 __XFS_HAS_FEAT(name, NAME); \
307static inline void xfs_add_ ## name (struct xfs_mount *mp) \
308{ \
309 mp->m_features |= XFS_FEAT_ ## NAME; \
310 xfs_sb_version_add ## name(&mp->m_sb); \
311}
312
313
314__XFS_ADD_FEAT(attr, ATTR)
315__XFS_HAS_FEAT(nlink, NLINK)
316__XFS_ADD_FEAT(quota, QUOTA)
317__XFS_HAS_FEAT(align, ALIGN)
318__XFS_HAS_FEAT(dalign, DALIGN)
319__XFS_HAS_FEAT(logv2, LOGV2)
320__XFS_HAS_FEAT(sector, SECTOR)
321__XFS_HAS_FEAT(extflg, EXTFLG)
322__XFS_HAS_FEAT(asciici, ASCIICI)
323__XFS_HAS_FEAT(lazysbcount, LAZYSBCOUNT)
324__XFS_ADD_FEAT(attr2, ATTR2)
325__XFS_HAS_FEAT(parent, PARENT)
326__XFS_ADD_FEAT(projid32, PROJID32)
327__XFS_HAS_FEAT(crc, CRC)
328__XFS_HAS_FEAT(v3inodes, V3INODES)
329__XFS_HAS_FEAT(pquotino, PQUOTINO)
330__XFS_HAS_FEAT(ftype, FTYPE)
331__XFS_HAS_FEAT(finobt, FINOBT)
332__XFS_HAS_FEAT(rmapbt, RMAPBT)
333__XFS_HAS_FEAT(reflink, REFLINK)
334__XFS_HAS_FEAT(sparseinodes, SPINODES)
335__XFS_HAS_FEAT(metauuid, META_UUID)
336__XFS_HAS_FEAT(realtime, REALTIME)
337__XFS_HAS_FEAT(inobtcounts, INOBTCNT)
338__XFS_HAS_FEAT(bigtime, BIGTIME)
339__XFS_HAS_FEAT(needsrepair, NEEDSREPAIR)
340
341
342
343
344
345
346
347
348__XFS_HAS_FEAT(noattr2, NOATTR2)
349__XFS_HAS_FEAT(noalign, NOALIGN)
350__XFS_HAS_FEAT(allocsize, ALLOCSIZE)
351__XFS_HAS_FEAT(large_iosize, LARGE_IOSIZE)
352__XFS_HAS_FEAT(wsync, WSYNC)
353__XFS_HAS_FEAT(dirsync, DIRSYNC)
354__XFS_HAS_FEAT(discard, DISCARD)
355__XFS_HAS_FEAT(grpid, GRPID)
356__XFS_HAS_FEAT(small_inums, SMALL_INUMS)
357__XFS_HAS_FEAT(ikeep, IKEEP)
358__XFS_HAS_FEAT(swalloc, SWALLOC)
359__XFS_HAS_FEAT(filestreams, FILESTREAMS)
360__XFS_HAS_FEAT(dax_always, DAX_ALWAYS)
361__XFS_HAS_FEAT(dax_never, DAX_NEVER)
362__XFS_HAS_FEAT(norecovery, NORECOVERY)
363__XFS_HAS_FEAT(nouuid, NOUUID)
364
365
366
367
368
369
370#define XFS_OPSTATE_UNMOUNTING 0
371#define XFS_OPSTATE_CLEAN 1
372#define XFS_OPSTATE_SHUTDOWN 2
373#define XFS_OPSTATE_INODE32 3
374#define XFS_OPSTATE_READONLY 4
375
376
377
378
379
380
381#define XFS_OPSTATE_INODEGC_ENABLED 5
382
383
384
385
386
387#define XFS_OPSTATE_BLOCKGC_ENABLED 6
388
389#define __XFS_IS_OPSTATE(name, NAME) \
390static inline bool xfs_is_ ## name (struct xfs_mount *mp) \
391{ \
392 return test_bit(XFS_OPSTATE_ ## NAME, &mp->m_opstate); \
393} \
394static inline bool xfs_clear_ ## name (struct xfs_mount *mp) \
395{ \
396 return test_and_clear_bit(XFS_OPSTATE_ ## NAME, &mp->m_opstate); \
397} \
398static inline bool xfs_set_ ## name (struct xfs_mount *mp) \
399{ \
400 return test_and_set_bit(XFS_OPSTATE_ ## NAME, &mp->m_opstate); \
401}
402
403__XFS_IS_OPSTATE(unmounting, UNMOUNTING)
404__XFS_IS_OPSTATE(clean, CLEAN)
405__XFS_IS_OPSTATE(shutdown, SHUTDOWN)
406__XFS_IS_OPSTATE(inode32, INODE32)
407__XFS_IS_OPSTATE(readonly, READONLY)
408__XFS_IS_OPSTATE(inodegc_enabled, INODEGC_ENABLED)
409__XFS_IS_OPSTATE(blockgc_enabled, BLOCKGC_ENABLED)
410
411#define XFS_OPSTATE_STRINGS \
412 { (1UL << XFS_OPSTATE_UNMOUNTING), "unmounting" }, \
413 { (1UL << XFS_OPSTATE_CLEAN), "clean" }, \
414 { (1UL << XFS_OPSTATE_SHUTDOWN), "shutdown" }, \
415 { (1UL << XFS_OPSTATE_INODE32), "inode32" }, \
416 { (1UL << XFS_OPSTATE_READONLY), "read_only" }, \
417 { (1UL << XFS_OPSTATE_INODEGC_ENABLED), "inodegc" }, \
418 { (1UL << XFS_OPSTATE_BLOCKGC_ENABLED), "blockgc" }
419
420
421
422
423
424#define XFS_MAX_IO_LOG 30
425#define XFS_MIN_IO_LOG PAGE_SHIFT
426
427#define xfs_is_shutdown(mp) xfs_is_shutdown(mp)
428void xfs_do_force_shutdown(struct xfs_mount *mp, int flags, char *fname,
429 int lnnum);
430#define xfs_force_shutdown(m,f) \
431 xfs_do_force_shutdown(m, f, __FILE__, __LINE__)
432
433#define SHUTDOWN_META_IO_ERROR 0x0001
434#define SHUTDOWN_LOG_IO_ERROR 0x0002
435#define SHUTDOWN_FORCE_UMOUNT 0x0004
436#define SHUTDOWN_CORRUPT_INCORE 0x0008
437
438#define XFS_SHUTDOWN_STRINGS \
439 { SHUTDOWN_META_IO_ERROR, "metadata_io" }, \
440 { SHUTDOWN_LOG_IO_ERROR, "log_io" }, \
441 { SHUTDOWN_FORCE_UMOUNT, "force_umount" }, \
442 { SHUTDOWN_CORRUPT_INCORE, "corruption" }
443
444
445
446
447#define XFS_MFSI_QUIET 0x40
448
449static inline xfs_agnumber_t
450xfs_daddr_to_agno(struct xfs_mount *mp, xfs_daddr_t d)
451{
452 xfs_rfsblock_t ld = XFS_BB_TO_FSBT(mp, d);
453 do_div(ld, mp->m_sb.sb_agblocks);
454 return (xfs_agnumber_t) ld;
455}
456
457static inline xfs_agblock_t
458xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d)
459{
460 xfs_rfsblock_t ld = XFS_BB_TO_FSBT(mp, d);
461 return (xfs_agblock_t) do_div(ld, mp->m_sb.sb_agblocks);
462}
463
464int xfs_buf_hash_init(struct xfs_perag *pag);
465void xfs_buf_hash_destroy(struct xfs_perag *pag);
466
467extern void xfs_uuid_table_free(void);
468extern uint64_t xfs_default_resblks(xfs_mount_t *mp);
469extern int xfs_mountfs(xfs_mount_t *mp);
470extern void xfs_unmountfs(xfs_mount_t *);
471
472
473
474
475
476
477
478
479#define XFS_FDBLOCKS_BATCH 1024
480
481extern int xfs_mod_fdblocks(struct xfs_mount *mp, int64_t delta,
482 bool reserved);
483extern int xfs_mod_frextents(struct xfs_mount *mp, int64_t delta);
484
485extern int xfs_readsb(xfs_mount_t *, int);
486extern void xfs_freesb(xfs_mount_t *);
487extern bool xfs_fs_writable(struct xfs_mount *mp, int level);
488extern int xfs_sb_validate_fsb_count(struct xfs_sb *, uint64_t);
489
490extern int xfs_dev_is_read_only(struct xfs_mount *, char *);
491
492extern void xfs_set_low_space_thresholds(struct xfs_mount *);
493
494int xfs_zero_extent(struct xfs_inode *ip, xfs_fsblock_t start_fsb,
495 xfs_off_t count_fsb);
496
497struct xfs_error_cfg * xfs_error_get_cfg(struct xfs_mount *mp,
498 int error_class, int error);
499void xfs_force_summary_recalc(struct xfs_mount *mp);
500int xfs_add_incompat_log_feature(struct xfs_mount *mp, uint32_t feature);
501bool xfs_clear_incompat_log_features(struct xfs_mount *mp);
502void xfs_mod_delalloc(struct xfs_mount *mp, int64_t delta);
503
504#endif
505