From: Radoslaw Zarzynski Date: Wed, 24 Feb 2016 13:28:58 +0000 (+0100) Subject: rgw: return proper etag in response for PUT on Swift's SLO. X-Git-Tag: v10.1.0~232^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d42829677c6d516d5250f05d7fc4443786599c6e;p=ceph.git rgw: return proper etag in response for PUT on Swift's SLO. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 49aa79e62f73..61667103a3d7 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -603,11 +603,19 @@ int RGWPutObj_ObjStore_SWIFT::get_params() return -EINVAL; } + MD5 etag_sum; uint64_t total_size = 0; - for (vector::iterator iter = slo_info->entries.begin(); iter != slo_info->entries.end(); ++iter) { - total_size += iter->size_bytes; - ldout(s->cct, 20) << "slo_part: " << iter->path << " size=" << iter->size_bytes << dendl; + for (const auto& entry : slo_info->entries) { + etag_sum.Update((const byte *)entry.etag.c_str(), + entry.etag.length()); + total_size += entry.size_bytes; + + ldout(s->cct, 20) << "slo_part: " << entry.path + << " size=" << entry.size_bytes + << " etag=" << entry.etag + << dendl; } + complete_etag(etag_sum, &lo_etag); slo_info->total_size = total_size; ofs = slo_info->raw_data_len; @@ -618,9 +626,24 @@ int RGWPutObj_ObjStore_SWIFT::get_params() void RGWPutObj_ObjStore_SWIFT::send_response() { - if (! op_ret) + if (! op_ret) { op_ret = STATUS_CREATED; - dump_etag(s, etag.c_str()); + } + + if (!lo_etag.empty()) { + /* Static Large Object of Swift API has two etags represented by + * following members: + * - etag - for the manifest itself (it will be stored in xattrs), + * - lo_etag - for the content composited from SLO's segments. + * The value is calculated basing on segments' etags. + * In response for PUT request we have to expose the second one. + * The first one may be obtained by GET with "multipart-manifest=get" + * in query string on a given SLO. */ + dump_etag(s, ("\"" + lo_etag + "\"").c_str()); + } else { + dump_etag(s, etag.c_str()); + } + dump_last_modified(s, mtime); set_req_state_err(s, op_ret); dump_errno(s); diff --git a/src/rgw/rgw_rest_swift.h b/src/rgw/rgw_rest_swift.h index 170f4fe78ba5..9d85eb6dd759 100644 --- a/src/rgw/rgw_rest_swift.h +++ b/src/rgw/rgw_rest_swift.h @@ -84,6 +84,7 @@ public: }; class RGWPutObj_ObjStore_SWIFT : public RGWPutObj_ObjStore { + string lo_etag; public: RGWPutObj_ObjStore_SWIFT() {} ~RGWPutObj_ObjStore_SWIFT() {}