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