Re: [PATCH V2] fs/ntfs3: Add missing direct_IO in ntfs_aops_cmpr

From: Jan Kara
Date: Tue Apr 15 2025 - 07:09:06 EST


On Tue 15-04-25 17:26:37, Lizhi Xu wrote:
> The ntfs3 can use the page cache directly, so its address_space_operations
> need direct_IO. Exit ntfs_direct_IO() if it is a compressed file.
>
> Fixes: b432163ebd15 ("fs/ntfs3: Update inode->i_mapping->a_ops on compression state")
> Reported-by: syzbot+e36cc3297bd3afd25e19@xxxxxxxxxxxxxxxxxxxxxxxxx
> Closes: https://syzkaller.appspot.com/bug?extid=e36cc3297bd3afd25e19
> Signed-off-by: Lizhi Xu <lizhi.xu@xxxxxxxxxxxxx>

OK, this looks sensible to me. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

Honza

> ---
> V1 -> V2: exit direct io if it is a compressed file.
>
> fs/ntfs3/inode.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
> index 3e2957a1e360..0f0d27d4644a 100644
> --- a/fs/ntfs3/inode.c
> +++ b/fs/ntfs3/inode.c
> @@ -805,6 +805,10 @@ static ssize_t ntfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
> ret = 0;
> goto out;
> }
> + if (is_compressed(ni)) {
> + ret = 0;
> + goto out;
> + }
>
> ret = blockdev_direct_IO(iocb, inode, iter,
> wr ? ntfs_get_block_direct_IO_W :
> @@ -2068,5 +2072,6 @@ const struct address_space_operations ntfs_aops_cmpr = {
> .read_folio = ntfs_read_folio,
> .readahead = ntfs_readahead,
> .dirty_folio = block_dirty_folio,
> + .direct_IO = ntfs_direct_IO,
> };
> // clang-format on
> --
> 2.43.0
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR