]> git.karo-electronics.de Git - karo-tx-linux.git/commit
ext4: Use end_io callback to avoid direct I/O fallback to buffered I/O
authorMingming Cao <cmm@us.ibm.com>
Mon, 28 Sep 2009 19:48:41 +0000 (15:48 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 14 Dec 2009 16:07:02 +0000 (08:07 -0800)
commit1295e40acf6d150d129fac939bc97aed771e6c7b
tree2887750840bf1625fb7e636edbda36f2382b1439
parent45eef039f3a5d0bce583d0a9b34818127ea79e49
ext4: Use end_io callback to avoid direct I/O fallback to buffered I/O

(cherry picked from commit 4c0425ff68b1b87b802ffeda7b6a46ff7da7241c)

Currently the DIO VFS code passes create = 0 when writing to the
middle of file.  It does this to avoid block allocation for holes, so
as not to expose stale data out when there is a parallel buffered read
(which does not hold the i_mutex lock).  Direct I/O writes into holes
falls back to buffered IO for this reason.

Since preallocated extents are treated as holes when doing a
get_block() look up (buffer is not mapped), direct IO over fallocate
also falls back to buffered IO.  Thus ext4 actually silently falls
back to buffered IO in above two cases, which is undesirable.

To fix this, this patch creates unitialized extents when a direct I/O
write into holes in sparse files, and registering an end_io callback which
converts the uninitialized extent to an initialized extent after the
I/O is completed.

Singed-Off-By: Mingming Cao <cmm@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/ext4/ext4.h
fs/ext4/inode.c
fs/ext4/super.c