bcachefs: BCH_FS_clean_recovery

Add a filesystem flag to indicate whether we did a clean recovery -
using c->sb.clean after we've got rw is incorrect, since c->sb is
updated whenever we write the superblock.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2024-09-26 16:19:58 -04:00
parent 9773547b16
commit 1c0ee43b2c
4 changed files with 8 additions and 3 deletions

View file

@ -594,6 +594,7 @@ struct bch_dev {
#define BCH_FS_FLAGS() \ #define BCH_FS_FLAGS() \
x(new_fs) \ x(new_fs) \
x(started) \ x(started) \
x(clean_recovery) \
x(btree_running) \ x(btree_running) \
x(accounting_replay_done) \ x(accounting_replay_done) \
x(may_go_rw) \ x(may_go_rw) \

View file

@ -1084,8 +1084,9 @@ static int check_inode(struct btree_trans *trans,
} }
} }
/* i_size_dirty is vestigal, since we now have logged ops for truncate * */
if (u.bi_flags & BCH_INODE_i_size_dirty && if (u.bi_flags & BCH_INODE_i_size_dirty &&
(!c->sb.clean || (!test_bit(BCH_FS_clean_recovery, &c->flags) ||
fsck_err(trans, inode_i_size_dirty_but_clean, fsck_err(trans, inode_i_size_dirty_but_clean,
"filesystem marked clean, but inode %llu has i_size dirty", "filesystem marked clean, but inode %llu has i_size dirty",
u.bi_inum))) { u.bi_inum))) {
@ -1114,8 +1115,9 @@ static int check_inode(struct btree_trans *trans,
do_update = true; do_update = true;
} }
/* i_sectors_dirty is vestigal, i_sectors is always updated transactionally */
if (u.bi_flags & BCH_INODE_i_sectors_dirty && if (u.bi_flags & BCH_INODE_i_sectors_dirty &&
(!c->sb.clean || (!test_bit(BCH_FS_clean_recovery, &c->flags) ||
fsck_err(trans, inode_i_sectors_dirty_but_clean, fsck_err(trans, inode_i_sectors_dirty_but_clean,
"filesystem marked clean, but inode %llu has i_sectors dirty", "filesystem marked clean, but inode %llu has i_sectors dirty",
u.bi_inum))) { u.bi_inum))) {

View file

@ -1113,7 +1113,7 @@ static int may_delete_deleted_inode(struct btree_trans *trans,
pos.offset, pos.snapshot)) pos.offset, pos.snapshot))
goto delete; goto delete;
if (c->sb.clean && if (test_bit(BCH_FS_clean_recovery, &c->flags) &&
!fsck_err(trans, deleted_inode_but_clean, !fsck_err(trans, deleted_inode_but_clean,
"filesystem marked as clean but have deleted inode %llu:%u", "filesystem marked as clean but have deleted inode %llu:%u",
pos.offset, pos.snapshot)) { pos.offset, pos.snapshot)) {

View file

@ -717,6 +717,8 @@ int bch2_fs_recovery(struct bch_fs *c)
if (c->opts.fsck) if (c->opts.fsck)
set_bit(BCH_FS_fsck_running, &c->flags); set_bit(BCH_FS_fsck_running, &c->flags);
if (c->sb.clean)
set_bit(BCH_FS_clean_recovery, &c->flags);
ret = bch2_blacklist_table_initialize(c); ret = bch2_blacklist_table_initialize(c);
if (ret) { if (ret) {