From 87e83e7d4cc74045e2839ec4f484bb41ba1da1c2 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Wed, 11 Aug 2004 01:27:53 +0000 Subject: [PATCH] In v_addpollinfo(), we allocate storage to back vp->v_pollinfo. However, we may sleep when doing so; check that we didn't race with another thread allocating storage for the vnode after allocation is made to a local pointer, and only update the vnode pointer if it's still NULL. Otherwise, accept that another thread got there first, and release the local storage. Discussed with: jmg --- sys/kern/vfs_subr.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 72d41c98b12..aa234be4913 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -3247,8 +3247,14 @@ vbusy(vp) void v_addpollinfo(struct vnode *vp) { + struct vpollinfo *vi; - vp->v_pollinfo = uma_zalloc(vnodepoll_zone, M_WAITOK); + vi = uma_zalloc(vnodepoll_zone, M_WAITOK); + if (vp->v_pollinfo != NULL) { + uma_zfree(vnodepoll_zone, vi); + return; + } + vp->v_pollinfo = vi; mtx_init(&vp->v_pollinfo->vpi_lock, "vnode pollinfo", NULL, MTX_DEF); }