linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: remove unnecessary code in __mb_check_buddy
@ 2022-04-04 15:22 Jinke Han
  2022-04-21 11:46 ` Jan Kara
  2022-05-11 15:43 ` Theodore Ts'o
  0 siblings, 2 replies; 3+ messages in thread
From: Jinke Han @ 2022-04-04 15:22 UTC (permalink / raw)
  To: tytso, adilger.kernel; +Cc: linux-ext4, linux-kernel, Jinke Han

From: Jinke Han <hanjinke.666@bytedance.com>

When enter elseif branch, the the MB_CHECK_ASSERT will never fail.
In addtion, the only illegal combination is 0/0, which can be caught
by the first if branch.

Signed-off-by: Jinke Han <hanjinke.666@bytedance.com>
---
 fs/ext4/mballoc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index e5d43d2ee474..eba650b31870 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -576,13 +576,10 @@ static int __mb_check_buddy(struct ext4_buddy *e4b, char *file,
 		for (i = 0; i < max; i++) {
 
 			if (mb_test_bit(i, buddy)) {
-				/* only single bit in buddy2 may be 1 */
+				/* only single bit in buddy2 may be 0 */
 				if (!mb_test_bit(i << 1, buddy2)) {
 					MB_CHECK_ASSERT(
 						mb_test_bit((i<<1)+1, buddy2));
-				} else if (!mb_test_bit((i << 1) + 1, buddy2)) {
-					MB_CHECK_ASSERT(
-						mb_test_bit(i << 1, buddy2));
 				}
 				continue;
 			}
-- 
2.20.1


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

* Re: [PATCH] ext4: remove unnecessary code in __mb_check_buddy
  2022-04-04 15:22 [PATCH] ext4: remove unnecessary code in __mb_check_buddy Jinke Han
@ 2022-04-21 11:46 ` Jan Kara
  2022-05-11 15:43 ` Theodore Ts'o
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2022-04-21 11:46 UTC (permalink / raw)
  To: Jinke Han; +Cc: tytso, adilger.kernel, linux-ext4, linux-kernel

On Mon 04-04-22 23:22:43, Jinke Han wrote:
> From: Jinke Han <hanjinke.666@bytedance.com>
> 
> When enter elseif branch, the the MB_CHECK_ASSERT will never fail.
> In addtion, the only illegal combination is 0/0, which can be caught
> by the first if branch.
> 
> Signed-off-by: Jinke Han <hanjinke.666@bytedance.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>
	
Ted, this seems to have fallen through the cracks...

								Honza

> ---
>  fs/ext4/mballoc.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index e5d43d2ee474..eba650b31870 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -576,13 +576,10 @@ static int __mb_check_buddy(struct ext4_buddy *e4b, char *file,
>  		for (i = 0; i < max; i++) {
>  
>  			if (mb_test_bit(i, buddy)) {
> -				/* only single bit in buddy2 may be 1 */
> +				/* only single bit in buddy2 may be 0 */
>  				if (!mb_test_bit(i << 1, buddy2)) {
>  					MB_CHECK_ASSERT(
>  						mb_test_bit((i<<1)+1, buddy2));
> -				} else if (!mb_test_bit((i << 1) + 1, buddy2)) {
> -					MB_CHECK_ASSERT(
> -						mb_test_bit(i << 1, buddy2));
>  				}
>  				continue;
>  			}
> -- 
> 2.20.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH] ext4: remove unnecessary code in __mb_check_buddy
  2022-04-04 15:22 [PATCH] ext4: remove unnecessary code in __mb_check_buddy Jinke Han
  2022-04-21 11:46 ` Jan Kara
@ 2022-05-11 15:43 ` Theodore Ts'o
  1 sibling, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2022-05-11 15:43 UTC (permalink / raw)
  To: adilger.kernel, Jinke Han; +Cc: Theodore Ts'o, linux-ext4, linux-kernel

On Mon, 4 Apr 2022 23:22:43 +0800, Jinke Han wrote:
> From: Jinke Han <hanjinke.666@bytedance.com>
> 
> When enter elseif branch, the the MB_CHECK_ASSERT will never fail.
> In addtion, the only illegal combination is 0/0, which can be caught
> by the first if branch.
> 
> 
> [...]

Applied, thanks!

[1/1] ext4: remove unnecessary code in __mb_check_buddy
      commit: 3114e248fcda22f4d9bb149050c22d5efb999899

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

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

end of thread, other threads:[~2022-05-11 15:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-04 15:22 [PATCH] ext4: remove unnecessary code in __mb_check_buddy Jinke Han
2022-04-21 11:46 ` Jan Kara
2022-05-11 15:43 ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).