Merge pull request #36502 from cbodley/wip-rgw-objv-tracker-inc

rgw: RGWObjVersionTracker tracks version over increments

Reviewed-by: Adam Emerson <aemerson@redhat.com>
Reviewed-by: Yehuda Sadeh <yehuda@redhat.com>
This commit is contained in:
J. Eric Ivancich 2020-09-03 12:59:18 -04:00 committed by GitHub
commit 375e966850
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 16 deletions

View File

@ -1064,10 +1064,7 @@ struct RGWObjVersionTracker {
void prepare_op_for_read(librados::ObjectReadOperation *op);
void prepare_op_for_write(librados::ObjectWriteOperation *op);
void apply_write() {
read_version = write_version;
write_version = obj_version();
}
void apply_write();
void clear() {
read_version = obj_version();

View File

@ -186,6 +186,20 @@ void RGWObjVersionTracker::prepare_op_for_write(ObjectWriteOperation *op)
}
}
void RGWObjVersionTracker::apply_write()
{
const bool checked = (read_version.ver != 0);
const bool incremented = (write_version.ver == 0);
if (checked && incremented) {
// apply cls_version_inc() so our next operation can recheck it
++read_version.ver;
} else {
read_version = write_version;
}
write_version = obj_version();
}
RGWObjState::RGWObjState() {
}

View File

@ -253,13 +253,13 @@ int RGWSI_SysObj_Cache::set_attrs(const rgw_raw_obj& obj,
}
info.status = 0;
info.flags = CACHE_FLAG_MODIFY_XATTRS;
if (objv_tracker) {
info.version = objv_tracker->write_version;
info.flags |= CACHE_FLAG_OBJV;
}
int ret = RGWSI_SysObj_Core::set_attrs(obj, attrs, rmattrs, objv_tracker, y);
string name = normal_name(pool, oid);
if (ret >= 0) {
if (objv_tracker && objv_tracker->read_version.ver) {
info.version = objv_tracker->read_version;
info.flags |= CACHE_FLAG_OBJV;
}
cache.put(name, info, NULL);
int r = distribute_cache(name, obj, info, UPDATE_OBJ, y);
if (r < 0)
@ -288,10 +288,6 @@ int RGWSI_SysObj_Cache::write(const rgw_raw_obj& obj,
info.status = 0;
info.data = data;
info.flags = CACHE_FLAG_XATTRS | CACHE_FLAG_DATA | CACHE_FLAG_META;
if (objv_tracker) {
info.version = objv_tracker->write_version;
info.flags |= CACHE_FLAG_OBJV;
}
ceph::real_time result_mtime;
int ret = RGWSI_SysObj_Core::write(obj, &result_mtime, attrs,
exclusive, data,
@ -299,6 +295,10 @@ int RGWSI_SysObj_Cache::write(const rgw_raw_obj& obj,
if (pmtime) {
*pmtime = result_mtime;
}
if (objv_tracker && objv_tracker->read_version.ver) {
info.version = objv_tracker->read_version;
info.flags |= CACHE_FLAG_OBJV;
}
info.meta.mtime = result_mtime;
info.meta.size = data.length();
string name = normal_name(pool, oid);
@ -339,13 +339,13 @@ int RGWSI_SysObj_Cache::write_data(const rgw_raw_obj& obj,
info.status = 0;
info.flags = CACHE_FLAG_DATA;
if (objv_tracker) {
info.version = objv_tracker->write_version;
info.flags |= CACHE_FLAG_OBJV;
}
int ret = RGWSI_SysObj_Core::write_data(obj, data, exclusive, objv_tracker, y);
string name = normal_name(pool, oid);
if (ret >= 0) {
if (objv_tracker && objv_tracker->read_version.ver) {
info.version = objv_tracker->read_version;
info.flags |= CACHE_FLAG_OBJV;
}
cache.put(name, info, NULL);
int r = distribute_cache(name, obj, info, UPDATE_OBJ, y);
if (r < 0)