Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6591323yba; Wed, 1 May 2019 15:46:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqx74DrHKZThgmKzugRsefjN7KvItx/ownh09WG9WvmTydN3/vE0+LXtzgDpbX6iySOoEcfJ X-Received: by 2002:a17:902:bb96:: with SMTP id m22mr147226pls.185.1556750789568; Wed, 01 May 2019 15:46:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556750789; cv=none; d=google.com; s=arc-20160816; b=Klr/xJAG1fTOGdYEGIk6dj3C67k3KCIkWE5zCJ3kt+PKQs9xT1O0IaIzn7YPHRulia YyqiAu6YPzClhOEKUMYCR1y5x4+wDJ8mrPvHDXDcAA4tOvMq7c4DgRH2mmIc0YGdzQSR T6LCbSt0D4FJR1L5YlKYqikzUigvMo0kllEF4v3tBhZYLKrNPWzEUyEMo8HNN+K8Fgw6 WVTpevsYa5jhLGYhSexf+P5u1QqDXMWVNEYD3zQJ0N5R0Y+/q9rY4oSkH3T5jsfg3LVN h2gmfP7iemTkII9O+QDal7/IWjD91blrSfSlYE7iTFIR0JU6FVfryEq30QPLQRtkZ2Wf eCcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=x0V9uK/aP7G9ZzVdOKI7b7Q4/Tvw/BSsZ6WLSxGpg8M=; b=PfGmW3RMfdNY5arIg4CSEEZCh40eg12SJfUYBZOmsm2ht1V4EquO8tRD3ny+mzHfVh 8mVHmRA0aSda7xmptLxJiAdpNPdlkJlE7oTspP59ZKOeXfzuob/qfiuiuoiLE/mJoE+c pmqhuRzd0seQwVQYl+oH5UTJHAuT3hSYFiy5nTYd5HqjioUUBsVuGps4LVZln92nLlu3 XwQhXwUR40ptqu5mBJ5E/pSJpC3MXjxg+la36bjpz6eVK7PjEC5c9QsMAbrZ/iqwJuBz AxuXQ5HWFWYI0wE5H2KsJ2de4j8yvWRKhyuJSRFa3OhvNKiJmdwH/nOM7h+Z9cD1I1Mh +kkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gwN46aKR; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s19si16391918plr.216.2019.05.01.15.46.11; Wed, 01 May 2019 15:46:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gwN46aKR; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726334AbfEAWqH (ORCPT + 99 others); Wed, 1 May 2019 18:46:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:47204 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726224AbfEAWqH (ORCPT ); Wed, 1 May 2019 18:46:07 -0400 Received: from ebiggers-linuxstation.mtv.corp.google.com (unknown [104.132.1.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C7404208C4; Wed, 1 May 2019 22:46:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556750766; bh=X/mYD3int+IFjsGHKyVvU/ocytwbsaEUU4yVz/voQ5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gwN46aKRhM8wHF0N8z7GG9yN6XRMEgGVua2A1lLv+wZTxx1ZsgmjycpjxjLg19zJ7 seEDN6xn96mScG/TqNq1xrO9UjEdhmZ76+/2+2GNoKavI055ZFfen/JdRrEJiA2NHR BYTwPdmChKRJx8noNAm8LE9s6AnT7lPv5oNsif74= From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org, linux-fsdevel@vger.kernel.org, Chandan Rajendra Subject: [PATCH 03/13] fscrypt: rename fscrypt_do_page_crypto() to fscrypt_crypt_block() Date: Wed, 1 May 2019 15:45:05 -0700 Message-Id: <20190501224515.43059-4-ebiggers@kernel.org> X-Mailer: git-send-email 2.21.0.593.g511ec345e18-goog In-Reply-To: <20190501224515.43059-1-ebiggers@kernel.org> References: <20190501224515.43059-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Eric Biggers fscrypt_do_page_crypto() only does a single encryption or decryption operation, with a single logical block number (single IV). So it actually operates on a filesystem block, not a "page" per se. To reflect this, rename it to fscrypt_crypt_block(). Signed-off-by: Eric Biggers --- fs/crypto/bio.c | 6 +++--- fs/crypto/crypto.c | 24 ++++++++++++------------ fs/crypto/fscrypt_private.h | 11 +++++------ 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/fs/crypto/bio.c b/fs/crypto/bio.c index 548ec6bb569cf..bcab8822217b0 100644 --- a/fs/crypto/bio.c +++ b/fs/crypto/bio.c @@ -84,9 +84,9 @@ int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk, return -ENOMEM; while (len--) { - err = fscrypt_do_page_crypto(inode, FS_ENCRYPT, lblk, - ZERO_PAGE(0), ciphertext_page, - PAGE_SIZE, 0, GFP_NOFS); + err = fscrypt_crypt_block(inode, FS_ENCRYPT, lblk, + ZERO_PAGE(0), ciphertext_page, + PAGE_SIZE, 0, GFP_NOFS); if (err) goto errout; diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c index ebfa13cfecb7d..e6802d7aca3c7 100644 --- a/fs/crypto/crypto.c +++ b/fs/crypto/crypto.c @@ -147,10 +147,11 @@ void fscrypt_generate_iv(union fscrypt_iv *iv, u64 lblk_num, crypto_cipher_encrypt_one(ci->ci_essiv_tfm, iv->raw, iv->raw); } -int fscrypt_do_page_crypto(const struct inode *inode, fscrypt_direction_t rw, - u64 lblk_num, struct page *src_page, - struct page *dest_page, unsigned int len, - unsigned int offs, gfp_t gfp_flags) +/* Encrypt or decrypt a single filesystem block of file contents */ +int fscrypt_crypt_block(const struct inode *inode, fscrypt_direction_t rw, + u64 lblk_num, struct page *src_page, + struct page *dest_page, unsigned int len, + unsigned int offs, gfp_t gfp_flags) { union fscrypt_iv iv; struct skcipher_request *req = NULL; @@ -227,9 +228,9 @@ struct page *fscrypt_encrypt_page(const struct inode *inode, if (inode->i_sb->s_cop->flags & FS_CFLG_OWN_PAGES) { /* with inplace-encryption we just encrypt the page */ - err = fscrypt_do_page_crypto(inode, FS_ENCRYPT, lblk_num, page, - ciphertext_page, len, offs, - gfp_flags); + err = fscrypt_crypt_block(inode, FS_ENCRYPT, lblk_num, page, + ciphertext_page, len, offs, + gfp_flags); if (err) return ERR_PTR(err); @@ -243,9 +244,8 @@ struct page *fscrypt_encrypt_page(const struct inode *inode, if (!ciphertext_page) return ERR_PTR(-ENOMEM); - err = fscrypt_do_page_crypto(inode, FS_ENCRYPT, lblk_num, - page, ciphertext_page, len, offs, - gfp_flags); + err = fscrypt_crypt_block(inode, FS_ENCRYPT, lblk_num, page, + ciphertext_page, len, offs, gfp_flags); if (err) { fscrypt_free_bounce_page(ciphertext_page); return ERR_PTR(err); @@ -277,8 +277,8 @@ int fscrypt_decrypt_page(const struct inode *inode, struct page *page, if (!(inode->i_sb->s_cop->flags & FS_CFLG_OWN_PAGES)) BUG_ON(!PageLocked(page)); - return fscrypt_do_page_crypto(inode, FS_DECRYPT, lblk_num, page, page, - len, offs, GFP_NOFS); + return fscrypt_crypt_block(inode, FS_DECRYPT, lblk_num, page, page, + len, offs, GFP_NOFS); } EXPORT_SYMBOL(fscrypt_decrypt_page); diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h index a5a5486979ff7..8565536feb2b8 100644 --- a/fs/crypto/fscrypt_private.h +++ b/fs/crypto/fscrypt_private.h @@ -117,12 +117,11 @@ static inline bool fscrypt_valid_enc_modes(u32 contents_mode, /* crypto.c */ extern struct kmem_cache *fscrypt_info_cachep; extern int fscrypt_initialize(unsigned int cop_flags); -extern int fscrypt_do_page_crypto(const struct inode *inode, - fscrypt_direction_t rw, u64 lblk_num, - struct page *src_page, - struct page *dest_page, - unsigned int len, unsigned int offs, - gfp_t gfp_flags); +extern int fscrypt_crypt_block(const struct inode *inode, + fscrypt_direction_t rw, u64 lblk_num, + struct page *src_page, struct page *dest_page, + unsigned int len, unsigned int offs, + gfp_t gfp_flags); extern struct page *fscrypt_alloc_bounce_page(gfp_t gfp_flags); extern const struct dentry_operations fscrypt_d_ops; -- 2.21.0.593.g511ec345e18-goog