fs/ntfs3/file.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-)
Reading large compressed files is extremely slow when readahead is enabled.
For example, reading a 4 GB XPRESS-4K compressed file (compression ratio
≈ 4:1) takes about 230 minutes with readahead enabled, but only around 3
minutes when readahead is disabled.
The issue was first observed in January 2025 and is reproducible with large
compressed NTFS files. Disabling readahead for compressed files avoids this
performance regression, although this may not be the ideal long-term fix.
This patch is submitted as an RFC to gather feedback on whether disabling
readahead is an acceptable solution or if a more targeted fix should be
implemented.
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
fs/ntfs3/file.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
index a9ba37758944..7471a4bbb438 100644
--- a/fs/ntfs3/file.c
+++ b/fs/ntfs3/file.c
@@ -325,9 +325,14 @@ static int ntfs_file_mmap_prepare(struct vm_area_desc *desc)
return -EOPNOTSUPP;
}
- if (is_compressed(ni) && rw) {
- ntfs_inode_warn(inode, "mmap(write) compressed not supported");
- return -EOPNOTSUPP;
+ if (is_compressed(ni)) {
+ if (rw) {
+ ntfs_inode_warn(inode,
+ "mmap(write) compressed not supported");
+ return -EOPNOTSUPP;
+ }
+ /* Turn off readahead for compressed files. */
+ file->f_ra.ra_pages = 0;
}
if (rw) {
@@ -884,9 +889,14 @@ static ssize_t ntfs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
if (err)
return err;
- if (is_compressed(ni) && (iocb->ki_flags & IOCB_DIRECT)) {
- ntfs_inode_warn(inode, "direct i/o + compressed not supported");
- return -EOPNOTSUPP;
+ if (is_compressed(ni)) {
+ if (iocb->ki_flags & IOCB_DIRECT) {
+ ntfs_inode_warn(
+ inode, "direct i/o + compressed not supported");
+ return -EOPNOTSUPP;
+ }
+ /* Turn off readahead for compressed files. */
+ file->f_ra.ra_pages = 0;
}
return generic_file_read_iter(iocb, iter);
@@ -906,6 +916,11 @@ static ssize_t ntfs_file_splice_read(struct file *in, loff_t *ppos,
if (err)
return err;
+ if (is_compressed(ntfs_i(inode))) {
+ /* Turn off readahead for compressed files. */
+ in->f_ra.ra_pages = 0;
+ }
+
return filemap_splice_read(in, ppos, pipe, len, flags);
}
--
2.43.0
On Tue, Oct 28, 2025 at 05:51:31PM +0100, Konstantin Komarov wrote: > Reading large compressed files is extremely slow when readahead is enabled. > For example, reading a 4 GB XPRESS-4K compressed file (compression ratio > ≈ 4:1) takes about 230 minutes with readahead enabled, but only around 3 > minutes when readahead is disabled. > > The issue was first observed in January 2025 and is reproducible with large > compressed NTFS files. Disabling readahead for compressed files avoids this > performance regression, although this may not be the ideal long-term fix. > > This patch is submitted as an RFC to gather feedback on whether disabling > readahead is an acceptable solution or if a more targeted fix should be > implemented. I suspect your real problem is that readahead is synchronous in ntfs3 and the VFS is not expecting this. Your get_block (ntfs_get_block_vbo) calls bh_read() which waits for the I/O to complete. That means we get no pipelining which will significantly reduce bandwidth.
© 2016 - 2026 Red Hat, Inc.