@@ -210,7 +210,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(x) (*x)
+#define percpu_counter_sum_positive(x) ((*x) > 0 ? (*x) : 0)
/*
* get_random_u32 is used for di_gen inode allocation, it must be zero for
@@ -1035,11 +1035,12 @@ xfs_log_sb(
* and hence we don't need have to update it here.
*/
if (xfs_has_lazysbcount(mp)) {
- mp->m_sb.sb_icount = percpu_counter_sum(&mp->m_icount);
+ mp->m_sb.sb_icount = percpu_counter_sum_positive(&mp->m_icount);
mp->m_sb.sb_ifree = min_t(uint64_t,
- percpu_counter_sum(&mp->m_ifree),
+ percpu_counter_sum_positive(&mp->m_ifree),
mp->m_sb.sb_icount);
- mp->m_sb.sb_fdblocks = percpu_counter_sum(&mp->m_fdblocks);
+ mp->m_sb.sb_fdblocks =
+ percpu_counter_sum_positive(&mp->m_fdblocks);
}
xfs_sb_to_disk(bp->b_addr, &mp->m_sb);