On Wed, May 10, 2023 at 08:19:58AM +1000, Dave Chinner wrote: > The userspace shutdown code already does this by default - it > actually calls freeze_bdev() to cause the filesystem to be made > consistent on the block device before it executes the shutdown. > So, in effect, we already have the "shutdown before turning off > block device" paths in the filesystems and extremely well tested. Yes. > Indeed, if the device is being removed, why not call freeze_bdev() > before doing anything else? It guarantees that applications will be > quiesced and the filesystem will stabilise and not try to change > anything until the shutdown occurs when the device is pulled... Because the primary use case of using sysfs to yank a block device out under a live fs is testing the shutdown path. Changing behavior here will not improve any actual user live, because no user actually intentially does this, but at the same time we add new odd code we need to test, while breaking existing tests.