162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2000-2005 Silicon Graphics, Inc. 462306a36Sopenharmony_ci * All Rights Reserved. 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci#ifndef __XFS_MOUNT_H__ 762306a36Sopenharmony_ci#define __XFS_MOUNT_H__ 862306a36Sopenharmony_ci 962306a36Sopenharmony_cistruct xlog; 1062306a36Sopenharmony_cistruct xfs_inode; 1162306a36Sopenharmony_cistruct xfs_mru_cache; 1262306a36Sopenharmony_cistruct xfs_ail; 1362306a36Sopenharmony_cistruct xfs_quotainfo; 1462306a36Sopenharmony_cistruct xfs_da_geometry; 1562306a36Sopenharmony_cistruct xfs_perag; 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci/* dynamic preallocation free space thresholds, 5% down to 1% */ 1862306a36Sopenharmony_cienum { 1962306a36Sopenharmony_ci XFS_LOWSP_1_PCNT = 0, 2062306a36Sopenharmony_ci XFS_LOWSP_2_PCNT, 2162306a36Sopenharmony_ci XFS_LOWSP_3_PCNT, 2262306a36Sopenharmony_ci XFS_LOWSP_4_PCNT, 2362306a36Sopenharmony_ci XFS_LOWSP_5_PCNT, 2462306a36Sopenharmony_ci XFS_LOWSP_MAX, 2562306a36Sopenharmony_ci}; 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci/* 2862306a36Sopenharmony_ci * Error Configuration 2962306a36Sopenharmony_ci * 3062306a36Sopenharmony_ci * Error classes define the subsystem the configuration belongs to. 3162306a36Sopenharmony_ci * Error numbers define the errors that are configurable. 3262306a36Sopenharmony_ci */ 3362306a36Sopenharmony_cienum { 3462306a36Sopenharmony_ci XFS_ERR_METADATA, 3562306a36Sopenharmony_ci XFS_ERR_CLASS_MAX, 3662306a36Sopenharmony_ci}; 3762306a36Sopenharmony_cienum { 3862306a36Sopenharmony_ci XFS_ERR_DEFAULT, 3962306a36Sopenharmony_ci XFS_ERR_EIO, 4062306a36Sopenharmony_ci XFS_ERR_ENOSPC, 4162306a36Sopenharmony_ci XFS_ERR_ENODEV, 4262306a36Sopenharmony_ci XFS_ERR_ERRNO_MAX, 4362306a36Sopenharmony_ci}; 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci#define XFS_ERR_RETRY_FOREVER -1 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci/* 4862306a36Sopenharmony_ci * Although retry_timeout is in jiffies which is normally an unsigned long, 4962306a36Sopenharmony_ci * we limit the retry timeout to 86400 seconds, or one day. So even a 5062306a36Sopenharmony_ci * signed 32-bit long is sufficient for a HZ value up to 24855. Making it 5162306a36Sopenharmony_ci * signed lets us store the special "-1" value, meaning retry forever. 5262306a36Sopenharmony_ci */ 5362306a36Sopenharmony_cistruct xfs_error_cfg { 5462306a36Sopenharmony_ci struct xfs_kobj kobj; 5562306a36Sopenharmony_ci int max_retries; 5662306a36Sopenharmony_ci long retry_timeout; /* in jiffies, -1 = infinite */ 5762306a36Sopenharmony_ci}; 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci/* 6062306a36Sopenharmony_ci * Per-cpu deferred inode inactivation GC lists. 6162306a36Sopenharmony_ci */ 6262306a36Sopenharmony_cistruct xfs_inodegc { 6362306a36Sopenharmony_ci struct xfs_mount *mp; 6462306a36Sopenharmony_ci struct llist_head list; 6562306a36Sopenharmony_ci struct delayed_work work; 6662306a36Sopenharmony_ci int error; 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci /* approximate count of inodes in the list */ 6962306a36Sopenharmony_ci unsigned int items; 7062306a36Sopenharmony_ci unsigned int shrinker_hits; 7162306a36Sopenharmony_ci unsigned int cpu; 7262306a36Sopenharmony_ci}; 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci/* 7562306a36Sopenharmony_ci * The struct xfsmount layout is optimised to separate read-mostly variables 7662306a36Sopenharmony_ci * from variables that are frequently modified. We put the read-mostly variables 7762306a36Sopenharmony_ci * first, then place all the other variables at the end. 7862306a36Sopenharmony_ci * 7962306a36Sopenharmony_ci * Typically, read-mostly variables are those that are set at mount time and 8062306a36Sopenharmony_ci * never changed again, or only change rarely as a result of things like sysfs 8162306a36Sopenharmony_ci * knobs being tweaked. 8262306a36Sopenharmony_ci */ 8362306a36Sopenharmony_citypedef struct xfs_mount { 8462306a36Sopenharmony_ci struct xfs_sb m_sb; /* copy of fs superblock */ 8562306a36Sopenharmony_ci struct super_block *m_super; 8662306a36Sopenharmony_ci struct xfs_ail *m_ail; /* fs active log item list */ 8762306a36Sopenharmony_ci struct xfs_buf *m_sb_bp; /* buffer for superblock */ 8862306a36Sopenharmony_ci char *m_rtname; /* realtime device name */ 8962306a36Sopenharmony_ci char *m_logname; /* external log device name */ 9062306a36Sopenharmony_ci struct xfs_da_geometry *m_dir_geo; /* directory block geometry */ 9162306a36Sopenharmony_ci struct xfs_da_geometry *m_attr_geo; /* attribute block geometry */ 9262306a36Sopenharmony_ci struct xlog *m_log; /* log specific stuff */ 9362306a36Sopenharmony_ci struct xfs_inode *m_rbmip; /* pointer to bitmap inode */ 9462306a36Sopenharmony_ci struct xfs_inode *m_rsumip; /* pointer to summary inode */ 9562306a36Sopenharmony_ci struct xfs_inode *m_rootip; /* pointer to root directory */ 9662306a36Sopenharmony_ci struct xfs_quotainfo *m_quotainfo; /* disk quota information */ 9762306a36Sopenharmony_ci xfs_buftarg_t *m_ddev_targp; /* saves taking the address */ 9862306a36Sopenharmony_ci xfs_buftarg_t *m_logdev_targp;/* ptr to log device */ 9962306a36Sopenharmony_ci xfs_buftarg_t *m_rtdev_targp; /* ptr to rt device */ 10062306a36Sopenharmony_ci void __percpu *m_inodegc; /* percpu inodegc structures */ 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ci /* 10362306a36Sopenharmony_ci * Optional cache of rt summary level per bitmap block with the 10462306a36Sopenharmony_ci * invariant that m_rsum_cache[bbno] <= the minimum i for which 10562306a36Sopenharmony_ci * rsum[i][bbno] != 0. Reads and writes are serialized by the rsumip 10662306a36Sopenharmony_ci * inode lock. 10762306a36Sopenharmony_ci */ 10862306a36Sopenharmony_ci uint8_t *m_rsum_cache; 10962306a36Sopenharmony_ci struct xfs_mru_cache *m_filestream; /* per-mount filestream data */ 11062306a36Sopenharmony_ci struct workqueue_struct *m_buf_workqueue; 11162306a36Sopenharmony_ci struct workqueue_struct *m_unwritten_workqueue; 11262306a36Sopenharmony_ci struct workqueue_struct *m_reclaim_workqueue; 11362306a36Sopenharmony_ci struct workqueue_struct *m_sync_workqueue; 11462306a36Sopenharmony_ci struct workqueue_struct *m_blockgc_wq; 11562306a36Sopenharmony_ci struct workqueue_struct *m_inodegc_wq; 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci int m_bsize; /* fs logical block size */ 11862306a36Sopenharmony_ci uint8_t m_blkbit_log; /* blocklog + NBBY */ 11962306a36Sopenharmony_ci uint8_t m_blkbb_log; /* blocklog - BBSHIFT */ 12062306a36Sopenharmony_ci uint8_t m_agno_log; /* log #ag's */ 12162306a36Sopenharmony_ci uint8_t m_sectbb_log; /* sectlog - BBSHIFT */ 12262306a36Sopenharmony_ci uint m_blockmask; /* sb_blocksize-1 */ 12362306a36Sopenharmony_ci uint m_blockwsize; /* sb_blocksize in words */ 12462306a36Sopenharmony_ci uint m_blockwmask; /* blockwsize-1 */ 12562306a36Sopenharmony_ci uint m_alloc_mxr[2]; /* max alloc btree records */ 12662306a36Sopenharmony_ci uint m_alloc_mnr[2]; /* min alloc btree records */ 12762306a36Sopenharmony_ci uint m_bmap_dmxr[2]; /* max bmap btree records */ 12862306a36Sopenharmony_ci uint m_bmap_dmnr[2]; /* min bmap btree records */ 12962306a36Sopenharmony_ci uint m_rmap_mxr[2]; /* max rmap btree records */ 13062306a36Sopenharmony_ci uint m_rmap_mnr[2]; /* min rmap btree records */ 13162306a36Sopenharmony_ci uint m_refc_mxr[2]; /* max refc btree records */ 13262306a36Sopenharmony_ci uint m_refc_mnr[2]; /* min refc btree records */ 13362306a36Sopenharmony_ci uint m_alloc_maxlevels; /* max alloc btree levels */ 13462306a36Sopenharmony_ci uint m_bm_maxlevels[2]; /* max bmap btree levels */ 13562306a36Sopenharmony_ci uint m_rmap_maxlevels; /* max rmap btree levels */ 13662306a36Sopenharmony_ci uint m_refc_maxlevels; /* max refcount btree level */ 13762306a36Sopenharmony_ci unsigned int m_agbtree_maxlevels; /* max level of all AG btrees */ 13862306a36Sopenharmony_ci xfs_extlen_t m_ag_prealloc_blocks; /* reserved ag blocks */ 13962306a36Sopenharmony_ci uint m_alloc_set_aside; /* space we can't use */ 14062306a36Sopenharmony_ci uint m_ag_max_usable; /* max space per AG */ 14162306a36Sopenharmony_ci int m_dalign; /* stripe unit */ 14262306a36Sopenharmony_ci int m_swidth; /* stripe width */ 14362306a36Sopenharmony_ci xfs_agnumber_t m_maxagi; /* highest inode alloc group */ 14462306a36Sopenharmony_ci uint m_allocsize_log;/* min write size log bytes */ 14562306a36Sopenharmony_ci uint m_allocsize_blocks; /* min write size blocks */ 14662306a36Sopenharmony_ci int m_logbufs; /* number of log buffers */ 14762306a36Sopenharmony_ci int m_logbsize; /* size of each log buffer */ 14862306a36Sopenharmony_ci uint m_rsumlevels; /* rt summary levels */ 14962306a36Sopenharmony_ci uint m_rsumsize; /* size of rt summary, bytes */ 15062306a36Sopenharmony_ci int m_fixedfsid[2]; /* unchanged for life of FS */ 15162306a36Sopenharmony_ci uint m_qflags; /* quota status flags */ 15262306a36Sopenharmony_ci uint64_t m_features; /* active filesystem features */ 15362306a36Sopenharmony_ci uint64_t m_low_space[XFS_LOWSP_MAX]; 15462306a36Sopenharmony_ci uint64_t m_low_rtexts[XFS_LOWSP_MAX]; 15562306a36Sopenharmony_ci struct xfs_ino_geometry m_ino_geo; /* inode geometry */ 15662306a36Sopenharmony_ci struct xfs_trans_resv m_resv; /* precomputed res values */ 15762306a36Sopenharmony_ci /* low free space thresholds */ 15862306a36Sopenharmony_ci unsigned long m_opstate; /* dynamic state flags */ 15962306a36Sopenharmony_ci bool m_always_cow; 16062306a36Sopenharmony_ci bool m_fail_unmount; 16162306a36Sopenharmony_ci bool m_finobt_nores; /* no per-AG finobt resv. */ 16262306a36Sopenharmony_ci bool m_update_sb; /* sb needs update in mount */ 16362306a36Sopenharmony_ci 16462306a36Sopenharmony_ci /* 16562306a36Sopenharmony_ci * Bitsets of per-fs metadata that have been checked and/or are sick. 16662306a36Sopenharmony_ci * Callers must hold m_sb_lock to access these two fields. 16762306a36Sopenharmony_ci */ 16862306a36Sopenharmony_ci uint8_t m_fs_checked; 16962306a36Sopenharmony_ci uint8_t m_fs_sick; 17062306a36Sopenharmony_ci /* 17162306a36Sopenharmony_ci * Bitsets of rt metadata that have been checked and/or are sick. 17262306a36Sopenharmony_ci * Callers must hold m_sb_lock to access this field. 17362306a36Sopenharmony_ci */ 17462306a36Sopenharmony_ci uint8_t m_rt_checked; 17562306a36Sopenharmony_ci uint8_t m_rt_sick; 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ci /* 17862306a36Sopenharmony_ci * End of read-mostly variables. Frequently written variables and locks 17962306a36Sopenharmony_ci * should be placed below this comment from now on. The first variable 18062306a36Sopenharmony_ci * here is marked as cacheline aligned so they it is separated from 18162306a36Sopenharmony_ci * the read-mostly variables. 18262306a36Sopenharmony_ci */ 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_ci spinlock_t ____cacheline_aligned m_sb_lock; /* sb counter lock */ 18562306a36Sopenharmony_ci struct percpu_counter m_icount; /* allocated inodes counter */ 18662306a36Sopenharmony_ci struct percpu_counter m_ifree; /* free inodes counter */ 18762306a36Sopenharmony_ci struct percpu_counter m_fdblocks; /* free block counter */ 18862306a36Sopenharmony_ci struct percpu_counter m_frextents; /* free rt extent counter */ 18962306a36Sopenharmony_ci 19062306a36Sopenharmony_ci /* 19162306a36Sopenharmony_ci * Count of data device blocks reserved for delayed allocations, 19262306a36Sopenharmony_ci * including indlen blocks. Does not include allocated CoW staging 19362306a36Sopenharmony_ci * extents or anything related to the rt device. 19462306a36Sopenharmony_ci */ 19562306a36Sopenharmony_ci struct percpu_counter m_delalloc_blks; 19662306a36Sopenharmony_ci /* 19762306a36Sopenharmony_ci * Global count of allocation btree blocks in use across all AGs. Only 19862306a36Sopenharmony_ci * used when perag reservation is enabled. Helps prevent block 19962306a36Sopenharmony_ci * reservation from attempting to reserve allocation btree blocks. 20062306a36Sopenharmony_ci */ 20162306a36Sopenharmony_ci atomic64_t m_allocbt_blks; 20262306a36Sopenharmony_ci 20362306a36Sopenharmony_ci struct radix_tree_root m_perag_tree; /* per-ag accounting info */ 20462306a36Sopenharmony_ci spinlock_t m_perag_lock; /* lock for m_perag_tree */ 20562306a36Sopenharmony_ci uint64_t m_resblks; /* total reserved blocks */ 20662306a36Sopenharmony_ci uint64_t m_resblks_avail;/* available reserved blocks */ 20762306a36Sopenharmony_ci uint64_t m_resblks_save; /* reserved blks @ remount,ro */ 20862306a36Sopenharmony_ci struct delayed_work m_reclaim_work; /* background inode reclaim */ 20962306a36Sopenharmony_ci struct dentry *m_debugfs; /* debugfs parent */ 21062306a36Sopenharmony_ci struct xfs_kobj m_kobj; 21162306a36Sopenharmony_ci struct xfs_kobj m_error_kobj; 21262306a36Sopenharmony_ci struct xfs_kobj m_error_meta_kobj; 21362306a36Sopenharmony_ci struct xfs_error_cfg m_error_cfg[XFS_ERR_CLASS_MAX][XFS_ERR_ERRNO_MAX]; 21462306a36Sopenharmony_ci struct xstats m_stats; /* per-fs stats */ 21562306a36Sopenharmony_ci#ifdef CONFIG_XFS_ONLINE_SCRUB_STATS 21662306a36Sopenharmony_ci struct xchk_stats *m_scrub_stats; 21762306a36Sopenharmony_ci#endif 21862306a36Sopenharmony_ci xfs_agnumber_t m_agfrotor; /* last ag where space found */ 21962306a36Sopenharmony_ci atomic_t m_agirotor; /* last ag dir inode alloced */ 22062306a36Sopenharmony_ci 22162306a36Sopenharmony_ci /* Memory shrinker to throttle and reprioritize inodegc */ 22262306a36Sopenharmony_ci struct shrinker m_inodegc_shrinker; 22362306a36Sopenharmony_ci /* 22462306a36Sopenharmony_ci * Workqueue item so that we can coalesce multiple inode flush attempts 22562306a36Sopenharmony_ci * into a single flush. 22662306a36Sopenharmony_ci */ 22762306a36Sopenharmony_ci struct work_struct m_flush_inodes_work; 22862306a36Sopenharmony_ci 22962306a36Sopenharmony_ci /* 23062306a36Sopenharmony_ci * Generation of the filesysyem layout. This is incremented by each 23162306a36Sopenharmony_ci * growfs, and used by the pNFS server to ensure the client updates 23262306a36Sopenharmony_ci * its view of the block device once it gets a layout that might 23362306a36Sopenharmony_ci * reference the newly added blocks. Does not need to be persistent 23462306a36Sopenharmony_ci * as long as we only allow file system size increments, but if we 23562306a36Sopenharmony_ci * ever support shrinks it would have to be persisted in addition 23662306a36Sopenharmony_ci * to various other kinds of pain inflicted on the pNFS server. 23762306a36Sopenharmony_ci */ 23862306a36Sopenharmony_ci uint32_t m_generation; 23962306a36Sopenharmony_ci struct mutex m_growlock; /* growfs mutex */ 24062306a36Sopenharmony_ci 24162306a36Sopenharmony_ci#ifdef DEBUG 24262306a36Sopenharmony_ci /* 24362306a36Sopenharmony_ci * Frequency with which errors are injected. Replaces xfs_etest; the 24462306a36Sopenharmony_ci * value stored in here is the inverse of the frequency with which the 24562306a36Sopenharmony_ci * error triggers. 1 = always, 2 = half the time, etc. 24662306a36Sopenharmony_ci */ 24762306a36Sopenharmony_ci unsigned int *m_errortag; 24862306a36Sopenharmony_ci struct xfs_kobj m_errortag_kobj; 24962306a36Sopenharmony_ci#endif 25062306a36Sopenharmony_ci 25162306a36Sopenharmony_ci /* cpus that have inodes queued for inactivation */ 25262306a36Sopenharmony_ci struct cpumask m_inodegc_cpumask; 25362306a36Sopenharmony_ci} xfs_mount_t; 25462306a36Sopenharmony_ci 25562306a36Sopenharmony_ci#define M_IGEO(mp) (&(mp)->m_ino_geo) 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_ci/* 25862306a36Sopenharmony_ci * Flags for m_features. 25962306a36Sopenharmony_ci * 26062306a36Sopenharmony_ci * These are all the active features in the filesystem, regardless of how 26162306a36Sopenharmony_ci * they are configured. 26262306a36Sopenharmony_ci */ 26362306a36Sopenharmony_ci#define XFS_FEAT_ATTR (1ULL << 0) /* xattrs present in fs */ 26462306a36Sopenharmony_ci#define XFS_FEAT_NLINK (1ULL << 1) /* 32 bit link counts */ 26562306a36Sopenharmony_ci#define XFS_FEAT_QUOTA (1ULL << 2) /* quota active */ 26662306a36Sopenharmony_ci#define XFS_FEAT_ALIGN (1ULL << 3) /* inode alignment */ 26762306a36Sopenharmony_ci#define XFS_FEAT_DALIGN (1ULL << 4) /* data alignment */ 26862306a36Sopenharmony_ci#define XFS_FEAT_LOGV2 (1ULL << 5) /* version 2 logs */ 26962306a36Sopenharmony_ci#define XFS_FEAT_SECTOR (1ULL << 6) /* sector size > 512 bytes */ 27062306a36Sopenharmony_ci#define XFS_FEAT_EXTFLG (1ULL << 7) /* unwritten extents */ 27162306a36Sopenharmony_ci#define XFS_FEAT_ASCIICI (1ULL << 8) /* ASCII only case-insens. */ 27262306a36Sopenharmony_ci#define XFS_FEAT_LAZYSBCOUNT (1ULL << 9) /* Superblk counters */ 27362306a36Sopenharmony_ci#define XFS_FEAT_ATTR2 (1ULL << 10) /* dynamic attr fork */ 27462306a36Sopenharmony_ci#define XFS_FEAT_PARENT (1ULL << 11) /* parent pointers */ 27562306a36Sopenharmony_ci#define XFS_FEAT_PROJID32 (1ULL << 12) /* 32 bit project id */ 27662306a36Sopenharmony_ci#define XFS_FEAT_CRC (1ULL << 13) /* metadata CRCs */ 27762306a36Sopenharmony_ci#define XFS_FEAT_V3INODES (1ULL << 14) /* Version 3 inodes */ 27862306a36Sopenharmony_ci#define XFS_FEAT_PQUOTINO (1ULL << 15) /* non-shared proj/grp quotas */ 27962306a36Sopenharmony_ci#define XFS_FEAT_FTYPE (1ULL << 16) /* inode type in dir */ 28062306a36Sopenharmony_ci#define XFS_FEAT_FINOBT (1ULL << 17) /* free inode btree */ 28162306a36Sopenharmony_ci#define XFS_FEAT_RMAPBT (1ULL << 18) /* reverse map btree */ 28262306a36Sopenharmony_ci#define XFS_FEAT_REFLINK (1ULL << 19) /* reflinked files */ 28362306a36Sopenharmony_ci#define XFS_FEAT_SPINODES (1ULL << 20) /* sparse inode chunks */ 28462306a36Sopenharmony_ci#define XFS_FEAT_META_UUID (1ULL << 21) /* metadata UUID */ 28562306a36Sopenharmony_ci#define XFS_FEAT_REALTIME (1ULL << 22) /* realtime device present */ 28662306a36Sopenharmony_ci#define XFS_FEAT_INOBTCNT (1ULL << 23) /* inobt block counts */ 28762306a36Sopenharmony_ci#define XFS_FEAT_BIGTIME (1ULL << 24) /* large timestamps */ 28862306a36Sopenharmony_ci#define XFS_FEAT_NEEDSREPAIR (1ULL << 25) /* needs xfs_repair */ 28962306a36Sopenharmony_ci#define XFS_FEAT_NREXT64 (1ULL << 26) /* large extent counters */ 29062306a36Sopenharmony_ci 29162306a36Sopenharmony_ci/* Mount features */ 29262306a36Sopenharmony_ci#define XFS_FEAT_NOATTR2 (1ULL << 48) /* disable attr2 creation */ 29362306a36Sopenharmony_ci#define XFS_FEAT_NOALIGN (1ULL << 49) /* ignore alignment */ 29462306a36Sopenharmony_ci#define XFS_FEAT_ALLOCSIZE (1ULL << 50) /* user specified allocation size */ 29562306a36Sopenharmony_ci#define XFS_FEAT_LARGE_IOSIZE (1ULL << 51) /* report large preferred 29662306a36Sopenharmony_ci * I/O size in stat() */ 29762306a36Sopenharmony_ci#define XFS_FEAT_WSYNC (1ULL << 52) /* synchronous metadata ops */ 29862306a36Sopenharmony_ci#define XFS_FEAT_DIRSYNC (1ULL << 53) /* synchronous directory ops */ 29962306a36Sopenharmony_ci#define XFS_FEAT_DISCARD (1ULL << 54) /* discard unused blocks */ 30062306a36Sopenharmony_ci#define XFS_FEAT_GRPID (1ULL << 55) /* group-ID assigned from directory */ 30162306a36Sopenharmony_ci#define XFS_FEAT_SMALL_INUMS (1ULL << 56) /* user wants 32bit inodes */ 30262306a36Sopenharmony_ci#define XFS_FEAT_IKEEP (1ULL << 57) /* keep empty inode clusters*/ 30362306a36Sopenharmony_ci#define XFS_FEAT_SWALLOC (1ULL << 58) /* stripe width allocation */ 30462306a36Sopenharmony_ci#define XFS_FEAT_FILESTREAMS (1ULL << 59) /* use filestreams allocator */ 30562306a36Sopenharmony_ci#define XFS_FEAT_DAX_ALWAYS (1ULL << 60) /* DAX always enabled */ 30662306a36Sopenharmony_ci#define XFS_FEAT_DAX_NEVER (1ULL << 61) /* DAX never enabled */ 30762306a36Sopenharmony_ci#define XFS_FEAT_NORECOVERY (1ULL << 62) /* no recovery - dirty fs */ 30862306a36Sopenharmony_ci#define XFS_FEAT_NOUUID (1ULL << 63) /* ignore uuid during mount */ 30962306a36Sopenharmony_ci 31062306a36Sopenharmony_ci#define __XFS_HAS_FEAT(name, NAME) \ 31162306a36Sopenharmony_cistatic inline bool xfs_has_ ## name (struct xfs_mount *mp) \ 31262306a36Sopenharmony_ci{ \ 31362306a36Sopenharmony_ci return mp->m_features & XFS_FEAT_ ## NAME; \ 31462306a36Sopenharmony_ci} 31562306a36Sopenharmony_ci 31662306a36Sopenharmony_ci/* Some features can be added dynamically so they need a set wrapper, too. */ 31762306a36Sopenharmony_ci#define __XFS_ADD_FEAT(name, NAME) \ 31862306a36Sopenharmony_ci __XFS_HAS_FEAT(name, NAME); \ 31962306a36Sopenharmony_cistatic inline void xfs_add_ ## name (struct xfs_mount *mp) \ 32062306a36Sopenharmony_ci{ \ 32162306a36Sopenharmony_ci mp->m_features |= XFS_FEAT_ ## NAME; \ 32262306a36Sopenharmony_ci xfs_sb_version_add ## name(&mp->m_sb); \ 32362306a36Sopenharmony_ci} 32462306a36Sopenharmony_ci 32562306a36Sopenharmony_ci/* Superblock features */ 32662306a36Sopenharmony_ci__XFS_ADD_FEAT(attr, ATTR) 32762306a36Sopenharmony_ci__XFS_HAS_FEAT(nlink, NLINK) 32862306a36Sopenharmony_ci__XFS_ADD_FEAT(quota, QUOTA) 32962306a36Sopenharmony_ci__XFS_HAS_FEAT(align, ALIGN) 33062306a36Sopenharmony_ci__XFS_HAS_FEAT(dalign, DALIGN) 33162306a36Sopenharmony_ci__XFS_HAS_FEAT(logv2, LOGV2) 33262306a36Sopenharmony_ci__XFS_HAS_FEAT(sector, SECTOR) 33362306a36Sopenharmony_ci__XFS_HAS_FEAT(extflg, EXTFLG) 33462306a36Sopenharmony_ci__XFS_HAS_FEAT(asciici, ASCIICI) 33562306a36Sopenharmony_ci__XFS_HAS_FEAT(lazysbcount, LAZYSBCOUNT) 33662306a36Sopenharmony_ci__XFS_ADD_FEAT(attr2, ATTR2) 33762306a36Sopenharmony_ci__XFS_HAS_FEAT(parent, PARENT) 33862306a36Sopenharmony_ci__XFS_ADD_FEAT(projid32, PROJID32) 33962306a36Sopenharmony_ci__XFS_HAS_FEAT(crc, CRC) 34062306a36Sopenharmony_ci__XFS_HAS_FEAT(v3inodes, V3INODES) 34162306a36Sopenharmony_ci__XFS_HAS_FEAT(pquotino, PQUOTINO) 34262306a36Sopenharmony_ci__XFS_HAS_FEAT(ftype, FTYPE) 34362306a36Sopenharmony_ci__XFS_HAS_FEAT(finobt, FINOBT) 34462306a36Sopenharmony_ci__XFS_HAS_FEAT(rmapbt, RMAPBT) 34562306a36Sopenharmony_ci__XFS_HAS_FEAT(reflink, REFLINK) 34662306a36Sopenharmony_ci__XFS_HAS_FEAT(sparseinodes, SPINODES) 34762306a36Sopenharmony_ci__XFS_HAS_FEAT(metauuid, META_UUID) 34862306a36Sopenharmony_ci__XFS_HAS_FEAT(realtime, REALTIME) 34962306a36Sopenharmony_ci__XFS_HAS_FEAT(inobtcounts, INOBTCNT) 35062306a36Sopenharmony_ci__XFS_HAS_FEAT(bigtime, BIGTIME) 35162306a36Sopenharmony_ci__XFS_HAS_FEAT(needsrepair, NEEDSREPAIR) 35262306a36Sopenharmony_ci__XFS_HAS_FEAT(large_extent_counts, NREXT64) 35362306a36Sopenharmony_ci 35462306a36Sopenharmony_ci/* 35562306a36Sopenharmony_ci * Mount features 35662306a36Sopenharmony_ci * 35762306a36Sopenharmony_ci * These do not change dynamically - features that can come and go, such as 32 35862306a36Sopenharmony_ci * bit inodes and read-only state, are kept as operational state rather than 35962306a36Sopenharmony_ci * features. 36062306a36Sopenharmony_ci */ 36162306a36Sopenharmony_ci__XFS_HAS_FEAT(noattr2, NOATTR2) 36262306a36Sopenharmony_ci__XFS_HAS_FEAT(noalign, NOALIGN) 36362306a36Sopenharmony_ci__XFS_HAS_FEAT(allocsize, ALLOCSIZE) 36462306a36Sopenharmony_ci__XFS_HAS_FEAT(large_iosize, LARGE_IOSIZE) 36562306a36Sopenharmony_ci__XFS_HAS_FEAT(wsync, WSYNC) 36662306a36Sopenharmony_ci__XFS_HAS_FEAT(dirsync, DIRSYNC) 36762306a36Sopenharmony_ci__XFS_HAS_FEAT(discard, DISCARD) 36862306a36Sopenharmony_ci__XFS_HAS_FEAT(grpid, GRPID) 36962306a36Sopenharmony_ci__XFS_HAS_FEAT(small_inums, SMALL_INUMS) 37062306a36Sopenharmony_ci__XFS_HAS_FEAT(ikeep, IKEEP) 37162306a36Sopenharmony_ci__XFS_HAS_FEAT(swalloc, SWALLOC) 37262306a36Sopenharmony_ci__XFS_HAS_FEAT(filestreams, FILESTREAMS) 37362306a36Sopenharmony_ci__XFS_HAS_FEAT(dax_always, DAX_ALWAYS) 37462306a36Sopenharmony_ci__XFS_HAS_FEAT(dax_never, DAX_NEVER) 37562306a36Sopenharmony_ci__XFS_HAS_FEAT(norecovery, NORECOVERY) 37662306a36Sopenharmony_ci__XFS_HAS_FEAT(nouuid, NOUUID) 37762306a36Sopenharmony_ci 37862306a36Sopenharmony_ci/* 37962306a36Sopenharmony_ci * Operational mount state flags 38062306a36Sopenharmony_ci * 38162306a36Sopenharmony_ci * Use these with atomic bit ops only! 38262306a36Sopenharmony_ci */ 38362306a36Sopenharmony_ci#define XFS_OPSTATE_UNMOUNTING 0 /* filesystem is unmounting */ 38462306a36Sopenharmony_ci#define XFS_OPSTATE_CLEAN 1 /* mount was clean */ 38562306a36Sopenharmony_ci#define XFS_OPSTATE_SHUTDOWN 2 /* stop all fs operations */ 38662306a36Sopenharmony_ci#define XFS_OPSTATE_INODE32 3 /* inode32 allocator active */ 38762306a36Sopenharmony_ci#define XFS_OPSTATE_READONLY 4 /* read-only fs */ 38862306a36Sopenharmony_ci 38962306a36Sopenharmony_ci/* 39062306a36Sopenharmony_ci * If set, inactivation worker threads will be scheduled to process queued 39162306a36Sopenharmony_ci * inodegc work. If not, queued inodes remain in memory waiting to be 39262306a36Sopenharmony_ci * processed. 39362306a36Sopenharmony_ci */ 39462306a36Sopenharmony_ci#define XFS_OPSTATE_INODEGC_ENABLED 5 39562306a36Sopenharmony_ci/* 39662306a36Sopenharmony_ci * If set, background speculative prealloc gc worker threads will be scheduled 39762306a36Sopenharmony_ci * to process queued blockgc work. If not, inodes retain their preallocations 39862306a36Sopenharmony_ci * until explicitly deleted. 39962306a36Sopenharmony_ci */ 40062306a36Sopenharmony_ci#define XFS_OPSTATE_BLOCKGC_ENABLED 6 40162306a36Sopenharmony_ci 40262306a36Sopenharmony_ci/* Kernel has logged a warning about online fsck being used on this fs. */ 40362306a36Sopenharmony_ci#define XFS_OPSTATE_WARNED_SCRUB 7 40462306a36Sopenharmony_ci/* Kernel has logged a warning about shrink being used on this fs. */ 40562306a36Sopenharmony_ci#define XFS_OPSTATE_WARNED_SHRINK 8 40662306a36Sopenharmony_ci/* Kernel has logged a warning about logged xattr updates being used. */ 40762306a36Sopenharmony_ci#define XFS_OPSTATE_WARNED_LARP 9 40862306a36Sopenharmony_ci/* Mount time quotacheck is running */ 40962306a36Sopenharmony_ci#define XFS_OPSTATE_QUOTACHECK_RUNNING 10 41062306a36Sopenharmony_ci 41162306a36Sopenharmony_ci#define __XFS_IS_OPSTATE(name, NAME) \ 41262306a36Sopenharmony_cistatic inline bool xfs_is_ ## name (struct xfs_mount *mp) \ 41362306a36Sopenharmony_ci{ \ 41462306a36Sopenharmony_ci return test_bit(XFS_OPSTATE_ ## NAME, &mp->m_opstate); \ 41562306a36Sopenharmony_ci} \ 41662306a36Sopenharmony_cistatic inline bool xfs_clear_ ## name (struct xfs_mount *mp) \ 41762306a36Sopenharmony_ci{ \ 41862306a36Sopenharmony_ci return test_and_clear_bit(XFS_OPSTATE_ ## NAME, &mp->m_opstate); \ 41962306a36Sopenharmony_ci} \ 42062306a36Sopenharmony_cistatic inline bool xfs_set_ ## name (struct xfs_mount *mp) \ 42162306a36Sopenharmony_ci{ \ 42262306a36Sopenharmony_ci return test_and_set_bit(XFS_OPSTATE_ ## NAME, &mp->m_opstate); \ 42362306a36Sopenharmony_ci} 42462306a36Sopenharmony_ci 42562306a36Sopenharmony_ci__XFS_IS_OPSTATE(unmounting, UNMOUNTING) 42662306a36Sopenharmony_ci__XFS_IS_OPSTATE(clean, CLEAN) 42762306a36Sopenharmony_ci__XFS_IS_OPSTATE(shutdown, SHUTDOWN) 42862306a36Sopenharmony_ci__XFS_IS_OPSTATE(inode32, INODE32) 42962306a36Sopenharmony_ci__XFS_IS_OPSTATE(readonly, READONLY) 43062306a36Sopenharmony_ci__XFS_IS_OPSTATE(inodegc_enabled, INODEGC_ENABLED) 43162306a36Sopenharmony_ci__XFS_IS_OPSTATE(blockgc_enabled, BLOCKGC_ENABLED) 43262306a36Sopenharmony_ci#ifdef CONFIG_XFS_QUOTA 43362306a36Sopenharmony_ci__XFS_IS_OPSTATE(quotacheck_running, QUOTACHECK_RUNNING) 43462306a36Sopenharmony_ci#else 43562306a36Sopenharmony_ci# define xfs_is_quotacheck_running(mp) (false) 43662306a36Sopenharmony_ci#endif 43762306a36Sopenharmony_ci 43862306a36Sopenharmony_cistatic inline bool 43962306a36Sopenharmony_cixfs_should_warn(struct xfs_mount *mp, long nr) 44062306a36Sopenharmony_ci{ 44162306a36Sopenharmony_ci return !test_and_set_bit(nr, &mp->m_opstate); 44262306a36Sopenharmony_ci} 44362306a36Sopenharmony_ci 44462306a36Sopenharmony_ci#define XFS_OPSTATE_STRINGS \ 44562306a36Sopenharmony_ci { (1UL << XFS_OPSTATE_UNMOUNTING), "unmounting" }, \ 44662306a36Sopenharmony_ci { (1UL << XFS_OPSTATE_CLEAN), "clean" }, \ 44762306a36Sopenharmony_ci { (1UL << XFS_OPSTATE_SHUTDOWN), "shutdown" }, \ 44862306a36Sopenharmony_ci { (1UL << XFS_OPSTATE_INODE32), "inode32" }, \ 44962306a36Sopenharmony_ci { (1UL << XFS_OPSTATE_READONLY), "read_only" }, \ 45062306a36Sopenharmony_ci { (1UL << XFS_OPSTATE_INODEGC_ENABLED), "inodegc" }, \ 45162306a36Sopenharmony_ci { (1UL << XFS_OPSTATE_BLOCKGC_ENABLED), "blockgc" }, \ 45262306a36Sopenharmony_ci { (1UL << XFS_OPSTATE_WARNED_SCRUB), "wscrub" }, \ 45362306a36Sopenharmony_ci { (1UL << XFS_OPSTATE_WARNED_SHRINK), "wshrink" }, \ 45462306a36Sopenharmony_ci { (1UL << XFS_OPSTATE_WARNED_LARP), "wlarp" }, \ 45562306a36Sopenharmony_ci { (1UL << XFS_OPSTATE_QUOTACHECK_RUNNING), "quotacheck" } 45662306a36Sopenharmony_ci 45762306a36Sopenharmony_ci/* 45862306a36Sopenharmony_ci * Max and min values for mount-option defined I/O 45962306a36Sopenharmony_ci * preallocation sizes. 46062306a36Sopenharmony_ci */ 46162306a36Sopenharmony_ci#define XFS_MAX_IO_LOG 30 /* 1G */ 46262306a36Sopenharmony_ci#define XFS_MIN_IO_LOG PAGE_SHIFT 46362306a36Sopenharmony_ci 46462306a36Sopenharmony_civoid xfs_do_force_shutdown(struct xfs_mount *mp, uint32_t flags, char *fname, 46562306a36Sopenharmony_ci int lnnum); 46662306a36Sopenharmony_ci#define xfs_force_shutdown(m,f) \ 46762306a36Sopenharmony_ci xfs_do_force_shutdown(m, f, __FILE__, __LINE__) 46862306a36Sopenharmony_ci 46962306a36Sopenharmony_ci#define SHUTDOWN_META_IO_ERROR (1u << 0) /* write attempt to metadata failed */ 47062306a36Sopenharmony_ci#define SHUTDOWN_LOG_IO_ERROR (1u << 1) /* write attempt to the log failed */ 47162306a36Sopenharmony_ci#define SHUTDOWN_FORCE_UMOUNT (1u << 2) /* shutdown from a forced unmount */ 47262306a36Sopenharmony_ci#define SHUTDOWN_CORRUPT_INCORE (1u << 3) /* corrupt in-memory structures */ 47362306a36Sopenharmony_ci#define SHUTDOWN_CORRUPT_ONDISK (1u << 4) /* corrupt metadata on device */ 47462306a36Sopenharmony_ci#define SHUTDOWN_DEVICE_REMOVED (1u << 5) /* device removed underneath us */ 47562306a36Sopenharmony_ci 47662306a36Sopenharmony_ci#define XFS_SHUTDOWN_STRINGS \ 47762306a36Sopenharmony_ci { SHUTDOWN_META_IO_ERROR, "metadata_io" }, \ 47862306a36Sopenharmony_ci { SHUTDOWN_LOG_IO_ERROR, "log_io" }, \ 47962306a36Sopenharmony_ci { SHUTDOWN_FORCE_UMOUNT, "force_umount" }, \ 48062306a36Sopenharmony_ci { SHUTDOWN_CORRUPT_INCORE, "corruption" }, \ 48162306a36Sopenharmony_ci { SHUTDOWN_DEVICE_REMOVED, "device_removed" } 48262306a36Sopenharmony_ci 48362306a36Sopenharmony_ci/* 48462306a36Sopenharmony_ci * Flags for xfs_mountfs 48562306a36Sopenharmony_ci */ 48662306a36Sopenharmony_ci#define XFS_MFSI_QUIET 0x40 /* Be silent if mount errors found */ 48762306a36Sopenharmony_ci 48862306a36Sopenharmony_cistatic inline xfs_agnumber_t 48962306a36Sopenharmony_cixfs_daddr_to_agno(struct xfs_mount *mp, xfs_daddr_t d) 49062306a36Sopenharmony_ci{ 49162306a36Sopenharmony_ci xfs_rfsblock_t ld = XFS_BB_TO_FSBT(mp, d); 49262306a36Sopenharmony_ci do_div(ld, mp->m_sb.sb_agblocks); 49362306a36Sopenharmony_ci return (xfs_agnumber_t) ld; 49462306a36Sopenharmony_ci} 49562306a36Sopenharmony_ci 49662306a36Sopenharmony_cistatic inline xfs_agblock_t 49762306a36Sopenharmony_cixfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d) 49862306a36Sopenharmony_ci{ 49962306a36Sopenharmony_ci xfs_rfsblock_t ld = XFS_BB_TO_FSBT(mp, d); 50062306a36Sopenharmony_ci return (xfs_agblock_t) do_div(ld, mp->m_sb.sb_agblocks); 50162306a36Sopenharmony_ci} 50262306a36Sopenharmony_ci 50362306a36Sopenharmony_ciint xfs_buf_hash_init(struct xfs_perag *pag); 50462306a36Sopenharmony_civoid xfs_buf_hash_destroy(struct xfs_perag *pag); 50562306a36Sopenharmony_ci 50662306a36Sopenharmony_ciextern void xfs_uuid_table_free(void); 50762306a36Sopenharmony_ciextern uint64_t xfs_default_resblks(xfs_mount_t *mp); 50862306a36Sopenharmony_ciextern int xfs_mountfs(xfs_mount_t *mp); 50962306a36Sopenharmony_ciextern void xfs_unmountfs(xfs_mount_t *); 51062306a36Sopenharmony_ci 51162306a36Sopenharmony_ci/* 51262306a36Sopenharmony_ci * Deltas for the block count can vary from 1 to very large, but lock contention 51362306a36Sopenharmony_ci * only occurs on frequent small block count updates such as in the delayed 51462306a36Sopenharmony_ci * allocation path for buffered writes (page a time updates). Hence we set 51562306a36Sopenharmony_ci * a large batch count (1024) to minimise global counter updates except when 51662306a36Sopenharmony_ci * we get near to ENOSPC and we have to be very accurate with our updates. 51762306a36Sopenharmony_ci */ 51862306a36Sopenharmony_ci#define XFS_FDBLOCKS_BATCH 1024 51962306a36Sopenharmony_ci 52062306a36Sopenharmony_ci/* 52162306a36Sopenharmony_ci * Estimate the amount of free space that is not available to userspace and is 52262306a36Sopenharmony_ci * not explicitly reserved from the incore fdblocks. This includes: 52362306a36Sopenharmony_ci * 52462306a36Sopenharmony_ci * - The minimum number of blocks needed to support splitting a bmap btree 52562306a36Sopenharmony_ci * - The blocks currently in use by the freespace btrees because they record 52662306a36Sopenharmony_ci * the actual blocks that will fill per-AG metadata space reservations 52762306a36Sopenharmony_ci */ 52862306a36Sopenharmony_cistatic inline uint64_t 52962306a36Sopenharmony_cixfs_fdblocks_unavailable( 53062306a36Sopenharmony_ci struct xfs_mount *mp) 53162306a36Sopenharmony_ci{ 53262306a36Sopenharmony_ci return mp->m_alloc_set_aside + atomic64_read(&mp->m_allocbt_blks); 53362306a36Sopenharmony_ci} 53462306a36Sopenharmony_ci 53562306a36Sopenharmony_ciint xfs_mod_freecounter(struct xfs_mount *mp, struct percpu_counter *counter, 53662306a36Sopenharmony_ci int64_t delta, bool rsvd); 53762306a36Sopenharmony_ci 53862306a36Sopenharmony_cistatic inline int 53962306a36Sopenharmony_cixfs_mod_fdblocks(struct xfs_mount *mp, int64_t delta, bool reserved) 54062306a36Sopenharmony_ci{ 54162306a36Sopenharmony_ci return xfs_mod_freecounter(mp, &mp->m_fdblocks, delta, reserved); 54262306a36Sopenharmony_ci} 54362306a36Sopenharmony_ci 54462306a36Sopenharmony_cistatic inline int 54562306a36Sopenharmony_cixfs_mod_frextents(struct xfs_mount *mp, int64_t delta) 54662306a36Sopenharmony_ci{ 54762306a36Sopenharmony_ci return xfs_mod_freecounter(mp, &mp->m_frextents, delta, false); 54862306a36Sopenharmony_ci} 54962306a36Sopenharmony_ci 55062306a36Sopenharmony_ciextern int xfs_readsb(xfs_mount_t *, int); 55162306a36Sopenharmony_ciextern void xfs_freesb(xfs_mount_t *); 55262306a36Sopenharmony_ciextern bool xfs_fs_writable(struct xfs_mount *mp, int level); 55362306a36Sopenharmony_ciextern int xfs_sb_validate_fsb_count(struct xfs_sb *, uint64_t); 55462306a36Sopenharmony_ci 55562306a36Sopenharmony_ciextern int xfs_dev_is_read_only(struct xfs_mount *, char *); 55662306a36Sopenharmony_ci 55762306a36Sopenharmony_ciextern void xfs_set_low_space_thresholds(struct xfs_mount *); 55862306a36Sopenharmony_ci 55962306a36Sopenharmony_ciint xfs_zero_extent(struct xfs_inode *ip, xfs_fsblock_t start_fsb, 56062306a36Sopenharmony_ci xfs_off_t count_fsb); 56162306a36Sopenharmony_ci 56262306a36Sopenharmony_cistruct xfs_error_cfg * xfs_error_get_cfg(struct xfs_mount *mp, 56362306a36Sopenharmony_ci int error_class, int error); 56462306a36Sopenharmony_civoid xfs_force_summary_recalc(struct xfs_mount *mp); 56562306a36Sopenharmony_ciint xfs_add_incompat_log_feature(struct xfs_mount *mp, uint32_t feature); 56662306a36Sopenharmony_cibool xfs_clear_incompat_log_features(struct xfs_mount *mp); 56762306a36Sopenharmony_civoid xfs_mod_delalloc(struct xfs_mount *mp, int64_t delta); 56862306a36Sopenharmony_ci 56962306a36Sopenharmony_ci#endif /* __XFS_MOUNT_H__ */ 570