From: Ben Collins <ben.c@servergy.com>
To: dm-devel@redhat.com
Cc: Ben Collins <ben.c@servergy.com>,
Mike Snitzer <snitzer@redhat.com>,
Alasdair Kergon <agk@redhat.com>
Subject: [PATCH] dm-crypt: Fix deadlock when algo returns -EBUSY
Date: Fri, 3 Apr 2015 16:09:46 +0000 [thread overview]
Message-ID: <1428077387-2292-1-git-send-email-ben.c@servergy.com> (raw)
I suspect this doesn't show up for most anyone because software
algorithms typically don't have a sense of being too busy. However,
when working with the Freescale CAAM driver, it would, under heavy
load, return -EBUSY on occasion, which would leave dm-crypt dead
locked and quite unhappy.
After checking the logic in some other drivers, the scheme for
crypt_convert() and it's callback, kcryptd_async_done() were not
correctly laid out to handle -EBUSY properly (nor -EINPROGRESS for
that matter).
This patch corrects that and makes things pretty happy. Where-as I
could cause a lockup withing 1-2 minutes, I've not been able to run
the reproduction test with CAAM drivers fully installed for over
24 hours now. I've regression tested it against software algorithms
on PPC32 and x86_64, and things seem perfectly happy there as well.
I've tested this all the way back to 3.13, and a few iterations
in-between. Please consider pushing this to various stable trees.
Cc: dm-devel@redhat.com
Cc: Alasdair Kergon <agk@redhat.com>
Cc: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Ben Collins <ben.c@servergy.com>
---
drivers/md/dm-crypt.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 713a962..3891f26 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -925,11 +925,10 @@ static int crypt_convert(struct crypt_config *cc,
switch (r) {
/* async */
+ case -EINPROGRESS:
case -EBUSY:
wait_for_completion(&ctx->restart);
reinit_completion(&ctx->restart);
- /* fall through*/
- case -EINPROGRESS:
ctx->req = NULL;
ctx->cc_sector++;
continue;
@@ -1346,10 +1345,8 @@ static void kcryptd_async_done(struct crypto_async_request *async_req,
struct dm_crypt_io *io = container_of(ctx, struct dm_crypt_io, ctx);
struct crypt_config *cc = io->cc;
- if (error == -EINPROGRESS) {
- complete(&ctx->restart);
+ if (error == -EINPROGRESS)
return;
- }
if (!error && cc->iv_gen_ops && cc->iv_gen_ops->post)
error = cc->iv_gen_ops->post(cc, iv_of_dmreq(cc, dmreq), dmreq);
@@ -1359,13 +1356,17 @@ static void kcryptd_async_done(struct crypto_async_request *async_req,
crypt_free_req(cc, req_of_dmreq(cc, dmreq), io->base_bio);
- if (!atomic_dec_and_test(&ctx->cc_pending))
+ if (!atomic_dec_and_test(&ctx->cc_pending)) {
+ complete(&ctx->restart);
return;
+ }
if (bio_data_dir(io->base_bio) == READ)
kcryptd_crypt_read_done(io);
else
kcryptd_crypt_write_io_submit(io, 1);
+
+ complete(&ctx->restart);
}
static void kcryptd_crypt(struct work_struct *work)
--
1.9.1
next reply other threads:[~2015-04-03 16:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-03 16:09 Ben Collins [this message]
2015-04-07 15:55 ` dm-crypt: Fix deadlock when algo returns -EBUSY Mike Snitzer
2015-04-07 16:28 ` [PATCH v2] dm crypt: fix " Mike Snitzer
2015-04-07 17:10 ` Ben Collins
2015-04-10 15:11 ` Mike Snitzer
2015-04-10 15:12 ` Ben Collins
2015-04-10 17:56 ` Ben Collins
2015-04-10 19:52 ` Mike Snitzer
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=1428077387-2292-1-git-send-email-ben.c@servergy.com \
--to=ben.c@servergy.com \
--cc=agk@redhat.com \
--cc=dm-devel@redhat.com \
--cc=snitzer@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.