]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix list bucket with delimiter wrongly skip some special keys 30168/head
authorTianshan Qu <tianshan@xsky.com>
Tue, 23 Jul 2019 13:50:15 +0000 (21:50 +0800)
committerNathan Cutler <ncutler@suse.com>
Thu, 5 Sep 2019 08:26:53 +0000 (10:26 +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 32db310a0c96e4735610ef7a14c2c5c743844e8d..2ae8263d995108df19cb79aa52f413d66ad8d621 100644 (file)
@@ -5689,14 +5689,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,
@@ -5777,14 +5769,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++;
           }
 
@@ -5800,6 +5784,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: