From patchwork Tue Sep 5 12:38:53 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: 111681 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp2785574qge; Tue, 5 Sep 2017 05:42:54 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5D7iwxU8Rq6Jc2VYbZjbFfrxCZh1/Ixz25t9ZyYIEVxIFBQI2g3h+wAYa66K6YSuUwzAvU X-Received: by 10.101.74.207 with SMTP id c15mr3814614pgu.227.1504615374761; Tue, 05 Sep 2017 05:42:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504615374; cv=none; d=google.com; s=arc-20160816; b=WIVqFYloTNLoA1erSV14qHYDT4qK7xeqgG7rrqeFb1w9wViT/2aT7IPtKMWWmCnC40 JWuKz9He1fsPF2eGnRiigHw/emMMDQtCURwdstIrOzz7sFfd8DZVcq/nvG5sSQkZOzLM 7N5MVwKEyANRn1VvpNH51ZKwNi5GuhoEWMxZTmtK+xjBdAC5ssxhyCMioAyd3Qp4/LDg 3v0afMzLUyrsr2thcpDaHzUZMC0knW6WrPU0P2+X1vjxxgXwtfxXt94Fm2irkZ313fhv PBzRO934kHkyRzvxNJUHcMywjjEN306H33mNnzUBCiKtwhIhrArMezCcvVoFO9oCytck cFJw== 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=V5+pdMVaV58CXee7eUr8X777D/mUlNlOwg1k0fJk5Wk=; b=Ec/69Vm3fc853bKV6eh1vEyIhbAdZHNO+Ulzi1/JAgMJrHOohT3ddIclfcUpPPhtuZ DgORePR2HtN3sB96SGmbfehR/ey1RaXpCasJr3x2TAH5pvo+tlrS6nM/JcJPXOfoik6m RZw0jnemNNuEz3lZrjK5YQftFG2Av229DcTR7TJQkbx5vhcscA3pl6H76UntAJAAU73z 91T7ClpoZjfQcSe5B/XAIzxAgHrZrjH7G/PkMfjSUrr/6obrp/RSxjfGRy+J2D+rv4ZN ABvITQtQubvA7nw3X08rkbIn/Os1ohrJ7DCxHxJ01RwRCIg+8J2RePnpKc1h7awYge++ 3RNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-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 r1si283078plb.713.2017.09.05.05.42.54; Tue, 05 Sep 2017 05:42:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751635AbdIEMmv (ORCPT + 1 other); Tue, 5 Sep 2017 08:42:51 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:39688 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751149AbdIEMmo (ORCPT ); Tue, 5 Sep 2017 08:42:44 -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 50972165C; Tue, 5 Sep 2017 05:42:44 -0700 (PDT) Received: from gby.kfn.arm.com (unknown [10.45.48.140]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 624513F3E1; Tue, 5 Sep 2017 05:42:35 -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, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Steffen Klassert , Alexey Kuznetsov , Hideaki YOSHIFUJI , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , 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-raid@vger.kernel.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 Cc: Ofir Drang Subject: [PATCH v8 14/20] cifs: move to generic async completion Date: Tue, 5 Sep 2017 15:38:53 +0300 Message-Id: <1504615144-29770-15-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504615144-29770-1-git-send-email-gilad@benyossef.com> References: <1504615144-29770-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@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.1.4 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index fb2934b..982b39d 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -2066,22 +2066,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) { @@ -2122,12 +2106,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__, @@ -2187,14 +2169,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);