From: Ming Lei <ming.lei@redhat.com>
To: Dave Chinner <david@fromorbit.com>
Cc: "hch@lst.de" <hch@lst.de>,
"Verma, Vishal L" <vishal.l.verma@intel.com>,
"linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>,
"Williams, Dan J" <dan.j.williams@intel.com>,
"darrick.wong@oracle.com" <darrick.wong@oracle.com>,
linux-block@vger.kernel.org
Subject: Re: 5.3-rc1 regression with XFS log recovery
Date: Wed, 21 Aug 2019 09:56:26 +0800 [thread overview]
Message-ID: <20190821015624.GA24167@ming.t460p> (raw)
In-Reply-To: <20190820214408.GG1119@dread.disaster.area>
On Wed, Aug 21, 2019 at 07:44:09AM +1000, Dave Chinner wrote:
> On Tue, Aug 20, 2019 at 05:24:25PM +0800, Ming Lei wrote:
> > On Tue, Aug 20, 2019 at 04:13:26PM +0800, Ming Lei wrote:
> > > On Tue, Aug 20, 2019 at 07:53:20AM +0200, hch@lst.de wrote:
> > > > On Tue, Aug 20, 2019 at 02:41:35PM +1000, Dave Chinner wrote:
> > > > > > With the following debug patch. Based on that I think I'll just
> > > > > > formally submit the vmalloc switch as we're at -rc5, and then we
> > > > > > can restart the unaligned slub allocation drama..
> > > > >
> > > > > This still doesn't make sense to me, because the pmem and brd code
> > > > > have no aligment limitations in their make_request code - they can
> > > > > handle byte adressing and should not have any problem at all with
> > > > > 8 byte aligned memory in bios.
> > > > >
> > > > > Digging a little furhter, I note that both brd and pmem use
> > > > > identical mechanisms to marshall data in and out of bios, so they
> > > > > are likely to have the same issue.
> > > > >
> > > > > So, brd_make_request() does:
> > > > >
> > > > > bio_for_each_segment(bvec, bio, iter) {
> > > > > unsigned int len = bvec.bv_len;
> > > > > int err;
> > > > >
> > > > > err = brd_do_bvec(brd, bvec.bv_page, len, bvec.bv_offset,
> > > > > bio_op(bio), sector);
> > > > > if (err)
> > > > > goto io_error;
> > > > > sector += len >> SECTOR_SHIFT;
> > > > > }
> > > > >
> > > > > So, the code behind bio_for_each_segment() splits multi-page bvecs
> > > > > into individual pages, which are passed to brd_do_bvec(). An
> > > > > unaligned 4kB io traces out as:
> > > > >
> > > > > [ 121.295550] p,o,l,s 00000000a77f0146,768,3328,0x7d0048
> > > > > [ 121.297635] p,o,l,s 000000006ceca91e,0,768,0x7d004e
> > > > >
> > > > > i.e. page offset len sector
> > > > > 00000000a77f0146 768 3328 0x7d0048
> > > > > 000000006ceca91e 0 768 0x7d004e
> > > > >
> > > > > You should be able to guess what the problems are from this.
> > >
> > > The problem should be that offset of '768' is passed to bio_add_page().
> >
> > It can be quite hard to deal with non-512 aligned sector buffer, since
> > one sector buffer may cross two pages, so far one workaround I thought
> > of is to not merge such IO buffer into one bvec.
> >
> > Verma, could you try the following patch?
> >
> > diff --git a/block/bio.c b/block/bio.c
> > index 24a496f5d2e2..49deab2ac8c4 100644
> > --- a/block/bio.c
> > +++ b/block/bio.c
> > @@ -769,6 +769,9 @@ bool __bio_try_merge_page(struct bio *bio, struct page *page,
> > if (WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)))
> > return false;
> >
> > + if (off & 511)
> > + return false;
>
> What does this acheive? It only prevents the unaligned segment from
> being merged, it doesn't prevent it from being added to a new bvec.
The current issue is that block layer won't handle such case, as I
mentioned, one sector buffer may cross two pages, then it can't be
splitted successfully, so simply put into one new bvec just as
before enabling multi-page bvec.
>
> However, the case here is that:
>
> > > > > i.e. page offset len sector
> > > > > 00000000a77f0146 768 3328 0x7d0048
> > > > > 000000006ceca91e 0 768 0x7d004e
>
> The second page added to the bvec is actually offset alignedr. Hence
> the check would do nothing on the first page because the bvec array
> is empty (so goes into a new bvec anyway), and the check on the
> second page would do nothing an it would merge with first because
> the offset is aligned correctly. In both cases, the length of the
> segment is not aligned, so that needs to be checked, too.
What the patch changes is the bvec stored in bio, the above bvec is
actually built in-flight.
So if the 1st page added to bio is (768, 512), then finally
bio_for_each_segment() will generate the 1st page as (768, 512), then
everything will be fine.
>
> IOWs, I think the check needs to be in bio_add_page, it needs to
> check both the offset and length for alignment, and it needs to grab
The length has to be 512 aligned, otherwise it is simply bug in fs.
> the alignment from queue_dma_alignment(), not use a hard coded value
> of 511.
Now the policy for bio_add_page() is to not checking any queue limit
given we don't know what is the actual limit for the finally IO, even the
queue isn't set when bio_add_page() is called.
If the upper layer won't pass slub buffer which is > PAGE_SIZE, block
layer may handle it well without the 512 alignment check.
Thanks,
Ming
prev parent reply other threads:[~2019-08-21 1:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190818071128.GA17286@lst.de>
[not found] ` <20190818074140.GA18648@lst.de>
[not found] ` <20190818173426.GA32311@lst.de>
[not found] ` <20190819000831.GX6129@dread.disaster.area>
[not found] ` <20190819034948.GA14261@lst.de>
[not found] ` <20190819041132.GA14492@lst.de>
[not found] ` <20190819042259.GZ6129@dread.disaster.area>
[not found] ` <20190819042905.GA15613@lst.de>
[not found] ` <20190819044012.GA15800@lst.de>
[not found] ` <20190820044135.GC1119@dread.disaster.area>
2019-08-20 5:53 ` 5.3-rc1 regression with XFS log recovery hch
2019-08-20 7:44 ` Dave Chinner
2019-08-20 8:13 ` Ming Lei
2019-08-20 9:24 ` Ming Lei
2019-08-20 16:30 ` Verma, Vishal L
2019-08-20 21:44 ` Dave Chinner
2019-08-20 22:08 ` Verma, Vishal L
2019-08-20 23:53 ` Dave Chinner
2019-08-21 2:19 ` Ming Lei
2019-08-21 1:56 ` 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=20190821015624.GA24167@ming.t460p \
--to=ming.lei@redhat.com \
--cc=dan.j.williams@intel.com \
--cc=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=vishal.l.verma@intel.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).