1 From 656b499b00fb237c83b8ccccc519a1577d981199 Mon Sep 17 00:00:00 2001
2 From: Yuan Zhou <yuan.zhou@intel.com>
3 Date: Mon, 6 Aug 2018 15:38:35 +0800
4 Subject: [PATCH 03/10] librbd: fix bufferlist point
6 Signed-off-by: Yuan Zhou <yuan.zhou@intel.com>
8 src/tools/rbd_cache/ObjectCacheStore.cc | 10 +++++-----
9 src/tools/rbd_cache/ObjectCacheStore.h | 2 +-
10 2 files changed, 6 insertions(+), 6 deletions(-)
12 diff --git a/src/tools/rbd_cache/ObjectCacheStore.cc b/src/tools/rbd_cache/ObjectCacheStore.cc
13 index 9572a1a..2a87469 100644
14 --- a/src/tools/rbd_cache/ObjectCacheStore.cc
15 +++ b/src/tools/rbd_cache/ObjectCacheStore.cc
16 @@ -63,13 +63,13 @@ int ObjectCacheStore::do_promote(std::string pool_name, std::string object_name)
17 m_cache_table.emplace(cache_file_name, PROMOTING);
20 - librados::bufferlist read_buf;
21 + librados::bufferlist* read_buf = new librados::bufferlist();
22 int object_size = 4096*1024; //TODO(): read config from image metadata
24 //TODO(): async promote
25 ret = promote_object(ioctx, object_name, read_buf, object_size);
27 - read_buf.append(std::string(object_size, '0'));
28 + read_buf->append(std::string(object_size, '0'));
32 @@ -81,7 +81,7 @@ int ObjectCacheStore::do_promote(std::string pool_name, std::string object_name)
33 // persistent to cache
34 librbd::cache::SyncFile cache_file(m_cct, cache_file_name);
36 - ret = cache_file.write_object_to_file(read_buf, object_size);
37 + ret = cache_file.write_object_to_file(*read_buf, object_size);
39 assert(m_cache_table.find(cache_file_name) != m_cache_table.end());
41 @@ -132,12 +132,12 @@ int ObjectCacheStore::lock_cache(std::string vol_name) {
45 -int ObjectCacheStore::promote_object(librados::IoCtx* ioctx, std::string object_name, librados::bufferlist read_buf, uint64_t read_len) {
46 +int ObjectCacheStore::promote_object(librados::IoCtx* ioctx, std::string object_name, librados::bufferlist* read_buf, uint64_t read_len) {
49 librados::AioCompletion* read_completion = librados::Rados::aio_create_completion();
51 - ret = ioctx->aio_read(object_name, read_completion, &read_buf, read_len, 0);
52 + ret = ioctx->aio_read(object_name, read_completion, read_buf, read_len, 0);
54 lderr(m_cct) << "fail to read from rados" << dendl;
56 diff --git a/src/tools/rbd_cache/ObjectCacheStore.h b/src/tools/rbd_cache/ObjectCacheStore.h
57 index a81beea..db09efa 100644
58 --- a/src/tools/rbd_cache/ObjectCacheStore.h
59 +++ b/src/tools/rbd_cache/ObjectCacheStore.h
60 @@ -45,7 +45,7 @@ class ObjectCacheStore
61 int do_promote(std::string pool_name, std::string object_name);
63 int promote_object(librados::IoCtx*, std::string object_name,
64 - librados::bufferlist read_buf,
65 + librados::bufferlist* read_buf,