From: Mike Snitzer <snitzer@redhat.com>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: Eric Wheeler <dm-devel@lists.ewheeler.net>,
dm-devel@redhat.com, hch@lst.de, johnstonj.public@codenest.com
Subject: Re: dm-crypt: Fix error with too large bios
Date: Sat, 13 Aug 2016 20:07:40 -0400 [thread overview]
Message-ID: <20160814000740.GA5317@redhat.com> (raw)
In-Reply-To: <alpine.LRH.2.02.1608131342250.3291@file01.intranet.prod.int.rdu2.redhat.com>
[top-posting just because others went wild with it]
I don't have a strong opinion but I just assumed the local dm-crypt
workaround wasn't the way forward. I didn't stage it because Christoph
disagreed with it:
https://lkml.org/lkml/2016/6/1/456
https://lkml.org/lkml/2016/6/1/477
Also, this would appear to be a more generic fix:
"block: make sure big bio is splitted into at most 256 bvecs
https://lkml.org/lkml/2016/8/12/154
(but Christoph disagrees there too, so the way forward isn't clear)
Mike
On Sat, Aug 13 2016 at 1:45pm -0400,
Mikulas Patocka <mpatocka@redhat.com> wrote:
> Yes, this should be backported. It was lost somehow.
>
> Mike, please put it to your git.
>
> Mikulas
>
>
> On Wed, 10 Aug 2016, Eric Wheeler wrote:
>
> > Hello Mikulas and dm-devel list,
> >
> > The simple patch below with is confirmed to fix James Johnston's issue and
> > doesn't appear to be in v4.8-rc1:
> >
> > This references the following patchwork entry:
> > https://patchwork.kernel.org/patch/9138595/
> >
> > Can we get this pushed upstream for v4.8?
> >
> > --
> > Eric Wheeler
> >
> >
> > On Fri, 27 May 2016, Mikulas Patocka wrote:
> > > dm-crypt: Fix error with too large bios
> > >
> > > When dm-crypt processes writes, it allocates a new bio in the function
> > > crypt_alloc_buffer. The bio is allocated from a bio set and it can have at
> > > most BIO_MAX_PAGES vector entries, however the incoming bio can be larger
> > > if it was allocated by other means. For example, bcache creates bios
> > > larger than BIO_MAX_PAGES. If the incoming bio is larger, bio_alloc_bioset
> > > fails and error is returned.
> > >
> > > To avoid the error, we test for too large bio in the function crypt_map
> > > and dm_accept_partial_bio to split the bio. dm_accept_partial_bio trims
> > > the current bio to the desired size and requests that the device mapper
> > > core sends another bio with the rest of the data.
> > >
> > > Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> > > Cc: stable@vger.kernel.org # v3.16+
> >
> > Tested-by: James Johnston <johnstonj.public@codenest.com>
> >
> > I tested this patch by:
> >
> > 1. Building v4.7-rc1 from Torvalds git repo. Confirmed that original bug
> > still occurs on Ubuntu 15.10.
> >
> > 2. Applying your patch to v4.7-rc1. My kill sequence no longer works,
> > and the writeback cache is now successfully flushed to disk, and the
> > cache can be detached from the backing device.
> >
> > 3. To check data integrity, copied 250 MB of /dev/urandom to some file
> > on main volume. Then, dd copy this file to /dev/bcache0. Then,
> > detached the cache device from the backing device. Then, rebooted.
> > Then, dd copy /dev/bcache0 to another file on main volume. Then,
> > diff the files and confirm no changes.
> >
> > So it looks like it works, based on this admittedly brief testing. Thanks!
> >
> > Best regards,
> >
> > James Johnston
> >
> >
> > --
> > dm-devel mailing list
> > dm-devel@redhat.com
> > https://www.redhat.com/mailman/listinfo/dm-devel
> >
> > Patch
> >
> > Index: linux-4.6/drivers/md/dm-crypt.c
> > ===================================================================
> > --- linux-4.6.orig/drivers/md/dm-crypt.c
> > +++ linux-4.6/drivers/md/dm-crypt.c
> > @@ -2137,6 +2137,10 @@ static int crypt_map(struct dm_target *t
> > struct dm_crypt_io *io;
> > struct crypt_config *cc = ti->private;
> >
> > + if (unlikely(bio->bi_iter.bi_size > BIO_MAX_SIZE) &&
> > + (bio->bi_rw & (REQ_FLUSH | REQ_DISCARD | REQ_WRITE)) == REQ_WRITE)
> > + dm_accept_partial_bio(bio, BIO_MAX_SIZE >> SECTOR_SHIFT);
> > +
> > /*
> > * If bio is REQ_FLUSH or REQ_DISCARD, just bypass crypt queues.
> > * - for REQ_FLUSH device-mapper core ensures that no IO is in-flight
> >
> >
> >
> >
next prev parent reply other threads:[~2016-08-14 0:07 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-11 3:56 [PATCH] Re: dm-crypt: Fix error with too large bios Eric Wheeler
2016-08-13 17:45 ` Mikulas Patocka
2016-08-14 0:07 ` Mike Snitzer [this message]
2016-08-15 17:03 ` Mikulas Patocka
2016-08-19 0:47 ` Eric Wheeler
2016-08-25 18:34 ` Mikulas Patocka
2016-08-25 18:34 ` [dm-devel] " Mikulas Patocka
2016-08-25 20:13 ` Jens Axboe
2016-08-26 14:05 ` Mike Snitzer
2016-08-27 15:09 ` Mikulas Patocka
2016-08-29 5:22 ` Ming Lei
2016-08-29 21:57 ` Mikulas Patocka
2016-08-30 7:33 ` Ming Lei
2016-08-30 12:19 ` Mikulas Patocka
2016-08-30 20:57 ` Mike Snitzer
2016-08-30 22:27 ` Mikulas Patocka
2016-08-31 6:26 ` Milan Broz
2016-08-31 13:39 ` Mike Snitzer
2016-08-29 18:19 ` Mike Snitzer
2016-08-29 22:01 ` Mikulas Patocka
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=20160814000740.GA5317@redhat.com \
--to=snitzer@redhat.com \
--cc=dm-devel@lists.ewheeler.net \
--cc=dm-devel@redhat.com \
--cc=hch@lst.de \
--cc=johnstonj.public@codenest.com \
--cc=mpatocka@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.