diff options
| author | Namjae Jeon <linkinjeon@kernel.org> | 2026-07-21 11:58:08 +0900 |
|---|---|---|
| committer | Namjae Jeon <linkinjeon@kernel.org> | 2026-08-19 18:16:42 +0900 |
| commit | b54559689a00eb50308fb768e05fbb5036c7b1b0 (patch) | |
| tree | 7177141f36841208b481e9e2cb6af0a307072b32 | |
| parent | eb67671cd8149d563c04764d39fda16f17194eae (diff) | |
| download | linux-b54559689a00eb50308fb768e05fbb5036c7b1b0.tar.gz linux-b54559689a00eb50308fb768e05fbb5036c7b1b0.zip | |
ntfs: fix initialized size and page state after compressed writes
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.
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
| -rw-r--r-- | fs/ntfs/compress.c | 15 |
1 files changed, 14 insertions, 1 deletions
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, loff_t pos, size_t count, } } + if (!copied) { + err = -EFAULT; + goto release_pages; + } + err = ntfs_write_cb(ni, pos, pages, pages_per_cb, page_offset); + if (!err && pos + copied > ni->initialized_size) { + mutex_lock(&ni->mrec_lock); + err = ntfs_attr_set_initialized_size(ni, pos + copied); + mutex_unlock(&ni->mrec_lock); + } +release_pages: for (i = 0; i < pages_per_cb; i++) { folio = 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); |
