[Devel] [PATCH hci-8.1 v5 3/6] block/blk-cbt: don't overwrite a map page with CBT_PAGE_MISSED

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Tue Oct 27 17:23:50 MSK 2026


The cache flush marks a missing map page with CBT_PAGE_MISSED from an
IPI, without cbt->lock. A page installed under cbt->lock in between, by
cbt_page_alloc(), is then overwritten: it leaks, and the bits already
set in it are lost.

Store the marker under cbt->lock, and set the bits in the page if it
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 | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/block/blk-cbt.c b/block/blk-cbt.c
index 1066b6a33b6b5..01114362bb2bc 100644
--- a/block/blk-cbt.c
+++ b/block/blk-cbt.c
@@ -194,10 +194,19 @@ static int __blk_cbt_set(struct cbt_info  *cbt, blkcnt_t block,
 			block += len;
 			continue;
 		} else if (pages_missed) {
+			bool installed;
+
+			/* Don't overwrite a page installed meanwhile */
+			spin_lock_irqsave(&cbt->lock, flags);
+			installed = CBT_PAGE(cbt, idx);
+			if (!installed)
+				cbt->map[idx] = CBT_PAGE_MISSED;
+			spin_unlock_irqrestore(&cbt->lock, flags);
+			if (installed)
+				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