1 diff -wur a/fs/ext4/ext4.h 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 */
8 +/* we know this is a Lustre mount thanks to the DIRDATA flag */
9 +#define IS_LUSTRE_MOUNT(sb) test_opt((sb), DIRDATA)
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
17 @@ -4766,8 +4766,9 @@ void ext4_set_inode_flags(struct inod
19 if (ext4_should_use_dax(inode))
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|
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
43 up_read(&EXT4_I(inode)->xattr_sem);
46 +EXPORT_SYMBOL(ext4_xattr_get);
49 ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
50 @@ -2413,13 +2415,18 @@
51 ext4_handle_sync(handle);
54 + if (!error && name_index == EXT4_XATTR_INDEX_ENCRYPTION &&
55 + strcmp(name, "c") == 0)
56 + EXT4_I(inode)->i_flags |= EXT4_ENCRYPT_FL;
61 ext4_write_unlock_xattr(inode, &no_expand);
64 +EXPORT_SYMBOL(ext4_xattr_set_handle);
66 int ext4_xattr_set_credits(struct inode *inode, size_t value_len,
67 bool is_create, int *credits)