From: Yehuda Sadeh Date: Mon, 7 Mar 2016 20:13:19 +0000 (-0800) Subject: rgw: don't clobber first_chunk on retry X-Git-Tag: v10.1.0~143^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2f3a9c68d05b9b8dd7a8be50b9aeee0f6d4d1e7f;p=ceph.git rgw: don't clobber first_chunk on retry A racing object sync can end up with multiple calls to cb.complete() which in turn will end up with this method getting called multiple times. We can't claim the bufferlist again, and will just clobber first_chunk. Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index d666f180d4e8..de53b563b930 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -2421,7 +2421,13 @@ int RGWPutObjProcessor_Atomic::complete_parts() int RGWPutObjProcessor_Atomic::complete_writing_data() { if (!data_ofs && !immutable_head()) { - first_chunk.claim(pending_data_bl); + /* only claim if pending_data_bl() is not empty. This is needed because we might be called twice + * (e.g., when a retry due to race happens). So a second call to first_chunk.claim() would + * clobber first_chunk + */ + if (pending_data_bl.length() > 0) { + first_chunk.claim(pending_data_bl); + } obj_len = (uint64_t)first_chunk.length(); } if (pending_data_bl.length()) {