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
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#include "librbd/cache/ImageWriteback.h"
#include "librbd/cache/pwl/ssd/LogEntry.h"
#define dout_subsys ceph_subsys_rbd_pwl
#undef dout_prefix
#define dout_prefix *_dout << "librbd::cache::pwl::ssd::WriteLogEntry: " \
<< this << " " << __func__ << ": "
namespace librbd {
namespace cache {
namespace pwl {
namespace ssd {
void WriteLogEntry::init_cache_bl(
bufferlist &src_bl, uint64_t off, uint64_t len) {
cache_bl.clear();
cache_bl.substr_of(src_bl, off, len);
}
buffer::list& WriteLogEntry::get_cache_bl() {
return cache_bl;
}
void WriteLogEntry::copy_cache_bl(bufferlist *out) {
std::lock_guard locker(m_entry_bl_lock);
*out = cache_bl;
}
void WriteLogEntry::remove_cache_bl() {
std::lock_guard locker(m_entry_bl_lock);
cache_bl.clear();
}
unsigned int WriteLogEntry::get_aligned_data_size() const {
if (cache_bl.length()) {
return round_up_to(cache_bl.length(), MIN_WRITE_ALLOC_SSD_SIZE);
}
return round_up_to(write_bytes(), MIN_WRITE_ALLOC_SSD_SIZE);
}
void WriteLogEntry::writeback_bl(
librbd::cache::ImageWritebackInterface &image_writeback,
Context *ctx, ceph::bufferlist&& bl) {
image_writeback.aio_write({{ram_entry.image_offset_bytes,
ram_entry.write_bytes}},
std::move(bl), 0, ctx);
}
void WriteSameLogEntry::writeback_bl(
librbd::cache::ImageWritebackInterface &image_writeback,
Context *ctx, ceph::bufferlist &&bl) {
image_writeback.aio_writesame(ram_entry.image_offset_bytes,
ram_entry.write_bytes,
std::move(bl), 0, ctx);
}
} // namespace ssd
} // namespace pwl
} // namespace cache
} // namespace librbd
|