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 1/5] loop: remove 'rw' parameter from lo_rw_aio()
Date: Mon, 10 Mar 2025 03:46:52 -0700 [thread overview]
Message-ID: <Z87DHHqd-HNPIpUG@infradead.org> (raw)
In-Reply-To: <20250308162312.1640828-2-ming.lei@redhat.com>
On Sun, Mar 09, 2025 at 12:23:05AM +0800, Ming Lei wrote:
> lo_rw_aio() is only called for READ/WRITE operation, which can be
> figured out from request directly, so remove 'rw' parameter from
> lo_rw_aio(), meantime rename the local variable as 'dir' which matches
> the actual use more.
>
> Meantime merge lo_read_simple() and lo_write_simple() into
> lo_rw_simple().
That's two entirely separate things, please split them into separate
patches.
static int lo_rw_simple(struct loop_device *lo, struct request *rq, loff_t pos)
> {
> struct bio_vec bvec;
> struct req_iterator iter;
> struct iov_iter i;
> ssize_t len;
>
> + if (req_op(rq) == REQ_OP_WRITE) {
> + int ret;
> +
> + rq_for_each_segment(bvec, rq, iter) {
> + ret = lo_write_bvec(lo->lo_backing_file, &bvec, &pos);
> + if (ret < 0)
> + break;
> + cond_resched();
> + }
> + return ret;
> + }
> +
> rq_for_each_segment(bvec, rq, iter) {
.. and nothing is really merged here. So unless you actually merge
some code later this part doesn't seem particularly useful.
> struct request *rq = blk_mq_rq_from_pdu(cmd);
> + int dir = (req_op(rq) == REQ_OP_READ) ? ITER_DEST : ITER_SOURCE;
> struct bio *bio = rq->bio;
> struct file *file = lo->lo_backing_file;
> struct bio_vec tmp;
> @@ -448,7 +442,7 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
> }
> atomic_set(&cmd->ref, 2);
>
> - iov_iter_bvec(&iter, rw, bvec, nr_bvec, blk_rq_bytes(rq));
> + iov_iter_bvec(&iter, dir, bvec, nr_bvec, blk_rq_bytes(rq));
> iter.iov_offset = offset;
>
> cmd->iocb.ki_pos = pos;
> @@ -457,7 +451,7 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
> cmd->iocb.ki_flags = IOCB_DIRECT;
> cmd->iocb.ki_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);
>
> - if (rw == ITER_SOURCE)
> + if (dir == ITER_SOURCE)
i'd just use the request direction check here, and then open code
the iter source/dest in the iov_iter_bvec call.
> case REQ_OP_READ:
> if (cmd->use_aio)
> - return lo_rw_aio(lo, cmd, pos, ITER_DEST);
> + return lo_rw_aio(lo, cmd, pos);
> else
> - return lo_read_simple(lo, rq, pos);
> + return lo_rw_simple(lo, rq, pos);
Not entirely new here, but there is no reason to use an else after a
return.
next prev parent reply other threads:[~2025-03-10 10:46 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 [this message]
2025-03-08 16:23 ` [RESEND PATCH 2/5] loop: cleanup lo_rw_aio() Ming Lei
2025-03-10 11:07 ` Christoph Hellwig
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=Z87DHHqd-HNPIpUG@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.