]>
Commit | Line | Data |
---|---|---|
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 | ||
10 | struct xfs_inode; | |
11 | struct xfs_buftarg; | |
12 | struct xfs_dir_ops; | |
13 | struct 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 | */ | |
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 | |
f866934a DW |
24 | |
25 | /* | |
26 | * Bitsets of per-fs metadata that have been checked and/or are sick. | |
27 | * Callers must hold m_sb_lock to access these two fields. | |
28 | */ | |
29 | uint8_t m_fs_checked; | |
30 | uint8_t m_fs_sick; | |
31 | ||
b626fb59 DC |
32 | char *m_fsname; /* filesystem name */ |
33 | int m_bsize; /* fs logical block size */ | |
34 | xfs_agnumber_t m_agfrotor; /* last ag where space found */ | |
35 | xfs_agnumber_t m_agirotor; /* last ag dir inode alloced */ | |
36 | xfs_agnumber_t m_maxagi; /* highest inode alloc group */ | |
e7fd2b6f | 37 | struct xfs_ino_geometry m_ino_geo; /* inode geometry */ |
b626fb59 DC |
38 | uint m_rsumlevels; /* rt summary levels */ |
39 | uint m_rsumsize; /* size of rt summary, bytes */ | |
463b0a60 OS |
40 | /* |
41 | * Optional cache of rt summary level per bitmap block with the | |
42 | * invariant that m_rsum_cache[bbno] <= the minimum i for which | |
43 | * rsum[i][bbno] != 0. Reads and writes are serialized by the rsumip | |
44 | * inode lock. | |
45 | */ | |
46 | uint8_t *m_rsum_cache; | |
b626fb59 DC |
47 | struct xfs_inode *m_rbmip; /* pointer to bitmap inode */ |
48 | struct xfs_inode *m_rsumip; /* pointer to summary inode */ | |
49 | struct xfs_buftarg *m_ddev_targp; | |
50 | struct xfs_buftarg *m_logdev_targp; | |
51 | struct xfs_buftarg *m_rtdev_targp; | |
52 | #define m_dev m_ddev_targp | |
53 | #define m_logdev m_logdev_targp | |
54 | #define m_rtdev m_rtdev_targp | |
14f8b681 DW |
55 | uint8_t m_dircook_elog; /* log d-cookie entry bits */ |
56 | uint8_t m_blkbit_log; /* blocklog + NBBY */ | |
57 | uint8_t m_blkbb_log; /* blocklog - BBSHIFT */ | |
58 | uint8_t m_sectbb_log; /* sectorlog - BBSHIFT */ | |
59 | uint8_t m_agno_log; /* log #ag's */ | |
b626fb59 DC |
60 | uint m_blockmask; /* sb_blocksize-1 */ |
61 | uint m_blockwsize; /* sb_blocksize in words */ | |
62 | uint m_blockwmask; /* blockwsize-1 */ | |
63 | uint m_alloc_mxr[2]; /* XFS_ALLOC_BLOCK_MAXRECS */ | |
64 | uint m_alloc_mnr[2]; /* XFS_ALLOC_BLOCK_MINRECS */ | |
65 | uint m_bmap_dmxr[2]; /* XFS_BMAP_BLOCK_DMAXRECS */ | |
66 | uint m_bmap_dmnr[2]; /* XFS_BMAP_BLOCK_DMINRECS */ | |
b3a96b46 DW |
67 | uint m_rmap_mxr[2]; /* max rmap btree records */ |
68 | uint m_rmap_mnr[2]; /* min rmap btree records */ | |
d8079fe0 DW |
69 | uint m_refc_mxr[2]; /* max refc btree records */ |
70 | uint m_refc_mnr[2]; /* min refc btree records */ | |
b626fb59 DC |
71 | uint m_ag_maxlevels; /* XFS_AG_MAXLEVELS */ |
72 | uint m_bm_maxlevels[2]; /* XFS_BM_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 */ | |
4c7161ce | 80 | bool m_finobt_nores; /* no per-AG finobt resv. */ |
b626fb59 DC |
81 | uint m_qflags; /* quota status flags */ |
82 | uint m_attroffset; /* inode attribute offset */ | |
b626fb59 | 83 | struct xfs_trans_resv m_resv; /* precomputed res values */ |
b626fb59 DC |
84 | int m_dalign; /* stripe unit */ |
85 | int m_swidth; /* stripe width */ | |
b626fb59 DC |
86 | const struct xfs_nameops *m_dirnameops; /* vector of dir name ops */ |
87 | ||
88 | struct xfs_da_geometry *m_dir_geo; /* directory block geometry */ | |
89 | struct xfs_da_geometry *m_attr_geo; /* attribute block geometry */ | |
90 | const struct xfs_dir_ops *m_dir_inode_ops; /* vector of dir inode ops */ | |
91 | const struct xfs_dir_ops *m_nondir_inode_ops; /* !dir inode ops */ | |
92 | #define M_DIROPS(mp) ((mp)->m_dir_inode_ops) | |
93 | ||
94 | /* | |
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 | |
97 | */ | |
98 | struct { | |
99 | int qi_dqperchunk; | |
100 | } *m_quotainfo; | |
101 | ||
1d6cb115 BF |
102 | /* |
103 | * xlog is defined in libxlog and thus is not intialized by libxfs. This | |
104 | * allows an application to initialize and store a reference to the log | |
105 | * if warranted. | |
106 | */ | |
e7fd2b6f | 107 | struct xlog *m_log; /* log specific stuff */ |
b626fb59 DC |
108 | } xfs_mount_t; |
109 | ||
e7fd2b6f DW |
110 | #define M_IGEO(mp) (&(mp)->m_ino_geo) |
111 | ||
cf8ce220 DW |
112 | /* per-AG block reservation data structures*/ |
113 | enum xfs_ag_resv_type { | |
114 | XFS_AG_RESV_NONE = 0, | |
9760cac2 | 115 | XFS_AG_RESV_AGFL, |
cf8ce220 | 116 | XFS_AG_RESV_METADATA, |
65a15e06 | 117 | XFS_AG_RESV_RMAPBT, |
cf8ce220 DW |
118 | }; |
119 | ||
120 | struct xfs_ag_resv { | |
121 | /* number of blocks originally reserved here */ | |
122 | xfs_extlen_t ar_orig_reserved; | |
123 | /* number of blocks reserved here */ | |
124 | xfs_extlen_t ar_reserved; | |
125 | /* number of blocks originally asked for */ | |
126 | xfs_extlen_t ar_asked; | |
127 | }; | |
128 | ||
b626fb59 DC |
129 | /* |
130 | * Per-ag incore structure, copies of information in agf and agi, | |
131 | * to improve the performance of allocation group selection. | |
132 | */ | |
133 | typedef struct xfs_perag { | |
134 | struct xfs_mount *pag_mount; /* owner filesystem */ | |
135 | xfs_agnumber_t pag_agno; /* AG this structure belongs to */ | |
136 | atomic_t pag_ref; /* perag reference count */ | |
137 | char pagf_init; /* this agf's entry is initialized */ | |
138 | char pagi_init; /* this agi's entry is initialized */ | |
139 | char pagf_metadata; /* the agf is preferred to be metadata */ | |
140 | char pagi_inodeok; /* The agi is ok for inodes */ | |
14f8b681 | 141 | uint8_t pagf_levels[XFS_BTNUM_AGF]; |
b626fb59 | 142 | /* # of levels in bno & cnt btree */ |
8dbee8f5 | 143 | bool pagf_agflreset; /* agfl requires reset before use */ |
14f8b681 | 144 | uint32_t pagf_flcount; /* count of blocks in freelist */ |
b626fb59 DC |
145 | xfs_extlen_t pagf_freeblks; /* total free blocks */ |
146 | xfs_extlen_t pagf_longest; /* longest free space */ | |
14f8b681 | 147 | uint32_t pagf_btreeblks; /* # of blocks held in AGF btrees */ |
b626fb59 DC |
148 | xfs_agino_t pagi_freecount; /* number of free inodes */ |
149 | xfs_agino_t pagi_count; /* number of allocated inodes */ | |
150 | ||
151 | /* | |
152 | * Inode allocation search lookup optimisation. | |
153 | * If the pagino matches, the search for new inodes | |
154 | * doesn't need to search the near ones again straight away | |
155 | */ | |
156 | xfs_agino_t pagl_pagino; | |
157 | xfs_agino_t pagl_leftrec; | |
158 | xfs_agino_t pagl_rightrec; | |
159 | int pagb_count; /* pagb slots in use */ | |
cf8ce220 DW |
160 | |
161 | /* Blocks reserved for all kinds of metadata. */ | |
162 | struct xfs_ag_resv pag_meta_resv; | |
163 | /* Blocks reserved for just AGFL-based metadata. */ | |
65a15e06 | 164 | struct xfs_ag_resv pag_rmapbt_resv; |
cf8ce220 | 165 | |
88ce0792 | 166 | /* reference count */ |
14f8b681 | 167 | uint8_t pagf_refcount_level; |
b626fb59 DC |
168 | } xfs_perag_t; |
169 | ||
cf8ce220 DW |
170 | static inline struct xfs_ag_resv * |
171 | xfs_perag_resv( | |
172 | struct xfs_perag *pag, | |
173 | enum xfs_ag_resv_type type) | |
174 | { | |
175 | switch (type) { | |
176 | case XFS_AG_RESV_METADATA: | |
177 | return &pag->pag_meta_resv; | |
65a15e06 BF |
178 | case XFS_AG_RESV_RMAPBT: |
179 | return &pag->pag_rmapbt_resv; | |
cf8ce220 DW |
180 | default: |
181 | return NULL; | |
182 | } | |
183 | } | |
184 | ||
b626fb59 DC |
185 | #define LIBXFS_MOUNT_DEBUGGER 0x0001 |
186 | #define LIBXFS_MOUNT_32BITINODES 0x0002 | |
187 | #define LIBXFS_MOUNT_32BITINOOPT 0x0004 | |
188 | #define LIBXFS_MOUNT_COMPAT_ATTR 0x0008 | |
189 | #define LIBXFS_MOUNT_ATTR2 0x0010 | |
23639f77 | 190 | #define LIBXFS_MOUNT_WANT_CORRUPTED 0x0020 |
b626fb59 DC |
191 | |
192 | #define LIBXFS_BHASHSIZE(sbp) (1<<10) | |
193 | ||
194 | extern xfs_mount_t *libxfs_mount (xfs_mount_t *, xfs_sb_t *, | |
195 | dev_t, dev_t, dev_t, int); | |
196 | extern void libxfs_umount (xfs_mount_t *); | |
197 | extern void libxfs_rtmount_destroy (xfs_mount_t *); | |
198 | ||
199 | #endif /* __XFS_MOUNT_H__ */ |