Lines Matching refs:host
628 struct nlm_host *host = af->af_host; in nlm_cancel_async_lock() local
631 mtx_assert(&host->nh_lock, MA_OWNED); in nlm_cancel_async_lock()
633 mtx_unlock(&host->nh_lock); in nlm_cancel_async_lock()
646 mtx_lock(&host->nh_lock); in nlm_cancel_async_lock()
650 "cancelled\n", af, host->nh_caller_name, host->nh_sysid); in nlm_cancel_async_lock()
656 TAILQ_REMOVE(&host->nh_pending, af, af_link); in nlm_cancel_async_lock()
657 mtx_unlock(&host->nh_lock); in nlm_cancel_async_lock()
659 mtx_lock(&host->nh_lock); in nlm_cancel_async_lock()
666 nlm_check_expired_locks(struct nlm_host *host) in nlm_check_expired_locks() argument
671 mtx_lock(&host->nh_lock); in nlm_check_expired_locks()
672 while ((af = TAILQ_FIRST(&host->nh_granted)) != NULL in nlm_check_expired_locks()
678 TAILQ_REMOVE(&host->nh_granted, af, af_link); in nlm_check_expired_locks()
679 mtx_unlock(&host->nh_lock); in nlm_check_expired_locks()
681 mtx_lock(&host->nh_lock); in nlm_check_expired_locks()
683 while ((af = TAILQ_FIRST(&host->nh_finished)) != NULL) { in nlm_check_expired_locks()
684 TAILQ_REMOVE(&host->nh_finished, af, af_link); in nlm_check_expired_locks()
685 mtx_unlock(&host->nh_lock); in nlm_check_expired_locks()
687 mtx_lock(&host->nh_lock); in nlm_check_expired_locks()
689 mtx_unlock(&host->nh_lock); in nlm_check_expired_locks()
697 nlm_host_destroy(struct nlm_host *host) in nlm_host_destroy() argument
701 TAILQ_REMOVE(&nlm_hosts, host, nh_link); in nlm_host_destroy()
704 if (host->nh_srvrpc.nr_client) in nlm_host_destroy()
705 CLNT_RELEASE(host->nh_srvrpc.nr_client); in nlm_host_destroy()
706 if (host->nh_clntrpc.nr_client) in nlm_host_destroy()
707 CLNT_RELEASE(host->nh_clntrpc.nr_client); in nlm_host_destroy()
708 mtx_destroy(&host->nh_lock); in nlm_host_destroy()
709 sysctl_ctx_free(&host->nh_sysctl); in nlm_host_destroy()
710 free(host, M_NLM); in nlm_host_destroy()
719 struct nlm_host *host = (struct nlm_host *) arg; in nlm_client_recovery_start() local
722 host->nh_caller_name); in nlm_client_recovery_start()
724 nlm_client_recovery(host); in nlm_client_recovery_start()
727 host->nh_caller_name); in nlm_client_recovery_start()
729 host->nh_monstate = NLM_MONITORED; in nlm_client_recovery_start()
730 nlm_host_release(host); in nlm_client_recovery_start()
743 nlm_host_notify(struct nlm_host *host, int newstate) in nlm_host_notify() argument
749 "state is %d\n", host->nh_caller_name, in nlm_host_notify()
750 host->nh_sysid, newstate); in nlm_host_notify()
756 mtx_lock(&host->nh_lock); in nlm_host_notify()
757 while ((af = TAILQ_FIRST(&host->nh_pending)) != NULL) { in nlm_host_notify()
764 mtx_unlock(&host->nh_lock); in nlm_host_notify()
765 nlm_check_expired_locks(host); in nlm_host_notify()
770 lf_clearremotesys(host->nh_sysid); in nlm_host_notify()
771 host->nh_state = newstate; in nlm_host_notify()
779 && host->nh_monstate != NLM_RECOVERING in nlm_host_notify()
780 && lf_countlocks(NLM_SYSID_CLIENT | host->nh_sysid) > 0) { in nlm_host_notify()
782 host->nh_monstate = NLM_RECOVERING; in nlm_host_notify()
783 refcount_acquire(&host->nh_refs); in nlm_host_notify()
784 kthread_add(nlm_client_recovery_start, host, curproc, &td, 0, 0, in nlm_host_notify()
785 "NFS lock recovery for %s", host->nh_caller_name); in nlm_host_notify()
795 struct nlm_host *host; in nlm_host_lock_count_sysctl() local
798 host = oidp->oid_arg1; in nlm_host_lock_count_sysctl()
799 count = lf_countlocks(host->nh_sysid); in nlm_host_lock_count_sysctl()
809 struct nlm_host *host; in nlm_host_client_lock_count_sysctl() local
812 host = oidp->oid_arg1; in nlm_host_client_lock_count_sysctl()
813 count = lf_countlocks(NLM_SYSID_CLIENT | host->nh_sysid); in nlm_host_client_lock_count_sysctl()
823 struct nlm_host *host; in nlm_create_host() local
830 host = malloc(sizeof(struct nlm_host), M_NLM, M_NOWAIT|M_ZERO); in nlm_create_host()
831 if (!host) in nlm_create_host()
833 mtx_init(&host->nh_lock, "nh_lock", NULL, MTX_DEF); in nlm_create_host()
834 host->nh_refs = 1; in nlm_create_host()
835 strlcpy(host->nh_caller_name, caller_name, MAXNAMELEN); in nlm_create_host()
836 host->nh_sysid = nlm_next_sysid++; in nlm_create_host()
837 snprintf(host->nh_sysid_string, sizeof(host->nh_sysid_string), in nlm_create_host()
838 "%d", host->nh_sysid); in nlm_create_host()
839 host->nh_vers = 0; in nlm_create_host()
840 host->nh_state = 0; in nlm_create_host()
841 host->nh_monstate = NLM_UNMONITORED; in nlm_create_host()
842 host->nh_grantcookie = 1; in nlm_create_host()
843 TAILQ_INIT(&host->nh_pending); in nlm_create_host()
844 TAILQ_INIT(&host->nh_granted); in nlm_create_host()
845 TAILQ_INIT(&host->nh_finished); in nlm_create_host()
846 TAILQ_INSERT_TAIL(&nlm_hosts, host, nh_link); in nlm_create_host()
850 sysctl_ctx_init(&host->nh_sysctl); in nlm_create_host()
851 oid = SYSCTL_ADD_NODE(&host->nh_sysctl, in nlm_create_host()
853 OID_AUTO, host->nh_sysid_string, CTLFLAG_RD, NULL, ""); in nlm_create_host()
854 SYSCTL_ADD_STRING(&host->nh_sysctl, SYSCTL_CHILDREN(oid), OID_AUTO, in nlm_create_host()
855 "hostname", CTLFLAG_RD, host->nh_caller_name, 0, ""); in nlm_create_host()
856 SYSCTL_ADD_UINT(&host->nh_sysctl, SYSCTL_CHILDREN(oid), OID_AUTO, in nlm_create_host()
857 "version", CTLFLAG_RD, &host->nh_vers, 0, ""); in nlm_create_host()
858 SYSCTL_ADD_UINT(&host->nh_sysctl, SYSCTL_CHILDREN(oid), OID_AUTO, in nlm_create_host()
859 "monitored", CTLFLAG_RD, &host->nh_monstate, 0, ""); in nlm_create_host()
860 SYSCTL_ADD_PROC(&host->nh_sysctl, SYSCTL_CHILDREN(oid), OID_AUTO, in nlm_create_host()
861 "lock_count", CTLTYPE_INT | CTLFLAG_RD, host, 0, in nlm_create_host()
863 SYSCTL_ADD_PROC(&host->nh_sysctl, SYSCTL_CHILDREN(oid), OID_AUTO, in nlm_create_host()
864 "client_lock_count", CTLTYPE_INT | CTLFLAG_RD, host, 0, in nlm_create_host()
869 return (host); in nlm_create_host()
928 struct nlm_host *host; in nlm_check_idle() local
937 TAILQ_FOREACH(host, &nlm_hosts, nh_link) { in nlm_check_idle()
938 if (host->nh_monstate == NLM_MONITORED in nlm_check_idle()
939 && time_uptime > host->nh_idle_timeout) { in nlm_check_idle()
941 if (lf_countlocks(host->nh_sysid) > 0 in nlm_check_idle()
943 + host->nh_sysid)) { in nlm_check_idle()
944 host->nh_idle_timeout = in nlm_check_idle()
949 nlm_host_unmonitor(host); in nlm_check_idle()
967 struct nlm_host *host; in nlm_find_host_by_name() local
974 TAILQ_FOREACH(host, &nlm_hosts, nh_link) { in nlm_find_host_by_name()
975 if (!strcmp(host->nh_caller_name, name)) in nlm_find_host_by_name()
979 if (!host) { in nlm_find_host_by_name()
980 host = nlm_create_host(name); in nlm_find_host_by_name()
981 if (!host) { in nlm_find_host_by_name()
986 refcount_acquire(&host->nh_refs); in nlm_find_host_by_name()
988 host->nh_idle_timeout = time_uptime + NLM_IDLE_TIMEOUT; in nlm_find_host_by_name()
1004 if (host->nh_addr.ss_len && host->nh_srvrpc.nr_client) { in nlm_find_host_by_name()
1006 (struct sockaddr *) &host->nh_addr, in nlm_find_host_by_name()
1008 || host->nh_vers != vers) { in nlm_find_host_by_name()
1010 mtx_lock(&host->nh_lock); in nlm_find_host_by_name()
1011 client = host->nh_srvrpc.nr_client; in nlm_find_host_by_name()
1012 host->nh_srvrpc.nr_client = NULL; in nlm_find_host_by_name()
1013 mtx_unlock(&host->nh_lock); in nlm_find_host_by_name()
1019 memcpy(&host->nh_addr, addr, addr->sa_len); in nlm_find_host_by_name()
1020 host->nh_vers = vers; in nlm_find_host_by_name()
1027 return (host); in nlm_find_host_by_name()
1044 struct nlm_host *host; in nlm_find_host_by_addr() local
1069 TAILQ_FOREACH(host, &nlm_hosts, nh_link) { in nlm_find_host_by_addr()
1071 (const struct sockaddr *) &host->nh_addr)) in nlm_find_host_by_addr()
1075 if (!host) { in nlm_find_host_by_addr()
1076 host = nlm_create_host(tmp); in nlm_find_host_by_addr()
1077 if (!host) { in nlm_find_host_by_addr()
1081 memcpy(&host->nh_addr, addr, addr->sa_len); in nlm_find_host_by_addr()
1082 host->nh_vers = vers; in nlm_find_host_by_addr()
1084 refcount_acquire(&host->nh_refs); in nlm_find_host_by_addr()
1086 host->nh_idle_timeout = time_uptime + NLM_IDLE_TIMEOUT; in nlm_find_host_by_addr()
1092 return (host); in nlm_find_host_by_addr()
1102 struct nlm_host *host; in nlm_find_host_by_sysid() local
1104 TAILQ_FOREACH(host, &nlm_hosts, nh_link) { in nlm_find_host_by_sysid()
1105 if (host->nh_sysid == sysid) { in nlm_find_host_by_sysid()
1106 refcount_acquire(&host->nh_refs); in nlm_find_host_by_sysid()
1107 return (host); in nlm_find_host_by_sysid()
1114 void nlm_host_release(struct nlm_host *host) in nlm_host_release() argument
1116 if (refcount_release(&host->nh_refs)) { in nlm_host_release()
1120 nlm_host_destroy(host); in nlm_host_release()
1128 nlm_host_unmonitor(struct nlm_host *host) in nlm_host_unmonitor() argument
1136 host->nh_caller_name, host->nh_sysid); in nlm_host_unmonitor()
1143 smmonid.mon_name = host->nh_caller_name; in nlm_host_unmonitor()
1161 host->nh_caller_name); in nlm_host_unmonitor()
1165 host->nh_monstate = NLM_UNMONITORED; in nlm_host_unmonitor()
1173 nlm_host_monitor(struct nlm_host *host, int state) in nlm_host_monitor() argument
1180 if (state && !host->nh_state) { in nlm_host_monitor()
1186 host->nh_state = state; in nlm_host_monitor()
1188 host->nh_caller_name, host->nh_sysid, state); in nlm_host_monitor()
1191 mtx_lock(&host->nh_lock); in nlm_host_monitor()
1192 if (host->nh_monstate != NLM_UNMONITORED) { in nlm_host_monitor()
1193 mtx_unlock(&host->nh_lock); in nlm_host_monitor()
1196 host->nh_monstate = NLM_MONITORED; in nlm_host_monitor()
1197 mtx_unlock(&host->nh_lock); in nlm_host_monitor()
1200 host->nh_caller_name, host->nh_sysid); in nlm_host_monitor()
1207 smmon.mon_id.mon_name = host->nh_caller_name; in nlm_host_monitor()
1212 memcpy(smmon.priv, &host->nh_sysid, sizeof(host->nh_sysid)); in nlm_host_monitor()
1226 host->nh_caller_name); in nlm_host_monitor()
1227 mtx_lock(&host->nh_lock); in nlm_host_monitor()
1228 host->nh_monstate = NLM_MONITOR_FAILED; in nlm_host_monitor()
1229 mtx_unlock(&host->nh_lock); in nlm_host_monitor()
1233 host->nh_monstate = NLM_MONITORED; in nlm_host_monitor()
1241 nlm_host_get_rpc(struct nlm_host *host, bool_t isserver) in nlm_host_get_rpc() argument
1246 mtx_lock(&host->nh_lock); in nlm_host_get_rpc()
1249 rpc = &host->nh_srvrpc; in nlm_host_get_rpc()
1251 rpc = &host->nh_clntrpc; in nlm_host_get_rpc()
1264 mtx_unlock(&host->nh_lock); in nlm_host_get_rpc()
1266 mtx_lock(&host->nh_lock); in nlm_host_get_rpc()
1270 mtx_unlock(&host->nh_lock); in nlm_host_get_rpc()
1271 client = nlm_get_rpc((struct sockaddr *)&host->nh_addr, in nlm_host_get_rpc()
1272 NLM_PROG, host->nh_vers); in nlm_host_get_rpc()
1273 mtx_lock(&host->nh_lock); in nlm_host_get_rpc()
1277 mtx_unlock(&host->nh_lock); in nlm_host_get_rpc()
1279 mtx_lock(&host->nh_lock); in nlm_host_get_rpc()
1290 mtx_unlock(&host->nh_lock); in nlm_host_get_rpc()
1296 int nlm_host_get_sysid(struct nlm_host *host) in nlm_host_get_sysid() argument
1299 return (host->nh_sysid); in nlm_host_get_sysid()
1303 nlm_host_get_state(struct nlm_host *host) in nlm_host_get_state() argument
1306 return (host->nh_state); in nlm_host_get_state()
1523 struct nlm_host *host, *nhost; in nlm_server_main() local
1670 TAILQ_FOREACH_SAFE(host, &nlm_hosts, nh_link, nhost) { in nlm_server_main()
1672 nlm_host_notify(host, 0); in nlm_server_main()
1673 nlm_host_release(host); in nlm_server_main()
1714 struct nlm_host *host; in nlm_sm_notify() local
1718 host = nlm_find_host_by_sysid(sysid); in nlm_sm_notify()
1719 if (host) { in nlm_sm_notify()
1720 nlm_host_notify(host, argp->state); in nlm_sm_notify()
1721 nlm_host_release(host); in nlm_sm_notify()
1738 nlm_get_vfs_state(struct nlm_host *host, struct svc_req *rqstp, in nlm_get_vfs_state() argument
1754 (struct sockaddr *)&host->nh_addr, &exflags, &credanon, in nlm_get_vfs_state()
1845 struct nlm_host *host, *bhost; in nlm_do_test() local
1853 host = nlm_find_host_by_name(argp->alock.caller_name, in nlm_do_test()
1855 if (!host) { in nlm_do_test()
1861 host->nh_caller_name, host->nh_sysid); in nlm_do_test()
1863 nlm_check_expired_locks(host); in nlm_do_test()
1864 sysid = host->nh_sysid; in nlm_do_test()
1875 error = nlm_get_vfs_state(host, rqstp, &fh, &vs, accmode); in nlm_do_test()
1932 *rpcp = nlm_host_get_rpc(host, TRUE); in nlm_do_test()
1933 nlm_host_release(host); in nlm_do_test()
1943 struct nlm_host *host; in nlm_do_lock() local
1951 host = nlm_find_host_by_name(argp->alock.caller_name, in nlm_do_lock()
1953 if (!host) { in nlm_do_lock()
1959 host->nh_caller_name, host->nh_sysid); in nlm_do_lock()
1961 if (monitor && host->nh_state && argp->state in nlm_do_lock()
1962 && host->nh_state != argp->state) { in nlm_do_lock()
1967 nlm_host_notify(host, argp->state); in nlm_do_lock()
1970 nlm_check_expired_locks(host); in nlm_do_lock()
1971 sysid = host->nh_sysid; in nlm_do_lock()
1982 error = nlm_get_vfs_state(host, rqstp, &fh, &vs, accmode); in nlm_do_lock()
2005 client = nlm_host_get_rpc(host, TRUE); in nlm_do_lock()
2017 mtx_lock(&host->nh_lock); in nlm_do_lock()
2018 TAILQ_FOREACH(af, &host->nh_pending, af_link) { in nlm_do_lock()
2027 cookie.ng_sysid = host->nh_sysid; in nlm_do_lock()
2028 cookie.ng_cookie = host->nh_grantcookie++; in nlm_do_lock()
2030 mtx_unlock(&host->nh_lock); in nlm_do_lock()
2042 af->af_host = host; in nlm_do_lock()
2069 mtx_lock(&host->nh_lock); in nlm_do_lock()
2070 TAILQ_INSERT_TAIL(&host->nh_pending, af, af_link); in nlm_do_lock()
2071 mtx_unlock(&host->nh_lock); in nlm_do_lock()
2082 mtx_lock(&host->nh_lock); in nlm_do_lock()
2083 TAILQ_REMOVE(&host->nh_pending, af, af_link); in nlm_do_lock()
2084 mtx_unlock(&host->nh_lock); in nlm_do_lock()
2090 "(sysid %d)\n", af, host->nh_caller_name, sysid); in nlm_do_lock()
2114 nlm_host_monitor(host, argp->state); in nlm_do_lock()
2121 *rpcp = nlm_host_get_rpc(host, TRUE); in nlm_do_lock()
2122 nlm_host_release(host); in nlm_do_lock()
2132 struct nlm_host *host; in nlm_do_cancel() local
2140 host = nlm_find_host_by_name(argp->alock.caller_name, in nlm_do_cancel()
2142 if (!host) { in nlm_do_cancel()
2148 host->nh_caller_name, host->nh_sysid); in nlm_do_cancel()
2150 nlm_check_expired_locks(host); in nlm_do_cancel()
2151 sysid = host->nh_sysid; in nlm_do_cancel()
2161 error = nlm_get_vfs_state(host, rqstp, &fh, &vs, (accmode_t)0); in nlm_do_cancel()
2181 mtx_lock(&host->nh_lock); in nlm_do_cancel()
2183 TAILQ_FOREACH(af, &host->nh_pending, af_link) { in nlm_do_cancel()
2193 mtx_unlock(&host->nh_lock); in nlm_do_cancel()
2206 mtx_unlock(&host->nh_lock); in nlm_do_cancel()
2211 *rpcp = nlm_host_get_rpc(host, TRUE); in nlm_do_cancel()
2212 nlm_host_release(host); in nlm_do_cancel()
2222 struct nlm_host *host; in nlm_do_unlock() local
2229 host = nlm_find_host_by_name(argp->alock.caller_name, in nlm_do_unlock()
2231 if (!host) { in nlm_do_unlock()
2237 host->nh_caller_name, host->nh_sysid); in nlm_do_unlock()
2239 nlm_check_expired_locks(host); in nlm_do_unlock()
2240 sysid = host->nh_sysid; in nlm_do_unlock()
2250 error = nlm_get_vfs_state(host, rqstp, &fh, &vs, (accmode_t)0); in nlm_do_unlock()
2273 *rpcp = nlm_host_get_rpc(host, TRUE); in nlm_do_unlock()
2274 nlm_host_release(host); in nlm_do_unlock()
2283 struct nlm_host *host; in nlm_do_granted() local
2288 host = nlm_find_host_by_addr(svc_getrpccaller(rqstp), rqstp->rq_vers); in nlm_do_granted()
2289 if (!host) { in nlm_do_granted()
2318 *rpcp = nlm_host_get_rpc(host, TRUE); in nlm_do_granted()
2319 nlm_host_release(host); in nlm_do_granted()
2326 struct nlm_host *host = NULL; in nlm_do_granted_res() local
2335 host = nlm_find_host_by_sysid(ng_sysid(&argp->cookie)); in nlm_do_granted_res()
2336 if (!host) { in nlm_do_granted_res()
2341 mtx_lock(&host->nh_lock); in nlm_do_granted_res()
2342 TAILQ_FOREACH(af, &host->nh_granted, af_link) in nlm_do_granted_res()
2347 TAILQ_REMOVE(&host->nh_granted, af, af_link); in nlm_do_granted_res()
2348 mtx_unlock(&host->nh_lock); in nlm_do_granted_res()
2352 "with unrecognized cookie %d:%d", host->nh_caller_name, in nlm_do_granted_res()
2353 host->nh_sysid, ng_sysid(&argp->cookie), in nlm_do_granted_res()
2363 "and we failed to unlock (%d)", host->nh_caller_name, in nlm_do_granted_res()
2364 host->nh_sysid, error); in nlm_do_granted_res()
2369 af, host->nh_caller_name, host->nh_sysid); in nlm_do_granted_res()
2372 af, host->nh_caller_name, host->nh_sysid); in nlm_do_granted_res()
2378 if (host) in nlm_do_granted_res()
2379 nlm_host_release(host); in nlm_do_granted_res()
2385 struct nlm_host *host, *thost; in nlm_do_free_all() local
2387 TAILQ_FOREACH_SAFE(host, &nlm_hosts, nh_link, thost) { in nlm_do_free_all()
2388 if (!strcmp(host->nh_caller_name, argp->name)) in nlm_do_free_all()
2389 nlm_host_notify(host, argp->state); in nlm_do_free_all()