Whamcloud - gitweb
LU-13717 sec: make client encryption compatible with ext4
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / rhel8.5 / ext4-enc-flag.patch
1 diff -wur a/fs/ext4/inode.c b/fs/ext4/inode.c
2 --- a/fs/ext4/inode.c
3 +++ b/fs/ext4/inode.c
4 @@ -4766,8 +4766,9 @@ void ext4_set_inode_flags(struct inod
5         if (init && ext4_should_enable_dax(inode))
6                 new_fl |= S_DAX;
7  
8 -       if (flags & EXT4_ENCRYPT_FL)
9 +       if (flags & EXT4_ENCRYPT_FL &&
10 +           unlikely(test_opt(inode->i_sb, DIRDATA) != EXT4_MOUNT_DIRDATA))
11                 new_fl |= S_ENCRYPTED;
12         inode_set_flags(inode, new_fl,
13                         S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_DAX|
14                         S_ENCRYPTED);
15 @@ -5753,8 +5757,9 @@ int ext4_getattr(const struct path *p
16                 stat->attributes |= STATX_ATTR_APPEND;
17         if (flags & EXT4_COMPR_FL)
18                 stat->attributes |= STATX_ATTR_COMPRESSED;
19 -       if (flags & EXT4_ENCRYPT_FL)
20 +       if (flags & EXT4_ENCRYPT_FL &&
21 +           unlikely(test_opt(inode->i_sb, DIRDATA) != EXT4_MOUNT_DIRDATA))
22                 stat->attributes |= STATX_ATTR_ENCRYPTED;
23         if (flags & EXT4_IMMUTABLE_FL)
24                 stat->attributes |= STATX_ATTR_IMMUTABLE;
25         if (flags & EXT4_NODUMP_FL)
26 diff -wur a/fs/ext4/xattr.c b/fs/ext4/xattr.c
27 --- a/fs/ext4/xattr.c
28 +++ b/fs/ext4/xattr.c
29 @@ -654,6 +654,7 @@
30         up_read(&EXT4_I(inode)->xattr_sem);
31         return error;
32  }
33 +EXPORT_SYMBOL(ext4_xattr_get);
34  
35  static int
36  ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
37 @@ -2413,12 +2413,17 @@ retry_inode:
38                         ext4_handle_sync(handle);
39         }
40  
41 +       if (!error && name_index == EXT4_XATTR_INDEX_ENCRYPTION &&
42 +           strcmp(name, "c") == 0)
43 +               EXT4_I(inode)->i_flags |= EXT4_ENCRYPT_FL;
44 +
45  cleanup:
46         brelse(is.iloc.bh);
47         brelse(bs.bh);
48         ext4_write_unlock_xattr(inode, &no_expand);
49         return error;
50  }
51 +EXPORT_SYMBOL(ext4_xattr_set_handle);
52  
53  int ext4_xattr_set_credits(struct inode *inode, size_t value_len,
54                            bool is_create, int *credits)