On Fri, Jun 20, 2025 at 03:05:42PM +0100, John Garry wrote: > On 11/06/2025 10:34, Ojaswin Mujoo wrote: > > This test is intended to ensure that multi blocks atomic writes > > maintain atomic guarantees across sudden FS shutdowns. > > This looks like an interesting test. Can you please consider writing a > fuller commit message describing how it works? Hey John, sure I'll add a more comprehensive commit message. Basically what we do here is to create a mixed mapping and then do an atomic write on it while shutting the FS down in parallel. Then we note down the last offset n where write happened before shutdown and check blocks from n - 5 to n + 5 to ensure they either have completely old data or completely new data but not a mix of both. We repeat this for non mixed mappings like fully written, hole etc but the mixed one is the one most likely to get torn. > > And do you verify that the test would fail for a non-atomic writes (before > proving that it works for atomic writes)? Yes we were reliably able to see torn data, every 20 iterations or so, when we tried this test on a non atomic block device (after modifying the test a bit eg not passing -A to pwrite). Infact even with an atomic device, we were also able to detect an issue in ext4's early multiblock atomic write implementation where mishandling of the transaction was resulting in torn data. > > I've had a lot of difficulty testing atomic write behavior for system > crash/unexpected shutdown, so it would be interesting to see how this works. > > In the meantime, I'll try to understand the code... Sure, one thing to note is that we use FS shutdown and focus mostly on making sure the FS doesn't tear the write. We might need something similar for block layer as well at some point. > > Thanks, > John Regards, ojaswin