Whamcloud - gitweb
Branch: HEAD
[fs/lustre-release.git] / lustre / kernel_patches / patches / vfs-do_truncate.patch
1 Index: linux-2.6.6/fs/namei.c
2 ===================================================================
3 --- linux-2.6.6.orig/fs/namei.c 2004-05-30 23:17:06.267030976 +0300
4 +++ linux-2.6.6/fs/namei.c      2004-05-30 23:23:15.642877312 +0300
5 @@ -1270,7 +1270,7 @@
6                 if (!error) {
7                         DQUOT_INIT(inode);
8                         
9 -                       error = do_truncate(dentry, 0);
10 +                       error = do_truncate(dentry, 0, 1);
11                 }
12                 put_write_access(inode);
13                 if (error)
14 Index: linux-2.6.6/fs/open.c
15 ===================================================================
16 --- linux-2.6.6.orig/fs/open.c  2004-05-30 20:05:26.857206992 +0300
17 +++ linux-2.6.6/fs/open.c       2004-05-30 23:24:38.908219056 +0300
18 @@ -189,7 +189,7 @@
19         return error;
20  }
21  
22 -int do_truncate(struct dentry *dentry, loff_t length)
23 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
24  {
25         int err;
26         struct iattr newattrs;
27 @@ -202,6 +202,8 @@
28         newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
29         down(&dentry->d_inode->i_sem);
30         down_write(&dentry->d_inode->i_alloc_sem);
31 +       if (called_from_open)
32 +               newattrs.ia_valid |= ATTR_FROM_OPEN;
33         err = notify_change(dentry, &newattrs);
34         up_write(&dentry->d_inode->i_alloc_sem);
35         up(&dentry->d_inode->i_sem);
36 @@ -259,7 +261,7 @@
37         error = locks_verify_truncate(inode, NULL, length);
38         if (!error) {
39                 DQUOT_INIT(inode);
40 -               error = do_truncate(nd.dentry, length);
41 +               error = do_truncate(nd.dentry, length, 0);
42         }
43         put_write_access(inode);
44  
45 @@ -311,7 +313,7 @@
46  
47         error = locks_verify_truncate(inode, file, length);
48         if (!error)
49 -               error = do_truncate(dentry, length);
50 +               error = do_truncate(dentry, length, 0);
51  out_putf:
52         fput(file);
53  out:
54 Index: linux-2.6.6/fs/exec.c
55 ===================================================================
56 --- linux-2.6.6.orig/fs/exec.c  2004-05-30 20:05:26.862206232 +0300
57 +++ linux-2.6.6/fs/exec.c       2004-05-30 23:23:15.648876400 +0300
58 @@ -1395,7 +1395,7 @@
59                 goto close_fail;
60         if (!file->f_op->write)
61                 goto close_fail;
62 -       if (do_truncate(file->f_dentry, 0) != 0)
63 +       if (do_truncate(file->f_dentry, 0, 0) != 0)
64                 goto close_fail;
65  
66         retval = binfmt->core_dump(signr, regs, file);
67 Index: linux-2.6.6/include/linux/fs.h
68 ===================================================================
69 --- linux-2.6.6.orig/include/linux/fs.h 2004-05-30 23:20:11.979798344 +0300
70 +++ linux-2.6.6/include/linux/fs.h      2004-05-30 23:25:29.167578472 +0300
71 @@ -249,6 +249,7 @@
72  #define ATTR_ATTR_FLAG 1024
73  #define ATTR_KILL_SUID 2048
74  #define ATTR_KILL_SGID 4096
75 +#define ATTR_FROM_OPEN 16384   /* called from open path, ie O_TRUNC */
76  
77  /*
78   * This is the Inode Attributes structure, used for notify_change().  It
79 @@ -1189,7 +1190,7 @@
80  
81  /* fs/open.c */
82  
83 -extern int do_truncate(struct dentry *, loff_t start);
84 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
85  extern struct file *filp_open(const char *, int, int);
86  extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
87  extern struct file * dentry_open_it(struct dentry *, struct vfsmount *, int, struct lookup_intent *);