From: Mikulas Patocka <mpatocka@redhat.com>
To: Ming Lei <ming.lei@redhat.com>
Cc: Mike Snitzer <snitzer@kernel.org>, Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, dm-devel@lists.linux.dev
Subject: Re: block: fail unaligned bio from submit_bio_noacct()
Date: Fri, 22 Mar 2024 11:16:27 +0100 (CET) [thread overview]
Message-ID: <dd4e8b49-aa76-4b1b-3827-6650cb525226@redhat.com> (raw)
In-Reply-To: <ZfzoC/V07nExJ+0x@fedora>
On Fri, 22 Mar 2024, Ming Lei wrote:
> On Thu, Mar 21, 2024 at 06:01:41PM +0100, Mikulas Patocka wrote:
> >
> >
> > > > +static bool bio_check_alignment(struct bio *bio, struct request_queue *q)
> > > > +{
> > > > + unsigned int bs = q->limits.logical_block_size;
> > > > + unsigned int size = bio->bi_iter.bi_size;
> > > > +
> > > > + if (size & (bs - 1))
> > > > + return false;
> > > > +
> > > > + if (size && ((bio->bi_iter.bi_sector << SECTOR_SHIFT) & (bs - 1)))
> > > > + return false;
> > > > +
> > > > + return true;
> > > > +}
> >
> > I would change it to
> >
> > if (unlikely(((bi_iter.bi_sector | bio_sectors(bio)) & ((queue_logical_block_size(q) >> 9) - 1)) != 0))
> > return false;
>
> What if bio->bi_iter.bi_size isn't aligned with 512? The above check
> can't find that at all.
Could it happen that bi_size is not aligned to 512? I haven't seen such a
bio yet. If you have seen it, say where was it created.
Mikulas
next prev parent reply other threads:[~2024-03-22 10:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-21 13:16 [PATCH] block: fail unaligned bio from submit_bio_noacct() Ming Lei
2024-03-21 15:14 ` Bart Van Assche
2024-03-21 15:18 ` Ming Lei
2024-03-21 15:43 ` Mike Snitzer
2024-03-21 17:01 ` Mikulas Patocka
2024-03-21 22:07 ` Christoph Hellwig
2024-03-22 2:08 ` Ming Lei
2024-03-22 2:39 ` Keith Busch
2024-03-24 8:02 ` Ming Lei
2024-03-22 10:16 ` Mikulas Patocka [this message]
2024-03-21 17:09 ` [PATCH] " Jens Axboe
2024-03-21 22:09 ` Christoph Hellwig
2024-03-21 22:50 ` Jens Axboe
2024-03-22 0:31 ` Christoph Hellwig
2024-03-22 1:21 ` Ming Lei
2024-03-21 22:06 ` 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=dd4e8b49-aa76-4b1b-3827-6650cb525226@redhat.com \
--to=mpatocka@redhat.com \
--cc=axboe@kernel.dk \
--cc=dm-devel@lists.linux.dev \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=snitzer@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;
as well as URLs for NNTP newsgroup(s).