From patchwork Thu Jul 27 08:04:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13329203 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9780AC04E69 for ; Thu, 27 Jul 2023 08:08:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 378666B0085; Thu, 27 Jul 2023 04:08:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3270D6B0087; Thu, 27 Jul 2023 04:08:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C9FF8D0001; Thu, 27 Jul 2023 04:08:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 0F4B56B0085 for ; Thu, 27 Jul 2023 04:08:56 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D6096160FDE for ; Thu, 27 Jul 2023 08:08:55 +0000 (UTC) X-FDA: 81056665830.10.BD292A9 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf19.hostedemail.com (Postfix) with ESMTP id F14BA1A000E for ; Thu, 27 Jul 2023 08:08:53 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=fVbo4B1S; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf19.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690445334; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9TzzNXWnGUC4v0Im6lZC1fetjV0NX81rj7dQA53Eb1w=; b=VfUSqQGv2bZk1AJs1tGVnS5kz6F7Cb7Cs1u5X+1SMAmZe44Q8jISRHy0VjonWyy5LAZoAY CedZmn7QQ3Xvh7XB4diBiKu2lLiKQh0mxhl2wOX/IwxNIBeEl1Li/JStYcR6RRcerDABne D2FVPjhOs5LB/UxtR1wSTOtnSYCl7m4= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=fVbo4B1S; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf19.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690445334; a=rsa-sha256; cv=none; b=Rc5ZgNiffVAB7U6IB9KG52QJdukcPboxLTYsPvxMGsXahQWzKMoURmaf/BW6ZiusrvdgtC TTWMmqkh9Vs89uOd2tVPyQbLk49MQuLPh80WxjWLTWahqE2JIpp/OyiG04nvhtpphuwoed C+XbH4Y2AUUWfSDM83BDQrSr7MQihtg= Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-686f74a8992so77598b3a.1 for ; Thu, 27 Jul 2023 01:08:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690445332; x=1691050132; 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=9TzzNXWnGUC4v0Im6lZC1fetjV0NX81rj7dQA53Eb1w=; b=fVbo4B1Sn0AGX1nNJK0Eo1gukSsful8PC6Tpi9R2ay4P+tk9frdioPsIm2s6rPxi46 ++BpYvSQrpfhaqWc0rmuBFjQPz0zzH5N+AGXb67rsChsvEkjfu687Mjmoln0lCJnbS1t S6gxfZ/pYInNuKorknrCkgDtrsNJQ+5b+KQpVkQdCPQpNRB6D3agySMM3uM99/xhPotu rAoYyPnK20sDnc7vY5XomSSW5p6ngHpl0qbTjtgeFdhf5V6H8EL0+GE/5QBEhSY2aRe8 CqIfoMbQ3ZACqieIYGVBf+Lq9zLueZGm5ISvf4EF/2FFF37Zi67sB1q+1Y4ZesHEzWZS zb1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690445332; x=1691050132; 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=9TzzNXWnGUC4v0Im6lZC1fetjV0NX81rj7dQA53Eb1w=; b=W2JucjnrdFIOj+NEGtDfDnv+ByyEftlMDhfMVcfidoXeVvsYnnr84q4cnwVKyExKqm k/sJ2p8d2ELiwsMNHR20X7O76aGjJyBXHnayRBVGjj4CPOwBwyucn8tPr02D1ZMzN1MJ 9sNxNMZSOFWpKxVm3X3Asn1pkJ/U3cyJn/CG+Sy75P4v+CzafdzeegHNyDhwaol+kU8+ u7hRhzAGV8tnIOIK9IqHBj9qxL77Vt1PkSMV1G8Asxde9YcJsPuyJ/a+ydUNptGR4gy5 r0g6vQaJJIs1HRxq2/qXaDzTQiT0GE/MEEUODBvawqdThy8UwLINrb4NSzn1ckXosV+j j1aw== X-Gm-Message-State: ABy/qLbPOEvIPkXXN3uupsXGEWqZSF9Dmx9r1WJ1Z7AWzyqURg7eAnDU 7v9VuKfItlzCVoat4YJK5LyTWw== X-Google-Smtp-Source: APBJJlFfoYzSpk6JWYRi+8IvWqqU5f15Mb/GG4zvV09auI3h1+KA8DLVYcizqJGa8aoS7uGFfDYCtA== X-Received: by 2002:a05:6a00:488e:b0:677:bb4c:c321 with SMTP id dk14-20020a056a00488e00b00677bb4cc321mr4639246pfb.0.1690445332713; Thu, 27 Jul 2023 01:08:52 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 01:08:52 -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 , Muchun Song Subject: [PATCH v3 15/49] nfs: dynamically allocate the nfs-acl shrinker Date: Thu, 27 Jul 2023 16:04:28 +0800 Message-Id: <20230727080502.77895-16-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 X-Rspamd-Queue-Id: F14BA1A000E X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: rrn55ebobxuzke73gq5f45coe7pme8q9 X-HE-Tag: 1690445333-416610 X-HE-Meta: U2FsdGVkX18YviimhaiPAyq8N+km82hBv2pAqlwoLyc4UQAlBeelrtjTRKvpknlDBq4DGjfa+15Um72Vr+diaIIcf7HBefhN7kDypmYBzNNaurMzX/FZhnNyG/ytp20WE8nX5G+K3JrIQE52ApyO+0xRxBTdytjWb7ZiO+iw8ZrQs7mjI7l3lIryKkHnMdzdlt6duHXSGCDv52kfg3VhalBGEqGurWzAzUHksZTnu0BLFmXxgAZ9CzjL3jLgqNzEPfhyEyoW04j09JEWhKTQs56ZFecjLTxxJ/+83XGaMJoxznMrHvEMcDEMD7cslzF3+HbfKkSq6yTeCu/eiBnPRB0UZKxry331isScF2p11p5wVe7NthyWr6OMFboaxZhBTVUEBwOBVMFPfy909PDm85qUBWkQ+zExXVWjy8Vf1Eud6vZFZCTl3u1N5ewRCQ40zKNVJN+b48rOGs5xUiZYlIgAoQyTKPMoUbRVkCvlLASgTQV0eJGcPYknrddrr53FjQ/aCyfRnT8ciQEJqH4NoEwdkPXBdMExsqY5tUflhIiZJiOmT58aq+0EStzjonC09UjfDuAHt2cugDS2YrkXEnRVMLcnmnVURBAsa/YrzkhWSzyUu2aLMebOAZyngv+TNsp8Bs4wOP884PhhIgYErW7m264n2AzhPnXL4Ztigk2u1BMGgwnYZxyj/rTO+DAlkJjnYEs1pCu0n76MeudtuQFJUx+gLcBq7Xg3kIfnTTqCFvP9oSAEwKrhaGmIhXK+9O4/zmA0Ti54MOFwCMq4antvwJgbp/jRpXMHCZWU1biMdlle3tk1+o60kGd+qeHGJSk3EdRLTYmwTIemoCRjrDcEZiFQ/excJcZq5yNBy7n09KD+zJo0oMP8dipdwMgxxEcTQc7v0wIUcJsFIGio9WUPhQUPVFSAhpxkzIradlEWjzMIkXQTOklDtqlni079pTjFhXfjMUOD+bt6yxb G6LTzNyo xCscO4ImXdfD//djoivcenmeOD+eCH2PZvJ2J6T3ZLm50buI3bJEV/tIQcXiRgogEYCBL7H9LabJM9KoasNSd8QYNaJJAhzGTrd2yoq4Z0fyIgFDYFJ0fyim8wfezug55mAnqf5MgMvv2cubTDpflFcUMvRwROr5N5Bf6h55W+aDtpuQb2tkMw3ehFu9SfS2DkmDw5hTGMrEIrEsgt4nukC9aC852Q/SxUZpLy8mbQTWmNjgc65ioKvEqI0x48UYwRSW2wBnVeuQ9LeAToriqPZsy7mm8IYu0t1ZPCDgknPzBhSPM7VIWspFxUou+oDUD6dGhzQh2cNXbqCIVu9U5JXKjOvNRuAaxfIsqtwjzU2FOeyJOzSEBiactVc6f+qWdhRmiD4vZRODIOccmlzGgFZ2Zdb4OB8nYPNCn X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Use new APIs to dynamically allocate the nfs-acl shrinker. Signed-off-by: Qi Zheng Reviewed-by: Muchun Song --- fs/nfs/super.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 2284f749d892..072d82e1be06 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -129,11 +129,7 @@ static void nfs_ssc_unregister_ops(void) } #endif /* CONFIG_NFS_V4_2 */ -static struct shrinker acl_shrinker = { - .count_objects = nfs_access_cache_count, - .scan_objects = nfs_access_cache_scan, - .seeks = DEFAULT_SEEKS, -}; +static struct shrinker *acl_shrinker; /* * Register the NFS filesystems @@ -153,9 +149,17 @@ int __init register_nfs_fs(void) ret = nfs_register_sysctl(); if (ret < 0) goto error_2; - ret = register_shrinker(&acl_shrinker, "nfs-acl"); - if (ret < 0) + + acl_shrinker = shrinker_alloc(0, "nfs-acl"); + if (!acl_shrinker) goto error_3; + + acl_shrinker->count_objects = nfs_access_cache_count; + acl_shrinker->scan_objects = nfs_access_cache_scan; + acl_shrinker->seeks = DEFAULT_SEEKS; + + shrinker_register(acl_shrinker); + #ifdef CONFIG_NFS_V4_2 nfs_ssc_register_ops(); #endif @@ -175,7 +179,7 @@ int __init register_nfs_fs(void) */ void __exit unregister_nfs_fs(void) { - unregister_shrinker(&acl_shrinker); + shrinker_free(acl_shrinker); nfs_unregister_sysctl(); unregister_nfs4_fs(); #ifdef CONFIG_NFS_V4_2