public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Keith Busch <kbusch@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, linux-kselftest@vger.kernel.org,
	Caleb Sander Mateos <csander@purestorage.com>
Subject: Re: [PATCH V2 3/3] selftests: ublk: add ublk zero copy test
Date: Thu, 27 Feb 2025 08:25:00 +0800	[thread overview]
Message-ID: <Z7-w3PAczKYn-d6s@fedora> (raw)
In-Reply-To: <Z79SV8gD1hah9PVD@kbusch-mbp>

On Wed, Feb 26, 2025 at 10:41:43AM -0700, Keith Busch wrote:
> On Wed, Feb 26, 2025 at 11:58:38PM +0800, Ming Lei wrote:
> > +	struct io_uring_sqe *reg;
> > +	struct io_uring_sqe *rw;
> > +	struct io_uring_sqe *ureg;
> > +
> > +	if (!zc) {
> > +		rw = ublk_queue_alloc_sqe(q);
> > +		if (!rw)
> > +			return -ENOMEM;
> > +
> > +		io_uring_prep_rw(op, rw, 1 /*fds[1]*/,
> > +				(void *)iod->addr,
> > +				iod->nr_sectors << 9,
> > +				iod->start_sector << 9);
> > +		io_uring_sqe_set_flags(rw, IOSQE_FIXED_FILE);
> > +		q->io_inflight++;
> > +		/* bit63 marks us as tgt io */
> > +		rw->user_data = build_user_data(tag, op, UBLK_IO_TGT_NORMAL, 1);
> > +		return 0;
> > +	}
> > +
> > +	ublk_queue_alloc_sqe3(q, &reg, &rw, &ureg);
> > +
> > +	io_uring_prep_buf_register(reg, 0, tag, q->q_id, tag);
> > +	reg->user_data = build_user_data(tag, 0xfe, 1, 1);
> > +	reg->flags |= IOSQE_CQE_SKIP_SUCCESS;
> > +	reg->flags |= IOSQE_IO_LINK;
> > +
> > +	io_uring_prep_rw(op, rw, 1 /*fds[1]*/, 0,
> > +		iod->nr_sectors << 9,
> > +		iod->start_sector << 9);
> > +	rw->buf_index = tag;
> > +	rw->flags |= IOSQE_FIXED_FILE;
> > +	rw->flags |= IOSQE_IO_LINK;
> > +	rw->user_data = build_user_data(tag, op, UBLK_IO_TGT_ZC_OP, 1);
> > +	q->io_inflight++;
> > +
> > +	io_uring_prep_buf_unregister(ureg, 0, tag, q->q_id, tag);
> > +	ureg->user_data = build_user_data(tag, 0xff, UBLK_IO_TGT_ZC_BUF, 1);
> 
> You don't have anything handling the unregister command's completion so
> I think you want the IOSQE_CQE_SKIP_SUCCESS flag on it otherwise you get
> an unexpected CQE for it.

Please see ublk_loop_io_done() which does handle unregister command by
the flag of UBLK_IO_TGT_ZC_BUF. And it is reasonable to complete the
io command after the whole link is done.

BTW, with this way, one ublk bug is actually triggered, and Caleb's patch
fixes it.


Thanks,
Ming


      reply	other threads:[~2025-02-27  0:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-26 15:58 [PATCH V2 0/3] selftests: add ublk selftests Ming Lei
2025-02-26 15:58 ` [PATCH V2 1/3] selftests: ublk: add kernel selftests for ublk Ming Lei
2025-02-26 15:58 ` [PATCH V2 2/3] selftests: ublk: add file backed ublk Ming Lei
2025-02-26 15:58 ` [PATCH V2 3/3] selftests: ublk: add ublk zero copy test Ming Lei
2025-02-26 17:41   ` Keith Busch
2025-02-27  0:25     ` Ming Lei [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z7-w3PAczKYn-d6s@fedora \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=csander@purestorage.com \
    --cc=kbusch@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox