diff options
author | Yingxin <yingxin.cheng@intel.com> | 2024-10-11 05:38:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-11 05:38:05 +0200 |
commit | b2a4bd8409dcfaaa2e84ed450a0d31126ac9b4c3 (patch) | |
tree | 3e17ee904c71589cf41edc7f4526a3e821002692 /src/crimson | |
parent | Merge pull request #60147 from rhcs-dashboard/sync-policy-pipe-edit-fixes (diff) | |
parent | crimson/os/seastore: fix data inconsistency during ool writes (diff) | |
download | ceph-b2a4bd8409dcfaaa2e84ed450a0d31126ac9b4c3.tar.xz ceph-b2a4bd8409dcfaaa2e84ed450a0d31126ac9b4c3.zip |
Merge pull request #59720 from myoungwon/wip-fix-overlapped-write
crimson/os/seastore: fix data inconsistency during ool writes
Reviewed-by: Yingxin Cheng <yingxin.cheng@intel.com>
Diffstat (limited to 'src/crimson')
-rw-r--r-- | src/crimson/os/seastore/cache.cc | 8 | ||||
-rw-r--r-- | src/crimson/os/seastore/extent_placement_manager.cc | 14 | ||||
-rw-r--r-- | src/crimson/os/seastore/transaction.h | 19 |
3 files changed, 38 insertions, 3 deletions
diff --git a/src/crimson/os/seastore/cache.cc b/src/crimson/os/seastore/cache.cc index cf8d3c0891d..5dcb7514ee1 100644 --- a/src/crimson/os/seastore/cache.cc +++ b/src/crimson/os/seastore/cache.cc @@ -990,8 +990,12 @@ void Cache::mark_transaction_conflicted( } efforts.mutate_delta_bytes += delta_stat.bytes; - for (auto &i: t.pre_alloc_list) { - epm.mark_space_free(i->get_paddr(), i->get_length()); + if (t.get_pending_ool()) { + t.get_pending_ool()->is_conflicted = true; + } else { + for (auto &i: t.pre_alloc_list) { + epm.mark_space_free(i->get_paddr(), i->get_length()); + } } auto& ool_stats = t.get_ool_write_stats(); diff --git a/src/crimson/os/seastore/extent_placement_manager.cc b/src/crimson/os/seastore/extent_placement_manager.cc index 34ac199eed8..0458fbfed74 100644 --- a/src/crimson/os/seastore/extent_placement_manager.cc +++ b/src/crimson/os/seastore/extent_placement_manager.cc @@ -987,7 +987,19 @@ RandomBlockOolWriter::alloc_write_ool_extents( return alloc_write_iertr::now(); } return seastar::with_gate(write_guard, [this, &t, &extents] { - return do_write(t, extents); + seastar::lw_shared_ptr<rbm_pending_ool_t> ptr = + seastar::make_lw_shared<rbm_pending_ool_t>(); + ptr->pending_extents = t.get_pre_alloc_list(); + assert(!t.is_conflicted()); + t.set_pending_ool(ptr); + return do_write(t, extents + ).finally([this, ptr=ptr] { + if (ptr->is_conflicted) { + for (auto &e : ptr->pending_extents) { + rb_cleaner->mark_space_free(e->get_paddr(), e->get_length()); + } + } + }); }); } diff --git a/src/crimson/os/seastore/transaction.h b/src/crimson/os/seastore/transaction.h index 52515937a9e..5d8ad00ba22 100644 --- a/src/crimson/os/seastore/transaction.h +++ b/src/crimson/os/seastore/transaction.h @@ -80,6 +80,11 @@ struct rewrite_stats_t { } }; +struct rbm_pending_ool_t { + bool is_conflicted = false; + std::list<CachedExtentRef> pending_extents; +}; + /** * Transaction * @@ -554,6 +559,18 @@ public: return static_cast<T&>(*view); } + void set_pending_ool(seastar::lw_shared_ptr<rbm_pending_ool_t> ptr) { + pending_ool = ptr; + } + + seastar::lw_shared_ptr<rbm_pending_ool_t> get_pending_ool() { + return pending_ool; + } + + const auto& get_pre_alloc_list() { + return pre_alloc_list; + } + private: friend class Cache; friend Ref make_test_transaction(); @@ -650,6 +667,8 @@ private: const src_t src; transaction_id_t trans_id = TRANS_ID_NULL; + + seastar::lw_shared_ptr<rbm_pending_ool_t> pending_ool; }; using TransactionRef = Transaction::Ref; |