]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: Use bch2_err_str() in error messages
authorKent Overstreet <kent.overstreet@gmail.com>
Mon, 18 Jul 2022 23:42:58 +0000 (19:42 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:36 +0000 (17:09 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
16 files changed:
fs/bcachefs/alloc_background.c
fs/bcachefs/btree_gc.c
fs/bcachefs/checksum.c
fs/bcachefs/ec.c
fs/bcachefs/fs.c
fs/bcachefs/fsck.c
fs/bcachefs/journal_reclaim.c
fs/bcachefs/migrate.c
fs/bcachefs/move.c
fs/bcachefs/movinggc.c
fs/bcachefs/quota.c
fs/bcachefs/rebalance.c
fs/bcachefs/recovery.c
fs/bcachefs/subvolume.c
fs/bcachefs/super.c
fs/bcachefs/tests.c

index 9ba1fdba41389a5853a31d07a9b182f5d707ece3..eb44a8bc04fe074893658971689bbc3610b15318 100644 (file)
@@ -464,7 +464,7 @@ int bch2_alloc_read(struct bch_fs *c)
        bch2_trans_exit(&trans);
 
        if (ret)
-               bch_err(c, "error reading alloc info: %i", ret);
+               bch_err(c, "error reading alloc info: %s", bch2_err_str(ret));
 
        return ret;
 }
@@ -1211,7 +1211,7 @@ static int bch2_dev_freespace_init(struct bch_fs *c, struct bch_dev *ca)
        bch2_trans_exit(&trans);
 
        if (ret < 0) {
-               bch_err(ca, "error initializing free space: %i", ret);
+               bch_err(ca, "error initializing free space: %s", bch2_err_str(ret));
                return ret;
        }
 
index 7a7639e9ee3f66ab0d52ae42fe489ff56aaa818a..e7098e910a73ce64769552a26efa09362e1bb36b 100644 (file)
@@ -402,8 +402,8 @@ again:
                }
 
                if (ret) {
-                       bch_err(c, "%s: error %i getting btree node",
-                               __func__, ret);
+                       bch_err(c, "%s: error getting btree node: %s",
+                               __func__, bch2_err_str(ret));
                        break;
                }
 
@@ -471,8 +471,8 @@ again:
                ret = PTR_ERR_OR_ZERO(cur);
 
                if (ret) {
-                       bch_err(c, "%s: error %i getting btree node",
-                               __func__, ret);
+                       bch_err(c, "%s: error getting btree node: %s",
+                               __func__, bch2_err_str(ret));
                        goto err;
                }
 
@@ -804,7 +804,7 @@ static int bch2_gc_mark_key(struct btree_trans *trans, enum btree_id btree_id,
 fsck_err:
 err:
        if (ret)
-               bch_err(c, "%s: ret %i", __func__, ret);
+               bch_err(c, "error from %s(): %s", __func__, bch2_err_str(ret));
        return ret;
 }
 
@@ -910,7 +910,8 @@ static int bch2_gc_btree_init_recurse(struct btree_trans *trans, struct btree *b
                ret = bch2_gc_mark_key(trans, b->c.btree_id, b->c.level,
                                       false, &k, true);
                if (ret) {
-                       bch_err(c, "%s: error %i from bch2_gc_mark_key", __func__, ret);
+                       bch_err(c, "%s: error from bch2_gc_mark_key: %s",
+                               __func__, bch2_err_str(ret));
                        goto fsck_err;
                }
 
@@ -970,8 +971,8 @@ static int bch2_gc_btree_init_recurse(struct btree_trans *trans, struct btree *b
                                        continue;
                                }
                        } else if (ret) {
-                               bch_err(c, "%s: error %i getting btree node",
-                                       __func__, ret);
+                               bch_err(c, "%s: error getting btree node: %s",
+                                       __func__, bch2_err_str(ret));
                                break;
                        }
 
@@ -1038,7 +1039,7 @@ fsck_err:
        six_unlock_read(&b->c.lock);
 
        if (ret < 0)
-               bch_err(c, "%s: ret %i", __func__, ret);
+               bch_err(c, "error from %s(): %s", __func__, bch2_err_str(ret));
        printbuf_exit(&buf);
        return ret;
 }
@@ -1068,7 +1069,7 @@ static int bch2_gc_btrees(struct bch_fs *c, bool initial, bool metadata_only)
                        : bch2_gc_btree(&trans, ids[i], initial, metadata_only);
 
        if (ret < 0)
-               bch_err(c, "%s: ret %i", __func__, ret);
+               bch_err(c, "error from %s(): %s", __func__, bch2_err_str(ret));
 
        bch2_trans_exit(&trans);
        return ret;
@@ -1266,7 +1267,7 @@ fsck_err:
        if (ca)
                percpu_ref_put(&ca->ref);
        if (ret)
-               bch_err(c, "%s: ret %i", __func__, ret);
+               bch_err(c, "error from %s(): %s", __func__, bch2_err_str(ret));
 
        percpu_up_write(&c->mark_lock);
        printbuf_exit(&buf);
@@ -1433,7 +1434,7 @@ static int bch2_gc_alloc_done(struct bch_fs *c, bool metadata_only)
                        bch2_alloc_write_key(&trans, &iter, k, metadata_only));
 
                if (ret < 0) {
-                       bch_err(c, "error writing alloc info: %i", ret);
+                       bch_err(c, "error writing alloc info: %s", bch2_err_str(ret));
                        percpu_ref_put(&ca->ref);
                        break;
                }
@@ -1497,7 +1498,7 @@ static int bch2_gc_alloc_start(struct bch_fs *c, bool metadata_only)
        bch2_trans_exit(&trans);
 
        if (ret)
-               bch_err(c, "error reading alloc info at gc start: %i", ret);
+               bch_err(c, "error reading alloc info at gc start: %s", bch2_err_str(ret));
 
        return ret;
 }
@@ -1968,7 +1969,7 @@ int bch2_gc_gens(struct bch_fs *c)
                                        BTREE_INSERT_NOFAIL,
                                gc_btree_gens_key(&trans, &iter, k));
                        if (ret) {
-                               bch_err(c, "error recalculating oldest_gen: %i", ret);
+                               bch_err(c, "error recalculating oldest_gen: %s", bch2_err_str(ret));
                                goto err;
                        }
                }
@@ -1981,7 +1982,7 @@ int bch2_gc_gens(struct bch_fs *c)
                        BTREE_INSERT_NOFAIL,
                bch2_alloc_write_oldest_gen(&trans, &iter, k));
        if (ret) {
-               bch_err(c, "error writing oldest_gen: %i", ret);
+               bch_err(c, "error writing oldest_gen: %s", bch2_err_str(ret));
                goto err;
        }
 
@@ -2053,7 +2054,7 @@ static int bch2_gc_thread(void *arg)
                ret = bch2_gc_gens(c);
 #endif
                if (ret < 0)
-                       bch_err(c, "btree gc failed: %i", ret);
+                       bch_err(c, "btree gc failed: %s", bch2_err_str(ret));
 
                debug_check_no_locks_held();
        }
@@ -2083,7 +2084,7 @@ int bch2_gc_thread_start(struct bch_fs *c)
 
        p = kthread_create(bch2_gc_thread, c, "bch-gc/%s", c->name);
        if (IS_ERR(p)) {
-               bch_err(c, "error creating gc thread: %li", PTR_ERR(p));
+               bch_err(c, "error creating gc thread: %s", bch2_err_str(PTR_ERR(p)));
                return PTR_ERR(p);
        }
 
index 7c2af6754aeaaf603970cf719270c1a2032bfe1d..b5850a761b91037dbbffb56eb5a7e1ae37f7cde6 100644 (file)
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "bcachefs.h"
 #include "checksum.h"
+#include "errcode.h"
 #include "super.h"
 #include "super-io.h"
 
@@ -527,7 +528,7 @@ int bch2_decrypt_sb_key(struct bch_fs *c,
 
        ret = bch2_request_key(c->disk_sb.sb, &user_key);
        if (ret) {
-               bch_err(c, "error requesting encryption key: %i", ret);
+               bch_err(c, "error requesting encryption key: %s", bch2_err_str(ret));
                goto err;
        }
 
@@ -552,20 +553,24 @@ err:
 
 static int bch2_alloc_ciphers(struct bch_fs *c)
 {
+       int ret;
+
        if (!c->chacha20)
                c->chacha20 = crypto_alloc_sync_skcipher("chacha20", 0, 0);
-       if (IS_ERR(c->chacha20)) {
-               bch_err(c, "error requesting chacha20 module: %li",
-                       PTR_ERR(c->chacha20));
-               return PTR_ERR(c->chacha20);
+       ret = PTR_ERR_OR_ZERO(c->chacha20);
+
+       if (ret) {
+               bch_err(c, "error requesting chacha20 module: %s", bch2_err_str(ret));
+               return ret;
        }
 
        if (!c->poly1305)
                c->poly1305 = crypto_alloc_shash("poly1305", 0, 0);
-       if (IS_ERR(c->poly1305)) {
-               bch_err(c, "error requesting poly1305 module: %li",
-                       PTR_ERR(c->poly1305));
-               return PTR_ERR(c->poly1305);
+       ret = PTR_ERR_OR_ZERO(c->poly1305);
+
+       if (ret) {
+               bch_err(c, "error requesting poly1305 module: %s", bch2_err_str(ret));
+               return ret;
        }
 
        return 0;
@@ -626,7 +631,7 @@ int bch2_enable_encryption(struct bch_fs *c, bool keyed)
        if (keyed) {
                ret = bch2_request_key(c->disk_sb.sb, &user_key);
                if (ret) {
-                       bch_err(c, "error requesting encryption key: %i", ret);
+                       bch_err(c, "error requesting encryption key: %s", bch2_err_str(ret));
                        goto err;
                }
 
@@ -678,9 +683,9 @@ int bch2_fs_encryption_init(struct bch_fs *c)
        pr_verbose_init(c->opts, "");
 
        c->sha256 = crypto_alloc_shash("sha256", 0, 0);
-       if (IS_ERR(c->sha256)) {
-               bch_err(c, "error requesting sha256 module");
-               ret = PTR_ERR(c->sha256);
+       ret = PTR_ERR_OR_ZERO(c->sha256);
+       if (ret) {
+               bch_err(c, "error requesting sha256 module: %s", bch2_err_str(ret));
                goto out;
        }
 
index 80e1689765e6437d2ef74f200d39aabc8d91eaa9..947f2f2b1c09daa3a21d88f10560c96781228486 100644 (file)
@@ -949,7 +949,8 @@ static void ec_stripe_create(struct ec_stripe_new *s)
        for_each_keylist_key(&s->keys, k) {
                ret = ec_stripe_update_extents(c, &s->new_stripe, &k->k);
                if (ret) {
-                       bch_err(c, "error creating stripe: error %i updating pointers", ret);
+                       bch_err(c, "error creating stripe: error updating pointers: %s",
+                               bch2_err_str(ret));
                        break;
                }
        }
index 08268fe1074fb5599d4d74e666c3b0f7c62c43aa..876552a2a83b1606dcb1223ffa5883a9266e6a0b 100644 (file)
@@ -8,6 +8,7 @@
 #include "buckets.h"
 #include "chardev.h"
 #include "dirent.h"
+#include "errcode.h"
 #include "extents.h"
 #include "fs.h"
 #include "fs-common.h"
@@ -1871,10 +1872,9 @@ got_sb:
        sb->s_shrink.seeks = 0;
 
        vinode = bch2_vfs_inode_get(c, BCACHEFS_ROOT_SUBVOL_INUM);
-       if (IS_ERR(vinode)) {
-               bch_err(c, "error mounting: error getting root inode %i",
-                       (int) PTR_ERR(vinode));
-               ret = PTR_ERR(vinode);
+       ret = PTR_ERR_OR_ZERO(vinode);
+       if (ret) {
+               bch_err(c, "error mounting: error getting root inode: %s", bch2_err_str(ret));
                goto err_put_super;
        }
 
index e601a1ee0ee14e33d2e6b865bd4bfe70d98475e9..021affcc82d49fb8c0121b9a79499605a997e6ad 100644 (file)
@@ -137,8 +137,8 @@ static int lookup_first_inode(struct btree_trans *trans, u64 inode_nr,
        ret = bch2_inode_unpack(k, inode);
 err:
        if (ret && ret != -EINTR)
-               bch_err(trans->c, "error %i fetching inode %llu",
-                       ret, inode_nr);
+               bch_err(trans->c, "error fetching inode %llu: %s",
+                       inode_nr, bch2_err_str(ret));
        bch2_trans_iter_exit(trans, &iter);
        return ret;
 }
@@ -165,8 +165,8 @@ static int __lookup_inode(struct btree_trans *trans, u64 inode_nr,
                *snapshot = iter.pos.snapshot;
 err:
        if (ret && ret != -EINTR)
-               bch_err(trans->c, "error %i fetching inode %llu:%u",
-                       ret, inode_nr, *snapshot);
+               bch_err(trans->c, "error fetching inode %llu:%u: %s",
+                       inode_nr, *snapshot, bch2_err_str(ret));
        bch2_trans_iter_exit(trans, &iter);
        return ret;
 }
@@ -225,7 +225,8 @@ static int write_inode(struct btree_trans *trans,
                                  BTREE_INSERT_LAZY_RW,
                                  __write_inode(trans, inode, snapshot));
        if (ret)
-               bch_err(trans->c, "error in fsck: error %i updating inode", ret);
+               bch_err(trans->c, "error in fsck: error updating inode: %s",
+                       bch2_err_str(ret));
        return ret;
 }
 
@@ -314,7 +315,7 @@ static int __remove_dirent(struct btree_trans *trans, struct bpos pos)
        bch2_trans_iter_exit(trans, &iter);
 err:
        if (ret && ret != -EINTR)
-               bch_err(c, "error %i from __remove_dirent()", ret);
+               bch_err(c, "error from __remove_dirent(): %s", bch2_err_str(ret));
        return ret;
 }
 
@@ -350,7 +351,7 @@ static int lookup_lostfound(struct btree_trans *trans, u32 subvol,
        }
 
        if (ret && ret != -EINTR)
-               bch_err(c, "error looking up lost+found: %i", ret);
+               bch_err(c, "error looking up lost+found: %s", bch2_err_str(ret));
        if (ret)
                return ret;
 
@@ -373,7 +374,7 @@ create_lostfound:
                                0, 0, S_IFDIR|0700, 0, NULL, NULL,
                                (subvol_inum) { }, 0);
        if (ret && ret != -EINTR)
-               bch_err(c, "error creating lost+found: %i", ret);
+               bch_err(c, "error creating lost+found: %s", bch2_err_str(ret));
        return ret;
 }
 
@@ -437,8 +438,8 @@ static int reattach_inode(struct btree_trans *trans,
                                  BTREE_INSERT_NOFAIL,
                        __reattach_inode(trans, inode, inode_snapshot));
        if (ret) {
-               bch_err(trans->c, "error %i reattaching inode %llu",
-                       ret, inode->bi_inum);
+               bch_err(trans->c, "error reattaching inode %llu: %s",
+                       inode->bi_inum, bch2_err_str(ret));
                return ret;
        }
 
@@ -910,7 +911,8 @@ static int check_inode(struct btree_trans *trans,
 
                ret = fsck_inode_rm(trans, u.bi_inum, iter->pos.snapshot);
                if (ret)
-                       bch_err(c, "error in fsck: error %i while deleting inode", ret);
+                       bch_err(c, "error in fsck: error while deleting inode: %s",
+                               bch2_err_str(ret));
                return ret;
        }
 
@@ -933,7 +935,8 @@ static int check_inode(struct btree_trans *trans,
                                POS(u.bi_inum, U64_MAX),
                                0, NULL);
                if (ret) {
-                       bch_err(c, "error in fsck: error %i truncating inode", ret);
+                       bch_err(c, "error in fsck: error truncating inode: %s",
+                               bch2_err_str(ret));
                        return ret;
                }
 
@@ -958,8 +961,8 @@ static int check_inode(struct btree_trans *trans,
 
                sectors = bch2_count_inode_sectors(trans, u.bi_inum, iter->pos.snapshot);
                if (sectors < 0) {
-                       bch_err(c, "error in fsck: error %i recounting inode sectors",
-                               (int) sectors);
+                       bch_err(c, "error in fsck: error recounting inode sectors: %s",
+                               bch2_err_str(sectors));
                        return sectors;
                }
 
@@ -978,13 +981,13 @@ static int check_inode(struct btree_trans *trans,
        if (do_update) {
                ret = __write_inode(trans, &u, iter->pos.snapshot);
                if (ret)
-                       bch_err(c, "error in fsck: error %i "
-                               "updating inode", ret);
+                       bch_err(c, "error in fsck: error updating inode: %s",
+                               bch2_err_str(ret));
        }
 err:
 fsck_err:
        if (ret)
-               bch_err(c, "error %i from check_inode()", ret);
+               bch_err(c, "error from check_inode(): %s", bch2_err_str(ret));
        return ret;
 }
 
@@ -1010,7 +1013,7 @@ static int check_inodes(struct bch_fs *c, bool full)
        bch2_trans_exit(&trans);
        snapshots_seen_exit(&s);
        if (ret)
-               bch_err(c, "error %i from check_inodes()", ret);
+               bch_err(c, "error from check_inodes(): %s", bch2_err_str(ret));
        return ret;
 }
 
@@ -1145,7 +1148,7 @@ static int check_i_sectors(struct btree_trans *trans, struct inode_walker *w)
        }
 fsck_err:
        if (ret)
-               bch_err(c, "error %i from check_i_sectors()", ret);
+               bch_err(c, "error from check_i_sectors(): %s", bch2_err_str(ret));
        return ret ?: ret2;
 }
 
@@ -1327,7 +1330,7 @@ static int check_extents(struct bch_fs *c)
        snapshots_seen_exit(&s);
 
        if (ret)
-               bch_err(c, "error %i from check_extents()", ret);
+               bch_err(c, "error from check_extents(): %s", bch2_err_str(ret));
        return ret;
 }
 
@@ -1366,7 +1369,7 @@ static int check_subdir_count(struct btree_trans *trans, struct inode_walker *w)
        }
 fsck_err:
        if (ret)
-               bch_err(c, "error %i from check_subdir_count()", ret);
+               bch_err(c, "error from check_subdir_count(): %s", bch2_err_str(ret));
        return ret ?: ret2;
 }
 
@@ -1485,7 +1488,7 @@ fsck_err:
        printbuf_exit(&buf);
 
        if (ret && ret != -EINTR)
-               bch_err(c, "error %i from check_target()", ret);
+               bch_err(c, "error from check_target(): %s", bch2_err_str(ret));
        return ret;
 }
 
@@ -1658,7 +1661,7 @@ fsck_err:
        printbuf_exit(&buf);
 
        if (ret && ret != -EINTR)
-               bch_err(c, "error %i from check_dirent()", ret);
+               bch_err(c, "error from check_dirent(): %s", bch2_err_str(ret));
        return ret;
 }
 
@@ -1697,7 +1700,7 @@ static int check_dirents(struct bch_fs *c)
        inode_walker_exit(&target);
 
        if (ret)
-               bch_err(c, "error %i from check_dirents()", ret);
+               bch_err(c, "error from check_dirents(): %s", bch2_err_str(ret));
        return ret;
 }
 
@@ -1733,7 +1736,7 @@ static int check_xattr(struct btree_trans *trans, struct btree_iter *iter,
        ret = hash_check_key(trans, bch2_xattr_hash_desc, hash_info, iter, k);
 fsck_err:
        if (ret && ret != -EINTR)
-               bch_err(c, "error %i from check_xattr()", ret);
+               bch_err(c, "error from check_xattr(): %s", bch2_err_str(ret));
        return ret;
 }
 
@@ -1765,7 +1768,7 @@ static int check_xattrs(struct bch_fs *c)
        bch2_trans_exit(&trans);
 
        if (ret)
-               bch_err(c, "error %i from check_xattrs()", ret);
+               bch_err(c, "error from check_xattrs(): %s", bch2_err_str(ret));
        return ret;
 }
 
@@ -1797,7 +1800,7 @@ static int check_root_trans(struct btree_trans *trans)
                                      BTREE_INSERT_LAZY_RW,
                        __bch2_btree_insert(trans, BTREE_ID_subvolumes, &root_subvol.k_i));
                if (ret) {
-                       bch_err(c, "error writing root subvol: %i", ret);
+                       bch_err(c, "error writing root subvol: %s", bch2_err_str(ret));
                        goto err;
                }
 
@@ -1816,7 +1819,7 @@ static int check_root_trans(struct btree_trans *trans)
 
                ret = __write_inode(trans, &root_inode, snapshot);
                if (ret)
-                       bch_err(c, "error writing root inode: %i", ret);
+                       bch_err(c, "error writing root inode: %s", bch2_err_str(ret));
        }
 err:
 fsck_err:
@@ -1969,7 +1972,7 @@ static int check_path(struct btree_trans *trans,
        }
 fsck_err:
        if (ret)
-               bch_err(c, "%s: err %i", __func__, ret);
+               bch_err(c, "%s: err %s", __func__, bch2_err_str(ret));
        return ret;
 }
 
index 873cc14e2ae9c0615407dac05f5db15edf1ca127..00d9e3a8e526a7451619bcf27907ccfcc343ca37 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "bcachefs.h"
 #include "btree_key_cache.h"
+#include "errcode.h"
 #include "error.h"
 #include "journal.h"
 #include "journal_io.h"
@@ -741,15 +742,17 @@ int bch2_journal_reclaim_start(struct journal *j)
 {
        struct bch_fs *c = container_of(j, struct bch_fs, journal);
        struct task_struct *p;
+       int ret;
 
        if (j->reclaim_thread)
                return 0;
 
        p = kthread_create(bch2_journal_reclaim_thread, j,
                           "bch-reclaim/%s", c->name);
-       if (IS_ERR(p)) {
-               bch_err(c, "error creating journal reclaim thread: %li", PTR_ERR(p));
-               return PTR_ERR(p);
+       ret = PTR_ERR_OR_ZERO(p);
+       if (ret) {
+               bch_err(c, "error creating journal reclaim thread: %s", bch2_err_str(ret));
+               return ret;
        }
 
        get_task_struct(p);
index be89628702f7399d7e75f3dfe65fd15cb63d912d..baeca0e2a30267b8f92c1bc00ed28516dba2e783 100644 (file)
@@ -8,6 +8,7 @@
 #include "btree_update.h"
 #include "btree_update_interior.h"
 #include "buckets.h"
+#include "errcode.h"
 #include "extents.h"
 #include "io.h"
 #include "journal.h"
@@ -151,7 +152,8 @@ retry:
                        }
 
                        if (ret) {
-                               bch_err(c, "Error updating btree node key: %i", ret);
+                               bch_err(c, "Error updating btree node key: %s",
+                                       bch2_err_str(ret));
                                break;
                        }
 next:
index 8b44d95c32ce32ed8f9e72e1c87a7659477ff90e..7fba0f70c4091dad5794ea91c212030dd6c582df 100644 (file)
@@ -8,6 +8,7 @@
 #include "btree_update_interior.h"
 #include "disk_groups.h"
 #include "ec.h"
+#include "errcode.h"
 #include "inode.h"
 #include "io.h"
 #include "journal_reclaim.h"
@@ -564,7 +565,7 @@ next:
        bch2_trans_exit(&trans);
 
        if (ret)
-               bch_err(c, "error %i in bch2_move_btree", ret);
+               bch_err(c, "error in %s(): %s", __func__, bch2_err_str(ret));
 
        bch2_btree_interior_updates_flush(c);
 
index 49fb405c143048fe42f7fdf04e2d3a07b62b9b72..438ea22ad5bdcb3918f03e42e6727b7d7d1325b4 100644 (file)
@@ -13,6 +13,7 @@
 #include "buckets.h"
 #include "clock.h"
 #include "disk_groups.h"
+#include "errcode.h"
 #include "error.h"
 #include "extents.h"
 #include "eytzinger.h"
@@ -319,7 +320,7 @@ static int bch2_copygc(struct bch_fs *c)
                             false,
                             copygc_pred, NULL);
        if (ret < 0)
-               bch_err(c, "error %i from bch2_move_data() in copygc", ret);
+               bch_err(c, "error from bch2_move_data() in copygc: %s", bch2_err_str(ret));
        if (ret)
                return ret;
 
@@ -427,6 +428,7 @@ void bch2_copygc_stop(struct bch_fs *c)
 int bch2_copygc_start(struct bch_fs *c)
 {
        struct task_struct *t;
+       int ret;
 
        if (c->copygc_thread)
                return 0;
@@ -438,9 +440,10 @@ int bch2_copygc_start(struct bch_fs *c)
                return -ENOMEM;
 
        t = kthread_create(bch2_copygc_thread, c, "bch-copygc/%s", c->name);
-       if (IS_ERR(t)) {
-               bch_err(c, "error creating copygc thread: %li", PTR_ERR(t));
-               return PTR_ERR(t);
+       ret = PTR_ERR_OR_ZERO(t);
+       if (ret) {
+               bch_err(c, "error creating copygc thread: %s", bch2_err_str(ret));
+               return ret;
        }
 
        get_task_struct(t);
index 42c831da70be6956742020ab37ae7a63d150a616..454c76e03be90484ebb68c5cbb55b2537ae1429f 100644 (file)
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "bcachefs.h"
 #include "btree_update.h"
+#include "errcode.h"
 #include "inode.h"
 #include "quota.h"
 #include "subvolume.h"
@@ -488,7 +489,7 @@ int bch2_fs_quota_read(struct bch_fs *c)
                        POS_MIN, BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k,
                bch2_fs_quota_read_inode(&trans, &iter, k));
        if (ret)
-               bch_err(c, "err in quota_read: %i", ret);
+               bch_err(c, "err in quota_read: %s", bch2_err_str(ret));
 
        bch2_trans_exit(&trans);
        return ret;
index 1de8183ea295e42be16f9c87614bfec86d1661ce..6b9ccc1b3fe3943be17c949593bd7d316ab2a65c 100644 (file)
@@ -6,6 +6,7 @@
 #include "buckets.h"
 #include "clock.h"
 #include "disk_groups.h"
+#include "errcode.h"
 #include "extents.h"
 #include "io.h"
 #include "move.h"
@@ -332,6 +333,7 @@ void bch2_rebalance_stop(struct bch_fs *c)
 int bch2_rebalance_start(struct bch_fs *c)
 {
        struct task_struct *p;
+       int ret;
 
        if (c->rebalance.thread)
                return 0;
@@ -340,9 +342,10 @@ int bch2_rebalance_start(struct bch_fs *c)
                return 0;
 
        p = kthread_create(bch2_rebalance_thread, c, "bch-rebalance/%s", c->name);
-       if (IS_ERR(p)) {
-               bch_err(c, "error creating rebalance thread: %li", PTR_ERR(p));
-               return PTR_ERR(p);
+       ret = PTR_ERR_OR_ZERO(p);
+       if (ret) {
+               bch_err(c, "error creating rebalance thread: %s", bch2_err_str(ret));
+               return ret;
        }
 
        get_task_struct(p);
index 7fb470e2e7f3da120b4dd5d882a4ea4df5999739..bb04b6f053ccfbaaa7f624fd3948e0b14c5c46ad 100644 (file)
@@ -10,6 +10,7 @@
 #include "buckets.h"
 #include "dirent.h"
 #include "ec.h"
+#include "errcode.h"
 #include "error.h"
 #include "fs-common.h"
 #include "fsck.h"
@@ -1419,9 +1420,9 @@ out:
        }
 
        if (ret)
-               bch_err(c, "Error in recovery: %s (%i)", err, ret);
+               bch_err(c, "Error in recovery: %s (%s)", err, bch2_err_str(ret));
        else
-               bch_verbose(c, "ret %i", ret);
+               bch_verbose(c, "ret %s", bch2_err_str(ret));
        return ret;
 err:
 fsck_err:
index 76be8735c700ff8839880bd42a700f205357310a..0469b90064ebbf9aebeeffecaf85c881a4848325 100644 (file)
@@ -3,6 +3,7 @@
 #include "bcachefs.h"
 #include "btree_key_cache.h"
 #include "btree_update.h"
+#include "errcode.h"
 #include "error.h"
 #include "fs.h"
 #include "subvolume.h"
@@ -315,8 +316,8 @@ static int check_subvol(struct btree_trans *trans,
        if (BCH_SUBVOLUME_UNLINKED(subvol.v)) {
                ret = bch2_subvolume_delete(trans, iter->pos.offset);
                if (ret && ret != -EINTR)
-                       bch_err(trans->c, "error deleting subvolume %llu: %i",
-                               iter->pos.offset, ret);
+                       bch_err(trans->c, "error deleting subvolume %llu: %s",
+                               iter->pos.offset, bch2_err_str(ret));
                if (ret)
                        return ret;
        }
@@ -365,7 +366,7 @@ int bch2_fs_snapshots_start(struct bch_fs *c)
        bch2_trans_exit(&trans);
 
        if (ret)
-               bch_err(c, "error starting snapshots: %i", ret);
+               bch_err(c, "error starting snapshots: %s", bch2_err_str(ret));
        return ret;
 }
 
@@ -647,7 +648,7 @@ int bch2_delete_dead_snapshots(struct bch_fs *c)
        if (!test_bit(BCH_FS_STARTED, &c->flags)) {
                ret = bch2_fs_read_write_early(c);
                if (ret) {
-                       bch_err(c, "error deleleting dead snapshots: error going rw: %i", ret);
+                       bch_err(c, "error deleleting dead snapshots: error going rw: %s", bch2_err_str(ret));
                        return ret;
                }
        }
@@ -663,7 +664,7 @@ int bch2_delete_dead_snapshots(struct bch_fs *c)
                        NULL, NULL, 0,
                bch2_delete_redundant_snapshot(&trans, &iter, k));
        if (ret) {
-               bch_err(c, "error deleting redundant snapshots: %i", ret);
+               bch_err(c, "error deleting redundant snapshots: %s", bch2_err_str(ret));
                goto err;
        }
 
@@ -671,7 +672,7 @@ int bch2_delete_dead_snapshots(struct bch_fs *c)
                           POS_MIN, 0, k,
                bch2_snapshot_set_equiv(&trans, k));
        if (ret) {
-               bch_err(c, "error in bch2_snapshots_set_equiv: %i", ret);
+               bch_err(c, "error in bch2_snapshots_set_equiv: %s", bch2_err_str(ret));
                goto err;
        }
 
@@ -690,7 +691,7 @@ int bch2_delete_dead_snapshots(struct bch_fs *c)
        bch2_trans_iter_exit(&trans, &iter);
 
        if (ret) {
-               bch_err(c, "error walking snapshots: %i", ret);
+               bch_err(c, "error walking snapshots: %s", bch2_err_str(ret));
                goto err;
        }
 
@@ -710,7 +711,7 @@ int bch2_delete_dead_snapshots(struct bch_fs *c)
                darray_exit(&equiv_seen);
 
                if (ret) {
-                       bch_err(c, "error deleting snapshot keys: %i", ret);
+                       bch_err(c, "error deleting snapshot keys: %s", bch2_err_str(ret));
                        goto err;
                }
        }
@@ -719,8 +720,8 @@ int bch2_delete_dead_snapshots(struct bch_fs *c)
                ret = commit_do(&trans, NULL, NULL, 0,
                        bch2_snapshot_node_delete(&trans, deleted.data[i]));
                if (ret) {
-                       bch_err(c, "error deleting snapshot %u: %i",
-                               deleted.data[i], ret);
+                       bch_err(c, "error deleting snapshot %u: %s",
+                               deleted.data[i], bch2_err_str(ret));
                        goto err;
                }
        }
@@ -912,7 +913,7 @@ void bch2_subvolume_wait_for_pagecache_and_delete(struct work_struct *work)
                        ret = bch2_trans_do(c, NULL, NULL, BTREE_INSERT_NOFAIL,
                                      bch2_subvolume_delete(&trans, *id));
                        if (ret) {
-                               bch_err(c, "error %i deleting subvolume %u", ret, *id);
+                               bch_err(c, "error deleting subvolume %u: %s", *id, bch2_err_str(ret));
                                break;
                        }
                }
index b926fb1b14a9a4cf6978042d9165ee8c9b7603af..87742962d6c2948ef1d0297465c27fe3743d6002 100644 (file)
@@ -25,6 +25,7 @@
 #include "debug.h"
 #include "disk_groups.h"
 #include "ec.h"
+#include "errcode.h"
 #include "error.h"
 #include "fs.h"
 #include "fs-io.h"
@@ -1430,7 +1431,7 @@ static int bch2_dev_remove_alloc(struct bch_fs *c, struct bch_dev *ca)
                bch2_btree_delete_range(c, BTREE_ID_alloc, start, end,
                                        BTREE_TRIGGER_NORUN, NULL);
        if (ret)
-               bch_err(c, "error %i removing dev alloc info", ret);
+               bch_err(c, "error removing dev alloc info: %s", bch2_err_str(ret));
 
        return ret;
 }
@@ -1458,7 +1459,7 @@ int bch2_dev_remove(struct bch_fs *c, struct bch_dev *ca, int flags)
 
        ret = bch2_dev_data_drop(c, ca->dev_idx, flags);
        if (ret) {
-               bch_err(ca, "Remove failed: error %i dropping data", ret);
+               bch_err(ca, "Remove failed: error dropping data: %s", bch2_err_str(ret));
                goto err;
        }
 
@@ -1470,7 +1471,7 @@ int bch2_dev_remove(struct bch_fs *c, struct bch_dev *ca, int flags)
 
        ret = bch2_journal_flush_device_pins(&c->journal, ca->dev_idx);
        if (ret) {
-               bch_err(ca, "Remove failed: error %i flushing journal", ret);
+               bch_err(ca, "Remove failed: error flushing journal: %s", bch2_err_str(ret));
                goto err;
        }
 
@@ -1482,7 +1483,7 @@ int bch2_dev_remove(struct bch_fs *c, struct bch_dev *ca, int flags)
 
        ret = bch2_replicas_gc2(c);
        if (ret) {
-               bch_err(ca, "Remove failed: error %i from replicas gc", ret);
+               bch_err(ca, "Remove failed: error from replicas gc: %s", bch2_err_str(ret));
                goto err;
        }
 
@@ -1546,7 +1547,7 @@ int bch2_dev_add(struct bch_fs *c, const char *path)
 
        ret = bch2_read_super(path, &opts, &sb);
        if (ret) {
-               bch_err(c, "device add error: error reading super: %i", ret);
+               bch_err(c, "device add error: error reading super: %s", bch2_err_str(ret));
                goto err;
        }
 
@@ -1639,13 +1640,13 @@ have_slot:
 
        ret = bch2_trans_mark_dev_sb(c, ca);
        if (ret) {
-               bch_err(c, "device add error: error marking new superblock: %i", ret);
+               bch_err(c, "device add error: error marking new superblock: %s", bch2_err_str(ret));
                goto err_late;
        }
 
        ret = bch2_fs_freespace_init(c);
        if (ret) {
-               bch_err(c, "device add error: error initializing free space: %i", ret);
+               bch_err(c, "device add error: error initializing free space: %s", bch2_err_str(ret));
                goto err_late;
        }
 
@@ -1707,8 +1708,8 @@ int bch2_dev_online(struct bch_fs *c, const char *path)
 
        ret = bch2_trans_mark_dev_sb(c, ca);
        if (ret) {
-               bch_err(c, "error bringing %s online: error %i from bch2_trans_mark_dev_sb",
-                       path, ret);
+               bch_err(c, "error bringing %s online: error from bch2_trans_mark_dev_sb: %s",
+                       path, bch2_err_str(ret));
                goto err;
        }
 
@@ -1777,7 +1778,7 @@ int bch2_dev_resize(struct bch_fs *c, struct bch_dev *ca, u64 nbuckets)
 
        ret = bch2_dev_buckets_resize(c, ca, nbuckets);
        if (ret) {
-               bch_err(ca, "Resize error: %i", ret);
+               bch_err(ca, "Resize error: %s", bch2_err_str(ret));
                goto err;
        }
 
index bfcb133ff483072b749b6a407eafdd8de0b6f2b6..bf0a33c0233d5d229810749b81016dd9e0f07471 100644 (file)
@@ -46,7 +46,7 @@ static int test_delete(struct bch_fs *c, u64 nr)
                bch2_btree_iter_traverse(&iter) ?:
                bch2_trans_update(&trans, &iter, &k.k_i, 0));
        if (ret) {
-               bch_err(c, "update error in test_delete: %i", ret);
+               bch_err(c, "update error in test_delete: %s", bch2_err_str(ret));
                goto err;
        }
 
@@ -55,7 +55,7 @@ static int test_delete(struct bch_fs *c, u64 nr)
                bch2_btree_iter_traverse(&iter) ?:
                bch2_btree_delete_at(&trans, &iter, 0));
        if (ret) {
-               bch_err(c, "delete error (first) in test_delete: %i", ret);
+               bch_err(c, "delete error (first) in test_delete: %s", bch2_err_str(ret));
                goto err;
        }
 
@@ -64,7 +64,7 @@ static int test_delete(struct bch_fs *c, u64 nr)
                bch2_btree_iter_traverse(&iter) ?:
                bch2_btree_delete_at(&trans, &iter, 0));
        if (ret) {
-               bch_err(c, "delete error (second) in test_delete: %i", ret);
+               bch_err(c, "delete error (second) in test_delete: %s", bch2_err_str(ret));
                goto err;
        }
 err:
@@ -92,7 +92,7 @@ static int test_delete_written(struct bch_fs *c, u64 nr)
                bch2_btree_iter_traverse(&iter) ?:
                bch2_trans_update(&trans, &iter, &k.k_i, 0));
        if (ret) {
-               bch_err(c, "update error in test_delete_written: %i", ret);
+               bch_err(c, "update error in test_delete_written: %s", bch2_err_str(ret));
                goto err;
        }
 
@@ -103,7 +103,7 @@ static int test_delete_written(struct bch_fs *c, u64 nr)
                bch2_btree_iter_traverse(&iter) ?:
                bch2_btree_delete_at(&trans, &iter, 0));
        if (ret) {
-               bch_err(c, "delete error in test_delete_written: %i", ret);
+               bch_err(c, "delete error in test_delete_written: %s", bch2_err_str(ret));
                goto err;
        }
 err:
@@ -136,7 +136,7 @@ static int test_iterate(struct bch_fs *c, u64 nr)
                ret = bch2_btree_insert(c, BTREE_ID_xattrs, &k.k_i,
                                        NULL, NULL, 0);
                if (ret) {
-                       bch_err(c, "insert error in test_iterate: %i", ret);
+                       bch_err(c, "insert error in test_iterate: %s", bch2_err_str(ret));
                        goto err;
                }
        }
@@ -192,7 +192,7 @@ static int test_iterate_extents(struct bch_fs *c, u64 nr)
                ret = bch2_btree_insert(c, BTREE_ID_extents, &k.k_i,
                                        NULL, NULL, 0);
                if (ret) {
-                       bch_err(c, "insert error in test_iterate_extents: %i", ret);
+                       bch_err(c, "insert error in test_iterate_extents: %s", bch2_err_str(ret));
                        goto err;
                }
        }
@@ -247,7 +247,7 @@ static int test_iterate_slots(struct bch_fs *c, u64 nr)
                ret = bch2_btree_insert(c, BTREE_ID_xattrs, &k.k_i,
                                        NULL, NULL, 0);
                if (ret) {
-                       bch_err(c, "insert error in test_iterate_slots: %i", ret);
+                       bch_err(c, "insert error in test_iterate_slots: %s", bch2_err_str(ret));
                        goto err;
                }
        }
@@ -313,7 +313,7 @@ static int test_iterate_slots_extents(struct bch_fs *c, u64 nr)
                ret = bch2_btree_insert(c, BTREE_ID_extents, &k.k_i,
                                        NULL, NULL, 0);
                if (ret) {
-                       bch_err(c, "insert error in test_iterate_slots_extents: %i", ret);
+                       bch_err(c, "insert error in test_iterate_slots_extents: %s", bch2_err_str(ret));
                        goto err;
                }
        }
@@ -419,7 +419,7 @@ static int insert_test_extent(struct bch_fs *c,
        ret = bch2_btree_insert(c, BTREE_ID_extents, &k.k_i,
                                NULL, NULL, 0);
        if (ret)
-               bch_err(c, "insert error in insert_test_extent: %i", ret);
+               bch_err(c, "insert error in insert_test_extent: %s", bch2_err_str(ret));
        return ret;
 }
 
@@ -518,7 +518,7 @@ static int test_snapshots(struct bch_fs *c, u64 nr)
 
        ret = test_snapshot_filter(c, snapids[0], snapids[1]);
        if (ret) {
-               bch_err(c, "err %i from test_snapshot_filter", ret);
+               bch_err(c, "err from test_snapshot_filter: %s", bch2_err_str(ret));
                return ret;
        }
 
@@ -555,7 +555,7 @@ static int rand_insert(struct bch_fs *c, u64 nr)
                ret = commit_do(&trans, NULL, NULL, 0,
                        __bch2_btree_insert(&trans, BTREE_ID_xattrs, &k.k_i));
                if (ret) {
-                       bch_err(c, "error in rand_insert: %i", ret);
+                       bch_err(c, "error in rand_insert: %s", bch2_err_str(ret));
                        break;
                }
        }
@@ -591,7 +591,7 @@ static int rand_insert_multi(struct bch_fs *c, u64 nr)
                        __bch2_btree_insert(&trans, BTREE_ID_xattrs, &k[6].k_i) ?:
                        __bch2_btree_insert(&trans, BTREE_ID_xattrs, &k[7].k_i));
                if (ret) {
-                       bch_err(c, "error in rand_insert_multi: %i", ret);
+                       bch_err(c, "error in rand_insert_multi: %s", bch2_err_str(ret));
                        break;
                }
        }
@@ -618,7 +618,7 @@ static int rand_lookup(struct bch_fs *c, u64 nr)
                k = bch2_btree_iter_peek(&iter);
                ret = bkey_err(k);
                if (ret) {
-                       bch_err(c, "error in rand_lookup: %i", ret);
+                       bch_err(c, "error in rand_lookup: %s", bch2_err_str(ret));
                        break;
                }
        }
@@ -641,7 +641,7 @@ static int rand_mixed_trans(struct btree_trans *trans,
        k = bch2_btree_iter_peek(iter);
        ret = bkey_err(k);
        if (ret && ret != -EINTR)
-               bch_err(trans->c, "lookup error in rand_mixed: %i", ret);
+               bch_err(trans->c, "lookup error in rand_mixed: %s", bch2_err_str(ret));
        if (ret)
                return ret;
 
@@ -671,7 +671,7 @@ static int rand_mixed(struct bch_fs *c, u64 nr)
                ret = commit_do(&trans, NULL, NULL, 0,
                        rand_mixed_trans(&trans, &iter, &cookie, i, rand));
                if (ret) {
-                       bch_err(c, "update error in rand_mixed: %i", ret);
+                       bch_err(c, "update error in rand_mixed: %s", bch2_err_str(ret));
                        break;
                }
        }
@@ -717,7 +717,7 @@ static int rand_delete(struct bch_fs *c, u64 nr)
                ret = commit_do(&trans, NULL, NULL, 0,
                        __do_delete(&trans, pos));
                if (ret) {
-                       bch_err(c, "error in rand_delete: %i", ret);
+                       bch_err(c, "error in rand_delete: %s", bch2_err_str(ret));
                        break;
                }
        }
@@ -747,7 +747,7 @@ static int seq_insert(struct bch_fs *c, u64 nr)
                        bch2_btree_iter_traverse(&iter) ?:
                        bch2_trans_update(&trans, &iter, &insert.k_i, 0));
                if (ret) {
-                       bch_err(c, "error in seq_insert: %i", ret);
+                       bch_err(c, "error in seq_insert: %s", bch2_err_str(ret));
                        break;
                }
 
@@ -798,7 +798,7 @@ static int seq_overwrite(struct bch_fs *c, u64 nr)
                        bch2_btree_iter_traverse(&iter) ?:
                        bch2_trans_update(&trans, &iter, &u.k_i, 0));
                if (ret) {
-                       bch_err(c, "error in seq_overwrite: %i", ret);
+                       bch_err(c, "error in seq_overwrite: %s", bch2_err_str(ret));
                        break;
                }
        }
@@ -816,7 +816,7 @@ static int seq_delete(struct bch_fs *c, u64 nr)
                                      SPOS(0, 0, U32_MAX), SPOS_MAX,
                                      0, NULL);
        if (ret)
-               bch_err(c, "error in seq_delete: %i", ret);
+               bch_err(c, "error in seq_delete: %s", bch2_err_str(ret));
        return ret;
 }
 
@@ -853,7 +853,7 @@ static int btree_perf_test_thread(void *data)
 
        ret = j->fn(j->c, div64_u64(j->nr, j->nr_threads));
        if (ret) {
-               bch_err(j->c, "%ps: error %i", j->fn, ret);
+               bch_err(j->c, "%ps: error %s", j->fn, bch2_err_str(ret));
                j->ret = ret;
        }