From patchwork Wed May 31 09:57:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13261879 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 920F4C7EE24 for ; Wed, 31 May 2023 10:04:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235822AbjEaKEc (ORCPT ); Wed, 31 May 2023 06:04:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235785AbjEaKEX (ORCPT ); Wed, 31 May 2023 06:04:23 -0400 Received: from out-32.mta0.migadu.com (out-32.mta0.migadu.com [91.218.175.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41FAA124 for ; Wed, 31 May 2023 03:04:19 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1685527116; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TtT/YiPGcEdmTG9OAN3DQ5AumhKObXT9/Vj+qIl0WEg=; b=PlSv9IPmuSHjdrKvEPl7w4TEiIOKkc/t+uD+8kCUMyQjVkWRlPkNzabQJ7hHCOKGaBYK7W bUUNx1CrZkZITlDuz0x6psukNLY7bBJ0k/0MQR2aKvy2s33NxB3JNm4Ms6dXTNpvioEckI QgaCfDLB4ZAFsh5XY9kozVeBEH/jkVw= From: Qi Zheng To: akpm@linux-foundation.org, tkhai@ya.ru, roman.gushchin@linux.dev, vbabka@suse.cz, viro@zeniv.linux.org.uk, brauner@kernel.org, djwong@kernel.org, hughd@google.com, paulmck@kernel.org, muchun.song@linux.dev Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, Qi Zheng Subject: [PATCH 5/8] fs: introduce struct super_operations::destroy_super() callback Date: Wed, 31 May 2023 09:57:39 +0000 Message-Id: <20230531095742.2480623-6-qi.zheng@linux.dev> In-Reply-To: <20230531095742.2480623-1-qi.zheng@linux.dev> References: <20230531095742.2480623-1-qi.zheng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Kirill Tkhai The patch introduces a new callback, which will be called asynchronous from delayed work. This will allows to make ::nr_cached_objects() safe to be called on destroying superblock in next patches, and to split unregister_shrinker() into two primitives. Signed-off-by: Kirill Tkhai Signed-off-by: Qi Zheng --- fs/super.c | 3 +++ include/linux/fs.h | 1 + 2 files changed, 4 insertions(+) diff --git a/fs/super.c b/fs/super.c index 2ce54561e82e..4e9d08224f86 100644 --- a/fs/super.c +++ b/fs/super.c @@ -170,6 +170,9 @@ static void destroy_super_work(struct work_struct *work) list_lru_destroy(&s->s_dentry_lru); list_lru_destroy(&s->s_inode_lru); + if (s->s_op->destroy_super) + s->s_op->destroy_super(s); + for (i = 0; i < SB_FREEZE_LEVELS; i++) percpu_free_rwsem(&s->s_writers.rw_sem[i]); kfree(s); diff --git a/include/linux/fs.h b/include/linux/fs.h index 0b54ac1d331b..30b46d0facfc 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1910,6 +1910,7 @@ struct super_operations { int (*drop_inode) (struct inode *); void (*evict_inode) (struct inode *); void (*put_super) (struct super_block *); + void (*destroy_super) (struct super_block *); int (*sync_fs)(struct super_block *sb, int wait); int (*freeze_super) (struct super_block *); int (*freeze_fs) (struct super_block *);