From patchwork Tue Aug 7 15:38:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10558815 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7BDFC157D for ; Tue, 7 Aug 2018 15:38:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69F9C2A464 for ; Tue, 7 Aug 2018 15:38:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C46C2A46E; Tue, 7 Aug 2018 15:38:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4CAC2A464 for ; Tue, 7 Aug 2018 15:38:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403839AbeHGRxf (ORCPT ); Tue, 7 Aug 2018 13:53:35 -0400 Received: from mail-eopbgr40138.outbound.protection.outlook.com ([40.107.4.138]:42249 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387578AbeHGRxf (ORCPT ); Tue, 7 Aug 2018 13:53:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rjLeLihaI+2XAryE8IBKttfF8XLlJtjoquTPBZciGHM=; b=SNitA1nHzY+fSEk9kgdqk7FWwpMkmXzOtEhwtAd0CcDs+sd9ztZR5m15PJSdfDU27KkAbnisvmN+ziOqepMIXj9iwYFbOavOKPcS9vub018J6Trn2+pZIYxfZhJrlvHMFZnGyn5uveZxzx2LhAuWG9eHoW2p3Ur8SzbsS7NCsoo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Received: from localhost.localdomain (185.231.240.5) by VI1PR0801MB2030.eurprd08.prod.outlook.com (2603:10a6:800:8b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.15; Tue, 7 Aug 2018 15:38:27 +0000 Subject: [PATCH RFC 05/10] fs: Move list_lru_destroy() to destroy_super_work() From: Kirill Tkhai To: akpm@linux-foundation.org, gregkh@linuxfoundation.org, rafael@kernel.org, viro@zeniv.linux.org.uk, darrick.wong@oracle.com, paulmck@linux.vnet.ibm.com, josh@joshtriplett.org, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com, hughd@google.com, shuah@kernel.org, robh@kernel.org, ulf.hansson@linaro.org, aspriel@gmail.com, vivek.gautam@codeaurora.org, robin.murphy@arm.com, joe@perches.com, heikki.krogerus@linux.intel.com, ktkhai@virtuozzo.com, sfr@canb.auug.org.au, vdavydov.dev@gmail.com, mhocko@suse.com, chris@chris-wilson.co.uk, penguin-kernel@I-love.SAKURA.ne.jp, aryabinin@virtuozzo.com, willy@infradead.org, ying.huang@intel.com, shakeelb@google.com, jbacik@fb.com, mingo@kernel.org, mhiramat@kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Date: Tue, 07 Aug 2018 18:38:23 +0300 Message-ID: <153365630328.19074.5326096793225967868.stgit@localhost.localdomain> In-Reply-To: <153365347929.19074.12509495712735843805.stgit@localhost.localdomain> References: <153365347929.19074.12509495712735843805.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 X-Originating-IP: [185.231.240.5] X-ClientProxiedBy: AM0PR02CA0029.eurprd02.prod.outlook.com (2603:10a6:208:3e::42) To VI1PR0801MB2030.eurprd08.prod.outlook.com (2603:10a6:800:8b::11) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 535b2c34-803b-493e-31b8-08d5fc7bd3f8 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:VI1PR0801MB2030; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB2030;3:vP4s6+o13YMo+jE4eLKJudDTNTpU3qf5LPU0PDe2VBHt0aLjg0ojRu5/V7+QBsHK2PZIoEjOxAzzj7Gw5kGpgugYwL7L3GU9ortWVwNega/CD3XOC1T66o99jtBsXe+donK+VZmhdR+oTbURZdaZiDPwZsQRqaiGrjleUlTNd5z1pXKXPGQKpeOFPNAcEPflWysy4M1aK5LvOBmLdhmyI1Cf8jjowy0ziZ3djy1BlNf9h2NidAIOEYHZ5P1TFicF;25:8yKSQzcuV9rzdACbV4nlke5ULHDs+ZbX93ih+bUrOQz/dk+qBlL4akeSlT2/mrlcXW2lRk6dbnskGC3439r32lBBmuxcN04IYojhwBOxXBiU7Lcmebr77JJw3Cb5TCAe3CHzm+JcOMlIwQTa0w/PGau3/m/N4hV3St2A1Siu/koKSItPYCjNA4QopwswkR2ShkDo1plN5zb2Nv7dCHUc+20XtIlNd56OlabdqORChLMl4NGBBYedVK7pUrgckw2RsDGipOlyTvfRnafko7IL3aBCaYWAzJoeN43xUhZe0WkOdOjWxkghthyly1xK98QOx2W7y64RpfrQHTcgaUZjKQ==;31:/f3lgy4jc5cyd+4vrLuCoXT91qEaaX+Y+mlICZBXIG7UxgBuY/xEDeT7HvRzYMJ5yMRigfRd1usyI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VS: X-Exchange-Antispam-Report-Test: UriScan:(192374486261705); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011)(7699016);SRVR:VI1PR0801MB2030;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0801MB2030; X-Forefront-PRVS: 0757EEBDCA X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6069001)(39850400004)(396003)(366004)(346002)(376002)(136003)(189003)(199004)(6506007)(16526019)(386003)(6666003)(7406005)(7416002)(106356001)(105586002)(5660300001)(97736004)(47776003)(66066001)(61506002)(55016002)(9686003)(217873002)(26005)(14444005)(53936002)(39060400002)(956004)(486006)(2906002)(25786009)(11346002)(446003)(186003)(476003)(33896004)(478600001)(50466002)(305945005)(3846002)(6116002)(8936002)(7736002)(81156014)(8676002)(81166006)(230700001)(76176011)(7696005)(52116002)(86362001)(58126008)(316002)(103116003)(68736007)(2486003)(23676004)(921003)(1121003);DIR:OUT;SFP:1102;SCL:1;SRVR:VI1PR0801MB2030;H:localhost.localdomain;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BVI1PR0801MB2030=3B23=3AOCmS3?= =?utf-8?q?4hzyvBMfaNlQ4EDpCmflHvLibhbVc5Pk0KwLO66gb395pqr03D7sf6lUp0A1BqL9q?= =?utf-8?q?wMl9CFVaMDDLfNiLnWu1U1BkSR+lrgJzcW77PKiVczOIfQ2XllwwrrjXFToSi//d1?= =?utf-8?q?UwmpIdPnRa7nGMtvxWKAA/PA/dY5VGS2dkLYGY6+hgd/N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0P0zILd8fYjhTL3TDiu?= =?utf-8?q?HuyikHYNF14ji58biJecCazG7XbSuWeRbJt+iFSoJ9nmx78hDAZLaMJj3Rzf5PA8o?= =?utf-8?q?wtGNy1t37uCX30QEzYPhQBL73hGHiSSt4Hd+Y1m02udeYkL2xYqgufmYXYwOJGs9g?= =?utf-8?q?bvlbzxauBUoKXDyEJ8+QHfvL3zhzDTf7d8dUrKwSw3WImRkxqA8dkCMhHM+XaJPuS?= =?utf-8?q?E6zw9OMFHu8Xovh6dlA7eYNb1Op0gmcH2Ax0P9A?= X-Microsoft-Antispam-Message-Info: RgxmoDmjw4NfngBWtKVQxW+6L3bCHVWF58NN89EhHZWDpNac9f95MO9zrTt7ZRoxzq5zexupMrj83raAtGfFwX+PTa+kAKYLk0wy11VvoU2fFrbzRvU2HlaI3tnLjYXyGKGgwE418VSmsl1AylPbVSts24rvW7nzrFxerc3XkKNLoUlQGG90YxbWFRvEQHBgZ2ynDmVpBwbmNy/3lxcuzpu1KlGCi+kYQYkvoL/k38/gEUt0Bidxnx38HO9rED0l+kROQeb3ql2slmn54v9vkYyboixlYAX4Ay+GHjq6tkUCPwHe1DgWc/zmhva3aUp1eFGfD+89hBjQ//J3PP4PrVBkPm2ZgS3iZSv/HYGLZCQ= X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB2030;6:o72oRoSssg1he9DqKt0I8PHv5vzUt329vdNDJhKWQahejeq98mp9R8/Z0hx0dJh+IZbqfnc7EcjGsSWlTs7WO4HtTPyscXGqWEfha84sU4YI+aCCr9kniKMET6bT9GwMTw542mBxxeZmiGItWozjoa7H/mMhfRq6KFN4t/stLHQw+cJhHRxpE92kyLxmBP4mIpsnvy7vTJf6uJPs6YYfV/hqQd54HwfkZfeTG1AB6EHggG1IWN6zijQYMMenwUvlKMCI9xHsq/fw+U5P3m1l+twkWcKzC45V3aQFBlmhecInBUAVa+AQS3I7YoE4gU9dFveTDNUyNCoqSpLlNfwV1ipJpdjHYUALltDerCoxqQ6NxBFO+5WQwkSV5Rpj1ZxEazz5ot+dULSHo8EQTwPVRseHM9j8zeCWcrXaws4xujHB03qdc2gpSm+Iu052Nohtn9qTpqFcM5mLYD2rR2FcCg==;5:EcvD8V62YPSOjIUgl+ndVl6VxLGwoespUDvfUxF8CuFUg+HD9IXT6vXiYlLoqqca7hbPyJmJioWj6Fgu+bYOnaHljae6ofPEwUg4pCl8dMuJQ+QWXvaeVmd5CaMUaAjxkBHBINf1bqxLw3BYd4hlRpUIjsvZRWFMCBmbqhiPJSs=;7:ZaX9nXvYn8rHdvLvK9FbHf/4jmEFhqneqFLncQ3usfoljbggv13H3QvjhXiZ6U3bIAjsv9ko6AIQHgqPfk49zV0I8YThx9a/3+NW6Rrz+lgbGZJ+DNuBvmMlNtqF0VFp1vya5B+XsfoNQhqMsogsPY+uPuRYHlVy571sWWxl3m9HUheGSOeGv1XxXyNHXFvSNZm+pRd/eVzn4EBSjAlpfZk6Lk3v7Sj3vYHvmIrUMH8Bi1nM62Rgyy4E2/1lzM+c SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB2030;20:O0SU6s1e7ZO+MbBKMYnyxB3kzr6KhN7aeCoKpGJjKE1I4g18pjnB9M9PuU/pO1Hp+qLXnrV791Ce8E1F1dr1pT7FXULxUvzqlNtG4fHtt2e90L9TyAnsszpa4LrUrcfToLDmzT5SQl9xJPhOSy8NfiMAiXMHGekFQIAwDBCSGz8= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2018 15:38:27.6610 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 535b2c34-803b-493e-31b8-08d5fc7bd3f8 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB2030 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The patch makes s_dentry_lru and s_inode_lru be destroyed later from the workqueue. This is preparation to split unregister_shrinker(super_block::s_shrink) in two stages, and to call finalize stage from destroy_super_work(). Note, that generic filesystem shrinker unregistration is safe to be splitted in two stages right after this patch, since super_cache_count() and super_cache_scan() have a deal with s_dentry_lru and s_inode_lru only. But there are two exceptions: XFS and SHMEM, which define .nr_cached_objects() and .free_cached_objects() callbacks. These two do not allow us to do the splitting right after this patch. They touch fs-specific data, which is destroyed earlier, than destroy_super_work(). So, we can't call unregister_shrinker_delayed_finalize() from destroy_super_work() because of them, and next patches make preparations to make this possible. Signed-off-by: Kirill Tkhai --- fs/super.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/fs/super.c b/fs/super.c index 426161360af3..457834278e37 100644 --- a/fs/super.c +++ b/fs/super.c @@ -159,6 +159,11 @@ static void destroy_super_work(struct work_struct *work) destroy_work); int i; + WARN_ON(list_lru_count(&s->s_dentry_lru)); + WARN_ON(list_lru_count(&s->s_inode_lru)); + list_lru_destroy(&s->s_dentry_lru); + list_lru_destroy(&s->s_inode_lru); + for (i = 0; i < SB_FREEZE_LEVELS; i++) percpu_free_rwsem(&s->s_writers.rw_sem[i]); kfree(s); @@ -177,8 +182,6 @@ static void destroy_unused_super(struct super_block *s) if (!s) return; up_write(&s->s_umount); - list_lru_destroy(&s->s_dentry_lru); - list_lru_destroy(&s->s_inode_lru); security_sb_free(s); put_user_ns(s->s_user_ns); kfree(s->s_subtype); @@ -283,8 +286,6 @@ static void __put_super(struct super_block *s) { if (!--s->s_count) { list_del_init(&s->s_list); - WARN_ON(s->s_dentry_lru.node); - WARN_ON(s->s_inode_lru.node); WARN_ON(!list_empty(&s->s_mounts)); security_sb_free(s); put_user_ns(s->s_user_ns); @@ -327,14 +328,6 @@ void deactivate_locked_super(struct super_block *s) unregister_shrinker(&s->s_shrink); fs->kill_sb(s); - /* - * Since list_lru_destroy() may sleep, we cannot call it from - * put_super(), where we hold the sb_lock. Therefore we destroy - * the lru lists right now. - */ - list_lru_destroy(&s->s_dentry_lru); - list_lru_destroy(&s->s_inode_lru); - put_filesystem(fs); put_super(s); } else {