mirror of
https://github.com/ceph/ceph
synced 2025-03-11 02:39:05 +00:00
rgw: radosgw-admin bucket stats
on indexless bucket crashes
The new bucket layout code didn't check whether the bucket is indexless prior to asking for the last entry in the layout log. The layout log appears to be empty for an indexless bucket, thereby putting the runtime in an undefined state that later may cause a failed assertion. This commit adds two safety checks and returns -EINVAL along with putting useful information on stderr when either stats are requested on an indexless bucket or when the layout log is empty. Signed-off-by: J. Eric Ivancich <ivancich@redhat.com>
This commit is contained in:
parent
030ec8e44d
commit
e0eb3d8c22
@ -1044,10 +1044,25 @@ static int bucket_stats(rgw::sal::Store* store,
|
||||
return ret;
|
||||
}
|
||||
|
||||
string bucket_ver, master_ver;
|
||||
string max_marker;
|
||||
if (bucket->get_info().layout.current_index.layout.type ==
|
||||
rgw::BucketIndexType::Indexless) {
|
||||
cerr << "error, indexless buckets do not maintain stats; bucket=" <<
|
||||
bucket->get_name() << std::endl;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (bucket->get_info().layout.logs.empty()) {
|
||||
// this check may be redundant with the previous check of
|
||||
// layout.type; calling back() on an empty vector produces
|
||||
// undefined behavior
|
||||
cerr << "error, layout log list is empty; bucket=" << bucket->get_name() <<
|
||||
std::endl;
|
||||
return -EINVAL;
|
||||
}
|
||||
const auto& latest_log = bucket->get_info().layout.logs.back();
|
||||
const auto& index = log_to_index_layout(latest_log);
|
||||
std::string bucket_ver, master_ver;
|
||||
std::string max_marker;
|
||||
ret = bucket->read_stats(dpp, index, RGW_NO_SHARD, &bucket_ver, &master_ver, stats, &max_marker);
|
||||
if (ret < 0) {
|
||||
cerr << "error getting bucket stats bucket=" << bucket->get_name() << " ret=" << ret << std::endl;
|
||||
|
Loading…
Reference in New Issue
Block a user