Skip to content

Commit ec22ba8

Browse files
Dmitry Monakhovtytso
authored andcommitted
ext4: disable merging of uninitialized extents
Derived from Jan's patch:http://permalink.gmane.org/gmane.comp.file-systems.ext4/36470 Merging of uninitialized extents creates all sorts of interesting race possibilities when writeback / DIO races with fallocate. Thus ext4_convert_unwritten_extents_endio() has to deal with a case where extent to be converted needs to be split out first. That isn't nice for two reasons: 1) It may need allocation of extent tree block so ENOSPC is possible. 2) It complicates end_io handling code So we disable merging of uninitialized extents which allows us to simplify the code. Extents will get merged after they are converted to initialized ones. Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Reviewed-by: Jan Kara <jack@suse.cz>
1 parent 357b66f commit ec22ba8

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎fs/ext4/extents.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,10 +1584,12 @@ ext4_can_extents_be_merged(struct inode *inode, struct ext4_extent *ex1,
15841584
unsigned short ext1_ee_len, ext2_ee_len, max_len;
15851585

15861586
/*
1587-
* Make sure that either both extents are uninitialized, or
1588-
* both are _not_.
1587+
* Make sure that both extents are initialized. We don't merge
1588+
* uninitialized extents so that we can be sure that end_io code has
1589+
* the extent that was written properly split out and conversion to
1590+
* initialized is trivial.
15891591
*/
1590-
if (ext4_ext_is_uninitialized(ex1) ^ ext4_ext_is_uninitialized(ex2))
1592+
if (ext4_ext_is_uninitialized(ex1) || ext4_ext_is_uninitialized(ex2))
15911593
return 0;
15921594

15931595
if (ext4_ext_is_uninitialized(ex1))

0 commit comments

Comments
 (0)