Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / kernel_patches / patches / vfs_nointent-2.6-sles10.patch
1 Index: linux-2.6.16.21-0.8/net/unix/af_unix.c
2 ===================================================================
3 --- linux-2.6.16.21-0.8.orig/net/unix/af_unix.c 2006-08-03 01:34:33.000000000 -0600
4 +++ linux-2.6.16.21-0.8/net/unix/af_unix.c      2006-08-03 01:35:38.000000000 -0600
5 @@ -673,6 +673,7 @@
6         int err = 0;
7         
8         if (sunname->sun_path[0]) {
9 +               intent_init(&nd.intent, IT_LOOKUP);
10                 err = path_lookup(sunname->sun_path, LOOKUP_FOLLOW, &nd);
11                 if (err)
12                         goto fail;
13 Index: linux-2.6.16.21-0.8/fs/open.c
14 ===================================================================
15 --- linux-2.6.16.21-0.8.orig/fs/open.c  2006-08-03 01:34:33.000000000 -0600
16 +++ linux-2.6.16.21-0.8/fs/open.c       2006-08-03 02:54:31.000000000 -0600
17 @@ -197,9 +197,10 @@
18  }
19  
20  int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
21 -       struct file *filp)
22 +       struct file *filp, int called_from_open)
23  {
24         int err;
25 +       struct inode_operations *op = dentry->d_inode->i_op;
26         struct iattr newattrs;
27  
28         /* Not pretty: "inode->i_size" shouldn't really be signed. But it is. */
29 @@ -214,7 +215,17 @@
30         }
31  
32         mutex_lock(&dentry->d_inode->i_mutex);
33 -       err = notify_change(dentry, &newattrs);
34 +       if (called_from_open)
35 +                newattrs.ia_valid |= ATTR_FROM_OPEN;
36 +        if (op->setattr_raw) {
37 +                newattrs.ia_valid |= ATTR_RAW;
38 +                newattrs.ia_ctime = CURRENT_TIME;
39 +                down_write(&dentry->d_inode->i_alloc_sem);
40 +                err = op->setattr_raw(dentry->d_inode, &newattrs);
41 +                up_write(&dentry->d_inode->i_alloc_sem);
42 +        } else
43 +                err = notify_change(dentry, &newattrs);
44 +
45         mutex_unlock(&dentry->d_inode->i_mutex);
46         return err;
47  }
48 @@ -269,7 +280,7 @@
49         error = locks_verify_truncate(inode, NULL, length);
50         if (!error) {
51                 DQUOT_INIT(inode);
52 -               error = do_truncate(nd.dentry, length, 0, NULL);
53 +               error = do_truncate(nd.dentry, length, 0, NULL, 0);
54         }
55         put_write_access(inode);
56  
57 @@ -321,7 +332,7 @@
58  
59         error = locks_verify_truncate(inode, file, length);
60         if (!error)
61 -               error = do_truncate(dentry, length, 0, file);
62 +               error = do_truncate(dentry, length, 0, file, 0);
63  out_putf:
64         fput(file);
65  out:
66 @@ -406,9 +417,20 @@
67                     (error = vfs_permission(&nd, MAY_WRITE)) != 0)
68                         goto dput_and_out;
69         }
70 -       mutex_lock(&inode->i_mutex);
71 -       error = notify_change(nd.dentry, &newattrs);
72 -       mutex_unlock(&inode->i_mutex);
73 +       if (inode->i_op->setattr_raw) {
74 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
75 +
76 +               newattrs.ia_valid |= ATTR_RAW;
77 +               error = op->setattr_raw(inode, &newattrs);
78 +               /* the file system wants to use normal vfs path now */
79 +               if (error != -EOPNOTSUPP)
80 +                       goto dput_and_out;
81 +       } else {
82 +               mutex_lock(&inode->i_mutex);
83 +               error = notify_change(nd.dentry, &newattrs);
84 +               mutex_unlock(&inode->i_mutex);
85 +       }
86 +
87  dput_and_out:
88         path_release(&nd);
89  out:
90 @@ -620,36 +642,52 @@
91         return error;
92  }
93  
94 +int chmod_common(struct dentry *dentry, mode_t mode)
95 +{
96 +      struct inode * inode = dentry->d_inode;
97 +      struct iattr newattrs;
98 +      int error = -EROFS;
99 +
100 +      if (IS_RDONLY(inode))
101 +              goto out;
102 +
103 +      if (inode->i_op->setattr_raw) {
104 +              struct inode_operations *op = dentry->d_inode->i_op;
105 +
106 +              newattrs.ia_mode = mode;
107 +              newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
108 +              newattrs.ia_valid |= ATTR_RAW;
109 +              error = op->setattr_raw(inode, &newattrs);
110 +              /* the file system wants to use normal vfs path now */
111 +              if (error != -EOPNOTSUPP)
112 +                    goto out;
113 +      }
114 +
115 +      error = -EPERM;
116 +      if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
117 +              goto out;
118 +
119 +      mutex_lock(&inode->i_mutex);
120 +      if (mode == (mode_t) -1)
121 +              mode = inode->i_mode;
122 +      newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
123 +      newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
124 +      error = notify_change(dentry, &newattrs);
125 +      mutex_unlock(&inode->i_mutex);
126 +out:
127 +      return error;
128 +}
129 +
130  asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
131  {
132 -       struct inode * inode;
133 -       struct dentry * dentry;
134         struct file * file;
135         int err = -EBADF;
136 -       struct iattr newattrs;
137  
138         file = fget(fd);
139         if (!file)
140                 goto out;
141  
142 -       dentry = file->f_dentry;
143 -       inode = dentry->d_inode;
144 -
145 -       err = -EROFS;
146 -       if (IS_RDONLY(inode))
147 -               goto out_putf;
148 -       err = -EPERM;
149 -       if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
150 -               goto out_putf;
151 -       mutex_lock(&inode->i_mutex);
152 -       if (mode == (mode_t) -1)
153 -               mode = inode->i_mode;
154 -       newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
155 -       newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
156 -       err = notify_change(dentry, &newattrs);
157 -       mutex_unlock(&inode->i_mutex);
158 -
159 -out_putf:
160 +        err = chmod_common(file->f_dentry, mode);
161         fput(file);
162  out:
163         return err;
164 @@ -659,32 +697,12 @@
165                              mode_t mode)
166  {
167         struct nameidata nd;
168 -       struct inode * inode;
169         int error;
170 -       struct iattr newattrs;
171  
172         error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd);
173         if (error)
174                 goto out;
175 -       inode = nd.dentry->d_inode;
176 -
177 -       error = -EROFS;
178 -       if (IS_RDONLY(inode))
179 -               goto dput_and_out;
180 -
181 -       error = -EPERM;
182 -       if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
183 -               goto dput_and_out;
184 -
185 -       mutex_lock(&inode->i_mutex);
186 -       if (mode == (mode_t) -1)
187 -               mode = inode->i_mode;
188 -       newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
189 -       newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
190 -       error = notify_change(nd.dentry, &newattrs);
191 -       mutex_unlock(&inode->i_mutex);
192 -
193 -dput_and_out:
194 +       error = chmod_common(nd.dentry, mode);
195         path_release(&nd);
196  out:
197         return error;
198 @@ -710,6 +728,18 @@
199         if (IS_RDONLY(inode))
200                 goto out;
201         error = -EPERM;
202 +       if (inode->i_op->setattr_raw) {
203 +               struct inode_operations *op = dentry->d_inode->i_op;
204 +
205 +               newattrs.ia_uid = user;
206 +               newattrs.ia_gid = group;
207 +               newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
208 +               newattrs.ia_valid |= ATTR_RAW;
209 +               error = op->setattr_raw(inode, &newattrs);
210 +               /* the file system wants to use normal vfs path now */
211 +               if (error != -EOPNOTSUPP)
212 +                       return error;
213 +       }
214         if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
215                 goto out;
216         newattrs.ia_valid =  ATTR_CTIME;
217 Index: linux-2.6.16.21-0.8/fs/namei.c
218 ===================================================================
219 --- linux-2.6.16.21-0.8.orig/fs/namei.c 2006-08-03 01:34:33.000000000 -0600
220 +++ linux-2.6.16.21-0.8/fs/namei.c      2006-08-03 02:54:31.000000000 -0600
221 @@ -1637,7 +1637,7 @@
222                 if (!error) {
223                         DQUOT_INIT(inode);
224                         
225 -                       error = do_truncate(dentry, 0, ATTR_MTIME|ATTR_CTIME, NULL);
226 +                       error = do_truncate(dentry, 0, ATTR_MTIME|ATTR_CTIME, NULL, 1);
227                 }
228                 put_write_access(inode);
229                 if (error)
230 @@ -1911,6 +1911,7 @@
231         char * tmp;
232         struct dentry * dentry;
233         struct nameidata nd;
234 +       intent_init(&nd.intent, IT_LOOKUP);
235  
236         if (S_ISDIR(mode))
237                 return -EPERM;
238 @@ -1921,6 +1922,15 @@
239         error = do_path_lookup(dfd, tmp, LOOKUP_PARENT, &nd);
240         if (error)
241                 goto out;
242 +
243 +       if (nd.dentry->d_inode->i_op->mknod_raw) {
244 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
245 +               error = op->mknod_raw(&nd, mode, dev);
246 +               /* the file system wants to use normal vfs path now */
247 +               if (error != -EOPNOTSUPP)
248 +                       goto out2;
249 +       }
250 +
251         dentry = lookup_create(&nd, 0);
252         error = PTR_ERR(dentry);
253  
254 @@ -1947,6 +1957,7 @@
255                 dput(dentry);
256         }
257         mutex_unlock(&nd.dentry->d_inode->i_mutex);
258 +out2:
259         path_release(&nd);
260  out:
261         putname(tmp);
262 @@ -1992,9 +2003,18 @@
263                 struct dentry *dentry;
264                 struct nameidata nd;
265  
266 +               intent_init(&nd.intent, IT_LOOKUP);
267                 error = do_path_lookup(dfd, tmp, LOOKUP_PARENT, &nd);
268                 if (error)
269                         goto out;
270 +               if (nd.dentry->d_inode->i_op->mkdir_raw) {
271 +                       struct inode_operations *op = nd.dentry->d_inode->i_op;
272 +                       error = op->mkdir_raw(&nd, mode);
273 +                       /* the file system wants to use normal vfs path now */
274 +                       if (error != -EOPNOTSUPP)
275 +                               goto out2;
276 +               }
277 +
278                 dentry = lookup_create(&nd, 1);
279                 error = PTR_ERR(dentry);
280                 if (!IS_ERR(dentry)) {
281 @@ -2004,6 +2024,7 @@
282                         dput(dentry);
283                 }
284                 mutex_unlock(&nd.dentry->d_inode->i_mutex);
285 +out2:
286                 path_release(&nd);
287  out:
288                 putname(tmp);
289 @@ -2084,6 +2105,7 @@
290         char * name;
291         struct dentry *dentry;
292         struct nameidata nd;
293 +       intent_init(&nd.intent, IT_LOOKUP);
294  
295         name = getname(pathname);
296         if(IS_ERR(name))
297 @@ -2104,6 +2126,14 @@
298                         error = -EBUSY;
299                         goto exit1;
300         }
301 +       if (nd.dentry->d_inode->i_op->rmdir_raw) {
302 +                struct inode_operations *op = nd.dentry->d_inode->i_op;
303 +
304 +                error = op->rmdir_raw(&nd);
305 +                /* the file system wants to use normal vfs path now */
306 +                if (error != -EOPNOTSUPP)
307 +                        goto exit1;
308 +        }
309         mutex_lock(&nd.dentry->d_inode->i_mutex);
310         dentry = lookup_hash(&nd);
311         error = PTR_ERR(dentry);
312 @@ -2167,6 +2197,7 @@
313         struct dentry *dentry;
314         struct nameidata nd;
315         struct inode *inode = NULL;
316 +       intent_init(&nd.intent, IT_LOOKUP);
317  
318         name = getname(pathname);
319         if(IS_ERR(name))
320 @@ -2178,6 +2209,13 @@
321         error = -EISDIR;
322         if (nd.last_type != LAST_NORM)
323                 goto exit1;
324 +       if (nd.dentry->d_inode->i_op->unlink_raw) {
325 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
326 +               error = op->unlink_raw(&nd);
327 +                /* the file system wants to use normal vfs path now */
328 +               if (error != -EOPNOTSUPP)
329 +                       goto exit1;
330 +        }
331         mutex_lock(&nd.dentry->d_inode->i_mutex);
332         dentry = lookup_hash(&nd);
333         error = PTR_ERR(dentry);
334 @@ -2260,9 +2298,17 @@
335                 struct dentry *dentry;
336                 struct nameidata nd;
337  
338 +               intent_init(&nd.intent, IT_LOOKUP);
339                 error = do_path_lookup(newdfd, to, LOOKUP_PARENT, &nd);
340                 if (error)
341                         goto out;
342 +               if (nd.dentry->d_inode->i_op->symlink_raw) {
343 +                       struct inode_operations *op = nd.dentry->d_inode->i_op;
344 +                       error = op->symlink_raw(&nd, from);
345 +                       /* the file system wants to use normal vfs path now */
346 +                       if (error != -EOPNOTSUPP)
347 +                               goto out2;
348 +               }
349                 dentry = lookup_create(&nd, 0);
350                 error = PTR_ERR(dentry);
351                 if (!IS_ERR(dentry)) {
352 @@ -2270,6 +2316,7 @@
353                         dput(dentry);
354                 }
355                 mutex_unlock(&nd.dentry->d_inode->i_mutex);
356 +out2:
357                 path_release(&nd);
358  out:
359                 putname(to);
360 @@ -2357,6 +2404,13 @@
361         error = -EXDEV;
362         if (old_nd.mnt != nd.mnt)
363                 goto out_release;
364 +       if (nd.dentry->d_inode->i_op->link_raw) {
365 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
366 +               error = op->link_raw(&old_nd, &nd);
367 +               /* the file system wants to use normal vfs path now */
368 +               if (error != -EOPNOTSUPP)
369 +                       goto out_release;
370 +       }
371         new_dentry = lookup_create(&nd, 0);
372         error = PTR_ERR(new_dentry);
373         if (!IS_ERR(new_dentry)) {
374 @@ -2533,6 +2587,8 @@
375         struct dentry * old_dentry, *new_dentry;
376         struct dentry * trap;
377         struct nameidata oldnd, newnd;
378 +       intent_init(&oldnd.intent, IT_LOOKUP);
379 +       intent_init(&newnd.intent, IT_LOOKUP);
380  
381         error = do_path_lookup(olddfd, oldname, LOOKUP_PARENT, &oldnd);
382         if (error)
383 @@ -2555,6 +2611,13 @@
384         if (newnd.last_type != LAST_NORM)
385                 goto exit2;
386  
387 +       if (old_dir->d_inode->i_op->rename_raw) {
388 +               error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
389 +               /* the file system wants to use normal vfs path now */
390 +               if (error != -EOPNOTSUPP)
391 +                       goto exit2;
392 +       }
393 +
394         trap = lock_rename(new_dir, old_dir);
395  
396         old_dentry = lookup_hash(&oldnd);
397 @@ -2586,8 +2649,7 @@
398         if (new_dentry == trap)
399                 goto exit5;
400  
401 -       error = vfs_rename(old_dir->d_inode, old_dentry,
402 -                                  new_dir->d_inode, new_dentry);
403 +       error = vfs_rename(old_dir->d_inode, old_dentry, new_dir->d_inode, new_dentry);
404  exit5:
405         dput(new_dentry);
406  exit4:
407 Index: linux-2.6.16.21-0.8/fs/exec.c
408 ===================================================================
409 --- linux-2.6.16.21-0.8.orig/fs/exec.c  2006-08-03 01:34:33.000000000 -0600
410 +++ linux-2.6.16.21-0.8/fs/exec.c       2006-08-03 01:35:38.000000000 -0600
411 @@ -1524,7 +1524,7 @@
412                 goto close_fail;
413         if (!file->f_op->write)
414                 goto close_fail;
415 -       if (do_truncate(file->f_dentry, 0, 0, file) != 0)
416 +       if (do_truncate(file->f_dentry, 0, 0, file, 0) != 0)
417                 goto close_fail;
418  
419         retval = binfmt->core_dump(signr, regs, file);
420 Index: linux-2.6.16.21-0.8/include/linux/fs.h
421 ===================================================================
422 --- linux-2.6.16.21-0.8.orig/include/linux/fs.h 2006-08-03 01:34:33.000000000 -0600
423 +++ linux-2.6.16.21-0.8/include/linux/fs.h      2006-08-03 01:35:38.000000000 -0600
424 @@ -1041,13 +1041,20 @@
425         int (*create) (struct inode *,struct dentry *,int, struct nameidata *);
426         struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);
427         int (*link) (struct dentry *,struct inode *,struct dentry *);
428 +       int (*link_raw) (struct nameidata *,struct nameidata *);
429         int (*unlink) (struct inode *,struct dentry *);
430 +       int (*unlink_raw) (struct nameidata *);
431         int (*symlink) (struct inode *,struct dentry *,const char *);
432 +       int (*symlink_raw) (struct nameidata *,const char *);
433         int (*mkdir) (struct inode *,struct dentry *,int);
434 +       int (*mkdir_raw) (struct nameidata *,int);
435         int (*rmdir) (struct inode *,struct dentry *);
436 +       int (*rmdir_raw) (struct nameidata *);
437         int (*mknod) (struct inode *,struct dentry *,int,dev_t);
438 +       int (*mknod_raw) (struct nameidata *,int,dev_t);
439         int (*rename) (struct inode *, struct dentry *,
440                         struct inode *, struct dentry *);
441 +       int (*rename_raw) (struct nameidata *, struct nameidata *);
442         int (*readlink) (struct dentry *, char __user *,int);
443         void * (*follow_link) (struct dentry *, struct nameidata *);
444         void (*put_link) (struct dentry *, struct nameidata *, void *);
445 @@ -1357,7 +1364,7 @@
446  /* fs/open.c */
447  
448  extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs,
449 -                      struct file *filp);
450 +                      struct file *filp, int called_from_open);
451  extern long do_sys_open(int fdf, const char __user *filename, int flags,
452                         int mode);
453  extern struct file *filp_open(const char *, int, int);