From 656b499b00fb237c83b8ccccc519a1577d981199 Mon Sep 17 00:00:00 2001 From: Yuan Zhou Date: Mon, 6 Aug 2018 15:38:35 +0800 Subject: [PATCH 03/10] librbd: fix bufferlist point Signed-off-by: Yuan Zhou --- src/tools/rbd_cache/ObjectCacheStore.cc | 10 +++++----- src/tools/rbd_cache/ObjectCacheStore.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tools/rbd_cache/ObjectCacheStore.cc b/src/tools/rbd_cache/ObjectCacheStore.cc index 9572a1a..2a87469 100644 --- a/src/tools/rbd_cache/ObjectCacheStore.cc +++ b/src/tools/rbd_cache/ObjectCacheStore.cc @@ -63,13 +63,13 @@ int ObjectCacheStore::do_promote(std::string pool_name, std::string object_name) m_cache_table.emplace(cache_file_name, PROMOTING); } - librados::bufferlist read_buf; + librados::bufferlist* read_buf = new librados::bufferlist(); int object_size = 4096*1024; //TODO(): read config from image metadata //TODO(): async promote ret = promote_object(ioctx, object_name, read_buf, object_size); if (ret == -ENOENT) { - read_buf.append(std::string(object_size, '0')); + read_buf->append(std::string(object_size, '0')); ret = 0; } @@ -81,7 +81,7 @@ int ObjectCacheStore::do_promote(std::string pool_name, std::string object_name) // persistent to cache librbd::cache::SyncFile cache_file(m_cct, cache_file_name); cache_file.open(); - ret = cache_file.write_object_to_file(read_buf, object_size); + ret = cache_file.write_object_to_file(*read_buf, object_size); assert(m_cache_table.find(cache_file_name) != m_cache_table.end()); @@ -132,12 +132,12 @@ int ObjectCacheStore::lock_cache(std::string vol_name) { return 0; } -int ObjectCacheStore::promote_object(librados::IoCtx* ioctx, std::string object_name, librados::bufferlist read_buf, uint64_t read_len) { +int ObjectCacheStore::promote_object(librados::IoCtx* ioctx, std::string object_name, librados::bufferlist* read_buf, uint64_t read_len) { int ret; librados::AioCompletion* read_completion = librados::Rados::aio_create_completion(); - ret = ioctx->aio_read(object_name, read_completion, &read_buf, read_len, 0); + ret = ioctx->aio_read(object_name, read_completion, read_buf, read_len, 0); if(ret < 0) { lderr(m_cct) << "fail to read from rados" << dendl; return ret; diff --git a/src/tools/rbd_cache/ObjectCacheStore.h b/src/tools/rbd_cache/ObjectCacheStore.h index a81beea..db09efa 100644 --- a/src/tools/rbd_cache/ObjectCacheStore.h +++ b/src/tools/rbd_cache/ObjectCacheStore.h @@ -45,7 +45,7 @@ class ObjectCacheStore int do_promote(std::string pool_name, std::string object_name); int promote_object(librados::IoCtx*, std::string object_name, - librados::bufferlist read_buf, + librados::bufferlist* read_buf, uint64_t length); enum { -- 2.7.4