summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-05-31 00:13:39 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2021-05-31 14:59:15 -0400
commit3913e0cac34e0993ab6dde67a2dec1ea485a2e28 (patch)
tree4e86cb2513ad23a66af17a4f21979ab10a440b5b
parent675144f15addd6312ad6b1eed7fb3c330124da54 (diff)
bcachefs: Journal space calculation fix
When devices have different bucket sizes, we may accumulate a journal write that doesn't fit on some of our devices - previously, we'd underflow when calculating space on that device and then everything would get weird. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--fs/bcachefs/journal_reclaim.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/bcachefs/journal_reclaim.c b/fs/bcachefs/journal_reclaim.c
index 427be2da1dfc..7a0ae5d3431c 100644
--- a/fs/bcachefs/journal_reclaim.c
+++ b/fs/bcachefs/journal_reclaim.c
@@ -93,6 +93,10 @@ journal_dev_space_available(struct journal *j, struct bch_dev *ca,
* until we write it out - thus, account for it here:
*/
while ((unwritten = get_unwritten_sectors(j, &idx))) {
+ /* entry won't fit on this device, skip: */
+ if (unwritten > ca->mi.bucket_size)
+ continue;
+
if (unwritten >= sectors) {
if (!buckets) {
sectors = 0;