return entry.format(os);
}
+void WriteSameLogEntry::init_bl(buffer::ptr &bp, buffer::list &bl) {
+ for (uint64_t i = 0; i < ram_entry.write_bytes / ram_entry.ws_datalen; i++) {
+ bl.append(bp);
+ }
+ int trailing_partial = ram_entry.write_bytes % ram_entry.ws_datalen;
+ if (trailing_partial) {
+ bl.append(bp, 0, trailing_partial);
+ }
+};
+
+void WriteSameLogEntry::writeback(librbd::cache::ImageWritebackInterface &image_writeback,
+ Context *ctx) {
+ bufferlist entry_bl;
+ buffer::list entry_bl_copy;
+ copy_pmem_bl(&entry_bl_copy);
+ entry_bl_copy.begin(0).copy(write_bytes(), entry_bl);
+ image_writeback.aio_writesame(ram_entry.image_offset_bytes, ram_entry.write_bytes,
+ std::move(entry_bl), 0, ctx);
+}
+
+std::ostream &WriteSameLogEntry::format(std::ostream &os) const {
+ os << "(WriteSame) ";
+ WriteLogEntry::format(os);
+ return os;
+};
+
+std::ostream &operator<<(std::ostream &os,
+ const WriteSameLogEntry &entry) {
+ return entry.format(os);
+}
+
} // namespace rwl
} // namespace cache
} // namespace librbd
uint32_t m_discard_granularity_bytes;
};
+class WriteSameLogEntry : public WriteLogEntry {
+protected:
+ void init_bl(buffer::ptr &bp, buffer::list &bl) override;
+
+public:
+ WriteSameLogEntry(std::shared_ptr<SyncPointLogEntry> sync_point_entry,
+ const uint64_t image_offset_bytes, const uint64_t write_bytes,
+ const uint32_t data_length)
+ : WriteLogEntry(sync_point_entry, image_offset_bytes, write_bytes) {
+ ram_entry.writesame = 1;
+ ram_entry.ws_datalen = data_length;
+ };
+ WriteSameLogEntry(const uint64_t image_offset_bytes, const uint64_t write_bytes,
+ const uint32_t data_length)
+ : WriteLogEntry(nullptr, image_offset_bytes, write_bytes) {
+ ram_entry.writesame = 1;
+ ram_entry.ws_datalen = data_length;
+ };
+ WriteSameLogEntry(const WriteSameLogEntry&) = delete;
+ WriteSameLogEntry &operator=(const WriteSameLogEntry&) = delete;
+ unsigned int write_bytes() const override {
+ /* The valid bytes in this ops data buffer. */
+ return ram_entry.ws_datalen;
+ };
+ unsigned int bytes_dirty() const override {
+ /* The bytes in the image this op makes dirty. */
+ return ram_entry.write_bytes;
+ };
+ void writeback(librbd::cache::ImageWritebackInterface &image_writeback,
+ Context *ctx) override;
+ std::ostream &format(std::ostream &os) const;
+ friend std::ostream &operator<<(std::ostream &os,
+ const WriteSameLogEntry &entry);
+};
+
} // namespace rwl
} // namespace cache
} // namespace librbd