bcachefs: Journal space calculation fix
authorKent Overstreet <kent.overstreet@gmail.com>
Mon, 31 May 2021 04:13:39 +0000 (00:13 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:05 +0000 (17:09 -0400)
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>
fs/bcachefs/journal_reclaim.c

index 812620d3de31ea5a92ec9bbc120d6eb3a8a04735..54d8e2f32a37ea8eab2586516cef28230cdad065 100644 (file)
@@ -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;