* [PATCH] ublk: use global index for reported zones
@ 2026-09-29 7:00 lirongqing
2026-09-29 9:15 ` Ming Lei
0 siblings, 1 reply; 3+ messages in thread
From: lirongqing @ 2026-09-29 7:00 UTC (permalink / raw)
To: Ming Lei, Jens Axboe, Andreas Hindborg, linux-block, linux-kernel
Cc: Li RongQing
From: Li RongQing <lirongqing@baidu.com>
ublk_report_zones() may split a zone report into multiple requests when
the number of zones exceeds the temporary buffer capacity. The index
passed to disk_report_zone() must refer to the zone position in the
whole report, rather than the position within the current request.
Currently, the per-request loop index is used as the callback index,
causing each chunk after the first one to restart from zero. This can
make userspace callbacks receive duplicate zone indices and may result
in blk_revalidate_disk_zones() updating incorrect entries in its zone
state array.
Use the number of zones already reported as the base index for each
request so that zone indices remain continuous across all chunks.
Fixes: 29802d7ca33b ("ublk: enable zoned storage support")
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
drivers/block/ublk_drv.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 66eb55e..007e703 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -649,6 +649,7 @@ static int ublk_report_zones(struct gendisk *disk, sector_t sector,
unsigned int remaining_zones = nr_zones - done_zones;
unsigned int zones_in_request =
min_t(unsigned int, remaining_zones, max_zones_per_request);
+ unsigned int batch_start = done_zones;
struct request *req;
struct ublk_zoned_report_desc desc;
blk_status_t status;
@@ -687,7 +688,7 @@ static int ublk_report_zones(struct gendisk *disk, sector_t sector,
if (!zone->len)
break;
- ret = disk_report_zone(disk, zone, i, args);
+ ret = disk_report_zone(disk, zone, batch_start + i, args);
if (ret)
goto out;
--
2.9.4
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ublk: use global index for reported zones
2026-09-29 7:00 [PATCH] ublk: use global index for reported zones lirongqing
@ 2026-09-29 9:15 ` Ming Lei
2026-09-29 9:51 ` 答复: [????] " Li,Rongqing
0 siblings, 1 reply; 3+ messages in thread
From: Ming Lei @ 2026-09-29 9:15 UTC (permalink / raw)
To: lirongqing; +Cc: Jens Axboe, Andreas Hindborg, linux-block, linux-kernel
On Tue, Sep 29, 2026 at 03:00:12PM +0800, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
>
> ublk_report_zones() may split a zone report into multiple requests when
> the number of zones exceeds the temporary buffer capacity. The index
> passed to disk_report_zone() must refer to the zone position in the
> whole report, rather than the position within the current request.
>
> Currently, the per-request loop index is used as the callback index,
> causing each chunk after the first one to restart from zero. This can
> make userspace callbacks receive duplicate zone indices and may result
> in blk_revalidate_disk_zones() updating incorrect entries in its zone
> state array.
>
> Use the number of zones already reported as the base index for each
> request so that zone indices remain continuous across all chunks.
>
> Fixes: 29802d7ca33b ("ublk: enable zoned storage support")
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> ---
> drivers/block/ublk_drv.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> index 66eb55e..007e703 100644
> --- a/drivers/block/ublk_drv.c
> +++ b/drivers/block/ublk_drv.c
> @@ -649,6 +649,7 @@ static int ublk_report_zones(struct gendisk *disk, sector_t sector,
> unsigned int remaining_zones = nr_zones - done_zones;
> unsigned int zones_in_request =
> min_t(unsigned int, remaining_zones, max_zones_per_request);
> + unsigned int batch_start = done_zones;
> struct request *req;
> struct ublk_zoned_report_desc desc;
> blk_status_t status;
> @@ -687,7 +688,7 @@ static int ublk_report_zones(struct gendisk *disk, sector_t sector,
> if (!zone->len)
> break;
>
> - ret = disk_report_zone(disk, zone, i, args);
> + ret = disk_report_zone(disk, zone, batch_start + i, args);
`done_zones` can be passed directly, then we can save one local variable,
otherwise, this patch looks fine:
Reviewed-by: Ming Lei <tom.leiming@gmail.com>
Thanks,
Ming
^ permalink raw reply [flat|nested] 3+ messages in thread* 答复: [????] Re: [PATCH] ublk: use global index for reported zones
2026-09-29 9:15 ` Ming Lei
@ 2026-09-29 9:51 ` Li,Rongqing
0 siblings, 0 replies; 3+ messages in thread
From: Li,Rongqing @ 2026-09-29 9:51 UTC (permalink / raw)
To: Ming Lei; +Cc: Jens Axboe, Andreas Hindborg, linux-block, linux-kernel
nes() may split a zone report into multiple requests
> > when the number of zones exceeds the temporary buffer capacity. The
> > index passed to disk_report_zone() must refer to the zone position in
> > the whole report, rather than the position within the current request.
> >
> > Currently, the per-request loop index is used as the callback index,
> > causing each chunk after the first one to restart from zero. This can
> > make userspace callbacks receive duplicate zone indices and may result
> > in blk_revalidate_disk_zones() updating incorrect entries in its zone
> > state array.
> >
> > Use the number of zones already reported as the base index for each
> > request so that zone indices remain continuous across all chunks.
> >
> > Fixes: 29802d7ca33b ("ublk: enable zoned storage support")
> > Signed-off-by: Li RongQing <lirongqing@baidu.com>
> > ---
> > drivers/block/ublk_drv.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c index
> > 66eb55e..007e703 100644
> > --- a/drivers/block/ublk_drv.c
> > +++ b/drivers/block/ublk_drv.c
> > @@ -649,6 +649,7 @@ static int ublk_report_zones(struct gendisk *disk,
> sector_t sector,
> > unsigned int remaining_zones = nr_zones - done_zones;
> > unsigned int zones_in_request =
> > min_t(unsigned int, remaining_zones, max_zones_per_request);
> > + unsigned int batch_start = done_zones;
> > struct request *req;
> > struct ublk_zoned_report_desc desc;
> > blk_status_t status;
> > @@ -687,7 +688,7 @@ static int ublk_report_zones(struct gendisk *disk,
> sector_t sector,
> > if (!zone->len)
> > break;
> >
> > - ret = disk_report_zone(disk, zone, i, args);
> > + ret = disk_report_zone(disk, zone, batch_start + i, args);
>
> `done_zones` can be passed directly, then we can save one local variable,
> otherwise, this patch looks fine:
>
Thanks, I will send v2
[Li,Rongqing]
> Reviewed-by: Ming Lei <tom.leiming@gmail.com>
>
>
> Thanks,
> Ming
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-29 9:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-29 7:00 [PATCH] ublk: use global index for reported zones lirongqing
2026-09-29 9:15 ` Ming Lei
2026-09-29 9:51 ` 答复: [????] " Li,Rongqing
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®