]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_admin: fix bi list command
authorYehuda Sadeh <yehuda@redhat.com>
Tue, 27 Sep 2016 18:55:32 +0000 (11:55 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Wed, 19 Oct 2016 15:41:48 +0000 (08:41 -0700)
Changes scoping of json section, and push the --object param in so that
an object can be specified as a filter.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index a32cca59437a44ae9db33d17c73bc13e5c0f1136..58acac3257977219ea28904f51ee5110a124ac4e 100644 (file)
@@ -4664,20 +4664,22 @@ next:
 
     int max_shards = (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1);
 
+    formatter->open_array_section("entries");
+
     for (int i = 0; i < max_shards; i++) {
       RGWRados::BucketShard bs(store);
       int shard_id = (bucket_info.num_shards > 0  ? i : -1);
       int ret = bs.init(bucket, shard_id);
+      marker.clear();
+
       if (ret < 0) {
         cerr << "ERROR: bs.init(bucket=" << bucket << ", shard=" << shard_id << "): " << cpp_strerror(-ret) << std::endl;
         return -ret;
       }
 
-      formatter->open_array_section("entries");
-
       do {
         entries.clear();
-        ret = store->bi_list(bs, marker, max_entries, &entries, &is_truncated);
+        ret = store->bi_list(bs, object, marker, max_entries, &entries, &is_truncated);
         if (ret < 0) {
           cerr << "ERROR: bi_list(): " << cpp_strerror(-ret) << std::endl;
           return -ret;
@@ -4691,9 +4693,10 @@ next:
         }
         formatter->flush(cout);
       } while (is_truncated);
-      formatter->close_section();
       formatter->flush(cout);
     }
+    formatter->close_section();
+    formatter->flush(cout);
   }
 
   if (opt_cmd == OPT_OBJECT_RM) {
@@ -4915,7 +4918,7 @@ next:
       marker.clear();
       while (is_truncated) {
         entries.clear();
-        ret = store->bi_list(bucket, i, marker, max_entries, &entries, &is_truncated);
+        ret = store->bi_list(bucket, i, string(), marker, max_entries, &entries, &is_truncated);
         if (ret < 0) {
           cerr << "ERROR: bi_list(): " << cpp_strerror(-ret) << std::endl;
           return -ret;
index e5cebb648351037111b19c445cfb672cf115dde1..187c446fc120dd51968d089a34b9aa504d065bb8 100644 (file)
@@ -11620,18 +11620,16 @@ int RGWRados::bi_list(rgw_bucket& bucket, const string& obj_name, const string&
   return 0;
 }
 
-int RGWRados::bi_list(BucketShard& bs, const string& marker, uint32_t max, list<rgw_cls_bi_entry> *entries, bool *is_truncated)
+int RGWRados::bi_list(BucketShard& bs, const string& filter_obj, const string& marker, uint32_t max, list<rgw_cls_bi_entry> *entries, bool *is_truncated)
 {
-  string filter_prefix;
-
-  int ret = cls_rgw_bi_list(bs.index_ctx, bs.bucket_obj, filter_prefix, marker, max, entries, is_truncated);
+  int ret = cls_rgw_bi_list(bs.index_ctx, bs.bucket_obj, filter_obj, marker, max, entries, is_truncated);
   if (ret < 0)
     return ret;
 
   return 0;
 }
 
-int RGWRados::bi_list(rgw_bucket& bucket, int shard_id, const string& marker, uint32_t max, list<rgw_cls_bi_entry> *entries, bool *is_truncated)
+int RGWRados::bi_list(rgw_bucket& bucket, int shard_id, const string& filter_obj, const string& marker, uint32_t max, list<rgw_cls_bi_entry> *entries, bool *is_truncated)
 {
   BucketShard bs(this);
   int ret = bs.init(bucket, shard_id);
@@ -11640,7 +11638,7 @@ int RGWRados::bi_list(rgw_bucket& bucket, int shard_id, const string& marker, ui
     return ret;
   }
 
-  return bi_list(bs, marker, max, entries, is_truncated);
+  return bi_list(bs, filter_obj, marker, max, entries, is_truncated);
 }
 
 int RGWRados::gc_operate(string& oid, librados::ObjectWriteOperation *op)
index d228b370c928c6766850043d6f91665ead5beff1..44ebcf7c59d54cd638d8b4f3ff638c56935e2d09 100644 (file)
@@ -2930,8 +2930,8 @@ public:
   void bi_put(librados::ObjectWriteOperation& op, BucketShard& bs, rgw_cls_bi_entry& entry);
   int bi_put(BucketShard& bs, rgw_cls_bi_entry& entry);
   int bi_put(rgw_bucket& bucket, rgw_obj& obj, rgw_cls_bi_entry& entry);
-  int bi_list(rgw_bucket& bucket, int shard_id, const string& marker, uint32_t max, list<rgw_cls_bi_entry> *entries, bool *is_truncated);
-  int bi_list(BucketShard& bs, const string& marker, uint32_t max, list<rgw_cls_bi_entry> *entries, bool *is_truncated);
+  int bi_list(rgw_bucket& bucket, int shard_id, const string& filter_obj, const string& marker, uint32_t max, list<rgw_cls_bi_entry> *entries, bool *is_truncated);
+  int bi_list(BucketShard& bs, const string& filter_obj, const string& marker, uint32_t max, list<rgw_cls_bi_entry> *entries, bool *is_truncated);
   int bi_list(rgw_bucket& bucket, const string& obj_name, const string& marker, uint32_t max,
               list<rgw_cls_bi_entry> *entries, bool *is_truncated);