linux-stable/fs/btrfs
Miao Xie 0934856d46 Btrfs: fix deadlock due to unsubmitted
The deadlock problem happened when running fsstress(a test program in LTP).

Steps to reproduce:
 # mkfs.btrfs -b 100M <partition>
 # mount <partition> <mnt>
 # <Path>/fsstress -p 3 -n 10000000 -d <mnt>

The reason is:
btrfs_direct_IO()
 |->do_direct_IO()
     |->get_page()
     |->get_blocks()
     |	 |->btrfs_delalloc_resereve_space()
     |	 |->btrfs_add_ordered_extent() -------	Add a new ordered extent
     |->dio_send_cur_page(page0) --------------	We didn't submit bio here
     |->get_page()
     |->get_blocks()
	 |->btrfs_delalloc_resereve_space()
	     |->flush_space()
		 |->btrfs_start_ordered_extent()
		     |->wait_event() ----------	Wait the completion of
						the ordered extent that is
						mentioned above

But because we didn't submit the bio that is mentioned above, the ordered
extent can not complete, we would wait for its completion forever.

There are two methods which can fix this deadlock problem:
1. submit the bio before we invoke get_blocks()
2. reserve the space before we do dio

Though the 1st is the simplest way, we need modify the code of VFS, and it
is likely to break contiguous requests, and introduce performance regression
for the other filesystems.

So we have to choose the 2nd way.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Cc: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
2013-02-20 12:59:45 -05:00
..
acl.c Btrfs: skip adding an acl attribute if we don't have to 2012-12-16 20:46:15 -05:00
async-thread.c Btrfs: call the ordered free operation without any locks held 2012-07-25 16:15:07 -04:00
async-thread.h
backref.c Btrfs: merge inode_list in __merge_refs 2012-12-12 17:15:27 -05:00
backref.h Btrfs: move fs/btrfs/ioctl.h to include/uapi/linux/btrfs.h 2013-02-20 09:37:28 -05:00
btrfs_inode.h Btrfs: use the inode own lock to protect its delalloc_bytes 2013-02-20 12:59:06 -05:00
check-integrity.c Btrfs: fix race in check-integrity caused by usage of bitfield 2012-12-16 20:46:13 -05:00
check-integrity.h
compat.h
compression.c Btrfs: handle errors from btrfs_map_bio() everywhere 2012-12-12 17:15:40 -05:00
compression.h
ctree.c btrfs: remove cache only arguments from defrag path 2013-02-20 12:59:36 -05:00
ctree.h Btrfs: steal from global reserve if we are cleaning up orphans 2013-02-20 12:59:42 -05:00
delayed-inode.c btrfs: remove unused "item" in btrfs_insert_delayed_item() 2013-02-20 12:59:23 -05:00
delayed-inode.h Btrfs: fix lots of orphan inodes when the space is not enough 2013-02-20 09:36:39 -05:00
delayed-ref.c Btrfs: make delayed ref lock logic more readable 2013-02-20 09:36:41 -05:00
delayed-ref.h Btrfs: make delayed ref lock logic more readable 2013-02-20 09:36:41 -05:00
dev-replace.c Btrfs: check the return value of btrfs_start_delalloc_inodes() 2013-02-20 09:37:21 -05:00
dev-replace.h Btrfs: add new sources for device replace code 2012-12-12 17:15:41 -05:00
dir-item.c Btrfs: fix hash overflow handling 2012-12-17 14:48:21 -05:00
disk-io.c Btrfs: fix the race between bio and btrfs_stop_workers 2013-02-20 12:59:40 -05:00
disk-io.h Btrfs: cleanup for btrfs_btree_balance_dirty 2012-12-12 17:15:28 -05:00
export.c ->encode_fh() API change 2012-05-29 23:28:33 -04:00
export.h
extent-tree.c Btrfs: fix deadlock due to unsubmitted 2013-02-20 12:59:45 -05:00
extent_io.c Btrfs: use percpu counter for dirty metadata count 2013-02-20 12:59:04 -05:00
extent_io.h Btrfs: pass fs_info to btrfs_map_block() instead of mapping_tree 2012-12-12 17:15:34 -05:00
extent_map.c Btrfs: do not merge logged extents if we've removed them from the tree 2013-02-05 16:09:03 -05:00
extent_map.h Btrfs: do not allow logged extents to be merged or removed 2013-01-24 12:49:48 -05:00
file-item.c Btrfs: extend the checksum item as much as possible 2013-02-20 12:59:37 -05:00
file.c Btrfs: use bit operation for ->fs_state 2013-02-20 12:59:09 -05:00
free-space-cache.c Btrfs: fix panic when recovering tree log 2013-01-24 12:49:49 -05:00
free-space-cache.h
hash.h btrfs: extended inode refs 2012-10-09 09:14:45 -04:00
inode-item.c btrfs: extended inode refs 2012-10-09 09:14:45 -04:00
inode-map.c Btrfs: improve the noflush reservation 2012-12-11 13:31:31 -05:00
inode-map.h
inode.c Btrfs: fix deadlock due to unsubmitted 2013-02-20 12:59:45 -05:00
ioctl.c Btrfs: fix memory leak of pending_snapshot->inherit 2013-02-20 12:59:41 -05:00
Kconfig
locking.c Btrfs: save us a read_lock 2013-02-20 09:37:17 -05:00
locking.h
lzo.c
Makefile Btrfs: add new sources for device replace code 2012-12-12 17:15:41 -05:00
math.h Btrfs: cleanup duplicated division functions 2012-12-11 13:31:30 -05:00
ordered-data.c Btrfs: don't traverse the ordered operation list repeatedly 2013-02-20 09:37:24 -05:00
ordered-data.h Btrfs: wait on ordered extents at the last possible moment 2013-02-20 09:37:04 -05:00
orphan.c btrfs: replace many BUG_ONs with proper error handling 2012-03-22 11:52:54 +01:00
print-tree.c btrfs: add missing break in btrfs_print_leaf() 2013-02-20 12:59:20 -05:00
print-tree.h
qgroup.c Btrfs: move fs/btrfs/ioctl.h to include/uapi/linux/btrfs.h 2013-02-20 09:37:28 -05:00
rcu-string.h Btrfs: use rcu to protect device->name 2012-06-14 21:29:16 -04:00
reada.c Btrfs: introduce GET_READ_MIRRORS functionality for btrfs_map_block() 2012-12-12 17:15:43 -05:00
relocation.c Btrfs: use wrapper page_offset 2013-02-20 09:36:43 -05:00
root-tree.c Btrfs: rename root_times_lock to root_item_lock 2012-12-16 20:46:21 -05:00
scrub.c Btrfs: use bit operation for ->fs_state 2013-02-20 12:59:09 -05:00
send.c btrfs: add "no file data" flag to btrfs send ioctl 2013-02-20 12:59:39 -05:00
send.h btrfs: add "no file data" flag to btrfs send ioctl 2013-02-20 12:59:39 -05:00
struct-funcs.c Btrfs: rewrite BTRFS_SETGET_FUNCS 2012-07-23 16:28:06 -04:00
super.c btrfs: fix varargs in __btrfs_std_error 2013-02-20 12:59:22 -05:00
sysfs.c
transaction.c btrfs: remove cache only arguments from defrag path 2013-02-20 12:59:36 -05:00
transaction.h btrfs: remove cache only arguments from defrag path 2013-02-20 12:59:36 -05:00
tree-defrag.c btrfs: remove cache only arguments from defrag path 2013-02-20 12:59:36 -05:00
tree-log.c btrfs: remove cache only arguments from defrag path 2013-02-20 12:59:36 -05:00
tree-log.h
ulist.c Btrfs: make aux field of ulist 64 bit 2012-10-01 15:18:53 -04:00
ulist.h Btrfs: make aux field of ulist 64 bit 2012-10-01 15:18:53 -04:00
version.h
volumes.c btrfs: ensure we don't overrun devices_info[] in __btrfs_alloc_chunk 2013-02-20 12:59:26 -05:00
volumes.h Btrfs: move fs/btrfs/ioctl.h to include/uapi/linux/btrfs.h 2013-02-20 09:37:28 -05:00
xattr.c Btrfs: only log the inode item if we can get away with it 2012-12-16 20:46:21 -05:00
xattr.h
zlib.c btrfs: fix message printing 2012-10-09 09:19:57 -04:00