Repository navigation
Conversation
|
Upstream branch: 24a19b9 |
|
Upstream branch: 24a19b9 |
a32ae97 to
8061221
Compare
2e69118 to
3cdd51f
Compare
|
Upstream branch: 4056b3c |
8061221 to
75119cf
Compare
3cdd51f to
e6ca2c1
Compare
|
Upstream branch: 0fcb05b |
75119cf to
2f95abc
Compare
e6ca2c1 to
3d027d5
Compare
|
Upstream branch: 58161ea |
2f95abc to
60e1bff
Compare
3d027d5 to
90ea7e4
Compare
|
Upstream branch: c03c1a1 |
60e1bff to
2b7c291
Compare
90ea7e4 to
435b194
Compare
|
Upstream branch: 7be4bc5 |
2b7c291 to
b1d4b78
Compare
435b194 to
fd67522
Compare
|
Upstream branch: 17bb0e2 |
b1d4b78 to
38840cc
Compare
fd67522 to
3b53a63
Compare
|
Upstream branch: 21a7f44 |
38840cc to
08a78fd
Compare
3b53a63 to
5d84576
Compare
|
Upstream branch: 6b4b543 |
5d84576 to
6582ed2
Compare
|
Upstream branch: fb2c3f4 |
8060932 to
c965365
Compare
6582ed2 to
b3a1abc
Compare
|
Upstream branch: d135ab4 |
c965365 to
48fe767
Compare
b3a1abc to
712496f
Compare
|
Upstream branch: c339f40 |
48fe767 to
01a63d4
Compare
712496f to
a186880
Compare
|
Upstream branch: d89e1d1 |
01a63d4 to
e4fc733
Compare
a186880 to
46206a3
Compare
|
Upstream branch: 6628e7d |
e4fc733 to
85ab541
Compare
46206a3 to
220bd96
Compare
|
Upstream branch: 05441d6 |
85ab541 to
737565a
Compare
220bd96 to
6c4625e
Compare
|
Upstream branch: f66469d |
737565a to
f0620f2
Compare
6c4625e to
c7f678d
Compare
|
Upstream branch: d487237 |
f0620f2 to
bf32589
Compare
c7f678d to
6aa6cd1
Compare
ext4_dio_write_iter() falls back to buffered I/O when the inode can't do direct I/O at all, i.e. journaled data, inline data or verity. That fallback runs before any atomic write handling, and ext4_buffered_write_iter() doesn't look at IOCB_ATOMIC, so an atomic write to such an inode is silently done as a plain buffered write with no torn-write protection. ext4_inode_can_atomic_write() makes it worse for journaled data by advertising atomic writes for those inodes: statx() reports atomic write limits and the file gets FMODE_CAN_ATOMIC_WRITE, so the write passes the VFS checks and reaches the fallback. This is reachable with data=journal, or with chattr +j on a nodelalloc mount. Inline data inodes don't have the extents flag and verity files can't be opened for writing, so those are refused before ext4 sees the write, but the fallback would still accept them. Reject IOCB_ATOMIC in ext4_buffered_write_iter(), next to the existing IOCB_NOWAIT rejection, so neither fallback into it can complete an atomic write non-atomically. Also require ext4_dio_alignment() to be nonzero in ext4_inode_can_atomic_write(), so statx() stops advertising atomic writes for these inodes and VFS refuses RWF_ATOMIC early. The runtime check is still needed, as the journal data flag can be changed on an open file. Fixes: b7987a7 ("ext4: Support setting FMODE_CAN_ATOMIC_WRITE") Reported-by: Sashiko <sashiko-bot@kernel.org> Link: https://sashiko.dev/#/patchset/20260909-ext4-atomic-no-fallback-v1-1-5a6b9539c002%40columbia.edu Signed-off-by: Tal Zussman <tz2294@columbia.edu> Reviewed-by: Jan Kara <jack@suse.cz>
ext4_dio_write_iter() finishes a short direct write through the page cache. ext4_buffered_write_iter() now rejects IOCB_ATOMIC, so a short atomic write would warn and then fail with -EOPNOTSUPP, as if atomic writes were unsupported on the inode. This came out of a block device fix [1], where an IOCB_ATOMIC direct write could complete short when only part of the buffer could be pinned, with the rest going through the buffered fallback. Christoph Hellwig noted that ext4 has the same fallback and only warns in it [2], and John Garry agreed it should reject the write instead [3]. In contrast to the block device, nothing reaches the branch on ext4 today: iomap requires the mapping to cover the whole atomic write, a buffer that can't be pinned in full fails in iomap before the bio is submitted, and a failed page cache invalidation returns -EAGAIN rather than reaching the buffered fallback. A short atomic write is therefore a bug, and neither a short count nor -EOPNOTSUPP is a valid result for one. Fail the write with -EIO before the fallback, keeping the WARN() so any future bug is visible. Link: https://lore.kernel.org/linux-block/20260828-blkdev-fixes-v2-0-32f3f40cebed@columbia.edu/ [1] Link: https://lore.kernel.org/linux-block/20260907071217.GD934@lst.de/ [2] Link: https://lore.kernel.org/linux-block/a7752d1e-8ec1-44d1-a266-c287c315e8ab@oracle.com/ [3] Signed-off-by: Tal Zussman <tz2294@columbia.edu> Reviewed-by: Jan Kara <jack@suse.cz>
ext4_file_write_iter() hands DAX inodes to ext4_dax_write_iter() before any of the atomic write handling, and the DAX path neither checks IOCB_ATOMIC nor provides torn-write protection. ext4_inode_can_atomic_write() doesn't exclude DAX inodes, so on a device that supported both DAX and atomic writes, statx() would advertise atomic writes for such an inode and the VFS would let an RWF_ATOMIC write through to a plain DAX write. No DAX-capable block device advertises atomic write limits today, so this isn't reachable. When XFS gained its corresponding check, Ritesh Harjani suggested excluding DAX inodes in ext4 anyway [1], so that what is advertised matches what the write path can do. XFS does the same in xfs_inode_can_hw_atomic_write() and xfs_inode_can_sw_atomic_write(). Link: https://lore.kernel.org/linux-ext4/87a54e4cdn.fsf@gmail.com/ [1] Signed-off-by: Tal Zussman <tz2294@columbia.edu> Reviewed-by: Jan Kara <jack@suse.cz>
|
Upstream branch: b3dfbde |
bf32589 to
c253f6f
Compare
Pull request for series with
subject: ext4: don't complete atomic writes through buffered I/O
version: 2
url: https://patchwork.kernel.org/series/1184078/