From patchwork Mon Jun 1 16:03:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 11582369 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6470B157C for ; Mon, 1 Jun 2020 16:08:52 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 232B02073B for ; Mon, 1 Jun 2020 16:08:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IkSEJEpD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 232B02073B Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591027731; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=BqlFFWMrpb1q8QUlXU5106lNKk7MAiSrHVR00gZsfcU=; b=IkSEJEpD4Ox5IpXZE5E9KO4OqxDgcUr7zTwYj/cGMbZ1nLiBlmJq9R1lqWJfq93au0lw5X ZrBUOKZQc/W3AduOJirKDVxsMnQj7tHgWWt6hfR6b612fLDXSeely2LxIF7rzOdmT/3mjw ButjmUMVb1iDOtDvRa9hDJGYXUPQ8NI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-242-pa15b_iKOS-KGdapW8XcXA-1; Mon, 01 Jun 2020 12:08:49 -0400 X-MC-Unique: pa15b_iKOS-KGdapW8XcXA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7ACF4107ACF2; Mon, 1 Jun 2020 16:08:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 601875D9C9; Mon, 1 Jun 2020 16:08:44 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 39DFC1809547; Mon, 1 Jun 2020 16:08:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 051G4P1i032223 for ; Mon, 1 Jun 2020 12:04:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id E29F47F0A2; Mon, 1 Jun 2020 16:04:25 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from leontynka.twibright.com (unknown [10.40.194.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 347687E7F1; Mon, 1 Jun 2020 16:04:25 +0000 (UTC) Received: from debian-a64.vm ([192.168.208.2]) by leontynka.twibright.com with smtp (Exim 4.92) (envelope-from ) id 1jfmvG-0001W2-Ob; Mon, 01 Jun 2020 18:04:23 +0200 Received: by debian-a64.vm (sSMTP sendmail emulation); Mon, 01 Jun 2020 18:04:22 +0200 Message-Id: <20200601160421.912555280@debian-a64.vm> User-Agent: quilt/0.65 Date: Mon, 01 Jun 2020 18:03:36 +0200 From: Mikulas Patocka To: Mike Snitzer , Giovanni Cabiddu , Herbert Xu , "David S. Miller" , Milan Broz , djeffery@redhat.com MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: dm-devel@redhat.com Cc: guazhang@redhat.com, qat-linux@intel.com, dm-devel@redhat.com, Mikulas Patocka , linux-crypto@vger.kernel.org, jpittman@redhat.com Subject: [dm-devel] [PATCH 4/4] dm-crypt: sleep and retry on allocation errors X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline; filename=crypt-enomem.patch 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 and data corruption. So, we sleep and retry. Signed-off-by: Mikulas Patocka Cc: stable@vger.kernel.org --- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-2.6/drivers/md/dm-crypt.c =================================================================== --- linux-2.6.orig/drivers/md/dm-crypt.c +++ linux-2.6/drivers/md/dm-crypt.c @@ -1534,6 +1534,7 @@ static blk_status_t crypt_convert(struct crypt_alloc_req(cc, ctx); atomic_inc(&ctx->cc_pending); +again: if (crypt_integrity_aead(cc)) r = crypt_convert_block_aead(cc, ctx, ctx->r.req_aead, tag_offset); else @@ -1541,6 +1542,17 @@ static blk_status_t crypt_convert(struct switch (r) { /* + * Some hardware crypto drivers use GFP_ATOMIC allocations in + * the request routine. These allocations can randomly fail. If + * we propagated the failure up to the I/O stack, it would cause + * I/O errors and data corruption. + * + * So, we sleep and retry. + */ + case -ENOMEM: + msleep(1); + goto again; + /* * The request was queued by a crypto driver * but the driver request queue is full, let's wait. */ From patchwork Tue Jun 2 11:53:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 11583669 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DFAE6739 for ; Tue, 2 Jun 2020 11:53:20 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9D00C206E2 for ; Tue, 2 Jun 2020 11:53:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EYPxDyC8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D00C206E2 Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591098799; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=QWB05NGTNUTp4i2iWV6N0icpCvJoCup4JUGOBahktE4=; b=EYPxDyC8pKVtySwLoPDzoG1w7O/TKK9rzwv9W/l6E+LgHDDts3Bq5xplxsdEM9ywFKfOAu 2Zp5ftmrFX1kKTyFSFKMWWMVsWKwXeQl71VkXu1kzZoImrKDuhrUn8QgY0lD2mQAUMQJMD 699b+IFWOVgI40nK1MKj8rlKFI5ziDs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-124-AhMtOaCgN2CWNhDd0Eyovg-1; Tue, 02 Jun 2020 07:53:17 -0400 X-MC-Unique: AhMtOaCgN2CWNhDd0Eyovg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7D7AF1052509; Tue, 2 Jun 2020 11:53:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 93FD110013D7; Tue, 2 Jun 2020 11:53:12 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E1192941CA; Tue, 2 Jun 2020 11:53:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 052BrAx2031015 for ; Tue, 2 Jun 2020 07:53:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id C0E125D9E2; Tue, 2 Jun 2020 11:53:10 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BA67E5D9CC; Tue, 2 Jun 2020 11:53:07 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id 052Br7gp025558; Tue, 2 Jun 2020 07:53:07 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id 052Br5eN025554; Tue, 2 Jun 2020 07:53:05 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Tue, 2 Jun 2020 07:53:05 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Mike Snitzer , Giovanni Cabiddu , Herbert Xu , "David S. Miller" , Milan Broz , djeffery@redhat.com In-Reply-To: <20200601160421.912555280@debian-a64.vm> Message-ID: References: <20200601160421.912555280@debian-a64.vm> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: dm-devel@redhat.com Cc: guazhang@redhat.com, dm-devel@redhat.com, qat-linux@intel.com, jpittman@redhat.com, linux-crypto@vger.kernel.org Subject: [dm-devel] [PATCH 5/4] dm-integrity: sleep and retry on allocation errors X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 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 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; }