On Aug 25, 2020, at 6:16 AM, Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote: > > On Tue, Aug 25, 2020 at 02:05:54PM +0200, Jan Kara wrote: >> Discarding blocks and buffers under a mounted filesystem is hardly >> anything admin wants to do. Usually it will confuse the filesystem and >> sometimes the loss of buffer_head state (including b_private field) can >> even cause crashes like: > > Doesn't work if the file system uses multiple devices. It's not _worse_ than the current situation of allowing the complete destruction of the mounted filesystem. It doesn't fix the problem for XFS with realtime devices, or ext4 with a separate journal device, but it fixes the problem for a majority of users with a single device filesystem. While BLKFLSBUF causing a crash is annoying, BLKDISCARD/BLKSECDISCARD under a mounted filesystem is definitely dangerous and wrong. What about checking for O_EXCL on the device, indicating that it is currently in use by some higher level? Cheers, Andreas
Attachment:
signature.asc
Description: Message signed with OpenPGP