[PATCH v7 02/31] ntfs: preserve compressed I/O preparation errors
From: Xuewen Wang
Date: Fri Dec 04 2026 - 02:50:09 EST
From: Xuewen Wang <wangxuewen@xxxxxxxxxx>
Compressed reads discard compression-buffer allocation and runlist mapping
errors at cleanup, returning EIO instead. Compressed writes also replace
mapping-pairs update errors with EIO.
Save allocation and mapping results before cleanup and return the original
errno. Keep EIO for an invalid runlist result with no more specific error,
and preserve the result of updating mapping pairs after compressed writes.
Reviewed-by: Baolin Liu <liubaolin@xxxxxxxxxx>
Signed-off-by: Xuewen Wang <wangxuewen@xxxxxxxxxx>
---
Changes in v7:
Rebase onto ntfs-next 660cb7022966; retain the v6 logical change.
fs/ntfs/compress.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
index da6cfac13d3b..416d0fd8a0e2 100644
--- a/fs/ntfs/compress.c
+++ b/fs/ntfs/compress.c
@@ -595,11 +595,13 @@ do_next_cb:
nr_cbs--;
mutex_lock(&ntfs_cb_lock);
- if (!ntfs_compression_buffer)
- if (allocate_compression_buffers()) {
+ if (!ntfs_compression_buffer) {
+ err = allocate_compression_buffers();
+ if (err) {
mutex_unlock(&ntfs_cb_lock);
goto err_out;
}
+ }
cb = ntfs_compression_buffer;
@@ -643,7 +645,8 @@ lock_retry_remap:
* duration.
*/
up_read(&ni->runlist.lock);
- if (!ntfs_map_runlist(ni, vcn))
+ err = ntfs_map_runlist(ni, vcn);
+ if (!err)
goto lock_retry_remap;
mutex_unlock(&ntfs_cb_lock);
goto map_rl_err;
@@ -854,6 +857,7 @@ map_rl_err:
goto err_out;
rl_err:
+ err = -EIO;
up_read(&ni->runlist.lock);
ntfs_error(vol->sb, "ntfs_rl_vcn_to_lcn() failed. Cannot read compression block.");
goto err_out;
@@ -874,7 +878,7 @@ err_out:
}
kfree(pages);
kfree(completed_pages);
- return -EIO;
+ return err;
}
/*
@@ -1467,8 +1471,6 @@ static int ntfs_write_cb(struct ntfs_inode *ni, loff_t pos, struct page **pages,
err = ntfs_attr_update_mapping_pairs_locked(ni, 0, ni);
up_write(&ni->runlist.lock);
- if (err)
- err = -EIO;
goto out;
free_rlc:
--
2.51.0