1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
7 #ifndef __XFS_MOUNT_H__
8 #define __XFS_MOUNT_H__
12 struct xfs_da_geometry
;
14 typedef void (*buf_writeback_fn
)(struct xfs_buf
*bp
);
17 * Define a user-level mount structure with all we need
18 * in order to make use of the numerous XFS_* macros.
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
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.
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 */
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
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_ag_maxlevels
; /* XFS_AG_MAXLEVELS */
75 uint m_bm_maxlevels
[2]; /* XFS_BM_MAXLEVELS */
76 uint m_rmap_maxlevels
; /* max rmap btree levels */
77 uint m_refc_maxlevels
; /* max refc btree levels */
78 xfs_extlen_t m_ag_prealloc_blocks
; /* reserved ag blocks */
79 uint m_alloc_set_aside
; /* space we can't use */
80 uint m_ag_max_usable
; /* max space per AG */
81 struct radix_tree_root m_perag_tree
;
82 uint m_flags
; /* global mount flags */
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 */
93 struct xfs_da_geometry
*m_dir_geo
; /* directory block geometry */
94 struct xfs_da_geometry
*m_attr_geo
; /* attribute block geometry */
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
104 buf_writeback_fn m_buf_writeback_fn
;
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
111 struct xlog
*m_log
; /* log specific stuff */
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.
118 atomic64_t m_allocbt_blks
;
119 spinlock_t m_perag_lock
; /* lock for m_perag_tree */
123 #define M_IGEO(mp) (&(mp)->m_ino_geo)
126 * Flags for m_features.
128 * These are all the active features in the filesystem, regardless of how
129 * they are configured.
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 */
158 #define __XFS_HAS_FEAT(name, NAME) \
159 static inline bool xfs_has_ ## name (struct xfs_mount *mp) \
161 return mp->m_features & XFS_FEAT_ ## NAME; \
164 /* Some features can be added dynamically so they need a set wrapper, too. */
165 #define __XFS_ADD_FEAT(name, NAME) \
166 __XFS_HAS_FEAT(name, NAME); \
167 static inline void xfs_add_ ## name (struct xfs_mount *mp) \
169 mp->m_features |= XFS_FEAT_ ## NAME; \
170 xfs_sb_version_add ## name(&mp->m_sb); \
173 /* Superblock features */
174 __XFS_ADD_FEAT(attr
, ATTR
)
175 __XFS_HAS_FEAT(nlink
, NLINK
)
176 __XFS_ADD_FEAT(quota
, QUOTA
)
177 __XFS_HAS_FEAT(align
, ALIGN
)
178 __XFS_HAS_FEAT(dalign
, DALIGN
)
179 __XFS_HAS_FEAT(logv2
, LOGV2
)
180 __XFS_HAS_FEAT(sector
, SECTOR
)
181 __XFS_HAS_FEAT(extflg
, EXTFLG
)
182 __XFS_HAS_FEAT(asciici
, ASCIICI
)
183 __XFS_HAS_FEAT(lazysbcount
, LAZYSBCOUNT
)
184 __XFS_ADD_FEAT(attr2
, ATTR2
)
185 __XFS_HAS_FEAT(parent
, PARENT
)
186 __XFS_ADD_FEAT(projid32
, PROJID32
)
187 __XFS_HAS_FEAT(crc
, CRC
)
188 __XFS_HAS_FEAT(v3inodes
, V3INODES
)
189 __XFS_HAS_FEAT(pquotino
, PQUOTINO
)
190 __XFS_HAS_FEAT(ftype
, FTYPE
)
191 __XFS_HAS_FEAT(finobt
, FINOBT
)
192 __XFS_HAS_FEAT(rmapbt
, RMAPBT
)
193 __XFS_HAS_FEAT(reflink
, REFLINK
)
194 __XFS_HAS_FEAT(sparseinodes
, SPINODES
)
195 __XFS_HAS_FEAT(metauuid
, META_UUID
)
196 __XFS_HAS_FEAT(realtime
, REALTIME
)
197 __XFS_HAS_FEAT(inobtcounts
, INOBTCNT
)
198 __XFS_HAS_FEAT(bigtime
, BIGTIME
)
199 __XFS_HAS_FEAT(needsrepair
, NEEDSREPAIR
)
201 /* Kernel mount features that we don't support */
202 #define __XFS_UNSUPP_FEAT(name) \
203 static inline bool xfs_has_ ## name (struct xfs_mount *mp) \
207 __XFS_UNSUPP_FEAT(wsync
)
208 __XFS_UNSUPP_FEAT(noattr2
)
209 __XFS_UNSUPP_FEAT(ikeep
)
210 __XFS_UNSUPP_FEAT(swalloc
)
211 __XFS_UNSUPP_FEAT(small_inums
)
212 __XFS_UNSUPP_FEAT(readonly
)
214 /* Operational mount state flags */
215 #define XFS_OPSTATE_INODE32 0 /* inode32 allocator active */
217 #define __XFS_IS_OPSTATE(name, NAME) \
218 static inline bool xfs_is_ ## name (struct xfs_mount *mp) \
220 return (mp)->m_opstate & (1UL << XFS_OPSTATE_ ## NAME); \
222 static inline bool xfs_clear_ ## name (struct xfs_mount *mp) \
224 bool ret = xfs_is_ ## name(mp); \
226 (mp)->m_opstate &= ~(1UL << XFS_OPSTATE_ ## NAME); \
229 static inline bool xfs_set_ ## name (struct xfs_mount *mp) \
231 bool ret = xfs_is_ ## name(mp); \
233 (mp)->m_opstate |= (1UL << XFS_OPSTATE_ ## NAME); \
237 __XFS_IS_OPSTATE(inode32
, INODE32
)
239 #define __XFS_UNSUPP_OPSTATE(name) \
240 static inline bool xfs_is_ ## name (struct xfs_mount *mp) \
244 __XFS_UNSUPP_OPSTATE(readonly
)
245 __XFS_UNSUPP_OPSTATE(shutdown
)
247 #define LIBXFS_MOUNT_DEBUGGER 0x0001
248 #define LIBXFS_MOUNT_32BITINODES 0x0002
249 #define LIBXFS_MOUNT_32BITINOOPT 0x0004
250 #define LIBXFS_MOUNT_COMPAT_ATTR 0x0008
251 #define LIBXFS_MOUNT_ATTR2 0x0010
252 #define LIBXFS_MOUNT_WANT_CORRUPTED 0x0020
253 #define LIBXFS_MOUNT_PERAG_DATA_LOADED 0x0040
255 #define LIBXFS_BHASHSIZE(sbp) (1<<10)
257 extern xfs_mount_t
*libxfs_mount (xfs_mount_t
*, xfs_sb_t
*,
258 dev_t
, dev_t
, dev_t
, int);
259 int libxfs_flush_mount(struct xfs_mount
*mp
);
260 int libxfs_umount(struct xfs_mount
*mp
);
261 extern void libxfs_rtmount_destroy (xfs_mount_t
*);
263 /* Dummy xfs_dquot so that libxfs compiles. */
267 #endif /* __XFS_MOUNT_H__ */