--- old/usr/src/uts/common/os/flock.c	Sun Aug 25 23:51:16 2013
+++ new/usr/src/uts/common/os/flock.c	Sun Aug 25 23:51:16 2013
@@ -27,6 +27,10 @@
 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
 /*	All Rights Reserved */
 
+/*
+ * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
+ */
+
 #include <sys/flock_impl.h>
 #include <sys/vfs.h>
 #include <sys/t_lock.h>		/* for <sys/callb.h> */
@@ -260,8 +264,8 @@
 	 * Check access permissions
 	 */
 	if ((cmd & SETFLCK) &&
-		((lckdat->l_type == F_RDLCK && (flag & FREAD) == 0) ||
-		(lckdat->l_type == F_WRLCK && (flag & FWRITE) == 0)))
+	    ((lckdat->l_type == F_RDLCK && (flag & FREAD) == 0) ||
+	    (lckdat->l_type == F_WRLCK && (flag & FWRITE) == 0)))
 			return (EBADF);
 
 	/*
@@ -269,10 +273,10 @@
 	 */
 
 	if ((lckdat->l_type == F_UNLCK) ||
-			!((cmd & INOFLCK) || (cmd & SETFLCK))) {
+	    !((cmd & INOFLCK) || (cmd & SETFLCK))) {
 		lock_request = &stack_lock_request;
 		(void) bzero((caddr_t)lock_request,
-				sizeof (lock_descriptor_t));
+		    sizeof (lock_descriptor_t));
 
 		/*
 		 * following is added to make the assertions in
@@ -302,17 +306,17 @@
 		ASSERT(lckdat->l_whence == 0);
 		lock_request->l_start = lckdat->l_start;
 		lock_request->l_end = (lckdat->l_len == 0) ? MAX_U_OFFSET_T :
-			lckdat->l_start + (lckdat->l_len - 1);
+		    lckdat->l_start + (lckdat->l_len - 1);
 	} else {
 		/* check the validity of the lock range */
 		error = flk_convert_lock_data(vp, lckdat,
-			&lock_request->l_start, &lock_request->l_end,
-			offset);
+		    &lock_request->l_start, &lock_request->l_end,
+		    offset);
 		if (error) {
 			goto done;
 		}
 		error = flk_check_lock_data(lock_request->l_start,
-					    lock_request->l_end, MAXEND);
+		    lock_request->l_end, MAXEND);
 		if (error) {
 			goto done;
 		}
@@ -342,7 +346,7 @@
 	}
 	if (!((cmd & SETFLCK) || (cmd & INOFLCK))) {
 		if (lock_request->l_type == F_RDLCK ||
-			lock_request->l_type == F_WRLCK)
+		    lock_request->l_type == F_WRLCK)
 			lock_request->l_state |= QUERY_LOCK;
 	}
 	lock_request->l_flock = (*lckdat);
@@ -378,10 +382,10 @@
 			 * to the registry.
 			 */
 			if (FLK_REGISTRY_IS_NLM_UNKNOWN(nlm_reg_status,
-				nlmid)) {
+			    nlmid)) {
 				FLK_REGISTRY_ADD_NLMID(nlm_reg_status, nlmid);
 			} else if (!FLK_REGISTRY_IS_NLM_UP(nlm_reg_status,
-				nlmid)) {
+			    nlmid)) {
 				/*
 				 * If the NLM server is already known (has made
 				 * previous lock requests) and its state is
@@ -407,8 +411,8 @@
 
 	if (IS_IO_LOCK(lock_request)) {
 		VOP_RWUNLOCK(vp,
-			(lock_request->l_type == F_RDLCK) ?
-				V_WRITELOCK_FALSE : V_WRITELOCK_TRUE, NULL);
+		    (lock_request->l_type == F_RDLCK) ?
+		    V_WRITELOCK_FALSE : V_WRITELOCK_TRUE, NULL);
 	}
 	mutex_enter(&gp->gp_mutex);
 
@@ -481,8 +485,8 @@
 
 	if (IS_IO_LOCK(lock_request)) {
 		(void) VOP_RWLOCK(vp,
-			(lock_request->l_type == F_RDLCK) ?
-				V_WRITELOCK_FALSE : V_WRITELOCK_TRUE, NULL);
+		    (lock_request->l_type == F_RDLCK) ?
+		    V_WRITELOCK_FALSE : V_WRITELOCK_TRUE, NULL);
 		if (!error) {
 			lckdat->l_type = F_UNLCK;
 
@@ -618,7 +622,7 @@
 	uint_t	i;
 
 	flk_edge_cache = kmem_cache_create("flk_edges",
-		sizeof (struct edge), 0, NULL, NULL, NULL, NULL, NULL, 0);
+	    sizeof (struct edge), 0, NULL, NULL, NULL, NULL, NULL, 0);
 	if (flk_edge_cache == NULL) {
 		cmn_err(CE_PANIC, "Couldn't create flk_edge_cache\n");
 	}
@@ -641,8 +645,8 @@
 
 	if (nlm_status_size != 0) {	/* booted as a cluster */
 		nlm_reg_status = (flk_nlm_status_t *)
-			kmem_alloc(sizeof (flk_nlm_status_t) * nlm_status_size,
-				KM_SLEEP);
+		    kmem_alloc(sizeof (flk_nlm_status_t) * nlm_status_size,
+		    KM_SLEEP);
 
 		/* initialize all NLM states in array to NLM_UNKNOWN */
 		for (i = 0; i < nlm_status_size; i++) {
@@ -807,8 +811,8 @@
 			 */
 
 			if (SAME_OWNER(lock, request) &&
-					COVERS(lock, request) &&
-						(request->l_type == F_RDLCK))
+			    COVERS(lock, request) &&
+			    (request->l_type == F_RDLCK))
 				return (flk_execute_request(request));
 			lock = lock->l_next;
 		} while (lock->l_vnode == vp);
@@ -913,7 +917,7 @@
 				if (!request_will_wait)
 					return (EAGAIN);
 				if (COVERS(lock, request) &&
-						lock->l_type == F_WRLCK) {
+				    lock->l_type == F_WRLCK) {
 					if (found_covering_lock &&
 					    !SAME_OWNER(lock, covered_by)) {
 						found_covering_lock++;
@@ -923,12 +927,12 @@
 					covered_by = lock;
 				}
 				if (found_covering_lock &&
-					!SAME_OWNER(lock, covered_by)) {
+				    !SAME_OWNER(lock, covered_by)) {
 					lock = lock->l_next;
 					continue;
 				}
 				if ((error = flk_add_edge(request, lock,
-						!found_covering_lock, 0)))
+				    !found_covering_lock, 0)))
 					return (error);
 			}
 			lock = lock->l_next;
@@ -949,12 +953,12 @@
 		do {
 			if (BLOCKS(lock, request)) {
 				if (found_covering_lock &&
-					!SAME_OWNER(lock, covered_by)) {
+				    !SAME_OWNER(lock, covered_by)) {
 					lock = lock->l_next;
 					continue;
 				}
 				if ((error = flk_add_edge(request, lock,
-							CHECK_CYCLE, 0)))
+				    CHECK_CYCLE, 0)))
 					return (error);
 			}
 			lock = lock->l_next;
@@ -1106,7 +1110,7 @@
 		mutex_exit(&gp->gp_mutex);
 
 		cprp = flk_invoke_callbacks(request->l_callbacks,
-					    FLK_BEFORE_SLEEP);
+		    FLK_BEFORE_SLEEP);
 
 		mutex_enter(&gp->gp_mutex);
 
@@ -1124,7 +1128,7 @@
 
 		mutex_exit(&gp->gp_mutex);
 		(void) flk_invoke_callbacks(request->l_callbacks,
-					    FLK_AFTER_SLEEP);
+		    FLK_AFTER_SLEEP);
 		mutex_enter(&gp->gp_mutex);
 	} else {
 		wait_for_lock(request);
@@ -1136,7 +1140,7 @@
 		 * error that will encourage the client to retransmit.
 		 */
 		if (fg->lockmgr_status[index] != FLK_LOCKMGR_UP &&
-			!IS_GRANTED(request)) {
+		    !IS_GRANTED(request)) {
 			flk_cancel_sleeping_lock(request, 1);
 			return (ENOLCK);
 		}
@@ -1234,8 +1238,8 @@
 		STACK_POP(vertex_stack, l_stack);
 
 		for (ep = FIRST_ADJ(vertex);
-			ep != HEAD(vertex);
-				ep = NEXT_ADJ(ep)) {
+		    ep != HEAD(vertex);
+		    ep = NEXT_ADJ(ep)) {
 			if (COLORED(ep->to_vertex))
 				continue;
 			COLOR(ep->to_vertex);
@@ -1324,10 +1328,10 @@
 	if (request->l_type == F_UNLCK)
 		lock_effect = FLK_UNLOCK;
 	else if (request->l_type == F_RDLCK &&
-			lock->l_type == F_WRLCK)
+	    lock->l_type == F_WRLCK)
 		lock_effect = FLK_DOWNGRADE;
 	else if (request->l_type == F_WRLCK &&
-			lock->l_type == F_RDLCK)
+	    lock->l_type == F_RDLCK)
 		lock_effect = FLK_UPGRADE;
 	else
 		lock_effect = FLK_STAY_SAME;
@@ -1334,7 +1338,7 @@
 
 	if (lock->l_end < request->l_start) {
 		if (lock->l_end == request->l_start - 1 &&
-				lock_effect == FLK_STAY_SAME) {
+		    lock_effect == FLK_STAY_SAME) {
 			topology[0] = request;
 			request->l_start = lock->l_start;
 			nvertex = 1;
@@ -1346,7 +1350,7 @@
 
 	if (lock->l_start > request->l_end) {
 		if (request->l_end == lock->l_start - 1 &&
-					lock_effect == FLK_STAY_SAME) {
+		    lock_effect == FLK_STAY_SAME) {
 			topology[0] = request;
 			request->l_end = lock->l_end;
 			nvertex = 1;
@@ -1544,7 +1548,7 @@
 
 	if (first_lock != NULL) {
 		for (; (lock->l_vnode == vp &&
-			lock->l_start < new_lock->l_start); lock = lock->l_next)
+		    lock->l_start < new_lock->l_start); lock = lock->l_next)
 			;
 	} else {
 		lock = ACTIVE_HEAD(gp);
@@ -1587,8 +1591,8 @@
 
 	if (vp->v_filocks == (struct filock *)lock) {
 		vp->v_filocks = (struct filock *)
-				((lock->l_next->l_vnode == vp) ? lock->l_next :
-								NULL);
+		    ((lock->l_next->l_vnode == vp) ? lock->l_next :
+		    NULL);
 	}
 	lock->l_next->l_prev = lock->l_prev;
 	lock->l_prev->l_next = lock->l_next;
@@ -1617,7 +1621,7 @@
 	ASSERT(IS_INITIAL(request));
 
 	for (lock = gp->sleeping_locks.l_next; (lock != &gp->sleeping_locks &&
-		lock->l_vnode < vp); lock = lock->l_next)
+	    lock->l_vnode < vp); lock = lock->l_next)
 		;
 
 	lock->l_prev->l_next = request;
@@ -1660,7 +1664,7 @@
 	while ((vertex = STACK_TOP(vertex_stack)) != NULL) {
 		STACK_POP(vertex_stack, l_stack);
 		for (ep = FIRST_ADJ(vertex); ep != HEAD(vertex);
-					ep = NEXT_ADJ(ep)) {
+		    ep = NEXT_ADJ(ep)) {
 			if (IS_RECOMPUTE(ep->to_vertex))
 				continue;
 			ep->to_vertex->l_state |= RECOMPUTE_LOCK;
@@ -1675,7 +1679,7 @@
 
 	if (nvertex) {
 		topology = kmem_zalloc(nvertex * sizeof (lock_descriptor_t *),
-						KM_SLEEP);
+		    KM_SLEEP);
 	}
 
 	/*
@@ -1754,7 +1758,7 @@
 	 */
 	if (nvertex)
 		kmem_free((void *)topology,
-			(nvertex * sizeof (lock_descriptor_t *)));
+		    (nvertex * sizeof (lock_descriptor_t *)));
 	/*
 	 * Possibility of some locks unblocked now
 	 */
@@ -1785,11 +1789,11 @@
 	if (gp->mark == UINT_MAX) {
 		gp->mark = 1;
 	for (lock = ACTIVE_HEAD(gp)->l_next; lock != ACTIVE_HEAD(gp);
-					lock = lock->l_next)
+	    lock = lock->l_next)
 			lock->l_color  = 0;
 
 	for (lock = SLEEPING_HEAD(gp)->l_next; lock != SLEEPING_HEAD(gp);
-					lock = lock->l_next)
+	    lock = lock->l_next)
 			lock->l_color  = 0;
 	} else {
 		gp->mark++;
@@ -1920,7 +1924,7 @@
 
 next_in_edge:
 		if (count == nvertex ||
-				vertex->l_sedge == HEAD(vertex)) {
+		    vertex->l_sedge == HEAD(vertex)) {
 			/* prune the tree below this */
 			STACK_POP(vertex_stack, l_stack);
 			vertex->l_state &= ~RECOMPUTE_DONE;
@@ -1966,7 +1970,7 @@
 
 		STACK_POP(vertex_stack, l_stack1);
 		for (ep = FIRST_ADJ(ver); ep != HEAD(ver);
-					ep = NEXT_ADJ(ep)) {
+		    ep = NEXT_ADJ(ep)) {
 			lock = ep->to_vertex;
 			if (COLORED(lock))
 				continue;
@@ -1999,7 +2003,7 @@
 	while ((vertex = STACK_TOP(vertex_stack)) != NULL) {
 		STACK_POP(vertex_stack, l_stack1);
 		for (ep = FIRST_IN(vertex); ep != HEAD(vertex);
-						ep = NEXT_IN(ep)) {
+		    ep = NEXT_IN(ep)) {
 			lck = ep->from_vertex;
 			if (COLORED(lck)) {
 				if (IS_BARRIER(lck)) {
@@ -2044,7 +2048,7 @@
 	while ((vertex = STACK_TOP(vertex_stack)) != NULL) {
 		STACK_POP(vertex_stack, l_stack1);
 		for (ep = FIRST_IN(vertex); ep != HEAD(vertex);
-						ep = NEXT_IN(ep)) {
+		    ep = NEXT_IN(ep)) {
 			lck = ep->from_vertex;
 			if (COLORED(lck)) {
 				/* this is a barrier */
@@ -2290,6 +2294,57 @@
 }
 
 /*
+ * Determine whether there are any locks for the given vnode with a remote
+ * sysid matching given sysid.
+ * Used by the new (open source) NFS Lock Manager (NLM)
+ */
+int
+flk_has_remote_locks_for_sysid(vnode_t *vp, int sysid)
+{
+	lock_descriptor_t *lock;
+	int result = 0;
+	graph_t *gp;
+
+	if (sysid == 0)
+		return (0);
+
+	gp = flk_get_lock_graph(vp, FLK_USE_GRAPH);
+	if (gp == NULL) {
+		return (0);
+	}
+
+	mutex_enter(&gp->gp_mutex);
+
+	SET_LOCK_TO_FIRST_ACTIVE_VP(gp, lock, vp);
+
+	if (lock) {
+		while (lock->l_vnode == vp) {
+			if (lock->l_flock.l_sysid == sysid) {
+				result = 1;
+				goto done;
+			}
+			lock = lock->l_next;
+		}
+	}
+
+	SET_LOCK_TO_FIRST_SLEEP_VP(gp, lock, vp);
+
+	if (lock) {
+		while (lock->l_vnode == vp) {
+			if (lock->l_flock.l_sysid == sysid) {
+				result = 1;
+				goto done;
+			}
+			lock = lock->l_next;
+		}
+	}
+
+done:
+	mutex_exit(&gp->gp_mutex);
+	return (result);
+}
+
+/*
  * Determine if there are any locks owned by the given sysid.
  * Returns zero if not, non-zero if there are.  Note that this return code
  * could be derived from flk_get_{sleeping,active}_locks, but this routine
@@ -2328,8 +2383,8 @@
 
 		if (lck_type & FLK_QUERY_SLEEPING) {
 			for (lock = SLEEPING_HEAD(gp)->l_next;
-				lock != SLEEPING_HEAD(gp) && !has_locks;
-				lock = lock->l_next) {
+			    lock != SLEEPING_HEAD(gp) && !has_locks;
+			    lock = lock->l_next) {
 				if (lock->l_flock.l_sysid == sysid)
 					has_locks = 1;
 			}
@@ -2534,8 +2589,8 @@
 		while (lock->l_vnode == vp) {
 			nlock = lock->l_next;
 			if (SAME_OWNER(lock, request) &&
-				lock->l_start == request->l_start &&
-					lock->l_end == request->l_end) {
+			    lock->l_start == request->l_start &&
+			    lock->l_end == request->l_end) {
 				INTERRUPT_WAKEUP(lock);
 				return (1);
 			}
@@ -2573,8 +2628,8 @@
 		do {
 			nlock = lock->l_next;
 			if ((lock->l_flock.l_pid == pid ||
-					pid == IGN_PID) &&
-				lock->l_flock.l_sysid == sysid) {
+			    pid == IGN_PID) &&
+			    lock->l_flock.l_sysid == sysid) {
 				CANCEL_WAKEUP(lock);
 			}
 			lock = nlock;
@@ -2587,8 +2642,8 @@
 		do {
 			nlock = lock->l_next;
 			if ((lock->l_flock.l_pid == pid ||
-					pid == IGN_PID) &&
-				lock->l_flock.l_sysid == sysid) {
+			    pid == IGN_PID) &&
+			    lock->l_flock.l_sysid == sysid) {
 				flk_delete_active_lock(lock, 0);
 				STACK_PUSH(link_stack, lock, l_stack);
 			}
@@ -2817,7 +2872,7 @@
 		flk_free_edge(ep);
 		ppep = start_vertex->edge;
 		for (pep = start_vertex->edge; pep != NULL; ppep = pep,
-						pep = ppep->next) {
+		    pep = ppep->next) {
 			if (pep->to_proc == adj_proc) {
 				pep->refcount--;
 				if (pep->refcount == 0) {
@@ -2845,7 +2900,7 @@
 		flk_free_edge(ep);
 		ppep = in_proc->edge;
 		for (pep = in_proc->edge; pep != NULL; ppep = pep,
-						pep = ppep->next) {
+		    pep = ppep->next) {
 			if (pep->to_proc == start_vertex) {
 				pep->refcount--;
 				if (pep->refcount == 0) {
@@ -2911,14 +2966,14 @@
 		}
 	}
 	palloc = kmem_zalloc((pgraph.gcount + PROC_CHUNK) *
-				sizeof (proc_vertex_t *), KM_SLEEP);
+	    sizeof (proc_vertex_t *), KM_SLEEP);
 
 	if (pgraph.proc) {
 		bcopy(pgraph.proc, palloc,
-			pgraph.gcount * sizeof (proc_vertex_t *));
+		    pgraph.gcount * sizeof (proc_vertex_t *));
 
 		kmem_free(pgraph.proc,
-			pgraph.gcount * sizeof (proc_vertex_t *));
+		    pgraph.gcount * sizeof (proc_vertex_t *));
 	}
 	pgraph.proc = palloc;
 	pgraph.free += (PROC_CHUNK - 1);
@@ -3122,7 +3177,7 @@
 		 * add it to the registry in the nlm shutting down state.
 		 */
 		FLK_REGISTRY_CHANGE_NLM_STATE(nlm_reg_status, nlmid,
-			FLK_NLM_SHUTTING_DOWN);
+		    FLK_NLM_SHUTTING_DOWN);
 	} else {
 		/*
 		 * Change the state of the NLM server identified by "nlmid"
@@ -3129,7 +3184,7 @@
 		 * in the NLM registry to the argument "nlm_state."
 		 */
 		FLK_REGISTRY_CHANGE_NLM_STATE(nlm_reg_status, nlmid,
-			nlm_state);
+		    nlm_state);
 	}
 
 	/*
@@ -3314,7 +3369,7 @@
 
 		mutex_enter(&gp->gp_mutex);
 		graph_head = (list_type == FLK_ACTIVE_STATE) ?
-			ACTIVE_HEAD(gp) : SLEEPING_HEAD(gp);
+		    ACTIVE_HEAD(gp) : SLEEPING_HEAD(gp);
 		for (lock = graph_head->l_next;
 		    lock != graph_head;
 		    lock = lock->l_next) {
@@ -3362,7 +3417,7 @@
 flk_get_sleeping_locks(int sysid, pid_t pid)
 {
 	return (get_lock_list(FLK_SLEEPING_STATE, 0, sysid, B_TRUE, pid, NULL,
-		    ALL_ZONES));
+	    ALL_ZONES));
 }
 
 locklist_t *
@@ -3369,7 +3424,7 @@
 flk_get_active_locks(int sysid, pid_t pid)
 {
 	return (get_lock_list(FLK_ACTIVE_STATE, 0, sysid, B_TRUE, pid, NULL,
-		    ALL_ZONES));
+	    ALL_ZONES));
 }
 
 /*
@@ -3386,7 +3441,7 @@
 flk_active_locks_for_vp(const vnode_t *vp)
 {
 	return (get_lock_list(FLK_ACTIVE_STATE, 0, 0, B_FALSE, NOPID, vp,
-		    ALL_ZONES));
+	    ALL_ZONES));
 }
 
 /*
@@ -3400,7 +3455,7 @@
 flk_active_nbmand_locks_for_vp(const vnode_t *vp)
 {
 	return (get_lock_list(FLK_ACTIVE_STATE, NBMAND_LOCK, 0, B_FALSE,
-				NOPID, vp, ALL_ZONES));
+	    NOPID, vp, ALL_ZONES));
 }
 
 /*
@@ -3417,7 +3472,7 @@
 flk_active_nbmand_locks(pid_t pid)
 {
 	return (get_lock_list(FLK_ACTIVE_STATE, NBMAND_LOCK, 0, B_FALSE,
-				pid, NULL, ALL_ZONES));
+	    pid, NULL, ALL_ZONES));
 }
 
 /*
@@ -3546,10 +3601,10 @@
 			if (IS_LOCKMGR(lock)) {
 				/* get NLM id */
 				lock_nlmid =
-					GETNLMID(lock->l_flock.l_sysid);
+				    GETNLMID(lock->l_flock.l_sysid);
 				if (nlmid == lock_nlmid) {
 					SET_NLM_STATE(lock,
-						FLK_NLM_SHUTTING_DOWN);
+					    FLK_NLM_SHUTTING_DOWN);
 					INTERRUPT_WAKEUP(lock);
 				}
 			}
@@ -3722,7 +3777,7 @@
 	flp->l_whence = 0;
 	flp->l_start = lp->l_start;
 	flp->l_len = (lp->l_end == MAX_U_OFFSET_T) ? 0 :
-		(lp->l_end - lp->l_start + 1);
+	    (lp->l_end - lp->l_start + 1);
 	flp->l_sysid = lp->l_flock.l_sysid;
 	flp->l_pid = lp->l_flock.l_pid;
 }
@@ -3803,7 +3858,7 @@
 		return (EINVAL);
 	}
 	if (start > end) {
-	    return (EINVAL);
+		return (EINVAL);
 	}
 	return (0);
 }
@@ -3853,7 +3908,7 @@
 				flrp->l_len = 0;
 			else
 				flrp->l_len = blocker->l_end -
-					blocker->l_start + 1;
+				    blocker->l_start + 1;
 		}
 	}
 }
@@ -3929,7 +3984,7 @@
 		    (lock->l_flock.l_sysid != sysid ||
 		    lock->l_flock.l_pid != pid) &&
 		    lock_blocks_io(op, offset, length,
-				lock->l_type, lock->l_start, lock->l_end)) {
+		    lock->l_type, lock->l_start, lock->l_end)) {
 			conflict = 1;
 			break;
 		}
@@ -3969,7 +4024,7 @@
 	edge_t	*ep;
 
 	for (lock = ACTIVE_HEAD(gp)->l_next; lock != ACTIVE_HEAD(gp);
-						lock = lock->l_next) {
+	    lock = lock->l_next) {
 		ASSERT(IS_ACTIVE(lock));
 		ASSERT(NOT_BLOCKED(lock));
 		ASSERT(!IS_BARRIER(lock));
@@ -3983,7 +4038,7 @@
 		}
 
 		for (lock1 = lock->l_next; lock1 != ACTIVE_HEAD(gp);
-					lock1 = lock1->l_next) {
+		    lock1 = lock1->l_next) {
 			if (lock1->l_vnode == lock->l_vnode) {
 			if (BLOCKS(lock1, lock)) {
 				cmn_err(CE_PANIC,
@@ -4078,10 +4133,10 @@
 	lock_descriptor_t *lock1, *lock2;
 	edge_t *ep;
 	for (lock1 = SLEEPING_HEAD(gp)->l_next; lock1 != SLEEPING_HEAD(gp);
-				lock1 = lock1->l_next) {
+	    lock1 = lock1->l_next) {
 				ASSERT(!IS_BARRIER(lock1));
 	for (lock2 = lock1->l_next; lock2 != SLEEPING_HEAD(gp);
-				lock2 = lock2->l_next) {
+	    lock2 = lock2->l_next) {
 		if (lock1->l_vnode == lock2->l_vnode) {
 			if (BLOCKS(lock2, lock1)) {
 				ASSERT(!IS_GRANTED(lock1));
@@ -4092,7 +4147,7 @@
 	}
 
 	for (lock2 = ACTIVE_HEAD(gp)->l_next; lock2 != ACTIVE_HEAD(gp);
-					lock2 = lock2->l_next) {
+	    lock2 = lock2->l_next) {
 				ASSERT(!IS_BARRIER(lock1));
 		if (lock1->l_vnode == lock2->l_vnode) {
 			if (BLOCKS(lock2, lock1)) {
@@ -4133,7 +4188,7 @@
 	while ((vertex = STACK_TOP(vertex_stack)) != NULL) {
 		STACK_POP(vertex_stack, l_dstack);
 		for (ep = FIRST_ADJ(vertex); ep != HEAD(vertex);
-						ep = NEXT_ADJ(ep)) {
+		    ep = NEXT_ADJ(ep)) {
 			if (COLORED(ep->to_vertex))
 				continue;
 			COLOR(ep->to_vertex);
