processor = select_processor();
- ret = processor->prepare(store, s);
+ ret = processor->prepare(store, s->obj_ctx);
if (ret < 0)
goto done;
class RGWRadosPutObj : public RGWGetDataCB
{
rgw_obj obj;
+ RGWPutObjProcessor_Atomic *processor;
public:
- RGWRadosPutObj(rgw_obj& _o) : obj(_o) {}
+ RGWRadosPutObj(RGWPutObjProcessor_Atomic *p) : processor(p) {}
int handle_data(bufferlist& bl, off_t ofs, off_t len) {
+ void *handle;
+ int ret = processor->handle_data(bl, ofs, &handle);
+ if (ret < 0)
+ return ret;
+
+ ret = processor->throttle_data(handle);
+ if (ret < 0)
+ return ret;
+
return 0;
}
+
+ int complete(string& etag, time_t *mtime, map<string, bufferlist>& attrs) {
+ return processor->complete(etag, mtime, attrs);
+ }
};
/**
map<string, bufferlist> src_attrs;
RGWRESTStreamReadRequest *in_stream_req;
- RGWRadosPutObj cb(dest_obj);
+ string tag;
+ append_rand_alpha(cct, tag, tag, 32);
+
+ RGWPutObjProcessor_Atomic processor(dest_obj.bucket, dest_obj.object,
+ cct->_conf->rgw_obj_stripe_size, tag);
+ ret = processor.prepare(this, ctx);
+ if (ret < 0)
+ return ret;
+
+ RGWRadosPutObj cb(&processor);
int ret = rest_conn->get_obj(user_id, src_obj, &cb, &in_stream_req);
if (ret < 0)
if (ret < 0)
return ret;
+ ret = cb.complete(etag, mtime, attrs);
+ if (ret < 0)
+ return ret;
+
return 0;
}
protected:
int prepare(RGWRados *store, void *obj_ctx);
int handle_data(bufferlist& bl, off_t ofs, void **phandle);
- int throttle_data(void *handle) { return 0; }
int do_complete(string& etag, time_t *mtime, map<string, bufferlist>& attrs);
public:
+ int throttle_data(void *handle) { return 0; }
RGWPutObjProcessor_Plain(rgw_bucket& b, const string& o) : bucket(b), obj_str(o), ofs(0) {}
};
uint64_t obj_len;
int handle_obj_data(rgw_obj& obj, bufferlist& bl, off_t ofs, off_t abs_ofs, void **phandle);
+
+public:
int throttle_data(void *handle);
RGWPutObjProcessor_Aio() : max_chunks(RGW_MAX_PENDING_CHUNKS), obj_len(0) {}
virtual bool immutable_head() { return false; }
- int prepare(RGWRados *store, void *obj_ctx);
virtual int do_complete(string& etag, time_t *mtime, map<string, bufferlist>& attrs);
void prepare_next_part(off_t ofs);
bucket(_b),
obj_str(_o),
unique_tag(_t) {}
+ int prepare(RGWRados *store, void *obj_ctx);
int handle_data(bufferlist& bl, off_t ofs, void **phandle);
};
if (mtime) {
string mtime_str;
set_str_from_headers(out_headers, "RGWX_MTIME", mtime_str);
- string err;
- long t = strict_strtol(mtime_str.c_str(), 10, &err);
- if (!err.empty()) {
- ldout(cct, 0) << "ERROR: failed converting mtime (" << mtime_str << ") to int " << dendl;
- return -EINVAL;
+ if (!mtime_str.empty()) {
+ string err;
+ long t = strict_strtol(mtime_str.c_str(), 10, &err);
+ if (!err.empty()) {
+ ldout(cct, 0) << "ERROR: failed converting mtime (" << mtime_str << ") to int " << dendl;
+ return -EINVAL;
+ }
+ *mtime = (time_t)t;
}
- *mtime = (time_t)t;
}
return status;