18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2000-2005 Silicon Graphics, Inc. 48c2ecf20Sopenharmony_ci * All Rights Reserved. 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci#ifndef __XFS_MOUNT_H__ 78c2ecf20Sopenharmony_ci#define __XFS_MOUNT_H__ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_cistruct xlog; 108c2ecf20Sopenharmony_cistruct xfs_inode; 118c2ecf20Sopenharmony_cistruct xfs_mru_cache; 128c2ecf20Sopenharmony_cistruct xfs_ail; 138c2ecf20Sopenharmony_cistruct xfs_quotainfo; 148c2ecf20Sopenharmony_cistruct xfs_da_geometry; 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci/* dynamic preallocation free space thresholds, 5% down to 1% */ 178c2ecf20Sopenharmony_cienum { 188c2ecf20Sopenharmony_ci XFS_LOWSP_1_PCNT = 0, 198c2ecf20Sopenharmony_ci XFS_LOWSP_2_PCNT, 208c2ecf20Sopenharmony_ci XFS_LOWSP_3_PCNT, 218c2ecf20Sopenharmony_ci XFS_LOWSP_4_PCNT, 228c2ecf20Sopenharmony_ci XFS_LOWSP_5_PCNT, 238c2ecf20Sopenharmony_ci XFS_LOWSP_MAX, 248c2ecf20Sopenharmony_ci}; 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci/* 278c2ecf20Sopenharmony_ci * Error Configuration 288c2ecf20Sopenharmony_ci * 298c2ecf20Sopenharmony_ci * Error classes define the subsystem the configuration belongs to. 308c2ecf20Sopenharmony_ci * Error numbers define the errors that are configurable. 318c2ecf20Sopenharmony_ci */ 328c2ecf20Sopenharmony_cienum { 338c2ecf20Sopenharmony_ci XFS_ERR_METADATA, 348c2ecf20Sopenharmony_ci XFS_ERR_CLASS_MAX, 358c2ecf20Sopenharmony_ci}; 368c2ecf20Sopenharmony_cienum { 378c2ecf20Sopenharmony_ci XFS_ERR_DEFAULT, 388c2ecf20Sopenharmony_ci XFS_ERR_EIO, 398c2ecf20Sopenharmony_ci XFS_ERR_ENOSPC, 408c2ecf20Sopenharmony_ci XFS_ERR_ENODEV, 418c2ecf20Sopenharmony_ci XFS_ERR_ERRNO_MAX, 428c2ecf20Sopenharmony_ci}; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci#define XFS_ERR_RETRY_FOREVER -1 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci/* 478c2ecf20Sopenharmony_ci * Although retry_timeout is in jiffies which is normally an unsigned long, 488c2ecf20Sopenharmony_ci * we limit the retry timeout to 86400 seconds, or one day. So even a 498c2ecf20Sopenharmony_ci * signed 32-bit long is sufficient for a HZ value up to 24855. Making it 508c2ecf20Sopenharmony_ci * signed lets us store the special "-1" value, meaning retry forever. 518c2ecf20Sopenharmony_ci */ 528c2ecf20Sopenharmony_cistruct xfs_error_cfg { 538c2ecf20Sopenharmony_ci struct xfs_kobj kobj; 548c2ecf20Sopenharmony_ci int max_retries; 558c2ecf20Sopenharmony_ci long retry_timeout; /* in jiffies, -1 = infinite */ 568c2ecf20Sopenharmony_ci}; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci/* 598c2ecf20Sopenharmony_ci * The struct xfsmount layout is optimised to separate read-mostly variables 608c2ecf20Sopenharmony_ci * from variables that are frequently modified. We put the read-mostly variables 618c2ecf20Sopenharmony_ci * first, then place all the other variables at the end. 628c2ecf20Sopenharmony_ci * 638c2ecf20Sopenharmony_ci * Typically, read-mostly variables are those that are set at mount time and 648c2ecf20Sopenharmony_ci * never changed again, or only change rarely as a result of things like sysfs 658c2ecf20Sopenharmony_ci * knobs being tweaked. 668c2ecf20Sopenharmony_ci */ 678c2ecf20Sopenharmony_citypedef struct xfs_mount { 688c2ecf20Sopenharmony_ci struct xfs_sb m_sb; /* copy of fs superblock */ 698c2ecf20Sopenharmony_ci struct super_block *m_super; 708c2ecf20Sopenharmony_ci struct xfs_ail *m_ail; /* fs active log item list */ 718c2ecf20Sopenharmony_ci struct xfs_buf *m_sb_bp; /* buffer for superblock */ 728c2ecf20Sopenharmony_ci char *m_rtname; /* realtime device name */ 738c2ecf20Sopenharmony_ci char *m_logname; /* external log device name */ 748c2ecf20Sopenharmony_ci struct xfs_da_geometry *m_dir_geo; /* directory block geometry */ 758c2ecf20Sopenharmony_ci struct xfs_da_geometry *m_attr_geo; /* attribute block geometry */ 768c2ecf20Sopenharmony_ci struct xlog *m_log; /* log specific stuff */ 778c2ecf20Sopenharmony_ci struct xfs_inode *m_rbmip; /* pointer to bitmap inode */ 788c2ecf20Sopenharmony_ci struct xfs_inode *m_rsumip; /* pointer to summary inode */ 798c2ecf20Sopenharmony_ci struct xfs_inode *m_rootip; /* pointer to root directory */ 808c2ecf20Sopenharmony_ci struct xfs_quotainfo *m_quotainfo; /* disk quota information */ 818c2ecf20Sopenharmony_ci xfs_buftarg_t *m_ddev_targp; /* saves taking the address */ 828c2ecf20Sopenharmony_ci xfs_buftarg_t *m_logdev_targp;/* ptr to log device */ 838c2ecf20Sopenharmony_ci xfs_buftarg_t *m_rtdev_targp; /* ptr to rt device */ 848c2ecf20Sopenharmony_ci /* 858c2ecf20Sopenharmony_ci * Optional cache of rt summary level per bitmap block with the 868c2ecf20Sopenharmony_ci * invariant that m_rsum_cache[bbno] <= the minimum i for which 878c2ecf20Sopenharmony_ci * rsum[i][bbno] != 0. Reads and writes are serialized by the rsumip 888c2ecf20Sopenharmony_ci * inode lock. 898c2ecf20Sopenharmony_ci */ 908c2ecf20Sopenharmony_ci uint8_t *m_rsum_cache; 918c2ecf20Sopenharmony_ci struct xfs_mru_cache *m_filestream; /* per-mount filestream data */ 928c2ecf20Sopenharmony_ci struct workqueue_struct *m_buf_workqueue; 938c2ecf20Sopenharmony_ci struct workqueue_struct *m_unwritten_workqueue; 948c2ecf20Sopenharmony_ci struct workqueue_struct *m_cil_workqueue; 958c2ecf20Sopenharmony_ci struct workqueue_struct *m_reclaim_workqueue; 968c2ecf20Sopenharmony_ci struct workqueue_struct *m_eofblocks_workqueue; 978c2ecf20Sopenharmony_ci struct workqueue_struct *m_sync_workqueue; 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci int m_bsize; /* fs logical block size */ 1008c2ecf20Sopenharmony_ci uint8_t m_blkbit_log; /* blocklog + NBBY */ 1018c2ecf20Sopenharmony_ci uint8_t m_blkbb_log; /* blocklog - BBSHIFT */ 1028c2ecf20Sopenharmony_ci uint8_t m_agno_log; /* log #ag's */ 1038c2ecf20Sopenharmony_ci uint8_t m_sectbb_log; /* sectlog - BBSHIFT */ 1048c2ecf20Sopenharmony_ci uint m_blockmask; /* sb_blocksize-1 */ 1058c2ecf20Sopenharmony_ci uint m_blockwsize; /* sb_blocksize in words */ 1068c2ecf20Sopenharmony_ci uint m_blockwmask; /* blockwsize-1 */ 1078c2ecf20Sopenharmony_ci uint m_alloc_mxr[2]; /* max alloc btree records */ 1088c2ecf20Sopenharmony_ci uint m_alloc_mnr[2]; /* min alloc btree records */ 1098c2ecf20Sopenharmony_ci uint m_bmap_dmxr[2]; /* max bmap btree records */ 1108c2ecf20Sopenharmony_ci uint m_bmap_dmnr[2]; /* min bmap btree records */ 1118c2ecf20Sopenharmony_ci uint m_rmap_mxr[2]; /* max rmap btree records */ 1128c2ecf20Sopenharmony_ci uint m_rmap_mnr[2]; /* min rmap btree records */ 1138c2ecf20Sopenharmony_ci uint m_refc_mxr[2]; /* max refc btree records */ 1148c2ecf20Sopenharmony_ci uint m_refc_mnr[2]; /* min refc btree records */ 1158c2ecf20Sopenharmony_ci uint m_ag_maxlevels; /* XFS_AG_MAXLEVELS */ 1168c2ecf20Sopenharmony_ci uint m_bm_maxlevels[2]; /* XFS_BM_MAXLEVELS */ 1178c2ecf20Sopenharmony_ci uint m_rmap_maxlevels; /* max rmap btree levels */ 1188c2ecf20Sopenharmony_ci uint m_refc_maxlevels; /* max refcount btree level */ 1198c2ecf20Sopenharmony_ci xfs_extlen_t m_ag_prealloc_blocks; /* reserved ag blocks */ 1208c2ecf20Sopenharmony_ci uint m_alloc_set_aside; /* space we can't use */ 1218c2ecf20Sopenharmony_ci uint m_ag_max_usable; /* max space per AG */ 1228c2ecf20Sopenharmony_ci int m_dalign; /* stripe unit */ 1238c2ecf20Sopenharmony_ci int m_swidth; /* stripe width */ 1248c2ecf20Sopenharmony_ci xfs_agnumber_t m_maxagi; /* highest inode alloc group */ 1258c2ecf20Sopenharmony_ci uint m_allocsize_log;/* min write size log bytes */ 1268c2ecf20Sopenharmony_ci uint m_allocsize_blocks; /* min write size blocks */ 1278c2ecf20Sopenharmony_ci int m_logbufs; /* number of log buffers */ 1288c2ecf20Sopenharmony_ci int m_logbsize; /* size of each log buffer */ 1298c2ecf20Sopenharmony_ci uint m_rsumlevels; /* rt summary levels */ 1308c2ecf20Sopenharmony_ci uint m_rsumsize; /* size of rt summary, bytes */ 1318c2ecf20Sopenharmony_ci int m_fixedfsid[2]; /* unchanged for life of FS */ 1328c2ecf20Sopenharmony_ci uint m_qflags; /* quota status flags */ 1338c2ecf20Sopenharmony_ci uint64_t m_flags; /* global mount flags */ 1348c2ecf20Sopenharmony_ci int64_t m_low_space[XFS_LOWSP_MAX]; 1358c2ecf20Sopenharmony_ci struct xfs_ino_geometry m_ino_geo; /* inode geometry */ 1368c2ecf20Sopenharmony_ci struct xfs_trans_resv m_resv; /* precomputed res values */ 1378c2ecf20Sopenharmony_ci /* low free space thresholds */ 1388c2ecf20Sopenharmony_ci bool m_always_cow; 1398c2ecf20Sopenharmony_ci bool m_fail_unmount; 1408c2ecf20Sopenharmony_ci bool m_finobt_nores; /* no per-AG finobt resv. */ 1418c2ecf20Sopenharmony_ci bool m_update_sb; /* sb needs update in mount */ 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci /* 1448c2ecf20Sopenharmony_ci * Bitsets of per-fs metadata that have been checked and/or are sick. 1458c2ecf20Sopenharmony_ci * Callers must hold m_sb_lock to access these two fields. 1468c2ecf20Sopenharmony_ci */ 1478c2ecf20Sopenharmony_ci uint8_t m_fs_checked; 1488c2ecf20Sopenharmony_ci uint8_t m_fs_sick; 1498c2ecf20Sopenharmony_ci /* 1508c2ecf20Sopenharmony_ci * Bitsets of rt metadata that have been checked and/or are sick. 1518c2ecf20Sopenharmony_ci * Callers must hold m_sb_lock to access this field. 1528c2ecf20Sopenharmony_ci */ 1538c2ecf20Sopenharmony_ci uint8_t m_rt_checked; 1548c2ecf20Sopenharmony_ci uint8_t m_rt_sick; 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci /* 1578c2ecf20Sopenharmony_ci * End of read-mostly variables. Frequently written variables and locks 1588c2ecf20Sopenharmony_ci * should be placed below this comment from now on. The first variable 1598c2ecf20Sopenharmony_ci * here is marked as cacheline aligned so they it is separated from 1608c2ecf20Sopenharmony_ci * the read-mostly variables. 1618c2ecf20Sopenharmony_ci */ 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci spinlock_t ____cacheline_aligned m_sb_lock; /* sb counter lock */ 1648c2ecf20Sopenharmony_ci struct percpu_counter m_icount; /* allocated inodes counter */ 1658c2ecf20Sopenharmony_ci struct percpu_counter m_ifree; /* free inodes counter */ 1668c2ecf20Sopenharmony_ci struct percpu_counter m_fdblocks; /* free block counter */ 1678c2ecf20Sopenharmony_ci /* 1688c2ecf20Sopenharmony_ci * Count of data device blocks reserved for delayed allocations, 1698c2ecf20Sopenharmony_ci * including indlen blocks. Does not include allocated CoW staging 1708c2ecf20Sopenharmony_ci * extents or anything related to the rt device. 1718c2ecf20Sopenharmony_ci */ 1728c2ecf20Sopenharmony_ci struct percpu_counter m_delalloc_blks; 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci struct radix_tree_root m_perag_tree; /* per-ag accounting info */ 1758c2ecf20Sopenharmony_ci spinlock_t m_perag_lock; /* lock for m_perag_tree */ 1768c2ecf20Sopenharmony_ci uint64_t m_resblks; /* total reserved blocks */ 1778c2ecf20Sopenharmony_ci uint64_t m_resblks_avail;/* available reserved blocks */ 1788c2ecf20Sopenharmony_ci uint64_t m_resblks_save; /* reserved blks @ remount,ro */ 1798c2ecf20Sopenharmony_ci struct delayed_work m_reclaim_work; /* background inode reclaim */ 1808c2ecf20Sopenharmony_ci struct delayed_work m_eofblocks_work; /* background eof blocks 1818c2ecf20Sopenharmony_ci trimming */ 1828c2ecf20Sopenharmony_ci struct delayed_work m_cowblocks_work; /* background cow blocks 1838c2ecf20Sopenharmony_ci trimming */ 1848c2ecf20Sopenharmony_ci struct xfs_kobj m_kobj; 1858c2ecf20Sopenharmony_ci struct xfs_kobj m_error_kobj; 1868c2ecf20Sopenharmony_ci struct xfs_kobj m_error_meta_kobj; 1878c2ecf20Sopenharmony_ci struct xfs_error_cfg m_error_cfg[XFS_ERR_CLASS_MAX][XFS_ERR_ERRNO_MAX]; 1888c2ecf20Sopenharmony_ci struct xstats m_stats; /* per-fs stats */ 1898c2ecf20Sopenharmony_ci xfs_agnumber_t m_agfrotor; /* last ag where space found */ 1908c2ecf20Sopenharmony_ci xfs_agnumber_t m_agirotor; /* last ag dir inode alloced */ 1918c2ecf20Sopenharmony_ci spinlock_t m_agirotor_lock;/* .. and lock protecting it */ 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_ci /* 1948c2ecf20Sopenharmony_ci * Workqueue item so that we can coalesce multiple inode flush attempts 1958c2ecf20Sopenharmony_ci * into a single flush. 1968c2ecf20Sopenharmony_ci */ 1978c2ecf20Sopenharmony_ci struct work_struct m_flush_inodes_work; 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci /* 2008c2ecf20Sopenharmony_ci * Generation of the filesysyem layout. This is incremented by each 2018c2ecf20Sopenharmony_ci * growfs, and used by the pNFS server to ensure the client updates 2028c2ecf20Sopenharmony_ci * its view of the block device once it gets a layout that might 2038c2ecf20Sopenharmony_ci * reference the newly added blocks. Does not need to be persistent 2048c2ecf20Sopenharmony_ci * as long as we only allow file system size increments, but if we 2058c2ecf20Sopenharmony_ci * ever support shrinks it would have to be persisted in addition 2068c2ecf20Sopenharmony_ci * to various other kinds of pain inflicted on the pNFS server. 2078c2ecf20Sopenharmony_ci */ 2088c2ecf20Sopenharmony_ci uint32_t m_generation; 2098c2ecf20Sopenharmony_ci struct mutex m_growlock; /* growfs mutex */ 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci#ifdef DEBUG 2128c2ecf20Sopenharmony_ci /* 2138c2ecf20Sopenharmony_ci * Frequency with which errors are injected. Replaces xfs_etest; the 2148c2ecf20Sopenharmony_ci * value stored in here is the inverse of the frequency with which the 2158c2ecf20Sopenharmony_ci * error triggers. 1 = always, 2 = half the time, etc. 2168c2ecf20Sopenharmony_ci */ 2178c2ecf20Sopenharmony_ci unsigned int *m_errortag; 2188c2ecf20Sopenharmony_ci struct xfs_kobj m_errortag_kobj; 2198c2ecf20Sopenharmony_ci#endif 2208c2ecf20Sopenharmony_ci} xfs_mount_t; 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_ci#define M_IGEO(mp) (&(mp)->m_ino_geo) 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci/* 2258c2ecf20Sopenharmony_ci * Flags for m_flags. 2268c2ecf20Sopenharmony_ci */ 2278c2ecf20Sopenharmony_ci#define XFS_MOUNT_WSYNC (1ULL << 0) /* for nfs - all metadata ops 2288c2ecf20Sopenharmony_ci must be synchronous except 2298c2ecf20Sopenharmony_ci for space allocations */ 2308c2ecf20Sopenharmony_ci#define XFS_MOUNT_UNMOUNTING (1ULL << 1) /* filesystem is unmounting */ 2318c2ecf20Sopenharmony_ci#define XFS_MOUNT_WAS_CLEAN (1ULL << 3) 2328c2ecf20Sopenharmony_ci#define XFS_MOUNT_FS_SHUTDOWN (1ULL << 4) /* atomic stop of all filesystem 2338c2ecf20Sopenharmony_ci operations, typically for 2348c2ecf20Sopenharmony_ci disk errors in metadata */ 2358c2ecf20Sopenharmony_ci#define XFS_MOUNT_DISCARD (1ULL << 5) /* discard unused blocks */ 2368c2ecf20Sopenharmony_ci#define XFS_MOUNT_NOALIGN (1ULL << 7) /* turn off stripe alignment 2378c2ecf20Sopenharmony_ci allocations */ 2388c2ecf20Sopenharmony_ci#define XFS_MOUNT_ATTR2 (1ULL << 8) /* allow use of attr2 format */ 2398c2ecf20Sopenharmony_ci#define XFS_MOUNT_GRPID (1ULL << 9) /* group-ID assigned from directory */ 2408c2ecf20Sopenharmony_ci#define XFS_MOUNT_NORECOVERY (1ULL << 10) /* no recovery - dirty fs */ 2418c2ecf20Sopenharmony_ci#define XFS_MOUNT_ALLOCSIZE (1ULL << 12) /* specified allocation size */ 2428c2ecf20Sopenharmony_ci#define XFS_MOUNT_SMALL_INUMS (1ULL << 14) /* user wants 32bit inodes */ 2438c2ecf20Sopenharmony_ci#define XFS_MOUNT_32BITINODES (1ULL << 15) /* inode32 allocator active */ 2448c2ecf20Sopenharmony_ci#define XFS_MOUNT_NOUUID (1ULL << 16) /* ignore uuid during mount */ 2458c2ecf20Sopenharmony_ci#define XFS_MOUNT_IKEEP (1ULL << 18) /* keep empty inode clusters*/ 2468c2ecf20Sopenharmony_ci#define XFS_MOUNT_SWALLOC (1ULL << 19) /* turn on stripe width 2478c2ecf20Sopenharmony_ci * allocation */ 2488c2ecf20Sopenharmony_ci#define XFS_MOUNT_RDONLY (1ULL << 20) /* read-only fs */ 2498c2ecf20Sopenharmony_ci#define XFS_MOUNT_DIRSYNC (1ULL << 21) /* synchronous directory ops */ 2508c2ecf20Sopenharmony_ci#define XFS_MOUNT_LARGEIO (1ULL << 22) /* report large preferred 2518c2ecf20Sopenharmony_ci * I/O size in stat() */ 2528c2ecf20Sopenharmony_ci#define XFS_MOUNT_FILESTREAMS (1ULL << 24) /* enable the filestreams 2538c2ecf20Sopenharmony_ci allocator */ 2548c2ecf20Sopenharmony_ci#define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */ 2558c2ecf20Sopenharmony_ci#define XFS_MOUNT_DAX_ALWAYS (1ULL << 26) 2568c2ecf20Sopenharmony_ci#define XFS_MOUNT_DAX_NEVER (1ULL << 27) 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci/* 2598c2ecf20Sopenharmony_ci * Max and min values for mount-option defined I/O 2608c2ecf20Sopenharmony_ci * preallocation sizes. 2618c2ecf20Sopenharmony_ci */ 2628c2ecf20Sopenharmony_ci#define XFS_MAX_IO_LOG 30 /* 1G */ 2638c2ecf20Sopenharmony_ci#define XFS_MIN_IO_LOG PAGE_SHIFT 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci#define XFS_LAST_UNMOUNT_WAS_CLEAN(mp) \ 2668c2ecf20Sopenharmony_ci ((mp)->m_flags & XFS_MOUNT_WAS_CLEAN) 2678c2ecf20Sopenharmony_ci#define XFS_FORCED_SHUTDOWN(mp) ((mp)->m_flags & XFS_MOUNT_FS_SHUTDOWN) 2688c2ecf20Sopenharmony_civoid xfs_do_force_shutdown(struct xfs_mount *mp, int flags, char *fname, 2698c2ecf20Sopenharmony_ci int lnnum); 2708c2ecf20Sopenharmony_ci#define xfs_force_shutdown(m,f) \ 2718c2ecf20Sopenharmony_ci xfs_do_force_shutdown(m, f, __FILE__, __LINE__) 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci#define SHUTDOWN_META_IO_ERROR 0x0001 /* write attempt to metadata failed */ 2748c2ecf20Sopenharmony_ci#define SHUTDOWN_LOG_IO_ERROR 0x0002 /* write attempt to the log failed */ 2758c2ecf20Sopenharmony_ci#define SHUTDOWN_FORCE_UMOUNT 0x0004 /* shutdown from a forced unmount */ 2768c2ecf20Sopenharmony_ci#define SHUTDOWN_CORRUPT_INCORE 0x0008 /* corrupt in-memory data structures */ 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_ci/* 2798c2ecf20Sopenharmony_ci * Flags for xfs_mountfs 2808c2ecf20Sopenharmony_ci */ 2818c2ecf20Sopenharmony_ci#define XFS_MFSI_QUIET 0x40 /* Be silent if mount errors found */ 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_cistatic inline xfs_agnumber_t 2848c2ecf20Sopenharmony_cixfs_daddr_to_agno(struct xfs_mount *mp, xfs_daddr_t d) 2858c2ecf20Sopenharmony_ci{ 2868c2ecf20Sopenharmony_ci xfs_rfsblock_t ld = XFS_BB_TO_FSBT(mp, d); 2878c2ecf20Sopenharmony_ci do_div(ld, mp->m_sb.sb_agblocks); 2888c2ecf20Sopenharmony_ci return (xfs_agnumber_t) ld; 2898c2ecf20Sopenharmony_ci} 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_cistatic inline xfs_agblock_t 2928c2ecf20Sopenharmony_cixfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d) 2938c2ecf20Sopenharmony_ci{ 2948c2ecf20Sopenharmony_ci xfs_rfsblock_t ld = XFS_BB_TO_FSBT(mp, d); 2958c2ecf20Sopenharmony_ci return (xfs_agblock_t) do_div(ld, mp->m_sb.sb_agblocks); 2968c2ecf20Sopenharmony_ci} 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_ci/* per-AG block reservation data structures*/ 2998c2ecf20Sopenharmony_cistruct xfs_ag_resv { 3008c2ecf20Sopenharmony_ci /* number of blocks originally reserved here */ 3018c2ecf20Sopenharmony_ci xfs_extlen_t ar_orig_reserved; 3028c2ecf20Sopenharmony_ci /* number of blocks reserved here */ 3038c2ecf20Sopenharmony_ci xfs_extlen_t ar_reserved; 3048c2ecf20Sopenharmony_ci /* number of blocks originally asked for */ 3058c2ecf20Sopenharmony_ci xfs_extlen_t ar_asked; 3068c2ecf20Sopenharmony_ci}; 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_ci/* 3098c2ecf20Sopenharmony_ci * Per-ag incore structure, copies of information in agf and agi, to improve the 3108c2ecf20Sopenharmony_ci * performance of allocation group selection. 3118c2ecf20Sopenharmony_ci */ 3128c2ecf20Sopenharmony_citypedef struct xfs_perag { 3138c2ecf20Sopenharmony_ci struct xfs_mount *pag_mount; /* owner filesystem */ 3148c2ecf20Sopenharmony_ci xfs_agnumber_t pag_agno; /* AG this structure belongs to */ 3158c2ecf20Sopenharmony_ci atomic_t pag_ref; /* perag reference count */ 3168c2ecf20Sopenharmony_ci char pagf_init; /* this agf's entry is initialized */ 3178c2ecf20Sopenharmony_ci char pagi_init; /* this agi's entry is initialized */ 3188c2ecf20Sopenharmony_ci char pagf_metadata; /* the agf is preferred to be metadata */ 3198c2ecf20Sopenharmony_ci char pagi_inodeok; /* The agi is ok for inodes */ 3208c2ecf20Sopenharmony_ci uint8_t pagf_levels[XFS_BTNUM_AGF]; 3218c2ecf20Sopenharmony_ci /* # of levels in bno & cnt btree */ 3228c2ecf20Sopenharmony_ci bool pagf_agflreset; /* agfl requires reset before use */ 3238c2ecf20Sopenharmony_ci uint32_t pagf_flcount; /* count of blocks in freelist */ 3248c2ecf20Sopenharmony_ci xfs_extlen_t pagf_freeblks; /* total free blocks */ 3258c2ecf20Sopenharmony_ci xfs_extlen_t pagf_longest; /* longest free space */ 3268c2ecf20Sopenharmony_ci uint32_t pagf_btreeblks; /* # of blocks held in AGF btrees */ 3278c2ecf20Sopenharmony_ci xfs_agino_t pagi_freecount; /* number of free inodes */ 3288c2ecf20Sopenharmony_ci xfs_agino_t pagi_count; /* number of allocated inodes */ 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_ci /* 3318c2ecf20Sopenharmony_ci * Inode allocation search lookup optimisation. 3328c2ecf20Sopenharmony_ci * If the pagino matches, the search for new inodes 3338c2ecf20Sopenharmony_ci * doesn't need to search the near ones again straight away 3348c2ecf20Sopenharmony_ci */ 3358c2ecf20Sopenharmony_ci xfs_agino_t pagl_pagino; 3368c2ecf20Sopenharmony_ci xfs_agino_t pagl_leftrec; 3378c2ecf20Sopenharmony_ci xfs_agino_t pagl_rightrec; 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_ci /* 3408c2ecf20Sopenharmony_ci * Bitsets of per-ag metadata that have been checked and/or are sick. 3418c2ecf20Sopenharmony_ci * Callers should hold pag_state_lock before accessing this field. 3428c2ecf20Sopenharmony_ci */ 3438c2ecf20Sopenharmony_ci uint16_t pag_checked; 3448c2ecf20Sopenharmony_ci uint16_t pag_sick; 3458c2ecf20Sopenharmony_ci spinlock_t pag_state_lock; 3468c2ecf20Sopenharmony_ci 3478c2ecf20Sopenharmony_ci spinlock_t pagb_lock; /* lock for pagb_tree */ 3488c2ecf20Sopenharmony_ci struct rb_root pagb_tree; /* ordered tree of busy extents */ 3498c2ecf20Sopenharmony_ci unsigned int pagb_gen; /* generation count for pagb_tree */ 3508c2ecf20Sopenharmony_ci wait_queue_head_t pagb_wait; /* woken when pagb_gen changes */ 3518c2ecf20Sopenharmony_ci 3528c2ecf20Sopenharmony_ci atomic_t pagf_fstrms; /* # of filestreams active in this AG */ 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_ci spinlock_t pag_ici_lock; /* incore inode cache lock */ 3558c2ecf20Sopenharmony_ci struct radix_tree_root pag_ici_root; /* incore inode cache root */ 3568c2ecf20Sopenharmony_ci int pag_ici_reclaimable; /* reclaimable inodes */ 3578c2ecf20Sopenharmony_ci unsigned long pag_ici_reclaim_cursor; /* reclaim restart point */ 3588c2ecf20Sopenharmony_ci 3598c2ecf20Sopenharmony_ci /* buffer cache index */ 3608c2ecf20Sopenharmony_ci spinlock_t pag_buf_lock; /* lock for pag_buf_hash */ 3618c2ecf20Sopenharmony_ci struct rhashtable pag_buf_hash; 3628c2ecf20Sopenharmony_ci 3638c2ecf20Sopenharmony_ci /* for rcu-safe freeing */ 3648c2ecf20Sopenharmony_ci struct rcu_head rcu_head; 3658c2ecf20Sopenharmony_ci int pagb_count; /* pagb slots in use */ 3668c2ecf20Sopenharmony_ci 3678c2ecf20Sopenharmony_ci /* Blocks reserved for all kinds of metadata. */ 3688c2ecf20Sopenharmony_ci struct xfs_ag_resv pag_meta_resv; 3698c2ecf20Sopenharmony_ci /* Blocks reserved for the reverse mapping btree. */ 3708c2ecf20Sopenharmony_ci struct xfs_ag_resv pag_rmapbt_resv; 3718c2ecf20Sopenharmony_ci 3728c2ecf20Sopenharmony_ci /* reference count */ 3738c2ecf20Sopenharmony_ci uint8_t pagf_refcount_level; 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ci /* 3768c2ecf20Sopenharmony_ci * Unlinked inode information. This incore information reflects 3778c2ecf20Sopenharmony_ci * data stored in the AGI, so callers must hold the AGI buffer lock 3788c2ecf20Sopenharmony_ci * or have some other means to control concurrency. 3798c2ecf20Sopenharmony_ci */ 3808c2ecf20Sopenharmony_ci struct rhashtable pagi_unlinked_hash; 3818c2ecf20Sopenharmony_ci} xfs_perag_t; 3828c2ecf20Sopenharmony_ci 3838c2ecf20Sopenharmony_cistatic inline struct xfs_ag_resv * 3848c2ecf20Sopenharmony_cixfs_perag_resv( 3858c2ecf20Sopenharmony_ci struct xfs_perag *pag, 3868c2ecf20Sopenharmony_ci enum xfs_ag_resv_type type) 3878c2ecf20Sopenharmony_ci{ 3888c2ecf20Sopenharmony_ci switch (type) { 3898c2ecf20Sopenharmony_ci case XFS_AG_RESV_METADATA: 3908c2ecf20Sopenharmony_ci return &pag->pag_meta_resv; 3918c2ecf20Sopenharmony_ci case XFS_AG_RESV_RMAPBT: 3928c2ecf20Sopenharmony_ci return &pag->pag_rmapbt_resv; 3938c2ecf20Sopenharmony_ci default: 3948c2ecf20Sopenharmony_ci return NULL; 3958c2ecf20Sopenharmony_ci } 3968c2ecf20Sopenharmony_ci} 3978c2ecf20Sopenharmony_ci 3988c2ecf20Sopenharmony_ciint xfs_buf_hash_init(xfs_perag_t *pag); 3998c2ecf20Sopenharmony_civoid xfs_buf_hash_destroy(xfs_perag_t *pag); 4008c2ecf20Sopenharmony_ci 4018c2ecf20Sopenharmony_ciextern void xfs_uuid_table_free(void); 4028c2ecf20Sopenharmony_ciextern int xfs_log_sbcount(xfs_mount_t *); 4038c2ecf20Sopenharmony_ciextern uint64_t xfs_default_resblks(xfs_mount_t *mp); 4048c2ecf20Sopenharmony_ciextern int xfs_mountfs(xfs_mount_t *mp); 4058c2ecf20Sopenharmony_ciextern int xfs_initialize_perag(xfs_mount_t *mp, xfs_agnumber_t agcount, 4068c2ecf20Sopenharmony_ci xfs_agnumber_t *maxagi); 4078c2ecf20Sopenharmony_ciextern void xfs_unmountfs(xfs_mount_t *); 4088c2ecf20Sopenharmony_ci 4098c2ecf20Sopenharmony_ci/* Accessor added for 5.10.y backport */ 4108c2ecf20Sopenharmony_cistatic inline uint64_t 4118c2ecf20Sopenharmony_cixfs_fdblocks_unavailable( 4128c2ecf20Sopenharmony_ci struct xfs_mount *mp) 4138c2ecf20Sopenharmony_ci{ 4148c2ecf20Sopenharmony_ci return mp->m_alloc_set_aside; 4158c2ecf20Sopenharmony_ci} 4168c2ecf20Sopenharmony_ci 4178c2ecf20Sopenharmony_ciextern int xfs_mod_fdblocks(struct xfs_mount *mp, int64_t delta, 4188c2ecf20Sopenharmony_ci bool reserved); 4198c2ecf20Sopenharmony_ciextern int xfs_mod_frextents(struct xfs_mount *mp, int64_t delta); 4208c2ecf20Sopenharmony_ci 4218c2ecf20Sopenharmony_ciextern int xfs_readsb(xfs_mount_t *, int); 4228c2ecf20Sopenharmony_ciextern void xfs_freesb(xfs_mount_t *); 4238c2ecf20Sopenharmony_ciextern bool xfs_fs_writable(struct xfs_mount *mp, int level); 4248c2ecf20Sopenharmony_ciextern int xfs_sb_validate_fsb_count(struct xfs_sb *, uint64_t); 4258c2ecf20Sopenharmony_ci 4268c2ecf20Sopenharmony_ciextern int xfs_dev_is_read_only(struct xfs_mount *, char *); 4278c2ecf20Sopenharmony_ci 4288c2ecf20Sopenharmony_ciextern void xfs_set_low_space_thresholds(struct xfs_mount *); 4298c2ecf20Sopenharmony_ci 4308c2ecf20Sopenharmony_ciint xfs_zero_extent(struct xfs_inode *ip, xfs_fsblock_t start_fsb, 4318c2ecf20Sopenharmony_ci xfs_off_t count_fsb); 4328c2ecf20Sopenharmony_ci 4338c2ecf20Sopenharmony_cistruct xfs_error_cfg * xfs_error_get_cfg(struct xfs_mount *mp, 4348c2ecf20Sopenharmony_ci int error_class, int error); 4358c2ecf20Sopenharmony_civoid xfs_force_summary_recalc(struct xfs_mount *mp); 4368c2ecf20Sopenharmony_civoid xfs_mod_delalloc(struct xfs_mount *mp, int64_t delta); 4378c2ecf20Sopenharmony_ci 4388c2ecf20Sopenharmony_ci#endif /* __XFS_MOUNT_H__ */ 439