}
+static inline std::string after_delim(std::string_view delim)
+{
+ // assert: ! delim.empty()
+ std::string result{delim.data(), delim.length()};
+ result += char(255);
+ return result;
+}
+
+
/**
* Get ordered listing of the objects in a bucket.
*
* is_truncated: if number of objects in the bucket is bigger than
* max, then truncated.
*/
-static inline std::string after_delim(std::string_view delim)
-{
- // assert: ! delim.empty()
- std::string result{delim.data(), delim.length()};
- result += char(255);
- return result;
-}
-
int RGWRados::Bucket::List::list_objects_ordered(
- int64_t max,
+ int64_t max_p,
vector<rgw_bucket_dir_entry> *result,
map<string, bool> *common_prefixes,
bool *is_truncated)
int count = 0;
bool truncated = true;
- int read_ahead = std::max(cct->_conf->rgw_list_bucket_min_readahead,max);
+ const int64_t max = // protect against memory issues and negative vals
+ std::min(bucket_list_objects_absolute_max, std::max(int64_t(0), max_p));
+ int read_ahead = std::max(cct->_conf->rgw_list_bucket_min_readahead, max);
result->clear();
string skip_after_delim;
while (truncated && count <= max) {
- if (skip_after_delim > cur_marker.name) {
- cur_marker = skip_after_delim;
-
- ldout(cct, 20) << "setting cur_marker="
- << cur_marker.name
- << "[" << cur_marker.instance << "]"
- << dendl;
- }
std::map<string, rgw_bucket_dir_entry> ent_map;
int r = store->cls_bucket_list_ordered(target->get_bucket_info(),
shard_id,
next_marker = prefix_key;
(*common_prefixes)[prefix_key] = true;
- int marker_delim_pos = cur_marker.name.find(
- params.delim, cur_prefix.size());
-
- skip_after_delim = cur_marker.name.substr(0, marker_delim_pos);
- skip_after_delim.append(after_delim_s);
-
- ldout(cct, 20) << "skip_after_delim=" << skip_after_delim << dendl;
-
count++;
}
result->emplace_back(std::move(entry));
count++;
}
+
+ if (!params.delim.empty()) {
+ int marker_delim_pos = cur_marker.name.find(params.delim, cur_prefix.size());
+ if (marker_delim_pos >= 0) {
+ skip_after_delim = cur_marker.name.substr(0, marker_delim_pos);
+ skip_after_delim.append(after_delim_s);
+
+ ldout(cct, 20) << "skip_after_delim=" << skip_after_delim << dendl;
+
+ if (skip_after_delim > cur_marker.name) {
+ cur_marker = skip_after_delim;
+ ldout(cct, 20) << "setting cur_marker="
+ << cur_marker.name
+ << "[" << cur_marker.instance << "]"
+ << dendl;
+ }
+ }
+ }
}
done:
* is_truncated: if number of objects in the bucket is bigger than max, then
* truncated.
*/
-int RGWRados::Bucket::List::list_objects_unordered(int64_t max,
+int RGWRados::Bucket::List::list_objects_unordered(int64_t max_p,
vector<rgw_bucket_dir_entry> *result,
map<string, bool> *common_prefixes,
bool *is_truncated)
int count = 0;
bool truncated = true;
+ const int64_t max = // protect against memory issues and negative vals
+ std::min(bucket_list_objects_absolute_max, std::max(int64_t(0), max_p));
+
// read a few extra in each call to cls_bucket_list_unordered in
// case some are filtered out due to namespace matching, versioning,
// filtering, etc.
meta.set_mtime = real_clock::now();
}
+ if (target->bucket_info.obj_lock_enabled() && target->bucket_info.obj_lock.has_rule() && meta.flags == PUT_OBJ_CREATE) {
+ auto iter = attrs.find(RGW_ATTR_OBJECT_RETENTION);
+ if (iter == attrs.end()) {
+ real_time lock_until_date = target->bucket_info.obj_lock.get_lock_until_date(meta.set_mtime);
+ string mode = target->bucket_info.obj_lock.get_mode();
+ RGWObjectRetention obj_retention(mode, lock_until_date);
+ bufferlist bl;
+ obj_retention.encode(bl);
+ op.setxattr(RGW_ATTR_OBJECT_RETENTION, bl);
+ }
+ }
+
if (state->is_olh) {
op.setxattr(RGW_ATTR_OLH_ID_TAG, state->olh_tag);
}
if (r < 0) {
return r;
}
+ if (params.target_obj) {
+ *params.target_obj = state.obj;
+ }
if (params.attrs) {
*params.attrs = astate->attrset;
if (cct->_conf->subsys.should_gather<ceph_subsys_rgw, 20>()) {
if (r < 0 && r != -ENOENT) {
return r;
}
+ } else {
+ r = 0;
}
if (r >= 0) {
ldout(cct, 10) << "RGWRados::cls_bucket_list_ordered: got " <<
if (r < 0 && r != -ENOENT) {
return r;
}
+ } else {
+ r = 0;
}
// at this point either r >=0 or r == -ENOENT