]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/cache/pwl/ssd/LogEntry.cc
import ceph 16.2.7
[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 return cache_bl;
25 }
26
27 void WriteLogEntry::copy_cache_bl(bufferlist *out) {
28 std::lock_guard locker(m_entry_bl_lock);
29 *out = cache_bl;
30 }
31
32 void WriteLogEntry::remove_cache_bl() {
33 std::lock_guard locker(m_entry_bl_lock);
34 cache_bl.clear();
35 }
36
37 unsigned int WriteLogEntry::get_aligned_data_size() const {
38 if (cache_bl.length()) {
39 return round_up_to(cache_bl.length(), MIN_WRITE_ALLOC_SSD_SIZE);
40 }
41 return round_up_to(write_bytes(), MIN_WRITE_ALLOC_SSD_SIZE);
42 }
43
44 void WriteLogEntry::writeback_bl(
45 librbd::cache::ImageWritebackInterface &image_writeback,
46 Context *ctx, ceph::bufferlist&& bl) {
47 image_writeback.aio_write({{ram_entry.image_offset_bytes,
48 ram_entry.write_bytes}},
49 std::move(bl), 0, ctx);
50 }
51
52 void WriteSameLogEntry::writeback_bl(
53 librbd::cache::ImageWritebackInterface &image_writeback,
54 Context *ctx, ceph::bufferlist &&bl) {
55 image_writeback.aio_writesame(ram_entry.image_offset_bytes,
56 ram_entry.write_bytes,
57 std::move(bl), 0, ctx);
58 }
59
60 } // namespace ssd
61 } // namespace pwl
62 } // namespace cache
63 } // namespace librbd