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 bool m_finobt_nores
; /* no per-AG finobt resv. */
84 uint m_qflags
; /* quota status flags */
85 uint m_attroffset
; /* inode attribute offset */
86 struct xfs_trans_resv m_resv
; /* precomputed res values */
87 int m_dalign
; /* stripe unit */
88 int m_swidth
; /* stripe width */
89 const struct xfs_nameops
*m_dirnameops
; /* vector of dir name ops */
91 struct xfs_da_geometry
*m_dir_geo
; /* directory block geometry */
92 struct xfs_da_geometry
*m_attr_geo
; /* attribute block geometry */
95 * anonymous struct to allow xfs_dquot_buf.c to compile.
96 * Pointer is always null in userspace, so code does not use it at all
102 buf_writeback_fn m_buf_writeback_fn
;
105 * xlog is defined in libxlog and thus is not intialized by libxfs. This
106 * allows an application to initialize and store a reference to the log
109 struct xlog
*m_log
; /* log specific stuff */
112 * Global count of allocation btree blocks in use across all AGs. Only
113 * used when perag reservation is enabled. Helps prevent block
114 * reservation from attempting to reserve allocation btree blocks.
116 atomic64_t m_allocbt_blks
;
120 #define M_IGEO(mp) (&(mp)->m_ino_geo)
123 /* number of blocks originally reserved here */
124 xfs_extlen_t ar_orig_reserved
;
125 /* number of blocks reserved here */
126 xfs_extlen_t ar_reserved
;
127 /* number of blocks originally asked for */
128 xfs_extlen_t ar_asked
;
132 * Per-ag incore structure, copies of information in agf and agi,
133 * to improve the performance of allocation group selection.
135 typedef struct xfs_perag
{
136 struct xfs_mount
*pag_mount
; /* owner filesystem */
137 xfs_agnumber_t pag_agno
; /* AG this structure belongs to */
138 atomic_t pag_ref
; /* perag reference count */
139 char pagf_init
; /* this agf's entry is initialized */
140 char pagi_init
; /* this agi's entry is initialized */
141 char pagf_metadata
; /* the agf is preferred to be metadata */
142 char pagi_inodeok
; /* The agi is ok for inodes */
143 uint8_t pagf_levels
[XFS_BTNUM_AGF
];
144 /* # of levels in bno & cnt btree */
145 bool pagf_agflreset
; /* agfl requires reset before use */
146 uint32_t pagf_flcount
; /* count of blocks in freelist */
147 xfs_extlen_t pagf_freeblks
; /* total free blocks */
148 xfs_extlen_t pagf_longest
; /* longest free space */
149 uint32_t pagf_btreeblks
; /* # of blocks held in AGF btrees */
150 xfs_agino_t pagi_freecount
; /* number of free inodes */
151 xfs_agino_t pagi_count
; /* number of allocated inodes */
154 * Inode allocation search lookup optimisation.
155 * If the pagino matches, the search for new inodes
156 * doesn't need to search the near ones again straight away
158 xfs_agino_t pagl_pagino
;
159 xfs_agino_t pagl_leftrec
;
160 xfs_agino_t pagl_rightrec
;
161 int pagb_count
; /* pagb slots in use */
163 /* Blocks reserved for all kinds of metadata. */
164 struct xfs_ag_resv pag_meta_resv
;
165 /* Blocks reserved for just AGFL-based metadata. */
166 struct xfs_ag_resv pag_rmapbt_resv
;
168 /* reference count */
169 uint8_t pagf_refcount_level
;
172 static inline struct xfs_ag_resv
*
174 struct xfs_perag
*pag
,
175 enum xfs_ag_resv_type type
)
178 case XFS_AG_RESV_METADATA
:
179 return &pag
->pag_meta_resv
;
180 case XFS_AG_RESV_RMAPBT
:
181 return &pag
->pag_rmapbt_resv
;
187 #define LIBXFS_MOUNT_DEBUGGER 0x0001
188 #define LIBXFS_MOUNT_32BITINODES 0x0002
189 #define LIBXFS_MOUNT_32BITINOOPT 0x0004
190 #define LIBXFS_MOUNT_COMPAT_ATTR 0x0008
191 #define LIBXFS_MOUNT_ATTR2 0x0010
192 #define LIBXFS_MOUNT_WANT_CORRUPTED 0x0020
193 #define LIBXFS_MOUNT_PERAG_DATA_LOADED 0x0040
195 #define LIBXFS_BHASHSIZE(sbp) (1<<10)
197 extern xfs_mount_t
*libxfs_mount (xfs_mount_t
*, xfs_sb_t
*,
198 dev_t
, dev_t
, dev_t
, int);
199 int libxfs_flush_mount(struct xfs_mount
*mp
);
200 int libxfs_umount(struct xfs_mount
*mp
);
201 extern void libxfs_rtmount_destroy (xfs_mount_t
*);
203 /* Dummy xfs_dquot so that libxfs compiles. */
207 #endif /* __XFS_MOUNT_H__ */