- /*
- * Save information about the lower layer.
- * This needs to keep track of pathname
- * and directory information which union_vn_create
- * might need.
- */
- if (lowervp != un->un_lowervp) {
- if (un->un_lowervp) {
- vrele(un->un_lowervp);
- free(un->un_path, M_TEMP);
- vrele(un->un_dirvp);
- }
- un->un_lowervp = lowervp;
- if (cnp && (lowervp != NULLVP) &&
- (lowervp->v_type == VREG)) {
- un->un_hash = cnp->cn_hash;
- un->un_path = malloc(cnp->cn_namelen+1,
- M_TEMP, M_WAITOK);
- bcopy(cnp->cn_nameptr, un->un_path,
- cnp->cn_namelen);
- un->un_path[cnp->cn_namelen] = '\0';
- VREF(dvp);
- un->un_dirvp = dvp;
- }
- } else if (lowervp) {
- vrele(lowervp);
+#ifdef DIAGNOSTIC
+ if (curproc)
+ un->un_pid = curproc->p_pid;
+ else
+ un->un_pid = -1;
+#endif
+ }
+
+ /*
+ * At this point, the union_node is locked,
+ * un->un_uppervp may not be locked, and uppervp
+ * is locked or nil.
+ */
+
+ /*
+ * Save information about the upper layer.
+ */
+ if (uppervp != un->un_uppervp) {
+ if (un->un_uppervp)
+ vrele(un->un_uppervp);
+ un->un_uppervp = uppervp;
+ } else if (uppervp) {
+ vrele(uppervp);
+ }
+
+ if (un->un_uppervp) {
+ un->un_flags |= UN_ULOCK;
+ un->un_flags &= ~UN_KLOCK;
+ }
+
+ /*
+ * Save information about the lower layer.
+ * This needs to keep track of pathname
+ * and directory information which union_vn_create
+ * might need.
+ */
+ if (lowervp != un->un_lowervp) {
+ if (un->un_lowervp) {
+ vrele(un->un_lowervp);
+ free(un->un_path, M_TEMP);
+ vrele(un->un_dirvp);
+ }
+ un->un_lowervp = lowervp;
+ if (cnp && (lowervp != NULLVP) &&
+ (lowervp->v_type == VREG)) {
+ un->un_hash = cnp->cn_hash;
+ un->un_path = malloc(cnp->cn_namelen+1,
+ M_TEMP, M_WAITOK);
+ bcopy(cnp->cn_nameptr, un->un_path,
+ cnp->cn_namelen);
+ un->un_path[cnp->cn_namelen] = '\0';
+ VREF(dvp);
+ un->un_dirvp = dvp;