diff options
author | Younger Liu <younger.liu@huawei.com> | 2014-02-10 17:25:51 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-02-10 19:01:43 -0500 |
commit | d62e74be1270c89fbaf7aada8218bfdf62d00a58 (patch) | |
tree | 2dde7ffc245d44cf51f699b3c5587df8f50882f2 /fs/ocfs2/file.c | |
parent | 8d547ff4ac5927245e0833ac18528f939da0ee0e (diff) |
ocfs2: fix issue that ocfs2_setattr() does not deal with new_i_size==i_size
The issue scenario is as following:
- Create a small file and fallocate a large disk space for a file with
FALLOC_FL_KEEP_SIZE option.
- ftruncate the file back to the original size again. but the disk free
space is not changed back. This is a real bug that be fixed in this
patch.
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>
Reviewed-by: Jie Liu <jeff.liu@oracle.com>
Tested-by: Jie Liu <jeff.liu@oracle.com>
Cc: Joel Becker <jlbec@evilplan.org>
Reviewed-by: Mark Fasheh <mfasheh@suse.de>
Cc: Sunil Mushran <sunil.mushran@gmail.com>
Reviewed-by: Jensen <shencanquan@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ocfs2/file.c')
-rw-r--r-- | fs/ocfs2/file.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index fcd970636bbf..9148353c5cf8 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -477,11 +477,6 @@ static int ocfs2_truncate_file(struct inode *inode, | |||
477 | goto bail; | 477 | goto bail; |
478 | } | 478 | } |
479 | 479 | ||
480 | /* lets handle the simple truncate cases before doing any more | ||
481 | * cluster locking. */ | ||
482 | if (new_i_size == le64_to_cpu(fe->i_size)) | ||
483 | goto bail; | ||
484 | |||
485 | down_write(&OCFS2_I(inode)->ip_alloc_sem); | 480 | down_write(&OCFS2_I(inode)->ip_alloc_sem); |
486 | 481 | ||
487 | ocfs2_resv_discard(&osb->osb_la_resmap, | 482 | ocfs2_resv_discard(&osb->osb_la_resmap, |
@@ -1148,14 +1143,14 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) | |||
1148 | goto bail_unlock_rw; | 1143 | goto bail_unlock_rw; |
1149 | } | 1144 | } |
1150 | 1145 | ||
1151 | if (size_change && attr->ia_size != i_size_read(inode)) { | 1146 | if (size_change) { |
1152 | status = inode_newsize_ok(inode, attr->ia_size); | 1147 | status = inode_newsize_ok(inode, attr->ia_size); |
1153 | if (status) | 1148 | if (status) |
1154 | goto bail_unlock; | 1149 | goto bail_unlock; |
1155 | 1150 | ||
1156 | inode_dio_wait(inode); | 1151 | inode_dio_wait(inode); |
1157 | 1152 | ||
1158 | if (i_size_read(inode) > attr->ia_size) { | 1153 | if (i_size_read(inode) >= attr->ia_size) { |
1159 | if (ocfs2_should_order_data(inode)) { | 1154 | if (ocfs2_should_order_data(inode)) { |
1160 | status = ocfs2_begin_ordered_truncate(inode, | 1155 | status = ocfs2_begin_ordered_truncate(inode, |
1161 | attr->ia_size); | 1156 | attr->ia_size); |