fs/dcache.c | 19 ++
fs/exec.c | 18 +-
- fs/namei.c | 322 +++++++++++++++++++++++++++++++++++++++++--------
+ fs/namei.c | 324 +++++++++++++++++++++++++++++++++++++++++--------
fs/namespace.c | 28 +++-
fs/open.c | 167 ++++++++++++++++++-------
fs/stat.c | 27 ++--
kernel/exit.c | 3
kernel/fork.c | 3
kernel/ksyms.c | 1
- 11 files changed, 556 insertions(+), 126 deletions(-)
+ 11 files changed, 558 insertions(+), 126 deletions(-)
--- linux-2.4.18-chaos/fs/exec.c~vfs_intent-2.4.18-18-chaos65 2003-07-28 17:52:03.000000000 +0400
+++ linux-2.4.18-chaos-alexey/fs/exec.c 2003-09-11 20:01:36.000000000 +0400
out0:
unlock_kernel();
--- linux-2.4.18-chaos/fs/namei.c~vfs_intent-2.4.18-18-chaos65 2003-07-28 17:52:05.000000000 +0400
-+++ linux-2.4.18-chaos-alexey/fs/namei.c 2003-09-11 20:01:36.000000000 +0400
++++ linux-2.4.18-chaos-alexey/fs/namei.c 2003-09-13 15:45:03.000000000 +0400
@@ -94,6 +94,13 @@
* XEmacs seems to be relying on it...
*/
if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) {
dput(dentry);
-@@ -281,11 +297,14 @@ static struct dentry * cached_lookup(str
+@@ -281,11 +297,15 @@ static struct dentry * cached_lookup(str
* make sure that nobody added the entry to the dcache in the meantime..
* SMP-safe
*/
{
struct dentry * result;
struct inode *dir = parent->d_inode;
++ int counter = 0;
+again:
-+
++ counter++;
down(&dir->i_sem);
/*
* First re-do the cached lookup just in case it was created
-@@ -300,6 +319,9 @@ static struct dentry * real_lookup(struc
+@@ -300,6 +320,9 @@ static struct dentry * real_lookup(struc
result = ERR_PTR(-ENOMEM);
if (dentry) {
lock_kernel();
result = dir->i_op->lookup(dir, dentry);
unlock_kernel();
if (result)
-@@ -321,6 +343,12 @@ static struct dentry * real_lookup(struc
+@@ -321,6 +344,15 @@ static struct dentry * real_lookup(struc
dput(result);
result = ERR_PTR(-ENOENT);
}
+ if (!result->d_op->d_revalidate_it(result, flags, it) &&
+ !d_invalidate(result)) {
+ dput(result);
-+ goto again;
++ if (counter > 10)
++ result = ERR_PTR(-ESTALE);
++ if (!IS_ERR(result))
++ goto again;
+ }
}
return result;
}
-@@ -334,7 +362,8 @@ int max_recursive_link = 5;
+@@ -334,7 +366,8 @@ int max_recursive_link = 5;
* Without that kind of total limit, nasty chains of consecutive
* symlinks can cause almost arbitrarily long lookups.
*/
{
int err;
if (current->link_count >= max_recursive_link)
-@@ -348,10 +377,12 @@ static inline int do_follow_link(struct
+@@ -348,10 +381,12 @@ static inline int do_follow_link(struct
current->link_count++;
current->total_link_count++;
UPDATE_ATIME(dentry->d_inode);
path_release(nd);
return -ELOOP;
}
-@@ -381,7 +412,8 @@ int follow_up(struct vfsmount **mnt, str
+@@ -381,7 +416,8 @@ int follow_up(struct vfsmount **mnt, str
return __follow_up(mnt, dentry);
}
{
struct vfsmount *mounted;
-@@ -401,7 +433,7 @@ static inline int __follow_down(struct v
+@@ -401,7 +437,7 @@ static inline int __follow_down(struct v
int follow_down(struct vfsmount **mnt, struct dentry **dentry)
{
}
static inline void follow_dotdot(struct nameidata *nd)
-@@ -437,7 +469,7 @@ static inline void follow_dotdot(struct
+@@ -437,7 +473,7 @@ static inline void follow_dotdot(struct
mntput(nd->mnt);
nd->mnt = parent;
}
;
}
-@@ -449,7 +481,8 @@ static inline void follow_dotdot(struct
+@@ -449,7 +485,8 @@ static inline void follow_dotdot(struct
*
* We expect 'base' to be positive and a directory.
*/
{
struct dentry *dentry;
struct inode *inode;
-@@ -526,18 +559,18 @@ int link_path_walk(const char * name, st
+@@ -526,18 +563,18 @@ int link_path_walk(const char * name, st
break;
}
/* This does the actual lookups.. */
;
err = -ENOENT;
-@@ -548,8 +581,8 @@ int link_path_walk(const char * name, st
+@@ -548,8 +585,8 @@ int link_path_walk(const char * name, st
if (!inode->i_op)
goto out_dput;
dput(dentry);
if (err)
goto return_err;
-@@ -565,7 +598,7 @@ int link_path_walk(const char * name, st
+@@ -565,7 +602,7 @@ int link_path_walk(const char * name, st
nd->dentry = dentry;
}
err = -ENOTDIR;
break;
continue;
/* here ends the main loop */
-@@ -592,22 +625,23 @@ last_component:
+@@ -592,22 +629,23 @@ last_component:
if (err < 0)
break;
}
dput(dentry);
if (err)
goto return_err;
-@@ -621,7 +655,8 @@ last_component:
+@@ -621,7 +659,8 @@ last_component:
goto no_inode;
if (lookup_flags & LOOKUP_DIRECTORY) {
err = -ENOTDIR;
break;
}
goto return_base;
-@@ -645,7 +680,24 @@ return_reval:
+@@ -645,7 +684,22 @@ return_reval:
* Check the cached dentry for staleness.
*/
dentry = nd->dentry;
- if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
-+ revalidate_again:
+ if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
+ err = -ESTALE;
+ if (!dentry->d_op->d_revalidate_it(dentry, 0, it)) {
+ d_invalidate(dentry);
+ dput(dentry);
+ dentry = new;
-+ goto revalidate_again;
+ }
+ }
+ else if (dentry && dentry->d_op && dentry->d_op->d_revalidate){
err = -ESTALE;
if (!dentry->d_op->d_revalidate(dentry, 0)) {
d_invalidate(dentry);
-@@ -658,15 +710,28 @@ out_dput:
+@@ -658,15 +712,28 @@ out_dput:
dput(dentry);
break;
}
}
/* SMP-safe */
-@@ -751,6 +816,17 @@ walk_init_root(const char *name, struct
+@@ -751,6 +818,17 @@ walk_init_root(const char *name, struct
}
/* SMP-safe */
int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
{
int error = 0;
-@@ -765,6 +841,7 @@ int path_init(const char *name, unsigned
+@@ -765,6 +843,7 @@ int path_init(const char *name, unsigned
{
nd->last_type = LAST_ROOT; /* if there are only slashes... */
nd->flags = flags;
if (*name=='/')
return walk_init_root(name,nd);
read_lock(¤t->fs->lock);
-@@ -779,7 +856,8 @@ int path_init(const char *name, unsigned
+@@ -779,7 +858,8 @@ int path_init(const char *name, unsigned
* needs parent already locked. Doesn't follow mounts.
* SMP-safe.
*/
{
struct dentry * dentry;
struct inode *inode;
-@@ -802,13 +880,16 @@ struct dentry * lookup_hash(struct qstr
+@@ -802,13 +882,16 @@ struct dentry * lookup_hash(struct qstr
goto out;
}
dentry = inode->i_op->lookup(inode, new);
unlock_kernel();
if (!dentry)
-@@ -820,6 +901,12 @@ out:
+@@ -820,6 +903,12 @@ out:
return dentry;
}
/* SMP-safe */
struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
{
-@@ -841,7 +928,7 @@ struct dentry * lookup_one_len(const cha
+@@ -841,7 +930,7 @@ struct dentry * lookup_one_len(const cha
}
this.hash = end_name_hash(hash);
access:
return ERR_PTR(-EACCES);
}
-@@ -872,6 +959,23 @@ int __user_walk(const char *name, unsign
+@@ -872,6 +961,23 @@ int __user_walk(const char *name, unsign
return err;
}
/*
* It's inline, so penalty for filesystems that don't use sticky bit is
* minimal.
-@@ -969,6 +1073,37 @@ static inline int lookup_flags(unsigned
+@@ -969,6 +1075,37 @@ static inline int lookup_flags(unsigned
return retval;
}
int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
{
int error;
-@@ -1045,14 +1180,17 @@ int may_open(struct nameidata *nd, int a
+@@ -1045,14 +1182,17 @@ int may_open(struct nameidata *nd, int a
return get_lease(inode, flag);
}
int count = 0;
if (!capable(CAP_SYS_ADMIN))
-@@ -1063,13 +1201,14 @@ struct file *filp_open(const char * path
+@@ -1063,13 +1203,14 @@ struct file *filp_open(const char * path
if (flag & O_TRUNC)
flag |= 2;
if (error)
return ERR_PTR(error);
dentry = nd.dentry;
-@@ -1079,6 +1218,8 @@ struct file *filp_open(const char * path
+@@ -1079,6 +1220,8 @@ struct file *filp_open(const char * path
/*
* Create - we need to know the parent.
*/
error = path_lookup(pathname, LOOKUP_PARENT, &nd);
if (error)
return ERR_PTR(error);
-@@ -1094,7 +1235,7 @@ struct file *filp_open(const char * path
+@@ -1094,7 +1237,7 @@ struct file *filp_open(const char * path
dir = nd.dentry;
down(&dir->d_inode->i_sem);
do_last:
error = PTR_ERR(dentry);
-@@ -1103,10 +1244,11 @@ do_last:
+@@ -1103,10 +1246,11 @@ do_last:
goto exit;
}
up(&dir->d_inode->i_sem);
dput(nd.dentry);
nd.dentry = dentry;
-@@ -1132,12 +1274,12 @@ do_last:
+@@ -1132,12 +1276,12 @@ do_last:
error = -ELOOP;
if (flag & O_NOFOLLOW)
goto exit_dput;
goto do_link;
dput(nd.dentry);
-@@ -1152,11 +1294,13 @@ ok:
+@@ -1152,11 +1296,13 @@ ok:
if (!S_ISREG(nd.dentry->d_inode->i_mode))
open_flags &= ~O_TRUNC;
path_release(&nd);
return ERR_PTR(error);
-@@ -1175,10 +1319,14 @@ do_link:
+@@ -1175,10 +1321,14 @@ do_link:
* are done. Procfs-like symlinks just set LAST_BIND.
*/
UPDATE_ATIME(dentry->d_inode);
if (nd.last_type == LAST_BIND) {
dentry = nd.dentry;
goto ok;
-@@ -1197,13 +1345,15 @@ do_link:
+@@ -1197,13 +1347,15 @@ do_link:
}
dir = nd.dentry;
down(&dir->d_inode->i_sem);
{
struct dentry *dentry;
-@@ -1211,7 +1361,7 @@ static struct dentry *lookup_create(stru
+@@ -1211,7 +1363,7 @@ static struct dentry *lookup_create(stru
dentry = ERR_PTR(-EEXIST);
if (nd->last_type != LAST_NORM)
goto fail;
if (IS_ERR(dentry))
goto fail;
if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
-@@ -1267,7 +1417,16 @@ asmlinkage long sys_mknod(const char * f
+@@ -1267,7 +1419,16 @@ asmlinkage long sys_mknod(const char * f
error = path_lookup(tmp, LOOKUP_PARENT, &nd);
if (error)
goto out;
error = PTR_ERR(dentry);
mode &= ~current->fs->umask;
-@@ -1288,6 +1447,7 @@ asmlinkage long sys_mknod(const char * f
+@@ -1288,6 +1449,7 @@ asmlinkage long sys_mknod(const char * f
dput(dentry);
}
up(&nd.dentry->d_inode->i_sem);
path_release(&nd);
out:
putname(tmp);
-@@ -1335,7 +1495,14 @@ asmlinkage long sys_mkdir(const char * p
+@@ -1335,7 +1497,14 @@ asmlinkage long sys_mkdir(const char * p
error = path_lookup(tmp, LOOKUP_PARENT, &nd);
if (error)
goto out;
error = PTR_ERR(dentry);
if (!IS_ERR(dentry)) {
error = vfs_mkdir(nd.dentry->d_inode, dentry,
-@@ -1343,6 +1510,7 @@ asmlinkage long sys_mkdir(const char * p
+@@ -1343,6 +1512,7 @@ asmlinkage long sys_mkdir(const char * p
dput(dentry);
}
up(&nd.dentry->d_inode->i_sem);
path_release(&nd);
out:
putname(tmp);
-@@ -1443,8 +1611,16 @@ asmlinkage long sys_rmdir(const char * p
+@@ -1443,8 +1613,16 @@ asmlinkage long sys_rmdir(const char * p
error = -EBUSY;
goto exit1;
}
error = PTR_ERR(dentry);
if (!IS_ERR(dentry)) {
error = vfs_rmdir(nd.dentry->d_inode, dentry);
-@@ -1502,8 +1678,15 @@ asmlinkage long sys_unlink(const char *
+@@ -1502,8 +1680,15 @@ asmlinkage long sys_unlink(const char *
error = -EISDIR;
if (nd.last_type != LAST_NORM)
goto exit1;
error = PTR_ERR(dentry);
if (!IS_ERR(dentry)) {
/* Why not before? Because we want correct error value */
-@@ -1570,15 +1753,23 @@ asmlinkage long sys_symlink(const char *
+@@ -1570,15 +1755,23 @@ asmlinkage long sys_symlink(const char *
error = path_lookup(to, LOOKUP_PARENT, &nd);
if (error)
goto out;
putname(to);
}
putname(from);
-@@ -1654,7 +1845,14 @@ asmlinkage long sys_link(const char * ol
+@@ -1654,7 +1847,14 @@ asmlinkage long sys_link(const char * ol
error = -EXDEV;
if (old_nd.mnt != nd.mnt)
goto out_release;
error = PTR_ERR(new_dentry);
if (!IS_ERR(new_dentry)) {
error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
-@@ -1698,7 +1896,7 @@ exit:
+@@ -1698,7 +1898,7 @@ exit:
* locking].
*/
int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
{
int error;
struct inode *target;
-@@ -1777,7 +1975,7 @@ out_unlock:
+@@ -1777,7 +1977,7 @@ out_unlock:
}
int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
{
int error;
-@@ -1865,9 +2063,18 @@ static inline int do_rename(const char *
+@@ -1865,9 +2065,18 @@ static inline int do_rename(const char *
if (newnd.last_type != LAST_NORM)
goto exit2;
error = PTR_ERR(old_dentry);
if (IS_ERR(old_dentry))
goto exit3;
-@@ -1883,16 +2090,16 @@ static inline int do_rename(const char *
+@@ -1883,16 +2092,16 @@ static inline int do_rename(const char *
if (newnd.last.name[newnd.last.len])
goto exit4;
}
dput(new_dentry);
exit4:
dput(old_dentry);
-@@ -1943,12 +2150,17 @@ out:
+@@ -1943,12 +2152,17 @@ out:
}
static inline int
if (*link == '/') {
path_release(nd);
-@@ -1956,7 +2168,7 @@ __vfs_follow_link(struct nameidata *nd,
+@@ -1956,7 +2170,7 @@ __vfs_follow_link(struct nameidata *nd,
/* weird __emul_prefix() stuff did it */
goto out;
}
out:
if (current->link_count || res || nd->last_type!=LAST_NORM)
return res;
-@@ -1978,7 +2190,13 @@ fail:
+@@ -1978,7 +2192,13 @@ fail:
int vfs_follow_link(struct nameidata *nd, const char *link)
{
}
/* get the link contents into pagecache */
-@@ -2020,7 +2238,7 @@ int page_follow_link(struct dentry *dent
+@@ -2020,7 +2240,7 @@ int page_follow_link(struct dentry *dent
{
struct page *page = NULL;
char *s = page_getlink(dentry, &page);