linux/fs/ext4
Lukas Czerner 91dd8c1144 ext4: prevent race while walking extent tree for fiemap
Currently ext4_ext_walk_space() only takes i_data_sem for read when
searching for the extent at given block with ext4_ext_find_extent().
Then it drops the lock and the extent tree can be changed at will.
However later on we're searching for the 'next' extent, but the extent
tree might already have changed, so the information might not be
accurate.

In fact we can hit BUG_ON(end <= start) if the extent got inserted into
the tree after the one we found and before the block we were searching
for. This has been reproduced by running xfstests 225 in loop on s390x
architecture, but theoretically we could hit this on any other
architecture as well, but probably not as often.

Moreover the extent currently in delayed allocation might be allocated
after we search the extent tree and before we search extent status tree
delayed buffers resulting in those delayed buffers being completely
missed, even though completely written and allocated.

We fix all those problems in several steps:

 1. remove unnecessary callback indirection
 2. rename functions
        ext4_ext_walk_space -> ext4_fill_fiemap_extents
        ext4_ext_fiemap_cb -> ext4_find_delayed_extent
 3. move fiemap_fill_next_extent() into ext4_fill_fiemap_extents()
 4. hold the i_data_sem for:
        ext4_ext_find_extent()
        ext4_ext_next_allocated_block()
        ext4_find_delayed_extent()
 5. call fiemap_fill_next_extent after releasing the i_data_sem
 6. move path reinitialization into the critical section.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-11-28 12:32:26 -05:00
..
acl.c ext4: fix memory leak in ext4_xattr_set_acl()'s error path 2012-11-08 15:11:11 -05:00
acl.h fs: take the ACL checks to common code 2011-07-25 14:30:23 -04:00
balloc.c ext4: Checksum the block bitmap properly with bigalloc enabled 2012-10-22 00:34:32 -04:00
bitmap.c ext4: Checksum the block bitmap properly with bigalloc enabled 2012-10-22 00:34:32 -04:00
block_validity.c ext2/3/4: delete unneeded includes of module.h 2012-01-09 13:52:10 +01:00
dir.c ext4: use core vfs llseek code for dir seeks 2012-07-23 00:00:28 +04:00
ext4_extents.h ext4: prevent race while walking extent tree for fiemap 2012-11-28 12:32:26 -05:00
ext4_jbd2.c ext4: fix metadata checksum calculation for the superblock 2012-10-10 01:06:58 -04:00
ext4_jbd2.h ext4: remove ext4_handle_release_buffer() 2012-11-08 11:22:46 -05:00
ext4.h ext4: reimplement ext4_find_delay_alloc_range on extent status tree 2012-11-08 21:57:35 -05:00
extents_status.c ext4: add some tracepoints in extent status tree 2012-11-08 21:57:33 -05:00
extents_status.h ext4: add operations on extent status tree 2012-11-08 21:57:20 -05:00
extents.c ext4: prevent race while walking extent tree for fiemap 2012-11-28 12:32:26 -05:00
file.c ext4: introduce lseek SEEK_DATA/SEEK_HOLE support 2012-11-08 21:57:40 -05:00
fsync.c ext4: fix ext4_flush_completed_IO wait semantics 2012-10-05 11:31:55 -04:00
hash.c ext4: return 32/64-bit dir name hash according to usage type 2012-03-18 22:44:40 -04:00
ialloc.c ext4: fix unjournaled inode bitmap modification 2012-10-28 22:24:57 -04:00
indirect.c ext4: let ext4 maintain extent status tree 2012-11-08 21:57:32 -05:00
inode.c ext4: remove calls to ext4_jbd2_file_inode() from delalloc write path 2012-11-15 23:08:57 -05:00
ioctl.c The big new feature added this time is supporting online resizing 2012-10-08 06:36:39 +09:00
Kconfig ext4: load the crc32c driver if necessary 2012-04-29 18:27:10 -04:00
Makefile ext4: add operations on extent status tree 2012-11-08 21:57:20 -05:00
mballoc.c ext4: warn when discard request fails other than EOPNOTSUPP 2012-11-08 14:04:52 -05:00
mballoc.h ext4: remove unused macro MB_DEFAULT_MAX_GROUPS_TO_SCAN 2012-08-17 10:00:17 -04:00
migrate.c userns: Convert ext4 to user kuid/kgid where appropriate 2012-05-15 14:59:27 -07:00
mmp.c ext4: Convert to new freezing mechanism 2012-07-31 09:45:48 +04:00
move_extent.c ext4: serialize dio nonlocked reads with defrag workers 2012-09-29 00:41:21 -04:00
namei.c ext4: don't verify checksums of dx non-leaf nodes during fallback scan 2012-11-12 23:51:02 -05:00
page-io.c ext4: use 'inode' variable that is already dereferenced 2012-11-08 14:53:35 -05:00
resize.c ext4: remove ext4_handle_release_buffer() 2012-11-08 11:22:46 -05:00
super.c ext4: let ext4 maintain extent status tree 2012-11-08 21:57:32 -05:00
symlink.c ext4: symlink must be handled via filesystem specific operation 2010-05-16 02:00:00 -04:00
truncate.h ext4: move common truncate functions to header file 2011-06-27 19:16:04 -04:00
xattr_security.c Merge branch 'for_linus' into for_linus_merged 2012-01-10 11:54:07 -05:00
xattr_trusted.c ext2/3/4: delete unneeded includes of module.h 2012-01-09 13:52:10 +01:00
xattr_user.c ext2/3/4: delete unneeded includes of module.h 2012-01-09 13:52:10 +01:00
xattr.c ext4: remove ext4_handle_release_buffer() 2012-11-08 11:22:46 -05:00
xattr.h ext4: change on-disk layout to support extended metadata checksumming 2012-04-29 18:23:10 -04:00