diff mbox series

[02/43] FIXUP: xfs: generalize the freespace and reserved blocks handling

Message ID 20250414053629.360672-3-hch@lst.de (mailing list archive)
State New
Headers show
Series [01/43] xfs: generalize the freespace and reserved blocks handling | expand

Commit Message

Christoph Hellwig April 14, 2025, 5:35 a.m. UTC
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
 include/xfs_mount.h  | 32 ++++++++++++++++++++++++++++++--
 libxfs/libxfs_priv.h | 13 +------------
 2 files changed, 31 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/include/xfs_mount.h b/include/xfs_mount.h
index 383cba7d6e3f..e0f72fc32b25 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 7e5c125b581a..cb4800de0b11 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;