remarkable-linux/fs/ext4
Akira Fujita fc04cb49a8 ext4: fix lock order problem in ext4_move_extents()
ext4_move_extents() checks the logical block contiguousness
of original file with ext4_find_extent() and mext_next_extent().
Therefore the extent which ext4_ext_path structure indicates
must not be changed between above functions.

But in current implementation, there is no i_data_sem protection
between ext4_ext_find_extent() and mext_next_extent().  So the extent
which ext4_ext_path structure indicates may be overwritten by
delalloc.  As a result, ext4_move_extents() will exchange wrong blocks
between original and donor files.  I change the place where
acquire/release i_data_sem to solve this problem.

Moreover, I changed move_extent_per_page() to start transaction first,
and then acquire i_data_sem.  Without this change, there is a
possibility of the deadlock between mmap() and ext4_move_extents():

* NOTE: "A", "B" and "C" mean different processes

A-1: ext4_ext_move_extents() acquires i_data_sem of two inodes.

B:   do_page_fault() starts the transaction (T),
     and then tries to acquire i_data_sem.
     But process "A" is already holding it, so it is kept waiting.

C:   While "A" and "B" running, kjournald2 tries to commit transaction (T)
     but it is under updating, so kjournald2 waits for it.

A-2: Call ext4_journal_start with holding i_data_sem,
     but transaction (T) is locked.

Signed-off-by: Akira Fujita <a-fujita@rs.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-11-23 07:24:43 -05:00
..
acl.c ext[234]: move over to 'check_acl' permission model 2009-09-08 11:09:04 -07:00
acl.h ext[234]: move over to 'check_acl' permission model 2009-09-08 11:09:04 -07:00
balloc.c ext4: open-code ext4_mb_update_group_info 2009-08-17 23:51:29 -04:00
bitmap.c
block_validity.c ext4: Add a comprehensive block validity check to ext4_get_blocks() 2009-05-17 15:38:01 -04:00
dir.c ext4: Define a new set of flags for ext4_get_blocks() 2009-05-14 00:58:52 -04:00
ext4.h ext4: skip conversion of uninit extents after direct IO if there isn't any 2009-11-10 10:48:04 -05:00
ext4_extents.h ext4: Split uninitialized extents for direct I/O 2009-09-28 15:49:08 -04:00
ext4_jbd2.c ext4: Assure that metadata blocks are written during fsync in no journal mode 2009-09-12 13:41:55 -04:00
ext4_jbd2.h ext4: Handle nested ext4_journal_start/stop calls without a journal 2009-09-29 11:01:03 -04:00
extents.c ext4: Fix return value of ext4_split_unwritten_extents() to fix direct I/O 2009-11-06 04:01:23 -05:00
file.c const: mark struct vm_struct_operations 2009-09-27 11:39:25 -07:00
fsync.c ext4: async direct IO for holes and fallocate support 2009-09-28 15:48:29 -04:00
hash.c
ialloc.c ext4: fix build warning when EXT4FS_DEBUG is on 2009-07-27 21:44:40 -04:00
inode.c ext4: skip conversion of uninit extents after direct IO if there isn't any 2009-11-10 10:48:04 -05:00
ioctl.c ext4: Return exchanged blocks count to user space in failure 2009-09-05 22:46:29 -04:00
Kconfig ext4: drop ext4dev compat 2009-10-01 02:21:07 -04:00
Makefile ext4: online defrag -- Add EXT4_IOC_MOVE_EXT ioctl 2009-06-17 19:24:03 -04:00
mballoc.c ext4: Use tracepoints for mb_history trace file 2009-09-30 00:32:42 -04:00
mballoc.h ext4: Use tracepoints for mb_history trace file 2009-09-30 00:32:42 -04:00
migrate.c ext4: Split uninitialized extents for direct I/O 2009-09-28 15:49:08 -04:00
move_extent.c ext4: fix lock order problem in ext4_move_extents() 2009-11-23 07:24:43 -05:00
namei.c ext4: fix potential buffer head leak when add_dirent_to_buf() returns ENOSPC 2009-11-23 07:25:49 -05:00
resize.c ext4: Clarify the locking details in mballoc 2009-09-09 23:50:17 -04:00
super.c ext4: avoid divide by zero when trying to mount a corrupted file system 2009-11-23 07:24:46 -05:00
symlink.c
xattr.c ext4: limit block allocations for indirect-block files to < 2^32 2009-09-16 14:45:10 -04:00
xattr.h
xattr_security.c
xattr_trusted.c
xattr_user.c