On Mon, Jul 24, 2023 at 10:51:45AM -0700, Christoph Hellwig wrote: > From: Jan Kara <jack@xxxxxxx> > > Currently get_tree_bdev and mount_bdev open the block device before > commiting to allocating a super block. This means the block device > is opened even for bind mounts and other reuses of the 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 mount code to first look whether the superblock for a > particular device is already mounted and open the block device only if > it is not. > > Signed-off-by: Jan Kara <jack@xxxxxxx> > [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] > Signed-off-by: Christoph Hellwig <hch@xxxxxx> > --- > > So I promised to get a series that builds on top of this ready, but > I'm way to busy and this will take a while. Getting this reworked > version of Jan's patch out for everyone to use it as a based given > that Christian is back from vacation, and I think Jan should be about > back now as well. I'm in the middle of reviewing this. You're probably aware, but both btrfs and nilfs at least still open the devices first since they open-code their bdev and sb handling.