FreeBSD/sys/nlm/nlm_prot_impl.c
/*
 * This is called when we receive a host state change notification. We
 * unlock any active locks owned by the host. When rpc.lockd is
 * shutting down, this function is called with newstate set to zero
 * which allows us to cancel any pending async locks and clear the
 * locking state.
 */
This is called when we receive a host state change notification. We
unlock any active locks owned by the host. When rpc.lockd is
shutting down, this function is called with newstate set to zero
which allows us to cancel any pending async locks and clear the
locking state.
This is called when we receive a host state change notification . We unlock any active locks owned by the host . When rpc . lockd is shutting down this function is called with newstate set to zero which allows us to cancel any pending async locks and clear the locking state .
static void
nlm_host_notify(struct nlm_host *host, int newstate)
{
	struct nlm_async_lock *af;
	if (newstate) {
		NLM_DEBUG(1, "NLM: host %s (sysid %d) rebooted, new "
		    "state is %d\n", host->nh_caller_name,
		    host->nh_sysid, newstate);
	}
	mtx_lock(&host->nh_lock);
	while ((af = TAILQ_FIRST(&host->nh_pending)) != NULL) {
		nlm_cancel_async_lock(af);
	}
	mtx_unlock(&host->nh_lock);
	nlm_check_expired_locks(host);
	lf_clearremotesys(host->nh_sysid);
	host->nh_state = newstate;
	if (newstate != 0
	    && host->nh_monstate != NLM_RECOVERING
	    && lf_countlocks(NLM_SYSID_CLIENT | host->nh_sysid) > 0) {
		struct thread *td;
		host->nh_monstate = NLM_RECOVERING;
		refcount_acquire(&host->nh_refs);
		kthread_add(nlm_client_recovery_start, host, curproc, &td, 0, 0,
		    "NFS lock recovery for %s", host->nh_caller_name);
	}
}
static void nlm_host_notify ( struct nlm_host * host , int newstate ) { struct nlm_async_lock * af ; if ( newstate ) { NLM_DEBUG ( 1 , " " " \n " , host -> nh_caller_name , host -> nh_sysid , newstate ) ; } mtx_lock ( & host -> nh_lock ) ; while ( ( af = TAILQ_FIRST ( & host -> nh_pending ) ) != NULL ) { nlm_cancel_async_lock ( af ) ; } mtx_unlock ( & host -> nh_lock ) ; nlm_check_expired_locks ( host ) ; lf_clearremotesys ( host -> nh_sysid ) ; host -> nh_state = newstate ; if ( newstate != 0 && host -> nh_monstate != NLM_RECOVERING && lf_countlocks ( NLM_SYSID_CLIENT | host -> nh_sysid ) > 0 ) { struct thread * td ; host -> nh_monstate = NLM_RECOVERING ; refcount_acquire ( & host -> nh_refs ) ; kthread_add ( nlm_client_recovery_start , host , curproc , & td , 0 , 0 , " " , host -> nh_caller_name ) ; } }
This is called when we receive a host state change notification.
This is called when we receive a host state change notification .
/*
	 * Cancel any pending async locks for this host.
	 */ /*
		 * nlm_cancel_async_lock will remove the entry from
		 * nh_pending and free it.
		 */ /*
	 * The host just rebooted - trash its locks.
	 */ /*
	 * If we have any remote locks for this host (i.e. it
	 * represents a remote NFS server that our local NFS client
	 * has locks for), start a recovery thread.
	 */