\
/* hints */ \
f(SETALLOCHINT, __CEPH_OSD_OP(WR, DATA, 35), "set-alloc-hint") \
+ \
+ /* cache pin/unpin */ \
+ f(CACHE_PIN, __CEPH_OSD_OP(WR, DATA, 36), "cache-pin") \
+ f(CACHE_UNPIN, __CEPH_OSD_OP(WR, DATA, 37), "cache-unpin") \
\
/** multi **/ \
f(CLONERANGE, __CEPH_OSD_OP(WR, MULTI, 1), "clonerange") \
void set_alloc_hint(uint64_t expected_object_size,
uint64_t expected_write_size);
+ /**
+ * Pin/unpin an object in cache tier
+ *
+ * @returns 0 on success, negative error code on failure
+ */
+ void cache_pin();
+ void cache_unpin();
+
friend class IoCtx;
};
void set_assert_version(uint64_t ver);
void set_assert_src_version(const std::string& o, uint64_t ver);
+ /**
+ * Pin/unpin an object in cache tier
+ *
+ * @param o the name of the object
+ * @returns 0 on success, negative error code on failure
+ */
+ int cache_pin(const std::string& o);
+ int cache_unpin(const std::string& o);
+
const std::string& get_pool_name() const;
void locator_set_key(const std::string& key);
notify_timeout = timeout;
}
+int librados::IoCtxImpl::cache_pin(const object_t& oid)
+{
+ ::ObjectOperation wr;
+ prepare_assert_ops(&wr);
+ wr.cache_pin();
+ return operate(oid, &wr, NULL);
+}
+
+int librados::IoCtxImpl::cache_unpin(const object_t& oid)
+{
+ ::ObjectOperation wr;
+ prepare_assert_ops(&wr);
+ wr.cache_unpin();
+ return operate(oid, &wr, NULL);
+}
+
///////////////////////////// C_aio_Ack ////////////////////////////////
void set_assert_src_version(const object_t& oid, uint64_t ver);
void set_notify_timeout(uint32_t timeout);
+ int cache_pin(const object_t& oid);
+ int cache_unpin(const object_t& oid);
+
};
#endif
o->set_alloc_hint(expected_object_size, expected_write_size);
}
+void librados::ObjectWriteOperation::cache_pin()
+{
+ ::ObjectOperation *o = (::ObjectOperation *)impl;
+ o->cache_pin();
+}
+
+void librados::ObjectWriteOperation::cache_unpin()
+{
+ ::ObjectOperation *o = (::ObjectOperation *)impl;
+ o->cache_unpin();
+}
+
librados::WatchCtx::
~WatchCtx()
{
io_ctx_impl->set_assert_src_version(obj, ver);
}
+int librados::IoCtx::cache_pin(const string& oid)
+{
+ object_t obj(oid);
+ return io_ctx_impl->cache_pin(obj);
+}
+
+int librados::IoCtx::cache_unpin(const string& oid)
+{
+ object_t obj(oid);
+ return io_ctx_impl->cache_unpin(obj);
+}
+
void librados::IoCtx::locator_set_key(const string& key)
{
io_ctx_impl->oloc.key = key;
out_rval[i] = &sops[i].rval;
}
}
+
+ /**
+ * Pin/unpin an object in cache tier
+ */
+ void cache_pin() {
+ add_op(CEPH_OSD_OP_CACHE_PIN);
+ }
+
+ void cache_unpin() {
+ add_op(CEPH_OSD_OP_CACHE_UNPIN);
+ }
};