[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <lsq.1518322806.690622623@decadent.org.uk>
Date: Sun, 11 Feb 2018 04:20:06 +0000
From: Ben Hutchings <ben@...adent.org.uk>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
CC: akpm@...ux-foundation.org, "Joel Becker" <jlbec@...lplan.org>,
"Sunil Mushran" <sunil.mushran@...il.com>,
"Jie Liu" <jeff.liu@...cle.com>,
"Younger Liu" <younger.liu@...wei.com>,
"Jensen" <shencanquan@...wei.com>,
"Linus Torvalds" <torvalds@...ux-foundation.org>,
"Mark Fasheh" <mfasheh@...e.de>
Subject: [PATCH 3.2 38/79] ocfs2: fix issue that ocfs2_setattr() does not
deal with new_i_size==i_size
3.2.99-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Younger Liu <younger.liu@...wei.com>
commit d62e74be1270c89fbaf7aada8218bfdf62d00a58 upstream.
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@...wei.com>
Reviewed-by: Jie Liu <jeff.liu@...cle.com>
Tested-by: Jie Liu <jeff.liu@...cle.com>
Cc: Joel Becker <jlbec@...lplan.org>
Reviewed-by: Mark Fasheh <mfasheh@...e.de>
Cc: Sunil Mushran <sunil.mushran@...il.com>
Reviewed-by: Jensen <shencanquan@...wei.com>
Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@...ux-foundation.org>
Signed-off-by: Ben Hutchings <ben@...adent.org.uk>
---
fs/ocfs2/alloc.c | 2 +-
fs/ocfs2/file.c | 9 ++-------
2 files changed, 3 insertions(+), 8 deletions(-)
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -7127,7 +7127,7 @@ int ocfs2_truncate_inline(struct inode *
if (end > i_size_read(inode))
end = i_size_read(inode);
- BUG_ON(start >= end);
+ BUG_ON(start > end);
if (!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) ||
!(le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_DATA_FL) ||
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -474,11 +474,6 @@ static int ocfs2_truncate_file(struct in
goto bail;
}
- /* lets handle the simple truncate cases before doing any more
- * cluster locking. */
- if (new_i_size == le64_to_cpu(fe->i_size))
- goto bail;
-
down_write(&OCFS2_I(inode)->ip_alloc_sem);
ocfs2_resv_discard(&osb->osb_la_resmap,
@@ -1149,14 +1144,14 @@ int ocfs2_setattr(struct dentry *dentry,
goto bail_unlock_rw;
}
- if (size_change && attr->ia_size != i_size_read(inode)) {
+ if (size_change) {
status = inode_newsize_ok(inode, attr->ia_size);
if (status)
goto bail_unlock;
inode_dio_wait(inode);
- if (i_size_read(inode) > attr->ia_size) {
+ if (i_size_read(inode) >= attr->ia_size) {
if (ocfs2_should_order_data(inode)) {
status = ocfs2_begin_ordered_truncate(inode,
attr->ia_size);
Powered by blists - more mailing lists