]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add support for end_marker for GET on Swift container. 4224/head
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Mon, 30 Mar 2015 13:00:59 +0000 (15:00 +0200)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Tue, 7 Apr 2015 14:55:29 +0000 (16:55 +0200)
Fixes: #10682
Backport: hammer
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_common.h
src/rgw/rgw_op.cc
src/rgw/rgw_op.h
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_rest_swift.cc

index 0a796c08deaf4bcba2e4d574b650e4fc0cd74163..a26d96e7c0fe26ea0d2a49f7fc00d15f943ef00e 100644 (file)
@@ -967,6 +967,9 @@ struct rgw_obj_key {
     }
     return (r < 0);
   }
+  bool operator<=(const rgw_obj_key& k) const {
+    return !(k < *this);
+  }
   void encode(bufferlist& bl) const {
     ENCODE_START(1, 1, bl);
     ::encode(name, bl);
index 24f85ac4da5f0f1a0f0f4f6178bb561b01f245b0..b499a03790b1b2097e736f38c82d6069dcdcfcce 100644 (file)
@@ -1227,6 +1227,7 @@ void RGWListBucket::execute()
   list_op.params.prefix = prefix;
   list_op.params.delim = delimiter;
   list_op.params.marker = marker;
+  list_op.params.end_marker = end_marker;
   list_op.params.list_versions = list_versions;
 
   ret = list_op.list_objects(max, &objs, &common_prefixes, &is_truncated);
index e5c1fde009a8bc98c29ba63875b2fed574743fdc..c036b78a06dbf40018e6d52af31293b2d65b6d20 100644 (file)
@@ -249,6 +249,7 @@ protected:
   string prefix;
   rgw_obj_key marker; 
   rgw_obj_key next_marker; 
+  rgw_obj_key end_marker;
   string max_keys;
   string delimiter;
   bool list_versions;
index 5183747aff33b62292de14d4f438bd900a9f37cc..9ee56f82dd26ac72d2c8c22dfc830f82632324b7 100644 (file)
@@ -2315,6 +2315,7 @@ int rgw_policy_from_attrset(CephContext *cct, map<string, bufferlist>& attrset,
  *     Any skipped results will have the matching portion of their name
  *     inserted in common_prefixes with a "true" mark.
  * marker: if filled in, begin the listing with this object.
+ * end_marker: if filled in, end the listing with this object.
  * result: the objects are put in here.
  * common_prefixes: if delim is filled in, any matching prefixes are placed
  *     here.
@@ -2335,13 +2336,20 @@ int RGWRados::Bucket::List::list_objects(int max, vector<RGWObjEnt> *result,
   }
   result->clear();
 
-  rgw_obj marker_obj, prefix_obj;
+  rgw_obj marker_obj, end_marker_obj, prefix_obj;
   marker_obj.set_instance(params.marker.instance);
   marker_obj.set_ns(params.ns);
   marker_obj.set_obj(params.marker.name);
   rgw_obj_key cur_marker;
   marker_obj.get_index_key(&cur_marker);
 
+  end_marker_obj.set_instance(params.end_marker.instance);
+  end_marker_obj.set_ns(params.ns);
+  end_marker_obj.set_obj(params.end_marker.name);
+  rgw_obj_key cur_end_marker;
+  end_marker_obj.get_index_key(&cur_end_marker);
+  const bool cur_end_marker_valid = !cur_end_marker.empty();
+
   prefix_obj.set_ns(params.ns);
   prefix_obj.set_obj(params.prefix);
   string cur_prefix = prefix_obj.get_index_key_name();
@@ -2407,6 +2415,11 @@ int RGWRados::Bucket::List::list_objects(int max, vector<RGWObjEnt> *result,
         continue;
       }
 
+      if (cur_end_marker_valid && cur_end_marker <= obj) {
+        truncated = false;
+        goto done;
+      }
+
       if (count < max) {
         params.marker = obj;
         next_marker = obj;
index a3fd6c09d73795e83229b5fd898b53c8e12ae85e..47fa126e1c2514f98d5678a60685276ae85c8c5a 100644 (file)
@@ -1641,6 +1641,7 @@ public:
         string prefix;
         string delim;
         rgw_obj_key marker;
+        rgw_obj_key end_marker;
         string ns;
         bool enforce_ns;
         RGWAccessListFilter *filter;
index fb59e4f854d8c02523302084d0c14531a9276397..0e4a133f9f97b04d6a18b4bfa6b1e792770e5457 100644 (file)
@@ -117,6 +117,7 @@ int RGWListBucket_ObjStore_SWIFT::get_params()
 {
   prefix = s->info.args.get("prefix");
   marker = s->info.args.get("marker");
+  end_marker = s->info.args.get("end_marker");
   max_keys = s->info.args.get("limit");
   ret = parse_max_keys();
   if (ret < 0) {