- remove compiler warning.
- add error log level.
- modify tool/immutable_obj_cache unit testing.
Signed-off-by: Dehao Shang <dehao.shang@intel.com>
template <typename I>
ParentCacheObjectDispatch<I>::ParentCacheObjectDispatch(
I* image_ctx) : m_image_ctx(image_ctx), m_cache_client(nullptr),
- m_initialized(false), m_object_store(nullptr), m_re_connecting(false) {
+ m_object_store(nullptr), m_initialized(false), m_re_connecting(false) {
std::string controller_path =
((CephContext*)(m_image_ctx->cct))->_conf.get_val<std::string>("immutable_object_cache_sock");
m_cache_client = new CacheClient(controller_path.c_str(), m_image_ctx->cct);
string oid = data_object_name(m_image_ctx, object_no);
/* if RO daemon still don't startup, or RO daemon crash,
- * or session have any error, try to re-connect daemon.*/
+ * or session occur any error, try to re-connect daemon.*/
if (!m_cache_client->is_session_work()) {
if(!m_re_connecting.load()) {
ldout(cct, 20) << "try to re-connct RO daemon. " << dendl;
ldout(cct, 5) << "session don't work, dispatch current request to lower object layer " << dendl;
return false;
}
-
ceph_assert(m_cache_client->is_session_work());
CacheGenContextURef ctx = make_gen_lambda_context<ObjectCacheRequest*,
template <typename I>
void ParentCacheObjectDispatch<I>::handle_read_cache(
- ObjectCacheRequest* ack, uint64_t read_off,
- uint64_t read_len, ceph::bufferlist* read_data,
- io::DispatchResult* dispatch_result, Context* on_dispatched) {
+ ObjectCacheRequest* ack, uint64_t read_off, uint64_t read_len,
+ ceph::bufferlist* read_data, io::DispatchResult* dispatch_result,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << dendl;
Context* register_ctx = new FunctionContext([this, cct, on_finish](int ret) {
if (ret < 0) {
- ldout(cct, 20) << "Parent cache fail to register client." << dendl;
+ lderr(cct) << "Parent cache fail to register client." << dendl;
handle_register_client(false);
on_finish->complete(-1);
return;
Context* connect_ctx = new FunctionContext(
[this, cct, register_ctx](int ret) {
if (ret < 0) {
- ldout(cct, 20) << "Parent cache fail to connect RO daeomn." << dendl;
+ lderr(cct) << "Parent cache fail to connect RO daeomn." << dendl;
register_ctx->complete(-1);
return;
}
int handle_register_client(bool reg);
int create_cache_session(Context* on_finish, bool is_reconnect);
- CacheClient *m_cache_client = nullptr;
ImageCtxT* m_image_ctx;
- SharedPersistentObjectCacher *m_object_store = nullptr;
+ CacheClient *m_cache_client;
+ SharedPersistentObjectCacher *m_object_store;
bool m_initialized;
std::atomic<bool> m_re_connecting;
};
}
}
- auto ctx = new FunctionContext([](bool reg) {
- ASSERT_TRUE(reg);
+ auto ctx = new FunctionContext([](int reg) {
+ ASSERT_TRUE(reg == 0);
});
m_cache_client->register_client(ctx);
ASSERT_TRUE(m_cache_client->is_session_work());
void test_register_client(uint64_t random_index) {
ASSERT_TRUE(m_cache_client_vec[random_index] == nullptr);
- auto ctx = new FunctionContext([](bool ret){
- ASSERT_TRUE(ret);
+ auto ctx = new FunctionContext([](int ret){
+ ASSERT_TRUE(ret == 0);
});
auto session = create_session(random_index);
session->register_client(ctx);
std::string temp_oid("12345");
ceph::bufferlist temp_bl;
::SnapContext *temp_snapc = nullptr;
- io::ExtentMap *temp_extent_map = nullptr;
io::DispatchResult* temp_dispatch_result = nullptr;
io::Extents temp_buffer_extents;
int* temp_op_flags = nullptr;
Context** temp_on_finish = nullptr;
Context* temp_on_dispatched = nullptr;
ZTracer::Trace* temp_trace = nullptr;
- io::FlushSource temp_flush_source;
io::LightweightBufferExtents buffer_extents;
ASSERT_EQ(mock_parent_image_cache->discard(0, 0, 0, *temp_snapc, 0, *temp_trace, temp_op_flags,
ASSERT_EQ(mock_parent_image_cache->compare_and_write(0, 0, std::move(temp_bl), std::move(temp_bl),
*temp_snapc, 0, *temp_trace, temp_journal_tid, temp_op_flags, temp_journal_tid,
temp_dispatch_result, temp_on_finish, temp_on_dispatched), false);
- ASSERT_EQ(mock_parent_image_cache->flush(temp_flush_source, *temp_trace, temp_journal_tid,
+ ASSERT_EQ(mock_parent_image_cache->flush(io::FLUSH_SOURCE_USER, *temp_trace, temp_journal_tid,
temp_dispatch_result, temp_on_finish, temp_on_dispatched), false);
ASSERT_EQ(mock_parent_image_cache->invalidate_cache(nullptr), false);
ASSERT_EQ(mock_parent_image_cache->reset_existence_cache(nullptr), false);
C_SaferCond cond;
Context* on_finish = &cond;
- auto& expect = EXPECT_CALL(*(mock_parent_image_cache->get_cache_client()), is_session_work())
- .WillOnce(Return(true))
- .WillOnce(Return(true));
+ auto& expect = EXPECT_CALL(*(mock_parent_image_cache->get_cache_client()), is_session_work());
+ expect.WillOnce(Return(true)).WillOnce(Return(true));
+
expect_cache_lookup_object(*mock_parent_image_cache, on_finish);
mock_parent_image_cache->read(0, 0, 4096, CEPH_NOSNAP, 0, {},