]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/cache/pwl/ssd/LogEntry.cc
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / librbd / cache / pwl / ssd / LogEntry.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #include "librbd/cache/ImageWriteback.h"
5 #include "librbd/cache/pwl/ssd/LogEntry.h"
6
7 #define dout_subsys ceph_subsys_rbd_pwl
8 #undef dout_prefix
9 #define dout_prefix *_dout << "librbd::cache::pwl::ssd::WriteLogEntry: " \
10 << this << " " << __func__ << ": "
11
12 namespace librbd {
13 namespace cache {
14 namespace pwl {
15 namespace ssd {
16
17 void WriteLogEntry::init_cache_bl(
18 bufferlist &src_bl, uint64_t off, uint64_t len) {
19 cache_bl.clear();
20 cache_bl.substr_of(src_bl, off, len);
21 }
22
23 buffer::list& WriteLogEntry::get_cache_bl() {
24 std::lock_guard locker(m_entry_bl_lock);
25 return cache_bl;
26 }
27
28 void WriteLogEntry::remove_cache_bl() {
29 std::lock_guard locker(m_entry_bl_lock);
30 cache_bl.clear();
31 }
32
33 unsigned int WriteLogEntry::get_aligned_data_size() const {
34 if (cache_bl.length()) {
35 return round_up_to(cache_bl.length(), MIN_WRITE_ALLOC_SSD_SIZE);
36 }
37 return round_up_to(write_bytes(), MIN_WRITE_ALLOC_SSD_SIZE);
38 }
39
40 void WriteLogEntry::writeback_bl(
41 librbd::cache::ImageWritebackInterface &image_writeback,
42 Context *ctx, ceph::bufferlist&& bl) {
43 image_writeback.aio_write({{ram_entry.image_offset_bytes,
44 ram_entry.write_bytes}},
45 std::move(bl), 0, ctx);
46 }
47
48 void WriteSameLogEntry::writeback_bl(
49 librbd::cache::ImageWritebackInterface &image_writeback,
50 Context *ctx, ceph::bufferlist &&bl) {
51 image_writeback.aio_writesame(ram_entry.image_offset_bytes,
52 ram_entry.write_bytes,
53 std::move(bl), 0, ctx);
54 }
55
56 } // namespace ssd
57 } // namespace pwl
58 } // namespace cache
59 } // namespace librbd