From patchwork Tue Feb 9 01:34:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 8257441 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C49B89F4DD for ; Tue, 9 Feb 2016 01:36:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EE70A202FE for ; Tue, 9 Feb 2016 01:36:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C1005202E9 for ; Tue, 9 Feb 2016 01:36:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756411AbcBIBfx (ORCPT ); Mon, 8 Feb 2016 20:35:53 -0500 Received: from mail.kernel.org ([198.145.29.136]:53510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932444AbcBIBeY (ORCPT ); Mon, 8 Feb 2016 20:34:24 -0500 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 47B0B202FE; Tue, 9 Feb 2016 01:34:23 +0000 (UTC) Received: from localhost (107-1-141-74-ip-static.hfc.comcastbusiness.net [107.1.141.74]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7B030202EC; Tue, 9 Feb 2016 01:34:22 +0000 (UTC) From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim , Theodore Ts'o Subject: [PATCH 3/5] f2fs crypto: f2fs_page_crypto() doesn't need a encryption context Date: Mon, 8 Feb 2016 17:34:15 -0800 Message-Id: <1454981657-25473-3-git-send-email-jaegeuk@kernel.org> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1454981657-25473-1-git-send-email-jaegeuk@kernel.org> References: <1454981657-25473-1-git-send-email-jaegeuk@kernel.org> X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adopts: ext4 crypto: ext4_page_crypto() doesn't need a encryption context Since ext4_page_crypto() doesn't need an encryption context (at least not any more), this allows us to simplify a number function signature and also allows us to avoid needing to allocate a context in ext4_block_write_begin(). It also means we no longer need a separate ext4_decrypt_one() function. Signed-off-by: Theodore Ts'o Signed-off-by: Jaegeuk Kim --- fs/f2fs/crypto.c | 27 +++++---------------------- fs/f2fs/data.c | 2 +- fs/f2fs/f2fs.h | 3 +-- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/fs/f2fs/crypto.c b/fs/f2fs/crypto.c index d879c6c..3ef3786 100644 --- a/fs/f2fs/crypto.c +++ b/fs/f2fs/crypto.c @@ -156,7 +156,7 @@ static void completion_pages(struct work_struct *work) bio_for_each_segment_all(bv, bio, i) { struct page *page = bv->bv_page; - int ret = f2fs_decrypt(ctx, page); + int ret = f2fs_decrypt(page); if (ret) { WARN_ON_ONCE(1); @@ -320,8 +320,7 @@ typedef enum { F2FS_ENCRYPT, } f2fs_direction_t; -static int f2fs_page_crypto(struct f2fs_crypto_ctx *ctx, - struct inode *inode, +static int f2fs_page_crypto(struct inode *inode, f2fs_direction_t rw, pgoff_t index, struct page *src_page, @@ -418,7 +417,7 @@ struct page *f2fs_encrypt(struct inode *inode, goto err_out; ctx->w.control_page = plaintext_page; - err = f2fs_page_crypto(ctx, inode, F2FS_ENCRYPT, plaintext_page->index, + err = f2fs_page_crypto(inode, F2FS_ENCRYPT, plaintext_page->index, plaintext_page, ciphertext_page); if (err) { ciphertext_page = ERR_PTR(err); @@ -446,30 +445,14 @@ err_out: * * Return: Zero on success, non-zero otherwise. */ -int f2fs_decrypt(struct f2fs_crypto_ctx *ctx, struct page *page) +int f2fs_decrypt(struct page *page) { BUG_ON(!PageLocked(page)); - return f2fs_page_crypto(ctx, page->mapping->host, + return f2fs_page_crypto(page->mapping->host, F2FS_DECRYPT, page->index, page, page); } -/* - * Convenience function which takes care of allocating and - * deallocating the encryption context - */ -int f2fs_decrypt_one(struct inode *inode, struct page *page) -{ - struct f2fs_crypto_ctx *ctx = f2fs_get_crypto_ctx(inode); - int ret; - - if (IS_ERR(ctx)) - return PTR_ERR(ctx); - ret = f2fs_decrypt(ctx, page); - f2fs_release_crypto_ctx(ctx); - return ret; -} - bool f2fs_valid_contents_enc_mode(uint32_t mode) { return (mode == F2FS_ENCRYPTION_MODE_AES_256_XTS); diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 03f948e..ca99a2a 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1592,7 +1592,7 @@ repeat: /* avoid symlink page */ if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) { - err = f2fs_decrypt_one(inode, page); + err = f2fs_decrypt(page); if (err) goto fail; } diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index f6a841b..66a87cb 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -2213,8 +2213,7 @@ uint32_t f2fs_validate_encryption_key_size(uint32_t, uint32_t); struct f2fs_crypto_ctx *f2fs_get_crypto_ctx(struct inode *); void f2fs_release_crypto_ctx(struct f2fs_crypto_ctx *); struct page *f2fs_encrypt(struct inode *, struct page *); -int f2fs_decrypt(struct f2fs_crypto_ctx *, struct page *); -int f2fs_decrypt_one(struct inode *, struct page *); +int f2fs_decrypt(struct page *); void f2fs_end_io_crypto_work(struct f2fs_crypto_ctx *, struct bio *); /* crypto_key.c */