From: Mikulas Patocka <mpatocka@redhat.com>
To: "Uladzislau Rezki (Sony)" <urezki@gmail.com>
Cc: Alasdair Kergon <agk@redhat.com>, DMML <dm-devel@lists.linux.dev>,
Andrew Morton <akpm@linux-foundation.org>,
Mike Snitzer <snitzer@redhat.com>,
Christoph Hellwig <hch@lst.de>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [RESEND PATCH] dm-ebs: Mark full buffer dirty even on partial write
Date: Mon, 17 Nov 2025 21:48:49 +0100 (CET) [thread overview]
Message-ID: <fff990bc-6ff9-7b34-8e80-57078de40928@redhat.com> (raw)
In-Reply-To: <20251117105945.10179-1-urezki@gmail.com>
Hi
What is the logical_block_size of the underlying nvme device? - i.e.
what's the content of this file
/sys/block/nvme0n1/queue/logical_block_size in the virtual machine?
Mikulas
On Mon, 17 Nov 2025, Uladzislau Rezki (Sony) wrote:
> When performing a read-modify-write(RMW) operation, any modification
> to a buffered block must cause the entire buffer to be marked dirty.
>
> Marking only a subrange as dirty is incorrect because the underlying
> device block size(ubs) defines the minimum read/write granularity. A
> lower device can perform I/O only on regions which are fully aligned
> and sized to ubs.
>
> This change ensures that write-back operations always occur in full
> ubs-sized chunks, matching the intended emulation semantics of the
> EBS target.
>
> As for user space visible impact, submitting sub-ubs and misaligned
> I/O for devices which are tuned to ubs sizes only, will reject such
> requests, therefore it can lead to losing data. Example:
>
> 1) Create a 8K nvme device in qemu by adding
>
> -device nvme,drive=drv0,serial=foo,logical_block_size=8192,physical_block_size=8192
>
> 2) Setup dm-ebs to emulate 512B to 8K mapping
>
> urezki@pc638:~/bin$ cat dmsetup.sh
>
> lower=/dev/nvme0n1
> len=$(blockdev --getsz "$lower")
>
> echo "0 $len ebs $lower 0 1 16" | dmsetup create nvme-8k
> urezki@pc638:~/bin$
>
> offset 0, ebs=1 and ubs=16(in sectors).
>
> 3) Create an ext4 filesystem(default 4K block size)
>
> urezki@pc638:~/bin$ sudo mkfs.ext4 -F /dev/dm-0
> mke2fs 1.47.0 (5-Feb-2023)
> Discarding device blocks: done
> Creating filesystem with 2072576 4k blocks and 518144 inodes
> Filesystem UUID: bd0b6ca6-0506-4e31-86da-8d22c9d50b63
> Superblock backups stored on blocks:
> 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
>
> Allocating group tables: done
> Writing inode tables: done
> Creating journal (16384 blocks): done
> Writing superblocks and filesystem accounting information: mkfs.ext4: Input/output error while writing out and closing file system
> urezki@pc638:~/bin$ dmesg
>
> <snip>
> [ 1618.875449] buffer_io_error: 1028 callbacks suppressed
> [ 1618.875456] Buffer I/O error on dev dm-0, logical block 0, lost async page write
> [ 1618.875527] Buffer I/O error on dev dm-0, logical block 1, lost async page write
> [ 1618.875602] Buffer I/O error on dev dm-0, logical block 2, lost async page write
> [ 1618.875620] Buffer I/O error on dev dm-0, logical block 3, lost async page write
> [ 1618.875639] Buffer I/O error on dev dm-0, logical block 4, lost async page write
> [ 1618.894316] Buffer I/O error on dev dm-0, logical block 5, lost async page write
> [ 1618.894358] Buffer I/O error on dev dm-0, logical block 6, lost async page write
> [ 1618.894380] Buffer I/O error on dev dm-0, logical block 7, lost async page write
> [ 1618.894405] Buffer I/O error on dev dm-0, logical block 8, lost async page write
> [ 1618.894427] Buffer I/O error on dev dm-0, logical block 9, lost async page write
> <snip>
>
> Many I/O errors because the lower 8K device rejects sub-ubs/misaligned
> requests.
>
> with a patch:
>
> urezki@pc638:~/bin$ sudo mkfs.ext4 -F /dev/dm-0
> mke2fs 1.47.0 (5-Feb-2023)
> Discarding device blocks: done
> Creating filesystem with 2072576 4k blocks and 518144 inodes
> Filesystem UUID: 9b54f44f-ef55-4bd4-9e40-c8b775a616ac
> Superblock backups stored on blocks:
> 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
>
> Allocating group tables: done
> Writing inode tables: done
> Creating journal (16384 blocks): done
> Writing superblocks and filesystem accounting information: done
>
> urezki@pc638:~/bin$ sudo mount /dev/dm-0 /mnt/
> urezki@pc638:~/bin$ ls -al /mnt/
> total 24
> drwxr-xr-x 3 root root 4096 Oct 17 15:13 .
> drwxr-xr-x 19 root root 4096 Jul 10 19:42 ..
> drwx------ 2 root root 16384 Oct 17 15:13 lost+found
> urezki@pc638:~/bin$
>
> After this change: mkfs completes; mount succeeds.
>
> v1 -> v2:
> - reflect a user space visible impact in the commit message.
>
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> ---
> drivers/md/dm-ebs-target.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/md/dm-ebs-target.c b/drivers/md/dm-ebs-target.c
> index 6abb31ca9662..b354e74a670e 100644
> --- a/drivers/md/dm-ebs-target.c
> +++ b/drivers/md/dm-ebs-target.c
> @@ -103,7 +103,7 @@ static int __ebs_rw_bvec(struct ebs_c *ec, enum req_op op, struct bio_vec *bv,
> } else {
> flush_dcache_page(bv->bv_page);
> memcpy(ba, pa, cur_len);
> - dm_bufio_mark_partial_buffer_dirty(b, buf_off, buf_off + cur_len);
> + dm_bufio_mark_buffer_dirty(b);
> }
>
> dm_bufio_release(b);
> --
> 2.47.3
>
next prev parent reply other threads:[~2025-11-17 20:49 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-17 10:59 Uladzislau Rezki (Sony)
2025-11-17 20:48 ` Mikulas Patocka [this message]
2025-11-18 11:39 ` Uladzislau Rezki
2025-11-18 12:00 ` Mikulas Patocka
2025-11-18 12:40 ` Uladzislau Rezki
2025-11-18 12:46 ` Christoph Hellwig
2025-11-18 14:15 ` Benjamin Marzinski
2025-11-18 17:21 ` Mikulas Patocka
2025-11-19 5:46 ` Christoph Hellwig
2025-11-19 8:43 ` Uladzislau Rezki
2025-11-19 8:53 ` Christoph Hellwig
2025-11-19 8:57 ` Uladzislau Rezki
2025-11-19 9:00 ` Christoph Hellwig
2025-11-19 9:01 ` Uladzislau Rezki
2025-11-19 9:05 ` Christoph Hellwig
2025-11-19 9:13 ` Uladzislau Rezki
2025-11-19 9:17 ` Christoph Hellwig
2025-11-19 17:26 ` Mikulas Patocka
2025-11-20 6:21 ` Christoph Hellwig
2025-11-20 12:08 ` Uladzislau Rezki
2025-11-20 12:40 ` Uladzislau Rezki
2025-11-21 7:25 ` Christoph Hellwig
2025-11-21 7:24 ` Christoph Hellwig
2025-11-21 13:21 ` Uladzislau Rezki
2025-11-21 16:48 ` Benjamin Marzinski
2025-11-24 10:43 ` Uladzislau Rezki
2025-11-24 14:30 ` Christoph Hellwig
2025-11-24 15:30 ` Uladzislau Rezki
2025-11-24 17:00 ` Christoph Hellwig
2025-11-24 18:05 ` Uladzislau Rezki
-- strict thread matches above, loose matches on Subject: below --
2025-10-14 14:47 Uladzislau Rezki (Sony)
2025-10-16 19:59 ` Andrew Morton
2025-10-17 15:55 ` Uladzislau Rezki
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=fff990bc-6ff9-7b34-8e80-57078de40928@redhat.com \
--to=mpatocka@redhat.com \
--cc=agk@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dm-devel@lists.linux.dev \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=snitzer@redhat.com \
--cc=urezki@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®