From patchwork Sun Oct 15 09:19:46 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: 115860 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2528194qgn; Sun, 15 Oct 2017 02:21:41 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBW8f1Su3GTGb+Yo7ezrklhT2zZJAdu3qvUnKDFb5mwPfHPePKYJBgqBVtGKUur4QGjfGoc X-Received: by 10.99.107.197 with SMTP id g188mr5460788pgc.341.1508059301872; Sun, 15 Oct 2017 02:21:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508059301; cv=none; d=google.com; s=arc-20160816; b=KH4s5fC+6C0yHIS+vM+4Olie42I5arhPdynL6EdP5Y2n3WtfvQ3qCmjVl266AKGAly PVeZGrDumnJ6ivWSWvVbXJZe2oAme3c7qJe2xAu0vw9MMoXFYpSdRk9psHFthzSXWYxG bRLRFlH44w5qSDhzdT2HxmHK7L0Am9MSBWYQ6GnE/BpfERErqs8Bzh6YFB2XWfGWLxne JU+CWLl/oNLYwYX8EzolBC+cmM9pdwWPV1VBK7/QcyzHcT5uJ0czWHmB25RBW3WH9FPK k4b3XzsBwZted5Wv7xnDu5nAhw3egRO0Iq/PtCAK72AKXQflHew736fB+Zi+w2qWAXUK tlng== 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=S1fMha9qW2Q1HJFmT9yw8z6At2r2w5ja/aa4fLAmKts=; b=UkQJFCpxMjzsu1gu01COUraMIdcB3PTbU8uhelDUyDxpWCVvpVqL75YfN/6A6bMuft yo4YsZqDUzosJrm+nglzyB0p/pU+mDmhAtDZviWFtYvOYcPh/duoW65T8de1e2ezCZ12 bYLL9P2gHtWZLwByL+zEeYQ+22yG3kcpA4HY3hxiCZD6FnZv0PeFJhhL3jviiZl8uZPL ta/S74Xk3rY63ebFWJXkdIKZJ+AEyR2077WMD9zQu2KXQgxncf7lu9N98lI6k7KhLCQB KGKQmmrPpVkSa5geSWwhZUlqyu+PbQB6TQK03LqXZU2ZbHMHC00rs2Q9VqQ2uD/b1WRR j8Fw== 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 y79si2139621pfb.41.2017.10.15.02.21.41; Sun, 15 Oct 2017 02:21:41 -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 S1751871AbdJOJVh (ORCPT + 27 others); Sun, 15 Oct 2017 05:21:37 -0400 Received: from foss.arm.com ([217.140.101.70]:47198 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751786AbdJOJVb (ORCPT ); Sun, 15 Oct 2017 05:21:31 -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 F1C1515A2; Sun, 15 Oct 2017 02:21:30 -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 DBE473F3E1; Sun, 15 Oct 2017 02:21:22 -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 v9 01/20] crypto: change transient busy return code to -EAGAIN Date: Sun, 15 Oct 2017 10:19:46 +0100 Message-Id: <1508059209-25529-2-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508059209-25529-1-git-send-email-gilad@benyossef.com> References: <1508059209-25529-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 -EAGAIN. 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..916bee3 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 = -EAGAIN; 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..d1dbdce 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 == -EAGAIN) goto out_put_cpu; queue_work_on(cpu, kcrypto_wq, &cpu_queue->work);