]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: get rid of replicalog index_by_instance param
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 29 Jan 2015 00:10:34 +0000 (16:10 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 29 Jan 2015 00:10:34 +0000 (16:10 -0800)
We convert old entries anyway, just complicates everything. Only use
that was kept is the one needed for the conversion function.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.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 a20e170447589d894f258d849465e72744f95a39..ad4122cd5570f5cf514bc0e2578c0bfbd0ca64a0 100644 (file)
@@ -897,8 +897,6 @@ int main(int argc, char **argv)
 
   int sync_stats = false;
 
-  int replicalog_index_by_instance = true;
-
   uint64_t min_rewrite_size = 4 * 1024 * 1024;
   uint64_t max_rewrite_size = ULLONG_MAX;
   uint64_t min_rewrite_stripe_size = 0;
@@ -1048,8 +1046,6 @@ int main(int argc, char **argv)
      // do nothing
     } else if (ceph_argparse_binary_flag(args, i, &include_all, NULL, "--include-all", (char*)NULL)) {
      // do nothing
-    } else if (ceph_argparse_binary_flag(args, i, &replicalog_index_by_instance, NULL, "--replicalog-index-by-instance", (char*)NULL)) {
-     // do nothing
     } else if (ceph_argparse_witharg(args, i, &val, "--caps", (char*)NULL)) {
       caps = val;
     } else if (ceph_argparse_witharg(args, i, &val, "-i", "--infile", (char*)NULL)) {
@@ -2581,7 +2577,7 @@ next:
       }
 
       RGWReplicaBucketLogger logger(store);
-      ret = logger.get_bounds(bucket, shard_id, bounds, replicalog_index_by_instance);
+      ret = logger.get_bounds(bucket, shard_id, bounds);
       if (ret < 0)
         return -ret;
     } else { // shouldn't get here
@@ -2632,7 +2628,7 @@ next:
       }
 
       RGWReplicaBucketLogger logger(store);
-      ret = logger.delete_bound(bucket, shard_id, daemon_id, replicalog_index_by_instance, false);
+      ret = logger.delete_bound(bucket, shard_id, daemon_id, false);
       if (ret < 0)
         return -ret;
     }
@@ -2694,7 +2690,7 @@ next:
       }
 
       RGWReplicaBucketLogger logger(store);
-      ret = logger.update_bound(bucket, shard_id, daemon_id, marker, time, &entries, replicalog_index_by_instance);
+      ret = logger.update_bound(bucket, shard_id, daemon_id, marker, time, &entries);
       if (ret < 0) {
         cerr << "ERROR: failed to update bounds: " << cpp_strerror(-ret) << std::endl;
         return -ret;
index 747cce68cd2f02a6bc36411547abaac9d6dcf734..977b2ef96c637cef9f920dc8ce7cf28d796bd0d1 100644 (file)
@@ -191,8 +191,7 @@ string RGWReplicaBucketLogger::obj_name(const rgw_bucket& bucket, int shard_id,
 
 int RGWReplicaBucketLogger::update_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id,
                    const string& marker, const utime_t& time,
-                   const list<RGWReplicaItemMarker> *entries,
-                   bool index_by_instance)
+                   const list<RGWReplicaItemMarker> *entries)
 {
   if (shard_id >= 0 ||
       !BucketIndexShardsManager::is_shards_marker(marker)) {
@@ -216,11 +215,11 @@ int RGWReplicaBucketLogger::update_bound(const rgw_bucket& bucket, int shard_id,
 
   map<int, string>::iterator iter;
   for (iter = vals.begin(); iter != vals.end(); ++iter) {
-    bool need_to_exist = index_by_instance && no_shards; /*
-                                                          * don't need to exist if not indexing by instance,
-                                                          * also, we only care about non-sharded
+    bool need_to_exist = no_shards; /*
+                                                          * we only care about non-sharded
                                                           * buckets, as these are the ones that
-                                                          * might not be indexed by instance id
+                                                          * might not be indexed by instance id, and
+                                                          * might need conversion
                                                           */
     ldout(cct, 20) << "updating bound: bucket=" << bucket << " shard=" << iter->first << " marker=" << marker << dendl;
     int r = RGWReplicaLogger::update_bound(obj_name(bucket, iter->first, true), pool,
@@ -245,10 +244,10 @@ int RGWReplicaBucketLogger::update_bound(const rgw_bucket& bucket, int shard_id,
   return ret;
 }
 
-int RGWReplicaBucketLogger::delete_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id, bool index_by_instance, bool purge_all)
+int RGWReplicaBucketLogger::delete_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id, bool purge_all)
 {
-  bool need_to_exist = index_by_instance; /* don't need to exist if not indexing by instance */
-  int r = RGWReplicaLogger::delete_bound(obj_name(bucket, shard_id, index_by_instance), pool, daemon_id, purge_all, need_to_exist);
+  bool need_to_exist = (shard_id < 0); /* don't need to exist if sharded */
+  int r = RGWReplicaLogger::delete_bound(obj_name(bucket, shard_id, true), pool, daemon_id, purge_all, need_to_exist);
   if (r != -ENOENT) {
     return r;
   }
@@ -261,12 +260,12 @@ int RGWReplicaBucketLogger::delete_bound(const rgw_bucket& bucket, int shard_id,
   if (r < 0 && r != -ENOENT) {
     return r;
   }
-  return RGWReplicaLogger::delete_bound(obj_name(bucket, shard_id, index_by_instance), pool, daemon_id, purge_all, false);
+  return RGWReplicaLogger::delete_bound(obj_name(bucket, shard_id, true), pool, daemon_id, purge_all, false);
 }
 
-int RGWReplicaBucketLogger::get_bounds(const rgw_bucket& bucket, int shard_id, RGWReplicaBounds& bounds, bool index_by_instance) {
-  int r = RGWReplicaLogger::get_bounds(obj_name(bucket, shard_id, index_by_instance), pool, bounds);
-  if (r != -ENOENT || !index_by_instance) {
+int RGWReplicaBucketLogger::get_bounds(const rgw_bucket& bucket, int shard_id, RGWReplicaBounds& bounds) {
+  int r = RGWReplicaLogger::get_bounds(obj_name(bucket, shard_id, true), pool, bounds);
+  if (r != -ENOENT || shard_id >= 0) {
     return r;
   }
 
@@ -275,7 +274,7 @@ int RGWReplicaBucketLogger::get_bounds(const rgw_bucket& bucket, int shard_id, R
     return r;
   }
 
-  return 0;
+  return RGWReplicaLogger::get_bounds(obj_name(bucket, shard_id, true), pool, bounds);
 }
 
 int RGWReplicaBucketLogger::convert_old_bounds(const rgw_bucket& bucket, int shard_id, RGWReplicaBounds& bounds) {
index b00080037f2aeb15256df8748e9316a27634378d..9ea3982ee559366efd10922d584c2c5d5194d552 100644 (file)
@@ -108,10 +108,9 @@ public:
   RGWReplicaBucketLogger(RGWRados *_store);
   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,
-                   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);
-  int get_bounds(const rgw_bucket& bucket, int shard_id, RGWReplicaBounds& bounds, bool index_by_instance);
+                   const list<RGWReplicaItemMarker> *entries);
+  int delete_bound(const rgw_bucket& bucket, int shard_id, const string& daemon_id, bool purge_all);
+  int get_bounds(const rgw_bucket& bucket, int shard_id, RGWReplicaBounds& bounds);
   int convert_old_bounds(const rgw_bucket& bucket, int shard_id, RGWReplicaBounds& bounds);
 };
 
index 543974a455c492749ef33a70cc590176490fdd26..aef3311c2af83b01cbfe08f3c377865e880afa30 100644 (file)
@@ -162,46 +162,6 @@ static int bucket_instance_to_bucket(RGWRados *store, const string& bucket_insta
   return 0;
 }
 
-static int get_bucket_for_bounds(RGWRados *store, XMLArgs& args, const string& bucket_instance, rgw_bucket& bucket, bool *index_by_instance)
-{
-  args.get_bool("index-by-instance", index_by_instance, true);
-
-  if (*index_by_instance) {
-    int r;
-    if ((r = bucket_instance_to_bucket(store, bucket_instance, bucket)) < 0)  {
-      return r;
-    }
-  } else {
-    string bucket_name = args.get("bucket");
-
-    if (bucket_name.empty()) {
-      bucket_name = bucket_instance;
-
-      ssize_t pos = bucket_name.find(':');
-      if (pos >= 0) {
-        bucket_name = bucket_name.substr(0, pos);
-      }
-    }
-
-    if (bucket_name.empty()) {
-      dout(5) << " Error - invalid parameter list" << dendl;
-      return -EINVAL;
-    }
-    RGWBucketInfo bucket_info;
-  
-    int r = store->get_bucket_info(NULL, bucket_name, bucket_info, NULL, NULL);
-    if (r < 0) {
-      dout(5) << "could not get bucket info for bucket=" << bucket_name << ": " << cpp_strerror(r) << dendl;
-      return r;
-    }
-
-    bucket = bucket_info.bucket;
-  }
-
-  return 0;
-
-}
-
 void RGWOp_BILog_SetBounds::execute() {
   string bucket_instance = s->info.args.get("bucket-instance"),
          marker = s->info.args.get("marker"),
@@ -231,9 +191,8 @@ void RGWOp_BILog_SetBounds::execute() {
   }
 
   rgw_bucket bucket;
-  bool index_by_instance;
 
-  if ((http_ret = get_bucket_for_bounds(store, s->info.args, bucket_instance, bucket, &index_by_instance)) < 0) {
+  if ((http_ret = bucket_instance_to_bucket(store, bucket_instance, bucket)) < 0) {
     return;
   }
   
@@ -246,13 +205,12 @@ void RGWOp_BILog_SetBounds::execute() {
     return;
   }
 
-  http_ret = rl.update_bound(bucket, shard_id, daemon_id, marker, ut, &markers, index_by_instance);
+  http_ret = rl.update_bound(bucket, shard_id, daemon_id, marker, ut, &markers);
 }
 
 void RGWOp_BILog_GetBounds::execute() {
   string bucket_instance = s->info.args.get("bucket-instance");
   rgw_bucket bucket;
-  bool index_by_instance;
 
   int shard_id;
 
@@ -262,15 +220,11 @@ void RGWOp_BILog_GetBounds::execute() {
     return;
   }
 
-  if ((http_ret = get_bucket_for_bounds(store, s->info.args, bucket_instance, bucket, &index_by_instance)) < 0) {
-    return;
-  }
-
   if ((http_ret = bucket_instance_to_bucket(store, bucket_instance, bucket)) < 0) 
     return;
 
   RGWReplicaBucketLogger rl(store);
-  http_ret = rl.get_bounds(bucket, shard_id, bounds, index_by_instance);
+  http_ret = rl.get_bounds(bucket, shard_id, bounds);
 }
 
 void RGWOp_BILog_GetBounds::send_response() {
@@ -306,14 +260,13 @@ void RGWOp_BILog_DeleteBounds::execute() {
   }
 
   rgw_bucket bucket;
-  bool index_by_instance;
 
-  if ((http_ret = get_bucket_for_bounds(store, s->info.args, bucket_instance, bucket, &index_by_instance)) < 0) {
+  if ((http_ret = bucket_instance_to_bucket(store, bucket_instance, bucket)) < 0) {
     return;
   }
 
   RGWReplicaBucketLogger rl(store);
-  http_ret = rl.delete_bound(bucket, shard_id, daemon_id, index_by_instance, purge_all);
+  http_ret = rl.delete_bound(bucket, shard_id, daemon_id, purge_all);
 }
 
 RGWOp *RGWHandler_ReplicaLog::op_get() {