Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2884762rwo; Mon, 24 Jul 2023 02:54:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlEYzzHE5I2MPoDwiLJog2ajlTXlWgOPWlaL1IADApALBXmiToTBTiCzA60D17L9SC5A6mFm X-Received: by 2002:a05:6402:1349:b0:51b:d567:cfed with SMTP id y9-20020a056402134900b0051bd567cfedmr8768957edw.5.1690192481360; Mon, 24 Jul 2023 02:54:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690192481; cv=none; d=google.com; s=arc-20160816; b=0rr0nO909BAKM357by5eG5ubhrfKIc6r7bzFu+Fnw7zgMVSvZ3NvJBS4+LV2gjfxRJ ke2JkQTgD+TlA8x3xMddoVR5iG6CVlpgA9YQO1WG7qc93Ltik30jVuQQhp4Gp/dxz1mG hHA4VTQxO55BycXuXCFap78G06x9DHcHU+DcGn1k9kqmwTstBf3ORPtXoHd6wsnfnXWk f4V1MjBVlVHqMJzqqerPPjVnfClah+RQDqLds2RvNAr97xdAsYhkW7Gvkz9SixdUlpTD A6MrYAbe3KCrV9eFOucvudbSFo+mOt/EDx+ikf2S9xr8lFbYY4kjaVh3905gbhF9g0wE vXjA== 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=ztwb9n/1dXh113w/8xubUIoix8VXd/5rqVT4RvFn/tw=; fh=3lDHiAuENCYj3gWFb2bYij2cH/UC7c23rwbOpuSBNc8=; b=mUBoHn7C2jd9n/2lQrFLWPmQ7BurxlgzcHDjEYzRiXE/MeLfGfzV7dJwzQe+Obrg5k GnbKbPx17HBPKbHnSwnRpowFp6M57+8e+L/SlN9Cikf7SjvpyRjXKHsIX4L4ovgqqiCC oDMnAkgZIuW8IIG7OaPuo62xP71XDHlSCZ3XMLuA6Mkoc+b9q9Adghgc/BNAowFHwb5W evsMljkLZN/431kV+EXH5vJ4znHGWgvmqwVpvw49HjBxZM1B87mndQ9XSj7X8b0irTDH gAtTtfF8Ob76l33ejEcYuwryG5bCR3Yaj2VB4uqXyXamEx5fodJKVljBlBijJxi2/LAn i0Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Am7FnjS3; 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 z25-20020aa7cf99000000b0051e04f1bd62si6350747edx.199.2023.07.24.02.54.16; Mon, 24 Jul 2023 02:54:41 -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=Am7FnjS3; 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 S232359AbjGXJwi (ORCPT + 99 others); Mon, 24 Jul 2023 05:52:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232011AbjGXJwU (ORCPT ); Mon, 24 Jul 2023 05:52:20 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFCF93C06 for ; Mon, 24 Jul 2023 02:48:37 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-51f64817809so327782a12.1 for ; Mon, 24 Jul 2023 02:48:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690192086; x=1690796886; 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=ztwb9n/1dXh113w/8xubUIoix8VXd/5rqVT4RvFn/tw=; b=Am7FnjS3Cpm4I6+unn47wV0WInP35j7cWyw7YSHmXYddBbEndaPLIOhBD501lhuXhz ziS0uq23cHOpl1MZygPYTe8AuNvoAdPlGK8k32I3Ef9lRu2tiO1YjBbYZCD1R2rMLxT1 sbS7mgch7/EfOaLRKT3V6tvhfJSY21ngFnqMEHN8grEnjoqg0M6Q11qf7CVQTrHQJzW3 E1Q+qRl3oeLAaumIkMGruzrANQhf6ocLGFa54JS2CwGaWbDUA2Re4gbZJ2jDKM9ntSrw dCSeZvHulgVnMl/ivIn59gXFxJS3Mnbl4ERIMhlA37amtawTgx9ciEfDapqLjZzr2ZBw AsLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690192086; x=1690796886; 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=ztwb9n/1dXh113w/8xubUIoix8VXd/5rqVT4RvFn/tw=; b=RzRYGVTtx9P8IF5yGzSwNdy/26PwXEkBU5w0RiHN0fnYdtRPAWko1JyqS/6PePchPA YYcF4vLLBg3Wyk0+dxkDTaV3Y53exvmsRjJu83FOA4dZd0orq3fnrzdsudIibT2rnMTS nD9Y+5zLLIc7D9zz6Rf0LRJJBlGeHYmZph/W/TQxTlfZxtr3wmv7y4mbqwd+Qk/NMN/e 3vpNwf/DUn0VtDoUulV4Gr9oLO802X5EsQVwx/DZaNMBT9zPTZOyy/v0Kp82g68t3Scv HYqWK31LpnFhf4is4Cz5MuWV9KrktMwA0KaNp4LOb4yrr6yYu0Ls5Hr5E+m7H3E+bXvY 7F5Q== X-Gm-Message-State: ABy/qLZQMS4rIlT07z88tEIHtaBZSKlvhKxXKbVfX2hiM9qSQkRFNEKB 4Syd3wmhLLxr7doBdKKi4rmnCg== X-Received: by 2002:a17:902:dad1:b0:1b8:aded:524c with SMTP id q17-20020a170902dad100b001b8aded524cmr12538511plx.1.1690192086608; Mon, 24 Jul 2023 02:48:06 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id d5-20020a170902c18500b001bb20380bf2sm8467233pld.13.2023.07.24.02.47.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 02:48:06 -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 v2 15/47] quota: dynamically allocate the dquota-cache shrinker Date: Mon, 24 Jul 2023 17:43:22 +0800 Message-Id: <20230724094354.90817-16-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230724094354.90817-1-zhengqi.arch@bytedance.com> References: <20230724094354.90817-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, SPF_HELO_NONE,SPF_PASS,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 dquota-cache shrinker. Signed-off-by: Qi Zheng --- fs/quota/dquot.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index e8232242dd34..6cb2d8911bc3 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -791,11 +791,7 @@ 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, -}; +static struct shrinker *dqcache_shrinker; /* * Safely release dquot and put reference to dquot. @@ -2991,8 +2987,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