Skip to contentSkip to conversation

ext4: fix two minor mistakes in ext4_es_scan()

PATCH Applied Zhang Yi 3 participants 7 messages May 22, 2021 – Jun 17, 2021 ext4 file system

lore
Share & tools
lore

Zhang Yi

author reviewer
#0 lore raw

cover 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(-)
Signature · 1 line
2.25.4
author reviewer
#1 lore raw

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")
---
 fs/ext4/extents_status.c | 3 ---
 1 file changed, 3 deletions(-)
fs/ext4/extents_status.c +0 -3
index 0a729027322d..db3cd70a72e4 100644
@@ -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);
Signature · 1 line
2.25.4
reviewer Reviewed-by on v1 1/2
#2 lore raw

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

Quoted 7 lines · Zhang Yi

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

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

Honza

Quoted 21 lines
---
 fs/ext4/extents_status.c | 3 ---
 1 file changed, 3 deletions(-)
fs/ext4/extents_status.c +0 -3
index 0a729027322d..db3cd70a72e4 100644
@@ -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);
Signature · 1 line
2.25.4
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
maintainer Applied
#3 lore raw

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

In reply to Zhang Yi
Quoted 7 lines · Zhang Yi

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

Thanks, applied.

- Ted

author reviewer
#4 lore raw

PATCH 2/2 ext4: correct the cache_nr in tracepoint ext4_es_shrink_exit

In reply to Zhang Yi

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")
---
 fs/ext4/extents_status.c | 1 +
 1 file changed, 1 insertion(+)
fs/ext4/extents_status.c +1 -0
index db3cd70a72e4..9a3a8996aacf 100644
@@ -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;
 }
Signature · 1 line
2.25.4
reviewer Reviewed-by on v1 2/2
#5 lore raw

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

Quoted 7 lines · Zhang Yi

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

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

Honza

Quoted 19 lines
---
 fs/ext4/extents_status.c | 1 +
 1 file changed, 1 insertion(+)
fs/ext4/extents_status.c +1 -0
index db3cd70a72e4..9a3a8996aacf 100644
@@ -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;
 }
Signature · 1 line
2.25.4
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
maintainer Applied
#6 lore raw

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

In reply to Zhang Yi
Quoted 7 lines · Zhang Yi

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

Thanks, applied.

- Ted