summaryrefslogtreecommitdiffstats
path: root/sys/fs/smbfs/smbfs_node.c
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2004-02-10 05:53:02 +0000
committertjr <tjr@FreeBSD.org>2004-02-10 05:53:02 +0000
commit40b810244fbce5f951ac0c46dbf1181adb21a0b7 (patch)
treeba73a74265f497f6e197c646b862844380ff2f4b /sys/fs/smbfs/smbfs_node.c
parent72c7aa83c9ff6fcca227bada024389ad5063cce1 (diff)
downloadFreeBSD-src-40b810244fbce5f951ac0c46dbf1181adb21a0b7.zip
FreeBSD-src-40b810244fbce5f951ac0c46dbf1181adb21a0b7.tar.gz
Fixes problems that occurred when a file was removed and a directory
created with the same name, and vice versa: - Immediately recycle vnodes of files & directories that have been deleted or renamed. - When looking an entry in the VFS name cache or smbfs's private cache, make sure the vnode type is consistent with the type of file the server thinks it is, and re-create the vnode if it isn't. The alternative to this is to recycle vnodes unconditionally when their use count drops to 0, but this would make all the caching we do mostly useless. PR: 62342 MFC after: 2 weeks
Diffstat (limited to 'sys/fs/smbfs/smbfs_node.c')
-rw-r--r--sys/fs/smbfs/smbfs_node.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/sys/fs/smbfs/smbfs_node.c b/sys/fs/smbfs/smbfs_node.c
index dcc0ada..830e1e5 100644
--- a/sys/fs/smbfs/smbfs_node.c
+++ b/sys/fs/smbfs/smbfs_node.c
@@ -164,6 +164,7 @@ static int
smbfs_node_alloc(struct mount *mp, struct vnode *dvp,
const char *name, int nmlen, struct smbfattr *fap, struct vnode **vpp)
{
+ struct vattr vattr;
struct thread *td = curthread; /* XXX */
struct smbmount *smp = VFSTOSMBFS(mp);
struct smbnode_hashhead *nhpp;
@@ -208,6 +209,20 @@ loop:
smbfs_hash_unlock(smp, td);
if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td) != 0)
goto retry;
+ /* Force cached attributes to be refreshed if stale. */
+ (void)VOP_GETATTR(vp, &vattr, td->td_ucred, td);
+ /*
+ * If the file type on the server is inconsistent with
+ * what it was when we created the vnode, kill the
+ * bogus vnode now and fall through to the code below
+ * to create a new one with the right type.
+ */
+ if ((vp->v_type == VDIR && (np->n_dosattr & SMB_FA_DIR) == 0) ||
+ (vp->v_type == VREG && (np->n_dosattr & SMB_FA_DIR) != 0)) {
+ vput(vp);
+ vgone(vp);
+ break;
+ }
*vpp = vp;
return 0;
}
@@ -361,6 +376,8 @@ smbfs_inactive(ap)
smbfs_attr_cacheremove(vp);
}
VOP_UNLOCK(vp, 0, td);
+ if (np->n_flag & NGONE)
+ vrecycle(vp, NULL, td);
return (0);
}
/*
OpenPOWER on IntegriCloud