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
40typedef struct xfs_mount {
41 struct super_block *m_super;
42 xfs_tid_t m_tid;
43 struct xfs_ail *m_ail;
44
45 struct xfs_sb m_sb;
46 spinlock_t m_sb_lock;
47 struct percpu_counter m_icount;
48 struct percpu_counter m_ifree;
49 struct percpu_counter m_fdblocks;
50
51 struct xfs_buf *m_sb_bp;
52 char *m_fsname;
53 int m_fsname_len;
54 char *m_rtname;
55 char *m_logname;
56 int m_bsize;
57 xfs_agnumber_t m_agfrotor;
58 xfs_agnumber_t m_agirotor;
59 spinlock_t m_agirotor_lock;
60 xfs_agnumber_t m_maxagi;
61 uint m_readio_log;
62 uint m_readio_blocks;
63 uint m_writeio_log;
64 uint m_writeio_blocks;
65 struct xfs_da_geometry *m_dir_geo;
66 struct xfs_da_geometry *m_attr_geo;
67 struct xlog *m_log;
68 int m_logbufs;
69 int m_logbsize;
70 uint m_rsumlevels;
71 uint m_rsumsize;
72 struct xfs_inode *m_rbmip;
73 struct xfs_inode *m_rsumip;
74 struct xfs_inode *m_rootip;
75 struct xfs_quotainfo *m_quotainfo;
76 xfs_buftarg_t *m_ddev_targp;
77 xfs_buftarg_t *m_logdev_targp;
78 xfs_buftarg_t *m_rtdev_targp;
79 __uint8_t m_blkbit_log;
80 __uint8_t m_blkbb_log;
81 __uint8_t m_agno_log;
82 __uint8_t m_agino_log;
83 uint m_inode_cluster_size;
84 uint m_blockmask;
85 uint m_blockwsize;
86 uint m_blockwmask;
87 uint m_alloc_mxr[2];
88 uint m_alloc_mnr[2];
89 uint m_bmap_dmxr[2];
90 uint m_bmap_dmnr[2];
91 uint m_inobt_mxr[2];
92 uint m_inobt_mnr[2];
93 uint m_ag_maxlevels;
94 uint m_bm_maxlevels[2];
95 uint m_in_maxlevels;
96 struct radix_tree_root m_perag_tree;
97 spinlock_t m_perag_lock;
98 struct mutex m_growlock;
99 int m_fixedfsid[2];
100 uint m_dmevmask;
101 __uint64_t m_flags;
102 int m_ialloc_inos;
103 int m_ialloc_blks;
104 int m_ialloc_min_blks;
105
106 int m_inoalign_mask;
107 uint m_qflags;
108 struct xfs_trans_resv m_resv;
109 __uint64_t m_maxicount;
110 __uint64_t m_resblks;
111 __uint64_t m_resblks_avail;
112 __uint64_t m_resblks_save;
113 int m_dalign;
114 int m_swidth;
115 int m_sinoalign;
116 __uint8_t m_sectbb_log;
117 const struct xfs_nameops *m_dirnameops;
118 const struct xfs_dir_ops *m_dir_inode_ops;
119 const struct xfs_dir_ops *m_nondir_inode_ops;
120 uint m_chsize;
121 atomic_t m_active_trans;
122 struct xfs_mru_cache *m_filestream;
123 struct delayed_work m_reclaim_work;
124 struct delayed_work m_eofblocks_work;
125
126 bool m_update_sb;
127 int64_t m_low_space[XFS_LOWSP_MAX];
128
129 struct xfs_kobj m_kobj;
130 struct xstats m_stats;
131
132 struct workqueue_struct *m_buf_workqueue;
133 struct workqueue_struct *m_data_workqueue;
134 struct workqueue_struct *m_unwritten_workqueue;
135 struct workqueue_struct *m_cil_workqueue;
136 struct workqueue_struct *m_reclaim_workqueue;
137 struct workqueue_struct *m_log_workqueue;
138 struct workqueue_struct *m_eofblocks_workqueue;
139
140
141
142
143
144
145
146
147
148
149 __uint32_t m_generation;
150
151#ifdef DEBUG
152
153
154
155
156
157
158
159 bool m_fail_writes;
160#endif
161} xfs_mount_t;
162
163
164
165
166#define XFS_MOUNT_WSYNC (1ULL << 0)
167
168
169#define XFS_MOUNT_WAS_CLEAN (1ULL << 3)
170#define XFS_MOUNT_FS_SHUTDOWN (1ULL << 4)
171
172
173#define XFS_MOUNT_DISCARD (1ULL << 5)
174#define XFS_MOUNT_NOALIGN (1ULL << 7)
175
176#define XFS_MOUNT_ATTR2 (1ULL << 8)
177#define XFS_MOUNT_GRPID (1ULL << 9)
178#define XFS_MOUNT_NORECOVERY (1ULL << 10)
179#define XFS_MOUNT_DFLT_IOSIZE (1ULL << 12)
180#define XFS_MOUNT_SMALL_INUMS (1ULL << 14)
181#define XFS_MOUNT_32BITINODES (1ULL << 15)
182#define XFS_MOUNT_NOUUID (1ULL << 16)
183#define XFS_MOUNT_BARRIER (1ULL << 17)
184#define XFS_MOUNT_IKEEP (1ULL << 18)
185#define XFS_MOUNT_SWALLOC (1ULL << 19)
186
187#define XFS_MOUNT_RDONLY (1ULL << 20)
188#define XFS_MOUNT_DIRSYNC (1ULL << 21)
189#define XFS_MOUNT_COMPAT_IOSIZE (1ULL << 22)
190
191#define XFS_MOUNT_FILESTREAMS (1ULL << 24)
192
193#define XFS_MOUNT_NOATTR2 (1ULL << 25)
194
195#define XFS_MOUNT_DAX (1ULL << 62)
196
197
198
199
200
201#define XFS_READIO_LOG_LARGE 16
202#define XFS_WRITEIO_LOG_LARGE 16
203
204
205
206
207
208#define XFS_MAX_IO_LOG 30
209#define XFS_MIN_IO_LOG PAGE_SHIFT
210
211
212
213
214
215#define XFS_WSYNC_READIO_LOG 15
216#define XFS_WSYNC_WRITEIO_LOG 14
217
218
219
220
221
222
223
224
225
226
227
228
229
230static inline unsigned long
231xfs_preferred_iosize(xfs_mount_t *mp)
232{
233 if (mp->m_flags & XFS_MOUNT_COMPAT_IOSIZE)
234 return PAGE_SIZE;
235 return (mp->m_swidth ?
236 (mp->m_swidth << mp->m_sb.sb_blocklog) :
237 ((mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) ?
238 (1 << (int)MAX(mp->m_readio_log, mp->m_writeio_log)) :
239 PAGE_SIZE));
240}
241
242#define XFS_LAST_UNMOUNT_WAS_CLEAN(mp) \
243 ((mp)->m_flags & XFS_MOUNT_WAS_CLEAN)
244#define XFS_FORCED_SHUTDOWN(mp) ((mp)->m_flags & XFS_MOUNT_FS_SHUTDOWN)
245void xfs_do_force_shutdown(struct xfs_mount *mp, int flags, char *fname,
246 int lnnum);
247#define xfs_force_shutdown(m,f) \
248 xfs_do_force_shutdown(m, f, __FILE__, __LINE__)
249
250#define SHUTDOWN_META_IO_ERROR 0x0001
251#define SHUTDOWN_LOG_IO_ERROR 0x0002
252#define SHUTDOWN_FORCE_UMOUNT 0x0004
253#define SHUTDOWN_CORRUPT_INCORE 0x0008
254#define SHUTDOWN_REMOTE_REQ 0x0010
255#define SHUTDOWN_DEVICE_REQ 0x0020
256
257
258
259
260#define XFS_MFSI_QUIET 0x40
261
262static inline xfs_agnumber_t
263xfs_daddr_to_agno(struct xfs_mount *mp, xfs_daddr_t d)
264{
265 xfs_daddr_t ld = XFS_BB_TO_FSBT(mp, d);
266 do_div(ld, mp->m_sb.sb_agblocks);
267 return (xfs_agnumber_t) ld;
268}
269
270static inline xfs_agblock_t
271xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d)
272{
273 xfs_daddr_t ld = XFS_BB_TO_FSBT(mp, d);
274 return (xfs_agblock_t) do_div(ld, mp->m_sb.sb_agblocks);
275}
276
277#ifdef DEBUG
278static inline bool
279xfs_mp_fail_writes(struct xfs_mount *mp)
280{
281 return mp->m_fail_writes;
282}
283#else
284static inline bool
285xfs_mp_fail_writes(struct xfs_mount *mp)
286{
287 return 0;
288}
289#endif
290
291
292
293
294
295typedef struct xfs_perag {
296 struct xfs_mount *pag_mount;
297 xfs_agnumber_t pag_agno;
298 atomic_t pag_ref;
299 char pagf_init;
300 char pagi_init;
301 char pagf_metadata;
302 char pagi_inodeok;
303 __uint8_t pagf_levels[XFS_BTNUM_AGF];
304
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 spinlock_t pagb_lock;
321 struct rb_root pagb_tree;
322
323 atomic_t pagf_fstrms;
324
325 spinlock_t pag_ici_lock;
326 struct radix_tree_root pag_ici_root;
327 int pag_ici_reclaimable;
328 struct mutex pag_ici_reclaim_lock;
329 unsigned long pag_ici_reclaim_cursor;
330
331
332 spinlock_t pag_buf_lock;
333 struct rb_root pag_buf_tree;
334
335
336 struct rcu_head rcu_head;
337 int pagb_count;
338} xfs_perag_t;
339
340extern void xfs_uuid_table_free(void);
341extern int xfs_log_sbcount(xfs_mount_t *);
342extern __uint64_t xfs_default_resblks(xfs_mount_t *mp);
343extern int xfs_mountfs(xfs_mount_t *mp);
344extern int xfs_initialize_perag(xfs_mount_t *mp, xfs_agnumber_t agcount,
345 xfs_agnumber_t *maxagi);
346extern void xfs_unmountfs(xfs_mount_t *);
347
348extern int xfs_mod_icount(struct xfs_mount *mp, int64_t delta);
349extern int xfs_mod_ifree(struct xfs_mount *mp, int64_t delta);
350extern int xfs_mod_fdblocks(struct xfs_mount *mp, int64_t delta,
351 bool reserved);
352extern int xfs_mod_frextents(struct xfs_mount *mp, int64_t delta);
353
354extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int);
355extern int xfs_readsb(xfs_mount_t *, int);
356extern void xfs_freesb(xfs_mount_t *);
357extern bool xfs_fs_writable(struct xfs_mount *mp, int level);
358extern int xfs_sb_validate_fsb_count(struct xfs_sb *, __uint64_t);
359
360extern int xfs_dev_is_read_only(struct xfs_mount *, char *);
361
362extern void xfs_set_low_space_thresholds(struct xfs_mount *);
363
364int xfs_zero_extent(struct xfs_inode *ip, xfs_fsblock_t start_fsb,
365 xfs_off_t count_fsb);
366
367#endif
368