Whamcloud - gitweb
LU-17504 build: fix gcc-13 [-Werror=stringop-overread] error
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / linux-5.8 / 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         if (init && ext4_should_enable_dax(inode))
19                 new_fl |= S_DAX;
20  
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         if (flags & EXT4_CASEFOLD_FL)
26                 new_fl |= S_CASEFOLD;
27         if (flags & EXT4_VERITY_FL)
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 @@ -2425,12 +2425,19 @@
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 +               mark_inode_dirty(inode);
58 +       }
59 +
60  cleanup:
61         brelse(is.iloc.bh);
62         brelse(bs.bh);
63         ext4_write_unlock_xattr(inode, &no_expand);
64         return error;
65  }
66 +EXPORT_SYMBOL(ext4_xattr_set_handle);
67  
68  int ext4_xattr_set_credits(struct inode *inode, size_t value_len,
69                            bool is_create, int *credits)