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