summaryrefslogtreecommitdiff
path: root/fs/bcachefs/buckets.h
diff options
context:
space:
mode:
authorDan Robertson <dan@dlrobertson.com>2021-05-18 20:36:20 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:03 -0400
commited34341189478344eb54588ce73f190b86da4d5e (patch)
tree15444c5676406966c91ac2a60375edc4e43b678c /fs/bcachefs/buckets.h
parentc21d5377791d94fca0d990eee82111572412640c (diff)
bcachefs: statfs resports incorrect avail blocks
The current implementation of bch_statfs does not scale the number of available blocks provided in f_bavail by the reserve factor. This causes an allocation of a file of this size to fail. Signed-off-by: Dan Robertson <dan@dlrobertson.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/buckets.h')
-rw-r--r--fs/bcachefs/buckets.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/bcachefs/buckets.h b/fs/bcachefs/buckets.h
index 7463e6420b14..04a2a9310cdd 100644
--- a/fs/bcachefs/buckets.h
+++ b/fs/bcachefs/buckets.h
@@ -294,6 +294,13 @@ static inline int bch2_disk_reservation_get(struct bch_fs *c,
return bch2_disk_reservation_add(c, res, sectors * nr_replicas, flags);
}
+#define RESERVE_FACTOR 6
+
+static inline u64 avail_factor(u64 r)
+{
+ return div_u64(r << RESERVE_FACTOR, (1 << RESERVE_FACTOR) + 1);
+}
+
int bch2_dev_buckets_resize(struct bch_fs *, struct bch_dev *, u64);
void bch2_dev_buckets_free(struct bch_dev *);
int bch2_dev_buckets_alloc(struct bch_fs *, struct bch_dev *);