summaryrefslogtreecommitdiff
path: root/fs/romfs
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2023-07-24 10:51:45 -0700
committerChristian Brauner <brauner@kernel.org>2023-08-10 10:34:56 +0200
commitaca740cecbe57b12bd9c1fc632092af5ebacda0c (patch)
treef428c673f3260b06ad92c897fe70bc81c4150a31 /fs/romfs
parenta4f64a300a299f884a1da55d99c97a87061201cd (diff)
fs: open block device after superblock creation
Currently get_tree_bdev and mount_bdev open the block device before committing to allocating a super block. That creates problems for restricting the number of writers to a device, and also leads to a unusual and not very helpful holder (the fs_type). Reorganize the super block code to first look whether the superblock for a particular device does already exist and open the block device only if it doesn't. [hch: port to before the bdev_handle changes, duplicate the bdev read-only check from blkdev_get_by_path, extend the fsfree_mutex coverage to protect against freezes, fix an open bdev leak when the bdev is frozen, use the bdev local variable more, rename the s variable to sb to be more descriptive] [brauner: remove references to mounts as they're mostly irrelevant] [brauner & hch: fold fixes for romfs and cramfs for syzbot+2faac0423fdc9692822b@syzkaller.appspotmail.com] Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Christoph Hellwig <hch@lst.de> Message-Id: <20230724175145.201318-1-hch@lst.de> Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/romfs')
-rw-r--r--fs/romfs/super.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/romfs/super.c b/fs/romfs/super.c
index c59b230d55b4..42d7a344472f 100644
--- a/fs/romfs/super.c
+++ b/fs/romfs/super.c
@@ -583,16 +583,18 @@ static int romfs_init_fs_context(struct fs_context *fc)
*/
static void romfs_kill_sb(struct super_block *sb)
{
+ generic_shutdown_super(sb);
+
#ifdef CONFIG_ROMFS_ON_MTD
if (sb->s_mtd) {
- kill_mtd_super(sb);
- return;
+ put_mtd_device(sb->s_mtd);
+ sb->s_mtd = NULL;
}
#endif
#ifdef CONFIG_ROMFS_ON_BLOCK
if (sb->s_bdev) {
- kill_block_super(sb);
- return;
+ sync_blockdev(sb->s_bdev);
+ blkdev_put(sb->s_bdev, sb->s_type);
}
#endif
}