Patchwork ext4: defragmentation code cleanup

login
register
mail settings
Submitter Dmitri Monakho
Date April 9, 2013, 3:15 p.m.
Message ID <1365520559-6622-1-git-send-email-dmonakhov@openvz.org>
Download mbox | patch
Permalink /patch/235110/
State Accepted
Headers show

Comments

Dmitri Monakho - April 9, 2013, 3:15 p.m.
- grab_cache_page_write_begin() may not wait on page's writeback since
  (1d1d1a767206). But it is still reasonable to wait on page's writeback
  here in order to be on the safe side.

- Fix miss typo: pass 'length' instead of 'end' to __block_write_begin()
  https://bugzilla.kernel.org/show_bug.cgi?id=56241

TESTCASE: git://oss.sgi.com/xfs/cmds/xfstests.git
MKFS_OPTIONS="-b1024" ; ./check ext4/304

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 fs/ext4/move_extent.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
Akira Fujita - April 10, 2013, 6:43 a.m.
Hi,

(2013/04/10 0:15), Dmitry Monakhov wrote:
> - grab_cache_page_write_begin() may not wait on page's writeback since
>    (1d1d1a767206). But it is still reasonable to wait on page's writeback
>    here in order to be on the safe side.
> 
> - Fix miss typo: pass 'length' instead of 'end' to __block_write_begin()
>    https://bugzilla.kernel.org/show_bug.cgi?id=56241

Looks good to me, thanks.

Reviewed-by: Akira Fujita <a-fujita.rs.jp.nec.com>
 
> TESTCASE: git://oss.sgi.com/xfs/cmds/xfstests.git
> MKFS_OPTIONS="-b1024" ; ./check ext4/304
> 
> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
> ---
>   fs/ext4/move_extent.c |   11 +++++++++--
>   1 files changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
> index 33e1c08..58b33e9 100644
> --- a/fs/ext4/move_extent.c
> +++ b/fs/ext4/move_extent.c
> @@ -737,6 +737,7 @@ mext_replace_branches(handle_t *handle, struct inode *orig_inode,
>   		donor_off += dext_alen;
>   		orig_off += dext_alen;
>   
> +		BUG_ON(replaced_count > count);
>   		/* Already moved the expected blocks */
>   		if (replaced_count >= count)
>   			break;
> @@ -814,7 +815,13 @@ mext_page_double_lock(struct inode *inode1, struct inode *inode2,
>   		page_cache_release(page[0]);
>   		return -ENOMEM;
>   	}
> -
> +	/*
> +	 * grab_cache_page_write_begin() may not wait on page's writeback if
> +	 * BDI not demand that. But it is reasonable to be very conservative
> +	 * here and explicitly wait on page's writeback
> +	 */
> +	wait_on_page_writeback(page[0]);
> +	wait_on_page_writeback(page[1]);
>   	if (inode1 > inode2) {
>   		struct page *tmp;
>   		tmp = page[0];
> @@ -1033,7 +1040,7 @@ data_copy:
>   	}
>   	/* Perform all necessary steps similar write_begin()/write_end()
>   	 * but keeping in mind that i_size will not change */
> -	*err = __block_write_begin(pagep[0], from, from + replaced_size,
> +	*err = __block_write_begin(pagep[0], from, replaced_size,
>   				   ext4_get_block);
>   	if (!*err)
>   		*err = block_commit_write(pagep[0], from, from + replaced_size);
> 


--
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
Theodore Ts'o - April 12, 2013, 3:33 a.m.
On Wed, Apr 10, 2013 at 03:43:09PM +0900, Akira Fujita wrote:
> Hi,
> 
> (2013/04/10 0:15), Dmitry Monakhov wrote:
> > - grab_cache_page_write_begin() may not wait on page's writeback since
> >    (1d1d1a767206). But it is still reasonable to wait on page's writeback
> >    here in order to be on the safe side.
> > 
> > - Fix miss typo: pass 'length' instead of 'end' to __block_write_begin()
> >    https://bugzilla.kernel.org/show_bug.cgi?id=56241
> 
> Looks good to me, thanks.
> 
> Reviewed-by: Akira Fujita <a-fujita.rs.jp.nec.com>

Applied, thanks.

					- Ted
--
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

Patch

diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
index 33e1c08..58b33e9 100644
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -737,6 +737,7 @@  mext_replace_branches(handle_t *handle, struct inode *orig_inode,
 		donor_off += dext_alen;
 		orig_off += dext_alen;
 
+		BUG_ON(replaced_count > count);
 		/* Already moved the expected blocks */
 		if (replaced_count >= count)
 			break;
@@ -814,7 +815,13 @@  mext_page_double_lock(struct inode *inode1, struct inode *inode2,
 		page_cache_release(page[0]);
 		return -ENOMEM;
 	}
-
+	/*
+	 * grab_cache_page_write_begin() may not wait on page's writeback if
+	 * BDI not demand that. But it is reasonable to be very conservative
+	 * here and explicitly wait on page's writeback
+	 */
+	wait_on_page_writeback(page[0]);
+	wait_on_page_writeback(page[1]);
 	if (inode1 > inode2) {
 		struct page *tmp;
 		tmp = page[0];
@@ -1033,7 +1040,7 @@  data_copy:
 	}
 	/* Perform all necessary steps similar write_begin()/write_end()
 	 * but keeping in mind that i_size will not change */
-	*err = __block_write_begin(pagep[0], from, from + replaced_size,
+	*err = __block_write_begin(pagep[0], from, replaced_size,
 				   ext4_get_block);
 	if (!*err)
 		*err = block_commit_write(pagep[0], from, from + replaced_size);