]> 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)
committerRobin H. Johnson <robin.johnson@dreamhost.com>
Thu, 9 Feb 2017 22:36:51 +0000 (14:36 -0800)
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>
(cherry picked from commit 716d096bbb8e836aefa6a451b799389d3bd85620)
See: http://tracker.ceph.com/issues/17556
See: https://github.com/ceph/ceph/pull/11368
Signed-off-by: Robin H. Johnson <robin.johnson@dreamhost.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index f3cbbebc77bb03fe9705a032bf5df60fb18ca67d..b04aabc65aa00e0fbf08629cdc6ad07050dd06f3 100644 (file)
@@ -4835,20 +4835,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;
@@ -4862,9 +4864,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) {
@@ -5086,7 +5089,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 ef33c84dbfba8c3bf2d9ffd8431a90360dcb4e91..364f30c218a57dc3ab090c2fc86145480eeb11bd 100644 (file)
@@ -11366,18 +11366,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);
@@ -11386,7 +11384,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 5dd03e7d4ef1b0c457c5427517a658bc51cdaac6..3e20f5970bfa2ceac2cf2d025c17023a475c8537 100644 (file)
@@ -2844,8 +2844,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);