Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: Gilad Ben-Yossef <gilad-6S/DczAoZh3WXxRugSxzZg@public.gmane.org>
To: Herbert Xu
	<herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>,
	"David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
	Jonathan Corbet <corbet-T1hC0tSOHrs@public.gmane.org>,
	David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Tom Lendacky <thomas.lendacky-5C7GfCeVMHo@public.gmane.org>,
	Gary Hook <gary.hook-5C7GfCeVMHo@public.gmane.org>,
	Boris Brezillon
	<boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	Arnaud Ebalard <arno-LkuqDEemtHBg9hUCZPvPmw@public.gmane.org>,
	Matthias Brugger
	<matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Alasdair Kergon <agk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Mike Snitzer <snitzer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	dm-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	Steve French <sfrench-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>,
	"Theodore Y. Ts'o" <tytso-3s7WtUTddSA@public.gmane.org>,
	Jaegeuk Kim <jaegeuk-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Steffen Klassert
	<steffen.klassert-opNxpl+3fjRBDgjK7y7TUQ@public.gmane.org>,
	Alexey Kuznetsov <kuznet-v/Mj1YrvjDBInbfyfbPRSQ@public.gmane.org>,
	Hideaki YOSHIFUJI
	<yoshfuji-VfPWfsRibaP+Ru+s062T9g@public.gmane.org>,
	Mimi Zohar
	<zohar-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>,
	Dmitry Kasatkin <dmitry.ka
Cc: Ofir Drang <ofir.drang-5wv7dgnIgG8@public.gmane.org>,
	linux-crypto-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	keyrings-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	samba-technical-w/Ol4Ecudpl8XjKLYN78aQ@public.gmane.org,
	linux-fscrypt-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-ima-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	linux-ima-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH v9 01/20] crypto: change transient busy return code to -EAGAIN
Date: Sun, 15 Oct 2017 10:19:46 +0100	[thread overview]
Message-ID: <1508059209-25529-2-git-send-email-gilad@benyossef.com> (raw)
In-Reply-To: <1508059209-25529-1-git-send-email-gilad-6S/DczAoZh3WXxRugSxzZg@public.gmane.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 <gilad-6S/DczAoZh3WXxRugSxzZg@public.gmane.org>
---
 crypto/algapi.c | 6 ++++--
 crypto/cryptd.c | 4 +---
 2 files changed, 5 insertions(+), 5 deletions(-)

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);
-- 
2.7.4

  parent reply	other threads:[~2017-10-15  9:19 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-15  9:19 [PATCH v9 00/20] simplify crypto wait for async op Gilad Ben-Yossef
     [not found] ` <1508059209-25529-1-git-send-email-gilad-6S/DczAoZh3WXxRugSxzZg@public.gmane.org>
2017-10-15  9:19   ` Gilad Ben-Yossef [this message]
2017-10-15  9:19   ` [PATCH v9 03/20] net: use -EAGAIN for transient busy indication Gilad Ben-Yossef
2017-10-15  9:19 ` [PATCH v9 02/20] crypto: ccp: " Gilad Ben-Yossef
2017-10-15  9:19 ` [PATCH v9 04/20] crypto: remove redundant backlog checks on EBUSY Gilad Ben-Yossef
2017-10-15  9:19 ` [PATCH v9 05/20] crypto: marvell/cesa: " Gilad Ben-Yossef
2017-10-15  9:19 ` [PATCH v9 06/20] crypto: introduce crypto wait for async op Gilad Ben-Yossef
2017-10-15  9:19 ` [PATCH v9 07/20] crypto: move algif to generic async completion Gilad Ben-Yossef
2017-10-15  9:19 ` [PATCH v9 08/20] crypto: move pub key " Gilad Ben-Yossef
2017-10-15  9:19 ` [PATCH v9 09/20] crypto: move drbg " Gilad Ben-Yossef
2017-10-15  9:19 ` [PATCH v9 10/20] crypto: move gcm " Gilad Ben-Yossef
2017-10-15  9:19 ` [PATCH v9 11/20] crypto: move testmgr " Gilad Ben-Yossef
2017-10-15  9:19 ` [PATCH v9 12/20] fscrypt: move " Gilad Ben-Yossef
2017-10-15  9:19 ` [PATCH v9 13/20] dm: move dm-verity " Gilad Ben-Yossef
2017-10-15  9:19 ` [PATCH v9 14/20] cifs: move " Gilad Ben-Yossef
2017-10-15  9:20 ` [PATCH v9 15/20] ima: " Gilad Ben-Yossef
2017-10-15  9:20 ` [PATCH v9 16/20] crypto: tcrypt: " Gilad Ben-Yossef
2017-10-15  9:20 ` [PATCH v9 17/20] crypto: talitos: " Gilad Ben-Yossef
2017-10-17 10:50   ` Christophe LEROY
2017-10-15  9:20 ` [PATCH v9 18/20] crypto: qce: " Gilad Ben-Yossef
2017-10-15  9:20 ` [PATCH v9 19/20] crypto: mediatek: " Gilad Ben-Yossef
2017-10-15  9:20 ` [PATCH v9 20/20] crypto: adapt api sample to use async. op wait Gilad Ben-Yossef
2017-10-15 15:38 ` [PATCH v9 00/20] simplify crypto wait for async op Herbert Xu
     [not found]   ` <20171015153831.GA22867-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>
2017-10-17 11:55     ` Gilad Ben-Yossef
2017-10-17 13:09       ` Herbert Xu
2017-10-17 14:06 ` Russell King - ARM Linux
2017-10-18  5:44   ` Gilad Ben-Yossef

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=1508059209-25529-2-git-send-email-gilad@benyossef.com \
    --to=gilad-6s/dczaozh3wxxrugsxzzg@public.gmane.org \
    --cc=agk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=arno-LkuqDEemtHBg9hUCZPvPmw@public.gmane.org \
    --cc=boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=corbet-T1hC0tSOHrs@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=dm-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=gary.hook-5C7GfCeVMHo@public.gmane.org \
    --cc=herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org \
    --cc=jaegeuk-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=keyrings-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=kuznet-v/Mj1YrvjDBInbfyfbPRSQ@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-crypto-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-fscrypt-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-ima-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=linux-ima-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=ofir.drang-5wv7dgnIgG8@public.gmane.org \
    --cc=samba-technical-w/Ol4Ecudpl8XjKLYN78aQ@public.gmane.org \
    --cc=sfrench-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org \
    --cc=snitzer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=steffen.klassert-opNxpl+3fjRBDgjK7y7TUQ@public.gmane.org \
    --cc=thomas.lendacky-5C7GfCeVMHo@public.gmane.org \
    --cc=tytso-3s7WtUTddSA@public.gmane.org \
    --cc=yoshfuji-VfPWfsRibaP+Ru+s062T9g@public.gmane.org \
    --cc=zohar-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox