From: Yiannis Pericleous Date: Wed, 30 May 2007 23:49:25 +0000 (-0400) Subject: export: bugfix, oopsing in d_revalidate when client gets ESTALE X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=4cd9d5abee210ff2dfbf008ea53fa8859d390d3b;p=unionfs-odf.git export: bugfix, oopsing in d_revalidate when client gets ESTALE with nfs exporting, when the cache is dropped on the server decode_fh will most likely return ESTALE to the client. On such cases the server can get a disconnected dentry in unionfs_open and a connected dentry in d_revalidate but with ibstart to -1. This fix just detects those cases and returns an err in order to stop the oopsing. However the file becomes unusable in the client, any attempt to read it will return ESTALE. The best way to fix this will be to implement decode_fh and make sure invariants are kept when an inode becomes stale --- diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c index b9bc33badf..52b01438ad 100644 --- a/fs/unionfs/commonfops.c +++ b/fs/unionfs/commonfops.c @@ -611,6 +611,17 @@ int unionfs_open(struct inode *inode, struct file *file) } dentry = file->f_dentry; + + /* FIXME: With nfs exporting we can get a disconnected dentry here. + * This can happen if the dcache is dropped on the server while the + * client is working, and export ops decodefh returns ESTALE to the + * user. It would best to catch this by implementing decodefh + * or maybe we could connect the dentry ourselves using getparent? + */ + if (dentry->d_flags & DCACHE_DISCONNECTED) { + err = -ESTALE; + goto out; + } unionfs_lock_dentry(dentry); bstart = fbstart(file) = dbstart(dentry); diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c index c9ff88676d..f84911cdde 100644 --- a/fs/unionfs/dentry.c +++ b/fs/unionfs/dentry.c @@ -37,6 +37,20 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry, int interpose_flag; struct nameidata lowernd; /* TODO: be gentler to the stack */ + /* FIXME: with nfs exporting, if export ops fails to connect a dentry + * and returns ESTALE to the client, we can end up with an inode that + * has ibstart -1. This fix only stops the oopsing but the dentry will + * become unusable on the client, it will keep getting ESTALE on any + * attempt to fix it. The best way to fix this is by implementing + * decode_fh and making sure no inode gets left with -1 ibstart + */ + if (dentry->d_inode && ibstart(dentry->d_inode) < 0) { + valid = 0; + make_bad_inode(dentry->d_inode); + d_drop(dentry); + goto out; + } + if (nd) memcpy(&lowernd, nd, sizeof(struct nameidata)); else