Re: [PATCH v5 06/14] ntfs: update file operations
From: Christoph Hellwig
Date: Mon Jan 19 2026 - 02:10:47 EST
On Sun, Jan 18, 2026 at 01:56:55PM +0900, Namjae Jeon wrote:
> > Talking about helpers, why does iomap_seek_hole/iomap_seek_data
> > not work for ntfs?
>
> Regarding iomap_seek_hole/iomap_seek_data, the default iomap
> implementation treats IOMAP_UNWRITTEN extents as holes unless they
> have dirty pages in the page cache. However, in ntfs iomap begin, the
> region between initialized_size and i_size (EOF) is mapped as
> IOMAP_UNWRITTEN. Since NTFS requires any pre-allocated regions before
> initialized_size to be physically zeroed, NTFS must treat all
> pre-allocated regions as DATA.
What do you need IOMAP_UNWRITTEN for in that case? If the blocks have
been zeroed on-disk, they are IOMAP_MAPPED by the usual iomap standards.
If you need special treatement, it might be worth adding a separate
IOMAP_PREZEROED with clearly defined semantics instead of overloading
IOMAP_UNWRITTEN.
>
> >
> > > + file_accessed(iocb->ki_filp);
> > > + ret = iomap_dio_rw(iocb, to, &ntfs_read_iomap_ops, NULL, IOMAP_DIO_PARTIAL,
> >
> > Why do you need IOMAP_DIO_PARTIAL? That's mostly a workaround
> > for "interesting" locking in btrfs and gfs2. If ntfs has similar
> > issues, it would be helpful to add a comment here. Also maybe fix
> > the overly long line.
> Regarding the use of IOMAP_DIO_PARTIAL, I was not aware that it was a
> workaround for specific locking issues in some filesystems. I
> incorrectly assumed it was a flag to enable partial success when a DIO
> request exceeds the actual data length. I will remove this flags and
> fix it.
It only does short I/O for -EFAULT, which only happens if the nofault
flag on the iov_iter is set. See the big comment in
btrfs_direct_write where that field is set about the explanation.
> > What is the reason to do the expansion here instead of in the iomap_begin
> > handler when we know we are committed to write to range?
> We can probably move it to iomap_begin(). Let me check it.
If it works better here that's also fine, just document it as it looks
a bit unusual. Handling the cleanup on failures might be a bit easier
if it is done in the iomap loop, though.