[PATCH] ext4/move_extent: use folio_next_pos()

Julia Lawall posted 1 patch 1 month, 3 weeks ago
fs/ext4/move_extent.c |    4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] ext4/move_extent: use folio_next_pos()
Posted by Julia Lawall 1 month, 3 weeks ago
A series of patches such as commit 60a70e61430b ("mm: Use
folio_next_pos()") replace folio_pos() + folio_size() by
folio_next_pos().  The former performs x << z + y << z while
the latter performs (x + y) << z, which is slightly more
efficient. This case was not taken into account, perhaps
because the argument is not named folio.

The change was performed using the following Coccinelle
semantic patch:

@@
expression folio;
@@

- folio_pos(folio) + folio_size(folio)
+ folio_next_pos(folio)

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>

---
 fs/ext4/move_extent.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff -u -p a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -224,8 +224,8 @@ static int mext_move_begin(struct mext_d
 	}
 
 	/* Adjust the moving length according to the length of shorter folio. */
-	move_len = umin(folio_pos(folio[0]) + folio_size(folio[0]) - orig_pos,
-			folio_pos(folio[1]) + folio_size(folio[1]) - donor_pos);
+	move_len = umin(folio_next_pos(folio[0]) - orig_pos,
+			folio_next_pos(folio[1]) - donor_pos);
 	move_len >>= blkbits;
 	if (move_len < mext->orig_map.m_len)
 		mext->orig_map.m_len = move_len;
Re: [PATCH] ext4/move_extent: use folio_next_pos()
Posted by Theodore Ts'o 6 days, 14 hours ago
On Sun, 22 Feb 2026 13:50:49 +0100, Julia Lawall wrote:
> A series of patches such as commit 60a70e61430b ("mm: Use
> folio_next_pos()") replace folio_pos() + folio_size() by
> folio_next_pos().  The former performs x << z + y << z while
> the latter performs (x + y) << z, which is slightly more
> efficient. This case was not taken into account, perhaps
> because the argument is not named folio.
> 
> [...]

Applied, thanks!

[1/1] ext4/move_extent: use folio_next_pos()
      commit: a804ecc399d91a529726fa1b10ff699bb531253d

Best regards,
-- 
Theodore Ts'o <tytso@mit.edu>
Re: [PATCH] ext4/move_extent: use folio_next_pos()
Posted by Zhang Yi 1 month, 2 weeks ago
On 2/22/2026 8:50 PM, Julia Lawall wrote:
> A series of patches such as commit 60a70e61430b ("mm: Use
> folio_next_pos()") replace folio_pos() + folio_size() by
> folio_next_pos().  The former performs x << z + y << z while
> the latter performs (x + y) << z, which is slightly more
> efficient. This case was not taken into account, perhaps
> because the argument is not named folio.
> 
> The change was performed using the following Coccinelle
> semantic patch:
> 
> @@
> expression folio;
> @@
> 
> - folio_pos(folio) + folio_size(folio)
> + folio_next_pos(folio)
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>

Thank you for the patch. Looks good to me.

Reviewed-by: Zhang Yi <yi.zhang@huawei.com>

> 
> ---
>  fs/ext4/move_extent.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff -u -p a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
> --- a/fs/ext4/move_extent.c
> +++ b/fs/ext4/move_extent.c
> @@ -224,8 +224,8 @@ static int mext_move_begin(struct mext_d
>  	}
>  
>  	/* Adjust the moving length according to the length of shorter folio. */
> -	move_len = umin(folio_pos(folio[0]) + folio_size(folio[0]) - orig_pos,
> -			folio_pos(folio[1]) + folio_size(folio[1]) - donor_pos);
> +	move_len = umin(folio_next_pos(folio[0]) - orig_pos,
> +			folio_next_pos(folio[1]) - donor_pos);
>  	move_len >>= blkbits;
>  	if (move_len < mext->orig_map.m_len)
>  		mext->orig_map.m_len = move_len;
> 
> 
>