summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-06-25 12:19:17 -0700
committerYehuda Sadeh <yehuda@inktank.com>2013-06-25 12:19:17 -0700
commitc4be5a7057a01d2aa8a9a32ad795a1957fe0e6a7 (patch)
treeaac295b1e299bc8f634ac3f6121bd87844a1fef2
parent86c73c94ff295116f1afe3b81ba15090a63bc3b4 (diff)
downloadceph-c4be5a7057a01d2aa8a9a32ad795a1957fe0e6a7.tar.gz
rgw: unlink bucket from user on metadata rm bucket:< bucket>
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/rgw/rgw_bucket.cc31
-rw-r--r--src/rgw/rgw_bucket.h2
-rw-r--r--src/rgw/rgw_op.cc4
-rw-r--r--src/rgw/rgw_rados.cc2
-rw-r--r--src/rgw/rgw_rados.h2
5 files changed, 25 insertions, 16 deletions
diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc
index 1e3a17ae6fe..22727f2558d 100644
--- a/src/rgw/rgw_bucket.cc
+++ b/src/rgw/rgw_bucket.cc
@@ -102,7 +102,7 @@ int rgw_add_bucket(RGWRados *store, string user_id, rgw_bucket& bucket, time_t c
return ret;
}
-int rgw_remove_user_bucket_info(RGWRados *store, string user_id, rgw_bucket& bucket)
+int rgw_remove_user_bucket_info(RGWRados *store, string user_id, const string& bucket_name)
{
int ret;
@@ -112,7 +112,7 @@ int rgw_remove_user_bucket_info(RGWRados *store, string user_id, rgw_bucket& buc
rgw_get_buckets_obj(user_id, buckets_obj_id);
rgw_obj obj(store->zone.user_uid_pool, buckets_obj_id);
- ret = store->omap_del(obj, bucket.name);
+ ret = store->omap_del(obj, bucket_name);
if (ret < 0) {
ldout(store->ctx(), 0) << "ERROR: error removing bucket from directory: "
<< cpp_strerror(-ret)<< dendl;
@@ -350,7 +350,7 @@ int rgw_remove_bucket(RGWRados *store, rgw_bucket& bucket, bool delete_children)
return ret;
}
- ret = rgw_remove_user_bucket_info(store, info.owner, bucket);
+ ret = rgw_remove_user_bucket_info(store, info.owner, bucket.name);
if (ret < 0) {
lderr(store->ctx()) << "ERROR: unable to remove user bucket information" << dendl;
}
@@ -437,7 +437,7 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, std::string *err_msg)
return -EIO;
}
- r = rgw_remove_user_bucket_info(store, owner.get_id(), bucket);
+ r = rgw_remove_user_bucket_info(store, owner.get_id(), bucket.name);
if (r < 0) {
set_err_msg(err_msg, "could not unlink policy from user " + owner.get_id());
return r;
@@ -493,7 +493,7 @@ int RGWBucket::unlink(RGWBucketAdminOpState& op_state, std::string *err_msg)
return -EINVAL;
}
- int r = rgw_remove_user_bucket_info(store, user_info.user_id, bucket);
+ int r = rgw_remove_user_bucket_info(store, user_info.user_id, bucket.name);
if (r < 0) {
set_err_msg(err_msg, "error unlinking bucket" + cpp_strerror(-r));
}
@@ -1389,14 +1389,23 @@ public:
};
int remove(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker) {
- rgw_bucket bucket;
- int r = init_bucket(store, entry, bucket, &objv_tracker);
- if (r < 0) {
- cerr << "could not init bucket=" << entry << std::endl;
- return r;
+ RGWBucketEntryPoint be;
+
+ int ret = store->get_bucket_entrypoint_info(NULL, entry, be, &objv_tracker, NULL);
+ if (ret < 0)
+ return ret;
+
+ ret = rgw_remove_user_bucket_info(store, be.owner, entry);
+ if (ret < 0) {
+ lderr(store->ctx()) << "could not unlink bucket=" << entry << " owner=" << be.owner << dendl;
}
- return store->delete_bucket(bucket, objv_tracker);
+ ret = rgw_bucket_delete_bucket_obj(store, entry, objv_tracker);
+ if (ret < 0) {
+ lderr(store->ctx()) << "could not delete bucket=" << entry << dendl;
+ }
+ /* idempotent */
+ return 0;
}
void get_pool_and_oid(RGWRados *store, string& key, rgw_bucket& bucket, string& oid) {
diff --git a/src/rgw/rgw_bucket.h b/src/rgw/rgw_bucket.h
index 2a87e9b097b..2e6ed69d7ca 100644
--- a/src/rgw/rgw_bucket.h
+++ b/src/rgw/rgw_bucket.h
@@ -100,7 +100,7 @@ extern int rgw_read_user_buckets(RGWRados *store, string user_id, RGWUserBuckets
const string& marker, uint64_t max, bool need_stats);
extern int rgw_add_bucket(RGWRados *store, string user_id, rgw_bucket& bucket, time_t creation_time);
-extern int rgw_remove_user_bucket_info(RGWRados *store, string user_id, rgw_bucket& bucket);
+extern int rgw_remove_user_bucket_info(RGWRados *store, string user_id, const string& bucket_name);
extern int rgw_remove_object(RGWRados *store, rgw_bucket& bucket, std::string& object);
extern int rgw_remove_bucket(RGWRados *store, rgw_bucket& bucket, bool delete_children);
diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc
index d4eaeccdbeb..43d2206eace 100644
--- a/src/rgw/rgw_op.cc
+++ b/src/rgw/rgw_op.cc
@@ -1033,7 +1033,7 @@ void RGWCreateBucket::execute()
ret = rgw_add_bucket(store, s->user.user_id, s->bucket, info.creation_time);
if (ret && !existed && ret != -EEXIST) /* if it exists (or previously existed), don't remove it! */
- rgw_remove_user_bucket_info(store, s->user.user_id, s->bucket);
+ rgw_remove_user_bucket_info(store, s->user.user_id, s->bucket.name);
if (ret == -EEXIST)
ret = -ERR_BUCKET_EXISTS;
@@ -1067,7 +1067,7 @@ void RGWDeleteBucket::execute()
ret = store->delete_bucket(s->bucket, objv_tracker);
if (ret == 0) {
- ret = rgw_remove_user_bucket_info(store, s->user.user_id, s->bucket);
+ ret = rgw_remove_user_bucket_info(store, s->user.user_id, s->bucket.name);
if (ret < 0) {
ldout(s->cct, 0) << "WARNING: failed to remove bucket: ret=" << ret << dendl;
}
diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc
index f54927c4fa2..ad49fc962f4 100644
--- a/src/rgw/rgw_rados.cc
+++ b/src/rgw/rgw_rados.cc
@@ -4701,7 +4701,7 @@ int RGWRados::omap_set(rgw_obj& obj, std::map<std::string, bufferlist>& m)
return r;
}
-int RGWRados::omap_del(rgw_obj& obj, std::string& key)
+int RGWRados::omap_del(rgw_obj& obj, const std::string& key)
{
rgw_bucket bucket;
std::string oid, okey;
diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h
index b9a4a0944a3..3b3ab67f0e6 100644
--- a/src/rgw/rgw_rados.h
+++ b/src/rgw/rgw_rados.h
@@ -1234,7 +1234,7 @@ public:
virtual int omap_get_all(rgw_obj& obj, bufferlist& header, std::map<string, bufferlist>& m);
virtual int omap_set(rgw_obj& obj, std::string& key, bufferlist& bl);
virtual int omap_set(rgw_obj& obj, map<std::string, bufferlist>& m);
- virtual int omap_del(rgw_obj& obj, std::string& key);
+ virtual int omap_del(rgw_obj& obj, const std::string& key);
virtual int update_containers_stats(map<string, RGWBucketEnt>& m);
virtual int append_async(rgw_obj& obj, size_t size, bufferlist& bl);