]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: add RADOS C interfaces for pin/unpin object
authorZhiqiang Wang <zhiqiang.wang@intel.com>
Wed, 11 Mar 2015 08:52:23 +0000 (16:52 +0800)
committerSage Weil <sage@redhat.com>
Tue, 20 Oct 2015 14:36:09 +0000 (10:36 -0400)
Signed-off-by: Zhiqiang Wang <zhiqiang.wang@intel.com>
src/include/rados/librados.h
src/librados/librados.cc

index 3aebf208a482191229d8e0b25f25c0e5ae17d1b2..5d4ac753a9607b8679609d35982b60b97c13f0f0 100644 (file)
@@ -2136,6 +2136,29 @@ CEPH_RADOS_API int rados_watch_flush(rados_t cluster);
 
 /** @} Watch/Notify */
 
+/**
+ * Pin an object in the cache tier
+ *
+ * When an object is pinned in the cache tier, it stays in the cache
+ * tier, and won't be flushed out.
+ *
+ * @param io the pool the object is in
+ * @param o the object id
+ * @returns 0 on success, negative error code on failure
+ */
+CEPH_RADOS_API int rados_cache_pin(rados_ioctx_t io, const char *o);
+
+/**
+ * Unpin an object in the cache tier
+ *
+ * After an object is unpinned in the cache tier, it can be flushed out
+ *
+ * @param io the pool the object is in
+ * @param o the object id
+ * @returns 0 on success, negative error code on failure
+ */
+CEPH_RADOS_API int rados_cache_unpin(rados_ioctx_t io, const char *o);
+
 /**
  * @name Hints
  *
index 09775e2ec588a41ec3502c022a82d9f6fbca2a65..86badc2bc84b044dc10a011cf0d50f621c55df3a 100644 (file)
@@ -4826,6 +4826,26 @@ extern "C" int rados_aio_read_op_operate(rados_read_op_t read_op,
   return retval;
 }
 
+extern "C" int rados_cache_pin(rados_ioctx_t io, const char *o)
+{
+  tracepoint(librados, rados_cache_pin_enter, io, o);
+  librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
+  object_t oid(o);
+  int retval = ctx->cache_pin(oid);
+  tracepoint(librados, rados_cache_pin_exit, retval);
+  return retval;
+}
+
+extern "C" int rados_cache_unpin(rados_ioctx_t io, const char *o)
+{
+  tracepoint(librados, rados_cache_unpin_enter, io, o);
+  librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
+  object_t oid(o);
+  int retval = ctx->cache_unpin(oid);
+  tracepoint(librados, rados_cache_unpin_exit, retval);
+  return retval;
+}
+
 
 ///////////////////////////// ListObject //////////////////////////////
 librados::ListObject::ListObject() : impl(NULL)