lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CADUfDZocSmRC2uSiY=1gayxQ5TGAcCnKQRSg+4SeficpQ3Bfhw@mail.gmail.com>
Date: Mon, 10 Nov 2025 08:47:46 -0800
From: Caleb Sander Mateos <csander@...estorage.com>
To: Ming Lei <ming.lei@...hat.com>
Cc: Jens Axboe <axboe@...nel.dk>, Damien Le Moal <dlemoal@...nel.org>, Christoph Hellwig <hch@....de>, 
	linux-block@...r.kernel.org, linux-kernel@...r.kernel.org, 
	Keith Busch <kbusch@...nel.org>
Subject: Re: [PATCH 1/2] loop: use blk_rq_nr_phys_segments() instead of
 iterating bvecs

On Sun, Nov 9, 2025 at 4:20 AM Ming Lei <ming.lei@...hat.com> wrote:
>
> On Sat, Nov 08, 2025 at 04:01:00PM -0700, Caleb Sander Mateos wrote:
> > The number of bvecs can be obtained directly from struct request's
> > nr_phys_segments field via blk_rq_nr_phys_segments(), so use that
> > instead of iterating over the bvecs an extra time.
> >
> > Signed-off-by: Caleb Sander Mateos <csander@...estorage.com>
> > ---
> >  drivers/block/loop.c | 5 +----
> >  1 file changed, 1 insertion(+), 4 deletions(-)
> >
> > diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> > index 13ce229d450c..8096478fad45 100644
> > --- a/drivers/block/loop.c
> > +++ b/drivers/block/loop.c
> > @@ -346,16 +346,13 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
> >       struct request *rq = blk_mq_rq_from_pdu(cmd);
> >       struct bio *bio = rq->bio;
> >       struct file *file = lo->lo_backing_file;
> >       struct bio_vec tmp;
> >       unsigned int offset;
> > -     int nr_bvec = 0;
> > +     unsigned short nr_bvec = blk_rq_nr_phys_segments(rq);
> >       int ret;
> >
> > -     rq_for_each_bvec(tmp, rq, rq_iter)
> > -             nr_bvec++;
> > -
>
> The two may not be same, since one bvec can be splitted into multiple segments.

Hmm, io_buffer_register_bvec() already assumes
blk_rq_nr_phys_segments() returns the number of bvecs iterated by
rq_for_each_bvec(). I asked about this on the patch adding it, but
Keith assures me they match:
https://lore.kernel.org/io-uring/Z7TmrB4_aBnZdFbo@kbusch-mbp/.

Best,
Caleb

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ