bcachefs: More improvements for alloc info checks
authorKent Overstreet <kent.overstreet@gmail.com>
Tue, 5 Apr 2022 17:44:18 +0000 (13:44 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:30 +0000 (17:09 -0400)
commite1effd42a1cb40048002f594c12e823b5e33ed5d
tree24af42ba8fc1021eebfceb6896c14132d6edb635
parentafb6f7f61ba38f4d4d96e8d1bf5fb9e7809e6c10
bcachefs: More improvements for alloc info checks

 - Move checks for whether the device & bucket are valid from the
   .key_invalid method to bch2_check_alloc_key(). This is because
   .key_invalid() is called on keys that may no longer exist (post
   journal replay), which is a problem when removing/resizing devices.

 - We weren't checking the need_discard btree to ensure that every set
   bucket has a corresponding alloc key. This refactors the code for
   checking the freespace btree, so that it now checks both.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
fs/bcachefs/alloc_background.c
fs/bcachefs/alloc_background.h
fs/bcachefs/buckets.c
fs/bcachefs/recovery.c
fs/bcachefs/super.c