lkml.org 
[lkml]   [2011]   [Dec]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 1/2] vfs: iversion truncate bug fix
Date
When a file is opened with O_TRUNC or truncated with truncate()/ftruncate(),
and then closed, iversion is not updated. This patch uses ATTR_OPEN flag,
which is currently used to identify files opened with O_TRUNC,
as an indication to increment iversion.
Also it adds passing of this flag from do_sys_truncate and do_sys_ftruncate.

Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
---
fs/attr.c | 3 +++
fs/open.c | 5 +++--
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/attr.c b/fs/attr.c
index 7ee7ba4..e02370d 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -176,6 +176,9 @@ int notify_change(struct dentry * dentry, struct iattr * attr)
return -EPERM;
}

+ if ((ia_valid & ATTR_OPEN) && IS_I_VERSION(inode))
+ inode_inc_iversion(inode);
+
if ((ia_valid & ATTR_MODE)) {
mode_t amode = attr->ia_mode;
/* Flag setting protected by i_mutex */
diff --git a/fs/open.c b/fs/open.c
index 22c41b5..4ee6847 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -113,7 +113,7 @@ static long do_sys_truncate(const char __user *pathname, loff_t length)
if (!error)
error = security_path_truncate(&path);
if (!error)
- error = do_truncate(path.dentry, length, 0, NULL);
+ error = do_truncate(path.dentry, length, ATTR_OPEN, NULL);

put_write_and_out:
put_write_access(inode);
@@ -168,7 +168,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
if (!error)
error = security_path_truncate(&file->f_path);
if (!error)
- error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
+ error = do_truncate(dentry, length,
+ ATTR_MTIME|ATTR_CTIME|ATTR_OPEN, file);
out_putf:
fput(file);
out:
--
1.7.4.1


\
 
 \ /
  Last update: 2011-12-22 09:59    [W:0.105 / U:1.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site