Merge pull request #31058 from cbodley/wip-rgw-skip-bilog

cls/rgw: avoid read_bucket_header() when bi logging is disabled

Reviewed-by: J. Eric Ivancich <ivancich@redhat.com>
This commit is contained in:
J. Eric Ivancich 2020-09-03 13:14:25 -04:00 committed by GitHub
commit 86df8b9c8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1677,39 +1677,42 @@ static int rgw_bucket_link_olh(cls_method_context_t hctx, bufferlist *in, buffer
return ret;
}
if (!op.log_op) {
return 0;
}
rgw_bucket_dir_header header;
ret = read_bucket_header(hctx, &header);
if (ret < 0) {
CLS_LOG(1, "ERROR: rgw_bucket_link_olh(): failed to read header\n");
return ret;
}
if (op.log_op && !header.syncstopped) {
rgw_bucket_dir_entry& entry = obj.get_dir_entry();
rgw_bucket_entry_ver ver;
ver.epoch = (op.olh_epoch ? op.olh_epoch : olh.get_epoch());
string *powner = NULL;
string *powner_display_name = NULL;
if (op.delete_marker) {
powner = &entry.meta.owner;
powner_display_name = &entry.meta.owner_display_name;
}
RGWModifyOp operation = (op.delete_marker ? CLS_RGW_OP_LINK_OLH_DM : CLS_RGW_OP_LINK_OLH);
ret = log_index_operation(hctx, op.key, operation, op.op_tag,
entry.meta.mtime, ver,
CLS_RGW_STATE_COMPLETE, header.ver, header.max_marker, op.bilog_flags | RGW_BILOG_FLAG_VERSIONED_OP,
powner, powner_display_name, &op.zones_trace);
if (ret < 0)
return ret;
return write_bucket_header(hctx, &header); /* updates header version */
if (header.syncstopped) {
return 0;
}
return 0;
rgw_bucket_dir_entry& entry = obj.get_dir_entry();
rgw_bucket_entry_ver ver;
ver.epoch = (op.olh_epoch ? op.olh_epoch : olh.get_epoch());
string *powner = NULL;
string *powner_display_name = NULL;
if (op.delete_marker) {
powner = &entry.meta.owner;
powner_display_name = &entry.meta.owner_display_name;
}
RGWModifyOp operation = (op.delete_marker ? CLS_RGW_OP_LINK_OLH_DM : CLS_RGW_OP_LINK_OLH);
ret = log_index_operation(hctx, op.key, operation, op.op_tag,
entry.meta.mtime, ver,
CLS_RGW_STATE_COMPLETE, header.ver, header.max_marker, op.bilog_flags | RGW_BILOG_FLAG_VERSIONED_OP,
powner, powner_display_name, &op.zones_trace);
if (ret < 0)
return ret;
return write_bucket_header(hctx, &header); /* updates header version */
}
static int rgw_bucket_unlink_instance(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
@ -1839,30 +1842,33 @@ static int rgw_bucket_unlink_instance(cls_method_context_t hctx, bufferlist *in,
return ret;
}
if (!op.log_op) {
return 0;
}
rgw_bucket_dir_header header;
ret = read_bucket_header(hctx, &header);
if (ret < 0) {
CLS_LOG(1, "ERROR: rgw_bucket_unlink_instance(): failed to read header\n");
return ret;
}
if (op.log_op && !header.syncstopped) {
rgw_bucket_entry_ver ver;
ver.epoch = (op.olh_epoch ? op.olh_epoch : olh.get_epoch());
real_time mtime = obj.mtime(); /* mtime has no real meaning in
* instance removal context */
ret = log_index_operation(hctx, op.key, CLS_RGW_OP_UNLINK_INSTANCE, op.op_tag,
mtime, ver,
CLS_RGW_STATE_COMPLETE, header.ver, header.max_marker,
op.bilog_flags | RGW_BILOG_FLAG_VERSIONED_OP, NULL, NULL, &op.zones_trace);
if (ret < 0)
return ret;
return write_bucket_header(hctx, &header); /* updates header version */
if (header.syncstopped) {
return 0;
}
return 0;
rgw_bucket_entry_ver ver;
ver.epoch = (op.olh_epoch ? op.olh_epoch : olh.get_epoch());
real_time mtime = obj.mtime(); /* mtime has no real meaning in
* instance removal context */
ret = log_index_operation(hctx, op.key, CLS_RGW_OP_UNLINK_INSTANCE, op.op_tag,
mtime, ver,
CLS_RGW_STATE_COMPLETE, header.ver, header.max_marker,
op.bilog_flags | RGW_BILOG_FLAG_VERSIONED_OP, NULL, NULL, &op.zones_trace);
if (ret < 0)
return ret;
return write_bucket_header(hctx, &header); /* updates header version */
}
static int rgw_bucket_read_olh_log(cls_method_context_t hctx, bufferlist *in, bufferlist *out)