]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/xfs_mount.h
configure: don't check for syncfs
[thirdparty/xfsprogs-dev.git] / include / xfs_mount.h
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
5 */
6
7 #ifndef __XFS_MOUNT_H__
8 #define __XFS_MOUNT_H__
9
10 struct xfs_inode;
11 struct xfs_buftarg;
12 struct xfs_da_geometry;
13 struct libxfs_init;
14
15 typedef void (*buf_writeback_fn)(struct xfs_buf *bp);
16
17 /* dynamic preallocation free space thresholds, 5% down to 1% */
18 enum {
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 * Define a user-level mount structure with all we need
29 * in order to make use of the numerous XFS_* macros.
30 */
31 typedef struct xfs_mount {
32 xfs_sb_t m_sb; /* copy of fs superblock */
33 #define m_icount m_sb.sb_icount
34 #define m_ifree m_sb.sb_ifree
35 #define m_fdblocks m_sb.sb_fdblocks
36 spinlock_t m_sb_lock;
37
38 /*
39 * Bitsets of per-fs metadata that have been checked and/or are sick.
40 * Callers must hold m_sb_lock to access these two fields.
41 */
42 uint8_t m_fs_checked;
43 uint8_t m_fs_sick;
44
45 char *m_fsname; /* filesystem name */
46 int m_bsize; /* fs logical block size */
47 spinlock_t m_agirotor_lock;
48 xfs_agnumber_t m_agfrotor; /* last ag where space found */
49 xfs_agnumber_t m_agirotor; /* last ag dir inode alloced */
50 xfs_agnumber_t m_maxagi; /* highest inode alloc group */
51 struct xfs_ino_geometry m_ino_geo; /* inode geometry */
52 uint m_rsumlevels; /* rt summary levels */
53 uint m_rsumsize; /* size of rt summary, bytes */
54 /*
55 * Optional cache of rt summary level per bitmap block with the
56 * invariant that m_rsum_cache[bbno] <= the minimum i for which
57 * rsum[i][bbno] != 0. Reads and writes are serialized by the rsumip
58 * inode lock.
59 */
60 uint8_t *m_rsum_cache;
61 struct xfs_inode *m_rbmip; /* pointer to bitmap inode */
62 struct xfs_inode *m_rsumip; /* pointer to summary inode */
63 struct xfs_buftarg *m_ddev_targp;
64 struct xfs_buftarg *m_logdev_targp;
65 struct xfs_buftarg *m_rtdev_targp;
66 #define m_dev m_ddev_targp
67 #define m_logdev m_logdev_targp
68 #define m_rtdev m_rtdev_targp
69 uint8_t m_dircook_elog; /* log d-cookie entry bits */
70 uint8_t m_blkbit_log; /* blocklog + NBBY */
71 uint8_t m_blkbb_log; /* blocklog - BBSHIFT */
72 uint8_t m_sectbb_log; /* sectorlog - BBSHIFT */
73 uint8_t m_agno_log; /* log #ag's */
74 int8_t m_rtxblklog; /* log2 of rextsize, if possible */
75 uint m_blockmask; /* sb_blocksize-1 */
76 uint m_blockwsize; /* sb_blocksize in words */
77 uint m_blockwmask; /* blockwsize-1 */
78 uint m_alloc_mxr[2]; /* XFS_ALLOC_BLOCK_MAXRECS */
79 uint m_alloc_mnr[2]; /* XFS_ALLOC_BLOCK_MINRECS */
80 uint m_bmap_dmxr[2]; /* XFS_BMAP_BLOCK_DMAXRECS */
81 uint m_bmap_dmnr[2]; /* XFS_BMAP_BLOCK_DMINRECS */
82 uint m_rmap_mxr[2]; /* max rmap btree records */
83 uint m_rmap_mnr[2]; /* min rmap btree records */
84 uint m_refc_mxr[2]; /* max refc btree records */
85 uint m_refc_mnr[2]; /* min refc btree records */
86 uint m_alloc_maxlevels; /* max alloc btree levels */
87 uint m_bm_maxlevels[2]; /* max bmap btree levels */
88 uint m_rmap_maxlevels; /* max rmap btree levels */
89 uint m_refc_maxlevels; /* max refc btree levels */
90 unsigned int m_agbtree_maxlevels; /* max level of all AG btrees */
91 xfs_extlen_t m_ag_prealloc_blocks; /* reserved ag blocks */
92 uint m_alloc_set_aside; /* space we can't use */
93 uint m_ag_max_usable; /* max space per AG */
94 struct radix_tree_root m_perag_tree;
95 uint64_t m_features; /* active filesystem features */
96 uint64_t m_low_space[XFS_LOWSP_MAX];
97 uint64_t m_rtxblkmask; /* rt extent block mask */
98 unsigned long m_opstate; /* dynamic state flags */
99 bool m_finobt_nores; /* no per-AG finobt resv. */
100 uint m_qflags; /* quota status flags */
101 uint m_attroffset; /* inode attribute offset */
102 struct xfs_trans_resv m_resv; /* precomputed res values */
103 int m_dalign; /* stripe unit */
104 int m_swidth; /* stripe width */
105 const struct xfs_nameops *m_dirnameops; /* vector of dir name ops */
106
107 struct xfs_da_geometry *m_dir_geo; /* directory block geometry */
108 struct xfs_da_geometry *m_attr_geo; /* attribute block geometry */
109
110 /*
111 * anonymous struct to allow xfs_dquot_buf.c to compile.
112 * Pointer is always null in userspace, so code does not use it at all
113 */
114 struct {
115 int qi_dqperchunk;
116 } *m_quotainfo;
117
118 buf_writeback_fn m_buf_writeback_fn;
119
120 /*
121 * xlog is defined in libxlog and thus is not intialized by libxfs. This
122 * allows an application to initialize and store a reference to the log
123 * if warranted.
124 */
125 struct xlog *m_log; /* log specific stuff */
126
127 /*
128 * Global count of allocation btree blocks in use across all AGs. Only
129 * used when perag reservation is enabled. Helps prevent block
130 * reservation from attempting to reserve allocation btree blocks.
131 */
132 atomic64_t m_allocbt_blks;
133 spinlock_t m_perag_lock; /* lock for m_perag_tree */
134
135 } xfs_mount_t;
136
137 #define M_IGEO(mp) (&(mp)->m_ino_geo)
138
139 /*
140 * Flags for m_features.
141 *
142 * These are all the active features in the filesystem, regardless of how
143 * they are configured.
144 */
145 #define XFS_FEAT_ATTR (1ULL << 0) /* xattrs present in fs */
146 #define XFS_FEAT_NLINK (1ULL << 1) /* 32 bit link counts */
147 #define XFS_FEAT_QUOTA (1ULL << 2) /* quota active */
148 #define XFS_FEAT_ALIGN (1ULL << 3) /* inode alignment */
149 #define XFS_FEAT_DALIGN (1ULL << 4) /* data alignment */
150 #define XFS_FEAT_LOGV2 (1ULL << 5) /* version 2 logs */
151 #define XFS_FEAT_SECTOR (1ULL << 6) /* sector size > 512 bytes */
152 #define XFS_FEAT_EXTFLG (1ULL << 7) /* unwritten extents */
153 #define XFS_FEAT_ASCIICI (1ULL << 8) /* ASCII only case-insens. */
154 #define XFS_FEAT_LAZYSBCOUNT (1ULL << 9) /* Superblk counters */
155 #define XFS_FEAT_ATTR2 (1ULL << 10) /* dynamic attr fork */
156 #define XFS_FEAT_PARENT (1ULL << 11) /* parent pointers */
157 #define XFS_FEAT_PROJID32 (1ULL << 12) /* 32 bit project id */
158 #define XFS_FEAT_CRC (1ULL << 13) /* metadata CRCs */
159 #define XFS_FEAT_V3INODES (1ULL << 14) /* Version 3 inodes */
160 #define XFS_FEAT_PQUOTINO (1ULL << 15) /* non-shared proj/grp quotas */
161 #define XFS_FEAT_FTYPE (1ULL << 16) /* inode type in dir */
162 #define XFS_FEAT_FINOBT (1ULL << 17) /* free inode btree */
163 #define XFS_FEAT_RMAPBT (1ULL << 18) /* reverse map btree */
164 #define XFS_FEAT_REFLINK (1ULL << 19) /* reflinked files */
165 #define XFS_FEAT_SPINODES (1ULL << 20) /* sparse inode chunks */
166 #define XFS_FEAT_META_UUID (1ULL << 21) /* metadata UUID */
167 #define XFS_FEAT_REALTIME (1ULL << 22) /* realtime device present */
168 #define XFS_FEAT_INOBTCNT (1ULL << 23) /* inobt block counts */
169 #define XFS_FEAT_BIGTIME (1ULL << 24) /* large timestamps */
170 #define XFS_FEAT_NEEDSREPAIR (1ULL << 25) /* needs xfs_repair */
171 #define XFS_FEAT_NREXT64 (1ULL << 26) /* large extent counters */
172
173 #define __XFS_HAS_FEAT(name, NAME) \
174 static inline bool xfs_has_ ## name (struct xfs_mount *mp) \
175 { \
176 return mp->m_features & XFS_FEAT_ ## NAME; \
177 }
178
179 /* Some features can be added dynamically so they need a set wrapper, too. */
180 #define __XFS_ADD_FEAT(name, NAME) \
181 __XFS_HAS_FEAT(name, NAME); \
182 static inline void xfs_add_ ## name (struct xfs_mount *mp) \
183 { \
184 mp->m_features |= XFS_FEAT_ ## NAME; \
185 xfs_sb_version_add ## name(&mp->m_sb); \
186 }
187
188 /* Superblock features */
189 __XFS_ADD_FEAT(attr, ATTR)
190 __XFS_HAS_FEAT(nlink, NLINK)
191 __XFS_ADD_FEAT(quota, QUOTA)
192 __XFS_HAS_FEAT(align, ALIGN)
193 __XFS_HAS_FEAT(dalign, DALIGN)
194 __XFS_HAS_FEAT(logv2, LOGV2)
195 __XFS_HAS_FEAT(sector, SECTOR)
196 __XFS_HAS_FEAT(extflg, EXTFLG)
197 __XFS_HAS_FEAT(asciici, ASCIICI)
198 __XFS_HAS_FEAT(lazysbcount, LAZYSBCOUNT)
199 __XFS_ADD_FEAT(attr2, ATTR2)
200 __XFS_HAS_FEAT(parent, PARENT)
201 __XFS_ADD_FEAT(projid32, PROJID32)
202 __XFS_HAS_FEAT(crc, CRC)
203 __XFS_HAS_FEAT(v3inodes, V3INODES)
204 __XFS_HAS_FEAT(pquotino, PQUOTINO)
205 __XFS_HAS_FEAT(ftype, FTYPE)
206 __XFS_HAS_FEAT(finobt, FINOBT)
207 __XFS_HAS_FEAT(rmapbt, RMAPBT)
208 __XFS_HAS_FEAT(reflink, REFLINK)
209 __XFS_HAS_FEAT(sparseinodes, SPINODES)
210 __XFS_HAS_FEAT(metauuid, META_UUID)
211 __XFS_HAS_FEAT(realtime, REALTIME)
212 __XFS_HAS_FEAT(inobtcounts, INOBTCNT)
213 __XFS_HAS_FEAT(bigtime, BIGTIME)
214 __XFS_HAS_FEAT(needsrepair, NEEDSREPAIR)
215 __XFS_HAS_FEAT(large_extent_counts, NREXT64)
216
217 /* Kernel mount features that we don't support */
218 #define __XFS_UNSUPP_FEAT(name) \
219 static inline bool xfs_has_ ## name (struct xfs_mount *mp) \
220 { \
221 return false; \
222 }
223 __XFS_UNSUPP_FEAT(wsync)
224 __XFS_UNSUPP_FEAT(noattr2)
225 __XFS_UNSUPP_FEAT(ikeep)
226 __XFS_UNSUPP_FEAT(swalloc)
227 __XFS_UNSUPP_FEAT(small_inums)
228 __XFS_UNSUPP_FEAT(readonly)
229
230 /* Operational mount state flags */
231 #define XFS_OPSTATE_INODE32 0 /* inode32 allocator active */
232 #define XFS_OPSTATE_DEBUGGER 1 /* is this the debugger? */
233 #define XFS_OPSTATE_REPORT_CORRUPTION 2 /* report buffer corruption? */
234 #define XFS_OPSTATE_PERAG_DATA_LOADED 3 /* per-AG data initialized? */
235
236 #define __XFS_IS_OPSTATE(name, NAME) \
237 static inline bool xfs_is_ ## name (struct xfs_mount *mp) \
238 { \
239 return (mp)->m_opstate & (1UL << XFS_OPSTATE_ ## NAME); \
240 } \
241 static inline bool xfs_clear_ ## name (struct xfs_mount *mp) \
242 { \
243 bool ret = xfs_is_ ## name(mp); \
244 \
245 (mp)->m_opstate &= ~(1UL << XFS_OPSTATE_ ## NAME); \
246 return ret; \
247 } \
248 static inline bool xfs_set_ ## name (struct xfs_mount *mp) \
249 { \
250 bool ret = xfs_is_ ## name(mp); \
251 \
252 (mp)->m_opstate |= (1UL << XFS_OPSTATE_ ## NAME); \
253 return ret; \
254 }
255
256 __XFS_IS_OPSTATE(inode32, INODE32)
257 __XFS_IS_OPSTATE(debugger, DEBUGGER)
258 __XFS_IS_OPSTATE(reporting_corruption, REPORT_CORRUPTION)
259 __XFS_IS_OPSTATE(perag_data_loaded, PERAG_DATA_LOADED)
260
261 #define __XFS_UNSUPP_OPSTATE(name) \
262 static inline bool xfs_is_ ## name (struct xfs_mount *mp) \
263 { \
264 return false; \
265 }
266 __XFS_UNSUPP_OPSTATE(readonly)
267 __XFS_UNSUPP_OPSTATE(shutdown)
268
269 /* don't fail on device size or AG count checks */
270 #define LIBXFS_MOUNT_DEBUGGER (1U << 0)
271 /* report metadata corruption to stdout */
272 #define LIBXFS_MOUNT_REPORT_CORRUPTION (1U << 1)
273
274 #define LIBXFS_BHASHSIZE(sbp) (1<<10)
275
276 void libxfs_compute_all_maxlevels(struct xfs_mount *mp);
277 struct xfs_mount *libxfs_mount(struct xfs_mount *mp, struct xfs_sb *sb,
278 struct libxfs_init *xi, unsigned int flags);
279 int libxfs_flush_mount(struct xfs_mount *mp);
280 int libxfs_umount(struct xfs_mount *mp);
281 extern void libxfs_rtmount_destroy (xfs_mount_t *);
282
283 /* Dummy xfs_dquot so that libxfs compiles. */
284 struct xfs_dquot {
285 int q_type;
286 };
287
288 typedef struct wait_queue_head {
289 } wait_queue_head_t;
290
291 static inline void wake_up(wait_queue_head_t *wq) {}
292
293 struct xfs_defer_drain { /* empty */ };
294
295 #define xfs_defer_drain_init(dr) ((void)0)
296 #define xfs_defer_drain_free(dr) ((void)0)
297
298 #define xfs_perag_intent_get(mp, agno) xfs_perag_get((mp), (agno))
299 #define xfs_perag_intent_put(pag) xfs_perag_put(pag)
300
301 static inline void xfs_perag_intent_hold(struct xfs_perag *pag) {}
302 static inline void xfs_perag_intent_rele(struct xfs_perag *pag) {}
303
304 #endif /* __XFS_MOUNT_H__ */