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