bcachefs: Fix cached data accounting
authorKent Overstreet <kent.overstreet@linux.dev>
Tue, 11 Oct 2022 08:49:23 +0000 (04:49 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:43 +0000 (17:09 -0400)
Negating without casting to a signed integer means the value wasn't
getting sign extended properly - oops.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/buckets.c

index 4b041707cd54b9e1495adc668db6e0c3b79eab56..5cb4a00166f93ad7eb388314a07bdab7417a21a3 100644 (file)
@@ -578,7 +578,7 @@ int bch2_mark_alloc(struct btree_trans *trans,
        if ((flags & BTREE_TRIGGER_BUCKET_INVALIDATE) &&
            old_a.cached_sectors) {
                ret = update_cached_sectors(c, new, ca->dev_idx,
-                                           -old_a.cached_sectors,
+                                           -((s64) old_a.cached_sectors),
                                            journal_seq, gc);
                if (ret) {
                        bch2_fs_fatal_error(c, "bch2_mark_alloc(): no replicas entry while updating cached sectors");