diff mbox series

[5/4] dm-integrity: sleep and retry on allocation errors

Message ID alpine.LRH.2.02.2006020752170.25489@file01.intranet.prod.int.rdu2.redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Mike Snitzer
Headers show
Series None | expand

Commit Message

Mikulas Patocka June 2, 2020, 11:53 a.m. UTC
dm-integrity: sleep and retry on allocation errors

Some hardware crypto drivers use GFP_ATOMIC allocations in the request
routine. These allocations can randomly fail - for example, they fail if
too many network packets are received.

If we propagated the failure up to the I/O stack, it would cause I/O
errors. So, we sleep and retry.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org

---
 drivers/md/dm-integrity.c |    5 +++++
 1 file changed, 5 insertions(+)


--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
diff mbox series

Patch

Index: linux-2.6/drivers/md/dm-integrity.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-integrity.c	2020-04-05 21:11:02.000000000 +0200
+++ linux-2.6/drivers/md/dm-integrity.c	2020-06-02 13:49:36.000000000 +0200
@@ -859,6 +859,7 @@  static void complete_journal_encrypt(str
 static bool do_crypt(bool encrypt, struct skcipher_request *req, struct journal_completion *comp)
 {
 	int r;
+retry:
 	skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
 				      complete_journal_encrypt, comp);
 	if (likely(encrypt))
@@ -874,6 +875,10 @@  static bool do_crypt(bool encrypt, struc
 		reinit_completion(&comp->ic->crypto_backoff);
 		return true;
 	}
+	if (r == -ENOMEM) {
+		msleep(1);
+		goto retry;
+	}
 	dm_integrity_io_error(comp->ic, "encrypt", r);
 	return false;
 }