]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/super.c
Update bcachefs sources to 90a9c61e2b bcachefs: Switch bch2_btree_delete_range()...
[bcachefs-tools-debian] / libbcachefs / super.c
index 2908974034ca0babfc12c049277af9b2cc58ef3c..7c6348001ae3904478bc0bb5dc4fc52a19b48f86 100644 (file)
@@ -24,6 +24,7 @@
 #include "debug.h"
 #include "disk_groups.h"
 #include "ec.h"
+#include "errcode.h"
 #include "error.h"
 #include "fs.h"
 #include "fs-io.h"
@@ -930,31 +931,10 @@ out:
        up_write(&c->state_lock);
        return ret;
 err:
-       switch (ret) {
-       case BCH_FSCK_ERRORS_NOT_FIXED:
-               bch_err(c, "filesystem contains errors: please report this to the developers");
-               pr_cont("mount with -o fix_errors to repair\n");
-               break;
-       case BCH_FSCK_REPAIR_UNIMPLEMENTED:
-               bch_err(c, "filesystem contains errors: please report this to the developers");
-               pr_cont("repair unimplemented: inform the developers so that it can be added\n");
-               break;
-       case BCH_FSCK_REPAIR_IMPOSSIBLE:
-               bch_err(c, "filesystem contains errors, but repair impossible");
-               break;
-       case BCH_FSCK_UNKNOWN_VERSION:
-               bch_err(c, "unknown metadata version");
-               break;
-       case -ENOMEM:
-               bch_err(c, "cannot allocate memory");
-               break;
-       case -EIO:
-               bch_err(c, "IO error");
-               break;
-       }
+       bch_err(c, "error starting filesystem: %s", bch2_err_str(ret));
 
-       if (ret >= 0)
-               ret = -EIO;
+       if (ret < -BCH_ERR_START)
+               ret = -EINVAL;
        goto out;
 }
 
@@ -1438,7 +1418,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;
 }
@@ -1466,7 +1446,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;
        }
 
@@ -1478,7 +1458,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;
        }
 
@@ -1490,7 +1470,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;
        }
 
@@ -1554,7 +1534,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;
        }
 
@@ -1647,13 +1627,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;
        }
 
@@ -1715,8 +1695,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;
        }
 
@@ -1785,7 +1765,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;
        }