diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-23 16:45:17 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-23 16:45:44 +0000 |
commit | 17d6a993fc17d533460c5f40f3908c708e057c18 (patch) | |
tree | 1a3bd93e0ecd74fa02f93a528fe2f87e5314c4b5 /src/librbd/io | |
parent | Releasing progress-linux version 18.2.2-0progress7.99u1. (diff) | |
download | ceph-17d6a993fc17d533460c5f40f3908c708e057c18.tar.xz ceph-17d6a993fc17d533460c5f40f3908c708e057c18.zip |
Merging upstream version 18.2.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/librbd/io/ImageRequest.cc | 54 | ||||
-rw-r--r-- | src/librbd/io/ImageRequest.h | 21 | ||||
-rw-r--r-- | src/librbd/io/ObjectRequest.cc | 18 | ||||
-rw-r--r-- | src/librbd/io/Types.h | 20 |
4 files changed, 38 insertions, 75 deletions
diff --git a/src/librbd/io/ImageRequest.cc b/src/librbd/io/ImageRequest.cc index e4c41c229..fb9f8944e 100644 --- a/src/librbd/io/ImageRequest.cc +++ b/src/librbd/io/ImageRequest.cc @@ -473,7 +473,7 @@ void AbstractImageWriteRequest<I>::send_request() { if (journaling) { // in-flight ops are flushed prior to closing the journal ceph_assert(image_ctx.journal != NULL); - journal_tid = append_journal_event(m_synchronous); + journal_tid = append_journal_event(); } // it's very important that IOContext is captured here instead of @@ -518,22 +518,12 @@ void ImageWriteRequest<I>::assemble_extent( } template <typename I> -uint64_t ImageWriteRequest<I>::append_journal_event(bool synchronous) { +uint64_t ImageWriteRequest<I>::append_journal_event() { I &image_ctx = this->m_image_ctx; - uint64_t tid = 0; - uint64_t buffer_offset = 0; ceph_assert(!this->m_image_extents.empty()); - for (auto &extent : this->m_image_extents) { - bufferlist sub_bl; - sub_bl.substr_of(m_bl, buffer_offset, extent.second); - buffer_offset += extent.second; - - tid = image_ctx.journal->append_write_event(extent.first, extent.second, - sub_bl, synchronous); - } - - return tid; + return image_ctx.journal->append_write_event( + this->m_image_extents, m_bl, false); } template <typename I> @@ -566,22 +556,12 @@ void ImageWriteRequest<I>::update_stats(size_t length) { } template <typename I> -uint64_t ImageDiscardRequest<I>::append_journal_event(bool synchronous) { +uint64_t ImageDiscardRequest<I>::append_journal_event() { I &image_ctx = this->m_image_ctx; - uint64_t tid = 0; ceph_assert(!this->m_image_extents.empty()); - for (auto &extent : this->m_image_extents) { - journal::EventEntry event_entry( - journal::AioDiscardEvent(extent.first, - extent.second, - this->m_discard_granularity_bytes)); - tid = image_ctx.journal->append_io_event(std::move(event_entry), - extent.first, extent.second, - synchronous, 0); - } - - return tid; + return image_ctx.journal->append_discard_event( + this->m_image_extents, m_discard_granularity_bytes, false); } template <typename I> @@ -717,21 +697,12 @@ void ImageFlushRequest<I>::send_request() { } template <typename I> -uint64_t ImageWriteSameRequest<I>::append_journal_event(bool synchronous) { +uint64_t ImageWriteSameRequest<I>::append_journal_event() { I &image_ctx = this->m_image_ctx; - uint64_t tid = 0; ceph_assert(!this->m_image_extents.empty()); - for (auto &extent : this->m_image_extents) { - journal::EventEntry event_entry(journal::AioWriteSameEvent(extent.first, - extent.second, - m_data_bl)); - tid = image_ctx.journal->append_io_event(std::move(event_entry), - extent.first, extent.second, - synchronous, 0); - } - - return tid; + return image_ctx.journal->append_write_same_event( + this->m_image_extents, m_data_bl, false); } template <typename I> @@ -768,8 +739,7 @@ void ImageWriteSameRequest<I>::update_stats(size_t length) { } template <typename I> -uint64_t ImageCompareAndWriteRequest<I>::append_journal_event( - bool synchronous) { +uint64_t ImageCompareAndWriteRequest<I>::append_journal_event() { I &image_ctx = this->m_image_ctx; uint64_t tid = 0; @@ -779,7 +749,7 @@ uint64_t ImageCompareAndWriteRequest<I>::append_journal_event( extent.second, m_cmp_bl, m_bl, - synchronous); + false); return tid; } diff --git a/src/librbd/io/ImageRequest.h b/src/librbd/io/ImageRequest.h index 2668c1acb..996c90a11 100644 --- a/src/librbd/io/ImageRequest.h +++ b/src/librbd/io/ImageRequest.h @@ -114,11 +114,6 @@ private: template <typename ImageCtxT = ImageCtx> class AbstractImageWriteRequest : public ImageRequest<ImageCtxT> { -public: - inline void flag_synchronous() { - m_synchronous = true; - } - protected: using typename ImageRequest<ImageCtxT>::ObjectRequests; @@ -127,8 +122,7 @@ protected: const char *trace_name, const ZTracer::Trace &parent_trace) : ImageRequest<ImageCtxT>(image_ctx, aio_comp, std::move(image_extents), - area, trace_name, parent_trace), - m_synchronous(false) { + area, trace_name, parent_trace) { } void send_request() override; @@ -144,11 +138,8 @@ protected: const LightweightObjectExtent &object_extent, IOContext io_context, uint64_t journal_tid, bool single_extent, Context *on_finish) = 0; - virtual uint64_t append_journal_event(bool synchronous) = 0; + virtual uint64_t append_journal_event() = 0; virtual void update_stats(size_t length) = 0; - -private: - bool m_synchronous; }; template <typename ImageCtxT = ImageCtx> @@ -180,7 +171,7 @@ protected: const LightweightObjectExtent &object_extent, IOContext io_context, uint64_t journal_tid, bool single_extent, Context *on_finish) override; - uint64_t append_journal_event(bool synchronous) override; + uint64_t append_journal_event() override; void update_stats(size_t length) override; private: @@ -215,7 +206,7 @@ protected: const LightweightObjectExtent &object_extent, IOContext io_context, uint64_t journal_tid, bool single_extent, Context *on_finish) override; - uint64_t append_journal_event(bool synchronous) override; + uint64_t append_journal_event() override; void update_stats(size_t length) override; int prune_object_extents( @@ -283,7 +274,7 @@ protected: const LightweightObjectExtent &object_extent, IOContext io_context, uint64_t journal_tid, bool single_extent, Context *on_finish) override; - uint64_t append_journal_event(bool synchronous) override; + uint64_t append_journal_event() override; void update_stats(size_t length) override; private: bufferlist m_data_bl; @@ -315,7 +306,7 @@ protected: const LightweightObjectExtent &object_extent, IOContext io_context, uint64_t journal_tid, bool single_extent, Context *on_finish) override; - uint64_t append_journal_event(bool synchronous) override; + uint64_t append_journal_event() override; void update_stats(size_t length) override; aio_type_t get_aio_type() const override { diff --git a/src/librbd/io/ObjectRequest.cc b/src/librbd/io/ObjectRequest.cc index 6d246cdf3..fc1a96858 100644 --- a/src/librbd/io/ObjectRequest.cc +++ b/src/librbd/io/ObjectRequest.cc @@ -834,16 +834,17 @@ void ObjectListSnapsRequest<I>::handle_list_snaps(int r) { end_snap_id, &diff, &end_size, &exists, &clone_end_snap_id, &read_whole_object); - if (read_whole_object || - (!diff.empty() && - ((m_list_snaps_flags & LIST_SNAPS_FLAG_WHOLE_OBJECT) != 0))) { + if (read_whole_object) { ldout(cct, 1) << "need to read full object" << dendl; - diff.clear(); diff.insert(0, image_ctx->layout.object_size); + exists = true; end_size = image_ctx->layout.object_size; clone_end_snap_id = end_snap_id; - } else if (!exists) { - end_size = 0; + } else if ((m_list_snaps_flags & LIST_SNAPS_FLAG_WHOLE_OBJECT) != 0 && + !diff.empty()) { + ldout(cct, 20) << "expanding diff from " << diff << dendl; + diff.clear(); + diff.insert(0, image_ctx->layout.object_size); } if (exists) { @@ -863,7 +864,8 @@ void ObjectListSnapsRequest<I>::handle_list_snaps(int r) { // clip diff to size of object (in case it was truncated) interval_set<uint64_t> zero_interval; - if (end_size < prev_end_size) { + if (end_size < prev_end_size && + (m_list_snaps_flags & LIST_SNAPS_FLAG_WHOLE_OBJECT) == 0) { zero_interval.insert(end_size, prev_end_size - end_size); zero_interval.intersection_of(object_interval); @@ -884,7 +886,7 @@ void ObjectListSnapsRequest<I>::handle_list_snaps(int r) { << "end_size=" << end_size << ", " << "prev_end_size=" << prev_end_size << ", " << "exists=" << exists << ", " - << "whole_object=" << read_whole_object << dendl; + << "read_whole_object=" << read_whole_object << dendl; // check if object exists prior to start of incremental snap delta so that // we don't DNE the object if no additional deltas exist diff --git a/src/librbd/io/Types.h b/src/librbd/io/Types.h index 7c70986c5..03e9ffa3b 100644 --- a/src/librbd/io/Types.h +++ b/src/librbd/io/Types.h @@ -180,8 +180,9 @@ struct SparseExtent { std::ostream& operator<<(std::ostream& os, const SparseExtent& state); struct SparseExtentSplitMerge { - SparseExtent split(uint64_t offset, uint64_t length, SparseExtent &se) const { - return SparseExtent(se.state, se.length); + SparseExtent split(uint64_t offset, uint64_t length, + const SparseExtent& se) const { + return SparseExtent(se.state, length); } bool can_merge(const SparseExtent& left, const SparseExtent& right) const { @@ -232,10 +233,10 @@ struct SparseBufferlistExtent : public SparseExtent { struct SparseBufferlistExtentSplitMerge { SparseBufferlistExtent split(uint64_t offset, uint64_t length, - SparseBufferlistExtent& sbe) const { + const SparseBufferlistExtent& sbe) const { ceph::bufferlist bl; if (sbe.state == SPARSE_EXTENT_STATE_DATA) { - bl.substr_of(bl, offset, length); + bl.substr_of(sbe.bl, offset, length); } return SparseBufferlistExtent(sbe.state, length, std::move(bl)); } @@ -247,14 +248,13 @@ struct SparseBufferlistExtentSplitMerge { SparseBufferlistExtent merge(SparseBufferlistExtent&& left, SparseBufferlistExtent&& right) const { + ceph::bufferlist bl; if (left.state == SPARSE_EXTENT_STATE_DATA) { - ceph::bufferlist bl{std::move(left.bl)}; - bl.claim_append(std::move(right.bl)); - return SparseBufferlistExtent(SPARSE_EXTENT_STATE_DATA, - bl.length(), std::move(bl)); - } else { - return SparseBufferlistExtent(left.state, left.length + right.length, {}); + bl.claim_append(left.bl); + bl.claim_append(right.bl); } + return SparseBufferlistExtent(left.state, left.length + right.length, + std::move(bl)); } uint64_t length(const SparseBufferlistExtent& sbe) const { |