diff mbox series

[v5,13/45] quota: dynamically allocate the dquota-cache shrinker

Message ID 20230824034304.37411-14-zhengqi.arch@bytedance.com (mailing list archive)
State New
Headers show
Series use refcount+RCU method to implement lockless slab shrink | expand

Commit Message

Qi Zheng Aug. 24, 2023, 3:42 a.m. UTC
Use new APIs to dynamically allocate the dquota-cache shrinker.

Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
CC: Jan Kara <jack@suse.com>
---
 fs/quota/dquot.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

Comments

Jan Kara Aug. 24, 2023, 9:51 a.m. UTC | #1
On Thu 24-08-23 11:42:32, Qi Zheng wrote:
> Use new APIs to dynamically allocate the dquota-cache shrinker.
> 
> Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
> Reviewed-by: Muchun Song <songmuchun@bytedance.com>
> CC: Jan Kara <jack@suse.com>

Looks good to me. Feel free to add:

Acked-by: Jan Kara <jack@suse.cz>

								Honza



> ---
>  fs/quota/dquot.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
> index 9e72bfe8bbad..c303cffdf433 100644
> --- a/fs/quota/dquot.c
> +++ b/fs/quota/dquot.c
> @@ -791,12 +791,6 @@ dqcache_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
>  	percpu_counter_read_positive(&dqstats.counter[DQST_FREE_DQUOTS]));
>  }
>  
> -static struct shrinker dqcache_shrinker = {
> -	.count_objects = dqcache_shrink_count,
> -	.scan_objects = dqcache_shrink_scan,
> -	.seeks = DEFAULT_SEEKS,
> -};
> -
>  /*
>   * Safely release dquot and put reference to dquot.
>   */
> @@ -2956,6 +2950,7 @@ static int __init dquot_init(void)
>  {
>  	int i, ret;
>  	unsigned long nr_hash, order;
> +	struct shrinker *dqcache_shrinker;
>  
>  	printk(KERN_NOTICE "VFS: Disk quotas %s\n", __DQUOT_VERSION__);
>  
> @@ -2990,8 +2985,15 @@ static int __init dquot_init(void)
>  	pr_info("VFS: Dquot-cache hash table entries: %ld (order %ld,"
>  		" %ld bytes)\n", nr_hash, order, (PAGE_SIZE << order));
>  
> -	if (register_shrinker(&dqcache_shrinker, "dquota-cache"))
> -		panic("Cannot register dquot shrinker");
> +	dqcache_shrinker = shrinker_alloc(0, "dquota-cache");
> +	if (!dqcache_shrinker)
> +		panic("Cannot allocate dquot shrinker");
> +
> +	dqcache_shrinker->count_objects = dqcache_shrink_count;
> +	dqcache_shrinker->scan_objects = dqcache_shrink_scan;
> +	dqcache_shrinker->seeks = DEFAULT_SEEKS;
> +
> +	shrinker_register(dqcache_shrinker);
>  
>  	return 0;
>  }
> -- 
> 2.30.2
>
diff mbox series

Patch

diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 9e72bfe8bbad..c303cffdf433 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -791,12 +791,6 @@  dqcache_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
 	percpu_counter_read_positive(&dqstats.counter[DQST_FREE_DQUOTS]));
 }
 
-static struct shrinker dqcache_shrinker = {
-	.count_objects = dqcache_shrink_count,
-	.scan_objects = dqcache_shrink_scan,
-	.seeks = DEFAULT_SEEKS,
-};
-
 /*
  * Safely release dquot and put reference to dquot.
  */
@@ -2956,6 +2950,7 @@  static int __init dquot_init(void)
 {
 	int i, ret;
 	unsigned long nr_hash, order;
+	struct shrinker *dqcache_shrinker;
 
 	printk(KERN_NOTICE "VFS: Disk quotas %s\n", __DQUOT_VERSION__);
 
@@ -2990,8 +2985,15 @@  static int __init dquot_init(void)
 	pr_info("VFS: Dquot-cache hash table entries: %ld (order %ld,"
 		" %ld bytes)\n", nr_hash, order, (PAGE_SIZE << order));
 
-	if (register_shrinker(&dqcache_shrinker, "dquota-cache"))
-		panic("Cannot register dquot shrinker");
+	dqcache_shrinker = shrinker_alloc(0, "dquota-cache");
+	if (!dqcache_shrinker)
+		panic("Cannot allocate dquot shrinker");
+
+	dqcache_shrinker->count_objects = dqcache_shrink_count;
+	dqcache_shrinker->scan_objects = dqcache_shrink_scan;
+	dqcache_shrinker->seeks = DEFAULT_SEEKS;
+
+	shrinker_register(dqcache_shrinker);
 
 	return 0;
 }