From a993f8db928e21495b4efc9e695ccc4f15d55f37 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Tue, 13 Nov 2018 16:51:25 -0500 Subject: [PATCH] rgw: list_buckets_* catches NObjectIterator exceptions Signed-off-by: Casey Bodley (cherry picked from commit 29fcd5386940b20b21b08f217fb2abb57d7e7b32) --- src/rgw/rgw_rados.cc | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 7c1fbb17e2c70..45efa03213d4d 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -4920,9 +4920,21 @@ int RGWRados::open_bucket_index_ctx(const RGWBucketInfo& bucket_info, librados:: */ int RGWRados::list_buckets_init(RGWAccessHandle *handle) { - librados::NObjectIterator *state = new librados::NObjectIterator(root_pool_ctx.nobjects_begin()); - *handle = (RGWAccessHandle)state; - return 0; + try { + auto iter = root_pool_ctx.nobjects_begin(); + librados::NObjectIterator *state = new librados::NObjectIterator(iter); + *handle = (RGWAccessHandle)state; + return 0; + } catch (const std::system_error& e) { + int r = -e.code().value(); + ldout(cct, 10) << "nobjects_begin threw " << e.what() + << ", returning " << r << dendl; + return r; + } catch (const std::exception& e) { + ldout(cct, 10) << "nobjects_begin threw " << e.what() + << ", returning -5" << dendl; + return -EIO; + } } /** @@ -4945,8 +4957,18 @@ int RGWRados::list_buckets_next(rgw_bucket_dir_entry& obj, RGWAccessHandle *hand if (obj.key.name[0] == '_') { obj.key.name = obj.key.name.substr(1); } - - (*state)++; + try { + (*state)++; + } catch (const std::system_error& e) { + int r = -e.code().value(); + ldout(cct, 10) << "nobjects_begin threw " << e.what() + << ", returning " << r << dendl; + return r; + } catch (const std::exception& e) { + ldout(cct, 10) << "nobjects_begin threw " << e.what() + << ", returning -5" << dendl; + return -EIO; + } } while (obj.key.name[0] == '.'); /* skip all entries starting with '.' */ return 0; -- 2.39.5