From d0e14d211b3dc807598bb8d2bd951bf332d63033 Mon Sep 17 00:00:00 2001 From: "J. Eric Ivancich" Date: Wed, 8 May 2019 14:47:04 -0400 Subject: [PATCH] rgw: allow radosgw-admin to list bucket w --allow-unordered Presently the `radosgw-admin bucket list --bucket=` lists the objects in lexical order. This can be an expensive operation since objects are not stored in bucket index shards in order and a selection sort process is done across all bucket index shards. By allowing the user to add the "--allow-unordered" command-line flag, a more efficient bucket listing is enabled. This is particularly important for buckets with a large number of objects. Signed-off-by: J. Eric Ivancich (cherry picked from commit 12452c4a91ee56c10d3dcf970dd2b0dd5aeb2401) --- doc/man/8/radosgw-admin.rst | 5 ++++- src/rgw/rgw_admin.cc | 7 ++++++- src/test/cli/radosgw-admin/help.t | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/man/8/radosgw-admin.rst b/doc/man/8/radosgw-admin.rst index 9135a5e05a74..e0778455fdc5 100644 --- a/doc/man/8/radosgw-admin.rst +++ b/doc/man/8/radosgw-admin.rst @@ -75,7 +75,10 @@ which are as follows: Remove access key. :command:`bucket list` - List all buckets. + List buckets, or, if bucket specified with --bucket=, + list its objects. If bucket specified adding --allow-unordered + removes ordering requirement, possibly generating results more + quickly in buckets with large number of objects. :command:`bucket limit check` Show bucket sharding stats. diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index fca87dd8f345..551311831c2b 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -79,7 +79,8 @@ void usage() cout << " subuser rm remove subuser\n"; cout << " key create create access key\n"; cout << " key rm remove access key\n"; - cout << " bucket list list buckets\n"; + cout << " bucket list list buckets (specify --allow-unordered for\n"; + cout << " faster, unsorted listing)\n"; cout << " bucket limit check show bucket sharding stats\n"; cout << " bucket link link bucket to specified user\n"; cout << " bucket unlink unlink bucket from specified user\n"; @@ -2781,6 +2782,7 @@ int main(int argc, const char **argv) bool have_max_objects = false; bool have_max_size = false; int include_all = false; + int allow_unordered = false; int sync_stats = false; int reset_stats = false; @@ -3027,6 +3029,8 @@ int main(int argc, const 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, &allow_unordered, NULL, "--allow-unordered", (char*)NULL)) { + // do nothing } else if (ceph_argparse_binary_flag(args, i, &extra_info, NULL, "--extra-info", (char*)NULL)) { // do nothing } else if (ceph_argparse_binary_flag(args, i, &bypass_gc, NULL, "--bypass-gc", (char*)NULL)) { @@ -5412,6 +5416,7 @@ int main(int argc, const char **argv) list_op.params.ns = ns; list_op.params.enforce_ns = false; list_op.params.list_versions = true; + list_op.params.allow_unordered = bool(allow_unordered); do { ret = list_op.list_objects(max_entries - count, &result, &common_prefixes, &truncated); diff --git a/src/test/cli/radosgw-admin/help.t b/src/test/cli/radosgw-admin/help.t index 912c500c54b3..eb9260bfee31 100644 --- a/src/test/cli/radosgw-admin/help.t +++ b/src/test/cli/radosgw-admin/help.t @@ -17,7 +17,8 @@ subuser rm remove subuser key create create access key key rm remove access key - bucket list list buckets + bucket list list buckets (specify --allow-unordered for + faster, unsorted listing) bucket limit check show bucket sharding stats bucket link link bucket to specified user bucket unlink unlink bucket from specified user -- 2.47.3