]>
Commit | Line | Data |
---|---|---|
7d777456 GKH |
1 | From cc781d3f1f03b2fd24b7260ed319dc34bf605ed0 Mon Sep 17 00:00:00 2001 |
2 | From: Dmitry Monakhov <dmonakhov@openvz.org> | |
3 | Date: Sun, 30 May 2010 22:50:00 -0400 | |
4 | Subject: ext4: Use bitops to read/modify i_flags in struct ext4_inode_info | |
5 | ||
6 | commit 12e9b892002d9af057655d35b44db8ee9243b0dc upstream (as of v2.6.34-git13) | |
7 | ||
8 | At several places we modify EXT4_I(inode)->i_flags without holding | |
9 | i_mutex (ext4_do_update_inode, ...). These modifications are racy and | |
10 | we can lose updates to i_flags. So convert handling of i_flags to use | |
11 | bitops which are atomic. | |
12 | ||
13 | https://bugzilla.kernel.org/show_bug.cgi?id=15792 | |
14 | ||
15 | Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> | |
16 | Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> | |
17 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> | |
18 | --- | |
19 | fs/ext4/dir.c | 4 - | |
20 | fs/ext4/ext4.h | 109 +++++++++++++++++++++++++++++++++++++++++++------- | |
21 | fs/ext4/ext4_jbd2.h | 6 +- | |
22 | fs/ext4/extents.c | 10 ++-- | |
23 | fs/ext4/file.c | 2 | |
24 | fs/ext4/ialloc.c | 4 - | |
25 | fs/ext4/inode.c | 30 ++++++------- | |
26 | fs/ext4/mballoc.c | 4 - | |
27 | fs/ext4/migrate.c | 2 | |
28 | fs/ext4/move_extent.c | 4 - | |
29 | fs/ext4/namei.c | 10 ++-- | |
30 | fs/ext4/super.c | 1 | |
31 | fs/ext4/xattr.c | 4 - | |
32 | 13 files changed, 135 insertions(+), 55 deletions(-) | |
33 | ||
34 | --- a/fs/ext4/dir.c | |
35 | +++ b/fs/ext4/dir.c | |
36 | @@ -111,7 +111,7 @@ static int ext4_readdir(struct file *fil | |
37 | ||
38 | if (EXT4_HAS_COMPAT_FEATURE(inode->i_sb, | |
39 | EXT4_FEATURE_COMPAT_DIR_INDEX) && | |
40 | - ((EXT4_I(inode)->i_flags & EXT4_INDEX_FL) || | |
41 | + ((ext4_test_inode_flag(inode, EXT4_INODE_INDEX)) || | |
42 | ((inode->i_size >> sb->s_blocksize_bits) == 1))) { | |
43 | err = ext4_dx_readdir(filp, dirent, filldir); | |
44 | if (err != ERR_BAD_DX_DIR) { | |
45 | @@ -122,7 +122,7 @@ static int ext4_readdir(struct file *fil | |
46 | * We don't set the inode dirty flag since it's not | |
47 | * critical that it get flushed back to the disk. | |
48 | */ | |
49 | - EXT4_I(filp->f_path.dentry->d_inode)->i_flags &= ~EXT4_INDEX_FL; | |
50 | + ext4_clear_inode_flag(filp->f_path.dentry->d_inode, EXT4_INODE_INDEX); | |
51 | } | |
52 | stored = 0; | |
53 | offset = filp->f_pos & (sb->s_blocksize - 1); | |
54 | --- a/fs/ext4/ext4.h | |
55 | +++ b/fs/ext4/ext4.h | |
56 | @@ -315,6 +315,83 @@ static inline __u32 ext4_mask_flags(umod | |
57 | return flags & EXT4_OTHER_FLMASK; | |
58 | } | |
59 | ||
60 | +/* | |
61 | + * Inode flags used for atomic set/get | |
62 | + */ | |
63 | +enum { | |
64 | + EXT4_INODE_SECRM = 0, /* Secure deletion */ | |
65 | + EXT4_INODE_UNRM = 1, /* Undelete */ | |
66 | + EXT4_INODE_COMPR = 2, /* Compress file */ | |
67 | + EXT4_INODE_SYNC = 3, /* Synchronous updates */ | |
68 | + EXT4_INODE_IMMUTABLE = 4, /* Immutable file */ | |
69 | + EXT4_INODE_APPEND = 5, /* writes to file may only append */ | |
70 | + EXT4_INODE_NODUMP = 6, /* do not dump file */ | |
71 | + EXT4_INODE_NOATIME = 7, /* do not update atime */ | |
72 | +/* Reserved for compression usage... */ | |
73 | + EXT4_INODE_DIRTY = 8, | |
74 | + EXT4_INODE_COMPRBLK = 9, /* One or more compressed clusters */ | |
75 | + EXT4_INODE_NOCOMPR = 10, /* Don't compress */ | |
76 | + EXT4_INODE_ECOMPR = 11, /* Compression error */ | |
77 | +/* End compression flags --- maybe not all used */ | |
78 | + EXT4_INODE_INDEX = 12, /* hash-indexed directory */ | |
79 | + EXT4_INODE_IMAGIC = 13, /* AFS directory */ | |
80 | + EXT4_INODE_JOURNAL_DATA = 14, /* file data should be journaled */ | |
81 | + EXT4_INODE_NOTAIL = 15, /* file tail should not be merged */ | |
82 | + EXT4_INODE_DIRSYNC = 16, /* dirsync behaviour (directories only) */ | |
83 | + EXT4_INODE_TOPDIR = 17, /* Top of directory hierarchies*/ | |
84 | + EXT4_INODE_HUGE_FILE = 18, /* Set to each huge file */ | |
85 | + EXT4_INODE_EXTENTS = 19, /* Inode uses extents */ | |
86 | + EXT4_INODE_EA_INODE = 21, /* Inode used for large EA */ | |
87 | + EXT4_INODE_EOFBLOCKS = 22, /* Blocks allocated beyond EOF */ | |
88 | + EXT4_INODE_RESERVED = 31, /* reserved for ext4 lib */ | |
89 | +}; | |
90 | + | |
91 | +#define TEST_FLAG_VALUE(FLAG) (EXT4_##FLAG##_FL == (1 << EXT4_INODE_##FLAG)) | |
92 | +#define CHECK_FLAG_VALUE(FLAG) if (!TEST_FLAG_VALUE(FLAG)) { \ | |
93 | + printk(KERN_EMERG "EXT4 flag fail: " #FLAG ": %d %d\n", \ | |
94 | + EXT4_##FLAG##_FL, EXT4_INODE_##FLAG); BUG_ON(1); } | |
95 | + | |
96 | +/* | |
97 | + * Since it's pretty easy to mix up bit numbers and hex values, and we | |
98 | + * can't do a compile-time test for ENUM values, we use a run-time | |
99 | + * test to make sure that EXT4_XXX_FL is consistent with respect to | |
100 | + * EXT4_INODE_XXX. If all is well the printk and BUG_ON will all drop | |
101 | + * out so it won't cost any extra space in the compiled kernel image. | |
102 | + * But it's important that these values are the same, since we are | |
103 | + * using EXT4_INODE_XXX to test for the flag values, but EXT4_XX_FL | |
104 | + * must be consistent with the values of FS_XXX_FL defined in | |
105 | + * include/linux/fs.h and the on-disk values found in ext2, ext3, and | |
106 | + * ext4 filesystems, and of course the values defined in e2fsprogs. | |
107 | + * | |
108 | + * It's not paranoia if the Murphy's Law really *is* out to get you. :-) | |
109 | + */ | |
110 | +static inline void ext4_check_flag_values(void) | |
111 | +{ | |
112 | + CHECK_FLAG_VALUE(SECRM); | |
113 | + CHECK_FLAG_VALUE(UNRM); | |
114 | + CHECK_FLAG_VALUE(COMPR); | |
115 | + CHECK_FLAG_VALUE(SYNC); | |
116 | + CHECK_FLAG_VALUE(IMMUTABLE); | |
117 | + CHECK_FLAG_VALUE(APPEND); | |
118 | + CHECK_FLAG_VALUE(NODUMP); | |
119 | + CHECK_FLAG_VALUE(NOATIME); | |
120 | + CHECK_FLAG_VALUE(DIRTY); | |
121 | + CHECK_FLAG_VALUE(COMPRBLK); | |
122 | + CHECK_FLAG_VALUE(NOCOMPR); | |
123 | + CHECK_FLAG_VALUE(ECOMPR); | |
124 | + CHECK_FLAG_VALUE(INDEX); | |
125 | + CHECK_FLAG_VALUE(IMAGIC); | |
126 | + CHECK_FLAG_VALUE(JOURNAL_DATA); | |
127 | + CHECK_FLAG_VALUE(NOTAIL); | |
128 | + CHECK_FLAG_VALUE(DIRSYNC); | |
129 | + CHECK_FLAG_VALUE(TOPDIR); | |
130 | + CHECK_FLAG_VALUE(HUGE_FILE); | |
131 | + CHECK_FLAG_VALUE(EXTENTS); | |
132 | + CHECK_FLAG_VALUE(EA_INODE); | |
133 | + CHECK_FLAG_VALUE(EOFBLOCKS); | |
134 | + CHECK_FLAG_VALUE(RESERVED); | |
135 | +} | |
136 | + | |
137 | /* Used to pass group descriptor data when online resize is done */ | |
138 | struct ext4_new_group_input { | |
139 | __u32 group; /* Group number for this data */ | |
140 | @@ -603,9 +680,8 @@ struct ext4_ext_cache { | |
141 | */ | |
142 | struct ext4_inode_info { | |
143 | __le32 i_data[15]; /* unconverted */ | |
144 | - __u32 i_flags; | |
145 | - ext4_fsblk_t i_file_acl; | |
146 | __u32 i_dtime; | |
147 | + ext4_fsblk_t i_file_acl; | |
148 | ||
149 | /* | |
150 | * i_block_group is the number of the block group which contains | |
151 | @@ -616,6 +692,7 @@ struct ext4_inode_info { | |
152 | */ | |
153 | ext4_group_t i_block_group; | |
154 | unsigned long i_state_flags; /* Dynamic state flags */ | |
155 | + unsigned long i_flags; | |
156 | ||
157 | ext4_lblk_t i_dir_start_lookup; | |
158 | #ifdef CONFIG_EXT4_FS_XATTR | |
159 | @@ -1049,20 +1126,22 @@ enum { | |
160 | EXT4_STATE_DIO_UNWRITTEN, /* need convert on dio done*/ | |
161 | }; | |
162 | ||
163 | -static inline int ext4_test_inode_state(struct inode *inode, int bit) | |
164 | -{ | |
165 | - return test_bit(bit, &EXT4_I(inode)->i_state_flags); | |
166 | -} | |
167 | - | |
168 | -static inline void ext4_set_inode_state(struct inode *inode, int bit) | |
169 | -{ | |
170 | - set_bit(bit, &EXT4_I(inode)->i_state_flags); | |
171 | +#define EXT4_INODE_BIT_FNS(name, field) \ | |
172 | +static inline int ext4_test_inode_##name(struct inode *inode, int bit) \ | |
173 | +{ \ | |
174 | + return test_bit(bit, &EXT4_I(inode)->i_##field); \ | |
175 | +} \ | |
176 | +static inline void ext4_set_inode_##name(struct inode *inode, int bit) \ | |
177 | +{ \ | |
178 | + set_bit(bit, &EXT4_I(inode)->i_##field); \ | |
179 | +} \ | |
180 | +static inline void ext4_clear_inode_##name(struct inode *inode, int bit) \ | |
181 | +{ \ | |
182 | + clear_bit(bit, &EXT4_I(inode)->i_##field); \ | |
183 | } | |
184 | ||
185 | -static inline void ext4_clear_inode_state(struct inode *inode, int bit) | |
186 | -{ | |
187 | - clear_bit(bit, &EXT4_I(inode)->i_state_flags); | |
188 | -} | |
189 | +EXT4_INODE_BIT_FNS(flag, flags) | |
190 | +EXT4_INODE_BIT_FNS(state, state_flags) | |
191 | #else | |
192 | /* Assume that user mode programs are passing in an ext4fs superblock, not | |
193 | * a kernel struct super_block. This will allow us to call the feature-test | |
194 | @@ -1247,7 +1326,7 @@ struct ext4_dir_entry_2 { | |
195 | ||
196 | #define is_dx(dir) (EXT4_HAS_COMPAT_FEATURE(dir->i_sb, \ | |
197 | EXT4_FEATURE_COMPAT_DIR_INDEX) && \ | |
198 | - (EXT4_I(dir)->i_flags & EXT4_INDEX_FL)) | |
199 | + ext4_test_inode_flag((dir), EXT4_INODE_INDEX)) | |
200 | #define EXT4_DIR_LINK_MAX(dir) (!is_dx(dir) && (dir)->i_nlink >= EXT4_LINK_MAX) | |
201 | #define EXT4_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1) | |
202 | ||
203 | --- a/fs/ext4/ext4_jbd2.h | |
204 | +++ b/fs/ext4/ext4_jbd2.h | |
205 | @@ -282,7 +282,7 @@ static inline int ext4_should_journal_da | |
206 | return 1; | |
207 | if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) | |
208 | return 1; | |
209 | - if (EXT4_I(inode)->i_flags & EXT4_JOURNAL_DATA_FL) | |
210 | + if (ext4_test_inode_flag(inode, EXT4_INODE_JOURNAL_DATA)) | |
211 | return 1; | |
212 | return 0; | |
213 | } | |
214 | @@ -293,7 +293,7 @@ static inline int ext4_should_order_data | |
215 | return 0; | |
216 | if (!S_ISREG(inode->i_mode)) | |
217 | return 0; | |
218 | - if (EXT4_I(inode)->i_flags & EXT4_JOURNAL_DATA_FL) | |
219 | + if (ext4_test_inode_flag(inode, EXT4_INODE_JOURNAL_DATA)) | |
220 | return 0; | |
221 | if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA) | |
222 | return 1; | |
223 | @@ -306,7 +306,7 @@ static inline int ext4_should_writeback_ | |
224 | return 0; | |
225 | if (EXT4_JOURNAL(inode) == NULL) | |
226 | return 1; | |
227 | - if (EXT4_I(inode)->i_flags & EXT4_JOURNAL_DATA_FL) | |
228 | + if (ext4_test_inode_flag(inode, EXT4_INODE_JOURNAL_DATA)) | |
229 | return 0; | |
230 | if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA) | |
231 | return 1; | |
232 | --- a/fs/ext4/extents.c | |
233 | +++ b/fs/ext4/extents.c | |
234 | @@ -3409,12 +3409,12 @@ int ext4_ext_get_blocks(handle_t *handle | |
235 | } | |
236 | } | |
237 | ||
238 | - if (unlikely(EXT4_I(inode)->i_flags & EXT4_EOFBLOCKS_FL)) { | |
239 | + if (unlikely(ext4_test_inode_flag(inode, EXT4_INODE_EOFBLOCKS))) { | |
240 | if (eh->eh_entries) { | |
241 | last_ex = EXT_LAST_EXTENT(eh); | |
242 | if (iblock + ar.len > le32_to_cpu(last_ex->ee_block) | |
243 | + ext4_ext_get_actual_len(last_ex)) | |
244 | - EXT4_I(inode)->i_flags &= ~EXT4_EOFBLOCKS_FL; | |
245 | + ext4_clear_inode_flag(inode, EXT4_INODE_EOFBLOCKS); | |
246 | } else { | |
247 | WARN_ON(eh->eh_entries == 0); | |
248 | ext4_error(inode->i_sb, __func__, | |
249 | @@ -3560,7 +3560,7 @@ static void ext4_falloc_update_inode(str | |
250 | * can proceed even if the new size is the same as i_size. | |
251 | */ | |
252 | if (new_size > i_size_read(inode)) | |
253 | - EXT4_I(inode)->i_flags |= EXT4_EOFBLOCKS_FL; | |
254 | + ext4_set_inode_flag(inode, EXT4_INODE_EOFBLOCKS); | |
255 | } | |
256 | ||
257 | } | |
258 | @@ -3588,7 +3588,7 @@ long ext4_fallocate(struct inode *inode, | |
259 | * currently supporting (pre)allocate mode for extent-based | |
260 | * files _only_ | |
261 | */ | |
262 | - if (!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)) | |
263 | + if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) | |
264 | return -EOPNOTSUPP; | |
265 | ||
266 | /* preallocation to directories is currently not supported */ | |
267 | @@ -3838,7 +3838,7 @@ int ext4_fiemap(struct inode *inode, str | |
268 | int error = 0; | |
269 | ||
270 | /* fallback to generic here if not in extents fmt */ | |
271 | - if (!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)) | |
272 | + if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) | |
273 | return generic_block_fiemap(inode, fieinfo, start, len, | |
274 | ext4_get_block); | |
275 | ||
276 | --- a/fs/ext4/file.c | |
277 | +++ b/fs/ext4/file.c | |
278 | @@ -65,7 +65,7 @@ ext4_file_write(struct kiocb *iocb, cons | |
279 | * is smaller than s_maxbytes, which is for extent-mapped files. | |
280 | */ | |
281 | ||
282 | - if (!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)) { | |
283 | + if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) { | |
284 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); | |
285 | size_t length = iov_length(iov, nr_segs); | |
286 | ||
287 | --- a/fs/ext4/ialloc.c | |
288 | +++ b/fs/ext4/ialloc.c | |
289 | @@ -497,7 +497,7 @@ static int find_group_orlov(struct super | |
290 | ||
291 | if (S_ISDIR(mode) && | |
292 | ((parent == sb->s_root->d_inode) || | |
293 | - (EXT4_I(parent)->i_flags & EXT4_TOPDIR_FL))) { | |
294 | + (ext4_test_inode_flag(parent, EXT4_INODE_TOPDIR)))) { | |
295 | int best_ndir = inodes_per_group; | |
296 | int ret = -1; | |
297 | ||
298 | @@ -1044,7 +1044,7 @@ got: | |
299 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) { | |
300 | /* set extent flag only for directory, file and normal symlink*/ | |
301 | if (S_ISDIR(mode) || S_ISREG(mode) || S_ISLNK(mode)) { | |
302 | - EXT4_I(inode)->i_flags |= EXT4_EXTENTS_FL; | |
303 | + ext4_set_inode_flag(inode, EXT4_INODE_EXTENTS); | |
304 | ext4_ext_tree_init(handle, inode); | |
305 | } | |
306 | } | |
307 | --- a/fs/ext4/inode.c | |
308 | +++ b/fs/ext4/inode.c | |
309 | @@ -957,7 +957,7 @@ static int ext4_ind_get_blocks(handle_t | |
310 | int count = 0; | |
311 | ext4_fsblk_t first_block = 0; | |
312 | ||
313 | - J_ASSERT(!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)); | |
314 | + J_ASSERT(!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))); | |
315 | J_ASSERT(handle != NULL || (flags & EXT4_GET_BLOCKS_CREATE) == 0); | |
316 | depth = ext4_block_to_path(inode, iblock, offsets, | |
317 | &blocks_to_boundary); | |
318 | @@ -1085,7 +1085,7 @@ static int ext4_indirect_calc_metadata_a | |
319 | */ | |
320 | static int ext4_calc_metadata_amount(struct inode *inode, sector_t lblock) | |
321 | { | |
322 | - if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL) | |
323 | + if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) | |
324 | return ext4_ext_calc_metadata_amount(inode, lblock); | |
325 | ||
326 | return ext4_indirect_calc_metadata_amount(inode, lblock); | |
327 | @@ -1274,7 +1274,7 @@ int ext4_get_blocks(handle_t *handle, st | |
328 | * file system block. | |
329 | */ | |
330 | down_read((&EXT4_I(inode)->i_data_sem)); | |
331 | - if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL) { | |
332 | + if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) { | |
333 | retval = ext4_ext_get_blocks(handle, inode, block, max_blocks, | |
334 | bh, 0); | |
335 | } else { | |
336 | @@ -1336,7 +1336,7 @@ int ext4_get_blocks(handle_t *handle, st | |
337 | * We need to check for EXT4 here because migrate | |
338 | * could have changed the inode type in between | |
339 | */ | |
340 | - if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL) { | |
341 | + if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) { | |
342 | retval = ext4_ext_get_blocks(handle, inode, block, max_blocks, | |
343 | bh, flags); | |
344 | } else { | |
345 | @@ -2371,7 +2371,7 @@ static void mpage_add_bh_to_extent(struc | |
346 | goto flush_it; | |
347 | ||
348 | /* check if thereserved journal credits might overflow */ | |
349 | - if (!(EXT4_I(mpd->inode)->i_flags & EXT4_EXTENTS_FL)) { | |
350 | + if (!(ext4_test_inode_flag(mpd->inode, EXT4_INODE_EXTENTS))) { | |
351 | if (nrblocks >= EXT4_MAX_TRANS_DATA) { | |
352 | /* | |
353 | * With non-extent format we are limited by the journal | |
354 | @@ -2836,7 +2836,7 @@ static int ext4_da_writepages_trans_bloc | |
355 | * number of contiguous block. So we will limit | |
356 | * number of contiguous block to a sane value | |
357 | */ | |
358 | - if (!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL) && | |
359 | + if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) && | |
360 | (max_blocks > EXT4_MAX_TRANS_DATA)) | |
361 | max_blocks = EXT4_MAX_TRANS_DATA; | |
362 | ||
363 | @@ -3872,7 +3872,7 @@ static ssize_t ext4_direct_IO(int rw, st | |
364 | struct file *file = iocb->ki_filp; | |
365 | struct inode *inode = file->f_mapping->host; | |
366 | ||
367 | - if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL) | |
368 | + if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) | |
369 | return ext4_ext_direct_IO(rw, iocb, iov, offset, nr_segs); | |
370 | ||
371 | return ext4_ind_direct_IO(rw, iocb, iov, offset, nr_segs); | |
372 | @@ -4503,12 +4503,12 @@ void ext4_truncate(struct inode *inode) | |
373 | if (!ext4_can_truncate(inode)) | |
374 | return; | |
375 | ||
376 | - EXT4_I(inode)->i_flags &= ~EXT4_EOFBLOCKS_FL; | |
377 | + ext4_clear_inode_flag(inode, EXT4_INODE_EOFBLOCKS); | |
378 | ||
379 | if (inode->i_size == 0 && !test_opt(inode->i_sb, NO_AUTO_DA_ALLOC)) | |
380 | ext4_set_inode_state(inode, EXT4_STATE_DA_ALLOC_CLOSE); | |
381 | ||
382 | - if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL) { | |
383 | + if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) { | |
384 | ext4_ext_truncate(inode); | |
385 | return; | |
386 | } | |
387 | @@ -5350,7 +5350,7 @@ int ext4_setattr(struct dentry *dentry, | |
388 | } | |
389 | ||
390 | if (attr->ia_valid & ATTR_SIZE) { | |
391 | - if (!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)) { | |
392 | + if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) { | |
393 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); | |
394 | ||
395 | if (attr->ia_size > sbi->s_bitmap_maxbytes) { | |
396 | @@ -5363,7 +5363,7 @@ int ext4_setattr(struct dentry *dentry, | |
397 | if (S_ISREG(inode->i_mode) && | |
398 | attr->ia_valid & ATTR_SIZE && | |
399 | (attr->ia_size < inode->i_size || | |
400 | - (EXT4_I(inode)->i_flags & EXT4_EOFBLOCKS_FL))) { | |
401 | + (ext4_test_inode_flag(inode, EXT4_INODE_EOFBLOCKS)))) { | |
402 | handle_t *handle; | |
403 | ||
404 | handle = ext4_journal_start(inode, 3); | |
405 | @@ -5395,7 +5395,7 @@ int ext4_setattr(struct dentry *dentry, | |
406 | } | |
407 | } | |
408 | /* ext4_truncate will clear the flag */ | |
409 | - if ((EXT4_I(inode)->i_flags & EXT4_EOFBLOCKS_FL)) | |
410 | + if ((ext4_test_inode_flag(inode, EXT4_INODE_EOFBLOCKS))) | |
411 | ext4_truncate(inode); | |
412 | } | |
413 | ||
414 | @@ -5471,7 +5471,7 @@ static int ext4_indirect_trans_blocks(st | |
415 | ||
416 | static int ext4_index_trans_blocks(struct inode *inode, int nrblocks, int chunk) | |
417 | { | |
418 | - if (!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)) | |
419 | + if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) | |
420 | return ext4_indirect_trans_blocks(inode, nrblocks, chunk); | |
421 | return ext4_ext_index_trans_blocks(inode, nrblocks, chunk); | |
422 | } | |
423 | @@ -5806,9 +5806,9 @@ int ext4_change_inode_journal_flag(struc | |
424 | */ | |
425 | ||
426 | if (val) | |
427 | - EXT4_I(inode)->i_flags |= EXT4_JOURNAL_DATA_FL; | |
428 | + ext4_set_inode_flag(inode, EXT4_INODE_JOURNAL_DATA); | |
429 | else | |
430 | - EXT4_I(inode)->i_flags &= ~EXT4_JOURNAL_DATA_FL; | |
431 | + ext4_clear_inode_flag(inode, EXT4_INODE_JOURNAL_DATA); | |
432 | ext4_set_aops(inode); | |
433 | ||
434 | jbd2_journal_unlock_updates(journal); | |
435 | --- a/fs/ext4/mballoc.c | |
436 | +++ b/fs/ext4/mballoc.c | |
437 | @@ -2008,7 +2008,7 @@ ext4_mb_regular_allocator(struct ext4_al | |
438 | sbi = EXT4_SB(sb); | |
439 | ngroups = ext4_get_groups_count(sb); | |
440 | /* non-extent files are limited to low blocks/groups */ | |
441 | - if (!(EXT4_I(ac->ac_inode)->i_flags & EXT4_EXTENTS_FL)) | |
442 | + if (!(ext4_test_inode_flag(ac->ac_inode, EXT4_INODE_EXTENTS))) | |
443 | ngroups = sbi->s_blockfile_groups; | |
444 | ||
445 | BUG_ON(ac->ac_status == AC_STATUS_FOUND); | |
446 | @@ -3176,7 +3176,7 @@ ext4_mb_use_preallocated(struct ext4_all | |
447 | continue; | |
448 | ||
449 | /* non-extent files can't have physical blocks past 2^32 */ | |
450 | - if (!(EXT4_I(ac->ac_inode)->i_flags & EXT4_EXTENTS_FL) && | |
451 | + if (!(ext4_test_inode_flag(ac->ac_inode, EXT4_INODE_EXTENTS)) && | |
452 | pa->pa_pstart + pa->pa_len > EXT4_MAX_BLOCK_FILE_PHYS) | |
453 | continue; | |
454 | ||
455 | --- a/fs/ext4/migrate.c | |
456 | +++ b/fs/ext4/migrate.c | |
457 | @@ -465,7 +465,7 @@ int ext4_ext_migrate(struct inode *inode | |
458 | */ | |
459 | if (!EXT4_HAS_INCOMPAT_FEATURE(inode->i_sb, | |
460 | EXT4_FEATURE_INCOMPAT_EXTENTS) || | |
461 | - (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)) | |
462 | + (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) | |
463 | return -EINVAL; | |
464 | ||
465 | if (S_ISLNK(inode->i_mode) && inode->i_blocks == 0) | |
466 | --- a/fs/ext4/move_extent.c | |
467 | +++ b/fs/ext4/move_extent.c | |
468 | @@ -975,11 +975,11 @@ mext_check_arguments(struct inode *orig_ | |
469 | } | |
470 | ||
471 | /* Ext4 move extent supports only extent based file */ | |
472 | - if (!(EXT4_I(orig_inode)->i_flags & EXT4_EXTENTS_FL)) { | |
473 | + if (!(ext4_test_inode_flag(orig_inode, EXT4_INODE_EXTENTS))) { | |
474 | ext4_debug("ext4 move extent: orig file is not extents " | |
475 | "based file [ino:orig %lu]\n", orig_inode->i_ino); | |
476 | return -EOPNOTSUPP; | |
477 | - } else if (!(EXT4_I(donor_inode)->i_flags & EXT4_EXTENTS_FL)) { | |
478 | + } else if (!(ext4_test_inode_flag(donor_inode, EXT4_INODE_EXTENTS))) { | |
479 | ext4_debug("ext4 move extent: donor file is not extents " | |
480 | "based file [ino:donor %lu]\n", donor_inode->i_ino); | |
481 | return -EOPNOTSUPP; | |
482 | --- a/fs/ext4/namei.c | |
483 | +++ b/fs/ext4/namei.c | |
484 | @@ -660,7 +660,7 @@ int ext4_htree_fill_tree(struct file *di | |
485 | dxtrace(printk(KERN_DEBUG "In htree_fill_tree, start hash: %x:%x\n", | |
486 | start_hash, start_minor_hash)); | |
487 | dir = dir_file->f_path.dentry->d_inode; | |
488 | - if (!(EXT4_I(dir)->i_flags & EXT4_INDEX_FL)) { | |
489 | + if (!(ext4_test_inode_flag(dir, EXT4_INODE_INDEX))) { | |
490 | hinfo.hash_version = EXT4_SB(dir->i_sb)->s_def_hash_version; | |
491 | if (hinfo.hash_version <= DX_HASH_TEA) | |
492 | hinfo.hash_version += | |
493 | @@ -805,7 +805,7 @@ static void ext4_update_dx_flag(struct i | |
494 | { | |
495 | if (!EXT4_HAS_COMPAT_FEATURE(inode->i_sb, | |
496 | EXT4_FEATURE_COMPAT_DIR_INDEX)) | |
497 | - EXT4_I(inode)->i_flags &= ~EXT4_INDEX_FL; | |
498 | + ext4_clear_inode_flag(inode, EXT4_INODE_INDEX); | |
499 | } | |
500 | ||
501 | /* | |
502 | @@ -1424,7 +1424,7 @@ static int make_indexed_dir(handle_t *ha | |
503 | brelse(bh); | |
504 | return retval; | |
505 | } | |
506 | - EXT4_I(dir)->i_flags |= EXT4_INDEX_FL; | |
507 | + ext4_set_inode_flag(dir, EXT4_INODE_INDEX); | |
508 | data1 = bh2->b_data; | |
509 | ||
510 | memcpy (data1, de, len); | |
511 | @@ -1497,7 +1497,7 @@ static int ext4_add_entry(handle_t *hand | |
512 | retval = ext4_dx_add_entry(handle, dentry, inode); | |
513 | if (!retval || (retval != ERR_BAD_DX_DIR)) | |
514 | return retval; | |
515 | - EXT4_I(dir)->i_flags &= ~EXT4_INDEX_FL; | |
516 | + ext4_clear_inode_flag(dir, EXT4_INODE_INDEX); | |
517 | dx_fallback++; | |
518 | ext4_mark_inode_dirty(handle, dir); | |
519 | } | |
520 | @@ -2292,7 +2292,7 @@ retry: | |
521 | } | |
522 | } else { | |
523 | /* clear the extent format for fast symlink */ | |
524 | - EXT4_I(inode)->i_flags &= ~EXT4_EXTENTS_FL; | |
525 | + ext4_clear_inode_flag(inode, EXT4_INODE_EXTENTS); | |
526 | inode->i_op = &ext4_fast_symlink_inode_operations; | |
527 | memcpy((char *)&EXT4_I(inode)->i_data, symname, l); | |
528 | inode->i_size = l-1; | |
529 | --- a/fs/ext4/super.c | |
530 | +++ b/fs/ext4/super.c | |
531 | @@ -3999,6 +3999,7 @@ static int __init init_ext4_fs(void) | |
532 | { | |
533 | int err; | |
534 | ||
535 | + ext4_check_flag_values(); | |
536 | err = init_ext4_system_zone(); | |
537 | if (err) | |
538 | return err; | |
539 | --- a/fs/ext4/xattr.c | |
540 | +++ b/fs/ext4/xattr.c | |
541 | @@ -816,7 +816,7 @@ inserted: | |
542 | EXT4_I(inode)->i_block_group); | |
543 | ||
544 | /* non-extent files can't have physical blocks past 2^32 */ | |
545 | - if (!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)) | |
546 | + if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) | |
547 | goal = goal & EXT4_MAX_BLOCK_FILE_PHYS; | |
548 | ||
549 | block = ext4_new_meta_blocks(handle, inode, | |
550 | @@ -824,7 +824,7 @@ inserted: | |
551 | if (error) | |
552 | goto cleanup; | |
553 | ||
554 | - if (!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)) | |
555 | + if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) | |
556 | BUG_ON(block > EXT4_MAX_BLOCK_FILE_PHYS); | |
557 | ||
558 | ea_idebug(inode, "creating block %d", block); |