fs/ntfs3: zero-fill folios beyond i_valid in ntfs_read_folio()

Handle ntfs_read_folio() early when the folio offset is beyond i_valid
by zero-filling the folio and marking it uptodate. This avoids needless
I/O and locking, improves read performance.

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
This commit is contained in:
Konstantin Komarov 2025-12-12 14:38:10 +03:00
parent 576248a34b
commit 356fa24816
No known key found for this signature in database
GPG Key ID: A9B0331F832407B6

View File

@ -723,6 +723,19 @@ static int ntfs_read_folio(struct file *file, struct folio *folio)
struct address_space *mapping = folio->mapping;
struct inode *inode = mapping->host;
struct ntfs_inode *ni = ntfs_i(inode);
loff_t vbo = folio_pos(folio);
if (unlikely(is_bad_ni(ni))) {
folio_unlock(folio);
return -EIO;
}
if (ni->i_valid <= vbo) {
folio_zero_range(folio, 0, folio_size(folio));
folio_mark_uptodate(folio);
folio_unlock(folio);
return 0;
}
if (is_resident(ni)) {
ni_lock(ni);