mirror of
https://github.com/ceph/ceph
synced 2025-01-31 07:22:56 +00:00
Merge pull request #17499 from dillaman/wip-21247
cls/rbd: metadata_list not honoring max_return parameter Reviewed-by: Kefu Chai <kchai@redhat.com> Reviewed-by: Mykola Golub <mgolub@mirantis.com>
This commit is contained in:
commit
81e8be812b
@ -2630,7 +2630,7 @@ static const string metadata_name_from_key(const string &key)
|
||||
* Input:
|
||||
* @param start_after which name to begin listing after
|
||||
* (use the empty string to start at the beginning)
|
||||
* @param max_return the maximum number of names to list(if 0 means no limit)
|
||||
* @param max_return the maximum number of names to list
|
||||
|
||||
* Output:
|
||||
* @param value
|
||||
@ -2649,33 +2649,33 @@ int metadata_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
// TODO remove implicit support for zero during the N-release
|
||||
if (max_return == 0) {
|
||||
max_return = RBD_MAX_KEYS_READ;
|
||||
}
|
||||
|
||||
map<string, bufferlist> data;
|
||||
string last_read = metadata_key_for_name(start_after);
|
||||
int max_read = max_return ? MIN(RBD_MAX_KEYS_READ, max_return) : RBD_MAX_KEYS_READ;
|
||||
bool more;
|
||||
bool more = true;
|
||||
|
||||
do {
|
||||
while (more && data.size() < max_return) {
|
||||
map<string, bufferlist> raw_data;
|
||||
int max_read = MIN(RBD_MAX_KEYS_READ, max_return - data.size());
|
||||
int r = cls_cxx_map_get_vals(hctx, last_read, RBD_METADATA_KEY_PREFIX,
|
||||
max_read, &raw_data, &more);
|
||||
if (r < 0) {
|
||||
CLS_ERR("failed to read the vals off of disk: %s", cpp_strerror(r).c_str());
|
||||
return r;
|
||||
}
|
||||
if (raw_data.empty())
|
||||
break;
|
||||
|
||||
map<string, bufferlist>::iterator it = raw_data.begin();
|
||||
for (; it != raw_data.end(); ++it)
|
||||
data[metadata_name_from_key(it->first)].swap(it->second);
|
||||
for (auto& kv : raw_data) {
|
||||
data[metadata_name_from_key(kv.first)].swap(kv.second);
|
||||
}
|
||||
|
||||
if (!more)
|
||||
break;
|
||||
|
||||
last_read = raw_data.rbegin()->first;
|
||||
if (max_return)
|
||||
max_read = MIN(RBD_MAX_KEYS_READ, max_return - data.size());
|
||||
} while (more);
|
||||
if (!raw_data.empty()) {
|
||||
last_read = raw_data.rbegin()->first;
|
||||
}
|
||||
}
|
||||
|
||||
::encode(data, *out);
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user