std::span<rgw_data_change_log_entry> entries,
std::string marker)
{
+ assert(shard < shards);
const auto [start_id, // Starting generation
start_cursor // Cursor to be used when listing the
// starting generation
const DoutPrefixProvider *dpp, int shard,
int max_entries, std::vector<rgw_data_change_log_entry>& entries,
std::string_view marker, std::string* out_marker, bool* truncated,
- optional_yield y)
+ std::string* errstr, optional_yield y)
{
std::exception_ptr eptr;
std::tuple<std::span<rgw_data_change_log_entry>,
std::string> out;
+ if (shard >= num_shards) [[unlikely]] {
+ if (errstr) {
+ *errstr = fmt::format("{} is not a valid shard. Valid shards are integers in [0, {})",
+ shard, num_shards);
+ }
+ return -EINVAL;
+ }
if (std::ssize(entries) < max_entries) {
entries.resize(max_entries);
}
}
int RGWDataChangesLog::get_info(const DoutPrefixProvider* dpp, int shard_id,
- RGWDataChangesLogInfo* info, optional_yield y)
+ RGWDataChangesLogInfo* info,
+ std::string* errstr, optional_yield y)
{
- assert(shard_id < num_shards);
+ if (shard_id >= num_shards) [[unlikely]] {
+ if (errstr) {
+ *errstr = fmt::format(
+ "{} is not a valid shard. Valid shards are integers in [0, {})",
+ shard_id, num_shards);
+ }
+ }
auto be = bes->head();
std::exception_ptr eptr;
if (y) {
const DoutPrefixProvider *dpp, int shard_id,
std::string_view marker)
{
+ assert(shard_id < shards);
auto [target_gen, cursor] = cursorgen(std::string{marker});
std::unique_lock l(m);
}
int RGWDataChangesLog::trim_entries(const DoutPrefixProvider *dpp, int shard_id,
- std::string_view marker, optional_yield y)
+ std::string_view marker, std::string* errstr,
+ optional_yield y)
{
- assert(shard_id < num_shards);
+ if (shard_id >= num_shards) [[unlikely]] {
+ if (errstr) {
+ *errstr = fmt::format(
+ "{} is not a valid shard. Valid shards are integers in [0, {})",
+ shard_id, num_shards);
+ }
+ }
std::exception_ptr eptr;
if (y) {
auto& yield = y.get_yield_context();
int RGWDataChangesLog::trim_entries(const DoutPrefixProvider* dpp, int shard_id,
std::string_view marker,
- librados::AioCompletion* c) {
+ librados::AioCompletion* c)
+{
+ if (shard_id >= num_shards) [[unlikely]] {
+ return -EINVAL;
+ }
asio::co_spawn(rados->get_executor(),
bes->trim_entries(dpp, shard_id, marker),
c);
void RGWDataChangesLog::mark_modified(int shard_id, const rgw_bucket_shard& bs, uint64_t gen)
{
+ assert(shard_id < num_shards);
if (!cct->_conf->rgw_data_notify_interval_msec) {
return;
}
int list_entries(const DoutPrefixProvider *dpp, int shard, int max_entries,
std::vector<rgw_data_change_log_entry>& entries,
std::string_view marker, std::string* out_marker,
- bool* truncated, optional_yield y);
+ bool* truncated, std::string* errstr, optional_yield y);
asio::awaitable<std::tuple<std::vector<rgw_data_change_log_entry>,
RGWDataChangesLogMarker>>
list_entries(const DoutPrefixProvider *dpp, int max_entries,
optional_yield y);
int trim_entries(const DoutPrefixProvider *dpp, int shard_id,
- std::string_view marker, optional_yield y);
+ std::string_view marker, std::string* errstr, optional_yield y);
int trim_entries(const DoutPrefixProvider *dpp, int shard_id,
- std::string_view marker, librados::AioCompletion* c);
+ std::string_view marker, librados::AioCompletion* c);
int get_info(const DoutPrefixProvider *dpp, int shard_id,
- RGWDataChangesLogInfo *info, optional_yield y);
+ RGWDataChangesLogInfo *info, std::string* errstr,
+ optional_yield y);
void mark_modified(int shard_id, const rgw_bucket_shard& bs, uint64_t gen);
auto read_clear_modified() {
// entry listed
op_ret = static_cast<rgw::sal::RadosStore*>(driver)->svc()->
datalog_rados->list_entries(this, shard_id, max_entries, entries,
- marker, &last_marker, &truncated, y);
+ marker, &last_marker, &truncated, nullptr, y);
RGWDataChangesLogInfo info;
op_ret = static_cast<rgw::sal::RadosStore*>(driver)->svc()->
- datalog_rados->get_info(this, shard_id, &info, y);
+ datalog_rados->get_info(this, shard_id, &info, nullptr, y);
last_update = info.last_update;
}
}
op_ret = static_cast<rgw::sal::RadosStore*>(driver)->svc()->
- datalog_rados->get_info(this, shard_id, &info, y);
+ datalog_rados->get_info(this, shard_id, &info, nullptr, y);
}
void RGWOp_DATALog_ShardInfo::send_response() {
}
op_ret = static_cast<rgw::sal::RadosStore*>(driver)->svc()->
- datalog_rados->trim_entries(this, shard_id, marker, y);
+ datalog_rados->trim_entries(this, shard_id, marker, nullptr, y);
}
// not in header to avoid pulling in rgw_sync.h
auto datalog_svc = static_cast<rgw::sal::RadosStore*>(driver)->svc()->datalog_rados;
RGWDataChangesLogMarker log_marker;
+ std::string errstr;
do {
std::vector<rgw_data_change_log_entry> entries;
if (specified_shard_id) {
ret = datalog_svc->list_entries(dpp(), shard_id, max_entries - count,
entries, marker,
&marker, &truncated,
- null_yield);
+ &errstr, null_yield);
} else {
ret = datalog_svc->list_entries(dpp(), max_entries - count, entries,
log_marker, &truncated, null_yield);
}
if (ret < 0) {
- cerr << "ERROR: datalog_svc->list_entries(): " << cpp_strerror(-ret) << std::endl;
+ cerr << "ERROR: datalog_svc->list_entries(): " << errstr << ": "
+ << cpp_strerror(-ret) << std::endl;
return -ret;
}
RGWDataChangesLogInfo info;
static_cast<rgw::sal::RadosStore*>(driver)->svc()->
- datalog_rados->get_info(dpp(), i, &info, null_yield);
+ datalog_rados->get_info(dpp(), i, &info, nullptr, null_yield);
::encode_json("info", info, formatter.get());
}
auto datalog = static_cast<rgw::sal::RadosStore*>(driver)->svc()->datalog_rados;
- ret = datalog->trim_entries(dpp(), shard_id, marker, null_yield);
+ ret = datalog->trim_entries(dpp(), shard_id, marker, nullptr, null_yield);
if (ret < 0 && ret != -ENODATA) {
cerr << "ERROR: trim_entries(): " << cpp_strerror(-ret) << std::endl;