Message ID | 20250409075557.3535745-3-hch@lst.de (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [01/45] xfs: generalize the freespace and reserved blocks handling | expand |
On Wed, Apr 09, 2025 at 09:55:05AM +0200, Christoph Hellwig wrote: > Signed-off-by: Christoph Hellwig <hch@lst.de> Looks ok, Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> --D > --- > 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 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; > > -- > 2.47.2 > >
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;
Signed-off-by: Christoph Hellwig <hch@lst.de> --- include/xfs_mount.h | 32 ++++++++++++++++++++++++++++++-- libxfs/libxfs_priv.h | 13 +------------ 2 files changed, 31 insertions(+), 14 deletions(-)