Skip to content

Commit 1c0ee43

Browse files
author
Kent Overstreet
committed
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>
1 parent 9773547 commit 1c0ee43

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

fs/bcachefs/bcachefs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ struct bch_dev {
594594
#define BCH_FS_FLAGS() \
595595
x(new_fs) \
596596
x(started) \
597+
x(clean_recovery) \
597598
x(btree_running) \
598599
x(accounting_replay_done) \
599600
x(may_go_rw) \

fs/bcachefs/fsck.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,8 +1084,9 @@ static int check_inode(struct btree_trans *trans,
10841084
}
10851085
}
10861086

1087+
/* i_size_dirty is vestigal, since we now have logged ops for truncate * */
10871088
if (u.bi_flags & BCH_INODE_i_size_dirty &&
1088-
(!c->sb.clean ||
1089+
(!test_bit(BCH_FS_clean_recovery, &c->flags) ||
10891090
fsck_err(trans, inode_i_size_dirty_but_clean,
10901091
"filesystem marked clean, but inode %llu has i_size dirty",
10911092
u.bi_inum))) {
@@ -1114,8 +1115,9 @@ static int check_inode(struct btree_trans *trans,
11141115
do_update = true;
11151116
}
11161117

1118+
/* i_sectors_dirty is vestigal, i_sectors is always updated transactionally */
11171119
if (u.bi_flags & BCH_INODE_i_sectors_dirty &&
1118-
(!c->sb.clean ||
1120+
(!test_bit(BCH_FS_clean_recovery, &c->flags) ||
11191121
fsck_err(trans, inode_i_sectors_dirty_but_clean,
11201122
"filesystem marked clean, but inode %llu has i_sectors dirty",
11211123
u.bi_inum))) {

fs/bcachefs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ static int may_delete_deleted_inode(struct btree_trans *trans,
11131113
pos.offset, pos.snapshot))
11141114
goto delete;
11151115

1116-
if (c->sb.clean &&
1116+
if (test_bit(BCH_FS_clean_recovery, &c->flags) &&
11171117
!fsck_err(trans, deleted_inode_but_clean,
11181118
"filesystem marked as clean but have deleted inode %llu:%u",
11191119
pos.offset, pos.snapshot)) {

fs/bcachefs/recovery.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,8 @@ int bch2_fs_recovery(struct bch_fs *c)
717717

718718
if (c->opts.fsck)
719719
set_bit(BCH_FS_fsck_running, &c->flags);
720+
if (c->sb.clean)
721+
set_bit(BCH_FS_clean_recovery, &c->flags);
720722

721723
ret = bch2_blacklist_table_initialize(c);
722724
if (ret) {

0 commit comments

Comments
 (0)