diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-12-12 04:37:11 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:09:49 +0300 |
commit | 858536c7cea8bb86511501768ef797d103642498 (patch) | |
tree | b19f4933c893bb2208478f55b7c169d2cb6c8ff8 | |
parent | e9a1da97377f89f09e6b0b484554fe7a0e2dbe3e (diff) | |
download | linux-858536c7cea8bb86511501768ef797d103642498.tar.xz |
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.c | 3 | ||||
-rw-r--r-- | fs/bcachefs/btree_gc.c | 4 | ||||
-rw-r--r-- | fs/bcachefs/btree_update_leaf.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/ec.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/errcode.h | 6 | ||||
-rw-r--r-- | fs/bcachefs/io.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/journal.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/move.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/movinggc.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/recovery.c | 4 | ||||
-rw-r--r-- | fs/bcachefs/reflink.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/super-io.c | 4 |
12 files changed, 18 insertions, 17 deletions
diff --git a/fs/bcachefs/alloc_foreground.c b/fs/bcachefs/alloc_foreground.c index dd47eeb1efc5..c4aee0022fab 100644 --- a/fs/bcachefs/alloc_foreground.c +++ b/fs/bcachefs/alloc_foreground.c @@ -1222,9 +1222,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 fdc9de6e9908..e43ccf896e8e 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -1988,7 +1988,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; @@ -2001,7 +2001,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 7a95649dd71e..f44abb3fe469 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -990,7 +990,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 65da4a185bbb..0d33dee1aed4 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -891,7 +891,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 5f0f75726784..96ee72c125d6 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) \ @@ -80,6 +79,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 27265ba35fac..44f3719d4b71 100644 --- a/fs/bcachefs/io.c +++ b/fs/bcachefs/io.c @@ -1417,7 +1417,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 c7a7b9cd20f0..9daa99f3732a 100644 --- a/fs/bcachefs/journal.c +++ b/fs/bcachefs/journal.c @@ -363,7 +363,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 4d6fd3025e40..848a415b6797 100644 --- a/fs/bcachefs/move.c +++ b/fs/bcachefs/move.c @@ -251,7 +251,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; /* write path might have to decompress data: */ bkey_for_each_ptr_decode(k.k, ptrs, p, entry) diff --git a/fs/bcachefs/movinggc.c b/fs/bcachefs/movinggc.c index 66f18f711d53..9c55a88a2b08 100644 --- a/fs/bcachefs/movinggc.c +++ b/fs/bcachefs/movinggc.c @@ -319,7 +319,7 @@ static int bch2_copygc(struct bch_fs *c) writepoint_ptr(&c->copygc_write_point), false, copygc_pred, NULL); - 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)); if (ret) return ret; diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index d054e83d86ef..80736be21b9f 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -631,8 +631,8 @@ static int bch2_journal_replay(struct bch_fs *c, u64 start_seq, u64 end_seq) : 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 8c426d6440c9..08c98ac03c13 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 8dfe92d7eb77..ff27ae1839a8 100644 --- a/fs/bcachefs/super-io.c +++ b/fs/bcachefs/super-io.c @@ -868,7 +868,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; } @@ -878,7 +878,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; } } |