Re: [PATCH RFC 2/2] block: Do not discard buffers under a mounted filesystem

Andreas Dilger
2020-08-28T08:21:38Z

[-- Attachment #1: Type: text/plain, Size: 997 bytes --]

On Aug 25, 2020, at 6:16 AM, Christoph Hellwig <hch@infradead.org> 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 #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 873 bytes --]