Re: [PATCH 6/6] fs: Make bind mounts work with bdev_allow_write_mounted=n

Jan Kara
2023-07-06T16:13:01Z

On Thu 06-07-23 08:55:18, Christoph Hellwig wrote:
> On Tue, Jul 04, 2023 at 02:56:54PM +0200, Jan Kara wrote:
> > When we don't allow opening of mounted block devices for writing, bind
> > mounting is broken because the bind mount tries to open the block device
> > before finding the superblock for it already exists. Reorganize the
> > mounting code to first look whether the superblock for a particular
> > device is already mounted and open the block device only if it is not.
>
> Warning: this might be a rathole.
>
> I really hate how mount_bdev / get_tree_bdev try to deal with multiple
> mounts.
>
> The idea to just open the device and work from there just feels very
> bogus.
>
> There is really no good reason to have the bdev to find a superblock,
> the dev_t does just fine (and in fact I have a patch to remove
> the bdev based get_super and just use the dev_t based one all the
> time). So I'd really like to actually turn this around and only
> open when we need to allocate a new super block. That probably
> means tearning sget_fc apart a bit, so it will turn into a fair
> amount of work, but I think it's the right thing to do.

Well, this is exactly what this patch does - we use dev_t to lookup the
superblock in sget_fc() and we open the block device only if we cannot find
matching superblock and need to create a new one...

Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR