mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
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>
This commit is contained in:
parent
eb67671cd8
commit
b54559689a
|
|
@ -1549,13 +1549,26 @@ int ntfs_compress_write(struct ntfs_inode *ni, loff_t pos, size_t count,
|
|||
}
|
||||
}
|
||||
|
||||
err = ntfs_write_cb(ni, pos, pages, pages_per_cb, page_offset);
|
||||
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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user