From patchwork Tue Aug 8 12:03:44 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: 109626 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp3985681obb; Tue, 8 Aug 2017 05:07:17 -0700 (PDT) X-Received: by 10.98.71.200 with SMTP id p69mr4194422pfi.296.1502194036907; Tue, 08 Aug 2017 05:07:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502194036; cv=none; d=google.com; s=arc-20160816; b=fsGD9BDpsM5Jiewv5DqG54DnzUmAuown5lfikWRy1XmKei8xC3SQB8z29JXbYvagiw fRkNPaF5oXTD8i0bkzxULhLfOeHhVVoXwqRbJCmnV6HEaHV5CdZzig5lBR4IKt6eEFCt H+jpPb4Duisqsc15HmxUZxcFGM+a0nWtmFgKJ/DzrMdv0NZEnRgvYtgzdtXdxJ7j+i2d sfBZl35KthTEe7pyShsN/Ky7MN/4hOMjaKilXyzIo1Iiz0/zM0JqddvTQgFlggDDsXNQ G/toDUlUJQjfsSB7pERHYjmH1UIFSiJEyFlfjE36J93Lex3C7Z5YNtSjXxCLRtn9hrUw N8rQ== 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=GWns1hNSP5Hw+39AuDkzItF6g9pNRvzW/kFJi0SQ8PQ=; b=hEcmUx/8uxxUrnKvmq6IL8XO18zaHc0XShiG+83GaFJ7yaGImUICvsUx+ql8+WnQLM VCByRPsnpXI7jpAsNT91+pwOxuBnJ88q38X7O1e1aVB/kbz4dKLZLrISMO55cF4VJ6nI rL87dxFFcwv7I5tjj3SFFGdgZZqU/7MK7Xz6hdXrDPmsuMzAkQJAaBibjDbdqOwhmNdx bXoqyqzhoqlaqaNuapN/rJTGQI8VLZSE9jw6B9mgEoy4EwnAZZ/5vILtIHJYAeVcteiI 2ed28GQmBnRm4T3pkuKWJ53tyd3BHoNgfiQKuO0H2RM4OS5pnVYipnjRIQDLbVVK8ba7 WJqg== 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 h69si728443pge.162.2017.08.08.05.07.16; Tue, 08 Aug 2017 05:07:16 -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 S1752763AbdHHMHO (ORCPT + 25 others); Tue, 8 Aug 2017 08:07:14 -0400 Received: from foss.arm.com ([217.140.101.70]:33892 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752130AbdHHMHK (ORCPT ); Tue, 8 Aug 2017 08:07:10 -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 22ACE1AED; Tue, 8 Aug 2017 05:07:10 -0700 (PDT) Received: from gby.kfn.arm.com (unknown [10.45.48.154]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C08373F577; Tue, 8 Aug 2017 05:06:59 -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 , 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, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v4 13/19] cifs: move to generic async completion Date: Tue, 8 Aug 2017 15:03:44 +0300 Message-Id: <1502193834-11289-14-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1502193834-11289-1-git-send-email-gilad@benyossef.com> References: <1502193834-11289-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.1.4 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index cfacf2c..16fb041 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -1878,22 +1878,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) { @@ -1934,12 +1918,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__, @@ -1999,14 +1981,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);