]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
quota: fix wrong condition in is_quota_modification()
authorChao Yu <yuchao0@huawei.com>
Wed, 11 Sep 2019 09:36:50 +0000 (17:36 +0800)
committerJan Kara <jack@suse.cz>
Thu, 12 Sep 2019 10:09:16 +0000 (12:09 +0200)
Quoted from
commit 3da40c7b0898 ("ext4: only call ext4_truncate when size <= isize")

" At LSF we decided that if we truncate up from isize we shouldn't trim
  fallocated blocks that were fallocated with KEEP_SIZE and are past the
 new i_size.  This patch fixes ext4 to do this. "

And generic/092 of fstest have covered this case for long time, however
is_quota_modification() didn't adjust based on that rule, so that in
below condition, we will lose to quota block change:
- fallocate blocks beyond EOF
- remount
- truncate(file_path, file_size)

Fix it.

Link: https://lore.kernel.org/r/20190911093650.35329-1-yuchao0@huawei.com
Fixes: 3da40c7b0898 ("ext4: only call ext4_truncate when size <= isize")
CC: stable@vger.kernel.org
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jan Kara <jack@suse.cz>
include/linux/quotaops.h

index dc905a4ff8d712294b2211b76ff43aced5799758..185d948297011fe6bd540e4847da2ff5ffa63761 100644 (file)
@@ -22,7 +22,7 @@ static inline struct quota_info *sb_dqopt(struct super_block *sb)
 /* i_mutex must being held */
 static inline bool is_quota_modification(struct inode *inode, struct iattr *ia)
 {
-       return (ia->ia_valid & ATTR_SIZE && ia->ia_size != inode->i_size) ||
+       return (ia->ia_valid & ATTR_SIZE) ||
                (ia->ia_valid & ATTR_UID && !uid_eq(ia->ia_uid, inode->i_uid)) ||
                (ia->ia_valid & ATTR_GID && !gid_eq(ia->ia_gid, inode->i_gid));
 }