From 6d033aa404e71710de217d63999fade2f2b0491f Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sat, 9 Feb 2019 19:45:36 -0500 Subject: [PATCH] bcachefs: Don't need to walk inodes on clean shutdown Signed-off-by: Kent Overstreet --- fs/bcachefs/fsck.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index 810e1c3f4c49..e79846a96f9c 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -1187,6 +1187,11 @@ static int check_inode(struct bch_fs *c, } if (u.bi_flags & BCH_INODE_UNLINKED) { + fsck_err_on(c->sb.clean, c, + "filesystem marked clean, " + "but inode %llu unlinked", + u.bi_inum); + bch_verbose(c, "deleting inode %llu", u.bi_inum); ret = bch2_inode_rm(c, u.bi_inum); @@ -1389,16 +1394,13 @@ static int check_inodes_fast(struct bch_fs *c) (BCH_INODE_I_SIZE_DIRTY| BCH_INODE_I_SECTORS_DIRTY| BCH_INODE_UNLINKED)) { - fsck_err_on(c->sb.clean, c, - "filesystem marked clean but found inode %llu with flags %x", - inode.k->p.inode, inode.v->bi_flags); ret = check_inode(c, NULL, &iter, inode, NULL); BUG_ON(ret == -EINTR); if (ret) break; } } -fsck_err: + return bch2_btree_iter_unlock(&iter) ?: ret; } @@ -1460,9 +1462,10 @@ int bch2_fsck(struct bch_fs *c) if (c->opts.fsck) return bch2_fsck_full(c); - if (!c->sb.clean && - !(c->sb.features & (1 << BCH_FEATURE_ATOMIC_NLINK))) - return bch2_fsck_inode_nlink(c); + if (c->sb.clean) + return 0; - return bch2_fsck_walk_inodes_only(c); + return c->sb.features & (1 << BCH_FEATURE_ATOMIC_NLINK) + ? bch2_fsck_walk_inodes_only(c) + : bch2_fsck_inode_nlink(c); }