• Jan Kara's avatar
    fs: open block device after superblock creation · aca740ce
    Jan Kara authored
    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: default avatarJan Kara <jack@suse.cz>
    Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
    Message-Id: <20230724175145.201318-1-hch@lst.de>
    Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
    aca740ce
super.c 15.3 KB