Re: [RFC PATCH v5 04/19] fscrypt: add fscrypt_context_for_new_inode

Jeff Layton
2021-04-08T16:27:15Z

On Wed, 2021-04-07 at 18:21 -0700, Eric Biggers wrote:
> On Fri, Mar 26, 2021 at 01:32:12PM -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.
>
> It would be helpful to briefly mention why fscrypt_set_context() can't be used
> instead (like the other filesystems do).
>

I'll add this to the changelog as well before the next posting, but
basically, when we send a create request to the MDS, we send along a
full set of attributes, including an xattr blob that includes the
encryption.ctx xattr.

If we used fscrypt_set_context then we'd have to make a separate round
trip to set the xattr on the server for every create. We'd also have a
window of time where the inode exists on the MDS but has no encryption
context attached, which could cause race conditions with other clients.
--
Jeff Layton <jlayton@kernel.org>