ocfs2: fix issue that ocfs2_setattr() does not deal with new_i_size==i_size
The issue scenario is as following:
1. fallocate a large disk space(eg. 30G) with FALLOC_FL_KEEP_SIZE for
a file whose i_size and disk size are 512(or other size). After
executing fallocate, i_size file is still 512, and the disk size became
to 30G+512;
2. ftruncate the file to new_i_size which equal to inode->i_size.
After executing ftruncate, disk space does not changes. In other
words, i_size file is still 512, and disk size is 30G+512. But we want
disk size to be 512. This does not meet our expectations.
In order to solve the issue above, we modified ocfs2_setattr(). If
attr->ia_size != i_size_read(inode), it calls ocfs2_truncate_file(), and
truncate disk space to attr->ia_size.
Signed-off-by: Younger Liu <younger.liu@huawei.com> Cc: Jie Liu <jeff.liu@oracle.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Mark Fasheh <mfasheh@suse.com> Cc: Sunil Mushran <sunil.mushran@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>