From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82E16C04AAC for ; Mon, 20 May 2019 17:28:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 59893217D7 for ; Mon, 20 May 2019 17:28:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558373332; bh=G6qGhs9z08vCCaPScCujWLwRdyw0LLLfhavJ6hq2ziU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Mkq8loJfBtUchB4ETjA6wwFVLA79nPCSs877sFOj8nyq7mrzyHddL+zvh+QocaHgJ DIf3AISTuOj2sfueWMT8FATP5iFnMO16SijARPa9qlbBNho55OUHiFDykGArXykge3 Ye/CWFQbD2ptoB5jRfjoZaPnmxJ09RogKXbohxIk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392944AbfETR2v (ORCPT ); Mon, 20 May 2019 13:28:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:40466 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726672AbfETR2s (ORCPT ); Mon, 20 May 2019 13:28:48 -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 3DE172171F; Mon, 20 May 2019 17:28:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558373327; bh=G6qGhs9z08vCCaPScCujWLwRdyw0LLLfhavJ6hq2ziU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BD6fzkfmnS0TgqHcU9BjHRDCjGu64xnYFP2zsvQ9zl/xeYodbvotnmxbWL4F0f8qs +Iq3RJveCLSFTVCdMIdcR93DTLf2aw9cvnZW+ZjmHkcsja4VOonVBpp/znKNvxvWma QS+jcFVFgNWIozyxoAnlfS8DghBCCNRFX1Q4WMdg= From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: Satya Tangirala , linux-api@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, keyrings@vger.kernel.org, linux-mtd@lists.infradead.org, linux-crypto@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, Paul Crowley Subject: [PATCH v6 04/16] fscrypt: add ->ci_inode to fscrypt_info Date: Mon, 20 May 2019 10:25:40 -0700 Message-Id: <20190520172552.217253-5-ebiggers@kernel.org> X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog In-Reply-To: <20190520172552.217253-1-ebiggers@kernel.org> References: <20190520172552.217253-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 Add an inode back-pointer to 'struct fscrypt_info', such that inode->i_crypt_info->ci_inode == inode. This will be useful for: 1. Evicting the inodes when a fscrypt key is removed, since we'll track the inodes using a given key by linking their fscrypt_infos together, rather than the inodes directly. This avoids bloating 'struct inode' with a new list_head. 2. Simplifying the per-file key setup, since the inode pointer won't have to be passed around everywhere just in case something goes wrong and it's needed for fscrypt_warn(). Signed-off-by: Eric Biggers --- fs/crypto/fscrypt_private.h | 3 +++ fs/crypto/keyinfo.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h index 52e09ef40bfa6..ac24edfc297f1 100644 --- a/fs/crypto/fscrypt_private.h +++ b/fs/crypto/fscrypt_private.h @@ -73,6 +73,9 @@ struct fscrypt_info { */ struct fscrypt_mode *ci_mode; + /* Back-pointer to the inode */ + struct inode *ci_inode; + /* * If non-NULL, then this inode uses a master key directly rather than a * derived key, and ci_ctfm will equal ci_master_key->mk_ctfm. diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c index 479389a4e0559..49764d335c370 100644 --- a/fs/crypto/keyinfo.c +++ b/fs/crypto/keyinfo.c @@ -541,6 +541,8 @@ int fscrypt_get_encryption_info(struct inode *inode) if (!crypt_info) return -ENOMEM; + crypt_info->ci_inode = inode; + crypt_info->ci_flags = ctx.flags; crypt_info->ci_data_mode = ctx.contents_encryption_mode; crypt_info->ci_filename_mode = ctx.filenames_encryption_mode; -- 2.21.0.1020.gf2820cf01a-goog