diff mbox series

null_blk: Fix zone write handling

Message ID 20200109050355.585524-1-damien.lemoal@wdc.com (mailing list archive)
State New, archived
Headers show
Series null_blk: Fix zone write handling | expand

Commit Message

Damien Le Moal Jan. 9, 2020, 5:03 a.m. UTC
null_zone_write() only allows writing empty and implicitly opened zones.
Writing to closed and explicitly opened zones must also be allowed and
the zone condition must be transitioned to implicit open if the zone
is not explicitly opened already.

Fixes: da644b2cc1a4 ("null_blk: add zone open, close, and finish support")
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 drivers/block/null_blk_zoned.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Damien Le Moal Jan. 15, 2020, 7:29 a.m. UTC | #1
Jens,

Ping ?

On 2020/01/09 14:04, Damien Le Moal wrote:
> null_zone_write() only allows writing empty and implicitly opened zones.
> Writing to closed and explicitly opened zones must also be allowed and
> the zone condition must be transitioned to implicit open if the zone
> is not explicitly opened already.
> 
> Fixes: da644b2cc1a4 ("null_blk: add zone open, close, and finish support")
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> ---
>  drivers/block/null_blk_zoned.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/block/null_blk_zoned.c b/drivers/block/null_blk_zoned.c
> index 5cf49d9db95e..ed34785dd64b 100644
> --- a/drivers/block/null_blk_zoned.c
> +++ b/drivers/block/null_blk_zoned.c
> @@ -129,11 +129,13 @@ static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
>  		return BLK_STS_IOERR;
>  	case BLK_ZONE_COND_EMPTY:
>  	case BLK_ZONE_COND_IMP_OPEN:
> +	case BLK_ZONE_COND_EXP_OPEN:
> +	case BLK_ZONE_COND_CLOSED:
>  		/* Writes must be at the write pointer position */
>  		if (sector != zone->wp)
>  			return BLK_STS_IOERR;
>  
> -		if (zone->cond == BLK_ZONE_COND_EMPTY)
> +		if (zone->cond != BLK_ZONE_COND_EXP_OPEN)
>  			zone->cond = BLK_ZONE_COND_IMP_OPEN;
>  
>  		zone->wp += nr_sectors;
>
Jens Axboe Jan. 15, 2020, 3:18 p.m. UTC | #2
On 1/8/20 10:03 PM, Damien Le Moal wrote:
> null_zone_write() only allows writing empty and implicitly opened zones.
> Writing to closed and explicitly opened zones must also be allowed and
> the zone condition must be transitioned to implicit open if the zone
> is not explicitly opened already.

Applied, thanks.
diff mbox series

Patch

diff --git a/drivers/block/null_blk_zoned.c b/drivers/block/null_blk_zoned.c
index 5cf49d9db95e..ed34785dd64b 100644
--- a/drivers/block/null_blk_zoned.c
+++ b/drivers/block/null_blk_zoned.c
@@ -129,11 +129,13 @@  static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
 		return BLK_STS_IOERR;
 	case BLK_ZONE_COND_EMPTY:
 	case BLK_ZONE_COND_IMP_OPEN:
+	case BLK_ZONE_COND_EXP_OPEN:
+	case BLK_ZONE_COND_CLOSED:
 		/* Writes must be at the write pointer position */
 		if (sector != zone->wp)
 			return BLK_STS_IOERR;
 
-		if (zone->cond == BLK_ZONE_COND_EMPTY)
+		if (zone->cond != BLK_ZONE_COND_EXP_OPEN)
 			zone->cond = BLK_ZONE_COND_IMP_OPEN;
 
 		zone->wp += nr_sectors;