b0030ea4b4e528154ee47b8ff5d5e65b296b13d5
[stor4nfv.git] / src / ceph / 0003-librbd-fix-bufferlist-point.patch
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
5
6 Signed-off-by: Yuan Zhou <yuan.zhou@intel.com>
7 ---
8  src/tools/rbd_cache/ObjectCacheStore.cc | 10 +++++-----
9  src/tools/rbd_cache/ObjectCacheStore.h  |  2 +-
10  2 files changed, 6 insertions(+), 6 deletions(-)
11
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);
18    }
19  
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
23  
24    //TODO(): async promote
25    ret = promote_object(ioctx, object_name, read_buf, object_size);
26    if (ret == -ENOENT) {
27 -    read_buf.append(std::string(object_size, '0'));
28 +    read_buf->append(std::string(object_size, '0'));
29      ret = 0;
30    }
31  
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);
35    cache_file.open();
36 -  ret = cache_file.write_object_to_file(read_buf, object_size);
37 +  ret = cache_file.write_object_to_file(*read_buf, object_size);
38    
39    assert(m_cache_table.find(cache_file_name) != m_cache_table.end()); 
40  
41 @@ -132,12 +132,12 @@ int ObjectCacheStore::lock_cache(std::string vol_name) {
42    return 0;
43  }
44  
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) {
47    int ret;
48  
49    librados::AioCompletion* read_completion = librados::Rados::aio_create_completion(); 
50  
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);
53    if(ret < 0) {
54      lderr(m_cct) << "fail to read from rados" << dendl;
55      return ret;
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);
62  
63      int promote_object(librados::IoCtx*, std::string object_name,
64 -                       librados::bufferlist read_buf,
65 +                       librados::bufferlist* read_buf,
66                         uint64_t length);
67  
68      enum {
69 -- 
70 2.7.4
71