From patchwork Wed Sep 13 11:10:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13382852 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 D70B1EDEC42 for ; Wed, 13 Sep 2023 11:11:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240216AbjIMLLy (ORCPT ); Wed, 13 Sep 2023 07:11:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240222AbjIMLLe (ORCPT ); Wed, 13 Sep 2023 07:11:34 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93B901FD4; Wed, 13 Sep 2023 04:11:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=AwVUXcoXpUXwAjgKY+YMHBurOxH8fp8xakqCS5N8QOI=; b=tQeAokJJ8m0XmksMRtptFl8ZrW 6Nom6PA+knKc6r3zg4W2KMC61HNnxlaQel6fkB1HrrRawRzpj0M2vmMWymFHxZopL1KDQnSJ22U5A Ow8kmT5tnVA86aSdIOqZfLkdy4Um0mUCoNALuvG5AqbRguzFlaFgGhQhRRopr604QlKgqzQKzCW5i 6ZPKeGOFyLSHYmNqpfo99oZf3xJs34VDYnSiA3E8zNPES+89u4ecfTrDYhf1lDxZiXSmDagrKT8Ad fyPmeFZghP6slRpc1RhK91m65VkoFrK8jVEe0jyJ6QJqD4oF6dovad5lpUbyEsuC1cydeEOELenjv u4xvPPqg==; Received: from [190.210.221.22] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qgNm2-005i7T-3B; Wed, 13 Sep 2023 11:11:11 +0000 From: Christoph Hellwig To: Christian Brauner , Al Viro Cc: Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Fenghua Yu , Reinette Chatre , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Dennis Dalessandro , Tejun Heo , Trond Myklebust , Anna Schumaker , Kees Cook , Damien Le Moal , Naohiro Aota , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linux-rdma@vger.kernel.org, linux-nfs@vger.kernel.org, linux-hardening@vger.kernel.org, cgroups@vger.kernel.org Subject: [PATCH 14/19] jffs2: convert to ->shutdown_sb and ->free_sb Date: Wed, 13 Sep 2023 08:10:08 -0300 Message-Id: <20230913111013.77623-15-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230913111013.77623-1-hch@lst.de> References: <20230913111013.77623-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org Convert jffs2 from ->kill_sb to ->shutdown_sb and ->free_sb. Drop the otherwise unused kill_mtd_super helpers, as there is no benefit in it over just calling put_mtd_device on sb->s_mtd. Signed-off-by: Christoph Hellwig --- drivers/mtd/mtdsuper.c | 12 ------------ fs/jffs2/super.c | 22 ++++++++++++++-------- include/linux/mtd/super.h | 2 -- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/drivers/mtd/mtdsuper.c b/drivers/mtd/mtdsuper.c index b7e3763c47f0cd..66da2e6f90f5f5 100644 --- a/drivers/mtd/mtdsuper.c +++ b/drivers/mtd/mtdsuper.c @@ -165,15 +165,3 @@ int get_tree_mtd(struct fs_context *fc, return -EINVAL; } EXPORT_SYMBOL_GPL(get_tree_mtd); - -/* - * destroy an MTD-based superblock - */ -void kill_mtd_super(struct super_block *sb) -{ - generic_shutdown_super(sb); - put_mtd_device(sb->s_mtd); - sb->s_mtd = NULL; -} - -EXPORT_SYMBOL_GPL(kill_mtd_super); diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index 7ea37f49f1e18e..14577368202e90 100644 --- a/fs/jffs2/super.c +++ b/fs/jffs2/super.c @@ -340,21 +340,27 @@ static void jffs2_put_super (struct super_block *sb) jffs2_dbg(1, "%s(): returning\n", __func__); } -static void jffs2_kill_sb(struct super_block *sb) +static void jffs2_shutdown_sb(struct super_block *sb) { struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); + if (c && !sb_rdonly(sb)) jffs2_stop_garbage_collect_thread(c); - kill_mtd_super(sb); - kfree(c); +} + +static void jffs2_free_sb(struct super_block *sb) +{ + put_mtd_device(sb->s_mtd); + kfree(JFFS2_SB_INFO(sb)); } static struct file_system_type jffs2_fs_type = { - .owner = THIS_MODULE, - .name = "jffs2", - .init_fs_context = jffs2_init_fs_context, - .parameters = jffs2_fs_parameters, - .kill_sb = jffs2_kill_sb, + .owner = THIS_MODULE, + .name = "jffs2", + .init_fs_context = jffs2_init_fs_context, + .parameters = jffs2_fs_parameters, + .shutdown_sb = jffs2_shutdown_sb, + .free_sb = jffs2_free_sb, }; MODULE_ALIAS_FS("jffs2"); diff --git a/include/linux/mtd/super.h b/include/linux/mtd/super.h index 3608a6c36faceb..f6d5c1a17eec23 100644 --- a/include/linux/mtd/super.h +++ b/include/linux/mtd/super.h @@ -17,8 +17,6 @@ extern int get_tree_mtd(struct fs_context *fc, int (*fill_super)(struct super_block *sb, struct fs_context *fc)); -extern void kill_mtd_super(struct super_block *sb); - #endif /* __KERNEL__ */