summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>2025-12-12 14:38:10 +0300
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>2025-12-29 16:33:30 +0300
commit356fa248168be90109b66f32a61b8eaedc98424a (patch)
treee3a5f62ab9fca9e905a01f343cc3ba4b432b47f2
parent576248a34b927e93b2fd3fff7df735ba73ad7d01 (diff)
downloadlinux-356fa248168be90109b66f32a61b8eaedc98424a.tar.xz
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>
-rw-r--r--fs/ntfs3/inode.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index 1319b99dfeb4..ace9873adaae 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -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);