From 017b1d400d62127b166268bea23b3c1f7282dfea Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 13 Sep 2003 11:47:31 +0000 Subject: [PATCH] - fix agaist bug #1322 'clients looping in revalidate after recovery failure' --- .../patches/vfs_intent-2.4.18-18-chaos65.patch | 116 +++++++++++---------- 1 file changed, 59 insertions(+), 57 deletions(-) diff --git a/lustre/kernel_patches/patches/vfs_intent-2.4.18-18-chaos65.patch b/lustre/kernel_patches/patches/vfs_intent-2.4.18-18-chaos65.patch index ece0cf8..8fd128e 100644 --- a/lustre/kernel_patches/patches/vfs_intent-2.4.18-18-chaos65.patch +++ b/lustre/kernel_patches/patches/vfs_intent-2.4.18-18-chaos65.patch @@ -1,6 +1,6 @@ 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 ++-- @@ -9,7 +9,7 @@ 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 @@ -229,7 +229,7 @@ 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... */ @@ -265,7 +265,7 @@ 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 */ @@ -275,13 +275,14 @@ { 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(); @@ -291,7 +292,7 @@ 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); } @@ -299,12 +300,15 @@ + 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. */ @@ -314,7 +318,7 @@ { 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); @@ -327,7 +331,7 @@ 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); } @@ -337,7 +341,7 @@ { 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) { @@ -346,7 +350,7 @@ } 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; } @@ -355,7 +359,7 @@ ; } -@@ -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. */ @@ -365,7 +369,7 @@ { 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.. */ @@ -387,7 +391,7 @@ ; 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; @@ -398,7 +402,7 @@ 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; @@ -407,7 +411,7 @@ break; continue; /* here ends the main loop */ -@@ -592,22 +625,23 @@ last_component: +@@ -592,22 +629,23 @@ last_component: if (err < 0) break; } @@ -436,7 +440,7 @@ 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; @@ -446,12 +450,11 @@ 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)) { @@ -465,14 +468,13 @@ + 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; } @@ -502,7 +504,7 @@ } /* 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 */ @@ -520,7 +522,7 @@ 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; @@ -528,7 +530,7 @@ 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. */ @@ -538,7 +540,7 @@ { 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; } @@ -556,7 +558,7 @@ dentry = inode->i_op->lookup(inode, new); unlock_kernel(); if (!dentry) -@@ -820,6 +901,12 @@ out: +@@ -820,6 +903,12 @@ out: return dentry; } @@ -569,7 +571,7 @@ /* 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); @@ -578,7 +580,7 @@ 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; } @@ -602,7 +604,7 @@ /* * 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; } @@ -640,7 +642,7 @@ 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); } @@ -659,7 +661,7 @@ 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; @@ -675,7 +677,7 @@ 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. */ @@ -684,7 +686,7 @@ 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); @@ -693,7 +695,7 @@ do_last: error = PTR_ERR(dentry); -@@ -1103,10 +1244,11 @@ do_last: +@@ -1103,10 +1246,11 @@ do_last: goto exit; } @@ -707,7 +709,7 @@ 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; @@ -722,7 +724,7 @@ 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; @@ -737,7 +739,7 @@ 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); @@ -753,7 +755,7 @@ 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); @@ -771,7 +773,7 @@ { 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; @@ -780,7 +782,7 @@ 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; @@ -798,7 +800,7 @@ 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); @@ -806,7 +808,7 @@ 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; @@ -822,7 +824,7 @@ 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); @@ -830,7 +832,7 @@ 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; } @@ -848,7 +850,7 @@ 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; @@ -865,7 +867,7 @@ 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; @@ -891,7 +893,7 @@ 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; @@ -907,7 +909,7 @@ 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, @@ -916,7 +918,7 @@ { 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, @@ -925,7 +927,7 @@ { 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; @@ -945,7 +947,7 @@ 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; } @@ -964,7 +966,7 @@ dput(new_dentry); exit4: dput(old_dentry); -@@ -1943,12 +2150,17 @@ out: +@@ -1943,12 +2152,17 @@ out: } static inline int @@ -983,7 +985,7 @@ 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; } @@ -992,7 +994,7 @@ 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) { @@ -1007,7 +1009,7 @@ } /* 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); -- 1.8.3.1