From: Samuel Moelius <sam.moelius@trailofbits.com>
To: Alasdair Kergon <agk@redhat.com>
Cc: Samuel Moelius <sam.moelius@trailofbits.com>,
Mike Snitzer <snitzer@kernel.org>,
Mikulas Patocka <mpatocka@redhat.com>,
Benjamin Marzinski <bmarzins@redhat.com>,
dm-devel@lists.linux.dev (open list:DEVICE-MAPPER (LVM)),
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] dm ebs: drop dirty bufio state when discarding blocks
Date: Wed, 3 Jun 2026 17:51:50 +0000 [thread overview]
Message-ID: <20260603175151.25026-1-sam.moelius@trailofbits.com> (raw)
dm-ebs can discard a block while a dirty dm-bufio buffer for the
same block is still cached. If that buffer is later written back,
stale data can be written over the discarded state.
That resurrects data that userspace explicitly discarded and breaks
the expected discard semantics of the target.
Invalidate or clean the matching bufio state when processing discards
so that old dirty buffers cannot be written back after the discard.
Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <sam.moelius@trailofbits.com>
---
drivers/md/dm-ebs-target.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/md/dm-ebs-target.c b/drivers/md/dm-ebs-target.c
index 1e52bde48b91..9fece535a0b3 100644
--- a/drivers/md/dm-ebs-target.c
+++ b/drivers/md/dm-ebs-target.c
@@ -212,8 +212,12 @@ static void __ebs_process_bios(struct work_struct *ws)
write = true;
r = __ebs_rw_bio(ec, REQ_OP_WRITE, bio);
} else if (bio_op(bio) == REQ_OP_DISCARD) {
- __ebs_forget_bio(ec, bio);
- r = __ebs_discard_bio(ec, bio);
+ if (write)
+ r = dm_bufio_write_dirty_buffers(ec->bufio);
+ if (!r) {
+ __ebs_forget_bio(ec, bio);
+ r = __ebs_discard_bio(ec, bio);
+ }
}
if (r < 0)
--
2.43.0
next reply other threads:[~2026-06-03 17:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 17:51 Samuel Moelius [this message]
2026-06-08 14:16 ` [PATCH] dm ebs: drop dirty bufio state when discarding blocks Mikulas Patocka
2026-06-08 16:03 ` Samuel Moelius
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=20260603175151.25026-1-sam.moelius@trailofbits.com \
--to=sam.moelius@trailofbits.com \
--cc=agk@redhat.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mpatocka@redhat.com \
--cc=snitzer@kernel.org \
/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.