]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix list bucket with delimiter wrongly skip some special keys 30068/head
authorTianshan Qu <tianshan@xsky.com>
Tue, 23 Jul 2019 13:50:15 +0000 (21:50 +0800)
committerNathan Cutler <ncutler@suse.com>
Tue, 3 Sep 2019 09:12:41 +0000 (11:12 +0200)
list with delimiter will skip subfile with directory + after_delim_s,
but the code wrongly add after_delim_s to next marker regardless it have directory

Fixes: http://tracker.ceph.com/issues/40905
Signed-off-by: Tianshan Qu <tianshan@xsky.com>
(cherry picked from commit bc82637f54ab466c7dcd9d452da40ab17f206d4e)

Conflicts:
src/rgw/rgw_rados.cc
(trivial context difference)

src/rgw/rgw_rados.cc

index bdea1249c96c83cde43e44dc2893e6d9cd00a018..97caa58bb2228930afadd45f666759cf48f2ce15 100644 (file)
@@ -2446,14 +2446,6 @@ int RGWRados::Bucket::List::list_objects_ordered(
 
   string skip_after_delim;
   while (truncated && count <= max) {
-    if (skip_after_delim > cur_marker.name) {
-      cur_marker = skip_after_delim;
-
-      ldout(cct, 20) << "setting cur_marker="
-                    << cur_marker.name
-                    << "[" << cur_marker.instance << "]"
-                    << dendl;
-    }
     std::map<string, rgw_bucket_dir_entry> ent_map;
     int r = store->cls_bucket_list_ordered(target->get_bucket_info(),
                                           shard_id,
@@ -2535,14 +2527,6 @@ int RGWRados::Bucket::List::list_objects_ordered(
             next_marker = prefix_key;
             (*common_prefixes)[prefix_key] = true;
 
-            int marker_delim_pos = cur_marker.name.find(
-             params.delim, cur_prefix.size());
-
-            skip_after_delim = cur_marker.name.substr(0, marker_delim_pos);
-            skip_after_delim.append(after_delim_s);
-
-            ldout(cct, 20) << "skip_after_delim=" << skip_after_delim << dendl;
-
             count++;
           }
 
@@ -2558,6 +2542,24 @@ int RGWRados::Bucket::List::list_objects_ordered(
       result->emplace_back(std::move(entry));
       count++;
     }
+
+    if (!params.delim.empty()) {
+      int marker_delim_pos = cur_marker.name.find(params.delim, cur_prefix.size());
+      if (marker_delim_pos >= 0) {
+        skip_after_delim = cur_marker.name.substr(0, marker_delim_pos);
+        skip_after_delim.append(after_delim_s);
+
+        ldout(cct, 20) << "skip_after_delim=" << skip_after_delim << dendl;
+
+        if (skip_after_delim > cur_marker.name) {
+          cur_marker = skip_after_delim;
+          ldout(cct, 20) << "setting cur_marker="
+                         << cur_marker.name
+                         << "[" << cur_marker.instance << "]"
+                         << dendl;
+        }
+      }
+    }
   }
 
 done: