fs/ntfs3: disable readahead for compressed files

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.

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
This commit is contained in:
Konstantin Komarov 2025-10-14 20:17:25 +03:00
parent 9948dcb2f7
commit 1ff28f36eb
No known key found for this signature in database
GPG Key ID: A9B0331F832407B6
1 changed files with 21 additions and 6 deletions

View File

@ -325,9 +325,14 @@ static int ntfs_file_mmap_prepare(struct vm_area_desc *desc)
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
if (is_compressed(ni) && rw) { if (is_compressed(ni)) {
ntfs_inode_warn(inode, "mmap(write) compressed not supported"); if (rw) {
return -EOPNOTSUPP; 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) { if (rw) {
@ -884,9 +889,14 @@ static ssize_t ntfs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
if (err) if (err)
return err; return err;
if (is_compressed(ni) && (iocb->ki_flags & IOCB_DIRECT)) { if (is_compressed(ni)) {
ntfs_inode_warn(inode, "direct i/o + compressed not supported"); if (iocb->ki_flags & IOCB_DIRECT) {
return -EOPNOTSUPP; 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); 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) if (err)
return 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); return filemap_splice_read(in, ppos, pipe, len, flags);
} }