[dm-devel] [PATCH 3/3] block: fail writes to read-only devices
Linus Torvalds
torvalds at linux-foundation.org
Fri Jun 2 15:56:26 UTC 2023
On Fri, Jun 2, 2023 at 11:41 AM Christoph Hellwig <hch at lst.de> wrote:
>
> Except the whole make a thing readonly just for fun is the corner case.
> DM does it, and we have a sysfs file to allow it. But the usual
> case is that a block device has been read-only all the time, or has
> been force to be read-only by the actual storage device, which
> doesn't know anything about the file descriptor model, and will
> not be happy.
The "it's always been read-only" case is unambiguous.
So I do wonder if we should have two read-only bits: a "hard" and
"soft" bit, and make the open-time one the hard bit.
Anyway, I'm ok trying this simple thing once more, but if we end up
getting reports of breakage again, I think you may just need to accept
the fact that "somebody turned the device read-only after the fact"
may just be something the kernel will have to continue to deal with.
We might be able to squirrell the "read-only at time of open" bit away
in the file descriptor in the FMODE_CAN_WRITE bit or something like
that (although that would gives the wrong error for write(): -EINVAL
instead of -EROFS or whatever)
Linus
More information about the dm-devel
mailing list