Re: [patch?] truncate and timestamps

Andrew Morton (akpm@digeo.com)
Thu, 22 May 2003 16:20:02 -0700


Andries.Brouwer@cwi.nl wrote:
>
> Investigating why some SuSE init script no longer works, I find:
> The shell command
> > file
> does not update the time stamp of file in case it existed and had size 0.

oops. That's due to me "don't call vmtruncate if i_size didn't change"
speedup. It was a pretty good speedup too.

Does this look sane?

25-akpm/fs/attr.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)

diff -puN fs/attr.c~a fs/attr.c
--- 25/fs/attr.c~a Thu May 22 16:16:33 2003
+++ 25-akpm/fs/attr.c Thu May 22 16:18:13 2003
@@ -68,10 +68,17 @@ int inode_setattr(struct inode * inode,
int error = 0;

if (ia_valid & ATTR_SIZE) {
- if (attr->ia_size != inode->i_size)
+ if (attr->ia_size != inode->i_size) {
error = vmtruncate(inode, attr->ia_size);
- if (error || (ia_valid == ATTR_SIZE))
- goto out;
+ if (error)
+ goto out;
+ } else {
+ /*
+ * We skipped the truncate but must still update
+ * timestamps
+ */
+ ia_valid |= ATTR_MTIME|ATTR_CTIME;
+ }
}

lock_kernel();

_

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/