]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - include/xfs_mount.h
xfs: cache minimum realtime summary level
[thirdparty/xfsprogs-dev.git] / include / xfs_mount.h
CommitLineData
959ef981 1// SPDX-License-Identifier: GPL-2.0
b626fb59
DC
2/*
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
b626fb59
DC
5 */
6
7#ifndef __XFS_MOUNT_H__
8#define __XFS_MOUNT_H__
9
10struct xfs_inode;
11struct xfs_buftarg;
12struct xfs_dir_ops;
13struct xfs_da_geometry;
14
15/*
16 * Define a user-level mount structure with all we need
17 * in order to make use of the numerous XFS_* macros.
18 */
19typedef 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 */
463b0a60
OS
31 /*
32 * Optional cache of rt summary level per bitmap block with the
33 * invariant that m_rsum_cache[bbno] <= the minimum i for which
34 * rsum[i][bbno] != 0. Reads and writes are serialized by the rsumip
35 * inode lock.
36 */
37 uint8_t *m_rsum_cache;
b626fb59
DC
38 struct xfs_inode *m_rbmip; /* pointer to bitmap inode */
39 struct xfs_inode *m_rsumip; /* pointer to summary inode */
40 struct xfs_buftarg *m_ddev_targp;
41 struct xfs_buftarg *m_logdev_targp;
42 struct xfs_buftarg *m_rtdev_targp;
43#define m_dev m_ddev_targp
44#define m_logdev m_logdev_targp
45#define m_rtdev m_rtdev_targp
14f8b681
DW
46 uint8_t m_dircook_elog; /* log d-cookie entry bits */
47 uint8_t m_blkbit_log; /* blocklog + NBBY */
48 uint8_t m_blkbb_log; /* blocklog - BBSHIFT */
49 uint8_t m_sectbb_log; /* sectorlog - BBSHIFT */
50 uint8_t m_agno_log; /* log #ag's */
51 uint8_t m_agino_log; /* #bits for agino in inum */
b626fb59 52 uint m_inode_cluster_size;/* min inode buf size */
42d896cf
DW
53 unsigned int m_inodes_per_cluster;
54 unsigned int m_blocks_per_cluster;
bafa1332
DW
55 unsigned int m_cluster_align;
56 unsigned int m_cluster_align_inodes;
b626fb59
DC
57 uint m_blockmask; /* sb_blocksize-1 */
58 uint m_blockwsize; /* sb_blocksize in words */
59 uint m_blockwmask; /* blockwsize-1 */
60 uint m_alloc_mxr[2]; /* XFS_ALLOC_BLOCK_MAXRECS */
61 uint m_alloc_mnr[2]; /* XFS_ALLOC_BLOCK_MINRECS */
62 uint m_bmap_dmxr[2]; /* XFS_BMAP_BLOCK_DMAXRECS */
63 uint m_bmap_dmnr[2]; /* XFS_BMAP_BLOCK_DMINRECS */
64 uint m_inobt_mxr[2]; /* XFS_INOBT_BLOCK_MAXRECS */
65 uint m_inobt_mnr[2]; /* XFS_INOBT_BLOCK_MINRECS */
b3a96b46
DW
66 uint m_rmap_mxr[2]; /* max rmap btree records */
67 uint m_rmap_mnr[2]; /* min rmap btree records */
d8079fe0
DW
68 uint m_refc_mxr[2]; /* max refc btree records */
69 uint m_refc_mnr[2]; /* min refc btree records */
b626fb59
DC
70 uint m_ag_maxlevels; /* XFS_AG_MAXLEVELS */
71 uint m_bm_maxlevels[2]; /* XFS_BM_MAXLEVELS */
72 uint m_in_maxlevels; /* XFS_IN_MAXLEVELS */
b3a96b46 73 uint m_rmap_maxlevels; /* max rmap btree levels */
d8079fe0 74 uint m_refc_maxlevels; /* max refc btree levels */
ef5340cd 75 xfs_extlen_t m_ag_prealloc_blocks; /* reserved ag blocks */
b8a8d6e5
DW
76 uint m_alloc_set_aside; /* space we can't use */
77 uint m_ag_max_usable; /* max space per AG */
b626fb59
DC
78 struct radix_tree_root m_perag_tree;
79 uint m_flags; /* global mount flags */
74e502ac 80 bool m_inotbt_nores; /* no per-AG finobt resv. */
b626fb59
DC
81 uint m_qflags; /* quota status flags */
82 uint m_attroffset; /* inode attribute offset */
83 int m_ialloc_inos; /* inodes in inode allocation */
84 int m_ialloc_blks; /* blocks in inode allocation */
62dc6cdb
BF
85 int m_ialloc_min_blks; /* min blocks in sparse inode
86 * allocation */
b626fb59
DC
87 int m_litino; /* size of inode union area */
88 int m_inoalign_mask;/* mask sb_inoalignmt if used */
89 struct xfs_trans_resv m_resv; /* precomputed res values */
14f8b681 90 uint64_t m_maxicount; /* maximum inode count */
b626fb59
DC
91 int m_dalign; /* stripe unit */
92 int m_swidth; /* stripe width */
93 int m_sinoalign; /* stripe unit inode alignmnt */
94 const struct xfs_nameops *m_dirnameops; /* vector of dir name ops */
95
96 struct xfs_da_geometry *m_dir_geo; /* directory block geometry */
97 struct xfs_da_geometry *m_attr_geo; /* attribute block geometry */
98 const struct xfs_dir_ops *m_dir_inode_ops; /* vector of dir inode ops */
99 const struct xfs_dir_ops *m_nondir_inode_ops; /* !dir inode ops */
100#define M_DIROPS(mp) ((mp)->m_dir_inode_ops)
101
102 /*
103 * anonymous struct to allow xfs_dquot_buf.c to compile.
104 * Pointer is always null in userspace, so code does not use it at all
105 */
106 struct {
107 int qi_dqperchunk;
108 } *m_quotainfo;
109
1d6cb115
BF
110 /*
111 * xlog is defined in libxlog and thus is not intialized by libxfs. This
112 * allows an application to initialize and store a reference to the log
113 * if warranted.
114 */
115 struct xlog *m_log;
b626fb59
DC
116} xfs_mount_t;
117
cf8ce220
DW
118/* per-AG block reservation data structures*/
119enum xfs_ag_resv_type {
120 XFS_AG_RESV_NONE = 0,
9760cac2 121 XFS_AG_RESV_AGFL,
cf8ce220 122 XFS_AG_RESV_METADATA,
65a15e06 123 XFS_AG_RESV_RMAPBT,
cf8ce220
DW
124};
125
126struct xfs_ag_resv {
127 /* number of blocks originally reserved here */
128 xfs_extlen_t ar_orig_reserved;
129 /* number of blocks reserved here */
130 xfs_extlen_t ar_reserved;
131 /* number of blocks originally asked for */
132 xfs_extlen_t ar_asked;
133};
134
b626fb59
DC
135/*
136 * Per-ag incore structure, copies of information in agf and agi,
137 * to improve the performance of allocation group selection.
138 */
139typedef struct xfs_perag {
140 struct xfs_mount *pag_mount; /* owner filesystem */
141 xfs_agnumber_t pag_agno; /* AG this structure belongs to */
142 atomic_t pag_ref; /* perag reference count */
143 char pagf_init; /* this agf's entry is initialized */
144 char pagi_init; /* this agi's entry is initialized */
145 char pagf_metadata; /* the agf is preferred to be metadata */
146 char pagi_inodeok; /* The agi is ok for inodes */
14f8b681 147 uint8_t pagf_levels[XFS_BTNUM_AGF];
b626fb59 148 /* # of levels in bno & cnt btree */
8dbee8f5 149 bool pagf_agflreset; /* agfl requires reset before use */
14f8b681 150 uint32_t pagf_flcount; /* count of blocks in freelist */
b626fb59
DC
151 xfs_extlen_t pagf_freeblks; /* total free blocks */
152 xfs_extlen_t pagf_longest; /* longest free space */
14f8b681 153 uint32_t pagf_btreeblks; /* # of blocks held in AGF btrees */
b626fb59
DC
154 xfs_agino_t pagi_freecount; /* number of free inodes */
155 xfs_agino_t pagi_count; /* number of allocated inodes */
156
157 /*
158 * Inode allocation search lookup optimisation.
159 * If the pagino matches, the search for new inodes
160 * doesn't need to search the near ones again straight away
161 */
162 xfs_agino_t pagl_pagino;
163 xfs_agino_t pagl_leftrec;
164 xfs_agino_t pagl_rightrec;
165 int pagb_count; /* pagb slots in use */
cf8ce220
DW
166
167 /* Blocks reserved for all kinds of metadata. */
168 struct xfs_ag_resv pag_meta_resv;
169 /* Blocks reserved for just AGFL-based metadata. */
65a15e06 170 struct xfs_ag_resv pag_rmapbt_resv;
cf8ce220 171
88ce0792 172 /* reference count */
14f8b681 173 uint8_t pagf_refcount_level;
b626fb59
DC
174} xfs_perag_t;
175
cf8ce220
DW
176static inline struct xfs_ag_resv *
177xfs_perag_resv(
178 struct xfs_perag *pag,
179 enum xfs_ag_resv_type type)
180{
181 switch (type) {
182 case XFS_AG_RESV_METADATA:
183 return &pag->pag_meta_resv;
65a15e06
BF
184 case XFS_AG_RESV_RMAPBT:
185 return &pag->pag_rmapbt_resv;
cf8ce220
DW
186 default:
187 return NULL;
188 }
189}
190
b626fb59
DC
191#define LIBXFS_MOUNT_DEBUGGER 0x0001
192#define LIBXFS_MOUNT_32BITINODES 0x0002
193#define LIBXFS_MOUNT_32BITINOOPT 0x0004
194#define LIBXFS_MOUNT_COMPAT_ATTR 0x0008
195#define LIBXFS_MOUNT_ATTR2 0x0010
23639f77 196#define LIBXFS_MOUNT_WANT_CORRUPTED 0x0020
b626fb59
DC
197
198#define LIBXFS_BHASHSIZE(sbp) (1<<10)
199
200extern xfs_mount_t *libxfs_mount (xfs_mount_t *, xfs_sb_t *,
201 dev_t, dev_t, dev_t, int);
202extern void libxfs_umount (xfs_mount_t *);
203extern void libxfs_rtmount_destroy (xfs_mount_t *);
204
205#endif /* __XFS_MOUNT_H__ */