Re: [PATCH v3 1/4] ntfs: add named stream ioctls support

From: Namjae Jeon

Date: Sun Oct 11 2026 - 20:38:45 EST


On Mon, Oct 12, 2026 at 8:47 AM CharSyam <charsyam@xxxxxxxxx> wrote:
>
> Hi, Namjae.
>
> I have two comments on the named stream write path. I tested both cases
> with the NTFS module in a QEMU guest.
>
> 1. In __ntfs_inode_non_resident_attr_pwrite(), count == PAGE_SIZE does
> not imply that pos is page aligned. Both full-page branches need to
> check the alignment of pos:
>
> while (count) {
> bool full_page = count == PAGE_SIZE &&
> IS_ALIGNED(pos, PAGE_SIZE);
>
> if (full_page) {
> /* __filemap_get_folio() path */
> } else {
> /* read_mapping_folio() path */
> }
>
> if (full_page) {
> offset = 0;
> attr_len = count;
> } else {
> offset = offset_in_folio(folio, pos);
> attr_len = min_t(size_t, (size_t)count,
> folio_size(folio) - offset);
> }
> ...
> }
>
> To reproduce this, I filled an 8 KiB stream with 'A' and wrote
> 4096 bytes of 'B' at offset 1. The ioctl reported success, but byte 0
> became 'B' and byte 4096 remained 'A'. With the condition above,
> byte 0 remained 'A' and byte 4096 became 'B', as expected.
This has already been fixed in ntfs-next by commit 7de32a72b75b7
(“ntfs: require page-aligned full-page attribute writes”).

>
> 2. An error on a later page returns the error even if earlier pages
> were written. The ioctl then returns the error without copying
> bytes_returned to userspace, and ntfs_inode_attr_pwrite() skips the
> base file's mtime/ctime update.
>
> I reproduced this in QEMU by injecting a test-only -EIO after the
> first page of an 8 KiB overwrite. The ioctl returned EIO with no
> transferred byte count, while the first 4 KiB changed from 'A' to
> 'B' and the second 4 KiB remained 'A'. The base file's mtime did not
> change. The changed data remained after sync and remount. With a
> test fix that updates the base timestamps when an earlier page was
> written, mtime changed in the same test; the ioctl still returned EIO.
>
> What partial-write behavior is intended for NTFS_IOC_STREAM_WRITE?
> Returning the completed byte count as a short successful transfer
> would follow write(2) conventions, but the stream is currently
> extended to pos + count before copying, so EOF handling would also
> need attention. If the ioctl should return the error, its UAPI should
> explain that partial changes may remain and define whether their
> length is reported. Either way, timestamps should reflect data that
> changed.
Okay, I will fix it.
Thanks!