linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
To: Kemeng Shi <shikemeng@huaweicloud.com>,
	tytso@mit.edu, adilger.kernel@dilger.ca
Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
	shikemeng@huaweicloud.com
Subject: Re: [PATCH 2/2] ext4: avoid unnecessary pointer dereference in ext4_mb_normalize_request
Date: Mon, 13 Mar 2023 07:43:42 +0530	[thread overview]
Message-ID: <87pm9dflex.fsf@doe.com> (raw)
In-Reply-To: <20230311170949.1047958-3-shikemeng@huaweicloud.com>

Kemeng Shi <shikemeng@huaweicloud.com> writes:

> Result of EXT4_SB(ac->ac_sb) is already stored in sbi at beginning of
> ext4_mb_normalize_request. Use sbi instead of EXT4_SB(ac->ac_sb) to
> remove unnecessary pointer dereference.
>
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> ---
>  fs/ext4/mballoc.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>

Looks good to me. Please feel free to add -

Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>


> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 13dce6f07fa4..d94eb52dda17 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -4049,7 +4049,7 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
>  		size = 8 * 1024 * 1024;
>  	} else {
>  		start_off = (loff_t) ac->ac_o_ex.fe_logical << bsbits;
> -		size	  = (loff_t) EXT4_C2B(EXT4_SB(ac->ac_sb),
> +		size	  = (loff_t) EXT4_C2B(sbi,
>  					      ac->ac_o_ex.fe_len) << bsbits;
>  	}
>  	size = size >> bsbits;
> @@ -4094,8 +4094,7 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
>  			continue;
>  		}
>
> -		pa_end = pa->pa_lstart + EXT4_C2B(EXT4_SB(ac->ac_sb),
> -						  pa->pa_len);
> +		pa_end = pa->pa_lstart + EXT4_C2B(sbi, pa->pa_len);
>
>  		/* PA must not overlap original request */
>  		BUG_ON(!(ac->ac_o_ex.fe_logical >= pa_end ||
> @@ -4128,8 +4127,7 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
>
>  		spin_lock(&pa->pa_lock);
>  		if (pa->pa_deleted == 0) {
> -			pa_end = pa->pa_lstart + EXT4_C2B(EXT4_SB(ac->ac_sb),
> -							  pa->pa_len);
> +			pa_end = pa->pa_lstart + EXT4_C2B(sbi, pa->pa_len);
>  			BUG_ON(!(start >= pa_end || end <= pa->pa_lstart));
>  		}
>  		spin_unlock(&pa->pa_lock);
> --
> 2.30.0

  reply	other threads:[~2023-03-13  2:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-11 17:09 [PATCH 0/2] two cleanups for mballoc Kemeng Shi
2023-03-11 17:09 ` [PATCH 1/2] ext4: fix typos in mballoc Kemeng Shi
2023-03-13  2:12   ` Ritesh Harjani
2023-03-11 17:09 ` [PATCH 2/2] ext4: avoid unnecessary pointer dereference in ext4_mb_normalize_request Kemeng Shi
2023-03-13  2:13   ` Ritesh Harjani [this message]
2023-03-17  1:52 ` [PATCH 0/2] two cleanups for mballoc Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pm9dflex.fsf@doe.com \
    --to=ritesh.list@gmail.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shikemeng@huaweicloud.com \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).