mirror of
https://github.com/ceph/ceph
synced 2024-12-17 00:46:05 +00:00
rgw: expose the version of synced items to the poster
To support this, we add an optional out argument to RGWMetadatManager::put() and fill in the read_version. When the function returns, that contains whatever the current on-disk version of the object is (either what already existed or what we just wrote). Signed-off-by: Greg Farnum <greg@inktank.com>
This commit is contained in:
parent
81b62b5c71
commit
063c71f0ff
@ -1573,6 +1573,7 @@ public:
|
||||
// are we actually going to perform this put, or is it too old?
|
||||
if (!check_versions(old_bci.info.objv_tracker.read_version, orig_mtime,
|
||||
objv_tracker.write_version, mtime, sync_type)) {
|
||||
objv_tracker.read_version = old_bci.info.objv_tracker.read_version;
|
||||
return STATUS_NO_APPLY;
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,8 @@ int RGWMetadataManager::get(string& metadata_key, Formatter *f)
|
||||
}
|
||||
|
||||
int RGWMetadataManager::put(string& metadata_key, bufferlist& bl,
|
||||
RGWMetadataHandler::sync_type_t sync_type)
|
||||
RGWMetadataHandler::sync_type_t sync_type,
|
||||
obj_version *existing_version)
|
||||
{
|
||||
RGWMetadataHandler *handler;
|
||||
string entry;
|
||||
@ -359,7 +360,11 @@ int RGWMetadataManager::put(string& metadata_key, bufferlist& bl,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return handler->put(store, entry, objv_tracker, mtime, jo, sync_type);
|
||||
ret = handler->put(store, entry, objv_tracker, mtime, jo, sync_type);
|
||||
if (existing_version) {
|
||||
*existing_version = objv_tracker.read_version;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int RGWMetadataManager::remove(string& metadata_key)
|
||||
|
@ -196,7 +196,8 @@ public:
|
||||
RGWObjVersionTracker *objv_tracker);
|
||||
int get(string& metadata_key, Formatter *f);
|
||||
int put(string& metadata_key, bufferlist& bl,
|
||||
RGWMetadataHandler::sync_type_t sync_mode);
|
||||
RGWMetadataHandler::sync_type_t sync_mode,
|
||||
obj_version *existing_version = NULL);
|
||||
int remove(string& metadata_key);
|
||||
|
||||
int list_keys_init(string& section, void **phandle);
|
||||
|
@ -174,7 +174,7 @@ void RGWOp_Metadata_Put::execute() {
|
||||
}
|
||||
}
|
||||
|
||||
http_ret = store->meta_mgr->put(metadata_key, bl, sync_type);
|
||||
http_ret = store->meta_mgr->put(metadata_key, bl, sync_type, &ondisk_version);
|
||||
if (http_ret < 0) {
|
||||
dout(5) << "ERROR: can't put key: " << cpp_strerror(http_ret) << dendl;
|
||||
return;
|
||||
@ -192,7 +192,11 @@ void RGWOp_Metadata_Put::send_response() {
|
||||
http_return_code = STATUS_NO_CONTENT;
|
||||
set_req_state_err(s, http_return_code);
|
||||
dump_errno(s);
|
||||
stringstream ver_stream;
|
||||
ver_stream << "ver:" << ondisk_version.ver
|
||||
<<",tag:" << ondisk_version.tag;
|
||||
dump_pair(s, "RGWX_UPDATE_STATUS", update_status.c_str());
|
||||
dump_pair(s, "RGWX_UPDATE_VERSION", ver_stream.str().c_str());
|
||||
end_header(s);
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
class RGWOp_Metadata_Put : public RGWRESTOp {
|
||||
int get_data(bufferlist& bl);
|
||||
string update_status;
|
||||
obj_version ondisk_version;
|
||||
public:
|
||||
RGWOp_Metadata_Put() {}
|
||||
~RGWOp_Metadata_Put() {}
|
||||
|
Loading…
Reference in New Issue
Block a user