linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Herbert Xu" <herbert@gondor.apana.org.au>
To: Linux Crypto Mailing List <linux-crypto@vger.kernel.org>,
	Alasdair Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@kernel.org>,
	dm-devel@redhat.com, "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, Tyler Hicks <code@tyhicks.com>,
	ecryptfs@vger.kernel.org, Marcel Holtmann <marcel@holtmann.org>,
	Johan Hedberg <johan.hedberg@gmail.com>,
	Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
	linux-bluetooth@vger.kernel.org,
	Steffen Klassert <steffen.klassert@secunet.com>,
	Jon Maloy <jmaloy@redhat.com>, Ying Xue <ying.xue@windriver.com>,
	Boris Pismenny <borisp@nvidia.com>,
	John Fastabend <john.fastabend@gmail.com>,
	David Howells <dhowells@redhat.com>,
	Jarkko Sakkinen <jarkko@kernel.org>,
	keyrings@vger.kernel.org
Subject: [PATCH 3/17] fs: ecryptfs: Use crypto_wait_req
Date: Mon, 06 Feb 2023 18:22:17 +0800	[thread overview]
Message-ID: <E1pOydd-007zgo-4c@formenos.hmeau.com> (raw)
In-Reply-To: Y+DUkqe1sagWaErA@gondor.apana.org.au

This patch replaces the custom crypto completion function with
crypto_req_done.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---

 fs/ecryptfs/crypto.c |   30 +++---------------------------
 1 file changed, 3 insertions(+), 27 deletions(-)

diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index e3f5d7f3c8a0..c3057539f088 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -260,22 +260,6 @@ int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg,
 	return i;
 }
 
-struct extent_crypt_result {
-	struct completion completion;
-	int rc;
-};
-
-static void extent_crypt_complete(struct crypto_async_request *req, int rc)
-{
-	struct extent_crypt_result *ecr = req->data;
-
-	if (rc == -EINPROGRESS)
-		return;
-
-	ecr->rc = rc;
-	complete(&ecr->completion);
-}
-
 /**
  * crypt_scatterlist
  * @crypt_stat: Pointer to the crypt_stat struct to initialize.
@@ -293,7 +277,7 @@ static int crypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
 			     unsigned char *iv, int op)
 {
 	struct skcipher_request *req = NULL;
-	struct extent_crypt_result ecr;
+	DECLARE_CRYPTO_WAIT(ecr);
 	int rc = 0;
 
 	if (unlikely(ecryptfs_verbosity > 0)) {
@@ -303,8 +287,6 @@ static int crypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
 				  crypt_stat->key_size);
 	}
 
-	init_completion(&ecr.completion);
-
 	mutex_lock(&crypt_stat->cs_tfm_mutex);
 	req = skcipher_request_alloc(crypt_stat->tfm, GFP_NOFS);
 	if (!req) {
@@ -315,7 +297,7 @@ static int crypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
 
 	skcipher_request_set_callback(req,
 			CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP,
-			extent_crypt_complete, &ecr);
+			crypto_req_done, &ecr);
 	/* Consider doing this once, when the file is opened */
 	if (!(crypt_stat->flags & ECRYPTFS_KEY_SET)) {
 		rc = crypto_skcipher_setkey(crypt_stat->tfm, crypt_stat->key,
@@ -334,13 +316,7 @@ static int crypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
 	skcipher_request_set_crypt(req, src_sg, dst_sg, size, iv);
 	rc = op == ENCRYPT ? crypto_skcipher_encrypt(req) :
 			     crypto_skcipher_decrypt(req);
-	if (rc == -EINPROGRESS || rc == -EBUSY) {
-		struct extent_crypt_result *ecr = req->base.data;
-
-		wait_for_completion(&ecr->completion);
-		rc = ecr->rc;
-		reinit_completion(&ecr->completion);
-	}
+	rc = crypto_wait_req(rc, &ecr);
 out:
 	skcipher_request_free(req);
 	return rc;

  parent reply	other threads:[~2023-02-06 11:34 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-06 10:21 [PATCH 0/17] crypto: api - Change completion callback argument to void star Herbert Xu
2023-02-06 10:22 ` [PATCH 1/17] dm: Add scaffolding to change completion function signature Herbert Xu
2023-02-06 17:29   ` Mike Snitzer
2023-02-06 10:22 ` [PATCH 2/17] net: macsec: " Herbert Xu
2023-02-10  0:43   ` Jarkko Sakkinen
2023-02-06 10:22 ` Herbert Xu [this message]
2023-02-10  0:42   ` [PATCH 3/17] fs: ecryptfs: Use crypto_wait_req Jarkko Sakkinen
2023-02-06 10:22 ` [PATCH 4/17] Bluetooth: " Herbert Xu
2023-02-06 10:22 ` [PATCH 5/17] net: ipv4: Add scaffolding to change completion function signature Herbert Xu
2023-02-06 10:22 ` [PATCH 6/17] net: ipv6: " Herbert Xu
2023-02-06 10:22 ` [PATCH 7/17] tipc: " Herbert Xu
2023-02-06 10:22 ` [PATCH 8/17] tls: Only use data field in crypto completion function Herbert Xu
2023-02-07  7:15   ` Jakub Kicinski
2023-02-07  8:18     ` [PATCH] tls: Pass rec instead of aead_req into tls_encrypt_done Herbert Xu
2023-02-07 18:50       ` Jakub Kicinski
2023-02-06 10:22 ` [PATCH 9/17] KEYS: DH: Use crypto_wait_req Herbert Xu
2023-02-06 10:22 ` [PATCH 10/17] crypto: api - Use data directly in completion function Herbert Xu
2023-02-08  5:58   ` [v2 PATCH " Herbert Xu
2023-02-06 10:22 ` [PATCH 11/17] dm: Remove completion function scaffolding Herbert Xu
2023-02-06 17:29   ` Mike Snitzer
2023-02-06 10:22 ` [PATCH 12/17] net: macsec: " Herbert Xu
2023-02-06 10:22 ` [PATCH 13/17] net: ipv4: " Herbert Xu
2023-02-06 10:22 ` [PATCH 14/17] net: ipv6: " Herbert Xu
2023-02-06 10:22 ` [PATCH 15/17] tipc: " Herbert Xu
2023-02-06 10:22 ` [PATCH 16/17] tls: " Herbert Xu
2023-02-06 10:22 ` [PATCH 17/17] crypto: api - " Herbert Xu
2023-02-10  0:56   ` Jarkko Sakkinen
2023-02-07  7:10 ` [PATCH 0/17] crypto: api - Change completion callback argument to void star Jakub Kicinski
2023-02-07  7:16   ` Jakub Kicinski
2023-02-07  8:03   ` Herbert Xu
2023-02-07 18:51     ` Jakub Kicinski
2023-02-08  4:02       ` Herbert Xu

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=E1pOydd-007zgo-4c@formenos.hmeau.com \
    --to=herbert@gondor.apana.org.au \
    --cc=agk@redhat.com \
    --cc=borisp@nvidia.com \
    --cc=code@tyhicks.com \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=ecryptfs@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=jarkko@kernel.org \
    --cc=jmaloy@redhat.com \
    --cc=johan.hedberg@gmail.com \
    --cc=john.fastabend@gmail.com \
    --cc=keyrings@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=snitzer@kernel.org \
    --cc=steffen.klassert@secunet.com \
    --cc=ying.xue@windriver.com \
    /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;
as well as URLs for NNTP newsgroup(s).