changeset 4738:3dd9c8466c6c

6485851 Jurassic panic with assertion failure in rfs4_dbe_rele
author rg137905
date Thu, 26 Jul 2007 21:58:32 -0700
parents 56a3be29f72c
children a180424b7664
files usr/src/uts/common/fs/nfs/nfs4_srv_deleg.c usr/src/uts/common/fs/nfs/nfs4_state.c
diffstat 2 files changed, 272 insertions(+), 320 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/fs/nfs/nfs4_srv_deleg.c	Thu Jul 26 09:59:54 2007 -0700
+++ b/usr/src/uts/common/fs/nfs/nfs4_srv_deleg.c	Thu Jul 26 21:58:32 2007 -0700
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -40,7 +40,7 @@
 #include <sys/ddi.h>
 
 #include <sys/vnode.h>
-
+#include <sys/sdt.h>
 #include <inet/common.h>
 #include <inet/ip.h>
 #include <inet/ip6.h>
@@ -122,7 +122,7 @@
 				/* reset to network order */
 				if (af == AF_INET) {
 					*(uint32_t *)ap =
-						htonl(*(uint32_t *)ap);
+					    htonl(*(uint32_t *)ap);
 					*pp = htons(port);
 				} else {
 					int ix;
@@ -220,12 +220,6 @@
 	rfs4_cbstate_t newstate;
 	rfs4_cbinfo_t *cbp = &cp->cbinfo;
 
-	if (cp == NULL) {
-		NFS4_DEBUG(rfs4_cb_debug, (CE_NOTE,
-			"rfs4_do_cb_null: no rfs4_client specified\n"));
-		return;
-	}
-
 	mutex_enter(cbp->cb_lock);
 	/* If another thread is doing CB_NULL RPC then return */
 	if (cbp->cb_nullcaller == TRUE) {
@@ -267,15 +261,15 @@
 
 		/* Move over the addr/netid */
 		cbp->cb_callback.cb_location.r_addr =
-			cbp->cb_newer.cb_callback.cb_location.r_addr;
+		    cbp->cb_newer.cb_callback.cb_location.r_addr;
 		cbp->cb_newer.cb_callback.cb_location.r_addr = NULL;
 		cbp->cb_callback.cb_location.r_netid =
-			cbp->cb_newer.cb_callback.cb_location.r_netid;
+		    cbp->cb_newer.cb_callback.cb_location.r_netid;
 		cbp->cb_newer.cb_callback.cb_location.r_netid = NULL;
 
 		/* Get the program number */
 		cbp->cb_callback.cb_program =
-			cbp->cb_newer.cb_callback.cb_program;
+		    cbp->cb_newer.cb_callback.cb_program;
 		cbp->cb_newer.cb_callback.cb_program = 0;
 
 		/* Don't forget the protocol's "cb_ident" field */
@@ -308,8 +302,6 @@
 
 	/* get/generate a client handle */
 	if ((ch = rfs4_cb_getch(cbp)) == NULL) {
-		NFS4_DEBUG(rfs4_cb_debug, (CE_NOTE,
-			"rfs4_do_cb_null: failed to get client handle\n"));
 		mutex_enter(cbp->cb_lock);
 		cbp->cb_state = CB_BAD;
 		cbp->cb_timefailed = gethrestime_sec(); /* observability */
@@ -320,9 +312,6 @@
 	tv.tv_sec = 30;
 	tv.tv_usec = 0;
 	if (clnt_call(ch, CB_NULL, xdr_void, NULL, xdr_void, NULL, tv) != 0) {
-		NFS4_DEBUG(rfs4_cb_debug, (CE_NOTE,
-			"rfs4_do_cb_null: clnt_call failed\n"));
-
 		newstate = CB_BAD;
 	} else {
 		newstate = CB_OK;
@@ -428,9 +417,9 @@
 	 * caller so they can do the CB_NULL
 	 */
 	if (cbp->cb_refcnt == 0 &&
-		cbp->cb_nullcaller == FALSE &&
-		cbp->cb_newer.cb_new == TRUE &&
-		cbp->cb_newer.cb_confirmed == TRUE)
+	    cbp->cb_nullcaller == FALSE &&
+	    cbp->cb_newer.cb_new == TRUE &&
+	    cbp->cb_newer.cb_confirmed == TRUE)
 		cb_new = TRUE;
 
 	mutex_exit(cbp->cb_lock);
@@ -453,15 +442,12 @@
 	in_port_t *pp;
 	int af;
 	char *devnam;
-	int err = 0;
+	int err;
 	struct netbuf nb;
 	int size;
 	CLIENT *ch = NULL;
 	int useresvport = 0;
 
-	NFS4_DEBUG(rfs4_cb_debug, (CE_NOTE,
-		"rfs4_cbch_init: entry cbp->%p\n", (void *)cbp));
-
 	mutex_enter(cbp->cb_lock);
 
 	if (cbp->cb_callback.cb_location.r_netid == NULL ||
@@ -476,47 +462,37 @@
 		devnam = "/dev/tcp";
 		af = AF_INET;
 	} else if (strcmp(cbp->cb_callback.cb_location.r_netid, "udp")
-		== 0) {
+	    == 0) {
 		knc.knc_semantics = NC_TPI_CLTS;
 		knc.knc_protofmly = "inet";
 		knc.knc_proto = "udp";
 		devnam = "/dev/udp";
 		af = AF_INET;
 	} else if (strcmp(cbp->cb_callback.cb_location.r_netid, "tcp6")
-		== 0) {
+	    == 0) {
 		knc.knc_semantics = NC_TPI_COTS;
 		knc.knc_protofmly = "inet6";
 		knc.knc_proto = "tcp";
 		devnam = "/dev/tcp6";
 		af = AF_INET6;
 	} else if (strcmp(cbp->cb_callback.cb_location.r_netid, "udp6")
-		== 0) {
+	    == 0) {
 		knc.knc_semantics = NC_TPI_CLTS;
 		knc.knc_protofmly = "inet6";
 		knc.knc_proto = "udp";
 		devnam = "/dev/udp6";
 		af = AF_INET6;
 	} else {
-		NFS4_DEBUG(rfs4_cb_debug, (CE_NOTE,
-			"rfs4_cbch_init: unknown transport %s\n",
-			cbp->cb_callback.cb_location.r_netid));
-
 		goto cb_init_out;
 	}
 
 	if ((err = lookupname(devnam, UIO_SYSSPACE, FOLLOW,
 	    NULLVPP, &vp)) != 0) {
 
-		NFS4_DEBUG(rfs4_cb_debug, (CE_NOTE,
-			"rfs4_cbch_init: lookupname failed %d\n", err));
-
 		goto cb_init_out;
 	}
 
 	if (vp->v_type != VCHR) {
-
-		NFS4_DEBUG(rfs4_cb_debug, (CE_NOTE,
-			"rfs4_cbch_init: %s is not VCHR", devnam));
 		VN_RELE(vp);
 		goto cb_init_out;
 	}
@@ -542,11 +518,7 @@
 	}
 
 	if (uaddr2sockaddr(af,
-		cbp->cb_callback.cb_location.r_addr, addr, pp)) {
-
-		NFS4_DEBUG(rfs4_cb_debug, (CE_NOTE,
-			"rfs4_cbch_init: malformed universal addr: %s\n",
-			cbp->cb_callback.cb_location.r_addr));
+	    cbp->cb_callback.cb_location.r_addr, addr, pp)) {
 
 		goto cb_init_out;
 	}
@@ -558,8 +530,6 @@
 	if (err = clnt_tli_kcreate(&knc, &nb, cbp->cb_callback.cb_program,
 	    NFS_CB, 0, 0, curthread->t_cred, &ch)) {
 
-		NFS4_DEBUG(rfs4_cb_debug, (CE_NOTE,
-			"rfs4_cbch_init: clnt_tli_kcreate failed %d\n", err));
 		ch = NULL;
 	}
 
@@ -580,10 +550,6 @@
 {
 	CLIENT *ch;
 
-	NFS4_DEBUG(rfs4_cb_debug, (CE_NOTE,
-		"rfs4_cb_flush: enter cbp->%p, cb_chc_free=%d\n",
-		(void *)cbp, cbp->cb_chc_free));
-
 	while (cbp->cb_chc_free) {
 		cbp->cb_chc_free--;
 		ch = cbp->cb_chc[cbp->cb_chc_free];
@@ -606,18 +572,11 @@
 	CLIENT *cbch = NULL;
 	uint32_t zilch = 0;
 
-	NFS4_DEBUG(rfs4_cb_debug, (CE_NOTE,
-		"rfs4_cb_getch: enter cbp->%p, cb_chc_free=%d\n",
-		(void *)cbp, cbp->cb_chc_free));
-
 	mutex_enter(cbp->cb_lock);
 
 	if (cbp->cb_chc_free) {
 		cbp->cb_chc_free--;
 		cbch = cbp->cb_chc[ cbp->cb_chc_free ];
-		NFS4_DEBUG(rfs4_cb_debug, (CE_NOTE,
-			"rfs4_cb_getch: cb_chc_free=%d ch->%p\n",
-			cbp->cb_chc_free, (void *)cbch));
 		mutex_exit(cbp->cb_lock);
 		(void) CLNT_CONTROL(cbch, CLSET_XID, (char *)&zilch);
 		return (cbch);
@@ -625,15 +584,9 @@
 
 	mutex_exit(cbp->cb_lock);
 
-	NFS4_DEBUG(rfs4_cb_debug, (CE_NOTE,
-		"rfs4_cb_getch: calling rfs4_cbch_init\n"));
-
 	/* none free so make it now */
 	cbch = rfs4_cbch_init(cbp);
 
-	NFS4_DEBUG(rfs4_cb_debug, (CE_NOTE,
-		"rfs4_cb_getch: returning cbch->%p\n", (void *)cbch));
-
 	return (cbch);
 }
 
@@ -651,18 +604,11 @@
 		cbp->cb_chc[ cbp->cb_chc_free++ ] = ch;
 		if (lockheld == FALSE)
 			mutex_exit(cbp->cb_lock);
-		NFS4_DEBUG(rfs4_cb_debug, (CE_NOTE,
-		    "rfs4_cb_freech: caching cbp->%p, ch->%p, cb_chc_free=%d\n",
-			(void *)cbp, (void *)ch, cbp->cb_chc_free));
 		return;
 	}
 	if (lockheld == FALSE)
 		mutex_exit(cbp->cb_lock);
 
-	NFS4_DEBUG(rfs4_cb_debug, (CE_NOTE,
-		"rfs4_cb_freech: destroying cbp->%p, ch->%p, cb_chc_free=%d\n",
-		(void *)cbp, (void *)ch, cbp->cb_chc_free));
-
 	/*
 	 * cache maxed out of free entries, obliterate
 	 * this client handle, destroy it, throw it away.
@@ -740,7 +686,7 @@
 	rfs4_dbe_hold(cp->dbe); /* hold the client struct for thread */
 
 	(void) thread_create(NULL, 0, rfs4_do_cb_null, cp, 0, &p0, TS_RUN,
-			    minclsyspri);
+	    minclsyspri);
 }
 
 static void
@@ -787,8 +733,6 @@
 			break;
 
 		default:
-			NFS4_DEBUG(rfs4_deleg_debug, (CE_NOTE,
-				"rfs4freeargres: unknown op"));
 			return;
 		}
 	}
@@ -816,9 +760,6 @@
 	res->tag.utf8string_val = NULL;
 	res->array = NULL;
 
-	NFS4_DEBUG(rfs4_cb_debug, (CE_NOTE,
-		"rfs4_do_callback: enter cp->%p\n", (void *)cp));
-
 retry:
 	cbp = rfs4_cbinfo_hold(cp);
 	if (cbp == NULL)
@@ -833,24 +774,20 @@
 		args->callback_ident = cbp->cb_ident;
 
 		stat = clnt_call(ch, CB_COMPOUND, xdr_CB_COMPOUND4args_srv,
-			(caddr_t)args, xdr_CB_COMPOUND4res,
-			(caddr_t)res, timeout);
+		    (caddr_t)args, xdr_CB_COMPOUND4res,
+		    (caddr_t)res, timeout);
 
 		/* free client handle */
 		rfs4_cb_freech(cbp, ch, FALSE);
 	}
 
-	NFS4_DEBUG(rfs4_cb_debug, (CE_NOTE,
-		"rfs4_do_callback: exit with RPC status %d, %s",
-		stat, clnt_sperrno(stat)));
-
 	/*
 	 * If the rele says that there may be new callback info then
 	 * retry this sequence and it may succeed as a result of the
 	 * new callback path
 	 */
 	if (rfs4_cbinfo_rele(cbp,
-		(stat == RPC_SUCCESS ? CB_NOCHANGE : CB_FAILED)) == TRUE)
+	    (stat == RPC_SUCCESS ? CB_NOCHANGE : CB_FAILED)) == TRUE)
 		goto retry;
 
 	return (stat);
@@ -909,7 +846,6 @@
 	nfs_fh4			*fhp;
 	enum clnt_stat		call_stat;
 
-	NFS4_DEBUG(rfs4_deleg_debug, (CE_NOTE, "rfs4_do_cb_recall: enter"));
 	/*
 	 * set up the compound args
 	 */
@@ -934,7 +870,7 @@
 
 	fhp = &dsp->finfo->filehandle;
 	rec_argp->fh.nfs_fh4_val = kmem_alloc(sizeof (char) *
-					    fhp->nfs_fh4_len, KM_SLEEP);
+	    fhp->nfs_fh4_len, KM_SLEEP);
 	nfs_fh4_copy(fhp, &rec_argp->fh);
 
 	/* Keep track of when we did this for observability */
@@ -947,14 +883,10 @@
 	timeout.tv_sec = (rfs4_lease_time * 80) / 100;
 	timeout.tv_usec = 0;
 
-	call_stat = rfs4_do_callback(dsp->client, &cb4_args,
-		&cb4_res, timeout);
+	call_stat = rfs4_do_callback(dsp->client, &cb4_args, &cb4_res, timeout);
 
 	if (call_stat != RPC_SUCCESS || cb4_res.status != NFS4_OK) {
 		rfs4_revoke_deleg(dsp);
-		NFS4_DEBUG(rfs4_deleg_debug, (CE_NOTE,
-			"rfs4_do_cb_recall: rpcstat=%d cbstat=%d ",
-			call_stat, cb4_res.status));
 	}
 
 	rfs4freeargres(&cb4_args, &cb4_res);
@@ -984,9 +916,10 @@
 	 * recall callback.
 	 */
 	if (dsp->dtype != OPEN_DELEGATE_NONE) {
-		NFS4_DEBUG(rfs4_deleg_debug,
-		    (CE_NOTE, "recall = %p, state = %p, fp = %p trunc = %d",
-		    (void*)arg->recall, (void*)dsp, (void*)fp, arg->trunc));
+		DTRACE_PROBE3(nfss__i__recall,
+		    struct recall_arg *, arg,
+		    struct rfs4_deleg_state_t *, dsp,
+		    struct rfs4_file_t *, fp);
 
 		if (arg->recall)
 			(void) (*arg->recall)(dsp, arg->trunc);
@@ -1030,34 +963,51 @@
 	int32_t recall_count;
 
 	rfs4_dbe_lock(fp->dbe);
-	/* Recall already in progress */
+
+	/* Recall already in progress ? */
+	mutex_enter(fp->dinfo->recall_lock);
 	if (fp->dinfo->recall_count != 0) {
+		mutex_exit(fp->dinfo->recall_lock);
 		rfs4_dbe_rele_nolock(fp->dbe);
 		rfs4_dbe_unlock(fp->dbe);
 		kmem_free(map, sizeof (struct master_recall_args));
 		return;
 	}
 
+	mutex_exit(fp->dinfo->recall_lock);
+
 	mutex_init(&cpr_lock, NULL, MUTEX_DEFAULT, NULL);
-	CALLB_CPR_INIT(&cpr_info, &cpr_lock, callb_generic_cpr,
-			"nfsv4RecallFile");
+	CALLB_CPR_INIT(&cpr_info, &cpr_lock, callb_generic_cpr,	"v4RecallFile");
 
 	recall_count = 0;
 	for (dsp = fp->delegationlist.next->dsp; dsp != NULL;
-		dsp = dsp->delegationlist.next->dsp) {
+	    dsp = dsp->delegationlist.next->dsp) {
+
+		rfs4_dbe_lock(dsp->dbe);
+		/*
+		 * if this delegation state
+		 * is being reaped skip it
+		 */
+		if (rfs4_dbe_is_invalid(dsp->dbe)) {
+			rfs4_dbe_unlock(dsp->dbe);
+			continue;
+		}
+
+		/* hold for receiving thread */
+		rfs4_dbe_hold(dsp->dbe);
+		rfs4_dbe_unlock(dsp->dbe);
+
 		arg = kmem_alloc(sizeof (struct recall_arg), KM_SLEEP);
 		arg->recall = map->recall;
 		arg->trunc = map->trunc;
-
-		rfs4_dbe_hold(dsp->dbe);	/* hold for receiving thread */
-
 		arg->dsp = dsp;
 
 		recall_count++;
 
 		(void) thread_create(NULL, 0, do_recall, arg, 0, &p0, TS_RUN,
-				    minclsyspri);
+		    minclsyspri);
 	}
+
 	rfs4_dbe_unlock(fp->dbe);
 
 	mutex_enter(fp->dinfo->recall_lock);
@@ -1073,8 +1023,7 @@
 
 	mutex_exit(fp->dinfo->recall_lock);
 
-	NFS4_DEBUG(rfs4_deleg_debug, (CE_NOTE, "Recall complete for %p",
-		    (void*)fp));
+	DTRACE_PROBE1(nfss__i__recall_done, rfs4_file_t *, fp);
 	rfs4_file_rele(fp);
 	kmem_free(map, sizeof (struct master_recall_args));
 	mutex_enter(&cpr_lock);
@@ -1116,7 +1065,7 @@
 	args->trunc = trunc;
 
 	(void) thread_create(NULL, 0, do_recall_file, args, 0, &p0, TS_RUN,
-			    minclsyspri);
+	    minclsyspri);
 }
 
 void
@@ -1129,7 +1078,7 @@
 		elapsed2 = gethrestime_sec() - fp->dinfo->time_lastwrite;
 		/* First check to see if a revocation should occur */
 		if (elapsed1 > rfs4_lease_time &&
-			elapsed2 > rfs4_lease_time) {
+		    elapsed2 > rfs4_lease_time) {
 			rfs4_revoke_file(fp);
 			return;
 		}
@@ -1219,7 +1168,7 @@
 		 * access to others, return a read delegation.
 		 */
 		if ((access & ~OPEN4_SHARE_ACCESS_WRITE) ||
-			(deny & ~OPEN4_SHARE_DENY_READ))
+		    (deny & ~OPEN4_SHARE_DENY_READ))
 			return (OPEN_DELEGATE_READ);
 
 		/* Shouldn't get here */
@@ -1234,7 +1183,7 @@
 		 */
 		if ((access & OPEN4_SHARE_ACCESS_WRITE) ||
 		    (deny & OPEN4_SHARE_DENY_READ))
-		    return (OPEN_DELEGATE_NONE);
+			return (OPEN_DELEGATE_NONE);
 		return (OPEN_DELEGATE_READ);
 
 	case OPEN_DELEGATE_WRITE:
@@ -1278,7 +1227,7 @@
 
 	/* Limit the number of read grants */
 	if (dtype == OPEN_DELEGATE_READ &&
-		dinfo->rdgrants > MAX_READ_DELEGATIONS)
+	    dinfo->rdgrants > MAX_READ_DELEGATIONS)
 		return (OPEN_DELEGATE_NONE);
 
 	/*
@@ -1319,8 +1268,6 @@
 
 	/* Don't grant a delegation if a deletion is impending. */
 	if (fp->dinfo->hold_grant > 0) {
-		NFS4_DEBUG(rfs4_deleg_debug,
-			(CE_NOTE, "rfs4_grant_delegation: hold_grant is set"));
 		return (NULL);
 	}
 
@@ -1337,8 +1284,6 @@
 	 * immediately recalled (if there's a conflict), so we're safe.
 	 */
 	if (lm_vp_active(fp->vp)) {
-		NFS4_DEBUG(rfs4_deleg_debug,
-		    (CE_NOTE, "rfs4_grant_delegation: NLM lock"));
 		return (NULL);
 	}
 
@@ -1398,10 +1343,8 @@
 		 * actual delegation.
 		 */
 		dtype = rfs4_delegation_policy(dtype, fp->dinfo,
-			sp->owner->client->clientid);
+		    sp->owner->client->clientid);
 
-		NFS4_DEBUG(rfs4_deleg_debug,
-			(CE_NOTE, "Grant policy dtype = %d", dtype));
 		if (dtype == OPEN_DELEGATE_NONE)
 			return (NULL);
 		break;
@@ -1565,7 +1508,7 @@
 		fp = rfs4_findfile(vp, NULL, &create);
 		if (fp != NULL) {
 			if (rfs4_check_delegated_byfp(mode, fp, trunc,
-						TRUE, FALSE, NULL)) {
+			    TRUE, FALSE, NULL)) {
 				rc = TRUE;
 			}
 			rfs4_file_rele(fp);
@@ -1612,8 +1555,8 @@
 
 	/* Shouldn't happen */
 	if (fp->dinfo->recall_count != 0 ||
-		(fp->dinfo->dtype == OPEN_DELEGATE_READ &&
-			dtype != OPEN_DELEGATE_READ)) {
+	    (fp->dinfo->dtype == OPEN_DELEGATE_READ &&
+	    dtype != OPEN_DELEGATE_READ)) {
 		return (NULL);
 	}
 
@@ -1655,9 +1598,9 @@
 	 * client
 	 */
 	if (fp->dinfo->recall_count != 0 ||
-		fp->dinfo->dtype == OPEN_DELEGATE_WRITE ||
-		(fp->dinfo->dtype == OPEN_DELEGATE_READ &&
-			dtype != OPEN_DELEGATE_READ)) {
+	    fp->dinfo->dtype == OPEN_DELEGATE_WRITE ||
+	    (fp->dinfo->dtype == OPEN_DELEGATE_READ &&
+	    dtype != OPEN_DELEGATE_READ)) {
 		rfs4_deleg_state_rele(dsp);
 		return (NULL);
 	}
@@ -1680,13 +1623,13 @@
 			}
 		}
 		(void) fem_install(vp, deleg_rdops, (void *)fp, OPUNIQ,
-				rfs4_mon_hold, rfs4_mon_rele);
+		    rfs4_mon_hold, rfs4_mon_rele);
 		if (vn_is_opened(vp, V_WRITE) || vn_is_mapped(vp, V_WRITE)) {
 			if (open_prev) {
 				*recall = 1;
 			} else {
 				(void) fem_uninstall(vp, deleg_rdops,
-						    (void *)fp);
+				    (void *)fp);
 				rfs4_deleg_state_rele(dsp);
 				return (NULL);
 			}
@@ -1701,13 +1644,13 @@
 			}
 		}
 		(void) fem_install(vp, deleg_wrops, (void *)fp, OPUNIQ,
-				rfs4_mon_hold, rfs4_mon_rele);
+		    rfs4_mon_hold, rfs4_mon_rele);
 		if (vn_is_opened(vp, V_RDORWR) || vn_is_mapped(vp, V_RDORWR)) {
 			if (open_prev) {
 				*recall = 1;
 			} else {
 				(void) fem_uninstall(vp, deleg_wrops,
-							(void *)fp);
+				    (void *)fp);
 				rfs4_deleg_state_rele(dsp);
 				return (NULL);
 			}
@@ -1747,7 +1690,7 @@
 
 	remque(&dsp->delegationlist);
 	dsp->delegationlist.next = dsp->delegationlist.prev =
-		&dsp->delegationlist;
+	    &dsp->delegationlist;
 
 	if (&fp->delegationlist == fp->delegationlist.next) {
 		dtypewas = fp->dinfo->dtype;
@@ -1758,10 +1701,10 @@
 		if (fp->vp != NULL) {
 			if (dtypewas == OPEN_DELEGATE_READ)
 				(void) fem_uninstall(fp->vp, deleg_rdops,
-						(void *)fp);
+				    (void *)fp);
 			else
 				(void) fem_uninstall(fp->vp, deleg_wrops,
-						(void *)fp);
+				    (void *)fp);
 		}
 	}
 
@@ -1825,8 +1768,8 @@
 	 * and locking the rfs4_file_t struct on init and end
 	 */
 	for (rfs4_dbe_lock(fp->dbe);
-		&fp->delegationlist != fp->delegationlist.next;
-		rfs4_dbe_lock(fp->dbe)) {
+	    &fp->delegationlist != fp->delegationlist.next;
+	    rfs4_dbe_lock(fp->dbe)) {
 
 		dsp = fp->delegationlist.next->dsp;
 		rfs4_dbe_hold(dsp->dbe);
@@ -1852,18 +1795,10 @@
 	rfs4_file_t *fp = state->finfo;
 	rfs4_client_t *cp = state->owner->client;
 
-	NFS4_DEBUG(rfs4_deleg_debug,
-		(CE_NOTE, "rfs4_is_deleg enter: cp = %p", (void*)cp));
-
 	ASSERT(rfs4_dbe_islocked(fp->dbe));
 	for (dsp = fp->delegationlist.next->dsp; dsp != NULL;
-		dsp = dsp->delegationlist.next->dsp) {
-		NFS4_DEBUG(rfs4_deleg_debug,
-			(CE_NOTE, "rfs4_is_deleg: client = %p",
-			(void*)dsp->client));
+	    dsp = dsp->delegationlist.next->dsp) {
 		if (cp != dsp->client) {
-			NFS4_DEBUG(rfs4_deleg_debug,
-				(CE_NOTE, "rfs4_is_deleg is true"));
 			return (TRUE);
 		}
 	}
--- a/usr/src/uts/common/fs/nfs/nfs4_state.c	Thu Jul 26 09:59:54 2007 -0700
+++ b/usr/src/uts/common/fs/nfs/nfs4_state.c	Thu Jul 26 21:58:32 2007 -0700
@@ -38,6 +38,7 @@
 #include <nfs/nfssys.h>
 #include <nfs/lm.h>
 #include <sys/pathname.h>
+#include <sys/sdt.h>
 #include <sys/nvpair.h>
 
 
@@ -170,7 +171,7 @@
 		break;
 	}
 	dacep->who.utf8string_val =
-		kmem_alloc(sacep->who.utf8string_len, KM_SLEEP);
+	    kmem_alloc(sacep->who.utf8string_len, KM_SLEEP);
 	bcopy(sacep->who.utf8string_val, dacep->who.utf8string_val,
 	    sacep->who.utf8string_len);
 }
@@ -222,11 +223,11 @@
 	switch (src->resop) {
 	case OP_LOCK:
 		deep_lock_copy(&dst->nfs_resop4_u.oplock,
-			    &src->nfs_resop4_u.oplock);
+		    &src->nfs_resop4_u.oplock);
 		break;
 	case OP_OPEN:
 		deep_open_copy(&dst->nfs_resop4_u.opopen,
-			    &src->nfs_resop4_u.opopen);
+		    &src->nfs_resop4_u.opopen);
 		break;
 	default:
 		break;
@@ -421,8 +422,8 @@
 	 * (account for the '/' and trailing null)
 	 */
 	if ((dir_len = strlen(dir)) > MAXPATHLEN ||
-		(leaf_len = strlen(leaf)) > MAXNAMELEN ||
-		(dir_len + leaf_len + 2) > MAXPATHLEN) {
+	    (leaf_len = strlen(leaf)) > MAXNAMELEN ||
+	    (dir_len + leaf_len + 2) > MAXPATHLEN) {
 		return (NULL);
 	}
 
@@ -514,7 +515,7 @@
 	err = VOP_GETATTR(vp, &va, 0, CRED());
 
 	kill_file = (va.va_size == 0 || va.va_size <
-		(NFS4_VERIFIER_SIZE + sizeof (uint_t)+1));
+	    (NFS4_VERIFIER_SIZE + sizeof (uint_t)+1));
 
 	if (err || kill_file) {
 		VOP_RWUNLOCK(vp, V_WRITELOCK_FALSE, NULL);
@@ -657,7 +658,7 @@
 		 * readdir chunk
 		 */
 		for (dep = (struct dirent64 *)dirt; size > 0;
-			dep = nextdp(dep)) {
+		    dep = nextdp(dep)) {
 
 			size -= dep->d_reclen;
 			dirchunk_offset = dep->d_off;
@@ -676,7 +677,7 @@
 				if (destdir != NULL) {
 					rfs4_ss_pnfree(ss_pn);
 					cl_ss->ss_pn = rfs4_ss_movestate(
-						statedir, destdir, dep->d_name);
+					    statedir, destdir, dep->d_name);
 				} else {
 					cl_ss->ss_pn = ss_pn;
 				}
@@ -865,7 +866,7 @@
 	while (osp != os_head) {
 		if (osp->cl_id4.id_len == cp->nfs_client.id_len) {
 			if (bcmp(osp->cl_id4.id_val, cp->nfs_client.id_val,
-					osp->cl_id4.id_len) == 0) {
+			    osp->cl_id4.id_len) == 0) {
 				cp->can_reclaim = 1;
 				break;
 			}
@@ -907,18 +908,18 @@
 	if (ca->sa_family == AF_INET) {
 
 		bcopy(svc_getrpccaller(req->rq_xprt)->buf, &cp->cl_addr,
-			sizeof (struct sockaddr_in));
+		    sizeof (struct sockaddr_in));
 		b = (uchar_t *)&((struct sockaddr_in *)ca)->sin_addr;
 		(void) sprintf(buf, "%03d.%03d.%03d.%03d", b[0] & 0xFF,
-				b[1] & 0xFF, b[2] & 0xFF, b[3] & 0xFF);
+		    b[1] & 0xFF, b[2] & 0xFF, b[3] & 0xFF);
 	} else if (ca->sa_family == AF_INET6) {
 		struct sockaddr_in6 *sin6;
 
 		sin6 = (struct sockaddr_in6 *)ca;
 		bcopy(svc_getrpccaller(req->rq_xprt)->buf, &cp->cl_addr,
-				sizeof (struct sockaddr_in6));
+		    sizeof (struct sockaddr_in6));
 		(void) kinet_ntop6((uchar_t *)&sin6->sin6_addr,
-				buf, INET6_ADDRSTRLEN);
+		    buf, INET6_ADDRSTRLEN);
 	}
 
 	(void) snprintf(leaf, MAXNAMELEN, "%s-%llx", buf,
@@ -993,7 +994,7 @@
 		return;
 
 	if (vn_open(ss_pn->pn, UIO_SYSSPACE, FCREAT|FWRITE, 0600, &vp,
-			    CRCREAT, 0)) {
+	    CRCREAT, 0)) {
 		rfs4_ss_pnfree(ss_pn);
 		return;
 	}
@@ -1035,7 +1036,7 @@
 	uio.uio_segflg = UIO_SYSSPACE;
 	uio.uio_llimit = (rlim64_t)MAXOFFSET_T;
 	uio.uio_resid = cl_id4->id_len + sizeof (int) +
-		NFS4_VERIFIER_SIZE + sizeof (uint_t);
+	    NFS4_VERIFIER_SIZE + sizeof (uint_t);
 
 	ioflag = uio.uio_fmode = (FWRITE|FSYNC);
 	uio.uio_extflg = UIO_COPY_DEFAULT;
@@ -1238,141 +1239,151 @@
 	/* Now create the individual tables */
 	rfs4_client_cache_time *= rfs4_lease_time;
 	rfs4_client_tab = rfs4_table_create(rfs4_server_state,
-					    "Client",
-					    rfs4_client_cache_time,
-					    2,
-					    rfs4_client_create,
-					    rfs4_client_destroy,
-					    rfs4_client_expiry,
-					    sizeof (rfs4_client_t),
-					    TABSIZE,
-					    MAXTABSZ/8, 100);
+	    "Client",
+	    rfs4_client_cache_time,
+	    2,
+	    rfs4_client_create,
+	    rfs4_client_destroy,
+	    rfs4_client_expiry,
+	    sizeof (rfs4_client_t),
+	    TABSIZE,
+	    MAXTABSZ/8, 100);
 	rfs4_nfsclnt_idx = rfs4_index_create(rfs4_client_tab,
-					    "nfs_client_id4", nfsclnt_hash,
-					    nfsclnt_compare, nfsclnt_mkkey,
-					    TRUE);
+	    "nfs_client_id4", nfsclnt_hash,
+	    nfsclnt_compare, nfsclnt_mkkey,
+	    TRUE);
 	rfs4_clientid_idx = rfs4_index_create(rfs4_client_tab,
-					    "client_id", clientid_hash,
-					    clientid_compare, clientid_mkkey,
-					    FALSE);
+	    "client_id", clientid_hash,
+	    clientid_compare, clientid_mkkey,
+	    FALSE);
 
 	rfs4_openowner_cache_time *= rfs4_lease_time;
 	rfs4_openowner_tab = rfs4_table_create(rfs4_server_state,
-					    "OpenOwner",
-					    rfs4_openowner_cache_time,
-					    1,
-					    rfs4_openowner_create,
-					    rfs4_openowner_destroy,
-					    rfs4_openowner_expiry,
-					    sizeof (rfs4_openowner_t),
-					    TABSIZE,
-					    MAXTABSZ, 100);
+	    "OpenOwner",
+	    rfs4_openowner_cache_time,
+	    1,
+	    rfs4_openowner_create,
+	    rfs4_openowner_destroy,
+	    rfs4_openowner_expiry,
+	    sizeof (rfs4_openowner_t),
+	    TABSIZE,
+	    MAXTABSZ, 100);
 	rfs4_openowner_idx = rfs4_index_create(rfs4_openowner_tab,
-					    "open_owner4", openowner_hash,
-					    openowner_compare,
-					    openowner_mkkey, TRUE);
+	    "open_owner4", openowner_hash,
+	    openowner_compare,
+	    openowner_mkkey, TRUE);
 
 	rfs4_state_cache_time *= rfs4_lease_time;
 	rfs4_state_tab = rfs4_table_create(rfs4_server_state,
-					"OpenStateID",
-					rfs4_state_cache_time,
-					3,
-					rfs4_state_create,
-					rfs4_state_destroy,
-					rfs4_state_expiry,
-					sizeof (rfs4_state_t),
-					TABSIZE,
-					MAXTABSZ, 100);
+	    "OpenStateID",
+	    rfs4_state_cache_time,
+	    3,
+	    rfs4_state_create,
+	    rfs4_state_destroy,
+	    rfs4_state_expiry,
+	    sizeof (rfs4_state_t),
+	    TABSIZE,
+	    MAXTABSZ, 100);
+
 	rfs4_state_owner_file_idx = rfs4_index_create(rfs4_state_tab,
-						"Openowner-File",
-						state_owner_file_hash,
-						state_owner_file_compare,
-						state_owner_file_mkkey, TRUE);
+	    "Openowner-File",
+	    state_owner_file_hash,
+	    state_owner_file_compare,
+	    state_owner_file_mkkey, TRUE);
+
 	rfs4_state_idx = rfs4_index_create(rfs4_state_tab,
-					"State-id", state_hash,
-					state_compare, state_mkkey, FALSE);
+	    "State-id", state_hash,
+	    state_compare, state_mkkey, FALSE);
+
 	rfs4_state_file_idx = rfs4_index_create(rfs4_state_tab,
-					"File", state_file_hash,
-					state_file_compare, state_file_mkkey,
-					FALSE);
+	    "File", state_file_hash,
+	    state_file_compare, state_file_mkkey,
+	    FALSE);
 
 	rfs4_lo_state_cache_time *= rfs4_lease_time;
 	rfs4_lo_state_tab = rfs4_table_create(rfs4_server_state,
-					    "LockStateID",
-					    rfs4_lo_state_cache_time,
-					    2,
-					    rfs4_lo_state_create,
-					    rfs4_lo_state_destroy,
-					    rfs4_lo_state_expiry,
-					    sizeof (rfs4_lo_state_t),
-					    TABSIZE,
-					    MAXTABSZ, 100);
+	    "LockStateID",
+	    rfs4_lo_state_cache_time,
+	    2,
+	    rfs4_lo_state_create,
+	    rfs4_lo_state_destroy,
+	    rfs4_lo_state_expiry,
+	    sizeof (rfs4_lo_state_t),
+	    TABSIZE,
+	    MAXTABSZ, 100);
+
 	rfs4_lo_state_owner_idx = rfs4_index_create(rfs4_lo_state_tab,
-						    "lockownerxstate",
-						    lo_state_lo_hash,
-						    lo_state_lo_compare,
-						    lo_state_lo_mkkey, TRUE);
+	    "lockownerxstate",
+	    lo_state_lo_hash,
+	    lo_state_lo_compare,
+	    lo_state_lo_mkkey, TRUE);
+
 	rfs4_lo_state_idx = rfs4_index_create(rfs4_lo_state_tab,
-					    "State-id",
-					    lo_state_hash, lo_state_compare,
-					    lo_state_mkkey, FALSE);
+	    "State-id",
+	    lo_state_hash, lo_state_compare,
+	    lo_state_mkkey, FALSE);
 
 	rfs4_lockowner_cache_time *= rfs4_lease_time;
+
 	rfs4_lockowner_tab = rfs4_table_create(rfs4_server_state,
-					    "Lockowner",
-					    rfs4_lockowner_cache_time,
-					    2,
-					    rfs4_lockowner_create,
-					    rfs4_lockowner_destroy,
-					    rfs4_lockowner_expiry,
-					    sizeof (rfs4_lockowner_t),
-					    TABSIZE,
-					    MAXTABSZ, 100);
+	    "Lockowner",
+	    rfs4_lockowner_cache_time,
+	    2,
+	    rfs4_lockowner_create,
+	    rfs4_lockowner_destroy,
+	    rfs4_lockowner_expiry,
+	    sizeof (rfs4_lockowner_t),
+	    TABSIZE,
+	    MAXTABSZ, 100);
+
 	rfs4_lockowner_idx = rfs4_index_create(rfs4_lockowner_tab,
-					    "lock_owner4", lockowner_hash,
-					    lockowner_compare,
-					    lockowner_mkkey, TRUE);
+	    "lock_owner4", lockowner_hash,
+	    lockowner_compare,
+	    lockowner_mkkey, TRUE);
+
 	rfs4_lockowner_pid_idx = rfs4_index_create(rfs4_lockowner_tab,
-						"pid", pid_hash,
-						pid_compare, pid_mkkey,
-						FALSE);
+	    "pid", pid_hash,
+	    pid_compare, pid_mkkey,
+	    FALSE);
 
 	rfs4_file_cache_time *= rfs4_lease_time;
 	rfs4_file_tab = rfs4_table_create(rfs4_server_state,
-					"File",
-					rfs4_file_cache_time,
-					1,
-					rfs4_file_create,
-					rfs4_file_destroy,
-					NULL,
-					sizeof (rfs4_file_t),
-					TABSIZE,
-					MAXTABSZ, -1);
+	    "File",
+	    rfs4_file_cache_time,
+	    1,
+	    rfs4_file_create,
+	    rfs4_file_destroy,
+	    NULL,
+	    sizeof (rfs4_file_t),
+	    TABSIZE,
+	    MAXTABSZ, -1);
+
 	rfs4_file_idx = rfs4_index_create(rfs4_file_tab,
-					"Filehandle", file_hash,
-					file_compare, file_mkkey, TRUE);
+	    "Filehandle", file_hash,
+	    file_compare, file_mkkey, TRUE);
 
 	rfs4_deleg_state_cache_time *= rfs4_lease_time;
 	rfs4_deleg_state_tab = rfs4_table_create(rfs4_server_state,
-					"DelegStateID",
-					rfs4_deleg_state_cache_time,
-					2,
-					rfs4_deleg_state_create,
-					rfs4_deleg_state_destroy,
-					rfs4_deleg_state_expiry,
-					sizeof (rfs4_deleg_state_t),
-					TABSIZE,
-					MAXTABSZ, 100);
+	    "DelegStateID",
+	    rfs4_deleg_state_cache_time,
+	    2,
+	    rfs4_deleg_state_create,
+	    rfs4_deleg_state_destroy,
+	    rfs4_deleg_state_expiry,
+	    sizeof (rfs4_deleg_state_t),
+	    TABSIZE,
+	    MAXTABSZ, 100);
 	rfs4_deleg_idx = rfs4_index_create(rfs4_deleg_state_tab,
-						"DelegByFileClient",
-						deleg_hash,
-						deleg_compare,
-						deleg_mkkey, TRUE);
+	    "DelegByFileClient",
+	    deleg_hash,
+	    deleg_compare,
+	    deleg_mkkey, TRUE);
+
 	rfs4_deleg_state_idx = rfs4_index_create(rfs4_deleg_state_tab,
-						"DelegState",
-						deleg_state_hash,
-						deleg_state_compare,
-						deleg_state_mkkey, FALSE);
+	    "DelegState",
+	    deleg_state_hash,
+	    deleg_state_compare,
+	    deleg_state_mkkey, FALSE);
 
 	/*
 	 * Init the stable storage.
@@ -1517,7 +1528,7 @@
 		return (FALSE);
 
 	return (bcmp(client->nfs_client.id_val, nfs_client->id_val,
-						nfs_client->id_len) == 0);
+	    nfs_client->id_len) == 0);
 }
 
 static void *
@@ -1543,8 +1554,8 @@
 	 * has exceeded its lease period.
 	 */
 	cp_expired = (cp->forced_expire ||
-		(gethrestime_sec() - cp->last_access
-			> rfs4_lease_time));
+	    (gethrestime_sec() - cp->last_access
+	    > rfs4_lease_time));
 
 	if (!cp->ss_remove && cp_expired)
 		cp->ss_remove = 1;
@@ -1667,7 +1678,7 @@
 	cp->sysidt = LM_NOSYSID;
 
 	cp->clientdeleglist.next = cp->clientdeleglist.prev =
-		&cp->clientdeleglist;
+	    &cp->clientdeleglist;
 	cp->clientdeleglist.dsp = NULL;
 
 	/* set up the callback control structure */
@@ -1723,7 +1734,7 @@
 	}
 
 	cp = (rfs4_client_t *)rfs4_dbsearch(rfs4_nfsclnt_idx, client,
-					create, (void *)client, RFS4_DBS_VALID);
+	    create, (void *)client, RFS4_DBS_VALID);
 
 	if (oldcp)
 		rfs4_dbe_unhide(oldcp->dbe);
@@ -1747,7 +1758,7 @@
 	rw_enter(&rfs4_findclient_lock, RW_READER);
 
 	cp = (rfs4_client_t *)rfs4_dbsearch(rfs4_clientid_idx, &clientid,
-					&create, NULL, RFS4_DBS_VALID);
+	    &create, NULL, RFS4_DBS_VALID);
 
 	rw_exit(&rfs4_findclient_lock);
 
@@ -1858,7 +1869,7 @@
 	if (rfs4_dbe_is_invalid(op->dbe))
 		return (TRUE);
 	return ((gethrestime_sec() - op->client->last_access
-		> rfs4_lease_time));
+	    > rfs4_lease_time));
 }
 
 static void
@@ -1912,8 +1923,8 @@
 	rw_enter(&rfs4_findclient_lock, RW_READER);
 
 	cp = (rfs4_client_t *)rfs4_dbsearch(rfs4_clientid_idx,
-					&openowner->clientid,
-					&create, NULL, RFS4_DBS_VALID);
+	    &openowner->clientid,
+	    &create, NULL, RFS4_DBS_VALID);
 
 	rw_exit(&rfs4_findclient_lock);
 
@@ -1925,9 +1936,11 @@
 
 	op->owner.clientid = openowner->clientid;
 	op->owner.owner_val =
-		kmem_alloc(openowner->owner_len, KM_SLEEP);
+	    kmem_alloc(openowner->owner_len, KM_SLEEP);
+
 	bcopy(openowner->owner_val,
 	    op->owner.owner_val, openowner->owner_len);
+
 	op->owner.owner_len = openowner->owner_len;
 
 	op->need_confirm = TRUE;
@@ -1963,7 +1976,7 @@
 	arg.owner = *openowner;
 	arg.open_seqid = seqid;
 	op = (rfs4_openowner_t *)rfs4_dbsearch(rfs4_openowner_idx, openowner,
-					    create, &arg, RFS4_DBS_VALID);
+	    create, &arg, RFS4_DBS_VALID);
 
 	return (op);
 }
@@ -1994,12 +2007,12 @@
 	    fh && fh->nfs_fh4_len) {
 		if (op->reply_fh.nfs_fh4_val == NULL)
 			op->reply_fh.nfs_fh4_val =
-				kmem_alloc(fh->nfs_fh4_len, KM_SLEEP);
+			    kmem_alloc(fh->nfs_fh4_len, KM_SLEEP);
 		nfs_fh4_copy(fh, &op->reply_fh);
 	} else {
 		if (op->reply_fh.nfs_fh4_val) {
 			kmem_free(op->reply_fh.nfs_fh4_val,
-				op->reply_fh.nfs_fh4_len);
+			    op->reply_fh.nfs_fh4_len);
 			op->reply_fh.nfs_fh4_val = NULL;
 			op->reply_fh.nfs_fh4_len = 0;
 		}
@@ -2021,7 +2034,7 @@
 		return (FALSE);
 
 	return (bcmp(lo->owner.owner_val, b->owner_val,
-					lo->owner.owner_len) == 0);
+	    lo->owner.owner_len) == 0);
 }
 
 void *
@@ -2109,8 +2122,8 @@
 	rw_enter(&rfs4_findclient_lock, RW_READER);
 
 	cp = (rfs4_client_t *)rfs4_dbsearch(rfs4_clientid_idx,
-					&lockowner->clientid,
-					&create, NULL, RFS4_DBS_VALID);
+	    &lockowner->clientid,
+	    &create, NULL, RFS4_DBS_VALID);
 
 	rw_exit(&rfs4_findclient_lock);
 
@@ -2134,7 +2147,7 @@
 	rfs4_lockowner_t *lo;
 
 	lo = (rfs4_lockowner_t *)rfs4_dbsearch(rfs4_lockowner_idx, lockowner,
-					    create, lockowner, RFS4_DBS_VALID);
+	    create, lockowner, RFS4_DBS_VALID);
 
 	return (lo);
 }
@@ -2146,7 +2159,7 @@
 	bool_t create = FALSE;
 
 	lo = (rfs4_lockowner_t *)rfs4_dbsearch(rfs4_lockowner_pid_idx,
-		(void *)(uintptr_t)pid, &create, NULL, RFS4_DBS_VALID);
+	    (void *)(uintptr_t)pid, &create, NULL, RFS4_DBS_VALID);
 
 	return (lo);
 }
@@ -2182,7 +2195,7 @@
 	ASSERT(fp->delegationlist.next == &fp->delegationlist);
 	if (fp->filehandle.nfs_fh4_val)
 		kmem_free(fp->filehandle.nfs_fh4_val,
-			fp->filehandle.nfs_fh4_len);
+		    fp->filehandle.nfs_fh4_len);
 	cv_destroy(fp->dinfo->recall_cv);
 	if (fp->vp) {
 		VN_RELE(fp->vp);
@@ -2231,14 +2244,14 @@
 	ASSERT(fh && fh->nfs_fh4_len);
 	if (fh && fh->nfs_fh4_len) {
 		fp->filehandle.nfs_fh4_val =
-			kmem_alloc(fh->nfs_fh4_len, KM_SLEEP);
+		    kmem_alloc(fh->nfs_fh4_len, KM_SLEEP);
 		nfs_fh4_copy(fh, &fp->filehandle);
 	}
 	fp->vp = vp;
 
 	/* Init list for remque/insque */
 	fp->delegationlist.next = fp->delegationlist.prev =
-		&fp->delegationlist;
+	    &fp->delegationlist;
 	fp->delegationlist.dsp = NULL; /* NULL since this is state list */
 
 	fp->share_deny = fp->share_access = fp->access_read = 0;
@@ -2264,7 +2277,7 @@
 	arg.fh = fh;
 
 	fp = (rfs4_file_t *)rfs4_dbsearch(rfs4_file_idx, vp, create,
-					&arg, RFS4_DBS_VALID);
+	    &arg, RFS4_DBS_VALID);
 	return (fp);
 }
 
@@ -2288,7 +2301,7 @@
 	arg.fh = fh;
 
 	fp = (rfs4_file_t *)rfs4_dbsearch(rfs4_file_idx, vp, create,
-					&arg, RFS4_DBS_VALID);
+	    &arg, RFS4_DBS_VALID);
 	if (fp != NULL) {
 		rw_enter(&fp->file_rwlock, RW_WRITER);
 		if (fp->vp == NULL) {
@@ -2343,7 +2356,7 @@
 	if (lsp->state->closed)
 		return (TRUE);
 	return ((gethrestime_sec() - lsp->state->owner->client->last_access
-		> rfs4_lease_time));
+	    > rfs4_lease_time));
 }
 
 static void
@@ -2369,9 +2382,8 @@
 				 * This PxFS routine removes file locks for a
 				 * client over all nodes of a cluster.
 				 */
-				NFS4_DEBUG(rfs4_debug, (CE_NOTE,
-				    "lm_remove_file_locks(sysid=0x%x)\n",
-				    new_sysid));
+				DTRACE_PROBE1(nfss_i_clust_rm_lck,
+				    int, new_sysid);
 				(*lm_remove_file_locks)(new_sysid);
 			} else {
 				(void) cleanlocks(lsp->state->finfo->vp,
@@ -2385,7 +2397,7 @@
 
 	remque(&lsp->lockownerlist);
 	lsp->lockownerlist.next = lsp->lockownerlist.prev =
-		&lsp->lockownerlist;
+	    &lsp->lockownerlist;
 
 	rfs4_dbe_unlock(lsp->state->dbe);
 
@@ -2424,7 +2436,7 @@
 	lsp->locker = lo;
 
 	lsp->lockownerlist.next = lsp->lockownerlist.prev =
-		&lsp->lockownerlist;
+	    &lsp->lockownerlist;
 	lsp->lockownerlist.lsp = lsp;
 
 	rfs4_dbe_lock(sp->dbe);
@@ -2453,7 +2465,7 @@
 	bool_t create = FALSE;
 
 	lsp = (rfs4_lo_state_t *)rfs4_dbsearch(rfs4_lo_state_idx, id,
-					    &create, NULL, RFS4_DBS_VALID);
+	    &create, NULL, RFS4_DBS_VALID);
 	if (lock_fp == TRUE && lsp != NULL)
 		rw_enter(&lsp->state->finfo->file_rwlock, RW_READER);
 
@@ -2495,7 +2507,7 @@
 	arg.state = sp;
 
 	lsp = (rfs4_lo_state_t *)rfs4_dbsearch(rfs4_lo_state_owner_idx, &arg,
-					    create, &arg, RFS4_DBS_VALID);
+	    create, &arg, RFS4_DBS_VALID);
 
 	return (lsp);
 }
@@ -2701,9 +2713,14 @@
 
 	if (rfs4_dbe_is_invalid(dsp->dbe))
 		return (TRUE);
-	return ((gethrestime_sec() - dsp->client->last_access
-		> rfs4_lease_time));
-
+
+	if ((gethrestime_sec() - dsp->client->last_access
+	    > rfs4_lease_time)) {
+		rfs4_dbe_invalidate(dsp->dbe);
+		return (TRUE);
+	}
+
+	return (FALSE);
 }
 
 static bool_t
@@ -2727,11 +2744,11 @@
 
 	/* Init lists for remque/insque */
 	dsp->delegationlist.next = dsp->delegationlist.prev =
-		&dsp->delegationlist;
+	    &dsp->delegationlist;
 	dsp->delegationlist.dsp = dsp;
 
 	dsp->clientdeleglist.next = dsp->clientdeleglist.prev =
-		&dsp->clientdeleglist;
+	    &dsp->clientdeleglist;
 	dsp->clientdeleglist.dsp = dsp;
 
 	/* Insert state on per open owner's list */
@@ -2761,7 +2778,7 @@
 
 	remque(&dsp->clientdeleglist);
 	dsp->clientdeleglist.next = dsp->clientdeleglist.prev =
-		&dsp->clientdeleglist;
+	    &dsp->clientdeleglist;
 
 	rfs4_dbe_unlock(dsp->client->dbe);
 
@@ -2778,7 +2795,7 @@
 	ds.finfo = sp->finfo;
 
 	dsp = (rfs4_deleg_state_t *)rfs4_dbsearch(rfs4_deleg_idx, &ds,
-					create, &ds, RFS4_DBS_VALID);
+	    create, &ds, RFS4_DBS_VALID);
 
 	return (dsp);
 }
@@ -2790,7 +2807,7 @@
 	bool_t create = FALSE;
 
 	dsp = (rfs4_deleg_state_t *)rfs4_dbsearch(rfs4_deleg_state_idx, id,
-					&create, NULL, RFS4_DBS_VALID);
+	    &create, NULL, RFS4_DBS_VALID);
 
 	return (dsp);
 }
@@ -2841,7 +2858,7 @@
 	rfs4_dbe_lock(op->dbe);
 
 	for (sp = op->ownerstateids.next->sp; sp != NULL;
-		sp = sp->ownerstateids.next->sp) {
+	    sp = sp->ownerstateids.next->sp) {
 		rfs4_state_close(sp, FALSE, close_of_client, CRED());
 		if (invalidate == TRUE)
 			rfs4_dbe_invalidate(sp->dbe);
@@ -2914,7 +2931,7 @@
 	key.finfo = file;
 
 	sp = (rfs4_state_t *)rfs4_dbsearch(rfs4_state_owner_file_idx, &key,
-					create, &key, RFS4_DBS_VALID);
+	    create, &key, RFS4_DBS_VALID);
 
 	return (sp);
 }
@@ -2926,7 +2943,7 @@
 	bool_t create = FALSE;
 
 	return ((rfs4_state_t *)rfs4_dbsearch(rfs4_state_file_idx, fp,
-		&create, fp, RFS4_DBS_VALID));
+	    &create, fp, RFS4_DBS_VALID));
 }
 
 static bool_t
@@ -2939,11 +2956,11 @@
 
 	if (sp->closed == TRUE &&
 	    ((gethrestime_sec() - rfs4_dbe_get_timerele(sp->dbe))
-		> rfs4_lease_time))
+	    > rfs4_lease_time))
 		return (TRUE);
 
 	return ((gethrestime_sec() - sp->owner->client->last_access
-		> rfs4_lease_time));
+	    > rfs4_lease_time));
 }
 
 static bool_t
@@ -2984,7 +3001,7 @@
 	bool_t create = FALSE;
 
 	sp = (rfs4_state_t *)rfs4_dbsearch(rfs4_state_idx, id,
-					&create, NULL, find_invalid);
+	    &create, NULL, find_invalid);
 	if (lock_fp == TRUE && sp != NULL)
 		rw_enter(&sp->finfo->file_rwlock, RW_READER);
 
@@ -3027,7 +3044,7 @@
 	rfs4_dbe_lock(cp->dbe);
 
 	for (oop = cp->openownerlist.next->oop;  oop != NULL;
-		oop = oop->openownerlist.next->oop) {
+	    oop = oop->openownerlist.next->oop) {
 		rfs4_free_opens(oop, TRUE, TRUE);
 	}
 
@@ -3395,7 +3412,7 @@
 			return (NFS4_OK);
 		}
 		if (mode == FWRITE ||
-			fp->dinfo->dtype == OPEN_DELEGATE_WRITE) {
+		    fp->dinfo->dtype == OPEN_DELEGATE_WRITE) {
 			rfs4_recall_deleg(fp, trunc, NULL);
 			rfs4_file_rele(fp);
 			return (NFS4ERR_DELAY);
@@ -3417,7 +3434,7 @@
 			if (id->bits.type == LOCKID) {
 				/* Seqid in the future? - that's bad */
 				if (lsp->lockid.bits.chgseq <
-					id->bits.chgseq) {
+				    id->bits.chgseq) {
 					rfs4_lo_state_rele(lsp, FALSE);
 					if (sp != NULL)
 						rfs4_state_rele_nounlock(sp);
@@ -3425,7 +3442,7 @@
 				}
 				/* Seqid in the past? - that's old */
 				if (lsp->lockid.bits.chgseq >
-					id->bits.chgseq) {
+				    id->bits.chgseq) {
 					rfs4_lo_state_rele(lsp, FALSE);
 					if (sp != NULL)
 						rfs4_state_rele_nounlock(sp);
@@ -3452,13 +3469,13 @@
 			if (id->bits.type == OPENID) {
 				/* Seqid in the future? - that's bad */
 				if (sp->stateid.bits.chgseq <
-					id->bits.chgseq) {
+				    id->bits.chgseq) {
 					rfs4_state_rele_nounlock(sp);
 					return (NFS4ERR_BAD_STATEID);
 				}
 				/* Seqid in the past - that's old */
 				if (sp->stateid.bits.chgseq >
-					id->bits.chgseq) {
+				    id->bits.chgseq) {
 					rfs4_state_rele_nounlock(sp);
 					return (NFS4ERR_OLD_STATEID);
 				}
@@ -3508,9 +3525,9 @@
 			 * time to indicate that activity is present.
 			 */
 			if (sp->finfo->dinfo->dtype == OPEN_DELEGATE_WRITE &&
-				mode == FWRITE) {
+			    mode == FWRITE) {
 				sp->finfo->dinfo->time_lastwrite =
-					gethrestime_sec();
+				    gethrestime_sec();
 			}
 
 			rfs4_state_rele_nounlock(sp);
@@ -3550,9 +3567,9 @@
 			 * time to indicate that activity is present.
 			 */
 			if (dsp->finfo->dinfo->dtype == OPEN_DELEGATE_WRITE &&
-				mode == FWRITE) {
+			    mode == FWRITE) {
 				dsp->finfo->dinfo->time_lastwrite =
-					gethrestime_sec();
+				    gethrestime_sec();
 			}
 
 			/*
@@ -3657,11 +3674,11 @@
 	FH_TO_FMT4(efhp, exi_fhp);
 
 	finfo_fhp =
-		(nfs_fh4_fmt_t *)lsp->state->finfo->filehandle.nfs_fh4_val;
+	    (nfs_fh4_fmt_t *)lsp->state->finfo->filehandle.nfs_fh4_val;
 
 	if (EQFSID(&finfo_fhp->fh4_fsid, &exi_fhp->fh4_fsid) &&
 	    bcmp(&finfo_fhp->fh4_xdata, &exi_fhp->fh4_xdata,
-		exi_fhp->fh4_xlen) == 0) {
+	    exi_fhp->fh4_xlen) == 0) {
 		rfs4_state_close(lsp->state, FALSE, FALSE, CRED());
 		rfs4_dbe_invalidate(lsp->dbe);
 		rfs4_dbe_invalidate(lsp->state->dbe);
@@ -3691,11 +3708,11 @@
 	FH_TO_FMT4(efhp, exi_fhp);
 
 	finfo_fhp =
-		(nfs_fh4_fmt_t *)sp->finfo->filehandle.nfs_fh4_val;
+	    (nfs_fh4_fmt_t *)sp->finfo->filehandle.nfs_fh4_val;
 
 	if (EQFSID(&finfo_fhp->fh4_fsid, &exi_fhp->fh4_fsid) &&
 	    bcmp(&finfo_fhp->fh4_xdata, &exi_fhp->fh4_xdata,
-		exi_fhp->fh4_xlen) == 0) {
+	    exi_fhp->fh4_xlen) == 0) {
 		rfs4_state_close(sp, TRUE, FALSE, CRED());
 		rfs4_dbe_invalidate(sp->dbe);
 	}
@@ -3724,11 +3741,11 @@
 	FH_TO_FMT4(efhp, exi_fhp);
 
 	finfo_fhp =
-		(nfs_fh4_fmt_t *)dsp->finfo->filehandle.nfs_fh4_val;
+	    (nfs_fh4_fmt_t *)dsp->finfo->filehandle.nfs_fh4_val;
 
 	if (EQFSID(&finfo_fhp->fh4_fsid, &exi_fhp->fh4_fsid) &&
 	    bcmp(&finfo_fhp->fh4_xdata, &exi_fhp->fh4_xdata,
-		exi_fhp->fh4_xlen) == 0) {
+	    exi_fhp->fh4_xlen) == 0) {
 		rfs4_dbe_invalidate(dsp->dbe);
 	}
 }
@@ -3758,15 +3775,15 @@
 
 	if (EQFSID(&finfo_fhp->fh4_fsid, &exi_fhp->fh4_fsid) &&
 	    bcmp(&finfo_fhp->fh4_xdata, &exi_fhp->fh4_xdata,
-		exi_fhp->fh4_xlen) == 0) {
+	    exi_fhp->fh4_xlen) == 0) {
 		if (fp->vp) {
 			/* don't leak monitors */
 			if (fp->dinfo->dtype == OPEN_DELEGATE_READ)
 				(void) fem_uninstall(fp->vp, deleg_rdops,
-						(void *)fp);
+				    (void *)fp);
 			else if (fp->dinfo->dtype == OPEN_DELEGATE_WRITE)
 				(void) fem_uninstall(fp->vp, deleg_wrops,
-						(void *)fp);
+				    (void *)fp);
 			VN_RELE(fp->vp);
 			fp->vp = NULL;
 		}