]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: extend replica log api (purge-all)
authorYehuda Sadeh <yehuda@inktank.com>
Mon, 12 May 2014 21:46:18 +0000 (14:46 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Wed, 28 Jan 2015 00:32:02 +0000 (16:32 -0800)
Adding a new purge-all option for the replica log api, which completely
removes a replica log object.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_replica_log.cc
src/rgw/rgw_replica_log.h
src/rgw/rgw_rest_replica_log.cc

index cc893fd9b509fd0b0d6409800e8369ebc5b2089d..31eb2e510084241f3a1c4c42f580d2d2e53e025c 100644 (file)
@@ -2598,7 +2598,7 @@ next:
         return EINVAL;
       }
       RGWReplicaObjectLogger logger(store, pool_name, META_REPLICA_LOG_OBJ_PREFIX);
-      int ret = logger.delete_bound(shard_id, daemon_id);
+      int ret = logger.delete_bound(shard_id, daemon_id, false);
       if (ret < 0)
         return -ret;
     } else if (replica_log_type == ReplicaLog_Data) {
@@ -2611,7 +2611,7 @@ next:
         return EINVAL;
       }
       RGWReplicaObjectLogger logger(store, pool_name, DATA_REPLICA_LOG_OBJ_PREFIX);
-      int ret = logger.delete_bound(shard_id, daemon_id);
+      int ret = logger.delete_bound(shard_id, daemon_id, false);
       if (ret < 0)
         return -ret;
     } else if (replica_log_type == ReplicaLog_Bucket) {
@@ -2627,7 +2627,7 @@ next:
       }
 
       RGWReplicaBucketLogger logger(store);
-      ret = logger.delete_bound(bucket, shard_id, daemon_id, replicalog_index_by_instance);
+      ret = logger.delete_bound(bucket, shard_id, daemon_id, replicalog_index_by_instance, false);
       if (ret < 0)
         return -ret;
     }
index a9a3b711ee72beded035ca9fbae0ea91265d9a96..f88b132bd29f8aaa5468304a89224ca97ae7f234 100644 (file)
@@ -76,7 +76,7 @@ int RGWReplicaLogger::update_bound(const string& oid, const string& pool,
 }
 
 int RGWReplicaLogger::delete_bound(const string& oid, const string& pool,
-                                   const string& daemon_id)
+                                   const string& daemon_id, bool purge_all)
 {
   librados::IoCtx ioctx;
   int r = open_ioctx(ioctx, pool);
@@ -84,6 +84,10 @@ int RGWReplicaLogger::delete_bound(const string& oid, const string& pool,
     return r;
   }
 
+  if (purge_all) {
+    return ioctx.remove(oid);
+  }
+
   librados::ObjectWriteOperation opw;
   cls_replica_log_delete_bound(opw, daemon_id);
   return ioctx.operate(oid, &opw);
index 544030a2ae0d363341ae1174c2d3eed4d8855958..16209a08a7b1240b81475c470c962ecb654e30b5 100644 (file)
@@ -52,7 +52,7 @@ protected:
                    const utime_t& time,
                    const list<RGWReplicaItemMarker> *entries);
   int delete_bound(const string& oid, const string& pool,
-                   const string& daemon_id);
+                   const string& daemon_id, bool purge_all);
   int get_bounds(const string& oid, const string& pool,
                  RGWReplicaBounds& bounds);
 };
@@ -81,11 +81,11 @@ public:
     return RGWReplicaLogger::update_bound(oid, pool,
                                           daemon_id, marker, time, entries);
   }
-  int delete_bound(int shard, const string& daemon_id) {
+  int delete_bound(int shard, const string& daemon_id, bool purge_all) {
     string oid;
     get_shard_oid(shard, oid);
     return RGWReplicaLogger::delete_bound(oid, pool,
-                                          daemon_id);
+                                          daemon_id, purge_all);
   }
   int get_bounds(int shard, RGWReplicaBounds& bounds) {
     string oid;
@@ -105,9 +105,9 @@ public:
   int update_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id,
                    const string& marker, const utime_t& time,
                    const list<RGWReplicaItemMarker> *entries);
-  int delete_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id, bool index_by_instance) {
+  int delete_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id, bool index_by_instance, bool purge_all) {
     return RGWReplicaLogger::delete_bound(obj_name(bucket, shard_id, index_by_instance), pool,
-                                          daemon_id);
+                                          daemon_id, purge_all);
   }
   int get_bounds(const rgw_bucket& bucket, int shard_id, RGWReplicaBounds& bounds, bool index_by_instance) {
     return RGWReplicaLogger::get_bounds(obj_name(bucket, shard_id, index_by_instance), pool,
index f842d90bff8c3606d0c5143bfebfb79aedd5cece..2f6d760fddbf0f9038548baf98e813503290e76e 100644 (file)
@@ -121,9 +121,12 @@ void RGWOp_OBJLog_GetBounds::send_response() {
 void RGWOp_OBJLog_DeleteBounds::execute() {
   string id = s->info.args.get("id"),
          daemon_id = s->info.args.get("daemon_id");
+  bool purge_all;
+
+  s->info.args.get_bool("purge-all", &purge_all, false);
 
   if (id.empty() ||
-      daemon_id.empty()) {
+      (!purge_all && daemon_id.empty())) {
     dout(5) << "Error - invalid parameter list" << dendl;
     http_ret = -EINVAL;
     return;
@@ -137,10 +140,10 @@ void RGWOp_OBJLog_DeleteBounds::execute() {
     dout(5) << "Error parsing id parameter - " << id << ", err " << err << dendl;
     http_ret = -EINVAL;
   }
-  
+
   string pool;
   RGWReplicaObjectLogger rl(store, pool, prefix);
-  http_ret = rl.delete_bound(shard, daemon_id);
+  http_ret = rl.delete_bound(shard, daemon_id, purge_all);
 }
 
 static int bucket_instance_to_bucket(RGWRados *store, string& bucket_instance, rgw_bucket& bucket) {
@@ -286,8 +289,11 @@ void RGWOp_BILog_GetBounds::send_response() {
 void RGWOp_BILog_DeleteBounds::execute() {
   string bucket_instance = s->info.args.get("bucket-instance");
   string daemon_id = s->info.args.get("daemon_id");
+  bool purge_all;
 
-  if (daemon_id.empty()) {
+  s->info.args.get_bool("purge-all", &purge_all, false);
+
+  if (daemon_id.empty() && !purge_all) {
     dout(5) << "Error - invalid parameter list" << dendl;
     http_ret = -EINVAL;
     return;
@@ -306,9 +312,10 @@ void RGWOp_BILog_DeleteBounds::execute() {
   if ((http_ret = get_bucket_for_bounds(store, s->info.args, bucket, &index_by_instance)) < 0) {
     return;
   }
-  
+
+
   RGWReplicaBucketLogger rl(store);
-  http_ret = rl.delete_bound(bucket, shard_id, daemon_id, index_by_instance);
+  http_ret = rl.delete_bound(bucket, shard_id, daemon_id, index_by_instance, purge_all);
 }
 
 RGWOp *RGWHandler_ReplicaLog::op_get() {