]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix bug with (un)ordered bucket listing and marker w/ namespace 34609/head
authorJ. Eric Ivancich <ivancich@redhat.com>
Fri, 31 Jan 2020 20:01:40 +0000 (15:01 -0500)
committerNathan Cutler <ncutler@suse.com>
Fri, 17 Apr 2020 12:03:09 +0000 (14:03 +0200)
When listing without specifying a namespace, the returned entries
could be in one or more namespaces. The marker used to continue the
listing may therefore contain a namespace, and that needs to be
preserved. This fixes a bug in both ordered and unordered listings
where it was not preserved.

Signed-off-by: J. Eric Ivancich <ivancich@redhat.com>
(cherry picked from commit 9457abb729754458aafc07a9ee514407906a1011)

Conflicts:
src/rgw/rgw_rados.cc
- trivial (nautilus is missing some whitespace-finessing that happened in master)

src/rgw/rgw_common.h
src/rgw/rgw_rados.cc

index 921a93add942a806e96741a9038c341b9077d008..8f31d7508d65f9690aefd108ceb14ea88be981f2 100644 (file)
@@ -1728,6 +1728,14 @@ struct rgw_obj_key {
     return instance;
   }
 
+  void set_ns(const std::string& _ns) {
+    ns = _ns;
+  }
+
+  const std::string& get_ns() const {
+    return ns;
+  }
+
   string get_index_key_name() const {
     if (ns.empty()) {
       if (name.size() < 1 || name[0] != '_') {
index 427dfbeb0c7a9a1544458237e622f40700ef9b95..1e9b7227739c5dff1b8bf53698e036b1b5a8061d 100644 (file)
@@ -2420,18 +2420,20 @@ int RGWRados::Bucket::List::list_objects_ordered(
 
   result->clear();
 
-  rgw_obj_key marker_obj(params.marker.name, params.marker.instance, params.ns);
+  // use a local marker; either the marker will have a previous entry
+  // or it will be empty; either way it's OK to copy
+  rgw_obj_key marker_obj(params.marker.name, params.marker.instance, params.marker.ns);
   rgw_obj_index_key cur_marker;
   marker_obj.get_index_key(&cur_marker);
 
   rgw_obj_key end_marker_obj(params.end_marker.name, params.end_marker.instance,
-                             params.ns);
+                             params.end_marker.ns);
   rgw_obj_index_key cur_end_marker;
   end_marker_obj.get_index_key(&cur_end_marker);
   const bool cur_end_marker_valid = !params.end_marker.empty();
 
   rgw_obj_key prefix_obj(params.prefix);
-  prefix_obj.ns = params.ns;
+  prefix_obj.set_ns(params.ns);
   string cur_prefix = prefix_obj.get_index_key_name();
   string after_delim_s; /* needed in !params.delim.empty() AND later */
 
@@ -2502,8 +2504,8 @@ int RGWRados::Bucket::List::list_objects_ordered(
       }
 
       if (count < max) {
-        params.marker = index_key;
-        next_marker = index_key;
+       params.marker = index_key;
+       next_marker = index_key;
       }
 
       if (params.filter && !params.filter->filter(obj.name, index_key.name))
@@ -2615,21 +2617,23 @@ int RGWRados::Bucket::List::list_objects_unordered(int64_t max_p,
 
   result->clear();
 
+  // use a local marker; either the marker will have a previous entry
+  // or it will be empty; either way it's OK to copy
   rgw_obj_key marker_obj(params.marker.name,
                         params.marker.instance,
-                        params.ns);
+                        params.marker.ns);
   rgw_obj_index_key cur_marker;
   marker_obj.get_index_key(&cur_marker);
 
   rgw_obj_key end_marker_obj(params.end_marker.name,
                             params.end_marker.instance,
-                             params.ns);
+                            params.end_marker.ns);
   rgw_obj_index_key cur_end_marker;
   end_marker_obj.get_index_key(&cur_end_marker);
   const bool cur_end_marker_valid = !params.end_marker.empty();
 
   rgw_obj_key prefix_obj(params.prefix);
-  prefix_obj.ns = params.ns;
+  prefix_obj.set_ns(params.ns);
   string cur_prefix = prefix_obj.get_index_key_name();
 
   while (truncated && count <= max) {
@@ -2654,6 +2658,11 @@ int RGWRados::Bucket::List::list_objects_unordered(int64_t max_p,
       rgw_obj_index_key index_key = entry.key;
       rgw_obj_key obj(index_key);
 
+      if (count < max) {
+       params.marker.set(index_key);
+       next_marker.set(index_key);
+      }
+
       /* note that parse_raw_oid() here will not set the correct
        * object's instance, as rgw_obj_index_key encodes that
        * separately. We don't need to set the instance because it's
@@ -2681,11 +2690,6 @@ int RGWRados::Bucket::List::list_objects_unordered(int64_t max_p,
        continue;
       }
 
-      if (count < max) {
-       params.marker.set(index_key);
-        next_marker.set(index_key);
-      }
-
       if (params.filter && !params.filter->filter(obj.name, index_key.name))
         continue;