linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Subject: Re: [RESEND PATCH 2/5] loop: cleanup lo_rw_aio()
Date: Mon, 10 Mar 2025 12:07:41 +0100	[thread overview]
Message-ID: <Z87H_UGknDva9ixP@infradead.org> (raw)
In-Reply-To: <20250308162312.1640828-3-ming.lei@redhat.com>

On Sun, Mar 09, 2025 at 12:23:06AM +0800, Ming Lei wrote:
> +	if (rq->bio != rq->biotail) {

This would probably be more self-explaining by checking for cmd->bdev
here.

> +		bvec = cmd->bvec;
> +		offset = 0;
> +	} else {
> +		struct bio *bio = rq->bio;
> +
> +		offset = bio->bi_iter.bi_bvec_done;
> +		bvec = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter);
> +	}
> +	iov_iter_bvec(&iter, dir, bvec, nr_bvec, blk_rq_bytes(rq));
> +	iter.iov_offset = offset;

And given that bvec and offset are only used here I'd just move the
iov_iter_bvec into the branches and do away with the two variables,
and kill the bio variable as well while at it.

> +static inline unsigned lo_cmd_nr_bvec(struct loop_cmd *cmd)
> +{
> +	struct req_iterator rq_iter;
> +	struct request *rq = blk_mq_rq_from_pdu(cmd);
> +	struct bio_vec tmp;
> +	int nr_bvec = 0;
> +
>  	rq_for_each_bvec(tmp, rq, rq_iter)
>  		nr_bvec++;
>  
> +	return nr_bvec;
> +}
> +
> +static int lo_rw_aio_prep(struct loop_device *lo, struct loop_cmd *cmd,
> +			  unsigned nr_bvec)

The function order is a bit weird.  I would expect them to appear in
the rough order that they are called, e.g. lo_cmd_nr_bvec first, then
lo_rw_aio_prep, then the submit helper.

> -		/*
> -		 * Same here, this bio may be started from the middle of the
> -		 * 'bvec' because of bio splitting, so offset from the bvec
> -		 * must be passed to iov iterator
> -		 */

It would be good if this comment didn't get lost.


  reply	other threads:[~2025-03-10 11:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-08 16:23 [RESEND PATCH 0/5] loop: improve loop aio perf by IOCB_NOWAIT Ming Lei
2025-03-08 16:23 ` [RESEND PATCH 1/5] loop: remove 'rw' parameter from lo_rw_aio() Ming Lei
2025-03-09  7:30   ` kernel test robot
2025-03-10 10:46   ` Christoph Hellwig
2025-03-08 16:23 ` [RESEND PATCH 2/5] loop: cleanup lo_rw_aio() Ming Lei
2025-03-10 11:07   ` Christoph Hellwig [this message]
2025-03-08 16:23 ` [RESEND PATCH 3/5] loop: add helper loop_queue_work_prep Ming Lei
2025-03-09  7:30   ` kernel test robot
2025-03-10 11:11   ` Christoph Hellwig
2025-03-11  1:21     ` Ming Lei
2025-03-11  7:55       ` Christoph Hellwig
2025-03-08 16:23 ` [RESEND PATCH 4/5] loop: try to handle loop aio command via NOWAIT IO first Ming Lei
2025-03-10 11:14   ` Christoph Hellwig
2025-03-11  1:33     ` Ming Lei
2025-03-11  7:58       ` Christoph Hellwig
2025-03-11 10:55         ` Ming Lei
2025-03-08 16:23 ` [RESEND PATCH 5/5] loop: add module parameter of 'nr_hw_queues' Ming Lei
2025-03-10 11:15   ` Christoph Hellwig

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=Z87H_UGknDva9ixP@infradead.org \
    --to=hch@infradead.org \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).