Skip to content

Commit f1f0beb

Browse files
committed
blk/kerneldevice: fix invalid iterator usage after erase in discard_queued traversal
fixes: https://tracker.ceph.com/issues/70636 Signed-off-by: Yite Gu <[email protected]>
1 parent d818d46 commit f1f0beb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/blk/kernel/KernelDevice.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -808,11 +808,11 @@ void KernelDevice::_discard_thread(uint64_t tid)
808808
// It will also allow threads to finish in a timely manner.
809809
constexpr unsigned MAX_LOCAL_DISCARD = 32;
810810
unsigned count = 0;
811-
for (auto p = discard_queued.begin();
812-
p != discard_queued.end() && count < MAX_LOCAL_DISCARD;
813-
++p, ++count) {
814-
discard_processing.insert(p.get_start(), p.get_len());
815-
discard_queued.erase(p);
811+
for (auto it = discard_queued.begin();
812+
it != discard_queued.end() && count < MAX_LOCAL_DISCARD;
813+
++count) {
814+
discard_processing.insert(it.get_start(), it.get_len());
815+
it = discard_queued.erase(it);
816816
}
817817

818818
// there are multiple active threads -> must use a counter instead of a flag

0 commit comments

Comments
 (0)