On Wed, 6 Sep 2023, Christian Brauner wrote: > On Wed, Sep 06, 2023 at 06:01:06PM +0200, Mikulas Patocka wrote: > > > > > > On Wed, 6 Sep 2023, Christian Brauner wrote: > > > > > > > IOW, you'd also hang on any umount of a bind-mount. IOW, every > > > > > single container making use of this filesystems via bind-mounts would > > > > > hang on umount and shutdown. > > > > > > > > bind-mount doesn't modify "s->s_writers.frozen", so the patch does nothing > > > > in this case. I tried unmounting bind-mounts and there was no deadlock. > > > > > > With your patch what happens if you do the following? > > > > > > #!/bin/sh -ex > > > modprobe brd rd_size=4194304 > > > vgcreate vg /dev/ram0 > > > lvcreate -L 16M -n lv vg > > > mkfs.ext4 /dev/vg/lv > > > > > > mount -t ext4 /dev/vg/lv /mnt/test > > > mount --bind /mnt/test /opt > > > mount --make-private /opt > > > > > > dmsetup suspend /dev/vg/lv > > > (sleep 1; dmsetup resume /dev/vg/lv) & > > > > > > umount /opt # I'd expect this to hang > > > > > > md5sum /dev/vg/lv > > > md5sum /dev/vg/lv > > > dmsetup remove_all > > > rmmod brd > > > > "umount /opt" doesn't hang. It waits one second (until dmsetup resume is > > called) and then proceeds. > > So unless I'm really misreading the code - entirely possible - the > umount of the bind-mount now waits until the filesystem is resumed with > your patch. And if that's the case that's a bug. Yes. It can be fixed by changing wait_and_deactivate_super to this: void wait_and_deactivate_super(struct super_block *s) { down_write(&s->s_umount); while (s->s_writers.frozen != SB_UNFROZEN && atomic_read(&s->s_active) == 2) { up_write(&s->s_umount); msleep(1); down_write(&s->s_umount); } deactivate_locked_super(s); } > > > > BTW. what do you think that unmount of a frozen filesystem should properly > > > > do? Fail with -EBUSY? Or, unfreeze the filesystem and unmount it? Or > > > > something else? > > > > > > In my opinion we should refuse to unmount frozen filesystems and log an > > > error that the filesystem is frozen. Waiting forever isn't a good idea > > > in my opinion. > > > > But lvm may freeze filesystems anytime - so we'd get randomly returned > > errors then. > > So? Or you might hang at anytime. lvm doesn't keep logical volumes suspended for a prolonged amount of time. It will unfreeze them after it made updates to the dm table and to the metadata. So, it won't hang forever. I think it's better to sleep for a short time in umount than to return an error. Mikulas