}
}
- uint64_t max_chunk_size = store->get_max_chunk_size();
-
pending_data_bl.claim_append(bl);
if (pending_data_bl.length() < max_chunk_size)
return 0;
return write_data(bl, write_ofs, phandle, exclusive);
}
-int RGWPutObjProcessor_Atomic::prepare(RGWRados *store, void *obj_ctx, string *oid_rand)
+
+int RGWPutObjProcessor_Atomic::prepare_init(RGWRados *store, void *obj_ctx, string *oid_rand)
{
RGWPutObjProcessor::prepare(store, obj_ctx, oid_rand);
- head_obj.init(bucket, obj_str);
+ int r = store->get_max_chunk_size(bucket, &max_chunk_size);
+ if (r < 0) {
+ return r;
+ }
- uint64_t max_chunk_size = store->get_max_chunk_size();
+ return 0;
+}
+
+int RGWPutObjProcessor_Atomic::prepare(RGWRados *store, void *obj_ctx, string *oid_rand)
+{
+ int r = prepare_init(store, obj_ctx, oid_rand);
+ if (r < 0) {
+ return r;
+ }
+ head_obj.init(bucket, obj_str);
manifest.set_trivial_rule(max_chunk_size, store->ctx()->_conf->rgw_obj_stripe_size);
- int r = manifest_gen.create_begin(store->ctx(), &manifest, bucket, head_obj);
+ r = manifest_gen.create_begin(store->ctx(), &manifest, bucket, head_obj);
if (r < 0) {
return r;
}
}
}
+int RGWRados::get_required_alignment(rgw_bucket& bucket, uint64_t *alignment)
+{
+ IoCtx ioctx;
+ int r = open_bucket_data_ctx(bucket, ioctx);
+ if (r < 0) {
+ ldout(cct, 0) << "ERROR: open_bucket_data_ctx() returned " << r << dendl;
+ return r;
+ }
+
+ *alignment = ioctx.pool_required_alignment();
+ return 0;
+}
+
+int RGWRados::get_max_chunk_size(rgw_bucket& bucket, uint64_t *max_chunk_size)
+{
+ uint64_t alignment;
+ int r = get_required_alignment(bucket, &alignment);
+ if (r < 0) {
+ return r;
+ }
+
+ uint64_t config_chunk_size = cct->_conf->rgw_max_chunk_size;
+
+ if (alignment == 0) {
+ *max_chunk_size = config_chunk_size;
+ return 0;
+ }
+
+ if (config_chunk_size <= alignment) {
+ *max_chunk_size = alignment;
+ return 0;
+ }
+
+ *max_chunk_size = config_chunk_size - (config_chunk_size % alignment);
+
+ return 0;
+}
+
void RGWRados::finalize()
{
if (need_watch_notify()) {
{
int ret;
- max_chunk_size = cct->_conf->rgw_max_chunk_size;
-
rados = new Rados();
if (!rados)
return -ENOMEM;
vector<rgw_obj> ref_objs;
- bool copy_data = !astate->has_manifest;
- bool copy_first = false;
- if (astate->has_manifest) {
- if (!astate->manifest.has_tail()) {
- copy_data = true;
- } else {
- uint64_t head_size = astate->manifest.get_head_size();
-
- if (head_size > 0) {
- if (head_size > max_chunk_size) // should never happen
- copy_data = true;
- else
- copy_first = true;
- }
- }
- }
-
-
if (remote_dest) {
/* dest is in a different region, copy it there */
return ret;
return 0;
- } else if (copy_data) { /* refcounting tail wouldn't work here, just copy the data */
- return copy_obj_data(ctx, dest_bucket_info.owner, &handle, end, dest_obj, src_obj, mtime, src_attrs, category, ptag, err);
+ }
+
+ uint64_t max_chunk_size;
+
+ ret = get_max_chunk_size(dest_obj.bucket, &max_chunk_size);
+ if (ret < 0) {
+ ldout(cct, 0) << "ERROR: failed to get max_chunk_size() for bucket " << dest_obj.bucket << dendl;
+ return ret;
+ }
+
+ bool copy_data = !astate->has_manifest;
+ bool copy_first = false;
+ if (astate->has_manifest) {
+ if (!astate->manifest.has_tail()) {
+ copy_data = true;
+ } else {
+ uint64_t head_size = astate->manifest.get_head_size();
+
+ if (head_size > 0) {
+ if (head_size > max_chunk_size)
+ copy_data = true;
+ else
+ copy_first = true;
+ }
+ }
+ }
+
+ if (copy_data) { /* refcounting tail wouldn't work here, just copy the data */
+ return copy_obj_data(ctx, dest_bucket_info.owner, &handle, end, dest_obj, src_obj, max_chunk_size, mtime, src_attrs, category, ptag, err);
}
RGWObjManifest::obj_iterator miter = astate->manifest.obj_begin();
void **handle, off_t end,
rgw_obj& dest_obj,
rgw_obj& src_obj,
+ uint64_t max_chunk_size,
time_t *mtime,
map<string, bufferlist>& attrs,
RGWObjCategory category,
bool merge_bl = false;
bufferlist *pbl = &bl;
bufferlist read_bl;
+ uint64_t max_chunk_size;
+
get_obj_bucket_and_oid_key(obj, bucket, oid, key);
}
}
+ r = get_max_chunk_size(bucket, &max_chunk_size);
+ if (r < 0) {
+ ldout(cct, 0) << "ERROR: failed to get max_chunk_size() for bucket " << bucket << dendl;
+ goto done_ret;
+ }
+
if (len > max_chunk_size)
len = max_chunk_size;
uint64_t extra_data_len;
bufferlist extra_data_bl;
bufferlist pending_data_bl;
+ uint64_t max_chunk_size;
+
protected:
rgw_bucket bucket;
string obj_str;
int complete_parts();
int complete_writing_data();
+ int prepare_init(RGWRados *store, void *obj_ctx, string *oid_rand);
+
public:
~RGWPutObjProcessor_Atomic() {}
RGWPutObjProcessor_Atomic(const string& bucket_owner, rgw_bucket& _b, const string& _o, uint64_t _p, const string& _t) :
cur_part_id(0),
data_ofs(0),
extra_data_len(0),
+ max_chunk_size(0),
bucket(_b),
obj_str(_o),
unique_tag(_t) {}
int get_obj_ref(const rgw_obj& obj, rgw_rados_ref *ref, rgw_bucket *bucket, bool ref_system_obj = false);
uint64_t max_bucket_id;
- uint64_t max_chunk_size;
-
int get_obj_state(RGWRadosCtx *rctx, rgw_obj& obj, RGWObjState **state, RGWObjVersionTracker *objv_tracker);
int append_atomic_test(RGWRadosCtx *rctx, rgw_obj& obj,
librados::ObjectOperation& op, RGWObjState **state);
num_watchers(0), watchers(NULL), watch_handles(NULL),
watch_initialized(false),
bucket_id_lock("rados_bucket_id"), max_bucket_id(0),
- max_chunk_size(0),
cct(NULL), rados(NULL),
pools_initialized(false),
quota_handler(NULL),
}
}
- uint64_t get_max_chunk_size() {
- return max_chunk_size;
- }
+ int get_required_alignment(rgw_bucket& bucket, uint64_t *alignment);
+ int get_max_chunk_size(rgw_bucket& bucket, uint64_t *max_chunk_size);
int list_raw_objects(rgw_bucket& pool, const string& prefix_filter, int max,
RGWListRawObjsCtx& ctx, list<string>& oids,
void **handle, off_t end,
rgw_obj& dest_obj,
rgw_obj& src_obj,
+ uint64_t max_chunk_size,
time_t *mtime,
map<string, bufferlist>& attrs,
RGWObjCategory category,