Skip to contentSkip to conversation

file-posix: fix zone write granularity assignment for zoned block devices

PATCH Superseded Niklas Cassel 3 participants 4 messages Aug 7 – Aug 11 Block layer

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 file-posix: fix zone write granularity assignment for zoned block devices

In the ZBC and ZAC specifications, the requirement is that the write granularity matches the physical block size.

However, in the ZNS specification, the requirement is simply that the write granularity matches the logical block size.

See:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a805a4fa4fa376bbc145762bb8b09caa2fa8af48

In Linux, there is a zone_write_granularity sysfs property which abstracts this away by providing, so let's make use of it.

Currently, it is theoretically possible that QEMU presents an inflated write granularity for NVMe devices where the physical block size is larger than the logical block size.

Fixes a3c41f06d5a8 ("file-posix: add tracking of the zone write pointers")
---
 block/file-posix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/file-posix.c +1 -1
index 3c985da94f..63c52b1044 100644
@@ -1495,7 +1495,7 @@ static void raw_refresh_zoned_limits(BlockDriverState *bs, struct stat *st,
         bs->bl.max_append_sectors = ret >> BDRV_SECTOR_BITS;
     }
 
-    ret = get_sysfs_long_val(st, "physical_block_size");
+    ret = get_sysfs_long_val(st, "zone_write_granularity");
     if (ret >= 0) {
         bs->bl.write_granularity = ret;
     }
Signature · 1 line
2.55.0
#1 lore raw
Quoted 11 lines · Niklas Cassel

In the ZBC and ZAC specifications, the requirement is that the write granularity matches the physical block size.

However, in the ZNS specification, the requirement is simply that the write granularity matches the logical block size.

See:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a805a4fa4fa376bbc145762bb8b09caa2fa8af48

In Linux, there is a zone_write_granularity sysfs property which abstracts this away by providing, so let's make use of it.

nit:
this away, so let's make use of it.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Niklas Cassel
Quoted 11 lines · Niklas Cassel

In the ZBC and ZAC specifications, the requirement is that the write granularity matches the physical block size.

However, in the ZNS specification, the requirement is simply that the write granularity matches the logical block size.

See:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a805a4fa4fa376bbc145762bb8b09caa2fa8af48

In Linux, there is a zone_write_granularity sysfs property which abstracts this away by providing, so let's make use of it.

s/by providing// ? Seems like the sentence is not complete otherwise...

Quoted 7 lines

Currently, it is theoretically possible that QEMU presents an inflated write granularity for NVMe devices where the physical block size is larger than the logical block size.

Fixes a3c41f06d5a8 ("file-posix: add tracking of the zone write pointers")

Other than that, looks OK to me.

Signature · 2 lines
Damien Le Moal
Western Digital Research
Reviewed-by on v1 1/1
#3 lore raw
In reply to Niklas Cassel
Quoted 16 lines · Niklas Cassel

In the ZBC and ZAC specifications, the requirement is that the write granularity matches the physical block size.

However, in the ZNS specification, the requirement is simply that the write granularity matches the logical block size.

See:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a805a4fa4fa376bbc145762bb8b09caa2fa8af48

In Linux, there is a zone_write_granularity sysfs property which abstracts this away by providing, so let's make use of it.

Currently, it is theoretically possible that QEMU presents an inflated write granularity for NVMe devices where the physical block size is larger than the logical block size.

Quoted 5 lines
Fixes a3c41f06d5a8 ("file-posix: add tracking of the zone write pointers")
---
 block/file-posix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)