mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
iomap: introduce IOMAP_F_ZERO_TAIL flag
In filesystems that maintain a separate Valid Data Length, such as exFAT and NTFS, a partial write may start at or beyond the current valid_size and extend it. In this case, the region after the previous valid_size but within the same filesystem block is considered unwritten. This patch introduces IOMAP_F_ZERO_TAIL. When this flag is set in iomap, __iomap_write_begin() will zero only the tail portion while preserving any valid data before it in the same block. Without this tail zeroing, stale data in the unwritten portion of the block can remain in the page cache. Subsequent reads can then return incorrect contents from that region. Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Link: https://patch.msgid.link/20260518114705.9601-2-linkinjeon@kernel.org Acked-by: "Darrick J. Wong" <djwong@kernel.org> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This commit is contained in:
parent
47f28b493d
commit
198c3b90e6
|
|
@ -836,6 +836,7 @@ static int __iomap_write_begin(const struct iomap_iter *iter,
|
|||
return -EIO;
|
||||
folio_zero_segments(folio, poff, from, to, poff + plen);
|
||||
} else {
|
||||
const struct iomap *iomap = iomap_iter_srcmap(iter);
|
||||
int status;
|
||||
|
||||
if (iter->flags & IOMAP_NOWAIT)
|
||||
|
|
@ -853,6 +854,9 @@ static int __iomap_write_begin(const struct iomap_iter *iter,
|
|||
len, status, GFP_NOFS);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
if (iomap->flags & IOMAP_F_ZERO_TAIL)
|
||||
folio_zero_segment(folio, to, poff + plen);
|
||||
}
|
||||
iomap_set_range_uptodate(folio, poff, plen);
|
||||
} while ((block_start += plen) < block_end);
|
||||
|
|
|
|||
|
|
@ -67,6 +67,9 @@ struct vm_fault;
|
|||
* bio, i.e. set REQ_ATOMIC.
|
||||
*
|
||||
* IOMAP_F_INTEGRITY indicates that the filesystems handles integrity metadata.
|
||||
*
|
||||
* IOMAP_F_ZERO_TAIL indicates the remainder of the block after the data
|
||||
* written should be zeroed.
|
||||
*/
|
||||
#define IOMAP_F_NEW (1U << 0)
|
||||
#define IOMAP_F_DIRTY (1U << 1)
|
||||
|
|
@ -86,6 +89,7 @@ struct vm_fault;
|
|||
#else
|
||||
#define IOMAP_F_INTEGRITY 0
|
||||
#endif /* CONFIG_BLK_DEV_INTEGRITY */
|
||||
#define IOMAP_F_ZERO_TAIL (1U << 10)
|
||||
|
||||
/*
|
||||
* Flag reserved for file system specific usage
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user