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
21struct xlog;
22struct xfs_inode;
23struct xfs_mru_cache;
24struct xfs_nameops;
25struct xfs_ail;
26struct xfs_quotainfo;
27struct xfs_dir_ops;
28struct xfs_da_geometry;
29
30
31enum {
32 XFS_LOWSP_1_PCNT = 0,
33 XFS_LOWSP_2_PCNT,
34 XFS_LOWSP_3_PCNT,
35 XFS_LOWSP_4_PCNT,
36 XFS_LOWSP_5_PCNT,
37 XFS_LOWSP_MAX,
38};
39
40
41
42
43
44
45
46enum {
47 XFS_ERR_METADATA,
48 XFS_ERR_CLASS_MAX,
49};
50enum {
51 XFS_ERR_DEFAULT,
52 XFS_ERR_EIO,
53 XFS_ERR_ENOSPC,
54 XFS_ERR_ENODEV,
55 XFS_ERR_ERRNO_MAX,
56};
57
58#define XFS_ERR_RETRY_FOREVER -1
59
60
61
62
63
64
65
66struct xfs_error_cfg {
67 struct xfs_kobj kobj;
68 int max_retries;
69 long retry_timeout;
70};
71
72typedef struct xfs_mount {
73 struct super_block *m_super;
74 xfs_tid_t m_tid;
75 struct xfs_ail *m_ail;
76
77 struct xfs_sb m_sb;
78 spinlock_t m_sb_lock;
79 struct percpu_counter m_icount;
80 struct percpu_counter m_ifree;
81 struct percpu_counter m_fdblocks;
82
83 struct xfs_buf *m_sb_bp;
84 char *m_fsname;
85 int m_fsname_len;
86 char *m_rtname;
87 char *m_logname;
88 int m_bsize;
89 xfs_agnumber_t m_agfrotor;
90 xfs_agnumber_t m_agirotor;
91 spinlock_t m_agirotor_lock;
92 xfs_agnumber_t m_maxagi;
93 uint m_readio_log;
94 uint m_readio_blocks;
95 uint m_writeio_log;
96 uint m_writeio_blocks;
97 struct xfs_da_geometry *m_dir_geo;
98 struct xfs_da_geometry *m_attr_geo;
99 struct xlog *m_log;
100 int m_logbufs;
101 int m_logbsize;
102 uint m_rsumlevels;
103 uint m_rsumsize;
104 struct xfs_inode *m_rbmip;
105 struct xfs_inode *m_rsumip;
106 struct xfs_inode *m_rootip;
107 struct xfs_quotainfo *m_quotainfo;
108 xfs_buftarg_t *m_ddev_targp;
109 xfs_buftarg_t *m_logdev_targp;
110 xfs_buftarg_t *m_rtdev_targp;
111 __uint8_t m_blkbit_log;
112 __uint8_t m_blkbb_log;
113 __uint8_t m_agno_log;
114 __uint8_t m_agino_log;
115 uint m_inode_cluster_size;
116 uint m_blockmask;
117 uint m_blockwsize;
118 uint m_blockwmask;
119 uint m_alloc_mxr[2];
120 uint m_alloc_mnr[2];
121 uint m_bmap_dmxr[2];
122 uint m_bmap_dmnr[2];
123 uint m_inobt_mxr[2];
124 uint m_inobt_mnr[2];
125 uint m_rmap_mxr[2];
126 uint m_rmap_mnr[2];
127 uint m_refc_mxr[2];
128 uint m_refc_mnr[2];
129 uint m_ag_maxlevels;
130 uint m_bm_maxlevels[2];
131 uint m_in_maxlevels;
132 uint m_rmap_maxlevels;
133 uint m_refc_maxlevels;
134 xfs_extlen_t m_ag_prealloc_blocks;
135 uint m_alloc_set_aside;
136 uint m_ag_max_usable;
137 struct radix_tree_root m_perag_tree;
138 spinlock_t m_perag_lock;
139 struct mutex m_growlock;
140 int m_fixedfsid[2];
141 uint m_dmevmask;
142 __uint64_t m_flags;
143 int m_ialloc_inos;
144 int m_ialloc_blks;
145 int m_ialloc_min_blks;
146
147 int m_inoalign_mask;
148 uint m_qflags;
149 struct xfs_trans_resv m_resv;
150 __uint64_t m_maxicount;
151 __uint64_t m_resblks;
152 __uint64_t m_resblks_avail;
153 __uint64_t m_resblks_save;
154 int m_dalign;
155 int m_swidth;
156 int m_sinoalign;
157 __uint8_t m_sectbb_log;
158 const struct xfs_nameops *m_dirnameops;
159 const struct xfs_dir_ops *m_dir_inode_ops;
160 const struct xfs_dir_ops *m_nondir_inode_ops;
161 uint m_chsize;
162 atomic_t m_active_trans;
163 struct xfs_mru_cache *m_filestream;
164 struct delayed_work m_reclaim_work;
165 struct delayed_work m_eofblocks_work;
166
167 struct delayed_work m_cowblocks_work;
168
169 bool m_update_sb;
170 int64_t m_low_space[XFS_LOWSP_MAX];
171
172 struct xfs_kobj m_kobj;
173 struct xfs_kobj m_error_kobj;
174 struct xfs_kobj m_error_meta_kobj;
175 struct xfs_error_cfg m_error_cfg[XFS_ERR_CLASS_MAX][XFS_ERR_ERRNO_MAX];
176 struct xstats m_stats;
177
178 struct workqueue_struct *m_buf_workqueue;
179 struct workqueue_struct *m_data_workqueue;
180 struct workqueue_struct *m_unwritten_workqueue;
181 struct workqueue_struct *m_cil_workqueue;
182 struct workqueue_struct *m_reclaim_workqueue;
183 struct workqueue_struct *m_log_workqueue;
184 struct workqueue_struct *m_eofblocks_workqueue;
185
186
187
188
189
190
191
192
193
194
195 __uint32_t m_generation;
196
197 bool m_fail_unmount;
198#ifdef DEBUG
199
200
201
202
203
204
205
206 bool m_fail_writes;
207#endif
208} xfs_mount_t;
209
210
211
212
213#define XFS_MOUNT_WSYNC (1ULL << 0)
214
215
216#define XFS_MOUNT_UNMOUNTING (1ULL << 1)
217#define XFS_MOUNT_WAS_CLEAN (1ULL << 3)
218#define XFS_MOUNT_FS_SHUTDOWN (1ULL << 4)
219
220
221#define XFS_MOUNT_DISCARD (1ULL << 5)
222#define XFS_MOUNT_NOALIGN (1ULL << 7)
223
224#define XFS_MOUNT_ATTR2 (1ULL << 8)
225#define XFS_MOUNT_GRPID (1ULL << 9)
226#define XFS_MOUNT_NORECOVERY (1ULL << 10)
227#define XFS_MOUNT_DFLT_IOSIZE (1ULL << 12)
228#define XFS_MOUNT_SMALL_INUMS (1ULL << 14)
229#define XFS_MOUNT_32BITINODES (1ULL << 15)
230#define XFS_MOUNT_NOUUID (1ULL << 16)
231#define XFS_MOUNT_BARRIER (1ULL << 17)
232#define XFS_MOUNT_IKEEP (1ULL << 18)
233#define XFS_MOUNT_SWALLOC (1ULL << 19)
234
235#define XFS_MOUNT_RDONLY (1ULL << 20)
236#define XFS_MOUNT_DIRSYNC (1ULL << 21)
237#define XFS_MOUNT_COMPAT_IOSIZE (1ULL << 22)
238
239#define XFS_MOUNT_FILESTREAMS (1ULL << 24)
240
241#define XFS_MOUNT_NOATTR2 (1ULL << 25)
242
243#define XFS_MOUNT_DAX (1ULL << 62)
244
245
246
247
248
249#define XFS_READIO_LOG_LARGE 16
250#define XFS_WRITEIO_LOG_LARGE 16
251
252
253
254
255
256#define XFS_MAX_IO_LOG 30
257#define XFS_MIN_IO_LOG PAGE_SHIFT
258
259
260
261
262
263#define XFS_WSYNC_READIO_LOG 15
264#define XFS_WSYNC_WRITEIO_LOG 14
265
266
267
268
269
270
271
272
273
274
275
276
277
278static inline unsigned long
279xfs_preferred_iosize(xfs_mount_t *mp)
280{
281 if (mp->m_flags & XFS_MOUNT_COMPAT_IOSIZE)
282 return PAGE_SIZE;
283 return (mp->m_swidth ?
284 (mp->m_swidth << mp->m_sb.sb_blocklog) :
285 ((mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) ?
286 (1 << (int)MAX(mp->m_readio_log, mp->m_writeio_log)) :
287 PAGE_SIZE));
288}
289
290#define XFS_LAST_UNMOUNT_WAS_CLEAN(mp) \
291 ((mp)->m_flags & XFS_MOUNT_WAS_CLEAN)
292#define XFS_FORCED_SHUTDOWN(mp) ((mp)->m_flags & XFS_MOUNT_FS_SHUTDOWN)
293void xfs_do_force_shutdown(struct xfs_mount *mp, int flags, char *fname,
294 int lnnum);
295#define xfs_force_shutdown(m,f) \
296 xfs_do_force_shutdown(m, f, __FILE__, __LINE__)
297
298#define SHUTDOWN_META_IO_ERROR 0x0001
299#define SHUTDOWN_LOG_IO_ERROR 0x0002
300#define SHUTDOWN_FORCE_UMOUNT 0x0004
301#define SHUTDOWN_CORRUPT_INCORE 0x0008
302#define SHUTDOWN_REMOTE_REQ 0x0010
303#define SHUTDOWN_DEVICE_REQ 0x0020
304
305
306
307
308#define XFS_MFSI_QUIET 0x40
309
310static inline xfs_agnumber_t
311xfs_daddr_to_agno(struct xfs_mount *mp, xfs_daddr_t d)
312{
313 xfs_daddr_t ld = XFS_BB_TO_FSBT(mp, d);
314 do_div(ld, mp->m_sb.sb_agblocks);
315 return (xfs_agnumber_t) ld;
316}
317
318static inline xfs_agblock_t
319xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d)
320{
321 xfs_daddr_t ld = XFS_BB_TO_FSBT(mp, d);
322 return (xfs_agblock_t) do_div(ld, mp->m_sb.sb_agblocks);
323}
324
325#ifdef DEBUG
326static inline bool
327xfs_mp_fail_writes(struct xfs_mount *mp)
328{
329 return mp->m_fail_writes;
330}
331#else
332static inline bool
333xfs_mp_fail_writes(struct xfs_mount *mp)
334{
335 return 0;
336}
337#endif
338
339
340enum xfs_ag_resv_type {
341 XFS_AG_RESV_NONE = 0,
342 XFS_AG_RESV_METADATA,
343 XFS_AG_RESV_AGFL,
344};
345
346struct xfs_ag_resv {
347
348 xfs_extlen_t ar_orig_reserved;
349
350 xfs_extlen_t ar_reserved;
351
352 xfs_extlen_t ar_asked;
353};
354
355
356
357
358
359typedef struct xfs_perag {
360 struct xfs_mount *pag_mount;
361 xfs_agnumber_t pag_agno;
362 atomic_t pag_ref;
363 char pagf_init;
364 char pagi_init;
365 char pagf_metadata;
366 char pagi_inodeok;
367 __uint8_t pagf_levels[XFS_BTNUM_AGF];
368
369 __uint32_t pagf_flcount;
370 xfs_extlen_t pagf_freeblks;
371 xfs_extlen_t pagf_longest;
372 __uint32_t pagf_btreeblks;
373 xfs_agino_t pagi_freecount;
374 xfs_agino_t pagi_count;
375
376
377
378
379
380
381 xfs_agino_t pagl_pagino;
382 xfs_agino_t pagl_leftrec;
383 xfs_agino_t pagl_rightrec;
384 spinlock_t pagb_lock;
385 struct rb_root pagb_tree;
386
387 atomic_t pagf_fstrms;
388
389 spinlock_t pag_ici_lock;
390 struct radix_tree_root pag_ici_root;
391 int pag_ici_reclaimable;
392 struct mutex pag_ici_reclaim_lock;
393 unsigned long pag_ici_reclaim_cursor;
394
395
396 spinlock_t pag_buf_lock;
397 struct rb_root pag_buf_tree;
398
399
400 struct rcu_head rcu_head;
401 int pagb_count;
402
403
404 struct xfs_ag_resv pag_meta_resv;
405
406 struct xfs_ag_resv pag_agfl_resv;
407
408
409 __uint8_t pagf_refcount_level;
410} xfs_perag_t;
411
412static inline struct xfs_ag_resv *
413xfs_perag_resv(
414 struct xfs_perag *pag,
415 enum xfs_ag_resv_type type)
416{
417 switch (type) {
418 case XFS_AG_RESV_METADATA:
419 return &pag->pag_meta_resv;
420 case XFS_AG_RESV_AGFL:
421 return &pag->pag_agfl_resv;
422 default:
423 return NULL;
424 }
425}
426
427extern void xfs_uuid_table_free(void);
428extern int xfs_log_sbcount(xfs_mount_t *);
429extern __uint64_t xfs_default_resblks(xfs_mount_t *mp);
430extern int xfs_mountfs(xfs_mount_t *mp);
431extern int xfs_initialize_perag(xfs_mount_t *mp, xfs_agnumber_t agcount,
432 xfs_agnumber_t *maxagi);
433extern void xfs_unmountfs(xfs_mount_t *);
434
435extern int xfs_mod_icount(struct xfs_mount *mp, int64_t delta);
436extern int xfs_mod_ifree(struct xfs_mount *mp, int64_t delta);
437extern int xfs_mod_fdblocks(struct xfs_mount *mp, int64_t delta,
438 bool reserved);
439extern int xfs_mod_frextents(struct xfs_mount *mp, int64_t delta);
440
441extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int);
442extern int xfs_readsb(xfs_mount_t *, int);
443extern void xfs_freesb(xfs_mount_t *);
444extern bool xfs_fs_writable(struct xfs_mount *mp, int level);
445extern int xfs_sb_validate_fsb_count(struct xfs_sb *, __uint64_t);
446
447extern int xfs_dev_is_read_only(struct xfs_mount *, char *);
448
449extern void xfs_set_low_space_thresholds(struct xfs_mount *);
450
451int xfs_zero_extent(struct xfs_inode *ip, xfs_fsblock_t start_fsb,
452 xfs_off_t count_fsb);
453
454struct xfs_error_cfg * xfs_error_get_cfg(struct xfs_mount *mp,
455 int error_class, int error);
456
457#endif
458