public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] zloop: fix zone append check in zloop_rw()
@ 2025-11-19  4:34 Damien Le Moal
  2025-11-19  5:40 ` Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Damien Le Moal @ 2025-11-19  4:34 UTC (permalink / raw)
  To: Jens Axboe, linux-block; +Cc: Christoph Hellwig, Hans Holmberg

While commit cf28f6f923cb ("zloop: fail zone append operations that are
targeting full zones") added a check in zloop_rw() that a zone append is
not issued to a full zone, commit e3a96ca90462 ("zloop: simplify checks
for writes to sequential zones") inadvertently removed the check to
verify that there is enough unwritten space in a zone for an incoming
zone append opration.

Re-add this check in zloop_rw() to make sure we do not write beyond the
end of a zone. Of note is that this same check is already present in the
function zloop_set_zone_append_sector() when ordered zone append is in
use.

Reported-by: Hans Holmberg <Hans.Holmberg@wdc.com>
Fixes: e3a96ca90462 ("zloop: simplify checks for writes to sequential zones")
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
 drivers/block/zloop.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c
index c4da3116f7a9..1273bbca7843 100644
--- a/drivers/block/zloop.c
+++ b/drivers/block/zloop.c
@@ -448,7 +448,8 @@ static void zloop_rw(struct zloop_cmd *cmd)
 			 * and set the target sector in zloop_queue_rq().
 			 */
 			if (!zlo->ordered_zone_append) {
-				if (zone->cond == BLK_ZONE_COND_FULL) {
+				if (zone->cond == BLK_ZONE_COND_FULL ||
+				    zone->wp + nr_sectors > zone_end) {
 					spin_unlock_irqrestore(&zone->wp_lock,
 							       flags);
 					ret = -EIO;
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] zloop: fix zone append check in zloop_rw()
  2025-11-19  4:34 [PATCH] zloop: fix zone append check in zloop_rw() Damien Le Moal
@ 2025-11-19  5:40 ` Christoph Hellwig
  2025-11-19  9:01 ` Hans Holmberg
  2025-11-19 14:39 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2025-11-19  5:40 UTC (permalink / raw)
  To: Damien Le Moal; +Cc: Jens Axboe, linux-block, Christoph Hellwig, Hans Holmberg

On Wed, Nov 19, 2025 at 01:34:23PM +0900, Damien Le Moal wrote:
> While commit cf28f6f923cb ("zloop: fail zone append operations that are
> targeting full zones") added a check in zloop_rw() that a zone append is
> not issued to a full zone, commit e3a96ca90462 ("zloop: simplify checks
> for writes to sequential zones") inadvertently removed the check to
> verify that there is enough unwritten space in a zone for an incoming
> zone append opration.
> 
> Re-add this check in zloop_rw() to make sure we do not write beyond the
> end of a zone. Of note is that this same check is already present in the
> function zloop_set_zone_append_sector() when ordered zone append is in
> use.

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] zloop: fix zone append check in zloop_rw()
  2025-11-19  4:34 [PATCH] zloop: fix zone append check in zloop_rw() Damien Le Moal
  2025-11-19  5:40 ` Christoph Hellwig
@ 2025-11-19  9:01 ` Hans Holmberg
  2025-11-19 14:39 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Hans Holmberg @ 2025-11-19  9:01 UTC (permalink / raw)
  To: Damien Le Moal, Jens Axboe, linux-block@vger.kernel.org; +Cc: hch

On 19/11/2025 05:38, Damien Le Moal wrote:
> While commit cf28f6f923cb ("zloop: fail zone append operations that are
> targeting full zones") added a check in zloop_rw() that a zone append is
> not issued to a full zone, commit e3a96ca90462 ("zloop: simplify checks
> for writes to sequential zones") inadvertently removed the check to
> verify that there is enough unwritten space in a zone for an incoming
> zone append opration.
> 
> Re-add this check in zloop_rw() to make sure we do not write beyond the
> end of a zone. Of note is that this same check is already present in the
> function zloop_set_zone_append_sector() when ordered zone append is in
> use.
> 
> Reported-by: Hans Holmberg <Hans.Holmberg@wdc.com>
> Fixes: e3a96ca90462 ("zloop: simplify checks for writes to sequential zones")
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> ---
>  drivers/block/zloop.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c
> index c4da3116f7a9..1273bbca7843 100644
> --- a/drivers/block/zloop.c
> +++ b/drivers/block/zloop.c
> @@ -448,7 +448,8 @@ static void zloop_rw(struct zloop_cmd *cmd)
>  			 * and set the target sector in zloop_queue_rq().
>  			 */
>  			if (!zlo->ordered_zone_append) {
> -				if (zone->cond == BLK_ZONE_COND_FULL) {
> +				if (zone->cond == BLK_ZONE_COND_FULL ||
> +				    zone->wp + nr_sectors > zone_end) {
>  					spin_unlock_irqrestore(&zone->wp_lock,
>  							       flags);
>  					ret = -EIO;

Looks good,

Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] zloop: fix zone append check in zloop_rw()
  2025-11-19  4:34 [PATCH] zloop: fix zone append check in zloop_rw() Damien Le Moal
  2025-11-19  5:40 ` Christoph Hellwig
  2025-11-19  9:01 ` Hans Holmberg
@ 2025-11-19 14:39 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2025-11-19 14:39 UTC (permalink / raw)
  To: linux-block, Damien Le Moal; +Cc: Christoph Hellwig, Hans Holmberg


On Wed, 19 Nov 2025 13:34:23 +0900, Damien Le Moal wrote:
> While commit cf28f6f923cb ("zloop: fail zone append operations that are
> targeting full zones") added a check in zloop_rw() that a zone append is
> not issued to a full zone, commit e3a96ca90462 ("zloop: simplify checks
> for writes to sequential zones") inadvertently removed the check to
> verify that there is enough unwritten space in a zone for an incoming
> zone append opration.
> 
> [...]

Applied, thanks!

[1/1] zloop: fix zone append check in zloop_rw()
      commit: a9637ab93c6cfdf7a80a299b7de691dea6a7d7ba

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-11-19 14:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-19  4:34 [PATCH] zloop: fix zone append check in zloop_rw() Damien Le Moal
2025-11-19  5:40 ` Christoph Hellwig
2025-11-19  9:01 ` Hans Holmberg
2025-11-19 14:39 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox