From: Pritha Srivastava Date: Wed, 27 May 2020 08:40:20 +0000 (+0530) Subject: cls/rgw_gc: Clearing off urgent data in bufferlist, before X-Git-Tag: v15.2.4~58^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ede74f7768e0423af30fd360a828b517f76cfc03;p=ceph.git cls/rgw_gc: Clearing off urgent data in bufferlist, before encoding the updated one. If this is not done, urgent data keeps getting appended to the head, finally overwriting queue data that results in invalid entries. Signed-off-by: Pritha Srivastava (cherry picked from commit 182382cf6368eaa6f9d1efbb883ae7813a9bf6d0) --- diff --git a/src/cls/queue/cls_queue_src.cc b/src/cls/queue/cls_queue_src.cc index b48dcd19f85..ae8eb8edd9b 100644 --- a/src/cls/queue/cls_queue_src.cc +++ b/src/cls/queue/cls_queue_src.cc @@ -25,6 +25,11 @@ int queue_write_head(cls_method_context_t hctx, cls_queue_head& head) bl.claim_append(bl_head); + if (bl.length() > head.max_head_size) { + CLS_LOG(0, "ERROR: queue_write_head: invalid head size = %u and urgent data size = %u \n", bl.length(), head.bl_urgent_data.length()); + return -EINVAL; + } + int ret = cls_cxx_write2(hctx, 0, bl.length(), &bl, CEPH_OSD_OP_FLAG_FADVISE_WILLNEED); if (ret < 0) { CLS_LOG(5, "ERROR: queue_write_head: failed to write head\n"); diff --git a/src/cls/rgw_gc/cls_rgw_gc.cc b/src/cls/rgw_gc/cls_rgw_gc.cc index 976e49ea52e..77e1e643389 100644 --- a/src/cls/rgw_gc/cls_rgw_gc.cc +++ b/src/cls/rgw_gc/cls_rgw_gc.cc @@ -361,7 +361,9 @@ static int cls_rgw_gc_queue_remove_entries(cls_method_context_t hctx, bufferlist } //Update urgent data map + head.bl_urgent_data.clear(); encode(urgent_data, head.bl_urgent_data); + CLS_LOG(5, "INFO: cls_rgw_gc_queue_remove_entries(): Urgent data size is %u\n", head.bl_urgent_data.length()); return queue_write_head(hctx, head); }