summaryrefslogtreecommitdiffstats
path: root/sys/nfsclient/nfs_subs.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2012-01-20 20:02:01 +0000
committerjhb <jhb@FreeBSD.org>2012-01-20 20:02:01 +0000
commitf75e35e4d7093d1f4cb56a1be3733e67271df618 (patch)
treed22b04598bdacdd3ec50c0e8e0490fb14fdbf8fe /sys/nfsclient/nfs_subs.c
parentd337cd8b79286df5494262294a0d9559f789b64e (diff)
downloadFreeBSD-src-f75e35e4d7093d1f4cb56a1be3733e67271df618.zip
FreeBSD-src-f75e35e4d7093d1f4cb56a1be3733e67271df618.tar.gz
Close a race in NFS lookup processing that could result in stale name cache
entries on one client when a directory was renamed on another client. The root cause for the stale entry being trusted is that each per-vnode nfsnode structure has a single 'n_ctime' timestamp used to validate positive name cache entries. However, if there are multiple entries for a single vnode, they all share a single timestamp. To fix this, extend the name cache to allow filesystems to optionally store a timestamp value in each name cache entry. The NFS clients now fetch the timestamp associated with each name cache entry and use that to validate cache hits instead of the timestamps previously stored in the nfsnode. Another part of the fix is that the NFS clients now use timestamps from the post-op attributes of RPCs when adding name cache entries rather than pulling the timestamps out of the file's attribute cache. The latter is subject to races with other lookups updating the attribute cache concurrently. Some more details: - Add a variant of nfsm_postop_attr() to the old NFS client that can return a vattr structure with a copy of the post-op attributes. - Handle lookups of "." as a special case in the NFS clients since the name cache does not store name cache entries for ".", so we cannot get a useful timestamp. It didn't really make much sense to recheck the attributes on the the directory to validate the namecache hit for "." anyway. - ABI compat shims for the name cache routines are present in this commit so that it is safe to MFC. MFC after: 2 weeks
Diffstat (limited to 'sys/nfsclient/nfs_subs.c')
-rw-r--r--sys/nfsclient/nfs_subs.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/nfsclient/nfs_subs.c b/sys/nfsclient/nfs_subs.c
index 19fde06..d00a025 100644
--- a/sys/nfsclient/nfs_subs.c
+++ b/sys/nfsclient/nfs_subs.c
@@ -978,8 +978,8 @@ nfsm_loadattr_xx(struct vnode **v, struct vattr *va, struct mbuf **md,
}
int
-nfsm_postop_attr_xx(struct vnode **v, int *f, struct mbuf **md,
- caddr_t *dpos)
+nfsm_postop_attr_xx(struct vnode **v, int *f, struct vattr *va,
+ struct mbuf **md, caddr_t *dpos)
{
u_int32_t *tl;
int t1;
@@ -990,7 +990,7 @@ nfsm_postop_attr_xx(struct vnode **v, int *f, struct mbuf **md,
return EBADRPC;
*f = fxdr_unsigned(int, *tl);
if (*f != 0) {
- t1 = nfs_loadattrcache(&ttvp, md, dpos, NULL, 1);
+ t1 = nfs_loadattrcache(&ttvp, md, dpos, va, 1);
if (t1 != 0) {
*f = 0;
return t1;
@@ -1020,7 +1020,7 @@ nfsm_wcc_data_xx(struct vnode **v, int *f, struct mbuf **md, caddr_t *dpos)
VTONFS(*v)->n_mtime.tv_nsec == fxdr_unsigned(u_int32_t, *(tl + 3)));
mtx_unlock(&(VTONFS(*v))->n_mtx);
}
- t1 = nfsm_postop_attr_xx(v, &ttattrf, md, dpos);
+ t1 = nfsm_postop_attr_xx(v, &ttattrf, NULL, md, dpos);
if (t1)
return t1;
if (*f)
OpenPOWER on IntegriCloud