Whamcloud - gitweb
e7f86935f0cc85f41c7b80945b421c84505ae0f4
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / rhel8 / ext4-enc-flag.patch
1 diff -wur a/fs/ext4/ext4.h b/fs/ext4/ext4.h
2 --- a/fs/ext4/ext4.h
3 +++ b/fs/ext4/ext4.h
4 @@ -1154,6 +1154,9 @@ struct ext4_inode_info {
5  #define EXT4_MOUNT_DISCARD             0x40000000 /* Issue DISCARD requests */
6  #define EXT4_MOUNT_INIT_INODE_TABLE    0x80000000 /* Initialize uninitialized itables */
7  
8 +/* we know this is a Lustre mount thanks to the DIRDATA flag */
9 +#define IS_LUSTRE_MOUNT(sb)    test_opt((sb), DIRDATA)
10 +
11  /*
12   * Mount flags set either automatically (could not be set by mount option)
13   * based on per file system feature or property or in special cases such as
14 diff -wur a/fs/ext4/inode.c b/fs/ext4/inode.c
15 --- a/fs/ext4/inode.c
16 +++ b/fs/ext4/inode.c
17 @@ -4766,8 +4766,9 @@ void ext4_set_inode_flags(struct inod
18                 new_fl |= S_DIRSYNC;
19         if (ext4_should_use_dax(inode))
20                 new_fl |= S_DAX;
21 -       if (flags & EXT4_ENCRYPT_FL)
22 +       if (flags & EXT4_ENCRYPT_FL &&
23 +           unlikely(!IS_LUSTRE_MOUNT(inode->i_sb)))
24                 new_fl |= S_ENCRYPTED;
25         inode_set_flags(inode, new_fl,
26                         S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_DAX|
27                         S_ENCRYPTED);
28 @@ -5753,8 +5757,9 @@ int ext4_getattr(const struct path *p
29                 stat->attributes |= STATX_ATTR_APPEND;
30         if (flags & EXT4_COMPR_FL)
31                 stat->attributes |= STATX_ATTR_COMPRESSED;
32 -       if (flags & EXT4_ENCRYPT_FL)
33 +       if (flags & EXT4_ENCRYPT_FL &&
34 +           unlikely(!IS_LUSTRE_MOUNT(inode->i_sb)))
35                 stat->attributes |= STATX_ATTR_ENCRYPTED;
36         if (flags & EXT4_IMMUTABLE_FL)
37                 stat->attributes |= STATX_ATTR_IMMUTABLE;
38         if (flags & EXT4_NODUMP_FL)
39 diff -wur a/fs/ext4/xattr.c b/fs/ext4/xattr.c
40 --- a/fs/ext4/xattr.c
41 +++ b/fs/ext4/xattr.c
42 @@ -654,6 +654,7 @@
43         up_read(&EXT4_I(inode)->xattr_sem);
44         return error;
45  }
46 +EXPORT_SYMBOL(ext4_xattr_get);
47  
48  static int
49  ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
50 @@ -2413,13 +2415,18 @@
51                         ext4_handle_sync(handle);
52         }
53  
54 +       if (!error && name_index == EXT4_XATTR_INDEX_ENCRYPTION &&
55 +           strcmp(name, "c") == 0)
56 +               EXT4_I(inode)->i_flags |= EXT4_ENCRYPT_FL;
57 +
58  cleanup:
59         brelse(is.iloc.bh);
60         brelse(bs.bh);
61         ext4_write_unlock_xattr(inode, &no_expand);
62         return error;
63  }
64 +EXPORT_SYMBOL(ext4_xattr_set_handle);
65  
66  int ext4_xattr_set_credits(struct inode *inode, size_t value_len,
67                             bool is_create, int *credits)
68