bcachefs: Add logging to bch2_inode_peek() & related
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 6 Aug 2023 14:04:05 +0000 (10:04 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:10:09 +0000 (17:10 -0400)
Add error messages when we fail to lookup an inode, and also add a few
missing bch2_err_class() calls.

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

index 3b39597a677aa34671f5f72d65171283a8573ba1..30b3d7b9f9dc14de467685e653a2624201a6cf5a 100644 (file)
@@ -294,8 +294,8 @@ do {                                                                        \
 
 #define bch_err_fn(_c, _ret)                                           \
         bch_err(_c, "%s(): error %s", __func__, bch2_err_str(_ret))
-#define bch_err_msg(_c, _ret, _msg)                                    \
-        bch_err(_c, "%s(): error " _msg " %s", __func__, bch2_err_str(_ret))
+#define bch_err_msg(_c, _ret, _msg, ...)                               \
+        bch_err(_c, "%s(): error " _msg " %s", __func__, ##__VA_ARGS__, bch2_err_str(_ret))
 
 #define bch_verbose(c, fmt, ...)                                       \
 do {                                                                   \
index e1824bdffdf82d9ee098bd9fb5d534dc4988d48c..695b8bc555907e6438b5d1be4a3c743f54e5bf88 100644 (file)
@@ -203,7 +203,7 @@ struct inode *bch2_vfs_inode_get(struct bch_fs *c, subvol_inum inum)
 
        if (ret) {
                iget_failed(&inode->v);
-               return ERR_PTR(ret);
+               return ERR_PTR(bch2_err_class(ret));
        }
 
        mutex_lock(&c->vfs_inodes_lock);
@@ -1000,11 +1000,16 @@ static int bch2_vfs_readdir(struct file *file, struct dir_context *ctx)
 {
        struct bch_inode_info *inode = file_bch_inode(file);
        struct bch_fs *c = inode->v.i_sb->s_fs_info;
+       int ret;
 
        if (!dir_emit_dots(file, ctx))
                return 0;
 
-       return bch2_readdir(c, inode_inum(inode), ctx);
+       ret = bch2_readdir(c, inode_inum(inode), ctx);
+       if (ret)
+               bch_err_fn(c, ret);
+
+       return bch2_err_class(ret);
 }
 
 static const struct file_operations bch_file_operations = {
index 294966e428503b55f8c0e9c2a70871e7b77ba0ce..e0d416553bf0b00ed2bb7eb112c9a2909afc6624 100644 (file)
@@ -348,6 +348,8 @@ 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))
+               bch_err_msg(trans->c, ret, "looking up inum %u:%llu:", inum.subvol, inum.inum);
        return ret;
 }