kernel-ark/fs/btrfs
Liu Bo ecb8bea87d Btrfs: fix race between direct io and autodefrag
The bug is from running xfstests 209 with autodefrag.

The race is as follows:
       t1                       t2(autodefrag)
   direct IO
     invalidate pagecache
     dio(old data)             add_inode_defrag
     invalidate pagecache
   endio

   direct IO
     invalidate pagecache
                                run_defrag
                                  readpage(old data)
                                  set page dirty (old data)
     dio(new data, rewrite)
     invalidate pagecache (*)
     endio

t2(autodefrag) will get old data into pagecache via readpage and set
pagecache dirty.  Meanwhile, invalidate pagecache(*) will fail due to
dirty flags in pages.  So the old data may be flushed into disk by
flush thread, which will lead to data loss.

And so does the case of user defragment progs.

The patch fixes this race by holding i_mutex when we readpage and set page dirty.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2012-03-29 09:57:44 -04:00
..
acl.c Btrfs: fix return value of btrfs_get_acl() 2011-10-20 18:10:47 +02:00
async-thread.c btrfs: return void in functions without error conditions 2012-03-22 01:45:34 +01:00
async-thread.h btrfs: return void in functions without error conditions 2012-03-22 01:45:34 +01:00
backref.c Merge git://git.jan-o-sch.net/btrfs-unstable into for-linus 2012-03-28 20:33:40 -04:00
backref.h Btrfs: fix regression in scrub path resolving 2012-03-27 14:51:21 +02:00
btrfs_inode.h Btrfs: add a delalloc mutex to inodes for delalloc reservations 2012-01-16 15:29:43 -05:00
check-integrity.c Btrfs: fix compiler warnings on 32 bit systems 2012-02-24 10:39:05 -05:00
check-integrity.h Btrfs: add optional integrity check code 2011-12-21 19:14:09 +01:00
compat.h
compression.c btrfs: replace many BUG_ONs with proper error handling 2012-03-22 11:52:54 +01:00
compression.h btrfs: return void in functions without error conditions 2012-03-22 01:45:34 +01:00
ctree.c Merge branch 'error-handling' into for-linus 2012-03-28 20:31:37 -04:00
ctree.h Merge branch 'for-chris' of git://github.com/idryomov/btrfs-unstable into for-linus 2012-03-28 20:32:46 -04:00
delayed-inode.c btrfs: replace many BUG_ONs with proper error handling 2012-03-22 11:52:54 +01:00
delayed-inode.h atomic: use <linux/atomic.h> 2011-07-26 16:49:47 -07:00
delayed-ref.c btrfs: return void in functions without error conditions 2012-03-22 01:45:34 +01:00
delayed-ref.h Btrfs: add waitqueue instead of doing busy waiting for more delayed refs 2012-01-04 16:12:48 +01:00
dir-item.c btrfs: replace many BUG_ONs with proper error handling 2012-03-22 11:52:54 +01:00
disk-io.c Btrfs: flush out and clean up any block device pages during mount 2012-03-28 20:33:58 -04:00
disk-io.h btrfs: enhance transaction abort infrastructure 2012-03-22 01:45:40 +01:00
export.c btrfs: replace many BUG_ONs with proper error handling 2012-03-22 11:52:54 +01:00
export.h
extent_io.c Merge branch 'error-handling' into for-linus 2012-03-28 20:31:37 -04:00
extent_io.h Merge branch 'error-handling' into for-linus 2012-03-28 20:31:37 -04:00
extent_map.c Btrfs: clean up code for merging extent maps 2011-08-01 14:30:50 -04:00
extent_map.h btrfs: fix structs where bitfields and spinlock/atomic share 8B word 2012-02-15 16:40:25 +01:00
extent-tree.c Btrfs: fix deadlock during allocating chunks 2012-03-29 09:57:44 -04:00
file-item.c Btrfs: don't use crc items bigger than 4KB 2012-03-28 20:34:10 -04:00
file.c btrfs: replace many BUG_ONs with proper error handling 2012-03-22 11:52:54 +01:00
free-space-cache.c btrfs: replace many BUG_ONs with proper error handling 2012-03-22 11:52:54 +01:00
free-space-cache.h
hash.h
inode-item.c Merge branch 'error-handling' into for-linus 2012-03-28 20:31:37 -04:00
inode-map.c Btrfs: show useful info in space reservation tracepoint 2012-03-29 09:57:44 -04:00
inode-map.h
inode.c Merge branch 'error-handling' into for-linus 2012-03-28 20:31:37 -04:00
ioctl.c Btrfs: fix race between direct io and autodefrag 2012-03-29 09:57:44 -04:00
ioctl.h Btrfs: add balance progress reporting 2012-01-16 22:04:49 +02:00
Kconfig Btrfs: add config option to enable btrfs integrity check 2011-12-21 19:14:16 +01:00
locking.c btrfs: return void in functions without error conditions 2012-03-22 01:45:34 +01:00
locking.h btrfs: return void in functions without error conditions 2012-03-22 01:45:34 +01:00
lzo.c
Makefile Merge branch 'integrity-check-patch-v2' of git://btrfs.giantdisaster.de/git/btrfs into integration 2012-01-16 15:27:58 -05:00
ordered-data.c btrfs: return void in functions without error conditions 2012-03-22 01:45:34 +01:00
ordered-data.h btrfs: return void in functions without error conditions 2012-03-22 01:45:34 +01:00
orphan.c btrfs: replace many BUG_ONs with proper error handling 2012-03-22 11:52:54 +01:00
print-tree.c btrfs: fix oops on failure path 2011-10-20 18:10:50 +02:00
print-tree.h
reada.c Btrfs: introduce common define for max number of mirrors 2012-03-27 14:21:26 -04:00
relocation.c btrfs: replace many BUG_ONs with proper error handling 2012-03-22 11:52:54 +01:00
root-tree.c btrfs: replace many BUG_ONs with proper error handling 2012-03-22 11:52:54 +01:00
scrub.c Merge git://git.jan-o-sch.net/btrfs-unstable into for-linus 2012-03-28 20:33:40 -04:00
struct-funcs.c Btrfs: add the ability to cache a pointer into the eb 2012-03-26 17:04:23 -04:00
super.c Merge git://git.jan-o-sch.net/btrfs-unstable into for-linus 2012-03-28 20:33:40 -04:00
sysfs.c
transaction.c Btrfs: show useful info in space reservation tracepoint 2012-03-29 09:57:44 -04:00
transaction.h btrfs: enhance transaction abort infrastructure 2012-03-22 01:45:40 +01:00
tree-defrag.c
tree-log.c btrfs: replace many BUG_ONs with proper error handling 2012-03-22 11:52:54 +01:00
tree-log.h btrfs: return void in functions without error conditions 2012-03-22 01:45:34 +01:00
ulist.c Btrfs: generic data structure to build unique lists 2011-12-22 16:22:24 +01:00
ulist.h Btrfs: generic data structure to build unique lists 2011-12-22 16:22:24 +01:00
version.h
volumes.c Btrfs: flush out and clean up any block device pages during mount 2012-03-28 20:33:58 -04:00
volumes.h btrfs: return void in functions without error conditions 2012-03-22 01:45:34 +01:00
xattr.c Btrfs: do not use btrfs_end_transaction_throttle everywhere 2012-01-16 15:28:54 -05:00
xattr.h
zlib.c