From: Kent Overstreet Date: Mon, 14 Oct 2024 21:55:48 +0000 (-0400) Subject: bcachefs: fix disk reservation accounting in bch2_folio_reservation_get() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=81e0b6c7c1f75c914dede330121391f57f216a6e;p=users%2Fjedix%2Flinux-maple.git bcachefs: fix disk reservation accounting in bch2_folio_reservation_get() bch2_disk_reservation_put() zeroes out the reservation - oops. This fixes a disk reservation leak when getting a quota reservation returned an error. Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/fs-io-pagecache.c b/fs/bcachefs/fs-io-pagecache.c index af3a24546aa37..cde3a0445ee94 100644 --- a/fs/bcachefs/fs-io-pagecache.c +++ b/fs/bcachefs/fs-io-pagecache.c @@ -431,9 +431,9 @@ int bch2_folio_reservation_get(struct bch_fs *c, ret = bch2_quota_reservation_add(c, inode, &res->quota, quota_sectors, true); if (unlikely(ret)) { struct disk_reservation tmp = { .sectors = disk_sectors }; + res->disk.sectors -= disk_sectors; bch2_disk_reservation_put(c, &tmp); - res->disk.sectors -= disk_sectors; return ret; } }