From: Milan Broz <gmazyland@gmail.com>
To: Mikulas Patocka <mpatocka@redhat.com>, Mike Snitzer <snitzer@redhat.com>
Cc: Ming Lei <tom.leiming@gmail.com>, Jens Axboe <axboe@kernel.dk>,
Eric Wheeler <dm-devel@lists.ewheeler.net>,
Christoph Hellwig <hch@lst.de>,
johnstonj.public@codenest.com,
linux-block <linux-block@vger.kernel.org>
Subject: Re: dm-crypt: Fix error with too large bios
Date: Wed, 31 Aug 2016 08:26:36 +0200 [thread overview]
Message-ID: <6a58fece-c60b-9dc2-e2e6-bee4e877a376@gmail.com> (raw)
In-Reply-To: <alpine.LRH.2.02.1608301825540.10943@file01.intranet.prod.int.rdu2.redhat.com>
On 08/31/2016 12:27 AM, Mikulas Patocka wrote:
...
>
> Drop that "#ifdef CONFIG_BCACHE". Anyone should be allowed to create a big
> bio, not just bcache.
Yes. Please, do not hide it behind #ifdef.
If it is in code, it should be enabled always.
There can third party modules or some new code appears and creating strange
config dependence only adds more problems later.
Milan
>
> That one test has no performance impact, there is no need to hide it
> behind #ifdef.
>
> Mikulas
>
>> From: Mikulas Patocka <mpatocka@redhat.com>
>> Date: Tue, 30 Aug 2016 16:38:42 -0400
>> Subject: [PATCH] dm crypt: fix error with too large bcache bios
>>
>> When dm-crypt processes writes, it allocates a new bio in
>> 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 bcache. If the incoming bio is larger,
>> bio_alloc_bioset() fails and an error is returned.
>>
>> To avoid the error, we test for a too large bio in the function
>> crypt_map() and use dm_accept_partial_bio() to split the bio.
>> dm_accept_partial_bio() trims the current bio to the desired size and
>> asks DM core to send another bio with the rest of the data.
>>
>> This fix is wrapped with a check for CONFIG_BCACHE because there
>> currently isn't any other code that generates too large bios. So unless
>> bcache is configured there is no point wasting time making this check.
>>
>> Signed-off-by: Mikulas Patocka <mpatocka redhat com>
>> Cc: stable@vger.kernel.org # v3.16+
>> ---
>> drivers/md/dm-crypt.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
>> index eedba67..743f548 100644
>> --- a/drivers/md/dm-crypt.c
>> +++ b/drivers/md/dm-crypt.c
>> @@ -1924,6 +1924,12 @@ static int crypt_map(struct dm_target *ti, struct bio *bio)
>> return DM_MAPIO_REMAPPED;
>> }
>>
>> +#ifdef CONFIG_BCACHE
>> + if (unlikely(bio->bi_iter.bi_size > (BIO_MAX_PAGES << PAGE_SHIFT)) &&
>> + bio_data_dir(bio) == WRITE)
>> + dm_accept_partial_bio(bio, ((BIO_MAX_PAGES << PAGE_SHIFT) >> SECTOR_SHIFT));
>> +#endif
>> +
>> io = dm_per_bio_data(bio, cc->per_bio_data_size);
>> crypt_io_init(io, cc, bio, dm_target_offset(ti, bio->bi_iter.bi_sector));
>> io->ctx.req = (struct skcipher_request *)(io + 1);
>> --
>> 2.7.4 (Apple Git-66)
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-block" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2016-08-31 6:26 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
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 [this message]
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=6a58fece-c60b-9dc2-e2e6-bee4e877a376@gmail.com \
--to=gmazyland@gmail.com \
--cc=axboe@kernel.dk \
--cc=dm-devel@lists.ewheeler.net \
--cc=hch@lst.de \
--cc=johnstonj.public@codenest.com \
--cc=linux-block@vger.kernel.org \
--cc=mpatocka@redhat.com \
--cc=snitzer@redhat.com \
--cc=tom.leiming@gmail.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.