]> Pileus Git - ~andy/linux/commitdiff
ext4: remove wait for unwritten extent conversion from ext4_truncate()
authorJan Kara <jack@suse.cz>
Tue, 4 Jun 2013 18:30:00 +0000 (14:30 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 4 Jun 2013 18:30:00 +0000 (14:30 -0400)
Since PageWriteback bit is now cleared after extents are converted
from unwritten to written ones, we have full exclusion of writeback
path from truncate (truncate_inode_pages() waits for PageWriteback
bits to get cleared on all invalidated pages).  Exclusion from DIO
path is achieved by inode_dio_wait() call in ext4_setattr().  So
there's no need to wait for extent convertion in ext4_truncate()
anymore.

Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
fs/ext4/inode.c
fs/ext4/page-io.c

index eb4ddfeeeedca899a9a66849b4adf189a4cd9ce2..d6e4f0e09a8cc071e1f2b54b9f15b2b80c912955 100644 (file)
@@ -3643,12 +3643,6 @@ void ext4_truncate(struct inode *inode)
                        return;
        }
 
-       /*
-        * finish any pending end_io work so we won't run the risk of
-        * converting any truncated blocks to initialized later
-        */
-       ext4_flush_unwritten_io(inode);
-
        if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
                credits = ext4_writepage_trans_blocks(inode);
        else
index 755741c211a4a1f1f8ebc85ee51d2cdd92887bf1..0f65561ab5a5c63750cf33099a90bd3d7b6bf135 100644 (file)
@@ -158,7 +158,14 @@ static void ext4_clear_io_unwritten_flag(ext4_io_end_t *io_end)
                wake_up_all(ext4_ioend_wq(inode));
 }
 
-/* check a range of space and convert unwritten extents to written. */
+/*
+ * Check a range of space and convert unwritten extents to written. Note that
+ * we are protected from truncate touching same part of extent tree by the
+ * fact that truncate code waits for all DIO to finish (thus exclusion from
+ * direct IO is achieved) and also waits for PageWriteback bits. Thus we
+ * cannot get to ext4_ext_truncate() before all IOs overlapping that range are
+ * completed (happens from ext4_free_ioend()).
+ */
 static int ext4_end_io(ext4_io_end_t *io)
 {
        struct inode *inode = io->inode;