]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
FIXUP: xfs: generalize the freespace and reserved blocks handling
authorChristoph Hellwig <hch@lst.de>
Fri, 20 Dec 2024 03:48:51 +0000 (19:48 -0800)
committerChristoph Hellwig <hch@lst.de>
Mon, 14 Apr 2025 05:25:38 +0000 (07:25 +0200)
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
include/xfs_mount.h
libxfs/libxfs_priv.h

index 383cba7d6e3fee676aefb1b9bdcf674f87c1cf14..e0f72fc32b251691a237819530218b9eb6e130c9 100644 (file)
@@ -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 */
index 7e5c125b581a2f38db6d426b9acab3fc897bceab..cb4800de0b1100b006ffb6cf7e9dee7416cd2a0c 100644 (file)
@@ -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;