[Devel] [PATCH hci-8.1 v7 5/8] block/blk-cbt: don't overwrite a map page with CBT_PAGE_MISSED
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Wed Oct 28 13:11:26 MSK 2026
The cache flush marks a missing map page with CBT_PAGE_MISSED from an
IPI, with a plain store. A page installed in between, by
cbt_page_alloc(), is then overwritten: it leaks, and the bits already
set in it are lost.
Store the marker with cmpxchg() only into an empty slot, and set the
bits in the page if one appeared meanwhile.
https://virtuozzo.atlassian.net/browse/VSTOR-149268
Feature: cbt: changed block tracking (for backup)
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
block/blk-cbt.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/block/blk-cbt.c b/block/blk-cbt.c
index 970a69ea8d58a..10e03a29114a4 100644
--- a/block/blk-cbt.c
+++ b/block/blk-cbt.c
@@ -199,10 +199,15 @@ static int __blk_cbt_set(struct cbt_info *cbt, blkcnt_t block,
block += len;
continue;
} else if (pages_missed) {
+ struct page *old;
+
+ /* Don't overwrite a page installed meanwhile */
+ old = cmpxchg(&cbt->map[idx], NULL, CBT_PAGE_MISSED);
+ if (old && old != CBT_PAGE_MISSED)
+ continue;
(*pages_missed)++;
if (!*idx_first)
*idx_first = idx;
- cbt->map[idx] = CBT_PAGE_MISSED;
count -= len;
block += len;
continue;
--
2.55.0
More information about the Devel
mailing list