From c502ea10864ed11997f4cee05abdcfe93f4432c0 Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Wed, 11 Mar 2015 16:52:23 +0800 Subject: [PATCH] librados: add RADOS C interfaces for pin/unpin object Signed-off-by: Zhiqiang Wang --- src/include/rados/librados.h | 23 +++++++++++++++++++++++ src/librados/librados.cc | 20 ++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/src/include/rados/librados.h b/src/include/rados/librados.h index 3aebf208a4821..5d4ac753a9607 100644 --- a/src/include/rados/librados.h +++ b/src/include/rados/librados.h @@ -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 * diff --git a/src/librados/librados.cc b/src/librados/librados.cc index 09775e2ec588a..86badc2bc84b0 100644 --- a/src/librados/librados.cc +++ b/src/librados/librados.cc @@ -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) -- 2.39.5