From 006bd492b791b066a27a423e2dc116a9c72a5612 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Wed, 3 Aug 2016 16:01:00 -0700 Subject: [PATCH] rgw: helper to stat remote obj Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_rados.cc | 4 ++-- src/rgw/rgw_rest_client.h | 6 ++++++ src/rgw/rgw_rest_conn.cc | 11 ++++++++--- src/rgw/rgw_rest_conn.h | 5 +++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 424a956706b44..98e2b6af0a526 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -6776,7 +6776,7 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx, { /* source is in a different zonegroup, copy from there */ - RGWRESTStreamReadRequest *in_stream_req; + RGWRESTStreamRWRequest *in_stream_req; string tag; map src_attrs; int i; @@ -6860,7 +6860,7 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx, ret = conn->get_obj(user_id, info, src_obj, pmod, unmod_ptr, dest_mtime_weight.zone_short_id, dest_mtime_weight.pg_ver, - true, &cb, &in_stream_req); + true, true, &cb, &in_stream_req); if (ret < 0) { goto set_err_state; } diff --git a/src/rgw/rgw_rest_client.h b/src/rgw/rgw_rest_client.h index 59df2c6c39b5d..6ceeb43f9b646 100644 --- a/src/rgw/rgw_rest_client.h +++ b/src/rgw/rgw_rest_client.h @@ -121,5 +121,11 @@ public: param_vec_t *_params) : RGWRESTStreamRWRequest(_cct, "GET", _url, _cb, _headers, _params) {} }; +class RGWRESTStreamHeadRequest : public RGWRESTStreamRWRequest { +public: + RGWRESTStreamHeadRequest(CephContext *_cct, const string& _url, RGWGetDataCB *_cb, param_vec_t *_headers, + param_vec_t *_params) : RGWRESTStreamRWRequest(_cct, "HEAD", _url, _cb, _headers, _params) {} +}; + #endif diff --git a/src/rgw/rgw_rest_conn.cc b/src/rgw/rgw_rest_conn.cc index ead41394f47a3..4ed49d1db34be 100644 --- a/src/rgw/rgw_rest_conn.cc +++ b/src/rgw/rgw_rest_conn.cc @@ -118,7 +118,8 @@ static void set_header(T val, map& headers, const string& header int RGWRESTConn::get_obj(const rgw_user& uid, req_info *info /* optional */, rgw_obj& obj, const real_time *mod_ptr, const real_time *unmod_ptr, uint32_t mod_zone_id, uint64_t mod_pg_ver, - bool prepend_metadata, RGWGetDataCB *cb, RGWRESTStreamReadRequest **req) + bool prepend_metadata, bool read_data, + RGWGetDataCB *cb, RGWRESTStreamRWRequest **req) { string url; int ret = get_url(url); @@ -137,7 +138,11 @@ int RGWRESTConn::get_obj(const rgw_user& uid, req_info *info /* optional */, rgw const string& instance = obj.get_instance(); params.push_back(param_pair_t("versionId", instance)); } - *req = new RGWRESTStreamReadRequest(cct, url, cb, NULL, ¶ms); + if (read_data) { + *req = new RGWRESTStreamReadRequest(cct, url, cb, NULL, ¶ms); + } else { + *req = new RGWRESTStreamHeadRequest(cct, url, cb, NULL, ¶ms); + } map extra_headers; if (info) { map& orig_map = info->env->get_map(); @@ -166,7 +171,7 @@ int RGWRESTConn::get_obj(const rgw_user& uid, req_info *info /* optional */, rgw return (*req)->get_obj(key, extra_headers, obj); } -int RGWRESTConn::complete_request(RGWRESTStreamReadRequest *req, string& etag, real_time *mtime, map& attrs) +int RGWRESTConn::complete_request(RGWRESTStreamRWRequest *req, string& etag, real_time *mtime, map& attrs) { int ret = req->complete(etag, mtime, attrs); delete req; diff --git a/src/rgw/rgw_rest_conn.h b/src/rgw/rgw_rest_conn.h index 26229958dc89c..1ef6385b20b3d 100644 --- a/src/rgw/rgw_rest_conn.h +++ b/src/rgw/rgw_rest_conn.h @@ -89,8 +89,9 @@ public: int get_obj(const rgw_user& uid, req_info *info /* optional */, rgw_obj& obj, const ceph::real_time *mod_ptr, const ceph::real_time *unmod_ptr, uint32_t mod_zone_id, uint64_t mod_pg_ver, - bool prepend_metadata, RGWGetDataCB *cb, RGWRESTStreamReadRequest **req); - int complete_request(RGWRESTStreamReadRequest *req, string& etag, ceph::real_time *mtime, map& attrs); + bool prepend_metadata, bool read_data, + RGWGetDataCB *cb, RGWRESTStreamRWRequest **req); + int complete_request(RGWRESTStreamRWRequest *req, string& etag, ceph::real_time *mtime, map& attrs); int get_resource(const string& resource, param_vec_t *extra_params, -- 2.39.5