Whamcloud - gitweb
LU-14651 ldiskfs: add 5.11 kernel support
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ubuntu20.04.3 / ext4-misc.patch
1 diff -ur a/fs/ext4/ext4.h b/fs/ext4/ext4.h
2 --- a/fs/ext4/ext4.h    2022-03-24 16:23:11.725060881 -0600
3 +++ b/fs/ext4/ext4.h    2022-03-24 16:24:35.400642866 -0600
4 @@ -1882,6 +1882,8 @@
5  
6  #define NEXT_ORPHAN(inode) EXT4_I(inode)->i_dtime
7  
8 +#define JOURNAL_START_HAS_3ARGS        1
9 +
10  /*
11   * Codes for operating systems
12   */
13 @@ -2121,7 +2123,21 @@
14  
15  EXTN_FEATURE_FUNCS(2)
16  EXTN_FEATURE_FUNCS(3)
17 -EXTN_FEATURE_FUNCS(4)
18 +static inline bool ext4_has_unknown_ext4_compat_features(struct super_block *sb)
19 +{
20 +       return ((EXT4_SB(sb)->s_es->s_feature_compat &
21 +               cpu_to_le32(~EXT4_FEATURE_COMPAT_SUPP)) != 0);
22 +}
23 +static inline bool ext4_has_unknown_ext4_ro_compat_features(struct super_block *sb)
24 +{
25 +       return ((EXT4_SB(sb)->s_es->s_feature_ro_compat &
26 +               cpu_to_le32(~EXT4_FEATURE_RO_COMPAT_SUPP)) != 0);
27 +}
28 +static inline bool ext4_has_unknown_ext4_incompat_features(struct super_block *sb)
29 +{
30 +       return ((EXT4_SB(sb)->s_es->s_feature_incompat &
31 +               cpu_to_le32(~EXT4_FEATURE_INCOMPAT_SUPP)) != 0);
32 +}
33  
34  static inline bool ext4_has_compat_features(struct super_block *sb)
35  {
36 @@ -3594,6 +3610,13 @@
37  #define EXT_MAX_BLOCKS 0xffffffff
38  
39  extern void ext4_ext_tree_init(handle_t *handle, struct inode *inode);
40 +extern struct buffer_head *ext4_read_inode_bitmap(struct super_block *sb,
41 +                                                 ext4_group_t block_group);
42 +extern void ext4_inc_count(struct inode *inode);
43 +extern void ext4_dec_count(struct inode *inode);
44 +extern struct buffer_head *ext4_append(handle_t *handle,
45 +                                      struct inode *inode,
46 +                                      ext4_lblk_t *block);
47  extern int ext4_ext_index_trans_blocks(struct inode *inode, int extents);
48  extern int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
49                                struct ext4_map_blocks *map, int flags);
50 diff -ur a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
51 --- a/fs/ext4/ialloc.c  2022-03-24 16:23:11.713060939 -0600
52 +++ b/fs/ext4/ialloc.c  2022-03-24 16:24:35.404642846 -0600
53 @@ -120,7 +120,7 @@
54   *
55   * Return buffer_head of bitmap on success, or an ERR_PTR on error.
56   */
57 -static struct buffer_head *
58 +struct buffer_head *
59  ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
60  {
61         struct ext4_group_desc *desc;
62 @@ -215,6 +215,7 @@
63         put_bh(bh);
64         return ERR_PTR(err);
65  }
66 +EXPORT_SYMBOL(ext4_read_inode_bitmap);
67  
68  /*
69   * NOTE! When we get the inode, we're the only people
70 diff -ur a/fs/ext4/inode.c b/fs/ext4/inode.c
71 --- a/fs/ext4/inode.c   2022-03-24 16:23:11.721060900 -0600
72 +++ b/fs/ext4/inode.c   2022-03-24 16:24:35.412642805 -0600
73 @@ -6222,3 +6222,19 @@
74  
75         return ret;
76  }
77 +EXPORT_SYMBOL(ext4_map_blocks);
78 +EXPORT_SYMBOL(ext4_truncate);
79 +EXPORT_SYMBOL(ext4_iget);
80 +EXPORT_SYMBOL(ext4_bread);
81 +EXPORT_SYMBOL(ext4_itable_unused_count);
82 +EXPORT_SYMBOL(ext4_force_commit);
83 +EXPORT_SYMBOL(__ext4_mark_inode_dirty);
84 +EXPORT_SYMBOL(ext4_get_group_desc);
85 +EXPORT_SYMBOL(__ext4_journal_get_write_access);
86 +EXPORT_SYMBOL(__ext4_journal_start_sb);
87 +EXPORT_SYMBOL(__ext4_journal_stop);
88 +EXPORT_SYMBOL(__ext4_handle_dirty_metadata);
89 +EXPORT_SYMBOL(__ext4_std_error);
90 +EXPORT_SYMBOL(ext4fs_dirhash);
91 +EXPORT_SYMBOL(ext4_get_inode_loc);
92 +EXPORT_SYMBOL(__ext4_journal_ensure_credits);
93 diff -ur a/fs/ext4/namei.c b/fs/ext4/namei.c
94 --- a/fs/ext4/namei.c   2022-03-24 16:23:11.725060881 -0600
95 +++ b/fs/ext4/namei.c   2022-03-24 16:24:35.420642764 -0600
96 @@ -50,7 +50,7 @@
97  #define NAMEI_RA_BLOCKS  4
98  #define NAMEI_RA_SIZE       (NAMEI_RA_CHUNKS * NAMEI_RA_BLOCKS)
99  
100 -static struct buffer_head *ext4_append(handle_t *handle,
101 +struct buffer_head *ext4_append(handle_t *handle,
102                                         struct inode *inode,
103                                         ext4_lblk_t *block)
104  {
105 @@ -79,6 +79,8 @@
106         return bh;
107  }
108  
109 +#define assert(test) J_ASSERT(test)
110 +
111  static int ext4_dx_csum_verify(struct inode *inode,
112                                struct ext4_dir_entry *dirent);
113  
114 @@ -181,6 +183,7 @@
115         }
116         return bh;
117  }
118 +EXPORT_SYMBOL(ext4_append);
119  
120  #ifdef DX_DEBUG
121  #define dxtrace(command) command
122 @@ -2568,23 +2571,25 @@
123   * for checking S_ISDIR(inode) (since the INODE_INDEX feature will not be set
124   * on regular files) and to avoid creating huge/slow non-HTREE directories.
125   */
126 -static void ext4_inc_count(struct inode *inode)
127 +void ext4_inc_count(struct inode *inode)
128  {
129         inc_nlink(inode);
130         if (is_dx(inode) &&
131             (inode->i_nlink > EXT4_LINK_MAX || inode->i_nlink == 2))
132                 set_nlink(inode, 1);
133  }
134 +EXPORT_SYMBOL(ext4_inc_count);
135  
136  /*
137   * If a directory had nlink == 1, then we should let it be 1. This indicates
138   * directory has >EXT4_LINK_MAX subdirs.
139   */
140 -static void ext4_dec_count(struct inode *inode)
141 +void ext4_dec_count(struct inode *inode)
142  {
143         if (!S_ISDIR(inode->i_mode) || inode->i_nlink > 2)
144                 drop_nlink(inode);
145  }
146 +EXPORT_SYMBOL(ext4_dec_count);
147  
148  
149  /*
150 diff -ur a/fs/ext4/super.c b/fs/ext4/super.c
151 --- a/fs/ext4/super.c   2022-03-24 16:23:11.601061482 -0600
152 +++ b/fs/ext4/super.c   2022-03-24 16:24:35.424642743 -0600
153 @@ -5557,7 +5557,7 @@
154                         __ext4_update_tstamp(&es->s_first_error_time,
155                                              &es->s_first_error_time_hi,
156                                              sbi->s_first_error_time);
157 -                       strncpy(es->s_first_error_func, sbi->s_first_error_func,
158 +                       strlcpy(es->s_first_error_func, sbi->s_first_error_func,
159                                 sizeof(es->s_first_error_func));
160                         es->s_first_error_line =
161                                 cpu_to_le32(sbi->s_first_error_line);
162 @@ -5571,7 +5571,7 @@
163                 __ext4_update_tstamp(&es->s_last_error_time,
164                                      &es->s_last_error_time_hi,
165                                      sbi->s_last_error_time);
166 -               strncpy(es->s_last_error_func, sbi->s_last_error_func,
167 +               strlcpy(es->s_last_error_func, sbi->s_last_error_func,
168                         sizeof(es->s_last_error_func));
169                 es->s_last_error_line = cpu_to_le32(sbi->s_last_error_line);
170                 es->s_last_error_ino = cpu_to_le32(sbi->s_last_error_ino);
171 @@ -6760,16 +6760,12 @@
172         if (err)
173                 goto out05;
174  
175 -       register_as_ext3();
176 -       register_as_ext2();
177         err = register_filesystem(&ext4_fs_type);
178         if (err)
179                 goto out;
180  
181         return 0;
182  out:
183 -       unregister_as_ext2();
184 -       unregister_as_ext3();
185  out05:
186         destroy_inodecache();
187  out1:
188 @@ -6793,8 +6789,6 @@
189  static void __exit ext4_exit_fs(void)
190  {
191         ext4_destroy_lazyinit_thread();
192 -       unregister_as_ext2();
193 -       unregister_as_ext3();
194         unregister_filesystem(&ext4_fs_type);
195         destroy_inodecache();
196         ext4_exit_mballoc();