fs/ntfs3: Keep preallocated only if option prealloc enabled
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Fri, 22 Oct 2021 14:37:52 +0000 (17:37 +0300)
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Tue, 23 Nov 2021 15:55:49 +0000 (18:55 +0300)
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 <hgkamath@hotmail.com>
Tested-by: Ganapathi Kamath <hgkamath@hotmail.com>
Reviewed-by: Kari Argillander <kari.argillander@gmail.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
fs/ntfs3/file.c

index 43b1451bff539576cd03c0f624708bf65b959270..3ac0482c688042ed48f21730df9b24a689407e22 100644 (file)
@@ -494,7 +494,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)