]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: only keep track for cleanup of rados objects that were written
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 9 Jan 2015 18:23:35 +0000 (10:23 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Wed, 14 Jan 2015 03:21:31 +0000 (19:21 -0800)
Fixes: #10311
We're keeping track of rados objects that we've written so that we could
clean them up if needed. Earlier we weren't too accurate about it and
were also setting the head object that is yet to be written. This now
only applies to the tail data, and a bit clearer.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 625f081a9a5348582f134d536ae99267ff142c38..7d083e37939d89ad7d0f0dfa65e5676b6f8530a1 100644 (file)
@@ -1462,7 +1462,6 @@ int RGWPutObjProcessor_Multipart::prepare(RGWRados *store, void *obj_ctx, string
   head_obj = manifest_gen.get_cur_obj();
   head_obj.index_hash_source = obj_str;
   cur_obj = head_obj;
-  add_obj(cur_obj);
 
   return 0;
 }
index 66d4d1c2083307050fa48097bb75e6c9267f4204..4b2b09c410a1c03110c808c33e82bfeafb87fd6a 100644 (file)
@@ -885,13 +885,15 @@ CephContext *RGWPutObjProcessor::ctx()
   return store->ctx();
 }
 
-RGWPutObjProcessor::~RGWPutObjProcessor()
+RGWPutObjProcessor_Aio::~RGWPutObjProcessor_Aio()
 {
+  drain_pending();
+
   if (is_complete)
     return;
 
   list<rgw_obj>::iterator iter;
-  for (iter = objs.begin(); iter != objs.end(); ++iter) {
+  for (iter = written_objs.begin(); iter != written_objs.end(); ++iter) {
     rgw_obj& obj = *iter;
     int r = store->delete_obj(obj_ctx, bucket_owner, obj);
     if (r < 0 && r != -ENOENT) {
@@ -946,6 +948,11 @@ int RGWPutObjProcessor_Aio::handle_obj_data(rgw_obj& obj, bufferlist& bl, off_t
   if ((uint64_t)abs_ofs + bl.length() > obj_len)
     obj_len = abs_ofs + bl.length();
 
+  if (!(obj == last_written_obj)) {
+    add_written_obj(obj);
+    last_written_obj = obj;
+  }
+
   // For the first call pass -1 as the offset to
   // do a write_full.
   int r = store->aio_put_obj_data(NULL, obj,
@@ -1146,7 +1153,6 @@ int RGWPutObjProcessor_Atomic::prepare_next_part(off_t ofs) {
   cur_part_ofs = ofs;
   next_part_ofs = ofs + manifest_gen.cur_stripe_max_size();
   cur_obj = manifest_gen.get_cur_obj();
-  add_obj(cur_obj);
 
   return 0;
 }
index 929b025e6d13dbeaeb3c08478c8572c22874b817..1071b2f1ae619c0291df1c28c3fb087ec5faa699 100644 (file)
@@ -554,14 +554,9 @@ protected:
                           map<string, bufferlist>& attrs,
                           const char *if_match = NULL, const char *if_nomatch = NULL) = 0;
 
-  list<rgw_obj> objs;
-
-  void add_obj(const rgw_obj& obj) {
-    objs.push_back(obj);
-  }
 public:
   RGWPutObjProcessor(const string& _bo) : store(NULL), obj_ctx(NULL), is_complete(false), bucket_owner(_bo) {}
-  virtual ~RGWPutObjProcessor();
+  virtual ~RGWPutObjProcessor() {}
   virtual int prepare(RGWRados *_store, void *_o, string *oid_rand) {
     store = _store;
     obj_ctx = _o;
@@ -614,9 +609,17 @@ class RGWPutObjProcessor_Aio : public RGWPutObjProcessor
   int wait_pending_front();
   bool pending_has_completed();
 
+  rgw_obj last_written_obj;
+
 protected:
   uint64_t obj_len;
 
+  list<rgw_obj> written_objs;
+
+  void add_written_obj(const rgw_obj& obj) {
+    written_objs.push_back(obj);
+  }
+
   int drain_pending();
   int handle_obj_data(rgw_obj& obj, bufferlist& bl, off_t ofs, off_t abs_ofs, void **phandle, bool exclusive);
 
@@ -624,9 +627,7 @@ public:
   int throttle_data(void *handle, bool need_to_wait);
 
   RGWPutObjProcessor_Aio(const string& bucket_owner) : RGWPutObjProcessor(bucket_owner), max_chunks(RGW_MAX_PENDING_CHUNKS), obj_len(0) {}
-  virtual ~RGWPutObjProcessor_Aio() {
-    drain_pending();
-  }
+  virtual ~RGWPutObjProcessor_Aio();
 };
 
 class RGWPutObjProcessor_Atomic : public RGWPutObjProcessor_Aio