Whamcloud - gitweb
LU-16369 ldiskfs: do not check enc context at lookup
authorSebastien Buisson <sbuisson@ddn.com>
Tue, 6 Dec 2022 16:36:02 +0000 (17:36 +0100)
committerAndreas Dilger <adilger@whamcloud.com>
Tue, 25 Apr 2023 03:42:23 +0000 (03:42 +0000)
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/ex/lustre-release/+/49894
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
ldiskfs/kernel_patches/patches/rhel8.5/ext4-filename-encode.patch
ldiskfs/kernel_patches/patches/rhel8.7/ext4-filename-encode.patch
ldiskfs/kernel_patches/patches/rhel8/ext4-filename-encode.patch

index 6351670..582f6b7 100644 (file)
@@ -1,7 +1,7 @@
 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
 + *
@@ -78,6 +78,14 @@ diff -wur /dev/null b/fs/ext4/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)
@@ -357,6 +365,15 @@ diff -wur a/fs/ext4/namei.c b/fs/ext4/namei.c
        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))
index 7dc0528..2551bbd 100644 (file)
@@ -1,7 +1,7 @@
 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
 + *
@@ -78,6 +78,14 @@ diff -wur /dev/null b/fs/ext4/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)
@@ -358,6 +366,15 @@ Index: kernel-4.18.0-423.el8/fs/ext4/namei.c
        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))
index 728ffa8..7a9f591 100644 (file)
@@ -1,7 +1,7 @@
 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
 + *
@@ -78,6 +78,14 @@ diff -wur /dev/null b/fs/ext4/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)
@@ -357,6 +365,15 @@ diff -wur a/fs/ext4/namei.c b/fs/ext4/namei.c
        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))