From patchwork Wed Oct 18 07:00:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 116212 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp5743047qgn; Wed, 18 Oct 2017 00:02:21 -0700 (PDT) X-Google-Smtp-Source: AOwi7QA9UihwSs3f9lCw+KE9BnCWDWxixgw95nknBN1lTf/XkLlriBCYFX/Z1BaI0PLaQpXzxfvn X-Received: by 10.101.72.65 with SMTP id i1mr12957837pgs.436.1508310141710; Wed, 18 Oct 2017 00:02:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508310141; cv=none; d=google.com; s=arc-20160816; b=cChsXlXjZkG6aMnCNtq0rEJXDeTJIv/w1vq/KOEOMYqT2TeCuafZzJZcQtQjqC0alv 7KV+AfIzXoc0CkMAupf205ceymsn0gRuiG2n1KppucRIrecPuJsP0putmupUGRPT6n1z MtYkyIBNPyQvlCK/5P/wHyyMKpD2ELusOQ+e432cBQuaTf6aOR4ocDWBmTBXi/iZrn/A /Z290f5VyDeK6bO0jYchlreqIduj4OD+/oHbf5QO5QyVJ05Ul8vT4/ncL19nHvuuaDXx K9IGofgY37iYwyFfzhDnzXjxYFN8pyV47rbQ6Gh/vxC4PUL2c3dXZ4sXmkWhoegxYWbY iPzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=zg4B5KCNiqTWEe9vpfrw9jHFAvmRd4XOZLcLphDf5M0=; b=ptiBpWA39ONPh1KbL91xhzgm0fMv5+uImbueHUCDb3z/2v39YJxIDrhfLjfx6xEWBX 3pVC4nnFsyd5pS78DkETwSR3UJsKt+y60ah6s7IRzPgGgcaTxUz+FS95YJkw1NDGBx2r c7emyip5RASyBLnRM1eA08H2RcU/bMiEYL4hTjPSqM+ffF/ns+ZxS/hOBesfGKu8eE6F ZclbO1IljhgQQ+qdWDSC1fcqAqyqh9P81haY4lrhr1KoL9sfoOlyRnaQTuXnu2pxpaTU HafKVkhR8VIJM6f3DuAQt8NMydO96nYoqw/PV1nkRz2EzSArmer46wXVT2Q8xaoLkD/Y uTgQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k11si994714plt.587.2017.10.18.00.02.21; Wed, 18 Oct 2017 00:02:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935517AbdJRHCU (ORCPT + 27 others); Wed, 18 Oct 2017 03:02:20 -0400 Received: from foss.arm.com ([217.140.101.70]:33248 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932290AbdJRHCP (ORCPT ); Wed, 18 Oct 2017 03:02:15 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2F9C71529; Wed, 18 Oct 2017 00:02:15 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 169CF3F590; Wed, 18 Oct 2017 00:02:06 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Steffen Klassert , Alexey Kuznetsov , Hideaki YOSHIFUJI , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" Cc: Ofir Drang , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, netdev@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Subject: [PATCH v10 01/20] crypto: change transient busy return code to -ENOSPC Date: Wed, 18 Oct 2017 08:00:33 +0100 Message-Id: <1508310057-25369-2-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508310057-25369-1-git-send-email-gilad@benyossef.com> References: <1508310057-25369-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The crypto API was using the -EBUSY return value to indicate both a hard failure to submit a crypto operation into a transformation provider when the latter was busy and the backlog mechanism was not enabled as well as a notification that the operation was queued into the backlog when the backlog mechanism was enabled. Having the same return code indicate two very different conditions depending on a flag is both error prone and requires extra runtime check like the following to discern between the cases: if (err == -EINPROGRESS || (err == -EBUSY && (ahash_request_flags(req) & CRYPTO_TFM_REQ_MAY_BACKLOG))) This patch changes the return code used to indicate a crypto op failed due to the transformation provider being transiently busy to -ENOSPC. Signed-off-by: Gilad Ben-Yossef --- crypto/algapi.c | 6 ++++-- crypto/cryptd.c | 4 +--- 2 files changed, 5 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/crypto/algapi.c b/crypto/algapi.c index aa699ff..60d7366 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -897,9 +897,11 @@ int crypto_enqueue_request(struct crypto_queue *queue, int err = -EINPROGRESS; if (unlikely(queue->qlen >= queue->max_qlen)) { - err = -EBUSY; - if (!(request->flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) + if (!(request->flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) { + err = -ENOSPC; goto out; + } + err = -EBUSY; if (queue->backlog == &queue->list) queue->backlog = &request->list; } diff --git a/crypto/cryptd.c b/crypto/cryptd.c index 0508c48..bd43cf5 100644 --- a/crypto/cryptd.c +++ b/crypto/cryptd.c @@ -137,16 +137,14 @@ static int cryptd_enqueue_request(struct cryptd_queue *queue, int cpu, err; struct cryptd_cpu_queue *cpu_queue; atomic_t *refcnt; - bool may_backlog; cpu = get_cpu(); cpu_queue = this_cpu_ptr(queue->cpu_queue); err = crypto_enqueue_request(&cpu_queue->queue, request); refcnt = crypto_tfm_ctx(request->tfm); - may_backlog = request->flags & CRYPTO_TFM_REQ_MAY_BACKLOG; - if (err == -EBUSY && !may_backlog) + if (err == -ENOSPC) goto out_put_cpu; queue_work_on(cpu, kcrypto_wq, &cpu_queue->work);