From 041dc675211d64c7ab5bd6c026e997ae33f21838 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Thu, 6 Jan 2022 10:18:20 +0100 Subject: [PATCH] LU-15406 sec: fix in-kernel fscrypt support When using in-kernel fscrypt provided by Linux 5.4, the encryption context can be retrieved by calling the .get_context function defined in the struct fscrypt_operations of the super_block. llite needs to retrieve the encryption context explicitly in case of migration via volatile files. Lustre-change: https://review.whamcloud.com/45987 Lustre-commit: 2169aed82a32df47be9aef2f249178ede6c7fadd Fixes: 09c558d16f ("LU-14677 sec: migrate/extend/split on encrypted file") Fixes: fdbf2ffd41 ("LU-14677 sec: no encryption key migrate/extend/resync/split") Signed-off-by: Sebastien Buisson Signed-off-by: James Simmons Change-Id: I76dbd21f0dc95920519ea375c583bc378d7c9f53 Reviewed-by: Andreas Dilger Reviewed-on: https://review.whamcloud.com/46172 Tested-by: jenkins Tested-by: Maloo --- lustre/include/lustre_crypto.h | 2 ++ lustre/llite/namei.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/lustre/include/lustre_crypto.h b/lustre/include/lustre_crypto.h index c100028..b6c1c8a 100644 --- a/lustre/include/lustre_crypto.h +++ b/lustre/include/lustre_crypto.h @@ -120,6 +120,8 @@ static inline int critical_decode(const u8 *src, int len, char *dst) #define llcrypt_symlink_data fscrypt_symlink_data #define llcrypt_dummy_context_enabled(inode) \ fscrypt_dummy_context_enabled(inode) +#define llcrypt_require_key(inode) \ + fscrypt_require_key(inode) #define llcrypt_has_encryption_key(inode) fscrypt_has_encryption_key(inode) #define llcrypt_encrypt_pagecache_blocks(page, len, offs, gfp_flags) \ fscrypt_encrypt_pagecache_blocks(page, len, offs, gfp_flags) diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 3e77184..aff3086 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -934,6 +934,9 @@ getctx: #ifdef CONFIG_LL_ENCRYPTION rc = lsi->lsi_cop->get_context(ref_inode, ctx, ctx_size); +#elif defined(HAVE_LUSTRE_CRYPTO) + rc = ref_inode->i_sb->s_cop->get_context(ref_inode, + ctx, ctx_size); #else rc = -ENODATA; #endif -- 1.8.3.1