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