Received: by 2002:ac8:45c5:0:b0:405:464a:c27a with SMTP id e5csp1000543qto; Thu, 27 Jul 2023 01:30:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlE8TcOzHxzj2jhrkOOc5uGMo44jCwkf218dCMU3oB6nW9x/V8dLfEbgMleuZAcEZPmcSdof X-Received: by 2002:a17:906:ce:b0:993:d617:bdc2 with SMTP id 14-20020a17090600ce00b00993d617bdc2mr1383971eji.75.1690446650367; Thu, 27 Jul 2023 01:30:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690446650; cv=none; d=google.com; s=arc-20160816; b=T9pU3IvhhmSg+XiegTlnZVLpjTpG9yf8Z7JuyykMY3LTykC/l4/7xtpIzACPxwlA9s DIuoAfgd0Uvj1j+smaqDE0HV7+6oIIvjZLzZ7RNrVmh4cSt/GtBrqpnj8F25ubBr7NiF Yr34e9aBcHU/WvG8qj9VoRWgYqKv/ayM+WbuH5yOu40mG10CpduvA3hN2LniIMo/oUpx II+ukdKjNRnJqUFt29ggUNY71fSG8vcpzQUYHr/0TT1ceGw/OlTOdaK7cqe54dP3Kwtp s1WrA8m64Cq0ZxzkRLmu7S41XNZoGRvzvd4tN/aXIfSwv2SWZ2bck2xvxSVTC3+arkJt pj0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PjmSZHUI5/Kx8ZOfBbo02iydikdUH/y22dszJBbwnrc=; fh=3lDHiAuENCYj3gWFb2bYij2cH/UC7c23rwbOpuSBNc8=; b=aZ/ytV9Uxd42fKXVdRz4J7O+Rd17yT3rcrDDIeE/y8q4Tr84TCl/wORdJ3oijUNT1V 6n/LtGzdi/feR5nP+gmjYEDWn5nAA8Mw9AXp72UdsP451EfV0LirYvGtJ/AczP1wYq9U m86sWsjGuGutGHybBVTvXufE1cBUgLqSGuIIq+zdruokTrGOzZNHvf7zNOB181ELTw0I 3RuIohXAl0KSBHIgKpwvmw4Zq84y9P5u7AwFkbevQmomhYmQU1k23jm60Mb7EK64VVVx cI45k72P8r2Yf38/F2+r63Pjg3E/BZk6m5vDPXVnIfvjRvqpZKxQgliUL/JNu/+kFhg7 wN/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Xysv3RsP; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y13-20020a170906524d00b00993cc1242ccsi642237ejm.623.2023.07.27.01.30.23; Thu, 27 Jul 2023 01:30:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Xysv3RsP; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232802AbjG0I11 (ORCPT + 99 others); Thu, 27 Jul 2023 04:27:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234033AbjG0I0q (ORCPT ); Thu, 27 Jul 2023 04:26:46 -0400 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B66F2468B for ; Thu, 27 Jul 2023 01:14:08 -0700 (PDT) Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-686f6231bdeso112714b3a.1 for ; Thu, 27 Jul 2023 01:14:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690445308; x=1691050108; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PjmSZHUI5/Kx8ZOfBbo02iydikdUH/y22dszJBbwnrc=; b=Xysv3RsPsBshttSMBUyUOf01pFj7ACJomxAeSKClYNtUM/IzDnc+1qcVpxKo3Yk7lI PMJO/0QAsBuNTHH31vZSyAI+mqZzOZhxUKyEZ0z882UMy5ds0dV7wjv4n79QhgQIluxL 7aiFKUJGI5uVRXEWRoqfDwEepuojrPx+nt9lSRf3+jabTyI60DcKdVq5RfgL5+gSsYt+ gIHfo7xL/z2KDHdpCbDlWUD9Wlzvl0HFxAouF/jEEZTs97EVMQFcZk2wLBhFoNV93wDr cOODQ3G+tMDc7b4BNamRJNYxJL3PiF9jIw3/5zQqa59OSVfyqIzXn4AyZmUz4TWVr103 SUHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690445308; x=1691050108; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PjmSZHUI5/Kx8ZOfBbo02iydikdUH/y22dszJBbwnrc=; b=SBoqAM5N7fo/1YtpJ1tvLHncimqdEVonsnJaAwte2eVNN9VumH0f4mDcW84u5734nC N5w7FHdsLhWeG+e6oT9zO0wrhDPbSCye2OSPF5lVd6OXfvEABv3fZYd9frC44nHXqwMC yO6sPcnBvsb70BmG/MBCxNOHT6mgNreAniq2vztB5RZWvyUe/HhmLpE3uhtEO5el1oiQ hUOHhvQ+G6rDUwD5SCMruN8+EbrhyuXGpLak76q/x1tSixhDZ1S8D40lXW+wU/jcWcj2 HgqMQ3TD1pUuzdVoJcWOXQWjMIB0GYVaWOgMDWigOMDumCh8//4UaX/k5fBrXXxLGfPQ lHug== X-Gm-Message-State: ABy/qLb5c5XPWEnOB5/tefNUvTAuMMKPFMlziK/7D19w+13XqMiR4VUQ a1GGa6FFxSjs+NQkBMfW1XwEjQ== X-Received: by 2002:a05:6a00:4a0e:b0:677:3439:874a with SMTP id do14-20020a056a004a0e00b006773439874amr5196539pfb.3.1690445308627; Thu, 27 Jul 2023 01:08:28 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id j8-20020aa78d08000000b006828e49c04csm885872pfe.75.2023.07.27.01.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 01:08:28 -0700 (PDT) From: Qi Zheng To: akpm@linux-foundation.org, david@fromorbit.com, tkhai@ya.ru, vbabka@suse.cz, roman.gushchin@linux.dev, djwong@kernel.org, brauner@kernel.org, paulmck@kernel.org, tytso@mit.edu, steven.price@arm.com, cel@kernel.org, senozhatsky@chromium.org, yujie.liu@intel.com, gregkh@linuxfoundation.org, muchun.song@linux.dev Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org, linux-erofs@lists.ozlabs.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-nfs@vger.kernel.org, linux-mtd@lists.infradead.org, rcu@vger.kernel.org, netdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, dm-devel@redhat.com, linux-raid@vger.kernel.org, linux-bcache@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org, Qi Zheng Subject: [PATCH v3 13/49] gfs2: dynamically allocate the gfs2-qd shrinker Date: Thu, 27 Jul 2023 16:04:26 +0800 Message-Id: <20230727080502.77895-14-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230727080502.77895-1-zhengqi.arch@bytedance.com> References: <20230727080502.77895-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Use new APIs to dynamically allocate the gfs2-qd shrinker. Signed-off-by: Qi Zheng --- fs/gfs2/main.c | 6 +++--- fs/gfs2/quota.c | 26 ++++++++++++++++++++------ fs/gfs2/quota.h | 3 ++- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index afcb32854f14..e47b1cc79f59 100644 --- a/fs/gfs2/main.c +++ b/fs/gfs2/main.c @@ -147,7 +147,7 @@ static int __init init_gfs2_fs(void) if (!gfs2_trans_cachep) goto fail_cachep8; - error = register_shrinker(&gfs2_qd_shrinker, "gfs2-qd"); + error = gfs2_qd_shrinker_init(); if (error) goto fail_shrinker; @@ -196,7 +196,7 @@ static int __init init_gfs2_fs(void) fail_wq2: destroy_workqueue(gfs_recovery_wq); fail_wq1: - unregister_shrinker(&gfs2_qd_shrinker); + gfs2_qd_shrinker_exit(); fail_shrinker: kmem_cache_destroy(gfs2_trans_cachep); fail_cachep8: @@ -229,7 +229,7 @@ static int __init init_gfs2_fs(void) static void __exit exit_gfs2_fs(void) { - unregister_shrinker(&gfs2_qd_shrinker); + gfs2_qd_shrinker_exit(); gfs2_glock_exit(); gfs2_unregister_debugfs(); unregister_filesystem(&gfs2_fs_type); diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index aa5fd06d47bc..6cbf323bc4d0 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -186,13 +186,27 @@ static unsigned long gfs2_qd_shrink_count(struct shrinker *shrink, return vfs_pressure_ratio(list_lru_shrink_count(&gfs2_qd_lru, sc)); } -struct shrinker gfs2_qd_shrinker = { - .count_objects = gfs2_qd_shrink_count, - .scan_objects = gfs2_qd_shrink_scan, - .seeks = DEFAULT_SEEKS, - .flags = SHRINKER_NUMA_AWARE, -}; +static struct shrinker *gfs2_qd_shrinker; + +int __init gfs2_qd_shrinker_init(void) +{ + gfs2_qd_shrinker = shrinker_alloc(SHRINKER_NUMA_AWARE, "gfs2-qd"); + if (!gfs2_qd_shrinker) + return -ENOMEM; + + gfs2_qd_shrinker->count_objects = gfs2_qd_shrink_count; + gfs2_qd_shrinker->scan_objects = gfs2_qd_shrink_scan; + gfs2_qd_shrinker->seeks = DEFAULT_SEEKS; + + shrinker_register(gfs2_qd_shrinker); + return 0; +} + +void gfs2_qd_shrinker_exit(void) +{ + shrinker_free(gfs2_qd_shrinker); +} static u64 qd2index(struct gfs2_quota_data *qd) { diff --git a/fs/gfs2/quota.h b/fs/gfs2/quota.h index 21ada332d555..f0d54dcbbc75 100644 --- a/fs/gfs2/quota.h +++ b/fs/gfs2/quota.h @@ -59,7 +59,8 @@ static inline int gfs2_quota_lock_check(struct gfs2_inode *ip, } extern const struct quotactl_ops gfs2_quotactl_ops; -extern struct shrinker gfs2_qd_shrinker; +int __init gfs2_qd_shrinker_init(void); +void gfs2_qd_shrinker_exit(void); extern struct list_lru gfs2_qd_lru; extern void __init gfs2_quota_hash_init(void); -- 2.30.2