mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-01 10:45:49 +00:00
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>
This commit is contained in:
parent
e9a1da9737
commit
858536c7ce
@ -1222,9 +1222,6 @@ int bch2_alloc_sectors_start_trans(struct btree_trans *trans,
|
||||
? -EAGAIN
|
||||
: -BCH_ERR_ENOSPC_bucket_alloc;
|
||||
|
||||
if (bch2_err_matches(ret, BCH_ERR_insufficient_devices))
|
||||
return -EROFS;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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) \
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -363,7 +363,7 @@ static int __journal_res_get(struct journal *j, struct journal_res *res,
|
||||
return 0;
|
||||
|
||||
if (bch2_journal_error(j))
|
||||
return -EROFS;
|
||||
return -BCH_ERR_erofs_journal_err;
|
||||
|
||||
spin_lock(&j->lock);
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user