From 716d096bbb8e836aefa6a451b799389d3bd85620 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 27 Sep 2016 11:55:32 -0700 Subject: [PATCH] rgw_admin: fix bi list command 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 --- src/rgw/rgw_admin.cc | 13 ++++++++----- src/rgw/rgw_rados.cc | 10 ++++------ src/rgw/rgw_rados.h | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index a32cca59437a4..58acac3257977 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -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; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index e5cebb6483510..187c446fc120d 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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 *entries, bool *is_truncated) +int RGWRados::bi_list(BucketShard& bs, const string& filter_obj, const string& marker, uint32_t max, list *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 *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 *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) diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index d228b370c928c..44ebcf7c59d54 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -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 *entries, bool *is_truncated); - int bi_list(BucketShard& bs, const string& marker, uint32_t max, list *entries, bool *is_truncated); + int bi_list(rgw_bucket& bucket, int shard_id, const string& filter_obj, const string& marker, uint32_t max, list *entries, bool *is_truncated); + int bi_list(BucketShard& bs, const string& filter_obj, const string& marker, uint32_t max, list *entries, bool *is_truncated); int bi_list(rgw_bucket& bucket, const string& obj_name, const string& marker, uint32_t max, list *entries, bool *is_truncated); -- 2.39.5