On rhel8, ldiskfs should not check for encryption context of inodes
upon lookup. On these kernels, ext4 is not encryption aware, so just
assume context is fine when target is mounted as ldiskfs.
Lustre-change: https://review.whamcloud.com/49324
Lustre-commit:
540c293a4d0fc80253670b3db8d6722da43284ad
Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Change-Id: I9f9813d290ea24b34f710e2c8219e856ca8fbc58
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49895
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
diff -wur /dev/null b/fs/ext4/critical_encode.h
--- /dev/null
+++ b/fs/ext4/critical_encode.h
-@@ -0,0 +1,158 @@
+@@ -0,0 +1,166 @@
+/*
+ * critical_encode.h
+ *
+#define fscrypt_get_encryption_info(inode) \
+ (unlikely(!IS_LUSTRE_MOUNT(inode->i_sb)) ? 0 : -EOPNOTSUPP)
+
++static inline int ext4_has_permitted_context(struct inode *parent,
++ struct inode *child)
++{
++ if (unlikely(!IS_LUSTRE_MOUNT(parent->i_sb)))
++ return 1;
++ return fscrypt_has_permitted_context(parent, child);
++}
++
+static inline int ext4_prepare_lookup(struct inode *dir,
+ struct dentry *dentry,
+ unsigned int flags)
if (err)
return ERR_PTR(err);
+@@ -1957,7 +1957,7 @@ static struct dentry *ext4_lookup(struct
+ }
+ if (!IS_ERR(inode) && IS_ENCRYPTED(dir) &&
+ (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) &&
+- !fscrypt_has_permitted_context(dir, inode)) {
++ !ext4_has_permitted_context(dir, inode)) {
+ ext4_warning(inode->i_sb,
+ "Inconsistent encryption contexts: %lu/%lu",
+ dir->i_ino, inode->i_ino);
@@ -2206,7 +2221,7 @@ int ext4_find_dest_de(struct inode *d
if (ext4_check_dir_entry(dir, NULL, de, bh,
buf, buf_size, offset))
diff -wur /dev/null b/fs/ext4/critical_encode.h
--- /dev/null
+++ b/fs/ext4/critical_encode.h
-@@ -0,0 +1,158 @@
+@@ -0,0 +1,166 @@
+/*
+ * critical_encode.h
+ *
+#define fscrypt_get_encryption_info(inode) \
+ (unlikely(!IS_LUSTRE_MOUNT(inode->i_sb)) ? 0 : -EOPNOTSUPP)
+
++static inline int ext4_has_permitted_context(struct inode *parent,
++ struct inode *child)
++{
++ if (unlikely(!IS_LUSTRE_MOUNT(parent->i_sb)))
++ return 1;
++ return fscrypt_has_permitted_context(parent, child);
++}
++
+static inline int ext4_prepare_lookup(struct inode *dir,
+ struct dentry *dentry,
+ unsigned int flags)
if (err)
return ERR_PTR(err);
+@@ -1957,7 +1957,7 @@ static struct dentry *ext4_lookup(struct
+ }
+ if (!IS_ERR(inode) && IS_ENCRYPTED(dir) &&
+ (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) &&
+- !fscrypt_has_permitted_context(dir, inode)) {
++ !ext4_has_permitted_context(dir, inode)) {
+ ext4_warning(inode->i_sb,
+ "Inconsistent encryption contexts: %lu/%lu",
+ dir->i_ino, inode->i_ino);
@@ -2271,7 +2296,7 @@ int ext4_find_dest_de(struct inode *dir,
if (ext4_check_dir_entry(dir, NULL, de, bh,
buf, buf_size, offset))
diff -wur /dev/null b/fs/ext4/critical_encode.h
--- /dev/null
+++ b/fs/ext4/critical_encode.h
-@@ -0,0 +1,158 @@
+@@ -0,0 +1,166 @@
+/*
+ * critical_encode.h
+ *
+#define fscrypt_get_encryption_info(inode) \
+ (unlikely(!IS_LUSTRE_MOUNT(inode->i_sb)) ? 0 : -EOPNOTSUPP)
+
++static inline int ext4_has_permitted_context(struct inode *parent,
++ struct inode *child)
++{
++ if (unlikely(!IS_LUSTRE_MOUNT(parent->i_sb)))
++ return 1;
++ return fscrypt_has_permitted_context(parent, child);
++}
++
+static inline int ext4_prepare_lookup(struct inode *dir,
+ struct dentry *dentry,
+ unsigned int flags)
if (err)
return ERR_PTR(err);
+@@ -1957,7 +1957,7 @@ static struct dentry *ext4_lookup(struct
+ }
+ if (!IS_ERR(inode) && IS_ENCRYPTED(dir) &&
+ (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) &&
+- !fscrypt_has_permitted_context(dir, inode)) {
++ !ext4_has_permitted_context(dir, inode)) {
+ ext4_warning(inode->i_sb,
+ "Inconsistent encryption contexts: %lu/%lu",
+ dir->i_ino, inode->i_ino);
@@ -2206,7 +2221,7 @@ int ext4_find_dest_de(struct inode *d
if (ext4_check_dir_entry(dir, NULL, de, bh,
buf, buf_size, offset))