linux/fs/ntfs
Hongling Zeng 5dffb73070 ntfs: handle a failed size rollback in the write error path
ntfs_file_write_iter() extends the data and initialized sizes before
it copies the user data and restores them when the write then fails.
The restoration is best-effort: both results are discarded, even
though the extension is already recorded in the dirty MFT record.
When the restoration fails too, the extended sizes reach the disk
while the VFS inode keeps reporting the old ones: after a remount the
file appears grown again, with an uninitialized tail where the failed
write never put any data, and nothing records the failure.

Keep both undo results: roll the initialized size back first, and
roll the data size back only when that rollback succeeded.  The data
rollback goes through the same VFS-facing truncate
ntfs_setattr_size() uses, which also supports compressed attributes,
and keeps the VFS size on the durable data size when it fails.  Its
shrink clamps the initialized size to the rolled-back data size,
which can sit above the old initialized size, so a failed initialized
size rollback would leave the clamp in place and expose the
uninitialized tail.  The undo runs under the mapping invalidate lock,
like ntfs_setattr_size(), which the truncate expects.  On an undo
failure, set NVolSetErrors(), which the next persistence point
persists as VOLUME_IS_DIRTY, and log a message for the errors=
policy.

Fixes: 9c87959601 ("ntfs: update file operations")
Suggested-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
2026-10-23 09:43:20 +09:00
..
lib ntfs: implement codec ops for LZX and XPRESS 2026-08-21 19:06:45 +09:00
aops.c ntfs: do not read ahead encrypted files 2026-10-20 18:46:00 +09:00
attrib.c ntfs: add pathname access for named streams 2026-10-20 18:45:57 +09:00
attrib.h ntfs: add pathname access for named streams 2026-10-20 18:45:57 +09:00
attrlist.c ntfs: add named stream ioctls support 2026-10-20 18:41:57 +09:00
attrlist.h ntfs: protect runlist updates with the runlist lock 2026-09-13 11:41:42 +09:00
bdev-io.c ntfs: compute bi_sector in 512-byte units 2026-08-27 21:47:38 +09:00
bitmap.c ntfs: validate and reserve bad clusters at mount 2026-10-20 18:41:56 +09:00
bitmap.h ntfs: validate and reserve bad clusters at mount 2026-10-20 18:41:56 +09:00
collate.c ntfs: return -EINVAL from ntfs_collate_ntofs_ulongs() on bad length 2026-10-20 18:41:41 +09:00
collate.h ntfs: update in-memory, on-disk structures and headers 2026-02-19 21:48:06 +09:00
compress.c ntfs: widen the sub-block offsets in ntfs_decompress() 2026-10-20 18:46:00 +09:00
debug.c ntfs: update misc operations 2026-02-19 21:50:56 +09:00
debug.h ntfs: update in-memory, on-disk structures and headers 2026-02-19 21:48:06 +09:00
dir.c ntfs: flush the block device when syncing a directory 2026-10-20 18:46:01 +09:00
dir.h ntfs: update in-memory, on-disk structures and headers 2026-02-19 21:48:06 +09:00
ea.c ntfs: support persistent noatime attribute 2026-10-20 18:46:02 +09:00
ea.h ntfs: support persistent noatime attribute 2026-10-20 18:46:02 +09:00
file.c ntfs: handle a failed size rollback in the write error path 2026-10-23 09:43:20 +09:00
index.c ntfs: reject index blocks with a too small entries offset 2026-10-22 20:44:30 +09:00
index.h ntfs: fix incorrect VCN units for index blocks in large clusters 2026-10-20 18:41:34 +09:00
inode.c ntfs: persist immutable in the $LINUXFLAGS EA 2026-10-20 18:45:59 +09:00
inode.h ntfs: persist immutable in the $LINUXFLAGS EA 2026-10-20 18:45:59 +09:00
iomap.c ntfs: add pathname access for named streams 2026-10-20 18:45:57 +09:00
iomap.h ntfs: update in-memory, on-disk structures and headers 2026-02-19 21:48:06 +09:00
Kconfig ntfs: add WOF compression config option 2026-08-21 19:06:34 +09:00
layout.h ntfs: reject non-resident attributes whose sizes exceed their allocation 2026-10-20 18:41:51 +09:00
lcnalloc.c ntfs: do not give a contiguous cluster allocation a second run 2026-10-20 18:41:54 +09:00
lcnalloc.h ntfs: update in-memory, on-disk structures and headers 2026-02-19 21:48:06 +09:00
logfile.c ntfs: fix u16 truncation of the update sequence array count check 2026-10-22 20:52:58 +09:00
logfile.h ntfs: update in-memory, on-disk structures and headers 2026-02-19 21:48:06 +09:00
Makefile ntfs: add named stream ioctls support 2026-10-20 18:41:57 +09:00
malloc.h Revert "fs: Remove NTFS classic" 2026-02-19 21:48:05 +09:00
mft.c ntfs: balance the $MFT runlist lock in data extension error paths 2026-10-20 18:41:53 +09:00
mft.h ntfs: use sync flag for direct MFT writes 2026-10-20 18:41:32 +09:00
mst.c ntfs: fix directory lookup on large-page systems 2026-10-20 18:41:33 +09:00
named_stream.c ntfs: add pathname access for named streams 2026-10-20 18:45:57 +09:00
namei.c ntfs: persist immutable in the $LINUXFLAGS EA 2026-10-20 18:45:59 +09:00
ntfs_codec.h ntfs: implement codec ops for LZX and XPRESS 2026-08-21 19:06:45 +09:00
ntfs.h ntfs: persist immutable in the $LINUXFLAGS EA 2026-10-20 18:45:59 +09:00
object_id.c ntfs: update misc operations 2026-02-19 21:50:56 +09:00
object_id.h ntfs: update in-memory, on-disk structures and headers 2026-02-19 21:48:06 +09:00
reparse.c ntfs: propagate the ntfs_attr_iget() error in update_reparse_data() 2026-10-20 18:41:42 +09:00
reparse.h ntfs: parse REPARSE_TAG_WOF 2026-08-21 19:06:38 +09:00
runlist.c ntfs: add a runlist merge that leaves the source runlist to the caller 2026-10-20 18:41:52 +09:00
runlist.h ntfs: add a runlist merge that leaves the source runlist to the caller 2026-10-20 18:41:52 +09:00
stream.h ntfs: add pathname access for named streams 2026-10-20 18:45:57 +09:00
super.c ntfs: support FS_IOC_GETFSUUID 2026-10-20 18:46:01 +09:00
sysctl.c ntfs: fix sysctl table registration and path 2026-03-01 14:53:37 +09:00
sysctl.h ntfs: update in-memory, on-disk structures and headers 2026-02-19 21:48:06 +09:00
time.h ntfs: update in-memory, on-disk structures and headers 2026-02-19 21:48:06 +09:00
unistr.c ntfs: fix lookup of POSIX names with Windows-invalid characters 2026-10-20 18:41:33 +09:00
upcase.c ntfs: update misc operations 2026-02-19 21:50:56 +09:00
volume.h ntfs: add pathname access for named streams 2026-10-20 18:45:57 +09:00
wof.c ntfs: add pathname access for named streams 2026-10-20 18:45:57 +09:00