A zone append that the server completes short is ended in full, so the caller is told that the whole bio was written while its tail never was. Requeueing the rest, as is done for a short write, doesn't work either: the rest is sent as a new zone append and written again at the moved write pointer, and blk_update_request() then fails the bio anyway. Fail a short zone append with BLK_STS_IOERR. Fixes: 29802d7ca33b ("ublk: enable zoned storage support") Signed-off-by: Ming Lei --- drivers/block/ublk_drv.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c index 69778b34ffd0..00ed6d9c8e98 100644 --- a/drivers/block/ublk_drv.c +++ b/drivers/block/ublk_drv.c @@ -1597,11 +1597,18 @@ static inline void __ublk_complete_rq(struct request *req, struct ublk_io *io, * FLUSH, DISCARD, WRITE_ZEROES and zone management requests usually * don't return a byte count, so end them directly. So is report zones * (DRV_IN): its reply can be shorter than the buffer, and a requeued - * rest would rerun the report. So is zone append: a requeued rest would - * be appended again at a moved write pointer. + * rest would rerun the report. + * + * A zone append can't be completed in part: a requeued rest would be + * appended again at a moved write pointer. Fail a short one, as + * blk_update_request() does for a partial zone append. */ - if (req_op(req) != REQ_OP_READ && req_op(req) != REQ_OP_WRITE) + if (req_op(req) != REQ_OP_READ && req_op(req) != REQ_OP_WRITE) { + if (req_op(req) == REQ_OP_ZONE_APPEND && + (unsigned int)io->res < blk_rq_bytes(req)) + res = BLK_STS_IOERR; goto exit; + } /* * Nothing to copy for WRITE, user copy, zero copy, auto buffer -- 2.56.1