Re: [PATCH RFC 1/4] block: Make bdev_can_atomic_write() robust against mis-aligned bdev size
From: John Garry
Date: Thu Sep 12 2024 - 10:58:47 EST
On 12/09/2024 14:15, Christoph Hellwig wrote:
On Tue, Sep 03, 2024 at 03:07:45PM +0000, John Garry wrote:
For bdev file operations, a write will be truncated when trying to write
past the end of the device. This could not be tolerated for an atomic
write.
Ensure that the size of the bdev matches max atomic write unit so that this
truncation would never occur.
But we'd still support atomic writes for all but the last sectors of
the device?
We should do be able to, but with this patch we cannot. However, a
misaligned partition would be very much unexpected.
Isn't this really an application problem?
Sure, if the application tried to do an atomic write to the end of the
device and it was truncated.
If not supporting atomic writes at all for unaligned devices is the right
thing to do, we'll need to clearly document this somewhere. Any maybe
also add a pr_once to log a message?
I could also just reject any truncation on the atomic write in fops.
Maybe that is better.
And at some stage looking at making parted, fdisk, and other
partitioning tools atomic write aware would be good, so that the user
knows about these restrictions.
Thanks,
John