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__
13 struct xfs_da_geometry
;
16 * Define a user-level mount structure with all we need
17 * in order to make use of the numerous XFS_* macros.
19 typedef struct xfs_mount
{
20 xfs_sb_t m_sb
; /* copy of fs superblock */
21 #define m_icount m_sb.sb_icount
22 #define m_ifree m_sb.sb_ifree
23 #define m_fdblocks m_sb.sb_fdblocks
24 char *m_fsname
; /* filesystem name */
25 int m_bsize
; /* fs logical block size */
26 xfs_agnumber_t m_agfrotor
; /* last ag where space found */
27 xfs_agnumber_t m_agirotor
; /* last ag dir inode alloced */
28 xfs_agnumber_t m_maxagi
; /* highest inode alloc group */
29 uint m_rsumlevels
; /* rt summary levels */
30 uint m_rsumsize
; /* size of rt summary, bytes */
31 struct xfs_inode
*m_rbmip
; /* pointer to bitmap inode */
32 struct xfs_inode
*m_rsumip
; /* pointer to summary inode */
33 struct xfs_buftarg
*m_ddev_targp
;
34 struct xfs_buftarg
*m_logdev_targp
;
35 struct xfs_buftarg
*m_rtdev_targp
;
36 #define m_dev m_ddev_targp
37 #define m_logdev m_logdev_targp
38 #define m_rtdev m_rtdev_targp
39 uint8_t m_dircook_elog
; /* log d-cookie entry bits */
40 uint8_t m_blkbit_log
; /* blocklog + NBBY */
41 uint8_t m_blkbb_log
; /* blocklog - BBSHIFT */
42 uint8_t m_sectbb_log
; /* sectorlog - BBSHIFT */
43 uint8_t m_agno_log
; /* log #ag's */
44 uint8_t m_agino_log
; /* #bits for agino in inum */
45 uint m_inode_cluster_size
;/* min inode buf size */
46 uint m_blockmask
; /* sb_blocksize-1 */
47 uint m_blockwsize
; /* sb_blocksize in words */
48 uint m_blockwmask
; /* blockwsize-1 */
49 uint m_alloc_mxr
[2]; /* XFS_ALLOC_BLOCK_MAXRECS */
50 uint m_alloc_mnr
[2]; /* XFS_ALLOC_BLOCK_MINRECS */
51 uint m_bmap_dmxr
[2]; /* XFS_BMAP_BLOCK_DMAXRECS */
52 uint m_bmap_dmnr
[2]; /* XFS_BMAP_BLOCK_DMINRECS */
53 uint m_inobt_mxr
[2]; /* XFS_INOBT_BLOCK_MAXRECS */
54 uint m_inobt_mnr
[2]; /* XFS_INOBT_BLOCK_MINRECS */
55 uint m_rmap_mxr
[2]; /* max rmap btree records */
56 uint m_rmap_mnr
[2]; /* min rmap btree records */
57 uint m_refc_mxr
[2]; /* max refc btree records */
58 uint m_refc_mnr
[2]; /* min refc btree records */
59 uint m_ag_maxlevels
; /* XFS_AG_MAXLEVELS */
60 uint m_bm_maxlevels
[2]; /* XFS_BM_MAXLEVELS */
61 uint m_in_maxlevels
; /* XFS_IN_MAXLEVELS */
62 uint m_rmap_maxlevels
; /* max rmap btree levels */
63 uint m_refc_maxlevels
; /* max refc btree levels */
64 xfs_extlen_t m_ag_prealloc_blocks
; /* reserved ag blocks */
65 uint m_alloc_set_aside
; /* space we can't use */
66 uint m_ag_max_usable
; /* max space per AG */
67 struct radix_tree_root m_perag_tree
;
68 uint m_flags
; /* global mount flags */
69 bool m_inotbt_nores
; /* no per-AG finobt resv. */
70 uint m_qflags
; /* quota status flags */
71 uint m_attroffset
; /* inode attribute offset */
72 int m_ialloc_inos
; /* inodes in inode allocation */
73 int m_ialloc_blks
; /* blocks in inode allocation */
74 int m_ialloc_min_blks
; /* min blocks in sparse inode
76 int m_litino
; /* size of inode union area */
77 int m_inoalign_mask
;/* mask sb_inoalignmt if used */
78 struct xfs_trans_resv m_resv
; /* precomputed res values */
79 uint64_t m_maxicount
; /* maximum inode count */
80 int m_dalign
; /* stripe unit */
81 int m_swidth
; /* stripe width */
82 int m_sinoalign
; /* stripe unit inode alignmnt */
83 const struct xfs_nameops
*m_dirnameops
; /* vector of dir name ops */
85 struct xfs_da_geometry
*m_dir_geo
; /* directory block geometry */
86 struct xfs_da_geometry
*m_attr_geo
; /* attribute block geometry */
87 const struct xfs_dir_ops
*m_dir_inode_ops
; /* vector of dir inode ops */
88 const struct xfs_dir_ops
*m_nondir_inode_ops
; /* !dir inode ops */
89 #define M_DIROPS(mp) ((mp)->m_dir_inode_ops)
92 * anonymous struct to allow xfs_dquot_buf.c to compile.
93 * Pointer is always null in userspace, so code does not use it at all
100 * xlog is defined in libxlog and thus is not intialized by libxfs. This
101 * allows an application to initialize and store a reference to the log
107 /* per-AG block reservation data structures*/
108 enum xfs_ag_resv_type
{
109 XFS_AG_RESV_NONE
= 0,
111 XFS_AG_RESV_METADATA
,
116 /* number of blocks originally reserved here */
117 xfs_extlen_t ar_orig_reserved
;
118 /* number of blocks reserved here */
119 xfs_extlen_t ar_reserved
;
120 /* number of blocks originally asked for */
121 xfs_extlen_t ar_asked
;
125 * Per-ag incore structure, copies of information in agf and agi,
126 * to improve the performance of allocation group selection.
128 typedef struct xfs_perag
{
129 struct xfs_mount
*pag_mount
; /* owner filesystem */
130 xfs_agnumber_t pag_agno
; /* AG this structure belongs to */
131 atomic_t pag_ref
; /* perag reference count */
132 char pagf_init
; /* this agf's entry is initialized */
133 char pagi_init
; /* this agi's entry is initialized */
134 char pagf_metadata
; /* the agf is preferred to be metadata */
135 char pagi_inodeok
; /* The agi is ok for inodes */
136 uint8_t pagf_levels
[XFS_BTNUM_AGF
];
137 /* # of levels in bno & cnt btree */
138 bool pagf_agflreset
; /* agfl requires reset before use */
139 uint32_t pagf_flcount
; /* count of blocks in freelist */
140 xfs_extlen_t pagf_freeblks
; /* total free blocks */
141 xfs_extlen_t pagf_longest
; /* longest free space */
142 uint32_t pagf_btreeblks
; /* # of blocks held in AGF btrees */
143 xfs_agino_t pagi_freecount
; /* number of free inodes */
144 xfs_agino_t pagi_count
; /* number of allocated inodes */
147 * Inode allocation search lookup optimisation.
148 * If the pagino matches, the search for new inodes
149 * doesn't need to search the near ones again straight away
151 xfs_agino_t pagl_pagino
;
152 xfs_agino_t pagl_leftrec
;
153 xfs_agino_t pagl_rightrec
;
154 int pagb_count
; /* pagb slots in use */
156 /* Blocks reserved for all kinds of metadata. */
157 struct xfs_ag_resv pag_meta_resv
;
158 /* Blocks reserved for just AGFL-based metadata. */
159 struct xfs_ag_resv pag_rmapbt_resv
;
161 /* reference count */
162 uint8_t pagf_refcount_level
;
165 static inline struct xfs_ag_resv
*
167 struct xfs_perag
*pag
,
168 enum xfs_ag_resv_type type
)
171 case XFS_AG_RESV_METADATA
:
172 return &pag
->pag_meta_resv
;
173 case XFS_AG_RESV_RMAPBT
:
174 return &pag
->pag_rmapbt_resv
;
180 #define LIBXFS_MOUNT_DEBUGGER 0x0001
181 #define LIBXFS_MOUNT_32BITINODES 0x0002
182 #define LIBXFS_MOUNT_32BITINOOPT 0x0004
183 #define LIBXFS_MOUNT_COMPAT_ATTR 0x0008
184 #define LIBXFS_MOUNT_ATTR2 0x0010
185 #define LIBXFS_MOUNT_WANT_CORRUPTED 0x0020
187 #define LIBXFS_BHASHSIZE(sbp) (1<<10)
189 extern xfs_mount_t
*libxfs_mount (xfs_mount_t
*, xfs_sb_t
*,
190 dev_t
, dev_t
, dev_t
, int);
191 extern void libxfs_umount (xfs_mount_t
*);
192 extern void libxfs_rtmount_destroy (xfs_mount_t
*);
194 #endif /* __XFS_MOUNT_H__ */