From patchwork Sat May 6 12:59:57 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: 98759 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp564944qge; Sat, 6 May 2017 06:01:57 -0700 (PDT) X-Received: by 10.99.64.69 with SMTP id n66mr8924967pga.197.1494075717802; Sat, 06 May 2017 06:01:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494075717; cv=none; d=google.com; s=arc-20160816; b=ZVK7agwhmzgwagaabvEzVVgs6yO9AQfpPMvYD1OMFM1QL+hCIXsSL2tnA7uLq+QnLp HoLEGfKOtkAzRq+5T2Fa8tvt+Kb2P6iLvmpNbiq8RdqDTyNexI7HVd56jz5amNOAoWY2 gtBOTVNZnYp30YUUPRyqcjxutalI+4dH/GsH6+7m4AEqAcpLZd1/0mkdEQ9ORbZVeyru M89NWAPDZWIJVV6Lmjz/Me9s7+jD2Pveou6TDM7+/Fsna9gT9purnEz42Hy4mR/XDgsB wNCWTfQDY2rJ9YO38JmEXjbFYYDFgtLdE3ousL0RAUzanDVcaMIMfHMNkfvuWxkfAIx8 Ry8Q== 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=Zdmz4A/hqceZaopk9QCNQkKtHd3Zq3BBlEEAU5LQ5Wo=; b=knkln7yj877XWuaZ+yJPbo6PSYF6VewgiSB6idQRepuTMpOUS+M4XYFdwV9yA90VQR mPOyxpPpxqe0e5jR7YUo9dUW8q1eOPAY5iKG2hK4V2ODN582ggUA1HzOGqEKIX0/tych sflju3WqjPoR+tDEYg5T8IK2UgzIEaAQtX0L85/kRLr3z9augAGepF7si6Izejc8aWym z3+qlFywAEgdohQXmy27jTukKSvpwEbLjsvPR+TZdDfwy4sbFtyeO1Z0xAxZkxDJlVF3 Qd9Nejl6EEVcV1cu99VuvIIo5EkxhTq27hOVF36mamULCdHDwQkE4xo66k9FandFHf0+ AD3w== 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 s1si8544258plj.269.2017.05.06.06.01.57; Sat, 06 May 2017 06:01:57 -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 S1752869AbdEFNBx (ORCPT + 25 others); Sat, 6 May 2017 09:01:53 -0400 Received: from foss.arm.com ([217.140.101.70]:59340 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754429AbdEFNBi (ORCPT ); Sat, 6 May 2017 09:01:38 -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 A8DD41688; Sat, 6 May 2017 06:01:27 -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 367F03F41F; Sat, 6 May 2017 06:01:21 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" Cc: Ofir Drang , Gilad Ben-Yossef , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fsdevel@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Subject: [RFC 08/10] cifs: move to generic async completion Date: Sat, 6 May 2017 15:59:57 +0300 Message-Id: <1494075602-5061-9-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1494075602-5061-1-git-send-email-gilad@benyossef.com> References: <1494075602-5061-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 --- 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 152e37f..cee7bb3 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -1706,22 +1706,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) { @@ -1762,12 +1746,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__, @@ -1825,14 +1807,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);