From 45543ee2cbd259eecf99a39e7ba65d76e907c0ed Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 19 Dec 2024 19:48:51 -0800 Subject: [PATCH] FIXUP: xfs: generalize the freespace and reserved blocks handling Signed-off-by: Christoph Hellwig --- include/xfs_mount.h | 32 ++++++++++++++++++++++++++++++-- libxfs/libxfs_priv.h | 13 +------------ 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/include/xfs_mount.h b/include/xfs_mount.h index 383cba7d6..e0f72fc32 100644 --- a/include/xfs_mount.h +++ b/include/xfs_mount.h @@ -63,8 +63,6 @@ typedef struct xfs_mount { xfs_sb_t m_sb; /* copy of fs superblock */ #define m_icount m_sb.sb_icount #define m_ifree m_sb.sb_ifree -#define m_fdblocks m_sb.sb_fdblocks -#define m_frextents m_sb.sb_frextents spinlock_t m_sb_lock; /* @@ -332,6 +330,36 @@ static inline bool xfs_is_ ## name (struct xfs_mount *mp) \ __XFS_UNSUPP_OPSTATE(readonly) __XFS_UNSUPP_OPSTATE(shutdown) +static inline int64_t xfs_sum_freecounter(struct xfs_mount *mp, + enum xfs_free_counter ctr) +{ + if (ctr == XC_FREE_RTEXTENTS) + return mp->m_sb.sb_frextents; + return mp->m_sb.sb_fdblocks; +} + +static inline int64_t xfs_estimate_freecounter(struct xfs_mount *mp, + enum xfs_free_counter ctr) +{ + return xfs_sum_freecounter(mp, ctr); +} + +static inline int xfs_compare_freecounter(struct xfs_mount *mp, + enum xfs_free_counter ctr, int64_t rhs, int32_t batch) +{ + uint64_t count; + + if (ctr == XC_FREE_RTEXTENTS) + count = mp->m_sb.sb_frextents; + else + count = mp->m_sb.sb_fdblocks; + if (count > rhs) + return 1; + else if (count < rhs) + return -1; + return 0; +} + /* don't fail on device size or AG count checks */ #define LIBXFS_MOUNT_DEBUGGER (1U << 0) /* report metadata corruption to stdout */ diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index 7e5c125b5..cb4800de0 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -209,7 +209,7 @@ static inline bool WARN_ON(bool expr) { } #define WARN_ON_ONCE(e) WARN_ON(e) -#define percpu_counter_read(x) (*x) + #define percpu_counter_read_positive(x) ((*x) > 0 ? (*x) : 0) #define percpu_counter_sum_positive(x) ((*x) > 0 ? (*x) : 0) @@ -219,17 +219,6 @@ uint32_t get_random_u32(void); #define get_random_u32() (0) #endif -static inline int -__percpu_counter_compare(uint64_t *count, int64_t rhs, int32_t batch) -{ - if (*count > rhs) - return 1; - else if (*count < rhs) - return -1; - return 0; -} - - #define PAGE_SIZE getpagesize() extern unsigned int PAGE_SHIFT; -- 2.50.1