Re: [PATCH 02/12] zloop: take freeze protection for writes
From: Christoph Hellwig
Date: Mon Nov 16 2026 - 01:47:15 EST
On Sat, Nov 14, 2026 at 11:47:09AM +0100, Christian Brauner wrote:
> --- a/drivers/block/zloop.c
> +++ b/drivers/block/zloop.c
> @@ -514,6 +514,10 @@ static void zloop_rw_complete(struct kiocb *iocb, long ret)
> {
> struct zloop_cmd *cmd = container_of(iocb, struct zloop_cmd, iocb);
>
> + /* A queued write still holds freeze protection. */
> + if (req_op(blk_mq_rq_from_pdu(cmd)) != REQ_OP_READ)
> + kiocb_end_write(iocb);
So io_uring, libario and cachefiles use the IOCB_WRITE flag on the
ioctl to make this somewhat generic.
> + if (rw == ITER_DEST)
> + return zone->file->f_op->read_iter(&cmd->iocb, &iter);
> +
> + kiocb_start_write(&cmd->iocb);
> + ret = zone->file->f_op->write_iter(&cmd->iocb, &iter);
> + if (ret != -EIOCBQUEUED)
> + kiocb_end_write(&cmd->iocb);
> + return ret;
And then everyone duplicates this. Do we want a little abstraction
for the above code + setting IOCB_WRITE, and then another one takes care
of the kiocb_end_write before or after calling into ->ki_complete?
Without that this is a lot of opencoding that feels a bit fragile.