mirror of
https://github.com/ceph/ceph
synced 2025-01-04 02:02:36 +00:00
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:
commit
375e966850
@ -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();
|
||||
|
@ -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() {
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user