From: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
To: Konstantin Khorenko <khorenko@virtuozzo.com>
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 v7 0/8] block/blk-cbt: don't lose writes held across a dm suspend
Date: Wed, 28 Oct 2026 11:11:21 +0100 [thread overview]
Message-ID: <20261028-ptikhomirov-vstor-149268-cbt-account-at-rq-start-v7-0-5c48672191c2@virtuozzo.com> (raw)
Fix CBT missing writes that request-based dm holds across a suspend,
which made incremental backups taken with ploop-backup silently lose
data.
Claude tested full and incremental ploop-backup under write load (a
random writer, and fio with 4 jobs x iodepth 64): the incremental backup
lost blocks without the fix, and was consistent in 30/30 and 10/10 runs
with it. CBT start/stop and device resize under fio ran without
warnings. With writes throttled by io.max on a loop device, CBT recorded
24 of 64 written blocks without the throttle patch, and all 64 with it.
A RWF_NOWAIT write into a missing bitmap page now fails with EAGAIN
instead of sleeping, and succeeds when retried without RWF_NOWAIT.
https://virtuozzo.atlassian.net/browse/VSTOR-149268
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
---
Changes in v7:
- New patch: use list_for_each_entry_safe() in blk_cbt_update_size(),
which read the next entry through a cbt it had just queued for
release (sashiko review).
- Take the SRCU read lock in blk_cbt_bio_queue() only after its early
exits, so that reads and queues without a CBT don't pay for it.
- Clarify the commit message of the unsigned shift patch and the comment
of cbt_pages_present() (sashiko review).
- Link to v6: http://lore.virtuozzo.com/20261027-ptikhomirov-vstor-149268-cbt-account-at-rq-start-v6-0-f9870cf5c7eb@virtuozzo.com
Changes in v6:
- New patch: load a map slot once with READ_ONCE() in CBT_PAGE(), as a
racing CBT_PAGE_MISSED store could make it return (struct page *)0x1,
and install a map page with smp_store_release(), so that a lockless
reader never sees it before its zeroing (sashiko review).
- Store CBT_PAGE_MISSED with cmpxchg() instead of under cbt->lock, since
taking a spinlock_t in the flush IPI is not allowed: it may sleep on
PREEMPT_RT (sashiko review).
- Skip queueing a page allocation that is already queued, instead of
taking cbt->lock for every write while the page is missing (sashiko
review).
- Link to v5: http://lore.virtuozzo.com/20261027-ptikhomirov-vstor-149268-cbt-account-at-rq-start-v5-0-88dccc74b48b@virtuozzo.com
Changes in v5:
- New patch: store CBT_PAGE_MISSED under cbt->lock, as the cache flush
could overwrite a page installed meanwhile; the allocation queued at
submission in v4 made this much more likely (sashiko review).
- New patch: walk cbt_list under SRCU, so that a sleeping bitmap page
allocation no longer drops the RCU lock in the middle of the walk, which
let a concurrent CBT stop or resize free the next cbt under it, a use
after free (the pre-existing problem noted in v4).
- New patch: don't sleep in CBT for a REQ_NOWAIT write, fail it with
BLK_STS_AGAIN if a bitmap page is missing (also noted in v4).
- Link to v4: http://lore.virtuozzo.com/20261027-ptikhomirov-vstor-149268-cbt-account-at-rq-start-v4-0-b4d92264f6a4@virtuozzo.com
Changes in v4:
- Only queue the bitmap page allocation at submission instead of
allocating there: the sleeping allocation dropped the RCU lock in the
middle of the cbt_list walk, and could put an extent into the cache of
a cbt that a resize had just replaced (sashiko review).
- Link to v3: http://lore.virtuozzo.com/20261027-ptikhomirov-vstor-149268-cbt-account-at-rq-start-v3-0-e1bc61a829a0@virtuozzo.com
Changes in v3:
- New patch: account a write delayed by blk-throttle in CBT, as the
throttle dispatch work skipped CBT (sashiko review).
- New patch: shift the CBT block size as unsigned, and use the unsigned
shift in the new cbt_set_present() too (sashiko review).
- Link to v2: http://lore.virtuozzo.com/20261027-ptikhomirov-vstor-149268-cbt-account-at-rq-start-v2-1-c64ee6178730@virtuozzo.com
Changes in v2:
- No GFP_ATOMIC allocation at dispatch: bitmap pages are now allocated
at bio submission, and the dispatch hook only sets bits in present pages.
- A page missing at dispatch (a write submitted before BLKCBTSTART) is
allocated with GFP_NOIO from the kblockd workqueue, and dm-rq returns
BLK_STS_RESOURCE so that blk-mq dispatches the request again later,
instead of setting CBT_ERROR when an atomic allocation fails.
- Move the hook from dm_start_request() to dm_mq_queue_rq(), before the
request is started, so that it can return BLK_STS_RESOURCE.
- Link to v1: http://lore.virtuozzo.com/20261016-ptikhomirov-vstor-149268-cbt-account-at-rq-start-v1-1-1f20b151431d@virtuozzo.com
---
Pavel Tikhomirov (8):
block/blk-cbt: don't read a released cbt in blk_cbt_update_size()
block/blk-cbt: shift the block size as unsigned
block/blk-throttle: account a throttled write in CBT
block/blk-cbt: read a map slot once, publish a map page with release
block/blk-cbt: don't overwrite a map page with CBT_PAGE_MISSED
block/blk-cbt: walk cbt_list under SRCU
block/blk-cbt: don't sleep in CBT for a REQ_NOWAIT write
block/blk-cbt: account a write request also when dm starts it
block/blk-cbt.c | 308 ++++++++++++++++++++++++++++++++++++++++++-------
block/blk-core.c | 5 +-
block/blk-throttle.c | 5 +-
drivers/md/dm-rq.c | 3 +
include/linux/blkdev.h | 12 +-
5 files changed, 288 insertions(+), 45 deletions(-)
---
base-commit: f5d1fdcfffe101fe2bafa7df09d95d2e811c5c5e
change-id: 20261016-ptikhomirov-vstor-149268-cbt-account-at-rq-start-a592cf2010aa
Best regards,
--
Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next reply other threads:[~2026-10-28 10:13 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 10:11 Pavel Tikhomirov [this message]
2026-10-28 10:11 ` [Devel] [PATCH hci-8.1 v7 1/8] block/blk-cbt: don't read a released cbt in blk_cbt_update_size() Pavel Tikhomirov
2026-10-28 10:16 ` no-reply
2026-10-28 10:11 ` [Devel] [PATCH hci-8.1 v7 2/8] block/blk-cbt: shift the block size as unsigned Pavel Tikhomirov
2026-10-28 10:16 ` no-reply
2026-10-28 10:11 ` [Devel] [PATCH hci-8.1 v7 3/8] block/blk-throttle: account a throttled write in CBT Pavel Tikhomirov
2026-10-28 10:18 ` no-reply
2026-10-28 10:11 ` [Devel] [PATCH hci-8.1 v7 4/8] block/blk-cbt: read a map slot once, publish a map page with release Pavel Tikhomirov
2026-10-28 10:18 ` no-reply
2026-10-28 10:11 ` [Devel] [PATCH hci-8.1 v7 5/8] block/blk-cbt: don't overwrite a map page with CBT_PAGE_MISSED Pavel Tikhomirov
2026-10-28 10:21 ` no-reply
2026-10-28 10:11 ` [Devel] [PATCH hci-8.1 v7 6/8] block/blk-cbt: walk cbt_list under SRCU Pavel Tikhomirov
2026-10-28 10:20 ` no-reply
2026-10-28 10:11 ` [Devel] [PATCH hci-8.1 v7 7/8] block/blk-cbt: don't sleep in CBT for a REQ_NOWAIT write Pavel Tikhomirov
2026-10-28 10:23 ` no-reply
2026-10-28 10:11 ` [Devel] [PATCH hci-8.1 v7 8/8] block/blk-cbt: account a write request also when dm starts it Pavel Tikhomirov
2026-10-28 10:25 ` no-reply
2026-11-03 18:02 ` Konstantin Khorenko
2026-11-04 12:10 ` [Devel] [PATCH hci-8.1 v8 " Pavel Tikhomirov
2026-11-03 18:02 ` [Devel] [PATCH hci-8.1 v7 0/8] block/blk-cbt: don't lose writes held across a dm suspend Konstantin Khorenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261028-ptikhomirov-vstor-149268-cbt-account-at-rq-start-v7-0-5c48672191c2@virtuozzo.com \
--to=ptikhomirov@virtuozzo.com \
--cc=devel@openvz.org \
--cc=khorenko@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.