]> git.baikalelectronics.ru Git - kernel.git/commitdiff
null_blk: Fix zone write handling
authorDamien Le Moal <damien.lemoal@wdc.com>
Thu, 9 Jan 2020 05:03:55 +0000 (14:03 +0900)
committerJens Axboe <axboe@kernel.dk>
Wed, 15 Jan 2020 15:18:39 +0000 (08:18 -0700)
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: 96173c746975 ("null_blk: add zone open, close, and finish support")
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/null_blk_zoned.c

index 5cf49d9db95e550df909d1508501ab5140643c85..ed34785dd64bd7b913d8003993e4b741fd58eb41 100644 (file)
@@ -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;