From: Konstantin Komarov Date: Fri, 22 Oct 2021 14:37:52 +0000 (+0300) Subject: fs/ntfs3: Keep preallocated only if option prealloc enabled X-Git-Tag: v5.18.3~857 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=49d2833defb03a40cd160ce096caca44030ee1c7;p=thirdparty%2Fkernel%2Fstable.git fs/ntfs3: Keep preallocated only if option prealloc enabled commit e95113ed4d428219e3395044e29f5713fc446720 upstream. If size of file was reduced, we still kept allocated blocks. This commit makes ntfs3 work as other fs like btrfs. Link: https://bugzilla.kernel.org/show_bug.cgi?id=214719 Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation") Reported-by: Ganapathi Kamath Tested-by: Ganapathi Kamath Reviewed-by: Kari Argillander Signed-off-by: Konstantin Komarov Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index 0bffd84ba8dd4..1eb5d88e661c7 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -495,7 +495,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)