From f86fb9799e173dd9d3486c71d9a464d3465ad256 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 5 Feb 2015 17:26:11 -0800 Subject: [PATCH] rgw: obj delete operation can use remove_objs param The remove_objs param is needed to atomically remove multiple entries from the bucket index, e.g., when cancelling a multipart upload. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_rados.cc | 15 +++++++++------ src/rgw/rgw_rados.h | 9 ++++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 0b6681b2f9f04..53d0b6106b5d2 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -4246,7 +4246,7 @@ int RGWRados::Object::Delete::delete_obj() int64_t poolid = ref.ioctx.get_id(); if (r >= 0 || r == -ENOENT) { - r = index_op.complete_del(poolid, ref.ioctx.get_last_version()); + r = index_op.complete_del(poolid, ref.ioctx.get_last_version(), params.remove_objs); } else { int ret = index_op.cancel(); if (ret < 0) { @@ -4323,7 +4323,7 @@ int RGWRados::delete_obj_index(rgw_obj& obj) RGWRados::Bucket bop(this, bucket); RGWRados::Bucket::UpdateIndex index_op(&bop, obj, NULL); - int r = index_op.complete_del(-1 /* pool */, 0); + int r = index_op.complete_del(-1 /* pool */, 0, NULL); return r; } @@ -5019,7 +5019,8 @@ int RGWRados::Bucket::UpdateIndex::complete(int64_t poolid, uint64_t epoch, uint return ret; } -int RGWRados::Bucket::UpdateIndex::complete_del(int64_t poolid, uint64_t epoch) +int RGWRados::Bucket::UpdateIndex::complete_del(int64_t poolid, uint64_t epoch, + list *remove_objs) { RGWRados *store = target->get_store(); BucketShard *bs; @@ -5028,7 +5029,7 @@ int RGWRados::Bucket::UpdateIndex::complete_del(int64_t poolid, uint64_t epoch) ldout(store->ctx(), 5) << "failed to get BucketShard object: ret=" << ret << dendl; return ret; } - return store->cls_obj_complete_del(*bs, optag, poolid, epoch, obj, bilog_flags); + return store->cls_obj_complete_del(*bs, optag, poolid, epoch, obj, remove_objs, bilog_flags); } @@ -7401,11 +7402,13 @@ int RGWRados::cls_obj_complete_add(BucketShard& bs, string& tag, int RGWRados::cls_obj_complete_del(BucketShard& bs, string& tag, int64_t pool, uint64_t epoch, - rgw_obj& obj, uint16_t bilog_flags) + rgw_obj& obj, + list *remove_objs, + uint16_t bilog_flags) { RGWObjEnt ent; obj.get_index_key(&ent.key); - return cls_obj_complete_op(bs, CLS_RGW_OP_DEL, tag, pool, epoch, ent, RGW_OBJ_CATEGORY_NONE, NULL, bilog_flags); + return cls_obj_complete_op(bs, CLS_RGW_OP_DEL, tag, pool, epoch, ent, RGW_OBJ_CATEGORY_NONE, remove_objs, bilog_flags); } int RGWRados::cls_obj_complete_cancel(BucketShard& bs, string& tag, rgw_obj& obj, uint16_t bilog_flags) diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 7b70fcba47731..e6fe72b60d5f8 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1555,8 +1555,9 @@ public: uint64_t olh_epoch; string marker_version_id; uint32_t bilog_flags; + list *remove_objs; - DeleteParams() : versioning_status(0), olh_epoch(0), bilog_flags(0) {} + DeleteParams() : versioning_status(0), olh_epoch(0), bilog_flags(0), remove_objs(NULL) {} } params; struct DeleteResult { @@ -1616,7 +1617,8 @@ public: utime_t& ut, string& etag, string& content_type, bufferlist *acl_bl, RGWObjCategory category, list *remove_objs); - int complete_del(int64_t poolid, uint64_t epoch); + int complete_del(int64_t poolid, uint64_t epoch, + list *remove_objs); int cancel(); }; @@ -1930,7 +1932,8 @@ public: RGWObjEnt& ent, RGWObjCategory category, list *remove_objs, uint16_t bilog_flags); int cls_obj_complete_add(BucketShard& bs, string& tag, int64_t pool, uint64_t epoch, RGWObjEnt& ent, RGWObjCategory category, list *remove_objs, uint16_t bilog_flags); - int cls_obj_complete_del(BucketShard& bs, string& tag, int64_t pool, uint64_t epoch, rgw_obj& obj, uint16_t bilog_flags); + int cls_obj_complete_del(BucketShard& bs, string& tag, int64_t pool, uint64_t epoch, rgw_obj& obj, + list *remove_objs, uint16_t bilog_flags); int cls_obj_complete_cancel(BucketShard& bs, string& tag, rgw_obj& obj, uint16_t bilog_flags); int cls_obj_set_bucket_tag_timeout(rgw_bucket& bucket, uint64_t timeout); int cls_bucket_list(rgw_bucket& bucket, rgw_obj_key& start, const string& prefix, -- 2.39.5