Lustre VFS patches for 2.6
Subsystems (2)
PATCH 7/9 Lustre VFS patches for 2.6
Make do_truncate aware of the case when we do truncate from open, that may need some special handling by filesystems. (special flag in ia_valid)
fs/exec.c | 2 +- fs/namei.c | 2 +- fs/open.c | 8 +++++--- include/linux/fs.h | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-)
fs/namei.c +1 -1
@@ -1270,7 +1270,7 @@if (!error) {DQUOT_INIT (inode); - error =do_truncate (dentry,0 ); + error =do_truncate (dentry,0 ,1 ); }put_write_access (inode);if (error)
fs/open.c +5 -3
@@ -189,7 +189,7 @@return error; } -int do_truncate (struct dentry *dentry,loff_t length) +int do_truncate (struct dentry *dentry,loff_t length,int called_from_open) {int err;struct iattr newattrs;
@@ -202,6 +202,8 @@ newattrs.ia_valid =ATTR_SIZE |ATTR_CTIME ;down (&dentry->d_inode->i_sem);down_write (&dentry->d_inode->i_alloc_sem); +if (called_from_open) + newattrs.ia_valid |=ATTR_FROM_OPEN ; err =notify_change (dentry, &newattrs);up_write (&dentry->d_inode->i_alloc_sem);up (&dentry->d_inode->i_sem);
@@ -259,7 +261,7 @@ error =locks_verify_truncate (inode,NULL , length);if (!error) {DQUOT_INIT (inode); - error =do_truncate (nd.dentry, length); + error =do_truncate (nd.dentry, length,0 ); }put_write_access (inode);
@@ -311,7 +313,7 @@ error =locks_verify_truncate (inode, file, length);if (!error) - error =do_truncate (dentry, length); + error =do_truncate (dentry, length,0 ); out_putf:fput (file); out:
fs/exec.c +1 -1
@@ -1395,7 +1395,7 @@ goto close_fail;if (!file->f_op->write) goto close_fail; -if (do_truncate (file->f_dentry,0 ) !=0 ) +if (do_truncate (file->f_dentry,0 ,0 ) !=0 ) goto close_fail; retval = binfmt->core_dump (signr, regs, file);
include/linux/fs.h +2 -1
@@ -249,6 +249,7 @@#define ATTR_ATTR_FLAG 1024#define ATTR_KILL_SUID 2048#define ATTR_KILL_SGID 4096 +#define ATTR_FROM_OPEN 8192/* called from open path, ie O_TRUNC */ /* * This is the Inode Attributes structure, used for notify_change(). It
@@ -1189,7 +1190,7 @@/* fs/open.c */ -extern int do_truncate (struct dentry *,loff_t start); +extern int do_truncate (struct dentry *,loff_t start,int called_from_open);extern struct file *filp_open (const char *,int ,int );extern struct file *dentry_open (struct dentry *,struct vfsmount *,int );extern struct file *dentry_open_it (struct dentry *,struct vfsmount *,int ,struct lookup_intent *);