]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix list bucket with delimiter wrongly skip some special keys 29215/head
authorTianshan Qu <tianshan@xsky.com>
Tue, 23 Jul 2019 13:50:15 +0000 (21:50 +0800)
committerTianshan Qu <tianshan@xsky.com>
Sun, 11 Aug 2019 16:19:54 +0000 (00:19 +0800)
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>
src/rgw/rgw_rados.cc

index e0d064045e52b23d91fa797b89c581f3b245077f..b1436e03bc80f0f37126b552a877a6e92c234b27 100644 (file)
@@ -2446,15 +2446,6 @@ int RGWRados::Bucket::List::list_objects_ordered(int64_t max_p,
 
   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;
-    }
-
     ent_map_t ent_map;
     ent_map.reserve(read_ahead);
     int r = store->cls_bucket_list_ordered(target->get_bucket_info(),
@@ -2538,14 +2529,6 @@ int RGWRados::Bucket::List::list_objects_ordered(int64_t max_p,
             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++;
           }
 
@@ -2561,6 +2544,24 @@ int RGWRados::Bucket::List::list_objects_ordered(int64_t max_p,
       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: