All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: delete redundant calculations in ext4_mb_get_buddy_page_lock()
@ 2023-10-23  1:34 Gou Hao
  2023-10-23 11:44 ` Jan Kara
  2023-10-24  3:52 ` [PATCH V2] " Gou Hao
  0 siblings, 2 replies; 5+ messages in thread
From: Gou Hao @ 2023-10-23  1:34 UTC (permalink / raw)
  To: tytso, adilger.kernel, jack, linux-ext4; +Cc: linux-kernel, gouhaojake

'blocks_per_page' is always 1 after 'if (blocks_per_page >= 2)',
'pnum' and 'block' is equal in this case.

Signed-off-by: Gou Hao <gouhao@uniontech.com>
Signed-off-by: Gou Hao <gouhaojake@163.com>
---
 fs/ext4/mballoc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 454d5612641e..8442f5474b25 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -1456,9 +1456,7 @@ static int ext4_mb_get_buddy_page_lock(struct super_block *sb,
 		return 0;
 	}
 
-	block++;
-	pnum = block / blocks_per_page;
-	page = find_or_create_page(inode->i_mapping, pnum, gfp);
+	page = find_or_create_page(inode->i_mapping, ++block, gfp);
 	if (!page)
 		return -ENOMEM;
 	BUG_ON(page->mapping != inode->i_mapping);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ext4: delete redundant calculations in ext4_mb_get_buddy_page_lock()
  2023-10-23  1:34 [PATCH] ext4: delete redundant calculations in ext4_mb_get_buddy_page_lock() Gou Hao
@ 2023-10-23 11:44 ` Jan Kara
  2023-10-24  2:35   ` Gou Hao
  2023-10-24  3:52 ` [PATCH V2] " Gou Hao
  1 sibling, 1 reply; 5+ messages in thread
From: Jan Kara @ 2023-10-23 11:44 UTC (permalink / raw)
  To: Gou Hao; +Cc: tytso, adilger.kernel, jack, linux-ext4, linux-kernel, gouhaojake

On Mon 23-10-23 09:34:16, Gou Hao wrote:
> 'blocks_per_page' is always 1 after 'if (blocks_per_page >= 2)',
> 'pnum' and 'block' is equal in this case.
> 
> Signed-off-by: Gou Hao <gouhao@uniontech.com>
> Signed-off-by: Gou Hao <gouhaojake@163.com>

No need for two signed-off-by here. Any one from you is enough :)

> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 454d5612641e..8442f5474b25 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -1456,9 +1456,7 @@ static int ext4_mb_get_buddy_page_lock(struct super_block *sb,
>  		return 0;
>  	}
>  
> -	block++;
> -	pnum = block / blocks_per_page;
> -	page = find_or_create_page(inode->i_mapping, pnum, gfp);
> +	page = find_or_create_page(inode->i_mapping, ++block, gfp);
						     ^^^ perhaps just
"block + 1" here? Maybe also add a comment before this call like:

	/* blocks_per_page == 1, hence we need another page for the buddy */

Otherwise the patch looks good!

								Honza

-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ext4: delete redundant calculations in ext4_mb_get_buddy_page_lock()
  2023-10-23 11:44 ` Jan Kara
@ 2023-10-24  2:35   ` Gou Hao
  0 siblings, 0 replies; 5+ messages in thread
From: Gou Hao @ 2023-10-24  2:35 UTC (permalink / raw)
  To: Jan Kara; +Cc: tytso, adilger.kernel, linux-ext4, linux-kernel, gouhaojake

On 10/23/23 19:44, Jan Kara wrote:

> On Mon 23-10-23 09:34:16, Gou Hao wrote:
>> 'blocks_per_page' is always 1 after 'if (blocks_per_page >= 2)',
>> 'pnum' and 'block' is equal in this case.
>>
>> Signed-off-by: Gou Hao <gouhao@uniontech.com>
>> Signed-off-by: Gou Hao <gouhaojake@163.com>
> No need for two signed-off-by here. Any one from you is enough :)
ok
>> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
>> index 454d5612641e..8442f5474b25 100644
>> --- a/fs/ext4/mballoc.c
>> +++ b/fs/ext4/mballoc.c
>> @@ -1456,9 +1456,7 @@ static int ext4_mb_get_buddy_page_lock(struct super_block *sb,
>>   		return 0;
>>   	}
>>   
>> -	block++;
>> -	pnum = block / blocks_per_page;
>> -	page = find_or_create_page(inode->i_mapping, pnum, gfp);
>> +	page = find_or_create_page(inode->i_mapping, ++block, gfp);
> 						     ^^^ perhaps just
> "block + 1" here? Maybe also add a comment before this call like:

Yes, 'block +1' is better here, i will add a comment.

Thanks for your review.

> 	/* blocks_per_page == 1, hence we need another page for the buddy */
>
> Otherwise the patch looks good!
>
> 								Honza
>
-- 
thanks,
Gou Hao <gouhao@uniontech.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH V2] ext4: delete redundant calculations in ext4_mb_get_buddy_page_lock()
  2023-10-23  1:34 [PATCH] ext4: delete redundant calculations in ext4_mb_get_buddy_page_lock() Gou Hao
  2023-10-23 11:44 ` Jan Kara
@ 2023-10-24  3:52 ` Gou Hao
  2024-01-09  2:53   ` Theodore Ts'o
  1 sibling, 1 reply; 5+ messages in thread
From: Gou Hao @ 2023-10-24  3:52 UTC (permalink / raw)
  To: gouhao; +Cc: adilger.kernel, gouhaojake, jack, linux-ext4, linux-kernel, tytso

'blocks_per_page' is always 1 after 'if (blocks_per_page >= 2)',
'pnum' and 'block' are equal in this case.

Signed-off-by: Gou Hao <gouhao@uniontech.com>
Reviewed-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/mballoc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 454d5612641e..c340d4d7287a 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -1456,9 +1456,8 @@ static int ext4_mb_get_buddy_page_lock(struct super_block *sb,
 		return 0;
 	}
 
-	block++;
-	pnum = block / blocks_per_page;
-	page = find_or_create_page(inode->i_mapping, pnum, gfp);
+	/* blocks_per_page == 1, hence we need another page for the buddy */
+	page = find_or_create_page(inode->i_mapping, block + 1, gfp);
 	if (!page)
 		return -ENOMEM;
 	BUG_ON(page->mapping != inode->i_mapping);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH V2] ext4: delete redundant calculations in ext4_mb_get_buddy_page_lock()
  2023-10-24  3:52 ` [PATCH V2] " Gou Hao
@ 2024-01-09  2:53   ` Theodore Ts'o
  0 siblings, 0 replies; 5+ messages in thread
From: Theodore Ts'o @ 2024-01-09  2:53 UTC (permalink / raw)
  To: Gou Hao
  Cc: Theodore Ts'o, adilger.kernel, gouhaojake, jack, linux-ext4,
	linux-kernel


On Tue, 24 Oct 2023 11:52:15 +0800, Gou Hao wrote:
> 'blocks_per_page' is always 1 after 'if (blocks_per_page >= 2)',
> 'pnum' and 'block' are equal in this case.
> 
> 

Applied, thanks!

[1/1] ext4: delete redundant calculations in ext4_mb_get_buddy_page_lock()
      commit: f2fec3e99a32d7c14dbf63c824f8286ebc94b18d

Best regards,
-- 
Theodore Ts'o <tytso@mit.edu>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-01-09  2:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-23  1:34 [PATCH] ext4: delete redundant calculations in ext4_mb_get_buddy_page_lock() Gou Hao
2023-10-23 11:44 ` Jan Kara
2023-10-24  2:35   ` Gou Hao
2023-10-24  3:52 ` [PATCH V2] " Gou Hao
2024-01-09  2:53   ` Theodore Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.