bcachefs: Kill missing inode warnings in bch2_quota_read()
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 11 Sep 2023 02:05:50 +0000 (22:05 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:10:12 +0000 (17:10 -0400)
bch2_quota_read(), when scanning for inodes, may attempt to look up
inodes that have been deleted in the main subvolume - this is not an
error.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/inode.c
fs/bcachefs/inode.h
fs/bcachefs/quota.c

index 8114b6e..4548de6 100644 (file)
@@ -318,7 +318,7 @@ int bch2_inode_unpack(struct bkey_s_c k,
        return bch2_inode_unpack_slowpath(k, unpacked);
 }
 
-int bch2_inode_peek(struct btree_trans *trans,
+static int bch2_inode_peek_nowarn(struct btree_trans *trans,
                    struct btree_iter *iter,
                    struct bch_inode_unpacked *inode,
                    subvol_inum inum, unsigned flags)
@@ -349,7 +349,17 @@ int bch2_inode_peek(struct btree_trans *trans,
        return 0;
 err:
        bch2_trans_iter_exit(trans, iter);
-       if (!bch2_err_matches(ret, BCH_ERR_transaction_restart))
+       return ret;
+}
+
+int bch2_inode_peek(struct btree_trans *trans,
+                   struct btree_iter *iter,
+                   struct bch_inode_unpacked *inode,
+                   subvol_inum inum, unsigned flags)
+{
+       int ret = bch2_inode_peek_nowarn(trans, iter, inode, inum, flags);
+
+       if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
                bch_err_msg(trans->c, ret, "looking up inum %u:%llu:", inum.subvol, inum.inum);
        return ret;
 }
@@ -880,6 +890,19 @@ err:
        return ret;
 }
 
+int bch2_inode_find_by_inum_nowarn_trans(struct btree_trans *trans,
+                                 subvol_inum inum,
+                                 struct bch_inode_unpacked *inode)
+{
+       struct btree_iter iter;
+       int ret;
+
+       ret = bch2_inode_peek_nowarn(trans, &iter, inode, inum, 0);
+       if (!ret)
+               bch2_trans_iter_exit(trans, &iter);
+       return ret;
+}
+
 int bch2_inode_find_by_inum_trans(struct btree_trans *trans,
                                  subvol_inum inum,
                                  struct bch_inode_unpacked *inode)
index 22b2440..a7464e1 100644 (file)
@@ -118,6 +118,9 @@ int bch2_inode_create(struct btree_trans *, struct btree_iter *,
 
 int bch2_inode_rm(struct bch_fs *, subvol_inum);
 
+int bch2_inode_find_by_inum_nowarn_trans(struct btree_trans *,
+                                 subvol_inum,
+                                 struct bch_inode_unpacked *);
 int bch2_inode_find_by_inum_trans(struct btree_trans *, subvol_inum,
                                  struct bch_inode_unpacked *);
 int bch2_inode_find_by_inum(struct bch_fs *, subvol_inum,
index ca99772..60d27f7 100644 (file)
@@ -572,7 +572,7 @@ static int bch2_fs_quota_read_inode(struct btree_trans *trans,
        if (!s_t.master_subvol)
                goto advance;
 
-       ret = bch2_inode_find_by_inum_trans(trans,
+       ret = bch2_inode_find_by_inum_nowarn_trans(trans,
                                (subvol_inum) {
                                        le32_to_cpu(s_t.master_subvol),
                                        k.k->p.offset,