From owner-trustedbsd-cvs@FreeBSD.ORG Mon Jan 22 15:43:44 2007 Return-Path: X-Original-To: trustedbsd-cvs@freebsd.org Delivered-To: trustedbsd-cvs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 967B916A404 for ; Mon, 22 Jan 2007 15:43:44 +0000 (UTC) (envelope-from owner-perforce@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [209.31.154.42]) by mx1.freebsd.org (Postfix) with ESMTP id 65F7B13C441 for ; Mon, 22 Jan 2007 15:43:36 +0000 (UTC) (envelope-from owner-perforce@freebsd.org) Received: from mx2.freebsd.org (mx2.freebsd.org [69.147.83.53]) by cyrus.watson.org (Postfix) with ESMTP id D55014A4F8 for ; Mon, 22 Jan 2007 10:43:29 -0500 (EST) Received: from hub.freebsd.org (hub.freebsd.org [69.147.83.54]) by mx2.freebsd.org (Postfix) with ESMTP id 04764572CD; Mon, 22 Jan 2007 15:43:11 +0000 (GMT) (envelope-from owner-perforce@freebsd.org) Received: by hub.freebsd.org (Postfix, from userid 32767) id F0C3816A405; Mon, 22 Jan 2007 15:43:10 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A742E16A401 for ; Mon, 22 Jan 2007 15:43:10 +0000 (UTC) (envelope-from millert@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 5F5BB13C45B for ; Mon, 22 Jan 2007 15:43:10 +0000 (UTC) (envelope-from millert@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id l0MFhAcH021920 for ; Mon, 22 Jan 2007 15:43:10 GMT (envelope-from millert@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id l0MFhAHN021917 for perforce@freebsd.org; Mon, 22 Jan 2007 15:43:10 GMT (envelope-from millert@freebsd.org) Date: Mon, 22 Jan 2007 15:43:10 GMT Message-Id: <200701221543.l0MFhAHN021917@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to millert@freebsd.org using -f From: Todd Miller To: Perforce Change Reviews Cc: Subject: PERFORCE change 113330 for review X-BeenThere: trustedbsd-cvs@FreeBSD.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: TrustedBSD CVS and Perforce commit message list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Jan 2007 15:43:44 -0000 http://perforce.freebsd.org/chv.cgi?CH=113330 Change 113330 by millert@millert_macbook on 2007/01/22 15:42:30 Minor reorg that takes into account that V_LABELED and V_LABEL are mutually exclusive. I also put a loop around the msleep() in vnode_label() and vnode_label1() to make sure that V_LABEL has really been cleared when we wake up (vnode_relabel() already did this). Affected files ... .. //depot/projects/trustedbsd/sedarwin8/darwin/xnu/security/mac_vfs_subr.c#9 edit Differences ... ==== //depot/projects/trustedbsd/sedarwin8/darwin/xnu/security/mac_vfs_subr.c#9 (text+ko) ==== @@ -36,14 +36,14 @@ return (ENOENT); } - if ((vp->v_lflag & (VL_LABEL|VL_LABELED)) == 0) { + if ((vp->v_lflag & VL_LABEL) == 0) { vp->v_lflag |= VL_LABEL; /* Could sleep on disk I/O, drop lock. */ vnode_unlock(vp); if (flags & VNODE_LABEL_CREATE) error = mac_vnode_notify_create(vfs_context_ucred(ctx), - mp, dvp, vp, cnp); + mp, dvp, vp, cnp); else error = mac_vnode_label_associate(mp, vp, ctx); vnode_lock(vp); @@ -51,30 +51,32 @@ if ((error == 0) && (vp->v_flag & VNCACHEABLE)) vp->v_lflag |= VL_LABELED; vp->v_lflag &= ~VL_LABEL; + if (vp->v_lflag & VL_LABELWAIT) { vp->v_lflag &= ~VL_LABELWAIT; wakeup(vp->v_label); } - } else - if (vp->v_lflag & VL_LABEL) { + vnode_put_locked(vp); + vnode_unlock(vp); + } else { struct timespec ts; ts.tv_sec = 10; ts.tv_nsec = 0; - vp->v_lflag |= VL_LABELWAIT; - - error = msleep(vp->v_label, &vp->v_lock, PVFS|PDROP, - "vnode_label", &ts); - if (error == EWOULDBLOCK) - vprint("vnode label timeout", vp); + while (vp->v_lflag & VL_LABEL) { + vp->v_lflag |= VL_LABELWAIT; + error = msleep(vp->v_label, &vp->v_lock, PVFS|PDROP, + "vnode_label", &ts); + if (error == EWOULDBLOCK) { + vprint("vnode label timeout", vp); + break; + } + } /* XXX: what should be done if labeling failed (above)? */ vnode_put(vp); - return (error); } - vnode_put_locked(vp); - vnode_unlock(vp); return (error); } @@ -90,11 +92,14 @@ struct vfs_context ctx; int error; + if (vp->v_lflag & VL_LABELED) + return (0); + error = 0; ctx.vc_proc = current_proc(); ctx.vc_ucred = kauth_cred_get(); - if ((vp->v_lflag & (VL_LABEL|VL_LABELED)) == 0) { + if ((vp->v_lflag & VL_LABEL) == 0) { vp->v_lflag |= VL_LABEL; /* Could sleep on disk I/O, drop lock. */ @@ -109,11 +114,13 @@ vp->v_lflag &= ~VL_LABELWAIT; wakeup(vp->v_label); } - } else - /* Wait for other labeling to complete. */ - if (vp->v_lflag & VL_LABEL) { - vp->v_lflag |= VL_LABELWAIT; - (void)msleep(vp->v_label, &vp->v_lock, PVFS, "vnode_label", 0); + } else { + /* Wait for any other labeling to complete. */ + while (vp->v_lflag & VL_LABEL) { + vp->v_lflag |= VL_LABELWAIT; + (void)msleep(vp->v_label, &vp->v_lock, PVFS, + "vnode_label1", 0); + } /* XXX: what should be done if labeling failed (above)? */ } @@ -132,7 +139,7 @@ vnode_relabel(struct vnode *vp) { - /* Wait for other labeling to complete. */ + /* Wait for any other labeling to complete. */ while (vp->v_lflag & VL_LABEL) { vp->v_lflag |= VL_LABELWAIT; (void)msleep(vp->v_label, &vp->v_lock, PVFS, "vnode_relabel", 0);