From patchwork Wed Oct 18 07:00: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: 116225 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp5745493qgn; Wed, 18 Oct 2017 00:05:25 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDqQlMFU/8956IXx/vSutAw2b9Xs/Bl9OCgV6DDn39Gzzq757chAOAHK3l+rrOdxymReUGQ X-Received: by 10.99.109.79 with SMTP id i76mr13334895pgc.134.1508310325626; Wed, 18 Oct 2017 00:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508310325; cv=none; d=google.com; s=arc-20160816; b=R/onIm+cV67gH6u0TlZiEEu+B9ZG2DSsPy4J4WyhSLyghDRB+L0WXwC7/4K1nMWY5M 2cluDoemHDIAepriFBwnRltYKaErzMNIHuHFj5HWN2vesoXGJVfN9lY4eU56LEsbCduM 7mc93ICnYAcqLhJ6V9LxuPJEIOLlFWVpZs9EhNz+p11NL4mVE8XvRnNQYu94ASpU1TAZ TMx+X0cuRUKSWYqSlnndbO5JtEsa+huh+UUHnwkkflwF3EhtvIRCTANCmTCJ6XSpCo5X ooUZr8/W/04iHQLJdCkiHq6r6jIO3sGQGFBp2Q42cw5rjm1We2pvPDq5wek7B41SRxoB NZ7g== 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=u3XMNwqRFqe0XhjHVtK3DWh/IPAkmsWcn4TJoVlgkSE=; b=i/uDl1f2AIlX+16O8Vdrhnu2acr13pWU/Oo4n/E5EcExvjmedKo2j9IX8MGkV4mbkf iQcECtFD1ggfU5opC+7Vxp1MNnPRaCI6D8gdsEKlh1IJgPRCUoj+WjVxx7x7YFi4FY53 n3RFJT3VJV4jQ45PkOnmqoUNbS8seeFdJhK+FtAVfTwwKBwJzJjVFF9cFSuYC35m/m6r loRj+FCz8ONXNS2E+zGakj4zBrlWReXPffW4buFruH0uvb9oH8julsyjlikRP9wA2WnN FB/rtDuAv5GnePiLECmtXx9SRSqPOcllRJD3LBNnKeCzYtC0iXcW5ncDahZgNamK6PpT f+zQ== 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 p3si1994987pga.745.2017.10.18.00.05.25; Wed, 18 Oct 2017 00:05:25 -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 S966776AbdJRHFX (ORCPT + 27 others); Wed, 18 Oct 2017 03:05:23 -0400 Received: from foss.arm.com ([217.140.101.70]:33942 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966527AbdJRHFS (ORCPT ); Wed, 18 Oct 2017 03:05:18 -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 1F02815BE; Wed, 18 Oct 2017 00:05:18 -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 C135C3F590; Wed, 18 Oct 2017 00:05:09 -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 14/20] cifs: move to generic async completion Date: Wed, 18 Oct 2017 08:00:46 +0100 Message-Id: <1508310057-25369-15-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 cifs starts an async. crypto op and waits for their completion. Move it over to generic code doing the same. Signed-off-by: Gilad Ben-Yossef Acked-by: Pavel Shilovsky --- fs/cifs/smb2ops.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) -- 2.7.4 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index bdb963d..e067404 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -2087,22 +2087,6 @@ init_sg(struct smb_rqst *rqst, u8 *sign) return sg; } -struct cifs_crypt_result { - int err; - struct completion completion; -}; - -static void cifs_crypt_complete(struct crypto_async_request *req, int err) -{ - struct cifs_crypt_result *res = req->data; - - if (err == -EINPROGRESS) - return; - - res->err = err; - complete(&res->completion); -} - static int smb2_get_enc_key(struct TCP_Server_Info *server, __u64 ses_id, int enc, u8 *key) { @@ -2143,12 +2127,10 @@ crypt_message(struct TCP_Server_Info *server, struct smb_rqst *rqst, int enc) struct aead_request *req; char *iv; unsigned int iv_len; - struct cifs_crypt_result result = {0, }; + DECLARE_CRYPTO_WAIT(wait); struct crypto_aead *tfm; unsigned int crypt_len = le32_to_cpu(tr_hdr->OriginalMessageSize); - init_completion(&result.completion); - rc = smb2_get_enc_key(server, tr_hdr->SessionId, enc, key); if (rc) { cifs_dbg(VFS, "%s: Could not get %scryption key\n", __func__, @@ -2208,14 +2190,10 @@ crypt_message(struct TCP_Server_Info *server, struct smb_rqst *rqst, int enc) aead_request_set_ad(req, assoc_data_len); aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - cifs_crypt_complete, &result); + crypto_req_done, &wait); - rc = enc ? crypto_aead_encrypt(req) : crypto_aead_decrypt(req); - - if (rc == -EINPROGRESS || rc == -EBUSY) { - wait_for_completion(&result.completion); - rc = result.err; - } + rc = crypto_wait_req(enc ? crypto_aead_encrypt(req) + : crypto_aead_decrypt(req), &wait); if (!rc && enc) memcpy(&tr_hdr->Signature, sign, SMB2_SIGNATURE_SIZE);