Re: [RESEND PATCH] dm-ebs: Mark full buffer dirty even on partial write

Mikulas Patocka
2025-11-19T17:26:27Z

On Wed, 19 Nov 2025, Christoph Hellwig wrote:

> On Tue, Nov 18, 2025 at 06:21:56PM +0100, Mikulas Patocka wrote:
> > OK - I accepted Uladzislau's patch. As logical block size and physical
> > block size seem to be unreliable, it's better to set the size in dm-ebs.
>
> logical and physical block size are reliable. Uladzislau just seems
> to have a completely broken device that needs fixing, because it will

He created a qemu-emulated NVMe device with physical and logical block
size 8192 in a virtual machine. And logical block size was reported as 512
in the guest kernel - so it is either a qemu bug or a kernel bug.

> run into all kinds of other problems otherwise.

Hmm, Linux may get it wrong too. See this piece of code in
include/linux/blkdev.h:

#ifdef CONFIG_TRANSPARENT_HUGEPAGE
/*
* We should strive for 1 << (PAGE_SHIFT + MAX_PAGECACHE_ORDER)
* however we constrain this to what we can validate and test.
*/
#define BLK_MAX_BLOCK_SIZE SZ_64K
#else
#define BLK_MAX_BLOCK_SIZE PAGE_SIZE
#endif

/* blk_validate_limits() validates bsize, so drivers don't usually need to */
static inline int blk_validate_block_size(unsigned long bsize)
{
if (bsize < 512 || bsize > BLK_MAX_BLOCK_SIZE || !is_power_of_2(bsize))
return -EINVAL;

return 0;
}

in nvme_update_disk_info there is this piece of code:
if (blk_validate_block_size(bs)) {
bs = (1 << 9);
valid = false;
}

So, the valid block size depends on whether CONFIG_TRANSPARENT_HUGEPAGE is
defined, which is quite weird.

Mikulas