10b61f8a4SDave Chinner// SPDX-License-Identifier: GPL-2.0
21da177e4SLinus Torvalds/*
37b718769SNathan Scott * Copyright (c) 2000-2005 Silicon Graphics, Inc.
47b718769SNathan Scott * All Rights Reserved.
51da177e4SLinus Torvalds */
61da177e4SLinus Torvalds#ifndef __XFS_MOUNT_H__
71da177e4SLinus Torvalds#define	__XFS_MOUNT_H__
81da177e4SLinus Torvalds
9ad223e60SMark Tinguelystruct xlog;
101da177e4SLinus Torvaldsstruct xfs_inode;
112a82b8beSDavid Chinnerstruct xfs_mru_cache;
1282fa9012SDavid Chinnerstruct xfs_ail;
137d095257SChristoph Hellwigstruct xfs_quotainfo;
140650b554SDave Chinnerstruct xfs_da_geometry;
1507b6403aSDave Chinnerstruct xfs_perag;
167d095257SChristoph Hellwig
17055388a3SDave Chinner/* dynamic preallocation free space thresholds, 5% down to 1% */
18055388a3SDave Chinnerenum {
19055388a3SDave Chinner	XFS_LOWSP_1_PCNT = 0,
20055388a3SDave Chinner	XFS_LOWSP_2_PCNT,
21055388a3SDave Chinner	XFS_LOWSP_3_PCNT,
22055388a3SDave Chinner	XFS_LOWSP_4_PCNT,
23055388a3SDave Chinner	XFS_LOWSP_5_PCNT,
24055388a3SDave Chinner	XFS_LOWSP_MAX,
25055388a3SDave Chinner};
26055388a3SDave Chinner
27192852beSCarlos Maiolino/*
28192852beSCarlos Maiolino * Error Configuration
29192852beSCarlos Maiolino *
30192852beSCarlos Maiolino * Error classes define the subsystem the configuration belongs to.
31192852beSCarlos Maiolino * Error numbers define the errors that are configurable.
32192852beSCarlos Maiolino */
33192852beSCarlos Maiolinoenum {
34ffd40ef6SCarlos Maiolino	XFS_ERR_METADATA,
35192852beSCarlos Maiolino	XFS_ERR_CLASS_MAX,
36192852beSCarlos Maiolino};
37192852beSCarlos Maiolinoenum {
38ffd40ef6SCarlos Maiolino	XFS_ERR_DEFAULT,
39e0a431b3SCarlos Maiolino	XFS_ERR_EIO,
40e0a431b3SCarlos Maiolino	XFS_ERR_ENOSPC,
41e0a431b3SCarlos Maiolino	XFS_ERR_ENODEV,
42192852beSCarlos Maiolino	XFS_ERR_ERRNO_MAX,
43192852beSCarlos Maiolino};
44192852beSCarlos Maiolino
45a5ea70d2SCarlos Maiolino#define XFS_ERR_RETRY_FOREVER	-1
46a5ea70d2SCarlos Maiolino
4777169812SEric Sandeen/*
4877169812SEric Sandeen * Although retry_timeout is in jiffies which is normally an unsigned long,
4977169812SEric Sandeen * we limit the retry timeout to 86400 seconds, or one day.  So even a
5077169812SEric Sandeen * signed 32-bit long is sufficient for a HZ value up to 24855.  Making it
5177169812SEric Sandeen * signed lets us store the special "-1" value, meaning retry forever.
5277169812SEric Sandeen */
53192852beSCarlos Maiolinostruct xfs_error_cfg {
54192852beSCarlos Maiolino	struct xfs_kobj	kobj;
55192852beSCarlos Maiolino	int		max_retries;
5677169812SEric Sandeen	long		retry_timeout;	/* in jiffies, -1 = infinite */
57192852beSCarlos Maiolino};
58192852beSCarlos Maiolino
59ab23a776SDave Chinner/*
60ab23a776SDave Chinner * Per-cpu deferred inode inactivation GC lists.
61ab23a776SDave Chinner */
62ab23a776SDave Chinnerstruct xfs_inodegc {
63ab23a776SDave Chinner	struct llist_head	list;
64ab23a776SDave Chinner	struct work_struct	work;
65ab23a776SDave Chinner
66ab23a776SDave Chinner	/* approximate count of inodes in the list */
67ab23a776SDave Chinner	unsigned int		items;
6840b1de00SDarrick J. Wong	unsigned int		shrinker_hits;
69ab23a776SDave Chinner};
70ab23a776SDave Chinner
71b0dff466SDave Chinner/*
72b0dff466SDave Chinner * The struct xfsmount layout is optimised to separate read-mostly variables
73b0dff466SDave Chinner * from variables that are frequently modified. We put the read-mostly variables
74b0dff466SDave Chinner * first, then place all the other variables at the end.
75b0dff466SDave Chinner *
76b0dff466SDave Chinner * Typically, read-mostly variables are those that are set at mount time and
77b0dff466SDave Chinner * never changed again, or only change rarely as a result of things like sysfs
78b0dff466SDave Chinner * knobs being tweaked.
79b0dff466SDave Chinner */
801da177e4SLinus Torvaldstypedef struct xfs_mount {
81b0dff466SDave Chinner	struct xfs_sb		m_sb;		/* copy of fs superblock */
82b267ce99SChristoph Hellwig	struct super_block	*m_super;
8382fa9012SDavid Chinner	struct xfs_ail		*m_ail;		/* fs active log item list */
841da177e4SLinus Torvalds	struct xfs_buf		*m_sb_bp;	/* buffer for superblock */
85fc1f8c1cSNathan Scott	char			*m_rtname;	/* realtime device name */
86fc1f8c1cSNathan Scott	char			*m_logname;	/* external log device name */
870650b554SDave Chinner	struct xfs_da_geometry	*m_dir_geo;	/* directory block geometry */
880650b554SDave Chinner	struct xfs_da_geometry	*m_attr_geo;	/* attribute block geometry */
89ad223e60SMark Tinguely	struct xlog		*m_log;		/* log specific stuff */
901da177e4SLinus Torvalds	struct xfs_inode	*m_rbmip;	/* pointer to bitmap inode */
911da177e4SLinus Torvalds	struct xfs_inode	*m_rsumip;	/* pointer to summary inode */
921da177e4SLinus Torvalds	struct xfs_inode	*m_rootip;	/* pointer to root directory */
931da177e4SLinus Torvalds	struct xfs_quotainfo	*m_quotainfo;	/* disk quota information */
941da177e4SLinus Torvalds	xfs_buftarg_t		*m_ddev_targp;	/* saves taking the address */
951da177e4SLinus Torvalds	xfs_buftarg_t		*m_logdev_targp;/* ptr to log device */
961da177e4SLinus Torvalds	xfs_buftarg_t		*m_rtdev_targp;	/* ptr to rt device */
970ed17f01SDave Chinner	struct list_head	m_mount_list;	/* global mount list */
98ab23a776SDave Chinner	void __percpu		*m_inodegc;	/* percpu inodegc structures */
99ab23a776SDave Chinner
100b0dff466SDave Chinner	/*
101b0dff466SDave Chinner	 * Optional cache of rt summary level per bitmap block with the
102b0dff466SDave Chinner	 * invariant that m_rsum_cache[bbno] <= the minimum i for which
103b0dff466SDave Chinner	 * rsum[i][bbno] != 0. Reads and writes are serialized by the rsumip
104b0dff466SDave Chinner	 * inode lock.
105b0dff466SDave Chinner	 */
106b0dff466SDave Chinner	uint8_t			*m_rsum_cache;
107b0dff466SDave Chinner	struct xfs_mru_cache	*m_filestream;  /* per-mount filestream data */
108b0dff466SDave Chinner	struct workqueue_struct *m_buf_workqueue;
109b0dff466SDave Chinner	struct workqueue_struct	*m_unwritten_workqueue;
110b0dff466SDave Chinner	struct workqueue_struct	*m_reclaim_workqueue;
111b0dff466SDave Chinner	struct workqueue_struct	*m_sync_workqueue;
112ab23a776SDave Chinner	struct workqueue_struct *m_blockgc_wq;
113ab23a776SDave Chinner	struct workqueue_struct *m_inodegc_wq;
114b0dff466SDave Chinner
115b0dff466SDave Chinner	int			m_bsize;	/* fs logical block size */
116c8ce540dSDarrick J. Wong	uint8_t			m_blkbit_log;	/* blocklog + NBBY */
117c8ce540dSDarrick J. Wong	uint8_t			m_blkbb_log;	/* blocklog - BBSHIFT */
118c8ce540dSDarrick J. Wong	uint8_t			m_agno_log;	/* log #ag's */
119b0dff466SDave Chinner	uint8_t			m_sectbb_log;	/* sectlog - BBSHIFT */
1201da177e4SLinus Torvalds	uint			m_blockmask;	/* sb_blocksize-1 */
1211da177e4SLinus Torvalds	uint			m_blockwsize;	/* sb_blocksize in words */
1221da177e4SLinus Torvalds	uint			m_blockwmask;	/* blockwsize-1 */
12360197e8dSChristoph Hellwig	uint			m_alloc_mxr[2];	/* max alloc btree records */
12460197e8dSChristoph Hellwig	uint			m_alloc_mnr[2];	/* min alloc btree records */
12560197e8dSChristoph Hellwig	uint			m_bmap_dmxr[2];	/* max bmap btree records */
12660197e8dSChristoph Hellwig	uint			m_bmap_dmnr[2];	/* min bmap btree records */
127035e00acSDarrick J. Wong	uint			m_rmap_mxr[2];	/* max rmap btree records */
128035e00acSDarrick J. Wong	uint			m_rmap_mnr[2];	/* min rmap btree records */
1291946b91cSDarrick J. Wong	uint			m_refc_mxr[2];	/* max refc btree records */
1301946b91cSDarrick J. Wong	uint			m_refc_mnr[2];	/* min refc btree records */
1317cb3efb4SDarrick J. Wong	uint			m_alloc_maxlevels; /* max alloc btree levels */
1327cb3efb4SDarrick J. Wong	uint			m_bm_maxlevels[2]; /* max bmap btree levels */
133035e00acSDarrick J. Wong	uint			m_rmap_maxlevels; /* max rmap btree levels */
1341946b91cSDarrick J. Wong	uint			m_refc_maxlevels; /* max refcount btree level */
135b74e15d7SDarrick J. Wong	unsigned int		m_agbtree_maxlevels; /* max level of all AG btrees */
1368018026eSDarrick J. Wong	xfs_extlen_t		m_ag_prealloc_blocks; /* reserved ag blocks */
13752548852SDarrick J. Wong	uint			m_alloc_set_aside; /* space we can't use */
13852548852SDarrick J. Wong	uint			m_ag_max_usable; /* max space per AG */
139b0dff466SDave Chinner	int			m_dalign;	/* stripe unit */
140b0dff466SDave Chinner	int			m_swidth;	/* stripe width */
141b0dff466SDave Chinner	xfs_agnumber_t		m_maxagi;	/* highest inode alloc group */
142b0dff466SDave Chinner	uint			m_allocsize_log;/* min write size log bytes */
143b0dff466SDave Chinner	uint			m_allocsize_blocks; /* min write size blocks */
144b0dff466SDave Chinner	int			m_logbufs;	/* number of log buffers */
145b0dff466SDave Chinner	int			m_logbsize;	/* size of each log buffer */
146b0dff466SDave Chinner	uint			m_rsumlevels;	/* rt summary levels */
147b0dff466SDave Chinner	uint			m_rsumsize;	/* size of rt summary, bytes */
1481da177e4SLinus Torvalds	int			m_fixedfsid[2];	/* unchanged for life of FS */
1491da177e4SLinus Torvalds	uint			m_qflags;	/* quota status flags */
150a1d86e8dSDave Chinner	uint64_t		m_features;	/* active filesystem features */
15165f03d86SDarrick J. Wong	uint64_t		m_low_space[XFS_LOWSP_MAX];
15265f03d86SDarrick J. Wong	uint64_t		m_low_rtexts[XFS_LOWSP_MAX];
153b0dff466SDave Chinner	struct xfs_ino_geometry	m_ino_geo;	/* inode geometry */
1540eadd102SJie Liu	struct xfs_trans_resv	m_resv;		/* precomputed res values */
155b0dff466SDave Chinner						/* low free space thresholds */
156ab23a776SDave Chinner	unsigned long		m_opstate;	/* dynamic state flags */
157b0dff466SDave Chinner	bool			m_always_cow;
158b0dff466SDave Chinner	bool			m_fail_unmount;
159b0dff466SDave Chinner	bool			m_finobt_nores; /* no per-AG finobt resv. */
160b0dff466SDave Chinner	bool			m_update_sb;	/* sb needs update in mount */
161b0dff466SDave Chinner
162b0dff466SDave Chinner	/*
163b0dff466SDave Chinner	 * Bitsets of per-fs metadata that have been checked and/or are sick.
164b0dff466SDave Chinner	 * Callers must hold m_sb_lock to access these two fields.
165b0dff466SDave Chinner	 */
166b0dff466SDave Chinner	uint8_t			m_fs_checked;
167b0dff466SDave Chinner	uint8_t			m_fs_sick;
168b0dff466SDave Chinner	/*
169b0dff466SDave Chinner	 * Bitsets of rt metadata that have been checked and/or are sick.
170b0dff466SDave Chinner	 * Callers must hold m_sb_lock to access this field.
171b0dff466SDave Chinner	 */
172b0dff466SDave Chinner	uint8_t			m_rt_checked;
173b0dff466SDave Chinner	uint8_t			m_rt_sick;
174b0dff466SDave Chinner
175b0dff466SDave Chinner	/*
176b0dff466SDave Chinner	 * End of read-mostly variables. Frequently written variables and locks
177b0dff466SDave Chinner	 * should be placed below this comment from now on. The first variable
178b0dff466SDave Chinner	 * here is marked as cacheline aligned so they it is separated from
179b0dff466SDave Chinner	 * the read-mostly variables.
180b0dff466SDave Chinner	 */
181b0dff466SDave Chinner
182b0dff466SDave Chinner	spinlock_t ____cacheline_aligned m_sb_lock; /* sb counter lock */
183b0dff466SDave Chinner	struct percpu_counter	m_icount;	/* allocated inodes counter */
184b0dff466SDave Chinner	struct percpu_counter	m_ifree;	/* free inodes counter */
185b0dff466SDave Chinner	struct percpu_counter	m_fdblocks;	/* free block counter */
186b0dff466SDave Chinner	/*
187b0dff466SDave Chinner	 * Count of data device blocks reserved for delayed allocations,
188b0dff466SDave Chinner	 * including indlen blocks.  Does not include allocated CoW staging
189b0dff466SDave Chinner	 * extents or anything related to the rt device.
190b0dff466SDave Chinner	 */
191b0dff466SDave Chinner	struct percpu_counter	m_delalloc_blks;
19216eaab83SBrian Foster	/*
19316eaab83SBrian Foster	 * Global count of allocation btree blocks in use across all AGs. Only
19416eaab83SBrian Foster	 * used when perag reservation is enabled. Helps prevent block
19516eaab83SBrian Foster	 * reservation from attempting to reserve allocation btree blocks.
19616eaab83SBrian Foster	 */
19716eaab83SBrian Foster	atomic64_t		m_allocbt_blks;
198b0dff466SDave Chinner