Skip to content

Commit 356fa24

Browse files
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>
1 parent 576248a commit 356fa24

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

fs/ntfs3/inode.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,19 @@ static int ntfs_read_folio(struct file *file, struct folio *folio)
723723
struct address_space *mapping = folio->mapping;
724724
struct inode *inode = mapping->host;
725725
struct ntfs_inode *ni = ntfs_i(inode);
726+
loff_t vbo = folio_pos(folio);
727+
728+
if (unlikely(is_bad_ni(ni))) {
729+
folio_unlock(folio);
730+
return -EIO;
731+
}
732+
733+
if (ni->i_valid <= vbo) {
734+
folio_zero_range(folio, 0, folio_size(folio));
735+
folio_mark_uptodate(folio);
736+
folio_unlock(folio);
737+
return 0;
738+
}
726739

727740
if (is_resident(ni)) {
728741
ni_lock(ni);

0 commit comments

Comments
 (0)