diff mbox

[24/29] ext4: Remove wait for unwritten extent conversion from ext4_ext_truncate()

Message ID 1365456754-29373-25-git-send-email-jack@suse.cz
State Superseded, archived
Headers show

Commit Message

Jan Kara April 8, 2013, 9:32 p.m. UTC
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_ext_truncate() anymore.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/extents.c |    6 ------
 fs/ext4/page-io.c |    9 ++++++++-
 2 files changed, 8 insertions(+), 7 deletions(-)

Comments

Zheng Liu May 8, 2013, 7:35 a.m. UTC | #1
On Mon, Apr 08, 2013 at 11:32:29PM +0200, Jan Kara wrote:
> 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_ext_truncate() anymore.
> 
> Signed-off-by: Jan Kara <jack@suse.cz>

Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Regards,
                                                - Zheng

> ---
>  fs/ext4/extents.c |    6 ------
>  fs/ext4/page-io.c |    9 ++++++++-
>  2 files changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index ae22735..ca4ff71 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -4256,12 +4256,6 @@ void ext4_ext_truncate(struct inode *inode)
>  	int err = 0;
>  
>  	/*
> -	 * 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);
> -
> -	/*
>  	 * probably first extent we're gonna free will be last in block
>  	 */
>  	err = ext4_writepage_trans_blocks(inode);
> diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
> index 2967794..2f0b943 100644
> --- a/fs/ext4/page-io.c
> +++ b/fs/ext4/page-io.c
> @@ -145,7 +145,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;
> -- 
> 1.7.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index ae22735..ca4ff71 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4256,12 +4256,6 @@  void ext4_ext_truncate(struct inode *inode)
 	int err = 0;
 
 	/*
-	 * 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);
-
-	/*
 	 * probably first extent we're gonna free will be last in block
 	 */
 	err = ext4_writepage_trans_blocks(inode);
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 2967794..2f0b943 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -145,7 +145,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;