diff --git a/fs/bcachefs/alloc_background.h b/fs/bcachefs/alloc_background.h
index ff366e61ace51ea4af61b916c88ca88f24d05a1e..488db3211ce47f005066bc25944651be16acf713 100644
--- a/fs/bcachefs/alloc_background.h
+++ b/fs/bcachefs/alloc_background.h
@@ -134,11 +134,13 @@ void bch2_do_discards(struct bch_fs *);
 static inline u64 should_invalidate_buckets(struct bch_dev *ca,
 					    struct bch_dev_usage u)
 {
-	u64 free = u.d[BCH_DATA_free].buckets +
-		u.d[BCH_DATA_need_discard].buckets;
+	u64 want_free = ca->mi.nbuckets >> 7;
+	u64 free = max_t(s64, 0,
+			   u.d[BCH_DATA_free].buckets
+			 + u.d[BCH_DATA_need_discard].buckets
+			 - bch2_dev_buckets_reserved(ca, RESERVE_none));
 
-	return clamp_t(s64, (ca->mi.nbuckets >> 7) - free,
-		       0, u.d[BCH_DATA_cached].buckets);
+	return clamp_t(s64, want_free - free, 0, u.d[BCH_DATA_cached].buckets);
 }
 
 void bch2_do_invalidates(struct bch_fs *);