]> git.karo-electronics.de Git - karo-tx-linux.git/commit
ext4: fix race between unwritten extent conversion and truncate
authorJeff Moyer <jmoyer@redhat.com>
Mon, 20 Feb 2012 22:59:24 +0000 (17:59 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 2 Apr 2012 17:32:20 +0000 (10:32 -0700)
commit2a45b2e1c6ed5e030e58fa6fbcb6dbc04d1dad64
tree0959d629406a333e151e13d0c86ddb296b9031fb
parent9dacb0fb008d3042a41889e4f9e21d6f1afc20c0
ext4: fix race between unwritten extent conversion and truncate

commit 266991b13890049ee1a6bb95b9817f06339ee3d7 upstream.

The following comment in ext4_end_io_dio caught my attention:

/* XXX: probably should move into the real I/O completion handler */
        inode_dio_done(inode);

The truncate code takes i_mutex, then calls inode_dio_wait.  Because the
ext4 code path above will end up dropping the mutex before it is
reacquired by the worker thread that does the extent conversion, it
seems to me that the truncate can happen out of order.  Jan Kara
mentioned that this might result in error messages in the system logs,
but that should be the extent of the "damage."

The fix is pretty straight-forward: don't call inode_dio_done until the
extent conversion is complete.

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/ext4.h
fs/ext4/inode.c
fs/ext4/page-io.c