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=-10.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 2885BC433E2 for ; Tue, 8 Sep 2020 11:31:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ECC9520936 for ; Tue, 8 Sep 2020 11:31:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599564695; bh=BSmMzOYGbAvjcnEx6v7x/E3VmkpQh3OSrDsVXUqKSPE=; h=Subject:From:To:Cc:Date:In-Reply-To:References:List-ID:From; b=GV5q2D/E+STBpuKQ+se2puUnredI65p3FucSUtfh90E2DIDKb0c8OMrRnpIqSPXsg rd5PfbrLQC8LMIsbOTov9qBQZd18A1Js5JjK+yJNJqNpuN3Jc81oJdU5aBgy8ZPb97 cEUQWToAXkDBc6fC2nEpGUdIP+wItVB0CDvHjvFY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730073AbgIHLat (ORCPT ); Tue, 8 Sep 2020 07:30:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:54622 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729753AbgIHLa2 (ORCPT ); Tue, 8 Sep 2020 07:30:28 -0400 Received: from tleilax.poochiereds.net (68-20-15-154.lightspeed.rlghnc.sbcglobal.net [68.20.15.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B1CF42087D; Tue, 8 Sep 2020 11:29:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599564600; bh=BSmMzOYGbAvjcnEx6v7x/E3VmkpQh3OSrDsVXUqKSPE=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=joPcZ1YBLxL8Qn6Rj++9+fibGNeSJhpg816JMNiHnvtNazWU8qUL2lJJW72FRjNwK nmJXJzjfkexgeDHL02JpH4SuIKk3MAukDuLdE38suPOtG6iNrU8fA9xDXDTa8vOp2p MLiYJlXLiAxvJP1YDwcZ7XUBKvwGsFXeFQlJSiZE= Message-ID: Subject: Re: [RFC PATCH v2 04/18] fscrypt: add fscrypt_new_context_from_inode From: Jeff Layton To: Eric Biggers Cc: ceph-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-fscrypt@vger.kernel.org Date: Tue, 08 Sep 2020 07:29:58 -0400 In-Reply-To: <20200908034830.GE68127@sol.localdomain> References: <20200904160537.76663-1-jlayton@kernel.org> <20200904160537.76663-5-jlayton@kernel.org> <20200908034830.GE68127@sol.localdomain> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org On Mon, 2020-09-07 at 20:48 -0700, Eric Biggers wrote: > On Fri, Sep 04, 2020 at 12:05:23PM -0400, Jeff Layton wrote: > > CephFS will need to be able to generate a context for a new "prepared" > > inode. Add a new routine for getting the context out of an in-core > > inode. > > > > Signed-off-by: Jeff Layton > > --- > > fs/crypto/policy.c | 20 ++++++++++++++++++++ > > include/linux/fscrypt.h | 1 + > > 2 files changed, 21 insertions(+) > > > > diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c > > index c56ad886f7d7..10eddd113a21 100644 > > --- a/fs/crypto/policy.c > > +++ b/fs/crypto/policy.c > > @@ -670,6 +670,26 @@ int fscrypt_set_context(struct inode *inode, void *fs_data) > > } > > EXPORT_SYMBOL_GPL(fscrypt_set_context); > > > > +/** > > + * fscrypt_context_from_inode() - fetch the encryption context out of in-core inode > > Comment doesn't match the function name. > > Also, the name isn't very clear. How about calling this > fscrypt_context_for_new_inode()? > > BTW, I might rename fscrypt_new_context_from_policy() to > fscrypt_context_from_policy() in my patchset. Since it now makes the caller > provide the nonce, technically it's no longer limited to "new" contexts. > Ahh yes. I didn't properly update the commit message here. Your suggested names sound fine. I'll plan to fix that up. > > + * @ctx: where context should be written > > + * @inode: inode from which to fetch context > > + * > > + * Given an in-core prepared, but not-necessarily fully-instantiated inode, > > + * generate an encryption context from its policy and write it to ctx. > > Clarify what is meant by "prepared" (fscrypt_prepare_new_inode() was called) > vs. "instantiated". > Ack. > > + * > > + * Returns size of the context. > > + */ > > +int fscrypt_new_context_from_inode(union fscrypt_context *ctx, struct inode *inode) > > +{ > > + struct fscrypt_info *ci = inode->i_crypt_info; > > + > > + BUILD_BUG_ON(sizeof(*ctx) != FSCRYPT_SET_CONTEXT_MAX_SIZE); > > + > > + return fscrypt_new_context_from_policy(ctx, &ci->ci_policy, ci->ci_nonce); > > +} > > +EXPORT_SYMBOL_GPL(fscrypt_new_context_from_inode); > > fscrypt_set_context() should be changed to call this, instead of duplicating the > same logic. As part of that, the WARN_ON_ONCE(!ci) that's currently in > fscrypt_set_context() should go in here instead. Ok. -- Jeff Layton