summaryrefslogtreecommitdiffstats
path: root/src/ceph/0003-librbd-fix-bufferlist-point.patch
blob: b0030ea4b4e528154ee47b8ff5d5e65b296b13d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
From 656b499b00fb237c83b8ccccc519a1577d981199 Mon Sep 17 00:00:00 2001
From: Yuan Zhou <yuan.zhou@intel.com>
Date: Mon, 6 Aug 2018 15:38:35 +0800
Subject: [PATCH 03/10] librbd: fix bufferlist point

Signed-off-by: Yuan Zhou <yuan.zhou@intel.com>
---
 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