All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Christian Brauner <brauner@kernel.org>,
	Al Viro <viro@zeniv.linux.org.uk>
Cc: Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Fenghua Yu <fenghua.yu@intel.com>,
	Reinette Chatre <reinette.chatre@intel.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>,
	Tejun Heo <tj@kernel.org>,
	Trond Myklebust <trond.myklebust@hammerspace.com>,
	Anna Schumaker <anna@kernel.org>,
	Kees Cook <keescook@chromium.org>,
	Damien Le Moal <dlemoal@kernel.org>,
	Naohiro Aota <naohiro.aota@wdc.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	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 18/19] fs: simple ->shutdown_sb and ->free_sb conversions
Date: Wed, 13 Sep 2023 08:10:12 -0300	[thread overview]
Message-ID: <20230913111013.77623-19-hch@lst.de> (raw)
In-Reply-To: <20230913111013.77623-1-hch@lst.de>

Convert all file systems that just called generic_shutdown_super from
->kill_sb without any state kept from before the call to after it to
->shutdown_sb and ->free_sb as needed.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/9p/vfs_super.c             | 14 +++-----------
 fs/afs/super.c                | 15 +++++++++++----
 fs/autofs/autofs_i.h          |  3 ++-
 fs/autofs/init.c              |  3 ++-
 fs/autofs/inode.c             | 24 +++++++++++++-----------
 fs/btrfs/super.c              | 11 ++++-------
 fs/ceph/super.c               | 13 +++++++++----
 fs/cramfs/inode.c             |  6 ++----
 fs/ecryptfs/main.c            | 11 ++---------
 fs/fuse/inode.c               |  7 +++----
 fs/fuse/virtio_fs.c           | 19 +++++++++++--------
 fs/hostfs/hostfs_kern.c       |  5 ++---
 fs/nfs/fs_context.c           | 18 ++++++++++--------
 fs/orangefs/orangefs-kernel.h |  2 +-
 fs/orangefs/orangefs-mod.c    |  2 +-
 fs/orangefs/super.c           | 11 ++++-------
 fs/proc/root.c                | 16 +++++++++-------
 fs/romfs/super.c              |  6 ++----
 fs/smb/client/cifsfs.c        | 14 +++++++++-----
 fs/ubifs/super.c              |  9 +++------
 20 files changed, 103 insertions(+), 106 deletions(-)

diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index e8b3641c98f886..a238065dd8b361 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -205,25 +205,17 @@ static struct dentry *v9fs_mount(struct file_system_type *fs_type, int flags,
 	return ERR_PTR(retval);
 }
 
-/**
- * v9fs_kill_super - Kill Superblock
- * @s: superblock
- *
- */
-
-static void v9fs_kill_super(struct super_block *s)
+static void v9fs_free_sb(struct super_block *s)
 {
 	struct v9fs_session_info *v9ses = s->s_fs_info;
 
 	p9_debug(P9_DEBUG_VFS, " %p\n", s);
 
-	generic_shutdown_super(s);
-
 	v9fs_session_cancel(v9ses);
 	v9fs_session_close(v9ses);
 	kfree(v9ses);
 	s->s_fs_info = NULL;
-	p9_debug(P9_DEBUG_VFS, "exiting kill_super\n");
+	p9_debug(P9_DEBUG_VFS, "exiting free_sb\n");
 }
 
 static void
@@ -340,7 +332,7 @@ static const struct super_operations v9fs_super_ops_dotl = {
 struct file_system_type v9fs_fs_type = {
 	.name = "9p",
 	.mount = v9fs_mount,
-	.kill_sb = v9fs_kill_super,
+	.free_sb = v9fs_free_sb,
 	.owner = THIS_MODULE,
 	.fs_flags = FS_RENAME_DOES_D_MOVE,
 };
diff --git a/fs/afs/super.c b/fs/afs/super.c
index 84b135ad3496b1..bd85554056415d 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -30,7 +30,8 @@
 #include "internal.h"
 
 static void afs_i_init_once(void *foo);
-static void afs_kill_super(struct super_block *sb);
+static void afs_shutdown_sb(struct super_block *sb);
+static void afs_free_sb(struct super_block *sb);
 static struct inode *afs_alloc_inode(struct super_block *sb);
 static void afs_destroy_inode(struct inode *inode);
 static void afs_free_inode(struct inode *inode);
@@ -45,7 +46,8 @@ struct file_system_type afs_fs_type = {
 	.name			= "afs",
 	.init_fs_context	= afs_init_fs_context,
 	.parameters		= afs_fs_parameters,
-	.kill_sb		= afs_kill_super,
+	.shutdown_sb		= afs_shutdown_sb,
+	.free_sb		= afs_free_sb,
 	.fs_flags		= FS_RENAME_DOES_D_MOVE,
 };
 MODULE_ALIAS_FS("afs");
@@ -527,7 +529,7 @@ static void afs_destroy_sbi(struct afs_super_info *as)
 	}
 }
 
-static void afs_kill_super(struct super_block *sb)
+static void afs_shutdown_sb(struct super_block *sb)
 {
 	struct afs_super_info *as = AFS_FS_S(sb);
 
@@ -539,7 +541,12 @@ static void afs_kill_super(struct super_block *sb)
 	 */
 	if (as->volume)
 		rcu_assign_pointer(as->volume->sb, NULL);
-	generic_shutdown_super(sb);
+}
+
+static void afs_free_sb(struct super_block *sb)
+{
+	struct afs_super_info *as = AFS_FS_S(sb);
+
 	if (as->volume)
 		afs_deactivate_volume(as->volume);
 	afs_destroy_sbi(as);
diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h
index d5a44fa88acf9a..f60f425c08b55c 100644
--- a/fs/autofs/autofs_i.h
+++ b/fs/autofs/autofs_i.h
@@ -276,4 +276,5 @@ static inline void autofs_del_expiring(struct dentry *dentry)
 	}
 }
 
-void autofs_kill_sb(struct super_block *);
+void autofs_shutdown_sb(struct super_block *sb);
+void autofs_free_sb(struct super_block *sb);
diff --git a/fs/autofs/init.c b/fs/autofs/init.c
index d3f55e87433890..1f7bed5391f822 100644
--- a/fs/autofs/init.c
+++ b/fs/autofs/init.c
@@ -17,7 +17,8 @@ struct file_system_type autofs_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "autofs",
 	.mount		= autofs_mount,
-	.kill_sb	= autofs_kill_sb,
+	.shutdown_sb	= autofs_shutdown_sb,
+	.free_sb	= autofs_free_sb,
 };
 MODULE_ALIAS_FS("autofs");
 MODULE_ALIAS("autofs");
diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
index c3b64799155840..363c55f0ae6a6f 100644
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -37,24 +37,26 @@ void autofs_free_ino(struct autofs_info *ino)
 	kfree_rcu(ino, rcu);
 }
 
-void autofs_kill_sb(struct super_block *sb)
+void autofs_shutdown_sb(struct super_block *sb)
 {
 	struct autofs_sb_info *sbi = autofs_sbi(sb);
 
 	/*
 	 * In the event of a failure in get_sb_nodev the superblock
-	 * info is not present so nothing else has been setup, so
-	 * just call generic_shutdown_super when we are called from
-	 * deactivate_super.
+	 * info is not present so nothing else has been setup.
 	 */
-	if (sbi) {
-		/* Free wait queues, close pipe */
-		autofs_catatonic_mode(sbi);
-		put_pid(sbi->oz_pgrp);
-	}
+	if (!sbi)
+		return;
+
+	/* Free wait queues, close pipe */
+	autofs_catatonic_mode(sbi);
+	put_pid(sbi->oz_pgrp);
+}
+
+void autofs_free_sb(struct super_block *sb)
+{
+	struct autofs_sb_info *sbi = autofs_sbi(sb);
 
-	pr_debug("shutting down\n");
-	generic_shutdown_super(sb);
 	if (sbi)
 		kfree_rcu(sbi, rcu);
 }
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 063b9aa313c227..9205f8919faeeb 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2136,19 +2136,16 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 	return 0;
 }
 
-static void btrfs_kill_super(struct super_block *sb)
+static void btrfs_free_sb(struct super_block *sb)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(sb);
-
-	generic_shutdown_super(sb);
-	btrfs_free_fs_info(fs_info);
+	btrfs_free_fs_info(btrfs_sb(sb));
 }
 
 static struct file_system_type btrfs_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "btrfs",
 	.mount		= btrfs_mount,
-	.kill_sb	= btrfs_kill_super,
+	.free_sb	= btrfs_free_sb,
 	.fs_flags	= FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA | FS_MGTIME,
 };
 
@@ -2156,7 +2153,7 @@ static struct file_system_type btrfs_root_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "btrfs",
 	.mount		= btrfs_mount_root,
-	.kill_sb	= btrfs_kill_super,
+	.free_sb	= btrfs_free_sb,
 	.fs_flags	= FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA |
 			  FS_ALLOW_IDMAP | FS_MGTIME,
 };
diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index cbeaab8c21d8e6..327180889bb6e3 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -1509,13 +1509,13 @@ void ceph_dec_osd_stopping_blocker(struct ceph_mds_client *mdsc)
 	__dec_stopping_blocker(mdsc);
 }
 
-static void ceph_kill_sb(struct super_block *s)
+static void ceph_shutdown_sb(struct super_block *s)
 {
 	struct ceph_fs_client *fsc = ceph_sb_to_client(s);
 	struct ceph_mds_client *mdsc = fsc->mdsc;
 	bool wait;
 
-	dout("kill_sb %p\n", s);
+	dout("shutdown_sb %p\n", s);
 
 	ceph_mdsc_pre_umount(mdsc);
 	flush_fs_workqueues(fsc);
@@ -1552,7 +1552,11 @@ static void ceph_kill_sb(struct super_block *s)
 	}
 
 	mdsc->stopping = CEPH_MDSC_STOPPING_FLUSHED;
-	generic_shutdown_super(s);
+}
+
+static void ceph_free_sb(struct super_block *s)
+{
+	struct ceph_fs_client *fsc = ceph_sb_to_client(s);
 
 	fsc->client->extra_mon_dispatch = NULL;
 	ceph_fs_debugfs_cleanup(fsc);
@@ -1566,7 +1570,8 @@ static struct file_system_type ceph_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "ceph",
 	.init_fs_context = ceph_init_fs_context,
-	.kill_sb	= ceph_kill_sb,
+	.shutdown_sb	= ceph_shutdown_sb,
+	.free_sb	= ceph_free_sb,
 	.fs_flags	= FS_RENAME_DOES_D_MOVE,
 };
 MODULE_ALIAS_FS("ceph");
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index 5ee7d7bbb361ce..afd05c3b1b5032 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -482,12 +482,10 @@ static const struct file_operations cramfs_physmem_fops = {
 #endif
 };
 
-static void cramfs_kill_sb(struct super_block *sb)
+static void cramfs_free_sb(struct super_block *sb)
 {
 	struct cramfs_sb_info *sbi = CRAMFS_SB(sb);
 
-	generic_shutdown_super(sb);
-
 	if (IS_ENABLED(CONFIG_CRAMFS_MTD) && sb->s_mtd) {
 		if (sbi && sbi->mtd_point_size)
 			mtd_unpoint(sb->s_mtd, 0, sbi->mtd_point_size);
@@ -977,7 +975,7 @@ static struct file_system_type cramfs_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "cramfs",
 	.init_fs_context = cramfs_init_fs_context,
-	.kill_sb	= cramfs_kill_sb,
+	.free_sb	= cramfs_free_sb,
 	.fs_flags	= FS_REQUIRES_DEV,
 };
 MODULE_ALIAS_FS("cramfs");
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 3ed91537a3991a..cad39d6cc5d9d6 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -616,17 +616,10 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags
 	return ERR_PTR(rc);
 }
 
-/**
- * ecryptfs_kill_block_super
- * @sb: The ecryptfs super block
- *
- * Used to bring the superblock down and free the private data.
- */
-static void ecryptfs_kill_block_super(struct super_block *sb)
+static void ecryptfs_free_sb(struct super_block *sb)
 {
 	struct ecryptfs_sb_info *sb_info = ecryptfs_superblock_to_private(sb);
 
-	generic_shutdown_super(sb);
 	if (!sb_info)
 		return;
 	ecryptfs_destroy_mount_crypt_stat(&sb_info->mount_crypt_stat);
@@ -637,7 +630,7 @@ static struct file_system_type ecryptfs_fs_type = {
 	.owner = THIS_MODULE,
 	.name = "ecryptfs",
 	.mount = ecryptfs_mount,
-	.kill_sb = ecryptfs_kill_block_super,
+	.free_sb = ecryptfs_free_sb,
 	.fs_flags = 0
 };
 MODULE_ALIAS_FS("ecryptfs");
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index d9981532530702..08d543b88b840d 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -1837,10 +1837,8 @@ void fuse_mount_destroy(struct fuse_mount *fm)
 }
 EXPORT_SYMBOL(fuse_mount_destroy);
 
-static void fuse_kill_sb_anon(struct super_block *sb)
+static void fuse_free_sb_anon(struct super_block *sb)
 {
-	fuse_shutdown_sb(sb);
-	generic_shutdown_super(sb);
 	fuse_mount_destroy(get_fuse_mount_super(sb));
 }
 
@@ -1850,7 +1848,8 @@ static struct file_system_type fuse_fs_type = {
 	.fs_flags	= FS_HAS_SUBTYPE | FS_USERNS_MOUNT,
 	.init_fs_context = fuse_init_fs_context,
 	.parameters	= fuse_fs_parameters,
-	.kill_sb	= fuse_kill_sb_anon,
+	.shutdown_sb	= fuse_shutdown_sb,
+	.free_sb	= fuse_free_sb_anon,
 };
 MODULE_ALIAS_FS("fuse");
 
diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
index a52957df956394..8c2b0b226ddf63 100644
--- a/fs/fuse/virtio_fs.c
+++ b/fs/fuse/virtio_fs.c
@@ -1387,19 +1387,21 @@ static void virtio_fs_conn_destroy(struct fuse_mount *fm)
 	virtio_fs_free_devs(vfs);
 }
 
-static void virtio_kill_sb(struct super_block *sb)
+static void virtio_shutdown_sb(struct super_block *sb)
 {
-	struct fuse_mount *fm = get_fuse_mount_super(sb);
-	bool last;
-
 	/* If mount failed, we can still be called without any fc */
 	if (sb->s_root) {
-		last = fuse_mount_remove(fm);
+		struct fuse_mount *fm = get_fuse_mount_super(sb);
+		bool last = fuse_mount_remove(fm);
+
 		if (last)
 			virtio_fs_conn_destroy(fm);
 	}
-	generic_shutdown_super(sb);
-	fuse_mount_destroy(fm);
+}
+
+static void virtio_free_sb(struct super_block *sb)
+{
+	fuse_mount_destroy(get_fuse_mount_super(sb));
 }
 
 static int virtio_fs_test_super(struct super_block *sb,
@@ -1507,7 +1509,8 @@ static struct file_system_type virtio_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "virtiofs",
 	.init_fs_context = virtio_fs_init_fs_context,
-	.kill_sb	= virtio_kill_sb,
+	.shutdown_sb	= virtio_shutdown_sb,
+	.free_sb	= virtio_free_sb,
 };
 
 static int __init virtio_fs_init(void)
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 97f3c9709418c9..21d57098413222 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -979,9 +979,8 @@ static struct dentry *hostfs_read_sb(struct file_system_type *type,
 	return mount_nodev(type, flags, data, hostfs_fill_sb_common);
 }
 
-static void hostfs_kill_sb(struct super_block *s)
+static void hostfs_free_sb(struct super_block *s)
 {
-	generic_shutdown_super(s);
 	kfree(s->s_fs_info);
 }
 
@@ -989,7 +988,7 @@ static struct file_system_type hostfs_type = {
 	.owner 		= THIS_MODULE,
 	.name 		= "hostfs",
 	.mount	 	= hostfs_read_sb,
-	.kill_sb	= hostfs_kill_sb,
+	.free_sb	= hostfs_free_sb,
 	.fs_flags 	= 0,
 };
 MODULE_ALIAS_FS("hostfs");
diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c
index ee82e4cfb38bb5..4983931b5ad6e8 100644
--- a/fs/nfs/fs_context.c
+++ b/fs/nfs/fs_context.c
@@ -1646,15 +1646,15 @@ static int nfs_init_fs_context(struct fs_context *fc)
 	return 0;
 }
 
-static void nfs_kill_super(struct super_block *s)
+static void nfs_shutdown_sb(struct super_block *s)
 {
-	struct nfs_server *server = NFS_SB(s);
-
-	nfs_sysfs_move_sb_to_server(server);
-	generic_shutdown_super(s);
+	nfs_sysfs_move_sb_to_server(NFS_SB(s));
+}
 
+static void nfs_free_sb(struct super_block *s)
+{
 	nfs_fscache_release_super_cookie(s);
-	nfs_free_server(server);
+	nfs_free_server(NFS_SB(s));
 }
 
 struct file_system_type nfs_fs_type = {
@@ -1662,7 +1662,8 @@ struct file_system_type nfs_fs_type = {
 	.name			= "nfs",
 	.init_fs_context	= nfs_init_fs_context,
 	.parameters		= nfs_fs_parameters,
-	.kill_sb		= nfs_kill_super,
+	.shutdown_sb		= nfs_shutdown_sb,
+	.free_sb		= nfs_free_sb,
 	.fs_flags		= FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA,
 };
 MODULE_ALIAS_FS("nfs");
@@ -1674,7 +1675,8 @@ struct file_system_type nfs4_fs_type = {
 	.name			= "nfs4",
 	.init_fs_context	= nfs_init_fs_context,
 	.parameters		= nfs_fs_parameters,
-	.kill_sb		= nfs_kill_super,
+	.shutdown_sb		= nfs_shutdown_sb,
+	.free_sb		= nfs_free_sb,
 	.fs_flags		= FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA,
 };
 MODULE_ALIAS_FS("nfs4");
diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h
index b711654ca18a9c..73db7e6edb9966 100644
--- a/fs/orangefs/orangefs-kernel.h
+++ b/fs/orangefs/orangefs-kernel.h
@@ -344,7 +344,7 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
 			   const char *devname,
 			   void *data);
 
-void orangefs_kill_sb(struct super_block *sb);
+void orangefs_free_sb(struct super_block *sb);
 int orangefs_remount(struct orangefs_sb_info_s *);
 
 int fsid_key_table_initialize(void);
diff --git a/fs/orangefs/orangefs-mod.c b/fs/orangefs/orangefs-mod.c
index 5ab741c60b7e29..8b87eab0828126 100644
--- a/fs/orangefs/orangefs-mod.c
+++ b/fs/orangefs/orangefs-mod.c
@@ -47,7 +47,7 @@ MODULE_PARM_DESC(hash_table_size,
 static struct file_system_type orangefs_fs_type = {
 	.name = "pvfs2",
 	.mount = orangefs_mount,
-	.kill_sb = orangefs_kill_sb,
+	.free_sb = orangefs_free_sb,
 	.owner = THIS_MODULE,
 };
 
diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c
index bf3a834ad15033..7c8d9a3fe34fca 100644
--- a/fs/orangefs/super.c
+++ b/fs/orangefs/super.c
@@ -580,9 +580,9 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
 	return dget(sb->s_root);
 
 free_sb_and_op:
-	/* Will call orangefs_kill_sb with sb not in list. */
+	/* Will call orangefs_free_sb with sb not in list. */
 	ORANGEFS_SB(sb)->no_list = 1;
-	/* ORANGEFS_VFS_OP_FS_UMOUNT is done by orangefs_kill_sb. */
+	/* ORANGEFS_VFS_OP_FS_UMOUNT is done by orangefs_free_sb. */
 	deactivate_locked_super(sb);
 free_op:
 	gossip_err("orangefs_mount: mount request failed with %d\n", ret);
@@ -596,13 +596,10 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
 	return d;
 }
 
-void orangefs_kill_sb(struct super_block *sb)
+void orangefs_free_sb(struct super_block *sb)
 {
 	int r;
-	gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_kill_sb: called\n");
-
-	/* provided sb cleanup */
-	generic_shutdown_super(sb);
+	gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_free_sb: called\n");
 
 	if (!ORANGEFS_SB(sb)) {
 		mutex_lock(&orangefs_request_mutex);
diff --git a/fs/proc/root.c b/fs/proc/root.c
index 2282366449ac0b..81f6abedbd28b7 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -257,19 +257,20 @@ static int proc_init_fs_context(struct fs_context *fc)
 	return 0;
 }
 
-static void proc_kill_sb(struct super_block *sb)
+static void proc_shutdown_sb(struct super_block *sb)
 {
 	struct proc_fs_info *fs_info = proc_sb_info(sb);
 
-	if (!fs_info) {
-		generic_shutdown_super(sb);
+	if (!fs_info)
 		return;
-	}
-
 	dput(fs_info->proc_self);
 	dput(fs_info->proc_thread_self);
+}
+
+static void proc_free_sb(struct super_block *sb)
+{
+	struct proc_fs_info *fs_info = proc_sb_info(sb);
 
-	generic_shutdown_super(sb);
 	put_pid_ns(fs_info->pid_ns);
 	kfree(fs_info);
 }
@@ -278,7 +279,8 @@ static struct file_system_type proc_fs_type = {
 	.name			= "proc",
 	.init_fs_context	= proc_init_fs_context,
 	.parameters		= proc_fs_parameters,
-	.kill_sb		= proc_kill_sb,
+	.shutdown_sb		= proc_shutdown_sb,
+	.free_sb		= proc_free_sb,
 	.fs_flags		= FS_USERNS_MOUNT | FS_DISALLOW_NOTIFY_PERM,
 };
 
diff --git a/fs/romfs/super.c b/fs/romfs/super.c
index 5c35f6c760377e..d7c7e69db980e6 100644
--- a/fs/romfs/super.c
+++ b/fs/romfs/super.c
@@ -580,10 +580,8 @@ static int romfs_init_fs_context(struct fs_context *fc)
 /*
  * destroy a romfs superblock in the appropriate manner
  */
-static void romfs_kill_sb(struct super_block *sb)
+static void romfs_free_sb(struct super_block *sb)
 {
-	generic_shutdown_super(sb);
-
 #ifdef CONFIG_ROMFS_ON_MTD
 	if (sb->s_mtd) {
 		put_mtd_device(sb->s_mtd);
@@ -602,7 +600,7 @@ static struct file_system_type romfs_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "romfs",
 	.init_fs_context = romfs_init_fs_context,
-	.kill_sb	= romfs_kill_sb,
+	.free_sb	= romfs_free_sb,
 	.fs_flags	= FS_REQUIRES_DEV,
 };
 MODULE_ALIAS_FS("romfs");
diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c
index 5700f1065af756..34141c80a0bbd3 100644
--- a/fs/smb/client/cifsfs.c
+++ b/fs/smb/client/cifsfs.c
@@ -286,7 +286,7 @@ cifs_read_super(struct super_block *sb)
 	return rc;
 }
 
-static void cifs_kill_sb(struct super_block *sb)
+static void cifs_shutdown_sb(struct super_block *sb)
 {
 	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
 
@@ -301,9 +301,11 @@ static void cifs_kill_sb(struct super_block *sb)
 		dput(cifs_sb->root);
 		cifs_sb->root = NULL;
 	}
+}
 
-	generic_shutdown_super(sb);
-	cifs_umount(cifs_sb);
+static void cifs_free_sb(struct super_block *sb)
+{
+	cifs_umount(CIFS_SB(sb));
 }
 
 static int
@@ -1121,7 +1123,8 @@ struct file_system_type cifs_fs_type = {
 	.name = "cifs",
 	.init_fs_context = smb3_init_fs_context,
 	.parameters = smb3_fs_parameters,
-	.kill_sb = cifs_kill_sb,
+	.shutdown_sb = cifs_shutdown_sb,
+	.free_sb = cifs_free_sb,
 	.fs_flags = FS_RENAME_DOES_D_MOVE,
 };
 MODULE_ALIAS_FS("cifs");
@@ -1131,7 +1134,8 @@ struct file_system_type smb3_fs_type = {
 	.name = "smb3",
 	.init_fs_context = smb3_init_fs_context,
 	.parameters = smb3_fs_parameters,
-	.kill_sb = cifs_kill_sb,
+	.shutdown_sb = cifs_shutdown_sb,
+	.free_sb = cifs_free_sb,
 	.fs_flags = FS_RENAME_DOES_D_MOVE,
 };
 MODULE_ALIAS_FS("smb3");
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index b9d1ab63e3c87e..0bce555fd14d44 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -2347,19 +2347,16 @@ static struct dentry *ubifs_mount(struct file_system_type *fs_type, int flags,
 	return ERR_PTR(err);
 }
 
-static void kill_ubifs_super(struct super_block *s)
+static void ubifs_free_sb(struct super_block *s)
 {
-	struct ubifs_info *c = s->s_fs_info;
-
-	generic_shutdown_super(s);
-	kfree(c);
+	kfree(s->s_fs_info);
 }
 
 static struct file_system_type ubifs_fs_type = {
 	.name    = "ubifs",
 	.owner   = THIS_MODULE,
 	.mount   = ubifs_mount,
-	.kill_sb = kill_ubifs_super,
+	.free_sb = ubifs_free_sb,
 };
 MODULE_ALIAS_FS("ubifs");
 
-- 
2.39.2


WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
To: Christian Brauner
	<brauner-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
Cc: Heiko Carstens <hca-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org>,
	Vasily Gorbik <gor-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org>,
	Alexander Gordeev
	<agordeev-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org>,
	Fenghua Yu <fenghua.yu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Reinette Chatre
	<reinette.chatre-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Miquel Raynal
	<miquel.raynal-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org>,
	Richard Weinberger <richard-/L3Ra7n9ekc@public.gmane.org>,
	Vignesh Raghavendra <vigneshr-l0cyMroinI0@public.gmane.org>,
	Dennis Dalessandro
	<dennis.dalessandro-ntyVByD3zXaTtA8H5PvdGFaTQe2KTcn/@public.gmane.org>,
	Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Trond Myklebust
	<trond.myklebust-F/q8l9xzQnoyLce1RVWEUA@public.gmane.org>,
	Anna Schumaker <anna-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	Damien Le Moal <dlemoal-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Naohiro Aota <naohiro.aota-Sjgp3cTcYWE@public.gmane.org>,
	Greg Kroah-Hartman
	<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-s390-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 18/19] fs: simple ->shutdown_sb and ->free_sb conversions
Date: Wed, 13 Sep 2023 08:10:12 -0300	[thread overview]
Message-ID: <20230913111013.77623-19-hch@lst.de> (raw)
In-Reply-To: <20230913111013.77623-1-hch-jcswGhMUV9g@public.gmane.org>

Convert all file systems that just called generic_shutdown_super from
->kill_sb without any state kept from before the call to after it to
->shutdown_sb and ->free_sb as needed.

Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
 fs/9p/vfs_super.c             | 14 +++-----------
 fs/afs/super.c                | 15 +++++++++++----
 fs/autofs/autofs_i.h          |  3 ++-
 fs/autofs/init.c              |  3 ++-
 fs/autofs/inode.c             | 24 +++++++++++++-----------
 fs/btrfs/super.c              | 11 ++++-------
 fs/ceph/super.c               | 13 +++++++++----
 fs/cramfs/inode.c             |  6 ++----
 fs/ecryptfs/main.c            | 11 ++---------
 fs/fuse/inode.c               |  7 +++----
 fs/fuse/virtio_fs.c           | 19 +++++++++++--------
 fs/hostfs/hostfs_kern.c       |  5 ++---
 fs/nfs/fs_context.c           | 18 ++++++++++--------
 fs/orangefs/orangefs-kernel.h |  2 +-
 fs/orangefs/orangefs-mod.c    |  2 +-
 fs/orangefs/super.c           | 11 ++++-------
 fs/proc/root.c                | 16 +++++++++-------
 fs/romfs/super.c              |  6 ++----
 fs/smb/client/cifsfs.c        | 14 +++++++++-----
 fs/ubifs/super.c              |  9 +++------
 20 files changed, 103 insertions(+), 106 deletions(-)

diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index e8b3641c98f886..a238065dd8b361 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -205,25 +205,17 @@ static struct dentry *v9fs_mount(struct file_system_type *fs_type, int flags,
 	return ERR_PTR(retval);
 }
 
-/**
- * v9fs_kill_super - Kill Superblock
- * @s: superblock
- *
- */
-
-static void v9fs_kill_super(struct super_block *s)
+static void v9fs_free_sb(struct super_block *s)
 {
 	struct v9fs_session_info *v9ses = s->s_fs_info;
 
 	p9_debug(P9_DEBUG_VFS, " %p\n", s);
 
-	generic_shutdown_super(s);
-
 	v9fs_session_cancel(v9ses);
 	v9fs_session_close(v9ses);
 	kfree(v9ses);
 	s->s_fs_info = NULL;
-	p9_debug(P9_DEBUG_VFS, "exiting kill_super\n");
+	p9_debug(P9_DEBUG_VFS, "exiting free_sb\n");
 }
 
 static void
@@ -340,7 +332,7 @@ static const struct super_operations v9fs_super_ops_dotl = {
 struct file_system_type v9fs_fs_type = {
 	.name = "9p",
 	.mount = v9fs_mount,
-	.kill_sb = v9fs_kill_super,
+	.free_sb = v9fs_free_sb,
 	.owner = THIS_MODULE,
 	.fs_flags = FS_RENAME_DOES_D_MOVE,
 };
diff --git a/fs/afs/super.c b/fs/afs/super.c
index 84b135ad3496b1..bd85554056415d 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -30,7 +30,8 @@
 #include "internal.h"
 
 static void afs_i_init_once(void *foo);
-static void afs_kill_super(struct super_block *sb);
+static void afs_shutdown_sb(struct super_block *sb);
+static void afs_free_sb(struct super_block *sb);
 static struct inode *afs_alloc_inode(struct super_block *sb);
 static void afs_destroy_inode(struct inode *inode);
 static void afs_free_inode(struct inode *inode);
@@ -45,7 +46,8 @@ struct file_system_type afs_fs_type = {
 	.name			= "afs",
 	.init_fs_context	= afs_init_fs_context,
 	.parameters		= afs_fs_parameters,
-	.kill_sb		= afs_kill_super,
+	.shutdown_sb		= afs_shutdown_sb,
+	.free_sb		= afs_free_sb,
 	.fs_flags		= FS_RENAME_DOES_D_MOVE,
 };
 MODULE_ALIAS_FS("afs");
@@ -527,7 +529,7 @@ static void afs_destroy_sbi(struct afs_super_info *as)
 	}
 }
 
-static void afs_kill_super(struct super_block *sb)
+static void afs_shutdown_sb(struct super_block *sb)
 {
 	struct afs_super_info *as = AFS_FS_S(sb);
 
@@ -539,7 +541,12 @@ static void afs_kill_super(struct super_block *sb)
 	 */
 	if (as->volume)
 		rcu_assign_pointer(as->volume->sb, NULL);
-	generic_shutdown_super(sb);
+}
+
+static void afs_free_sb(struct super_block *sb)
+{
+	struct afs_super_info *as = AFS_FS_S(sb);
+
 	if (as->volume)
 		afs_deactivate_volume(as->volume);
 	afs_destroy_sbi(as);
diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h
index d5a44fa88acf9a..f60f425c08b55c 100644
--- a/fs/autofs/autofs_i.h
+++ b/fs/autofs/autofs_i.h
@@ -276,4 +276,5 @@ static inline void autofs_del_expiring(struct dentry *dentry)
 	}
 }
 
-void autofs_kill_sb(struct super_block *);
+void autofs_shutdown_sb(struct super_block *sb);
+void autofs_free_sb(struct super_block *sb);
diff --git a/fs/autofs/init.c b/fs/autofs/init.c
index d3f55e87433890..1f7bed5391f822 100644
--- a/fs/autofs/init.c
+++ b/fs/autofs/init.c
@@ -17,7 +17,8 @@ struct file_system_type autofs_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "autofs",
 	.mount		= autofs_mount,
-	.kill_sb	= autofs_kill_sb,
+	.shutdown_sb	= autofs_shutdown_sb,
+	.free_sb	= autofs_free_sb,
 };
 MODULE_ALIAS_FS("autofs");
 MODULE_ALIAS("autofs");
diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
index c3b64799155840..363c55f0ae6a6f 100644
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -37,24 +37,26 @@ void autofs_free_ino(struct autofs_info *ino)
 	kfree_rcu(ino, rcu);
 }
 
-void autofs_kill_sb(struct super_block *sb)
+void autofs_shutdown_sb(struct super_block *sb)
 {
 	struct autofs_sb_info *sbi = autofs_sbi(sb);
 
 	/*
 	 * In the event of a failure in get_sb_nodev the superblock
-	 * info is not present so nothing else has been setup, so
-	 * just call generic_shutdown_super when we are called from
-	 * deactivate_super.
+	 * info is not present so nothing else has been setup.
 	 */
-	if (sbi) {
-		/* Free wait queues, close pipe */
-		autofs_catatonic_mode(sbi);
-		put_pid(sbi->oz_pgrp);
-	}
+	if (!sbi)
+		return;
+
+	/* Free wait queues, close pipe */
+	autofs_catatonic_mode(sbi);
+	put_pid(sbi->oz_pgrp);
+}
+
+void autofs_free_sb(struct super_block *sb)
+{
+	struct autofs_sb_info *sbi = autofs_sbi(sb);
 
-	pr_debug("shutting down\n");
-	generic_shutdown_super(sb);
 	if (sbi)
 		kfree_rcu(sbi, rcu);
 }
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 063b9aa313c227..9205f8919faeeb 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2136,19 +2136,16 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 	return 0;
 }
 
-static void btrfs_kill_super(struct super_block *sb)
+static void btrfs_free_sb(struct super_block *sb)
 {
-	struct btrfs_fs_info *fs_info = btrfs_sb(sb);
-
-	generic_shutdown_super(sb);
-	btrfs_free_fs_info(fs_info);
+	btrfs_free_fs_info(btrfs_sb(sb));
 }
 
 static struct file_system_type btrfs_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "btrfs",
 	.mount		= btrfs_mount,
-	.kill_sb	= btrfs_kill_super,
+	.free_sb	= btrfs_free_sb,
 	.fs_flags	= FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA | FS_MGTIME,
 };
 
@@ -2156,7 +2153,7 @@ static struct file_system_type btrfs_root_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "btrfs",
 	.mount		= btrfs_mount_root,
-	.kill_sb	= btrfs_kill_super,
+	.free_sb	= btrfs_free_sb,
 	.fs_flags	= FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA |
 			  FS_ALLOW_IDMAP | FS_MGTIME,
 };
diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index cbeaab8c21d8e6..327180889bb6e3 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -1509,13 +1509,13 @@ void ceph_dec_osd_stopping_blocker(struct ceph_mds_client *mdsc)
 	__dec_stopping_blocker(mdsc);
 }
 
-static void ceph_kill_sb(struct super_block *s)
+static void ceph_shutdown_sb(struct super_block *s)
 {
 	struct ceph_fs_client *fsc = ceph_sb_to_client(s);
 	struct ceph_mds_client *mdsc = fsc->mdsc;
 	bool wait;
 
-	dout("kill_sb %p\n", s);
+	dout("shutdown_sb %p\n", s);
 
 	ceph_mdsc_pre_umount(mdsc);
 	flush_fs_workqueues(fsc);
@@ -1552,7 +1552,11 @@ static void ceph_kill_sb(struct super_block *s)
 	}
 
 	mdsc->stopping = CEPH_MDSC_STOPPING_FLUSHED;
-	generic_shutdown_super(s);
+}
+
+static void ceph_free_sb(struct super_block *s)
+{
+	struct ceph_fs_client *fsc = ceph_sb_to_client(s);
 
 	fsc->client->extra_mon_dispatch = NULL;
 	ceph_fs_debugfs_cleanup(fsc);
@@ -1566,7 +1570,8 @@ static struct file_system_type ceph_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "ceph",
 	.init_fs_context = ceph_init_fs_context,
-	.kill_sb	= ceph_kill_sb,
+	.shutdown_sb	= ceph_shutdown_sb,
+	.free_sb	= ceph_free_sb,
 	.fs_flags	= FS_RENAME_DOES_D_MOVE,
 };
 MODULE_ALIAS_FS("ceph");
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index 5ee7d7bbb361ce..afd05c3b1b5032 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -482,12 +482,10 @@ static const struct file_operations cramfs_physmem_fops = {
 #endif
 };
 
-static void cramfs_kill_sb(struct super_block *sb)
+static void cramfs_free_sb(struct super_block *sb)
 {
 	struct cramfs_sb_info *sbi = CRAMFS_SB(sb);
 
-	generic_shutdown_super(sb);
-
 	if (IS_ENABLED(CONFIG_CRAMFS_MTD) && sb->s_mtd) {
 		if (sbi && sbi->mtd_point_size)
 			mtd_unpoint(sb->s_mtd, 0, sbi->mtd_point_size);
@@ -977,7 +975,7 @@ static struct file_system_type cramfs_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "cramfs",
 	.init_fs_context = cramfs_init_fs_context,
-	.kill_sb	= cramfs_kill_sb,
+	.free_sb	= cramfs_free_sb,
 	.fs_flags	= FS_REQUIRES_DEV,
 };
 MODULE_ALIAS_FS("cramfs");
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 3ed91537a3991a..cad39d6cc5d9d6 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -616,17 +616,10 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags
 	return ERR_PTR(rc);
 }
 
-/**
- * ecryptfs_kill_block_super
- * @sb: The ecryptfs super block
- *
- * Used to bring the superblock down and free the private data.
- */
-static void ecryptfs_kill_block_super(struct super_block *sb)
+static void ecryptfs_free_sb(struct super_block *sb)
 {
 	struct ecryptfs_sb_info *sb_info = ecryptfs_superblock_to_private(sb);
 
-	generic_shutdown_super(sb);
 	if (!sb_info)
 		return;
 	ecryptfs_destroy_mount_crypt_stat(&sb_info->mount_crypt_stat);
@@ -637,7 +630,7 @@ static struct file_system_type ecryptfs_fs_type = {
 	.owner = THIS_MODULE,
 	.name = "ecryptfs",
 	.mount = ecryptfs_mount,
-	.kill_sb = ecryptfs_kill_block_super,
+	.free_sb = ecryptfs_free_sb,
 	.fs_flags = 0
 };
 MODULE_ALIAS_FS("ecryptfs");
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index d9981532530702..08d543b88b840d 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -1837,10 +1837,8 @@ void fuse_mount_destroy(struct fuse_mount *fm)
 }
 EXPORT_SYMBOL(fuse_mount_destroy);
 
-static void fuse_kill_sb_anon(struct super_block *sb)
+static void fuse_free_sb_anon(struct super_block *sb)
 {
-	fuse_shutdown_sb(sb);
-	generic_shutdown_super(sb);
 	fuse_mount_destroy(get_fuse_mount_super(sb));
 }
 
@@ -1850,7 +1848,8 @@ static struct file_system_type fuse_fs_type = {
 	.fs_flags	= FS_HAS_SUBTYPE | FS_USERNS_MOUNT,
 	.init_fs_context = fuse_init_fs_context,
 	.parameters	= fuse_fs_parameters,
-	.kill_sb	= fuse_kill_sb_anon,
+	.shutdown_sb	= fuse_shutdown_sb,
+	.free_sb	= fuse_free_sb_anon,
 };
 MODULE_ALIAS_FS("fuse");
 
diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
index a52957df956394..8c2b0b226ddf63 100644
--- a/fs/fuse/virtio_fs.c
+++ b/fs/fuse/virtio_fs.c
@@ -1387,19 +1387,21 @@ static void virtio_fs_conn_destroy(struct fuse_mount *fm)
 	virtio_fs_free_devs(vfs);
 }
 
-static void virtio_kill_sb(struct super_block *sb)
+static void virtio_shutdown_sb(struct super_block *sb)
 {
-	struct fuse_mount *fm = get_fuse_mount_super(sb);
-	bool last;
-
 	/* If mount failed, we can still be called without any fc */
 	if (sb->s_root) {
-		last = fuse_mount_remove(fm);
+		struct fuse_mount *fm = get_fuse_mount_super(sb);
+		bool last = fuse_mount_remove(fm);
+
 		if (last)
 			virtio_fs_conn_destroy(fm);
 	}
-	generic_shutdown_super(sb);
-	fuse_mount_destroy(fm);
+}
+
+static void virtio_free_sb(struct super_block *sb)
+{
+	fuse_mount_destroy(get_fuse_mount_super(sb));
 }
 
 static int virtio_fs_test_super(struct super_block *sb,
@@ -1507,7 +1509,8 @@ static struct file_system_type virtio_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "virtiofs",
 	.init_fs_context = virtio_fs_init_fs_context,
-	.kill_sb	= virtio_kill_sb,
+	.shutdown_sb	= virtio_shutdown_sb,
+	.free_sb	= virtio_free_sb,
 };
 
 static int __init virtio_fs_init(void)
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 97f3c9709418c9..21d57098413222 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -979,9 +979,8 @@ static struct dentry *hostfs_read_sb(struct file_system_type *type,
 	return mount_nodev(type, flags, data, hostfs_fill_sb_common);
 }
 
-static void hostfs_kill_sb(struct super_block *s)
+static void hostfs_free_sb(struct super_block *s)
 {
-	generic_shutdown_super(s);
 	kfree(s->s_fs_info);
 }
 
@@ -989,7 +988,7 @@ static struct file_system_type hostfs_type = {
 	.owner 		= THIS_MODULE,
 	.name 		= "hostfs",
 	.mount	 	= hostfs_read_sb,
-	.kill_sb	= hostfs_kill_sb,
+	.free_sb	= hostfs_free_sb,
 	.fs_flags 	= 0,
 };
 MODULE_ALIAS_FS("hostfs");
diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c
index ee82e4cfb38bb5..4983931b5ad6e8 100644
--- a/fs/nfs/fs_context.c
+++ b/fs/nfs/fs_context.c
@@ -1646,15 +1646,15 @@ static int nfs_init_fs_context(struct fs_context *fc)
 	return 0;
 }
 
-static void nfs_kill_super(struct super_block *s)
+static void nfs_shutdown_sb(struct super_block *s)
 {
-	struct nfs_server *server = NFS_SB(s);
-
-	nfs_sysfs_move_sb_to_server(server);
-	generic_shutdown_super(s);
+	nfs_sysfs_move_sb_to_server(NFS_SB(s));
+}
 
+static void nfs_free_sb(struct super_block *s)
+{
 	nfs_fscache_release_super_cookie(s);
-	nfs_free_server(server);
+	nfs_free_server(NFS_SB(s));
 }
 
 struct file_system_type nfs_fs_type = {
@@ -1662,7 +1662,8 @@ struct file_system_type nfs_fs_type = {
 	.name			= "nfs",
 	.init_fs_context	= nfs_init_fs_context,
 	.parameters		= nfs_fs_parameters,
-	.kill_sb		= nfs_kill_super,
+	.shutdown_sb		= nfs_shutdown_sb,
+	.free_sb		= nfs_free_sb,
 	.fs_flags		= FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA,
 };
 MODULE_ALIAS_FS("nfs");
@@ -1674,7 +1675,8 @@ struct file_system_type nfs4_fs_type = {
 	.name			= "nfs4",
 	.init_fs_context	= nfs_init_fs_context,
 	.parameters		= nfs_fs_parameters,
-	.kill_sb		= nfs_kill_super,
+	.shutdown_sb		= nfs_shutdown_sb,
+	.free_sb		= nfs_free_sb,
 	.fs_flags		= FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA,
 };
 MODULE_ALIAS_FS("nfs4");
diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h
index b711654ca18a9c..73db7e6edb9966 100644
--- a/fs/orangefs/orangefs-kernel.h
+++ b/fs/orangefs/orangefs-kernel.h
@@ -344,7 +344,7 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
 			   const char *devname,
 			   void *data);
 
-void orangefs_kill_sb(struct super_block *sb);
+void orangefs_free_sb(struct super_block *sb);
 int orangefs_remount(struct orangefs_sb_info_s *);
 
 int fsid_key_table_initialize(void);
diff --git a/fs/orangefs/orangefs-mod.c b/fs/orangefs/orangefs-mod.c
index 5ab741c60b7e29..8b87eab0828126 100644
--- a/fs/orangefs/orangefs-mod.c
+++ b/fs/orangefs/orangefs-mod.c
@@ -47,7 +47,7 @@ MODULE_PARM_DESC(hash_table_size,
 static struct file_system_type orangefs_fs_type = {
 	.name = "pvfs2",
 	.mount = orangefs_mount,
-	.kill_sb = orangefs_kill_sb,
+	.free_sb = orangefs_free_sb,
 	.owner = THIS_MODULE,
 };
 
diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c
index bf3a834ad15033..7c8d9a3fe34fca 100644
--- a/fs/orangefs/super.c
+++ b/fs/orangefs/super.c
@@ -580,9 +580,9 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
 	return dget(sb->s_root);
 
 free_sb_and_op:
-	/* Will call orangefs_kill_sb with sb not in list. */
+	/* Will call orangefs_free_sb with sb not in list. */
 	ORANGEFS_SB(sb)->no_list = 1;
-	/* ORANGEFS_VFS_OP_FS_UMOUNT is done by orangefs_kill_sb. */
+	/* ORANGEFS_VFS_OP_FS_UMOUNT is done by orangefs_free_sb. */
 	deactivate_locked_super(sb);
 free_op:
 	gossip_err("orangefs_mount: mount request failed with %d\n", ret);
@@ -596,13 +596,10 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
 	return d;
 }
 
-void orangefs_kill_sb(struct super_block *sb)
+void orangefs_free_sb(struct super_block *sb)
 {
 	int r;
-	gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_kill_sb: called\n");
-
-	/* provided sb cleanup */
-	generic_shutdown_super(sb);
+	gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_free_sb: called\n");
 
 	if (!ORANGEFS_SB(sb)) {
 		mutex_lock(&orangefs_request_mutex);
diff --git a/fs/proc/root.c b/fs/proc/root.c
index 2282366449ac0b..81f6abedbd28b7 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -257,19 +257,20 @@ static int proc_init_fs_context(struct fs_context *fc)
 	return 0;
 }
 
-static void proc_kill_sb(struct super_block *sb)
+static void proc_shutdown_sb(struct super_block *sb)
 {
 	struct proc_fs_info *fs_info = proc_sb_info(sb);
 
-	if (!fs_info) {
-		generic_shutdown_super(sb);
+	if (!fs_info)
 		return;
-	}
-
 	dput(fs_info->proc_self);
 	dput(fs_info->proc_thread_self);
+}
+
+static void proc_free_sb(struct super_block *sb)
+{
+	struct proc_fs_info *fs_info = proc_sb_info(sb);
 
-	generic_shutdown_super(sb);
 	put_pid_ns(fs_info->pid_ns);
 	kfree(fs_info);
 }
@@ -278,7 +279,8 @@ static struct file_system_type proc_fs_type = {
 	.name			= "proc",
 	.init_fs_context	= proc_init_fs_context,
 	.parameters		= proc_fs_parameters,
-	.kill_sb		= proc_kill_sb,
+	.shutdown_sb		= proc_shutdown_sb,
+	.free_sb		= proc_free_sb,
 	.fs_flags		= FS_USERNS_MOUNT | FS_DISALLOW_NOTIFY_PERM,
 };
 
diff --git a/fs/romfs/super.c b/fs/romfs/super.c
index 5c35f6c760377e..d7c7e69db980e6 100644
--- a/fs/romfs/super.c
+++ b/fs/romfs/super.c
@@ -580,10 +580,8 @@ static int romfs_init_fs_context(struct fs_context *fc)
 /*
  * destroy a romfs superblock in the appropriate manner
  */
-static void romfs_kill_sb(struct super_block *sb)
+static void romfs_free_sb(struct super_block *sb)
 {
-	generic_shutdown_super(sb);
-
 #ifdef CONFIG_ROMFS_ON_MTD
 	if (sb->s_mtd) {
 		put_mtd_device(sb->s_mtd);
@@ -602,7 +600,7 @@ static struct file_system_type romfs_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "romfs",
 	.init_fs_context = romfs_init_fs_context,
-	.kill_sb	= romfs_kill_sb,
+	.free_sb	= romfs_free_sb,
 	.fs_flags	= FS_REQUIRES_DEV,
 };
 MODULE_ALIAS_FS("romfs");
diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c
index 5700f1065af756..34141c80a0bbd3 100644
--- a/fs/smb/client/cifsfs.c
+++ b/fs/smb/client/cifsfs.c
@@ -286,7 +286,7 @@ cifs_read_super(struct super_block *sb)
 	return rc;
 }
 
-static void cifs_kill_sb(struct super_block *sb)
+static void cifs_shutdown_sb(struct super_block *sb)
 {
 	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
 
@@ -301,9 +301,11 @@ static void cifs_kill_sb(struct super_block *sb)
 		dput(cifs_sb->root);
 		cifs_sb->root = NULL;
 	}
+}
 
-	generic_shutdown_super(sb);
-	cifs_umount(cifs_sb);
+static void cifs_free_sb(struct super_block *sb)
+{
+	cifs_umount(CIFS_SB(sb));
 }
 
 static int
@@ -1121,7 +1123,8 @@ struct file_system_type cifs_fs_type = {
 	.name = "cifs",
 	.init_fs_context = smb3_init_fs_context,
 	.parameters = smb3_fs_parameters,
-	.kill_sb = cifs_kill_sb,
+	.shutdown_sb = cifs_shutdown_sb,
+	.free_sb = cifs_free_sb,
 	.fs_flags = FS_RENAME_DOES_D_MOVE,
 };
 MODULE_ALIAS_FS("cifs");
@@ -1131,7 +1134,8 @@ struct file_system_type smb3_fs_type = {
 	.name = "smb3",
 	.init_fs_context = smb3_init_fs_context,
 	.parameters = smb3_fs_parameters,
-	.kill_sb = cifs_kill_sb,
+	.shutdown_sb = cifs_shutdown_sb,
+	.free_sb = cifs_free_sb,
 	.fs_flags = FS_RENAME_DOES_D_MOVE,
 };
 MODULE_ALIAS_FS("smb3");
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index b9d1ab63e3c87e..0bce555fd14d44 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -2347,19 +2347,16 @@ static struct dentry *ubifs_mount(struct file_system_type *fs_type, int flags,
 	return ERR_PTR(err);
 }
 
-static void kill_ubifs_super(struct super_block *s)
+static void ubifs_free_sb(struct super_block *s)
 {
-	struct ubifs_info *c = s->s_fs_info;
-
-	generic_shutdown_super(s);
-	kfree(c);
+	kfree(s->s_fs_info);
 }
 
 static struct file_system_type ubifs_fs_type = {
 	.name    = "ubifs",
 	.owner   = THIS_MODULE,
 	.mount   = ubifs_mount,
-	.kill_sb = kill_ubifs_super,
+	.free_sb = ubifs_free_sb,
 };
 MODULE_ALIAS_FS("ubifs");
 
-- 
2.39.2


  parent reply	other threads:[~2023-09-13 11:12 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-13 11:09 split up ->kill_sb Christoph Hellwig
2023-09-13 11:09 ` Christoph Hellwig
2023-09-13 11:09 ` [PATCH 01/19] fs: reflow deactivate_locked_super Christoph Hellwig
2023-09-13 11:09   ` Christoph Hellwig
2023-09-13 16:35   ` Christian Brauner
2023-09-13 16:35     ` Christian Brauner
2023-09-26  9:24     ` Christoph Hellwig
2023-09-26  9:24       ` Christoph Hellwig
2023-09-13 11:09 ` [PATCH 02/19] fs: make ->kill_sb optional Christoph Hellwig
2023-09-13 11:09   ` Christoph Hellwig
2023-09-13 11:09 ` [PATCH 03/19] fs: release anon dev_t in deactivate_locked_super Christoph Hellwig
2023-09-13 11:09   ` Christoph Hellwig
2023-09-13 23:27   ` Al Viro
2023-09-13 23:27     ` Al Viro
2023-09-14  2:37     ` Al Viro
2023-09-14  2:37       ` Al Viro
2023-09-14  5:38       ` Al Viro
2023-09-14  5:38         ` Al Viro
2023-09-14  7:56         ` Christian Brauner
2023-09-14  7:56           ` Christian Brauner
2023-09-26  9:31           ` Christoph Hellwig
2023-09-26  9:31             ` Christoph Hellwig
2023-09-14 14:02         ` Christian Brauner
2023-09-14 14:02           ` Christian Brauner
2023-09-14 16:58           ` Al Viro
2023-09-14 16:58             ` Al Viro
2023-09-14 19:23             ` Al Viro
2023-09-14 19:23               ` Al Viro
2023-09-15  7:40               ` Christian Brauner
2023-09-15  7:40                 ` Christian Brauner
2023-09-15  9:44             ` Christian Brauner
2023-09-15  9:44               ` Christian Brauner
2023-09-15 14:12               ` Christian Brauner
2023-09-15 14:12                 ` Christian Brauner
2023-09-15 14:28                 ` Al Viro
2023-09-15 14:28                   ` Al Viro
2023-09-15 14:33                   ` Al Viro
2023-09-15 14:33                     ` Al Viro
2023-09-15 14:40                   ` Christian Brauner
2023-09-15 14:40                     ` Christian Brauner
2023-09-26  9:41         ` Christoph Hellwig
2023-09-26  9:41           ` Christoph Hellwig
2023-09-26  9:38     ` Christoph Hellwig
2023-09-26  9:38       ` Christoph Hellwig
2023-09-26 21:25       ` Al Viro
2023-09-27 22:29         ` Al Viro
2023-10-02  6:46         ` Christoph Hellwig
2023-10-09 21:57           ` Al Viro
2023-10-10  8:44             ` Christian Brauner
2023-10-17 19:50               ` Al Viro
2023-09-13 11:09 ` [PATCH 04/19] NFS: remove the s_dev field from struct nfs_server Christoph Hellwig
2023-09-13 11:09   ` Christoph Hellwig
2023-09-13 11:09 ` [PATCH 05/19] fs: assign an anon dev_t in common code Christoph Hellwig
2023-09-13 11:09   ` Christoph Hellwig
2023-09-14  0:34   ` Al Viro
2023-09-14  0:34     ` Al Viro
2023-09-13 11:10 ` [PATCH 06/19] qibfs: use simple_release_fs Christoph Hellwig
2023-09-13 11:10   ` Christoph Hellwig
2023-09-18 11:41   ` Leon Romanovsky
2023-09-18 11:41     ` Leon Romanovsky
2023-09-13 11:10 ` [PATCH 07/19] hypfs: use d_genocide to kill fs entries Christoph Hellwig
2023-09-13 11:10   ` Christoph Hellwig
2023-09-13 11:10 ` [PATCH 08/19] pstore: shrink the pstore_sb_lock critical section in pstore_kill_sb Christoph Hellwig
2023-09-13 11:10   ` Christoph Hellwig
2023-09-13 22:07   ` Kees Cook
2023-09-13 22:07     ` Kees Cook
2023-09-13 11:10 ` [PATCH 09/19] zonefs: remove duplicate cleanup in zonefs_fill_super Christoph Hellwig
2023-09-13 11:10   ` Christoph Hellwig
2023-09-14  0:33   ` Damien Le Moal
2023-09-14  0:33     ` Damien Le Moal
2023-09-14  0:49   ` Al Viro
2023-09-14  0:49     ` Al Viro
2023-09-13 11:10 ` [PATCH 10/19] USB: gadget/legacy: remove sb_mutex Christoph Hellwig
2023-09-13 11:10   ` Christoph Hellwig
2023-09-13 16:10   ` Alan Stern
2023-09-13 16:10     ` Alan Stern
2023-09-26  9:24     ` Christoph Hellwig
2023-09-26  9:24       ` Christoph Hellwig
2023-09-14 10:22   ` Sergey Shtylyov
2023-09-14 10:22     ` Sergey Shtylyov
2023-09-13 11:10 ` [PATCH 11/19] fs: add new shutdown_sb and free_sb methods Christoph Hellwig
2023-09-13 11:10   ` Christoph Hellwig
2023-09-14  2:07   ` Al Viro
2023-09-14  2:07     ` Al Viro
2023-09-13 11:10 ` [PATCH 12/19] fs: convert kill_litter_super to litter_shutdown_sb Christoph Hellwig
2023-09-13 11:10   ` Christoph Hellwig
2023-09-13 22:07   ` Kees Cook
2023-09-13 22:07     ` Kees Cook
2023-09-13 11:10 ` [PATCH 13/19] fs: convert kill_block_super to block_free_sb Christoph Hellwig
2023-09-13 11:10   ` Christoph Hellwig
2023-09-14  2:29   ` Al Viro
2023-09-14  2:29     ` Al Viro
2023-09-13 11:10 ` [PATCH 14/19] jffs2: convert to ->shutdown_sb and ->free_sb Christoph Hellwig
2023-09-13 11:10   ` Christoph Hellwig
2023-09-13 11:10 ` [PATCH 15/19] kernfs: split ->kill_sb Christoph Hellwig
2023-09-13 11:10   ` Christoph Hellwig
2023-09-18 15:24   ` Michal Koutný
2023-09-18 15:24     ` Michal Koutný
2023-09-13 11:10 ` [PATCH 16/19] x86/resctrl: release rdtgroup_mutex and the CPU hotplug lock in rdt_shutdown_sb Christoph Hellwig
2023-09-13 11:10   ` Christoph Hellwig
2023-09-13 11:10 ` [PATCH 17/19] NFS: move nfs_kill_super to fs_context.c Christoph Hellwig
2023-09-13 11:10   ` Christoph Hellwig
2023-09-13 11:10 ` Christoph Hellwig [this message]
2023-09-13 11:10   ` [PATCH 18/19] fs: simple ->shutdown_sb and ->free_sb conversions Christoph Hellwig
2023-09-13 11:10 ` [PATCH 19/19] fs: remove ->kill_sb Christoph Hellwig
2023-09-13 11:10   ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230913111013.77623-19-hch@lst.de \
    --to=hch@lst.de \
    --cc=agordeev@linux.ibm.com \
    --cc=anna@kernel.org \
    --cc=brauner@kernel.org \
    --cc=cgroups@vger.kernel.org \
    --cc=dennis.dalessandro@cornelisnetworks.com \
    --cc=dlemoal@kernel.org \
    --cc=fenghua.yu@intel.com \
    --cc=gor@linux.ibm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hca@linux.ibm.com \
    --cc=keescook@chromium.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=naohiro.aota@wdc.com \
    --cc=reinette.chatre@intel.com \
    --cc=richard@nod.at \
    --cc=tj@kernel.org \
    --cc=trond.myklebust@hammerspace.com \
    --cc=vigneshr@ti.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.