]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: don't clobber first_chunk on retry
authorYehuda Sadeh <yehuda@redhat.com>
Mon, 7 Mar 2016 20:13:19 +0000 (12:13 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 7 Mar 2016 20:18:16 +0000 (12:18 -0800)
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 <yehuda@redhat.com>
src/rgw/rgw_rados.cc

index d666f180d4e8d3b4a40c5da7acafe7a16a91c681..de53b563b9309a30b11b2ea598fdda6ab3202846 100644 (file)
@@ -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()) {