linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfs: return when delta equals 0 in xfs_mod_freecounter
@ 2022-06-21  3:11 Shida Zhang
  2022-06-21  4:35 ` Dave Chinner
  0 siblings, 1 reply; 3+ messages in thread
From: Shida Zhang @ 2022-06-21  3:11 UTC (permalink / raw)
  To: djwong; +Cc: zhangshida, starzhangzsd, linux-kernel, linux-xfs

There are cases that xfs_mod_freecounter() will get called when delta
equals 0 while it's unnecessary.

Signed-off-by: Shida Zhang <zhangshida@kylinos.cn>
---
 fs/xfs/xfs_mount.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index daa8d29c46b4..a3db932fd1fc 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -1129,6 +1129,9 @@ xfs_mod_freecounter(
 	if (rsvd)
 		ASSERT(has_resv_pool);
 
+	if (delta == 0)
+		return 0;
+
 	if (delta > 0) {
 		/*
 		 * If the reserve pool is depleted, put blocks back into it
-- 
2.25.1


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

* Re: [PATCH] xfs: return when delta equals 0 in xfs_mod_freecounter
  2022-06-21  3:11 [PATCH] xfs: return when delta equals 0 in xfs_mod_freecounter Shida Zhang
@ 2022-06-21  4:35 ` Dave Chinner
  2022-06-21  7:04   ` Stephen Zhang
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Chinner @ 2022-06-21  4:35 UTC (permalink / raw)
  To: Shida Zhang; +Cc: djwong, zhangshida, linux-kernel, linux-xfs

On Tue, Jun 21, 2022 at 11:11:13AM +0800, Shida Zhang wrote:
> There are cases that xfs_mod_freecounter() will get called when delta
> equals 0 while it's unnecessary.

AFAICT all of the call paths are guarded by checks to ensure the
delta is, in fact, not zero. i.e. if the delta is zero, we shouldn't
be calling xfs_mod_fdblocks() or xfs_mod_frextents() at all.

Can you explain in more detail what code path leads to delta = 0
here?

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH] xfs: return when delta equals 0 in xfs_mod_freecounter
  2022-06-21  4:35 ` Dave Chinner
@ 2022-06-21  7:04   ` Stephen Zhang
  0 siblings, 0 replies; 3+ messages in thread
From: Stephen Zhang @ 2022-06-21  7:04 UTC (permalink / raw)
  To: Dave Chinner; +Cc: djwong, zhangshida, linux-kernel, linux-xfs

Dave Chinner <david@fromorbit.com> 于2022年6月21日周二 12:35写道:
>
> On Tue, Jun 21, 2022 at 11:11:13AM +0800, Shida Zhang wrote:
> > There are cases that xfs_mod_freecounter() will get called when delta
> > equals 0 while it's unnecessary.
>
> AFAICT all of the call paths are guarded by checks to ensure the
> delta is, in fact, not zero. i.e. if the delta is zero, we shouldn't
> be calling xfs_mod_fdblocks() or xfs_mod_frextents() at all.
>
> Can you explain in more detail what code path leads to delta = 0
> here?
>
> Cheers,
>
> Dave.
> --
> Dave Chinner
> david@fromorbit.com

Yeah. I will give it in another v2 version patch.

Cheers,

Stephen.

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

end of thread, other threads:[~2022-06-21  7:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-21  3:11 [PATCH] xfs: return when delta equals 0 in xfs_mod_freecounter Shida Zhang
2022-06-21  4:35 ` Dave Chinner
2022-06-21  7:04   ` Stephen Zhang

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).