summaryrefslogtreecommitdiff
path: root/fs/ntfs3/file.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2022-06-03 16:57:16 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2022-06-03 16:57:16 -0700
commit1f952675835bfe18d6ae494a5581724d68c52352 (patch)
tree8b523ca9e9e2cd79e6aa53ec915bf5968601e5c1 /fs/ntfs3/file.c
parent67850b7bdcd2803e10d019f0da5673a92139b43a (diff)
parent724bbe49c5e427cb077357d72d240a649f2e4054 (diff)
Merge tag 'ntfs3_for_5.19' of https://github.com/Paragon-Software-Group/linux-ntfs3
Pull ntfs3 updates from Konstantin Komarov: - fix some memory leaks and panic - fixed xfstests (tested on x86_64): generic/092 generic/099 generic/228 generic/240 generic/307 generic/444 - fix some typos, dead code, etc * tag 'ntfs3_for_5.19' of https://github.com/Paragon-Software-Group/linux-ntfs3: fs/ntfs3: provide block_invalidate_folio to fix memory leak fs/ntfs3: Fix invalid free in log_replay fs/ntfs3: Update valid size if -EIOCBQUEUED fs/ntfs3: Check new size for limits fs/ntfs3: Fix fiemap + fix shrink file size (to remove preallocated space) fs/ntfs3: In function ntfs_set_acl_ex do not change inode->i_mode if called from function ntfs_init_acl fs/ntfs3: Optimize locking in ntfs_save_wsl_perm fs/ntfs3: Update i_ctime when xattr is added fs/ntfs3: Restore ntfs_xattr_get_acl and ntfs_xattr_set_acl functions fs/ntfs3: Keep preallocated only if option prealloc enabled fs/ntfs3: Fix some memory leaks in an error handling path of 'log_replay()'
Diffstat (limited to 'fs/ntfs3/file.c')
-rw-r--r--fs/ntfs3/file.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
index a4fcdc7927ca..8e9d2b35175f 100644
--- a/fs/ntfs3/file.c
+++ b/fs/ntfs3/file.c
@@ -492,7 +492,7 @@ static int ntfs_truncate(struct inode *inode, loff_t new_size)
down_write(&ni->file.run_lock);
err = attr_set_size(ni, ATTR_DATA, NULL, 0, &ni->file.run, new_size,
- &new_valid, true, NULL);
+ &new_valid, ni->mi.sbi->options->prealloc, NULL);
up_write(&ni->file.run_lock);
if (new_valid < ni->i_valid)
@@ -659,7 +659,13 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)
/*
* Normal file: Allocate clusters, do not change 'valid' size.
*/
- err = ntfs_set_size(inode, max(end, i_size));
+ loff_t new_size = max(end, i_size);
+
+ err = inode_newsize_ok(inode, new_size);
+ if (err)
+ goto out;
+
+ err = ntfs_set_size(inode, new_size);
if (err)
goto out;
@@ -759,7 +765,7 @@ int ntfs3_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
}
inode_dio_wait(inode);
- if (attr->ia_size < oldsize)
+ if (attr->ia_size <= oldsize)
err = ntfs_truncate(inode, attr->ia_size);
else if (attr->ia_size > oldsize)
err = ntfs_extend(inode, attr->ia_size, 0, NULL);