Re: [PATCHv12 06/12] block: expose write streams for block device nodes

Nitesh Shetty
2024-12-10T06:16:50Z

[-- Attachment #1: Type: text/plain, Size: 1975 bytes --]

On 06/12/24 02:17PM, Keith Busch wrote:
>From: Christoph Hellwig <hch@lst.de>
>
>Export statx information about the number and granularity of write
>streams, use the per-kiocb write hint and map temperature hints
>to write streams (which is a bit questionable, but this shows how it is
>done).
>
>Signed-off-by: Christoph Hellwig <hch@lst.de>
>Signed-off-by: Keith Busch <kbusch@kernel.org>
>---
> block/bdev.c | 6 ++++++
> block/fops.c | 23 +++++++++++++++++++++++
> 2 files changed, 29 insertions(+)
>
>diff --git a/block/bdev.c b/block/bdev.c
>index 738e3c8457e7f..c23245f1fdfe3 100644
>--- a/block/bdev.c
>+++ b/block/bdev.c
>@@ -1296,6 +1296,12 @@ void bdev_statx(struct path *path, struct kstat *stat,
> stat->result_mask |= STATX_DIOALIGN;
> }
>
>+ if ((request_mask & STATX_WRITE_STREAM) &&
We may not reach this point, if user application doesn't set either of
STATX_DIOALIGN or STATX_WRITE_ATOMIC.

>+ bdev_max_write_streams(bdev)) {
>+ stat->write_stream_max = bdev_max_write_streams(bdev);
>+ stat->result_mask |= STATX_WRITE_STREAM;
statx will show value of 0 for write_stream_granularity.

Below is the fix which might help you,

diff --git a/block/bdev.c b/block/bdev.c
index c23245f1fdfe..290577e20457 100644
--- a/block/bdev.c
+++ b/block/bdev.c
@@ -1275,7 +1275,8 @@ void bdev_statx(struct path *path, struct kstat *stat,
struct inode *backing_inode;
struct block_device *bdev;

- if (!(request_mask & (STATX_DIOALIGN | STATX_WRITE_ATOMIC)))
+ if (!(request_mask & (STATX_DIOALIGN | STATX_WRITE_ATOMIC |
+ STATX_WRITE_STREAM)))
return;

backing_inode = d_backing_inode(path->dentry);
@@ -1299,6 +1300,7 @@ void bdev_statx(struct path *path, struct kstat *stat,
if ((request_mask & STATX_WRITE_STREAM) &&
bdev_max_write_streams(bdev)) {
stat->write_stream_max = bdev_max_write_streams(bdev);
+ stat->write_stream_granularity = bdev_write_stream_granularity(bdev);
stat->result_mask |= STATX_WRITE_STREAM;
}

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]