]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: partially expose PGLS filter interface
authorJohn Spray <john.spray@redhat.com>
Fri, 17 Jul 2015 14:32:03 +0000 (15:32 +0100)
committerJohn Spray <john.spray@redhat.com>
Tue, 11 Aug 2015 10:17:18 +0000 (11:17 +0100)
Not bothering with this for non-namespaced object iterator
or the C interface.  Expect to replace this with
the new-style pgls, so just exposing it enough for
cephfs-data-scan to touch the new osd-side pgls filtering
on forward scrub tags.

Signed-off-by: John Spray <john.spray@redhat.com>
src/include/rados/librados.hpp
src/librados/ListObjectImpl.h
src/librados/librados.cc

index 175a22d105ac3d87c13d292ce41a5738f641d0d5..dfe22e9226c68a62da9325b63d83b7340f3c7983 100644 (file)
@@ -109,6 +109,12 @@ namespace librados
     /// move the iterator to a given hash position.  this may (will!) be rounded to the nearest pg.
     uint32_t seek(uint32_t pos);
 
+    /**
+     * Configure PGLS filter to be applied OSD-side (requires caller
+     * to know/understand the format expected by the OSD)
+     */
+    void set_filter(const bufferlist &bl);
+
   private:
     NObjectIterator(ObjListCtx *ctx_);
     void get_next();
@@ -765,9 +771,10 @@ namespace librados
 
 
     /// Start enumerating objects for a pool
-    NObjectIterator nobjects_begin();
+    NObjectIterator nobjects_begin(const bufferlist &filter=bufferlist());
     /// Start enumerating objects for a pool starting from a hash position
-    NObjectIterator nobjects_begin(uint32_t start_hash_position);
+    NObjectIterator nobjects_begin(uint32_t start_hash_position,
+                                   const bufferlist &filter=bufferlist());
     /// Iterator indicating the end of a pool
     const NObjectIterator& nobjects_end() const;
 
index fe52f68075a1f4a30e972a0954489cf623f2e640..bda275f7f5c37e99f9df5f94d56a95cf95850a49 100644 (file)
@@ -67,6 +67,8 @@ class NObjectIteratorImpl {
     /// move the iterator to a given hash position.  this may (will!) be rounded to the nearest pg.
     uint32_t seek(uint32_t pos);
 
+    void set_filter(const bufferlist &bl);
+
   private:
     NObjectIteratorImpl(ObjListCtx *ctx_);
     void get_next();
index 5a86cdec4c050c0573e8cace65aec40922f93d7d..6418ae23054d93a7c1517d27060acc54f68b826f 100644 (file)
@@ -624,6 +624,18 @@ uint32_t librados::NObjectIteratorImpl::seek(uint32_t pos)
   return r;
 }
 
+void librados::NObjectIteratorImpl::set_filter(const bufferlist &bl)
+{
+  assert(ctx);
+  if (ctx->nlc) {
+    ctx->nlc->filter = bl;
+  }
+
+  if (ctx->lc) {
+    ctx->lc->filter = bl;
+  }
+}
+
 void librados::NObjectIteratorImpl::get_next()
 {
   const char *entry, *key, *nspace;
@@ -737,6 +749,11 @@ uint32_t librados::NObjectIterator::seek(uint32_t pos)
   return impl->seek(pos);
 }
 
+void librados::NObjectIterator::set_filter(const bufferlist &bl)
+{
+  impl->set_filter(bl);
+}
+
 void librados::NObjectIterator::get_next()
 {
   assert(impl);
@@ -1535,20 +1552,28 @@ int librados::IoCtx::list_lockers(const std::string &oid, const std::string &nam
   return tmp_lockers.size();
 }
 
-librados::NObjectIterator librados::IoCtx::nobjects_begin()
+librados::NObjectIterator librados::IoCtx::nobjects_begin(
+    const bufferlist &filter)
 {
   rados_list_ctx_t listh;
   rados_nobjects_list_open(io_ctx_impl, &listh);
   NObjectIterator iter((ObjListCtx*)listh);
+  if (filter.length() > 0) {
+    iter.set_filter(filter);
+  }
   iter.get_next();
   return iter;
 }
 
-librados::NObjectIterator librados::IoCtx::nobjects_begin(uint32_t pos)
+librados::NObjectIterator librados::IoCtx::nobjects_begin(
+  uint32_t pos, const bufferlist &filter)
 {
   rados_list_ctx_t listh;
   rados_nobjects_list_open(io_ctx_impl, &listh);
   NObjectIterator iter((ObjListCtx*)listh);
+  if (filter.length() > 0) {
+    iter.set_filter(filter);
+  }
   iter.seek(pos);
   return iter;
 }