Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1171785rwo; Wed, 2 Aug 2023 09:43:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlGIsMyum4Hgy53GJOqA+RemxTzi5b56TpYC/dSRkQFX6zps/3hEhi87UFQoydRbmlxHrlew X-Received: by 2002:a05:6a20:d90b:b0:13d:af0e:4ee5 with SMTP id jd11-20020a056a20d90b00b0013daf0e4ee5mr10629959pzb.18.1690994585351; Wed, 02 Aug 2023 09:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690994585; cv=none; d=google.com; s=arc-20160816; b=PnTZ/dwaqt2XRpC9nTG0+n0vsLG5Asug0iFRDlF8S8ctkmYn++VUsP2gPZ/7djn7Vu ie1fYlnAICOaAkzg6T99j5DFI9Jy4LAoKzVvTtpNkEUvjA5vFlR3Xahd9i/OB7byTmZN GroI0t8kR5vSisW0+gK1pBmDOUx4x0OPI2iy42rzCt3P0bOSaLGBAvrUvK0iKn9qKiUk eV6k3B/0wXB6XkoAymAb954EDqlkt/CDaUveqJwR6fN9SxQSfARuGTQ5BlJQbS3QIyXM cU+V4X/Qzdm254Rc2P/H6joDVKz7COUBlaRoJ9QzdzsohY8fduMM55a+wKKrf47I05xh hbjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=M1CYJB5aZHpSvwyG1hOGEAK3efdcwABvgd5jbMJTCG8=; fh=EY4nBjRR1THbvUmIeG1UZvfGbBl7lvcJq64vCzE68S8=; b=0zFYzRw1ibcYNU8aUI0wX8BAyh8BP8YY3besbxJrOB+bgpkfBdA6OJPA4qq6auYAwW piRxViSbD9f5YUf9j9FgGDqOG9bHKHoYeGh+8IW9zhUG2Es+5kTh6MZFKaUdXopfcBZr o6vJanPV4Y03F8u++85n85ciKg6XZCpM4msvQ0GlSz/vn8c5r1l113sjtpHKE96tqe/F HE5SOLWHWTNZ0oMoR1k1alcWX61w7LmVhB+iCxOOOuHujVek8WYzfQH8e8bQREmvVhFS RiRfVBOwc11MiA5ZinLlbFNbJcZEbXs6+03EOtbBiAUCXpO6XyihG5nce3DEDeGsO8Mq MpAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=4M2U9E2z; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cn7-20020a056a00340700b0068722b7ab8esi2530203pfb.222.2023.08.02.09.42.51; Wed, 02 Aug 2023 09:43:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=4M2U9E2z; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233889AbjHBPmi (ORCPT + 99 others); Wed, 2 Aug 2023 11:42:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235272AbjHBPmQ (ORCPT ); Wed, 2 Aug 2023 11:42:16 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AB9B2122; Wed, 2 Aug 2023 08:42:05 -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=M1CYJB5aZHpSvwyG1hOGEAK3efdcwABvgd5jbMJTCG8=; b=4M2U9E2zBIKq45Q55cHcXCmYTg gAnYWD0UBubVeGE8flbFzHcT2SAbc9FEd/qFH3xmSbWluAsI7ww7kYoPqlU3QRz8RzFRKLHIzCgsf cr+3pEEMdDlLG1z5QCdKhFRnxuZje6F/ETjowj21lvzt7iG5qDNkgAKTduXm8RM6mxtnghjEmUiaS 7mgukROVBAbdXXqRfUtEp/TlgAYZIPJaVLwJpzJz5iuX46JRBvvwzLD9hgz9rnWt+GHxif423Xbbh VxSnMzgn7bE0RP3Snb8vXJU9C2OAa1FWQ+NPZeXwjgltT9BQvqIRMcNdE46+kaNcA/LQM6OmRuIiT 4Jzx0irw==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qRDz3-005GGI-2j; Wed, 02 Aug 2023 15:41:58 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner Cc: Jan Kara , Chris Mason , Josef Bacik , David Sterba , "Theodore Ts'o" , Andreas Dilger , Jaegeuk Kim , Chao Yu , Ryusuke Konishi , "Darrick J. Wong" , Jens Axboe , linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH 06/12] fs: use the super_block as holder when mounting file systems Date: Wed, 2 Aug 2023 17:41:25 +0200 Message-Id: <20230802154131.2221419-7-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230802154131.2221419-1-hch@lst.de> References: <20230802154131.2221419-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org The file system type is not a very useful holder as it doesn't allow us to go back to the actual file system instance. Pass the super_block instead which is useful when passed back to the file system driver. Signed-off-by: Christoph Hellwig --- fs/btrfs/super.c | 7 ++----- fs/f2fs/super.c | 7 +++---- fs/super.c | 8 ++++---- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 5980b5dcc6b163..8a47c7f2690880 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -69,8 +69,6 @@ static const struct super_operations btrfs_super_ops; * requested by subvol=/path. That way the callchain is straightforward and we * don't have to play tricks with the mount options and recursive calls to * btrfs_mount. - * - * The new btrfs_root_fs_type also servers as a tag for the bdev_holder. */ static struct file_system_type btrfs_fs_type; static struct file_system_type btrfs_root_fs_type; @@ -1498,8 +1496,7 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, } else { struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; - error = btrfs_open_devices(fs_devices, sb_open_mode(flags), - fs_type); + error = btrfs_open_devices(fs_devices, sb_open_mode(flags), s); if (error) goto out_deactivate; @@ -1513,7 +1510,7 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, fs_devices->latest_dev->bdev); shrinker_debugfs_rename(&s->s_shrink, "sb-%s:%s", fs_type->name, s->s_id); - btrfs_sb(s)->bdev_holder = fs_type; + fs_info->bdev_holder = s; error = btrfs_fill_super(s, fs_devices, data); } if (!error) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index ca31163da00a55..05c90fdb7a6cca 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1561,7 +1561,7 @@ static void destroy_device_list(struct f2fs_sb_info *sbi) int i; for (i = 0; i < sbi->s_ndevs; i++) { - blkdev_put(FDEV(i).bdev, sbi->sb->s_type); + blkdev_put(FDEV(i).bdev, sbi->sb); #ifdef CONFIG_BLK_DEV_ZONED kvfree(FDEV(i).blkz_seq); #endif @@ -4198,7 +4198,7 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi) /* Single zoned block device mount */ FDEV(0).bdev = blkdev_get_by_dev(sbi->sb->s_bdev->bd_dev, mode, - sbi->sb->s_type, NULL); + sbi->sb, NULL); } else { /* Multi-device mount */ memcpy(FDEV(i).path, RDEV(i).path, MAX_PATH_LEN); @@ -4217,8 +4217,7 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi) sbi->log_blocks_per_seg) - 1; } FDEV(i).bdev = blkdev_get_by_path(FDEV(i).path, mode, - sbi->sb->s_type, - NULL); + sbi->sb, NULL); } if (IS_ERR(FDEV(i).bdev)) return PTR_ERR(FDEV(i).bdev); diff --git a/fs/super.c b/fs/super.c index 6aaa275fa8630d..09b65ee1a8b737 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1249,7 +1249,7 @@ int setup_bdev_super(struct super_block *sb, int sb_flags, blk_mode_t mode = sb_open_mode(sb_flags); struct block_device *bdev; - bdev = blkdev_get_by_dev(sb->s_dev, mode, sb->s_type, &fs_holder_ops); + bdev = blkdev_get_by_dev(sb->s_dev, mode, sb, &fs_holder_ops); if (IS_ERR(bdev)) { if (fc) errorf(fc, "%s: Can't open blockdev", fc->source); @@ -1262,7 +1262,7 @@ int setup_bdev_super(struct super_block *sb, int sb_flags, * writable from userspace even for a read-only block device. */ if ((mode & BLK_OPEN_WRITE) && bdev_read_only(bdev)) { - blkdev_put(bdev, sb->s_type); + blkdev_put(bdev, sb); return -EACCES; } @@ -1278,7 +1278,7 @@ int setup_bdev_super(struct super_block *sb, int sb_flags, mutex_unlock(&bdev->bd_fsfreeze_mutex); if (fc) warnf(fc, "%pg: Can't mount, blockdev is frozen", bdev); - blkdev_put(bdev, sb->s_type); + blkdev_put(bdev, sb); return -EBUSY; } spin_lock(&sb_lock); @@ -1418,7 +1418,7 @@ void kill_block_super(struct super_block *sb) if (bdev) { bdev->bd_super = NULL; sync_blockdev(bdev); - blkdev_put(bdev, sb->s_type); + blkdev_put(bdev, sb); } } -- 2.39.2