In fact, although in get_cache_bl it use lock to protect, it can't
protect function "list& operator= (const list& other)".
So we should use copy_cache_bl.
Fixes: https://tracker.ceph.com/issues/52400
Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
(cherry picked from commit
fe72b3953735329441397f257d5dd18f6819187d)
BlockExtent block_extent();
virtual unsigned int reader_count() const = 0;
/* Constructs a new bl containing copies of cache_bp */
- void copy_cache_bl(bufferlist *out_bl) override {};
bool can_retire() const override {
return (this->completed && this->get_flushed() && (0 == reader_count()));
}
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();
Context *ctx, ceph::bufferlist &&bl) override;
void init_cache_bl(bufferlist &src_bl, uint64_t off, uint64_t len) override;
buffer::list &get_cache_bl() override;
+ void copy_cache_bl(bufferlist *out) override;
void remove_cache_bl() override;
unsigned int get_aligned_data_size() const override;
void inc_bl_refs() { bl_refs++; };
ldout(m_image_ctx.cct, 5) << dendl;
auto write_entry = static_pointer_cast<WriteLogEntry>(map_entry.log_entry);
buffer::list hit_bl;
- hit_bl = write_entry->get_cache_bl();
+ write_entry->copy_cache_bl(&hit_bl);
bool writesame = write_entry->is_writesame_entry();
auto hit_extent_buf = std::make_shared<ImageExtentBuf>(
hit_extent, hit_bl, true, read_buffer_offset, writesame);