More error code improvements - this gets us more useful error messages.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
? -EAGAIN
: -BCH_ERR_ENOSPC_bucket_alloc;
- if (bch2_err_matches(ret, BCH_ERR_insufficient_devices))
- return -EROFS;
-
return ret;
}
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;
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;
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);
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;
}
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) \
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) \
if (c->opts.nochanges ||
!percpu_ref_tryget_live(&c->writes)) {
- op->error = -EROFS;
+ op->error = -BCH_ERR_erofs_no_writes;
goto err;
}
return 0;
if (bch2_journal_error(j))
- return -EROFS;
+ return -BCH_ERR_erofs_journal_err;
spin_lock(&j->lock);
}
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)
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;
: 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;
}
}
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);
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;
}
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;
}
}