From: Yehuda Sadeh Date: Fri, 9 Jan 2015 18:23:35 +0000 (-0800) Subject: rgw: only keep track for cleanup of rados objects that were written X-Git-Tag: v0.92~12^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0b5d80337e11359f2b910ce5cead4490cc5ab35b;p=ceph.git rgw: only keep track for cleanup of rados objects that were written 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 --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 625f081a9a53..7d083e37939d 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -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; } diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 66d4d1c20833..4b2b09c410a1 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -885,13 +885,15 @@ CephContext *RGWPutObjProcessor::ctx() return store->ctx(); } -RGWPutObjProcessor::~RGWPutObjProcessor() +RGWPutObjProcessor_Aio::~RGWPutObjProcessor_Aio() { + drain_pending(); + if (is_complete) return; list::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; } diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 929b025e6d13..1071b2f1ae61 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -554,14 +554,9 @@ protected: map& attrs, const char *if_match = NULL, const char *if_nomatch = NULL) = 0; - list 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 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