]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: drain pending requests before completing write
authorYehuda Sadeh <yehuda@inktank.com>
Tue, 10 Sep 2013 19:18:55 +0000 (12:18 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Wed, 18 Sep 2013 18:41:58 +0000 (11:41 -0700)
Fixes: #6268
When doing aio write of objects (either regular or multipart parts) we
need to drain pending aio requests. Otherwise if gateway goes down then
object might end up corrupted.

Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_op.cc

index 0c157c561fb59e0305fc4d396263e11d821ae6ad..3485e690ca59585309b4cb0a801fa629472d248b 100644 (file)
@@ -1019,11 +1019,11 @@ class RGWPutObjProcessor_Aio : public RGWPutObjProcessor
   struct put_obj_aio_info pop_pending();
   int wait_pending_front();
   bool pending_has_completed();
-  int drain_pending();
 
 protected:
   uint64_t obj_len;
 
+  int drain_pending();
   int handle_obj_data(rgw_obj& obj, bufferlist& bl, off_t ofs, off_t abs_ofs, void **phandle);
   int throttle_data(void *handle);
 
@@ -1213,8 +1213,12 @@ int RGWPutObjProcessor_Atomic::do_complete(string& etag, map<string, bufferlist>
 
   store->set_atomic(s->obj_ctx, head_obj);
 
-  int r = store->put_obj_meta(s->obj_ctx, head_obj, obj_len, NULL, attrs,
-                              RGW_OBJ_CATEGORY_MAIN, PUT_OBJ_CREATE, NULL, &first_chunk, &manifest, NULL, NULL);
+  int r = drain_pending();
+  if (r < 0)
+    return r;
+
+  r = store->put_obj_meta(s->obj_ctx, head_obj, obj_len, NULL, attrs,
+                          RGW_OBJ_CATEGORY_MAIN, PUT_OBJ_CREATE, NULL, &first_chunk, &manifest, NULL, NULL);
 
   return r;
 }
@@ -1261,7 +1265,11 @@ int RGWPutObjProcessor_Multipart::do_complete(string& etag, map<string, bufferli
 {
   complete_parts();
 
-  int r = store->put_obj_meta(s->obj_ctx, head_obj, s->obj_size, NULL, attrs, RGW_OBJ_CATEGORY_MAIN, 0, NULL, NULL, NULL, NULL, NULL);
+  int r = drain_pending();
+  if (r < 0)
+    return r;
+
+  r = store->put_obj_meta(s->obj_ctx, head_obj, s->obj_size, NULL, attrs, RGW_OBJ_CATEGORY_MAIN, 0, NULL, NULL, NULL, NULL, NULL);
   if (r < 0)
     return r;