Re: [PATCH 05/11] ntfs: fix initialized size and page state after compressed writes

Hyunchul Lee <[email protected]> Thu, 23 Jul 2026 11:14:24 +0900
Newsgroups dev.linux.lists.ntfs
Message-ID <CANFS6bb5oJT5+XrboQOiOxWQrCwc8iOOZ5v22XGD7_SofjjC1g@mail.gmail.com>
2026=EB=85=84 7=EC=9B=94 21=EC=9D=BC (=ED=99=94) =EC=98=A4=ED=9B=84 6:54, N=
amjae Jeon <[email protected]>=EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1:
>
> The write iterator now expands attributes before calling
> ntfs_compress_write(), so compressed writes must not expand the
> attribute themselves. However, the compressed path still needs to reject
> zero-byte iterator copies, advance initialized_size after successful I/O,
> and invalidate modified folios after a failed compression-unit write.
> Reject no-progress copies, persist the new initialized size on success,
>
> and clear folio uptodate state when the synchronous write fails.
>
> Signed-off-by: Namjae Jeon <[email protected]>

Looks good to me.

Reviewed-by: Hyunchul Lee <[email protected]>


> ---
>  fs/ntfs/compress.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
> index 5b5cd494e5d8..a993cba3b961 100644
> --- a/fs/ntfs/compress.c
> +++ b/fs/ntfs/compress.c
> @@ -1549,13 +1549,26 @@ int ntfs_compress_write(struct ntfs_inode *ni, lo=
ff_t pos, size_t count,
>                         }
>                 }
>
> +               if (!copied) {
> +                       err =3D -EFAULT;
> +                       goto release_pages;
> +               }
> +
>                 err =3D ntfs_write_cb(ni, pos, pages, pages_per_cb, page_=
offset);
> +               if (!err && pos + copied > ni->initialized_size) {
> +                       mutex_lock(&ni->mrec_lock);
> +                       err =3D ntfs_attr_set_initialized_size(ni, pos + =
copied);
> +                       mutex_unlock(&ni->mrec_lock);
> +               }
>
> +release_pages:
>                 for (i =3D 0; i < pages_per_cb; i++) {
>                         folio =3D page_folio(pages[i]);
> -                       if (i < ip) {
> +                       if (!err) {
>                                 folio_clear_dirty(folio);
>                                 folio_mark_uptodate(folio);
> +                       } else {
> +                               folio_clear_uptodate(folio);
>                         }
>                         folio_unlock(folio);
>                         folio_put(folio);
> --
> 2.34.1
>


--=20
Thanks,
Hyunchul