[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1276146485-9346-1-git-send-email-tao.ma@oracle.com>
Date: Thu, 10 Jun 2010 13:08:05 +0800
From: Tao Ma <tao.ma@...cle.com>
To: linux-fsdevel@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, Tao Ma <tao.ma@...cle.com>,
Joel Becker <joel.becker@...cle.com>,
Christoph Hellwig <hch@....de>, Nick Piggin <npiggin@...e.de>
Subject: [PATCH v3] ocfs2: Let ocfs2_setattr use new truncate sequence.
Let ocfs2 use the new truncate sequence. The changes include:
1. Use truncate_setsize directly since we don't implement our
own ->truncate and what we need is "update i_size and
truncate_pagecache" which truncate_setsize now does.
2. For direct write, ocfs2 actually don't allow write to pass
i_size(see ocfs2_prepare_inode_for_write), so we don't have
a chance to increase i_size. So remove the bogus check.
Cc: Joel Becker <joel.becker@...cle.com>
Cc: Christoph Hellwig <hch@....de>
Cc: Nick Piggin <npiggin@...e.de>
Signed-off-by: Tao Ma <tao.ma@...cle.com>
---
fs/ocfs2/file.c | 32 ++++++--------------------------
1 files changed, 6 insertions(+), 26 deletions(-)
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 1fb0985..8b5447e 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -987,7 +987,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
if (status)
goto bail_unlock;
- if (i_size_read(inode) > attr->ia_size) {
+ if (inode->i_size > attr->ia_size) {
if (ocfs2_should_order_data(inode)) {
status = ocfs2_begin_ordered_truncate(inode,
attr->ia_size);
@@ -1052,22 +1052,13 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
}
/*
- * This will intentionally not wind up calling truncate_setsize(),
- * since all the work for a size change has been done above.
- * Otherwise, we could get into problems with truncate as
- * ip_alloc_sem is used there to protect against i_size
- * changes.
- *
- * XXX: this means the conditional below can probably be removed.
+ * Since all the work for a size change has been done above.
+ * Call truncate_setsize directly to change size and truncate
+ * pagecache.
*/
if ((attr->ia_valid & ATTR_SIZE) &&
- attr->ia_size != i_size_read(inode)) {
- status = vmtruncate(inode, attr->ia_size);
- if (status) {
- mlog_errno(status);
- goto bail_commit;
- }
- }
+ attr->ia_size != inode->i_size)
+ truncate_setsize(inode, attr->ia_size);
setattr_copy(inode, attr);
mark_inode_dirty(inode);
@@ -2122,17 +2113,6 @@ relock:
written = generic_file_direct_write(iocb, iov, &nr_segs, *ppos,
ppos, count, ocount);
if (written < 0) {
- /*
- * direct write may have instantiated a few
- * blocks outside i_size. Trim these off again.
- * Don't need i_size_read because we hold i_mutex.
- *
- * XXX(truncate): this looks buggy because ocfs2 did not
- * actually implement ->truncate. Take a look at
- * the new truncate sequence and update this accordingly
- */
- if (*ppos + count > inode->i_size)
- truncate_setsize(inode, inode->i_size);
ret = written;
goto out_dio;
}
--
1.5.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists