2021-05-22 10:22:29

by Zhang Yi

[permalink] [raw]
Subject: [PATCH 0/2] ext4: fix two minor mistakes in ext4_es_scan()

Fix two minor mistakes introduced by 1ab6c4997e04 ("fs: convert fs
shrinkers to new scan/count API") in ext4_es_scan().

Zhang Yi (2):
ext4: remove check for zero nr_to_scan in ext4_es_scan()
ext4: correct the cache_nr in tracepoint ext4_es_shrink_exit

fs/ext4/extents_status.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

--
2.25.4


2021-05-22 10:22:50

by Zhang Yi

[permalink] [raw]
Subject: [PATCH 1/2] ext4: remove check for zero nr_to_scan in ext4_es_scan()

After converting fs shrinkers to new scan/count API, we are no longer
pass zero nr_to_scan parameter to detect the number of objects to free,
just remove this check.

Fixes: 1ab6c4997e04 ("fs: convert fs shrinkers to new scan/count API")
Cc: [email protected] # 3.12+
Signed-off-by: Zhang Yi <[email protected]>
---
fs/ext4/extents_status.c | 3 ---
1 file changed, 3 deletions(-)

diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
index 0a729027322d..db3cd70a72e4 100644
--- a/fs/ext4/extents_status.c
+++ b/fs/ext4/extents_status.c
@@ -1574,9 +1574,6 @@ static unsigned long ext4_es_scan(struct shrinker *shrink,
ret = percpu_counter_read_positive(&sbi->s_es_stats.es_stats_shk_cnt);
trace_ext4_es_shrink_scan_enter(sbi->s_sb, nr_to_scan, ret);

- if (!nr_to_scan)
- return ret;
-
nr_shrunk = __es_shrink(sbi, nr_to_scan, NULL);

trace_ext4_es_shrink_scan_exit(sbi->s_sb, nr_shrunk, ret);
--
2.25.4

2021-05-22 10:24:17

by Zhang Yi

[permalink] [raw]
Subject: [PATCH 2/2] ext4: correct the cache_nr in tracepoint ext4_es_shrink_exit

The cache_cnt parameter of tracepoint ext4_es_shrink_exit means the
remaining cache count after shrink, but now it is the cache count before
shrink, fix it by read sbi->s_extent_cache_cnt again.

Fixes: 1ab6c4997e04 ("fs: convert fs shrinkers to new scan/count API")
Cc: [email protected] # 3.12+
Signed-off-by: Zhang Yi <[email protected]>
---
fs/ext4/extents_status.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
index db3cd70a72e4..9a3a8996aacf 100644
--- a/fs/ext4/extents_status.c
+++ b/fs/ext4/extents_status.c
@@ -1576,6 +1576,7 @@ static unsigned long ext4_es_scan(struct shrinker *shrink,

nr_shrunk = __es_shrink(sbi, nr_to_scan, NULL);

+ ret = percpu_counter_read_positive(&sbi->s_es_stats.es_stats_shk_cnt);
trace_ext4_es_shrink_scan_exit(sbi->s_sb, nr_shrunk, ret);
return nr_shrunk;
}
--
2.25.4

2021-05-24 09:53:24

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH 1/2] ext4: remove check for zero nr_to_scan in ext4_es_scan()

On Sat 22-05-21 18:30:44, Zhang Yi wrote:
> After converting fs shrinkers to new scan/count API, we are no longer
> pass zero nr_to_scan parameter to detect the number of objects to free,
> just remove this check.
>
> Fixes: 1ab6c4997e04 ("fs: convert fs shrinkers to new scan/count API")
> Cc: [email protected] # 3.12+
> Signed-off-by: Zhang Yi <[email protected]>

Looks good. Thanks for the patch. Feel free to add:

Reviewed-by: Jan Kara <[email protected]>

Honza

> ---
> fs/ext4/extents_status.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
> index 0a729027322d..db3cd70a72e4 100644
> --- a/fs/ext4/extents_status.c
> +++ b/fs/ext4/extents_status.c
> @@ -1574,9 +1574,6 @@ static unsigned long ext4_es_scan(struct shrinker *shrink,
> ret = percpu_counter_read_positive(&sbi->s_es_stats.es_stats_shk_cnt);
> trace_ext4_es_shrink_scan_enter(sbi->s_sb, nr_to_scan, ret);
>
> - if (!nr_to_scan)
> - return ret;
> -
> nr_shrunk = __es_shrink(sbi, nr_to_scan, NULL);
>
> trace_ext4_es_shrink_scan_exit(sbi->s_sb, nr_shrunk, ret);
> --
> 2.25.4
>
--
Jan Kara <[email protected]>
SUSE Labs, CR

2021-05-24 09:54:40

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH 2/2] ext4: correct the cache_nr in tracepoint ext4_es_shrink_exit

On Sat 22-05-21 18:30:45, Zhang Yi wrote:
> The cache_cnt parameter of tracepoint ext4_es_shrink_exit means the
> remaining cache count after shrink, but now it is the cache count before
> shrink, fix it by read sbi->s_extent_cache_cnt again.
>
> Fixes: 1ab6c4997e04 ("fs: convert fs shrinkers to new scan/count API")
> Cc: [email protected] # 3.12+
> Signed-off-by: Zhang Yi <[email protected]>

Yeah, probably it is better this way. Feel free to add:

Reviewed-by: Jan Kara <[email protected]>

Honza

> ---
> fs/ext4/extents_status.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
> index db3cd70a72e4..9a3a8996aacf 100644
> --- a/fs/ext4/extents_status.c
> +++ b/fs/ext4/extents_status.c
> @@ -1576,6 +1576,7 @@ static unsigned long ext4_es_scan(struct shrinker *shrink,
>
> nr_shrunk = __es_shrink(sbi, nr_to_scan, NULL);
>
> + ret = percpu_counter_read_positive(&sbi->s_es_stats.es_stats_shk_cnt);
> trace_ext4_es_shrink_scan_exit(sbi->s_sb, nr_shrunk, ret);
> return nr_shrunk;
> }
> --
> 2.25.4
>
--
Jan Kara <[email protected]>
SUSE Labs, CR

2021-06-17 21:32:31

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH 1/2] ext4: remove check for zero nr_to_scan in ext4_es_scan()

On Sat, May 22, 2021 at 06:30:44PM +0800, Zhang Yi wrote:
> After converting fs shrinkers to new scan/count API, we are no longer
> pass zero nr_to_scan parameter to detect the number of objects to free,
> just remove this check.
>
> Fixes: 1ab6c4997e04 ("fs: convert fs shrinkers to new scan/count API")
> Cc: [email protected] # 3.12+
> Signed-off-by: Zhang Yi <[email protected]>

Thanks, applied.

- Ted

2021-06-17 21:33:00

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH 2/2] ext4: correct the cache_nr in tracepoint ext4_es_shrink_exit

On Sat, May 22, 2021 at 06:30:45PM +0800, Zhang Yi wrote:
> The cache_cnt parameter of tracepoint ext4_es_shrink_exit means the
> remaining cache count after shrink, but now it is the cache count before
> shrink, fix it by read sbi->s_extent_cache_cnt again.
>
> Fixes: 1ab6c4997e04 ("fs: convert fs shrinkers to new scan/count API")
> Cc: [email protected] # 3.12+
> Signed-off-by: Zhang Yi <[email protected]>

Thanks, applied.

- Ted