summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-12-11 20:37:11 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2022-12-13 18:24:57 -0500
commitae170372cc80eca67a78160317243f730b93c270 (patch)
tree2d4b3d0b8ad8f5e5b29d164257b3484a9a071619
parent9a3457e6b0e38f3414f9e16905a17a85940bee09 (diff)
bcachefs: Convert EROFS errors to private error codes
More error code improvements - this gets us more useful error messages. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/alloc_foreground.c3
-rw-r--r--fs/bcachefs/btree_gc.c4
-rw-r--r--fs/bcachefs/btree_update_leaf.c2
-rw-r--r--fs/bcachefs/ec.c2
-rw-r--r--fs/bcachefs/errcode.h6
-rw-r--r--fs/bcachefs/io.c2
-rw-r--r--fs/bcachefs/journal.c2
-rw-r--r--fs/bcachefs/move.c2
-rw-r--r--fs/bcachefs/movinggc.c2
-rw-r--r--fs/bcachefs/recovery.c4
-rw-r--r--fs/bcachefs/reflink.c2
-rw-r--r--fs/bcachefs/super-io.c4
12 files changed, 18 insertions, 17 deletions
diff --git a/fs/bcachefs/alloc_foreground.c b/fs/bcachefs/alloc_foreground.c
index 46f215c8bced..634ae1bba41a 100644
--- a/fs/bcachefs/alloc_foreground.c
+++ b/fs/bcachefs/alloc_foreground.c
@@ -1227,9 +1227,6 @@ err:
? -EAGAIN
: -BCH_ERR_ENOSPC_bucket_alloc;
- if (bch2_err_matches(ret, BCH_ERR_insufficient_devices))
- return -EROFS;
-
return ret;
}
diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c
index 055987a2a6a6..067d44b9164d 100644
--- a/fs/bcachefs/btree_gc.c
+++ b/fs/bcachefs/btree_gc.c
@@ -1975,7 +1975,7 @@ int bch2_gc_gens(struct bch_fs *c)
NULL, NULL,
BTREE_INSERT_NOFAIL,
gc_btree_gens_key(&trans, &iter, k));
- if (ret && ret != -EROFS)
+ if (ret && !bch2_err_matches(ret, EROFS))
bch_err(c, "error recalculating oldest_gen: %s", bch2_err_str(ret));
if (ret)
goto err;
@@ -1988,7 +1988,7 @@ int bch2_gc_gens(struct bch_fs *c)
NULL, NULL,
BTREE_INSERT_NOFAIL,
bch2_alloc_write_oldest_gen(&trans, &iter, k));
- if (ret && ret != -EROFS)
+ if (ret && !bch2_err_matches(ret, EROFS))
bch_err(c, "error writing oldest_gen: %s", bch2_err_str(ret));
if (ret)
goto err;
diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c
index dfaa1a8cf13d..3143e2f5bbb2 100644
--- a/fs/bcachefs/btree_update_leaf.c
+++ b/fs/bcachefs/btree_update_leaf.c
@@ -968,7 +968,7 @@ bch2_trans_commit_get_rw_cold(struct btree_trans *trans)
if (likely(!(trans->flags & BTREE_INSERT_LAZY_RW)) ||
test_bit(BCH_FS_STARTED, &c->flags))
- return -EROFS;
+ return -BCH_ERR_erofs_trans_commit;
bch2_trans_unlock(trans);
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c
index 53f0d8209a27..c234c8d5d6a3 100644
--- a/fs/bcachefs/ec.c
+++ b/fs/bcachefs/ec.c
@@ -942,7 +942,7 @@ static void ec_stripe_create(struct ec_stripe_new *s)
closure_sync(&s->iodone);
if (s->err) {
- if (s->err != -EROFS)
+ if (!bch2_err_matches(s->err, EROFS))
bch_err(c, "error creating stripe: error writing data buckets");
goto err;
}
diff --git a/fs/bcachefs/errcode.h b/fs/bcachefs/errcode.h
index 1ab4c4c564eb..a1e39987fec1 100644
--- a/fs/bcachefs/errcode.h
+++ b/fs/bcachefs/errcode.h
@@ -20,7 +20,6 @@
x(0, open_buckets_empty) \
x(0, freelist_empty) \
x(BCH_ERR_freelist_empty, no_buckets_found) \
- x(0, insufficient_devices) \
x(0, transaction_restart) \
x(BCH_ERR_transaction_restart, transaction_restart_fault_inject) \
x(BCH_ERR_transaction_restart, transaction_restart_relock) \
@@ -81,6 +80,11 @@
x(EINVAL, device_already_online) \
x(EINVAL, insufficient_devices_to_start) \
x(EINVAL, invalid) \
+ x(EROFS, erofs_trans_commit) \
+ x(EROFS, erofs_no_writes) \
+ x(EROFS, erofs_journal_err) \
+ x(EROFS, erofs_sb_err) \
+ x(EROFS, insufficient_devices) \
x(BCH_ERR_invalid, invalid_sb) \
x(BCH_ERR_invalid_sb, invalid_sb_magic) \
x(BCH_ERR_invalid_sb, invalid_sb_version) \
diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c
index f0fca861b901..afef49cd9dd0 100644
--- a/fs/bcachefs/io.c
+++ b/fs/bcachefs/io.c
@@ -1775,7 +1775,7 @@ void bch2_write(struct closure *cl)
if (c->opts.nochanges ||
!percpu_ref_tryget_live(&c->writes)) {
- op->error = -EROFS;
+ op->error = -BCH_ERR_erofs_no_writes;
goto err;
}
diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c
index 95c29229d3fe..010052742c06 100644
--- a/fs/bcachefs/journal.c
+++ b/fs/bcachefs/journal.c
@@ -353,7 +353,7 @@ retry:
return 0;
if (bch2_journal_error(j))
- return -EROFS;
+ return -BCH_ERR_erofs_journal_err;
spin_lock(&j->lock);
diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c
index 433a809566c7..b308354aa5e3 100644
--- a/fs/bcachefs/move.c
+++ b/fs/bcachefs/move.c
@@ -258,7 +258,7 @@ static int bch2_move_extent(struct btree_trans *trans,
}
if (!percpu_ref_tryget_live(&c->writes))
- return -EROFS;
+ return -BCH_ERR_erofs_no_writes;
/*
* Before memory allocations & taking nocow locks in
diff --git a/fs/bcachefs/movinggc.c b/fs/bcachefs/movinggc.c
index fbc8043e0bf9..f0ab65ffab73 100644
--- a/fs/bcachefs/movinggc.c
+++ b/fs/bcachefs/movinggc.c
@@ -163,7 +163,7 @@ static int bch2_copygc(struct bch_fs *c)
bch2_moving_ctxt_exit(&ctxt);
- if (ret < 0 && ret != -EROFS)
+ if (ret < 0 && !bch2_err_matches(ret, EROFS))
bch_err(c, "error from bch2_move_data() in copygc: %s", bch2_err_str(ret));
trace_and_count(c, copygc, c, atomic64_read(&move_stats.sectors_moved), 0, 0, 0);
diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c
index 069aafba48ac..aec98a98a39a 100644
--- a/fs/bcachefs/recovery.c
+++ b/fs/bcachefs/recovery.c
@@ -625,8 +625,8 @@ static int bch2_journal_replay(struct bch_fs *c)
: 0),
bch2_journal_replay_key(&trans, k));
if (ret) {
- bch_err(c, "journal replay: error %d while replaying key at btree %s level %u",
- ret, bch2_btree_ids[k->btree_id], k->level);
+ bch_err(c, "journal replay: error while replaying key at btree %s level %u: %s",
+ bch2_btree_ids[k->btree_id], k->level, bch2_err_str(ret));
goto err;
}
}
diff --git a/fs/bcachefs/reflink.c b/fs/bcachefs/reflink.c
index ec672fedbd16..e89a9a1abe9f 100644
--- a/fs/bcachefs/reflink.c
+++ b/fs/bcachefs/reflink.c
@@ -283,7 +283,7 @@ s64 bch2_remap_range(struct bch_fs *c,
int ret = 0, ret2 = 0;
if (!percpu_ref_tryget_live(&c->writes))
- return -EROFS;
+ return -BCH_ERR_erofs_no_writes;
bch2_check_set_feature(c, BCH_FEATURE_reflink);
diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c
index c4020cb9d6eb..738b68b5d35c 100644
--- a/fs/bcachefs/super-io.c
+++ b/fs/bcachefs/super-io.c
@@ -863,7 +863,7 @@ int bch2_write_super(struct bch_fs *c)
le64_to_cpu(ca->sb_read_scratch->seq),
ca->disk_sb.seq);
percpu_ref_put(&ca->io_ref);
- ret = -EROFS;
+ ret = -BCH_ERR_erofs_sb_err;
goto out;
}
@@ -873,7 +873,7 @@ int bch2_write_super(struct bch_fs *c)
le64_to_cpu(ca->sb_read_scratch->seq),
ca->disk_sb.seq);
percpu_ref_put(&ca->io_ref);
- ret = -EROFS;
+ ret = -BCH_ERR_erofs_sb_err;
goto out;
}
}