summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-06-12 23:59:49 -0700
committerYehuda Sadeh <yehuda@inktank.com>2013-06-12 23:59:49 -0700
commitcdd11ea6b60b98fa8d9014899bb00e6e7a4bc311 (patch)
treee967e11162dcbea08f032bc067920abfeedaa613
parent165926bd0289bb2aa761be9e1cf523ee0051c5f4 (diff)
downloadceph-cdd11ea6b60b98fa8d9014899bb00e6e7a4bc311.tar.gz
rgw: a few fixes to copy object across region
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/rgw/rgw_op.cc2
-rw-r--r--src/rgw/rgw_rados.cc31
-rw-r--r--src/rgw/rgw_rados.h6
-rw-r--r--src/rgw/rgw_rest_client.cc14
4 files changed, 42 insertions, 11 deletions
diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc
index baf6a2c9bba..0bf33a931f3 100644
--- a/src/rgw/rgw_op.cc
+++ b/src/rgw/rgw_op.cc
@@ -1152,7 +1152,7 @@ void RGWPutObj::execute()
processor = select_processor();
- ret = processor->prepare(store, s);
+ ret = processor->prepare(store, s->obj_ctx);
if (ret < 0)
goto done;
diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc
index 0f39753f338..809be0343c0 100644
--- a/src/rgw/rgw_rados.cc
+++ b/src/rgw/rgw_rados.cc
@@ -2109,11 +2109,25 @@ bool RGWRados::aio_completed(void *handle)
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);
+ }
};
/**
@@ -2182,7 +2196,16 @@ int RGWRados::copy_obj(void *ctx,
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)
@@ -2194,6 +2217,10 @@ int RGWRados::copy_obj(void *ctx,
if (ret < 0)
return ret;
+ ret = cb.complete(etag, mtime, attrs);
+ if (ret < 0)
+ return ret;
+
return 0;
}
diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h
index f6a6a8d078a..9952feafa25 100644
--- a/src/rgw/rgw_rados.h
+++ b/src/rgw/rgw_rados.h
@@ -211,10 +211,10 @@ class RGWPutObjProcessor_Plain : public RGWPutObjProcessor
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) {}
};
@@ -236,6 +236,8 @@ protected:
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) {}
@@ -264,7 +266,6 @@ protected:
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);
@@ -279,6 +280,7 @@ public:
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);
};
diff --git a/src/rgw/rgw_rest_client.cc b/src/rgw/rgw_rest_client.cc
index 9ff6ba57d8e..907ac0c423b 100644
--- a/src/rgw/rgw_rest_client.cc
+++ b/src/rgw/rgw_rest_client.cc
@@ -584,13 +584,15 @@ int RGWRESTStreamReadRequest::complete(string& etag, time_t *mtime)
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;