Lines Matching refs:seg

454 static int rsm_closeconnection(rsmseg_t *seg, void **cookie);
455 static int rsm_unpublish(rsmseg_t *seg, int mode);
456 static int rsm_unbind(rsmseg_t *seg);
464 int rsm_disconnect(rsmseg_t *seg);
1744 rsmsharecv_signal(rsmseg_t *seg, int oldstate, int newstate) in rsmsharecv_signal() argument
1746 ASSERT(rsmsharelock_held(seg)); in rsmsharecv_signal()
1748 if (seg->s_share->rsmsi_state == oldstate) { in rsmsharecv_signal()
1749 seg->s_share->rsmsi_state = newstate; in rsmsharecv_signal()
1750 cv_broadcast(&seg->s_share->rsmsi_cv); in rsmsharecv_signal()
1833 rsmseg_free(rsmseg_t *seg) in rsmseg_free() argument
1841 rsmseglock_acquire(seg); in rsmseg_free()
1842 if (seg->s_ckl != NULL) { in rsmseg_free()
1844 seg->s_state = RSM_STATE_END; in rsmseg_free()
1845 rsmseglock_release(seg); in rsmseg_free()
1851 rsmseglock_release(seg); in rsmseg_free()
1853 ASSERT(seg->s_state == RSM_STATE_END || seg->s_state == RSM_STATE_NEW); in rsmseg_free()
1860 if (seg->s_share != NULL) { in rsmseg_free()
1862 ASSERT(seg->s_type == RSM_RESOURCE_IMPORT_SEGMENT); in rsmseg_free()
1864 rsmsharelock_acquire(seg); in rsmseg_free()
1866 ASSERT(seg->s_share->rsmsi_refcnt > 0); in rsmseg_free()
1868 seg->s_share->rsmsi_refcnt--; in rsmseg_free()
1870 if (seg->s_share->rsmsi_refcnt == 0) { in rsmseg_free()
1871 rsmsharelock_release(seg); in rsmseg_free()
1872 mutex_destroy(&seg->s_share->rsmsi_lock); in rsmseg_free()
1873 cv_destroy(&seg->s_share->rsmsi_cv); in rsmseg_free()
1874 kmem_free((void *)(seg->s_share), in rsmseg_free()
1877 rsmsharelock_release(seg); in rsmseg_free()
1883 seg->s_share = NULL; in rsmseg_free()
1886 cv_destroy(&seg->s_cv); in rsmseg_free()
1887 mutex_destroy(&seg->s_lock); in rsmseg_free()
1888 rsmacl_free(seg->s_acl, seg->s_acl_len); in rsmseg_free()
1889 rsmpiacl_free(seg->s_acl_in, seg->s_acl_len); in rsmseg_free()
1890 if (seg->s_adapter) in rsmseg_free()
1891 rsmka_release_adapter(seg->s_adapter); in rsmseg_free()
1893 kmem_free((void *)seg, sizeof (*seg)); in rsmseg_free()
1999 rsmseg_close(rsmseg_t *seg, int force_flag) in rsmseg_close() argument
2007 rsmseglock_acquire(seg); in rsmseg_close()
2008 if (!force_flag && (seg->s_hdr.rsmrc_type == in rsmseg_close()
2016 while (seg->s_flags & RSM_FORCE_DESTROY_WAIT) { in rsmseg_close()
2017 cv_wait(&seg->s_cv, &seg->s_lock); in rsmseg_close()
2020 rsmseglock_release(seg); in rsmseg_close()
2023 switch (seg->s_state) { in rsmseg_close()
2027 e = rsm_unpublish(seg, 1); in rsmseg_close()
2032 e = rsm_unbind(seg); in rsmseg_close()
2035 ASSERT(seg->s_hdr.rsmrc_type == RSM_RESOURCE_EXPORT_SEGMENT); in rsmseg_close()
2038 rsmseglock_acquire(seg); in rsmseg_close()
2039 seg->s_state = RSM_STATE_NEW; in rsmseg_close()
2040 cv_broadcast(&seg->s_cv); in rsmseg_close()
2041 rsmseglock_release(seg); in rsmseg_close()
2062 rsmseglock_acquire(seg); in rsmseg_close()
2063 seg->s_state = RSM_STATE_NEW; in rsmseg_close()
2064 rsmseglock_release(seg); in rsmseg_close()
2072 ASSERT(seg->s_hdr.rsmrc_type == RSM_RESOURCE_IMPORT_SEGMENT); in rsmseg_close()
2073 (void) rsm_disconnect(seg); in rsmseg_close()
2079 "Invalid segment state %d in rsm_close\n", seg->s_state)); in rsmseg_close()
2083 "Invalid segment state %d in rsm_close\n", seg->s_state)); in rsmseg_close()
2092 ASSERT(seg->s_state == RSM_STATE_NEW); in rsmseg_close()
2104 rsmseglock_acquire(seg); in rsmseg_close()
2105 seg->s_state = RSM_STATE_ZOMBIE; in rsmseg_close()
2106 rsmseglock_release(seg); in rsmseg_close()
2108 rsmseg_free(seg); in rsmseg_close()
2288 rsm_unbind_pages(rsmseg_t *seg) in rsm_unbind_pages() argument
2294 ASSERT(rsmseglock_held(seg)); in rsm_unbind_pages()
2296 if (seg->s_cookie != NULL) { in rsm_unbind_pages()
2298 ddi_umem_unlock(seg->s_cookie); in rsm_unbind_pages()
2299 rsm_dec_pgcnt(btopr(seg->s_len)); in rsm_unbind_pages()
2300 seg->s_cookie = NULL; in rsm_unbind_pages()
2310 rsm_bind(rsmseg_t *seg, rsm_ioctlmsg_t *msg, intptr_t dataptr, int mode) in rsm_bind() argument
2340 rsmseglock_acquire(seg); in rsm_bind()
2342 while (seg->s_state == RSM_STATE_NEW_QUIESCED) { in rsm_bind()
2343 if (cv_wait_sig(&seg->s_cv, &seg->s_lock) == 0) { in rsm_bind()
2347 rsmseglock_release(seg); in rsm_bind()
2352 ASSERT(seg->s_state == RSM_STATE_NEW); in rsm_bind()
2354 ASSERT(seg->s_cookie == NULL); in rsm_bind()
2356 e = rsm_bind_pages(&seg->s_cookie, msg->vaddr, msg->len, curproc); in rsm_bind()
2358 seg->s_flags |= RSM_USER_MEMORY; in rsm_bind()
2360 seg->s_flags |= RSMKA_ALLOW_UNBIND_REBIND; in rsm_bind()
2363 seg->s_flags |= RSMKA_SET_RESOURCE_DONTWAIT; in rsm_bind()
2365 seg->s_region.r_vaddr = msg->vaddr; in rsm_bind()
2378 seg->s_pid = ddi_get_pid(); in rsm_bind()
2379 seg->s_len = msg->len; in rsm_bind()
2380 seg->s_state = RSM_STATE_BIND; in rsm_bind()
2381 seg->s_adapter = adapter; in rsm_bind()
2382 seg->s_proc = curproc; in rsm_bind()
2389 msg->rnum = seg->s_minor; in rsm_bind()
2391 rsmseglock_release(seg); in rsm_bind()
2439 rsmseg_t *seg = (rsmseg_t *)p; in rsm_remap_local_importers() local
2440 rsmseglock_acquire(seg); in rsm_remap_local_importers()
2449 if ((seg->s_segid == ex_segid) && (seg->s_node == src_nodeid) && in rsm_remap_local_importers()
2450 (seg->s_state == RSM_STATE_ACTIVE)) { in rsm_remap_local_importers()
2451 seg->s_cookie = cookie; in rsm_remap_local_importers()
2453 rsmseglock_release(seg); in rsm_remap_local_importers()
2462 rsm_rebind(rsmseg_t *seg, rsm_ioctlmsg_t *msg) in rsm_rebind() argument
2472 if (!(seg->s_flags & RSMKA_ALLOW_UNBIND_REBIND)) { in rsm_rebind()
2476 if (seg->s_pid != ddi_get_pid() && in rsm_rebind()
2491 if (msg->len != seg->s_len) { in rsm_rebind()
2498 rsmseglock_acquire(seg); in rsm_rebind()
2500 while ((seg->s_state == RSM_STATE_BIND_QUIESCED) || in rsm_rebind()
2501 (seg->s_state == RSM_STATE_EXPORT_QUIESCING) || in rsm_rebind()
2502 (seg->s_state == RSM_STATE_EXPORT_QUIESCED)) { in rsm_rebind()
2503 if (cv_wait_sig(&seg->s_cv, &seg->s_lock) == 0) { in rsm_rebind()
2504 rsmseglock_release(seg); in rsm_rebind()
2512 if ((seg->s_state != RSM_STATE_BIND) && in rsm_rebind()
2513 (seg->s_state != RSM_STATE_EXPORT)) { in rsm_rebind()
2515 rsmseglock_release(seg); in rsm_rebind()
2521 ASSERT(seg->s_cookie != NULL); in rsm_rebind()
2523 if (msg->vaddr == seg->s_region.r_vaddr) { in rsm_rebind()
2524 rsmseglock_release(seg); in rsm_rebind()
2542 adapter = seg->s_adapter; in rsm_rebind()
2544 seg->s_handle.out, 0, &mem, in rsm_rebind()
2552 (void) rsm_unbind_pages(seg); in rsm_rebind()
2553 seg->s_cookie = cookie; in rsm_rebind()
2554 seg->s_region.r_vaddr = msg->vaddr; in rsm_rebind()
2555 rsm_remap_local_importers(my_nodeid, seg->s_segid, in rsm_rebind()
2578 rsmseglock_release(seg); in rsm_rebind()
2586 rsm_unbind(rsmseg_t *seg) in rsm_unbind() argument
2592 rsmseglock_acquire(seg); in rsm_unbind()
2595 if ((seg->s_state != RSM_STATE_BIND) && in rsm_unbind()
2596 (seg->s_state != RSM_STATE_BIND_QUIESCED)) { in rsm_unbind()
2597 rsmseglock_release(seg); in rsm_unbind()
2604 (void) rsm_unbind_pages(seg); in rsm_unbind()
2606 if (seg->s_state == RSM_STATE_BIND) { in rsm_unbind()
2607 seg->s_state = RSM_STATE_NEW; in rsm_unbind()
2608 } else if (seg->s_state == RSM_STATE_BIND_QUIESCED) { in rsm_unbind()
2609 seg->s_state = RSM_STATE_NEW_QUIESCED; in rsm_unbind()
2612 rsmseglock_release(seg); in rsm_unbind()
2769 rsmseg_t *seg; in rsmsegacl_validate() local
2782 seg = rsmexport_lookup(key); in rsmsegacl_validate()
2783 if (!seg) { in rsmsegacl_validate()
2789 ASSERT(rsmseglock_held(seg)); in rsmsegacl_validate()
2790 ASSERT(seg->s_state == RSM_STATE_EXPORT); in rsmsegacl_validate()
2799 if (seg->s_acl_len > 0) { in rsmsegacl_validate()
2803 ASSERT(seg->s_acl != NULL); in rsmsegacl_validate()
2804 for (i = 0; i < seg->s_acl_len; i++) { in rsmsegacl_validate()
2805 if (seg->s_acl[i].ae_node == rnode) { in rsmsegacl_validate()
2806 perm &= seg->s_acl[i].ae_permission; in rsmsegacl_validate()
2811 rsmseglock_release(seg); in rsmsegacl_validate()
2817 perm &= seg->s_mode; in rsmsegacl_validate()
2823 reply->rsmipc_uid = seg->s_uid; in rsmsegacl_validate()
2824 reply->rsmipc_gid = seg->s_gid; in rsmsegacl_validate()
2825 reply->rsmipc_segid = seg->s_segid; in rsmsegacl_validate()
2826 reply->rsmipc_seglen = seg->s_len; in rsmsegacl_validate()
2831 rsmseglock_release(seg); in rsmsegacl_validate()
2849 rsm_publish(rsmseg_t *seg, rsm_ioctlmsg_t *msg, intptr_t dataptr, int mode) in rsm_publish() argument
2867 if (seg->s_adapter == &loopback_adapter) in rsm_publish()
2870 if (seg->s_pid != ddi_get_pid() && in rsm_publish()
2928 e = rsmexport_add(seg, segment_id); in rsm_publish()
2936 seg->s_segid = segment_id; in rsm_publish()
2938 if ((seg->s_state != RSM_STATE_BIND) && in rsm_publish()
2939 (seg->s_state != RSM_STATE_BIND_QUIESCED)) { in rsm_publish()
2941 rsmseglock_release(seg); in rsm_publish()
2942 rsmexport_rm(seg); in rsm_publish()
2946 seg->s_state)); in rsm_publish()
2964 xbuf = ddi_umem_iosetup(seg->s_cookie, 0, seg->s_len, B_WRITE, in rsm_publish()
2973 adapter = seg->s_adapter; in rsm_publish()
2980 rsmseglock_release(seg); in rsm_publish()
2981 rsmexport_rm(seg); in rsm_publish()
2989 if (seg->s_state == RSM_STATE_BIND) { in rsm_publish()
2994 if (seg->s_flags & RSMKA_ALLOW_UNBIND_REBIND) { in rsm_publish()
2998 if (seg->s_flags & RSMKA_SET_RESOURCE_DONTWAIT) { in rsm_publish()
3006 &seg->s_handle.out, seg->s_len, in rsm_publish()
3017 rsmseglock_release(seg); in rsm_publish()
3018 rsmexport_rm(seg); in rsm_publish()
3037 seg->s_handle.out, in rsm_publish()
3039 seg->s_segid, in rsm_publish()
3043 adapter->rsmpi_ops->rsm_seg_destroy(seg->s_handle.out); in rsm_publish()
3044 rsmseglock_release(seg); in rsm_publish()
3045 rsmexport_rm(seg); in rsm_publish()
3055 seg->s_acl_in = rsmpi_acl; in rsm_publish()
3059 seg->s_acl_len = acl_len; in rsm_publish()
3060 seg->s_acl = acl; in rsm_publish()
3062 if (seg->s_state == RSM_STATE_BIND) { in rsm_publish()
3063 seg->s_state = RSM_STATE_EXPORT; in rsm_publish()
3064 } else if (seg->s_state == RSM_STATE_BIND_QUIESCED) { in rsm_publish()
3065 seg->s_state = RSM_STATE_EXPORT_QUIESCED; in rsm_publish()
3066 cv_broadcast(&seg->s_cv); in rsm_publish()
3069 rsmseglock_release(seg); in rsm_publish()
3104 rsm_republish(rsmseg_t *seg, rsm_ioctlmsg_t *msg, int mode) in rsm_republish() argument
3118 if ((seg->s_state != RSM_STATE_EXPORT) && in rsm_republish()
3119 (seg->s_state != RSM_STATE_EXPORT_QUIESCED) && in rsm_republish()
3120 (seg->s_state != RSM_STATE_EXPORT_QUIESCING)) in rsm_republish()
3123 if (seg->s_pid != ddi_get_pid() && in rsm_republish()
3130 if (seg->s_adapter == &loopback_adapter) in rsm_republish()
3144 rsmseglock_acquire(seg); in rsm_republish()
3150 while (((seg->s_state == RSM_STATE_EXPORT) && in rsm_republish()
3151 (seg->s_flags & RSM_REPUBLISH_WAIT)) || in rsm_republish()
3152 (seg->s_state == RSM_STATE_EXPORT_QUIESCED) || in rsm_republish()
3153 (seg->s_state == RSM_STATE_EXPORT_QUIESCING)) { in rsm_republish()
3154 if (cv_wait_sig(&seg->s_cv, &seg->s_lock) == 0) { in rsm_republish()
3157 rsmseglock_release(seg); in rsm_republish()
3164 if (seg->s_state != RSM_STATE_EXPORT) { in rsm_republish()
3165 rsmseglock_release(seg); in rsm_republish()
3170 key = seg->s_key; in rsm_republish()
3171 old_acl = seg->s_acl; in rsm_republish()
3172 old_acl_len = seg->s_acl_len; in rsm_republish()
3174 seg->s_acl = new_acl; in rsm_republish()
3175 seg->s_acl_len = new_acl_len; in rsm_republish()
3181 adapter = seg->s_adapter; in rsm_republish()
3188 seg->s_acl = old_acl; in rsm_republish()
3189 seg->s_acl_len = old_acl_len; in rsm_republish()
3190 rsmseglock_release(seg); in rsm_republish()
3196 rsmpi_old_acl = seg->s_acl_in; in rsm_republish()
3197 seg->s_acl_in = rsmpi_new_acl; in rsm_republish()
3199 e = adapter->rsmpi_ops->rsm_republish(seg->s_handle.out, in rsm_republish()
3200 seg->s_acl_in, seg->s_acl_len, in rsm_republish()
3204 seg->s_acl = old_acl; in rsm_republish()
3205 seg->s_acl_in = rsmpi_old_acl; in rsm_republish()
3206 seg->s_acl_len = old_acl_len; in rsm_republish()
3207 rsmseglock_release(seg); in rsm_republish()
3235 permission = seg->s_mode; in rsm_republish()
3239 seg->s_flags |= RSM_REPUBLISH_WAIT; in rsm_republish()
3241 rsmseglock_release(seg); in rsm_republish()
3246 rsmseglock_acquire(seg); in rsm_republish()
3247 seg->s_flags &= ~RSM_REPUBLISH_WAIT; in rsm_republish()
3249 cv_broadcast(&seg->s_cv); in rsm_republish()
3250 rsmseglock_release(seg); in rsm_republish()
3261 rsm_unpublish(rsmseg_t *seg, int mode) in rsm_unpublish() argument
3272 if (seg->s_pid != ddi_get_pid() && in rsm_unpublish()
3279 rsmseglock_acquire(seg); in rsm_unpublish()
3286 while ((seg->s_state == RSM_STATE_EXPORT_QUIESCING) || in rsm_unpublish()
3287 ((seg->s_state == RSM_STATE_EXPORT) && (seg->s_rdmacnt > 0))) { in rsm_unpublish()
3288 if (cv_wait_sig(&seg->s_cv, &seg->s_lock) == 0) { in rsm_unpublish()
3289 rsmseglock_release(seg); in rsm_unpublish()
3298 if ((seg->s_state != RSM_STATE_EXPORT) && in rsm_unpublish()
3299 (seg->s_state != RSM_STATE_EXPORT_QUIESCED)) { in rsm_unpublish()
3300 rsmseglock_release(seg); in rsm_unpublish()
3302 "rsm_unpublish done: bad state %x\n", seg->s_state)); in rsm_unpublish()
3306 rsmseglock_release(seg); in rsm_unpublish()
3308 rsmexport_rm(seg); in rsm_unpublish()
3310 rsm_send_importer_disconnects(seg->s_segid, my_nodeid); in rsm_unpublish()
3312 rsmseglock_acquire(seg); in rsm_unpublish()
3316 while ((seg->s_state == RSM_STATE_EXPORT) && in rsm_unpublish()
3317 (seg->s_flags & RSM_REPUBLISH_WAIT)) { in rsm_unpublish()
3318 if (cv_wait_sig(&seg->s_cv, &seg->s_lock) == 0) { in rsm_unpublish()
3321 rsmseglock_release(seg); in rsm_unpublish()
3326 if ((seg->s_state != RSM_STATE_EXPORT) && in rsm_unpublish()
3327 (seg->s_state != RSM_STATE_EXPORT_QUIESCED)) { in rsm_unpublish()
3330 rsmseglock_release(seg); in rsm_unpublish()
3342 acl = seg->s_acl; in rsm_unpublish()
3349 if (seg->s_state == RSM_STATE_EXPORT_QUIESCED) in rsm_unpublish()
3352 adapter = seg->s_adapter; in rsm_unpublish()
3354 if (seg->s_state != RSM_STATE_EXPORT) { in rsm_unpublish()
3355 rsmseglock_release(seg); in rsm_unpublish()
3358 seg->s_state)); in rsm_unpublish()
3363 e = adapter->rsmpi_ops->rsm_unpublish(seg->s_handle.out); in rsm_unpublish()
3373 seg->s_flags |= RSM_EXPORT_WAIT; in rsm_unpublish()
3381 (void) cv_reltimedwait(&seg->s_cv, &seg->s_lock, in rsm_unpublish()
3387 seg->s_flags &= ~RSM_EXPORT_WAIT; in rsm_unpublish()
3392 seg->s_state = RSM_STATE_BIND; in rsm_unpublish()
3394 rsmseglock_release(seg); in rsm_unpublish()
3400 e = adapter->rsmpi_ops->rsm_seg_destroy(seg->s_handle.out); in rsm_unpublish()
3405 seg->s_key, e)); in rsm_unpublish()
3409 acl = seg->s_acl; in rsm_unpublish()
3410 rsmpi_acl = seg->s_acl_in; in rsm_unpublish()
3411 acl_len = seg->s_acl_len; in rsm_unpublish()
3413 seg->s_acl = NULL; in rsm_unpublish()
3414 seg->s_acl_in = NULL; in rsm_unpublish()
3415 seg->s_acl_len = 0; in rsm_unpublish()
3417 if (seg->s_state == RSM_STATE_EXPORT) { in rsm_unpublish()
3418 seg->s_state = RSM_STATE_BIND; in rsm_unpublish()
3419 } else if (seg->s_state == RSM_STATE_EXPORT_QUIESCED) { in rsm_unpublish()
3420 seg->s_state = RSM_STATE_BIND_QUIESCED; in rsm_unpublish()
3421 cv_broadcast(&seg->s_cv); in rsm_unpublish()
3424 rsmseglock_release(seg); in rsm_unpublish()
3664 rsmseg_t *seg = (rsmseg_t *)p; in rsm_force_unload() local
3665 if ((seg->s_segid == ex_segid) && (seg->s_node == src_nodeid)) { in rsm_force_unload()
3675 rsmseglock_acquire(seg); in rsm_force_unload()
3677 seg->s_flags |= RSM_FORCE_DISCONNECT; in rsm_force_unload()
3678 rsmseg_unload(seg); in rsm_force_unload()
4020 rsmseg_t *seg; in rsm_intr_event() local
4030 if ((seg = msg->rsmipc_segment_cookie) != NULL) { in rsm_intr_event()
4041 seg = (rsmseg_t *)p; in rsm_intr_event()
4042 rsmseglock_acquire(seg); in rsm_intr_event()
4044 atomic_inc_32(&seg->s_pollevent); in rsm_intr_event()
4046 if (seg->s_pollflag & RSM_SEGMENT_POLL) in rsm_intr_event()
4047 pollwakeup(&seg->s_poll, POLLRDNORM); in rsm_intr_event()
4049 rsmseglock_release(seg); in rsm_intr_event()
4056 seg = rsmexport_lookup(msg->rsmipc_key); in rsm_intr_event()
4057 if (!seg) { in rsm_intr_event()
4063 ASSERT(rsmseglock_held(seg)); in rsm_intr_event()
4065 atomic_inc_32(&seg->s_pollevent); in rsm_intr_event()
4073 if (seg->s_pollflag & RSM_SEGMENT_POLL) in rsm_intr_event()
4074 pollwakeup(&seg->s_poll, POLLRDNORM); in rsm_intr_event()
4076 rsmseglock_release(seg); in rsm_intr_event()
4092 rsmseg_t *seg; in importer_update() local
4109 seg = (rsmseg_t *)p; in importer_update()
4111 rsmseglock_acquire(seg); in importer_update()
4112 rsmsharelock_acquire(seg); in importer_update()
4113 seg->s_share->rsmsi_mode = perm; in importer_update()
4114 rsmsharelock_release(seg); in importer_update()
4115 rsmseglock_release(seg); in importer_update()
4182 rsmseg_t *seg; in exporter_quiesce() local
4199 seg = (rsmseg_t *)current; in exporter_quiesce()
4200 rsmseglock_acquire(seg); in exporter_quiesce()
4203 adapter = seg->s_adapter; in exporter_quiesce()
4208 if ((seg->s_acl == NULL) || in exporter_quiesce()
4209 (seg->s_acl[0].ae_node != my_nodeid) || in exporter_quiesce()
4210 (seg->s_acl[0].ae_permission != 0)) { in exporter_quiesce()
4213 seg->s_handle.out); in exporter_quiesce()
4218 seg->s_handle.out); in exporter_quiesce()
4225 (void) rsm_unbind_pages(seg); in exporter_quiesce()
4226 seg->s_state = RSM_STATE_EXPORT_QUIESCED; in exporter_quiesce()
4227 cv_broadcast(&seg->s_cv); in exporter_quiesce()
4229 rsmseglock_release(seg); in exporter_quiesce()
4261 rsmseg_t *seg; in importer_suspend() local
4291 seg = (rsmseg_t *)curp; in importer_suspend()
4293 rsmseglock_acquire(seg); in importer_suspend()
4295 if ((seg->s_node != first->s_node) || in importer_suspend()
4296 (seg->s_key != first->s_key) || in importer_suspend()
4297 (seg->s_state == RSM_STATE_DISCONNECT)) { in importer_suspend()
4302 rsmseglock_release(seg); in importer_suspend()
4306 rsmseg_suspend(seg, &susp_flg); in importer_suspend()
4309 rsmseglock_release(seg); in importer_suspend()
4314 rsmsharelock_acquire(seg); in importer_suspend()
4320 seg->s_share->rsmsi_refcnt) { in importer_suspend()
4321 rsmsharelock_release(seg); in importer_suspend()
4322 rsmseglock_release(seg); in importer_suspend()
4325 rsmsharelock_release(seg); in importer_suspend()
4326 rsmseglock_release(seg); in importer_suspend()
4336 rsmsegshare_suspend(seg); in importer_suspend()
4353 rsmseg_suspend(rsmseg_t *seg, int *susp_flg) in rsmseg_suspend() argument
4361 "rsmseg_suspend enter: key=%u\n", seg->s_key)); in rsmseg_suspend()
4365 ASSERT(rsmseglock_held(seg)); in rsmseg_suspend()
4367 while (seg->s_rdmacnt > 0) in rsmseg_suspend()
4368 cv_wait(&seg->s_cv, &seg->s_lock); in rsmseg_suspend()
4375 seg->s_key, seg->s_state)); in rsmseg_suspend()
4377 switch (seg->s_state) { in rsmseg_suspend()
4382 seg->s_state = RSM_STATE_ABORT_CONNECT; in rsmseg_suspend()
4387 seg->s_handle.in = NULL; in rsmseg_suspend()
4388 seg->s_state = RSM_STATE_CONN_QUIESCE; in rsmseg_suspend()
4392 while (seg->s_state == RSM_STATE_MAPPING) in rsmseg_suspend()
4393 cv_wait(&seg->s_cv, &seg->s_lock); in rsmseg_suspend()
4398 if (seg->s_ckl != NULL) { in rsmseg_suspend()
4399 hdl = seg->s_ckl; in rsmseg_suspend()
4405 seg->s_mapinfo = NULL; in rsmseg_suspend()
4406 seg->s_state = RSM_STATE_MAP_QUIESCE; in rsmseg_suspend()
4425 rsmsegshare_suspend(rsmseg_t *seg) in rsmsegshare_suspend() argument
4436 rsmseglock_acquire(seg); in rsmsegshare_suspend()
4437 rsmsharelock_acquire(seg); in rsmsegshare_suspend()
4439 sharedp = seg->s_share; in rsmsegshare_suspend()
4440 adapter = seg->s_adapter; in rsmsegshare_suspend()
4469 e = adapter->rsmpi_ops->rsm_unmap(seg->s_handle.in); in rsmsegshare_suspend()
4493 rsmsharelock_release(seg); in rsmsegshare_suspend()
4494 rsmseglock_release(seg); in rsmsegshare_suspend()
4522 rsmseg_t *seg = (rsmseg_t *)p; in importer_resume() local
4524 rsmseglock_acquire(seg); in importer_resume()
4527 if (seg->s_node != src_node) { in importer_resume()
4528 rsmseglock_release(seg); in importer_resume()
4532 if (rsmseg_resume(seg, &cookie) != RSM_SUCCESS) { in importer_resume()
4541 request.rsmipc_key = seg->s_segid; in importer_resume()
4543 rsmseglock_release(seg); in importer_resume()
4544 (void) rsmipc_send(seg->s_node, &request, in importer_resume()
4547 rsmseglock_release(seg); in importer_resume()
4558 rsmseg_resume(rsmseg_t *seg, void **cookie) in rsmseg_resume() argument
4572 "rsmseg_resume enter: key=%u\n", seg->s_key)); in rsmseg_resume()
4576 ASSERT(rsmseglock_held(seg)); in rsmseg_resume()
4578 if ((seg->s_state != RSM_STATE_CONN_QUIESCE) && in rsmseg_resume()
4579 (seg->s_state != RSM_STATE_MAP_QUIESCE)) { in rsmseg_resume()
4583 sharedp = seg->s_share; in rsmseg_resume()
4585 rsmsharelock_acquire(seg); in rsmseg_resume()
4588 retc = rsmsegshare_resume(seg); in rsmseg_resume()
4590 if (seg->s_state == RSM_STATE_CONN_QUIESCE) { in rsmseg_resume()
4595 seg->s_handle.in = sharedp->rsmsi_handle; in rsmseg_resume()
4596 rsmsharelock_release(seg); in rsmseg_resume()
4597 seg->s_state = RSM_STATE_CONNECT; in rsmseg_resume()
4600 seg->s_handle.in = NULL; in rsmseg_resume()
4601 seg->s_state = RSM_STATE_DISCONNECT; in rsmseg_resume()
4608 rsmsharelock_release(seg); in rsmseg_resume()
4617 rsmsharelock_release(seg); in rsmseg_resume()
4623 seg->s_share = NULL; in rsmseg_resume()
4627 cv_broadcast(&seg->s_cv); in rsmseg_resume()
4630 "rsmseg_resume done:state=%d\n", seg->s_state)); in rsmseg_resume()
4634 ASSERT(seg->s_state == RSM_STATE_MAP_QUIESCE); in rsmseg_resume()
4638 if (seg->s_mode & RSM_PERM_READ) { in rsmseg_resume()
4641 if (seg->s_mode & RSM_PERM_WRITE) { in rsmseg_resume()
4649 ASSERT(seg->s_ckl != NULL); in rsmseg_resume()
4651 for (hdl = seg->s_ckl; hdl != NULL; hdl = hdl->c_next) { in rsmseg_resume()
4660 seg->s_handle.in = NULL; in rsmseg_resume()
4661 seg->s_state = RSM_STATE_DISCONNECT; in rsmseg_resume()
4666 seg->s_mapinfo = NULL; in rsmseg_resume()
4670 rsmsharelock_release(seg); in rsmseg_resume()
4679 rsmsharelock_release(seg); in rsmseg_resume()
4685 seg->s_share = NULL; in rsmseg_resume()
4688 cv_broadcast(&seg->s_cv); in rsmseg_resume()
4692 seg->s_key, retc)); in rsmseg_resume()
4697 seg->s_handle.in = sharedp->rsmsi_handle; in rsmseg_resume()
4699 if (seg->s_node == my_nodeid) { /* loopback */ in rsmseg_resume()
4700 ASSERT(seg->s_mapinfo == NULL); in rsmseg_resume()
4702 for (hdl = seg->s_ckl; hdl != NULL; hdl = hdl->c_next) { in rsmseg_resume()
4704 rsm_dip, seg->s_cookie, in rsmseg_resume()
4713 seg->s_mapinfo = sharedp->rsmsi_mapinfo; in rsmseg_resume()
4715 for (hdl = seg->s_ckl; hdl != NULL; hdl = hdl->c_next) { in rsmseg_resume()
4716 p = rsm_get_mapinfo(seg, hdl->c_off, hdl->c_len, in rsmseg_resume()
4727 rsmsharelock_release(seg); in rsmseg_resume()
4729 seg->s_state = RSM_STATE_ACTIVE; in rsmseg_resume()
4730 cv_broadcast(&seg->s_cv); in rsmseg_resume()
4738 rsmsegshare_resume(rsmseg_t *seg) in rsmsegshare_resume() argument
4748 ASSERT(rsmseglock_held(seg)); in rsmsegshare_resume()
4749 ASSERT(rsmsharelock_held(seg)); in rsmsegshare_resume()
4751 sharedp = seg->s_share; in rsmsegshare_resume()
4763 adapter = seg->s_adapter; in rsmsegshare_resume()
4845 (void) seg->s_adapter->rsmpi_ops-> in rsmsegshare_resume()
6084 rsm_connect(rsmseg_t *seg, rsm_ioctlmsg_t *msg, cred_t *cred, in rsm_connect() argument
6115 ASSERT(seg->s_hdr.rsmrc_type == RSM_RESOURCE_IMPORT_SEGMENT); in rsm_connect()
6116 ASSERT(seg->s_state == RSM_STATE_NEW); in rsm_connect()
6133 seg->s_node = msg->nodeid; in rsm_connect()
6139 e = rsmimport_add(seg, msg->key); in rsm_connect()
6146 seg->s_state = RSM_STATE_CONNECTING; in rsm_connect()
6153 seg->s_adapter = adapter; in rsm_connect()
6155 rsmseglock_release(seg); in rsm_connect()
6161 sharedp = rsmshare_get(msg->key, msg->nodeid, adapter, seg); in rsm_connect()
6163 ASSERT(rsmsharelock_held(seg)); in rsm_connect()
6189 rsmsharelock_release(seg); in rsm_connect()
6190 rsmimport_rm(seg); in rsm_connect()
6191 seg->s_adapter = NULL; in rsm_connect()
6193 seg->s_state = RSM_STATE_NEW; in rsm_connect()
6224 rsmsharelock_release(seg); in rsm_connect()
6230 rsmsharelock_acquire(seg); in rsm_connect()
6231 rsmsharecv_signal(seg, RSMSI_STATE_CONNECTING, in rsm_connect()
6233 rsmsharelock_release(seg); in rsm_connect()
6234 rsmimport_rm(seg); in rsm_connect()
6235 seg->s_adapter = NULL; in rsm_connect()
6237 seg->s_state = RSM_STATE_NEW; in rsm_connect()
6262 rsmsharelock_acquire(seg); in rsm_connect()
6263 rsmsharecv_signal(seg, RSMSI_STATE_CONNECTING, in rsm_connect()
6265 rsmsharelock_release(seg); in rsm_connect()
6266 rsmimport_rm(seg); in rsm_connect()
6267 seg->s_adapter = NULL; in rsm_connect()
6269 seg->s_state = RSM_STATE_NEW; in rsm_connect()
6276 rsmsharelock_acquire(seg); in rsm_connect()
6277 rsmsharecv_signal(seg, RSMSI_STATE_CONNECTING, in rsm_connect()
6279 rsmsharelock_release(seg); in rsm_connect()
6280 rsmimport_rm(seg); in rsm_connect()
6281 seg->s_adapter = NULL; in rsm_connect()
6283 seg->s_state = RSM_STATE_NEW; in rsm_connect()
6290 rsmsharelock_acquire(seg); in rsm_connect()
6299 rsmsharelock_release(seg); in rsm_connect()
6308 rsmseglock_acquire(seg); in rsm_connect()
6309 rsmsharelock_acquire(seg); in rsm_connect()
6310 ASSERT(seg->s_state == RSM_STATE_CONNECTING || in rsm_connect()
6311 seg->s_state == RSM_STATE_ABORT_CONNECT); in rsm_connect()
6315 if ((seg->s_state == RSM_STATE_ABORT_CONNECT) || in rsm_connect()
6317 seg->s_state = RSM_STATE_NEW; in rsm_connect()
6318 seg->s_adapter = NULL; in rsm_connect()
6319 rsmsharelock_release(seg); in rsm_connect()
6320 rsmseglock_release(seg); in rsm_connect()
6321 rsmimport_rm(seg); in rsm_connect()
6324 rsmsharelock_acquire(seg); in rsm_connect()
6331 rsmsharelock_release(seg); in rsm_connect()
6335 rsmsharelock_acquire(seg); in rsm_connect()
6342 rsmsharelock_release(seg); in rsm_connect()
6357 rsmsharelock_release(seg); in rsm_connect()
6358 seg->s_state = RSM_STATE_NEW; in rsm_connect()
6359 seg->s_adapter = NULL; in rsm_connect()
6360 rsmseglock_release(seg); in rsm_connect()
6361 rsmimport_rm(seg); in rsm_connect()
6367 rsmsharelock_acquire(seg); in rsm_connect()
6369 rsmsharelock_release(seg); in rsm_connect()
6374 rsmsharelock_acquire(seg); in rsm_connect()
6378 rsmsharelock_release(seg); in rsm_connect()
6386 seg->s_segid = sharedp->rsmsi_segid; in rsm_connect()
6387 seg->s_len = sharedp->rsmsi_seglen; in rsm_connect()
6388 seg->s_mode = access & sharedp->rsmsi_mode; in rsm_connect()
6389 seg->s_pid = ddi_get_pid(); in rsm_connect()
6390 seg->s_mapinfo = NULL; in rsm_connect()
6392 if (seg->s_node != my_nodeid) { in rsm_connect()
6396 addr, seg->s_segid, &sharedp->rsmsi_handle); in rsm_connect()
6399 seg->s_state = RSM_STATE_NEW; in rsm_connect()
6400 seg->s_adapter = NULL; in rsm_connect()
6401 rsmsharelock_release(seg); in rsm_connect()
6402 rsmseglock_release(seg); in rsm_connect()
6403 rsmimport_rm(seg); in rsm_connect()
6422 rsmsharelock_acquire(seg); in rsm_connect()
6425 rsmsharelock_release(seg); in rsm_connect()
6440 seg->s_handle.in = sharedp->rsmsi_handle; in rsm_connect()
6444 seg->s_state = RSM_STATE_CONNECT; in rsm_connect()
6447 seg->s_flags &= ~RSM_IMPORT_DUMMY; /* clear dummy flag */ in rsm_connect()
6450 atomic_inc_16(bar_va + seg->s_hdr.rsmrc_num); in rsm_connect()
6452 msg->off = (int)seg->s_hdr.rsmrc_num; in rsm_connect()
6460 msg->rnum = seg->s_minor; in rsm_connect()
6461 rsmsharecv_signal(seg, RSMSI_STATE_CONNECTING, RSMSI_STATE_CONNECTED); in rsm_connect()
6462 rsmsharelock_release(seg); in rsm_connect()
6463 rsmseglock_release(seg); in rsm_connect()
6500 rsm_unmap(rsmseg_t *seg) in rsm_unmap() argument
6508 "rsm_unmap enter %u\n", seg->s_segid)); in rsm_unmap()
6510 ASSERT(seg->s_hdr.rsmrc_type == RSM_RESOURCE_IMPORT_SEGMENT); in rsm_unmap()
6513 ASSERT(rsmseglock_held(seg)); in rsm_unmap()
6514 ASSERT(seg->s_state != RSM_STATE_MAPPING); in rsm_unmap()
6516 if ((seg->s_state != RSM_STATE_ACTIVE) && in rsm_unmap()
6517 (seg->s_state != RSM_STATE_MAP_QUIESCE)) { in rsm_unmap()
6523 sharedp = seg->s_share; in rsm_unmap()
6525 rsmsharelock_acquire(seg); in rsm_unmap()
6548 adapter = seg->s_adapter; in rsm_unmap()
6549 if (seg->s_node != my_nodeid) { in rsm_unmap()
6564 rsmsharelock_release(seg); in rsm_unmap()
6579 seg->s_cookie = NULL; in rsm_unmap()
6581 seg->s_mapinfo = NULL; in rsm_unmap()
6583 if (seg->s_state == RSM_STATE_ACTIVE) in rsm_unmap()
6584 seg->s_state = RSM_STATE_CONNECT; in rsm_unmap()
6586 seg->s_state = RSM_STATE_CONN_QUIESCE; in rsm_unmap()
6599 rsm_closeconnection(rsmseg_t *seg, void **cookie) in rsm_closeconnection() argument
6611 ASSERT(seg->s_hdr.rsmrc_type == RSM_RESOURCE_IMPORT_SEGMENT); in rsm_closeconnection()
6614 ASSERT(rsmseglock_held(seg)); in rsm_closeconnection()
6616 if (seg->s_state == RSM_STATE_DISCONNECT) { in rsm_closeconnection()
6623 while (seg->s_rdmacnt > 0) { in rsm_closeconnection()
6624 cv_wait(&seg->s_cv, &seg->s_lock); in rsm_closeconnection()
6627 (void) rsm_unmap(seg); in rsm_closeconnection()
6629 ASSERT(seg->s_state == RSM_STATE_CONNECT || in rsm_closeconnection()
6630 seg->s_state == RSM_STATE_CONN_QUIESCE); in rsm_closeconnection()
6632 adapter = seg->s_adapter; in rsm_closeconnection()
6633 sharedp = seg->s_share; in rsm_closeconnection()
6637 rsmsharelock_acquire(seg); in rsm_closeconnection()
6660 seg->s_key, e)); in rsm_closeconnection()
6665 seg->s_handle.in = NULL; in rsm_closeconnection()
6673 rsmsharelock_release(seg); in rsm_closeconnection()
6681 rsmsharelock_release(seg); in rsm_closeconnection()
6686 atomic_inc_16(bar_va + seg->s_hdr.rsmrc_num); in rsm_closeconnection()
6693 seg->s_share = NULL; in rsm_closeconnection()
6695 seg->s_state = RSM_STATE_DISCONNECT; in rsm_closeconnection()
6697 cv_broadcast(&seg->s_cv); in rsm_closeconnection()
6706 rsm_disconnect(rsmseg_t *seg) in rsm_disconnect() argument
6714 ASSERT(seg->s_hdr.rsmrc_type == RSM_RESOURCE_IMPORT_SEGMENT); in rsm_disconnect()
6717 ASSERT(!rsmseglock_held(seg)); in rsm_disconnect()
6721 rsmimport_rm(seg); in rsm_disconnect()
6724 rsmseglock_acquire(seg); in rsm_disconnect()
6727 while (seg->s_state == RSM_STATE_MAPPING) in rsm_disconnect()
6728 cv_wait(&seg->s_cv, &seg->s_lock); in rsm_disconnect()
6730 if (seg->s_state == RSM_STATE_DISCONNECT) { in rsm_disconnect()
6731 seg->s_state = RSM_STATE_NEW; in rsm_disconnect()
6732 rsmseglock_release(seg); in rsm_disconnect()
6738 (void) rsm_closeconnection(seg, &shared_cookie); in rsm_disconnect()
6741 seg->s_state = RSM_STATE_NEW; in rsm_disconnect()
6749 request.rsmipc_key = seg->s_segid; in rsm_disconnect()
6751 rsmseglock_release(seg); in rsm_disconnect()
6752 (void) rsmipc_send(seg->s_node, &request, RSM_NO_REPLY); in rsm_disconnect()
6754 rsmseglock_release(seg); in rsm_disconnect()
6768 rsmseg_t *seg; in rsm_chpoll() local
6787 seg = (rsmseg_t *)res; in rsm_chpoll()
6789 if (seg->s_pollevent) { in rsm_chpoll()
6797 *phpp = &seg->s_poll; in rsm_chpoll()
6798 seg->s_pollflag |= RSM_SEGMENT_POLL; in rsm_chpoll()
6813 rsmseg_t *seg; in rsmresource_seg() local
6820 seg = (rsmseg_t *)res; in rsmresource_seg()
6823 seg = rsmseg_alloc(rnum, credp); in rsmresource_seg()
6837 seg->s_state = RSM_STATE_NEW_QUIESCED; in rsmresource_seg()
6842 rsmresource_insert(rnum, (rsmresource_t *)seg, type); in rsmresource_seg()
6847 return (seg); in rsmresource_seg()
6851 rsmexport_ioctl(rsmseg_t *seg, rsm_ioctlmsg_t *msg, int cmd, intptr_t arg, in rsmexport_ioctl() argument
6862 ASSERT(seg != NULL); in rsmexport_ioctl()
6866 error = rsm_bind(seg, msg, arg, mode); in rsmexport_ioctl()
6869 error = rsm_rebind(seg, msg); in rsmexport_ioctl()
6875 error = rsm_publish(seg, msg, arg, mode); in rsmexport_ioctl()
6878 error = rsm_republish(seg, msg, mode); in rsmexport_ioctl()
6881 error = rsm_unpublish(seg, 1); in rsmexport_ioctl()
6894 rsmimport_ioctl(rsmseg_t *seg, rsm_ioctlmsg_t *msg, int cmd, intptr_t arg, in rsmimport_ioctl() argument
6902 ASSERT(seg); in rsmimport_ioctl()
6906 error = rsm_connect(seg, msg, credp, arg, mode); in rsmimport_ioctl()
6919 rsmbar_ioctl(rsmseg_t *seg, rsm_ioctlmsg_t *msg, int cmd, intptr_t arg, in rsmbar_ioctl() argument
6929 if ((seg->s_flags & RSM_IMPORT_DUMMY) != 0) { in rsmbar_ioctl()
6933 } else if (seg->s_node == my_nodeid) { in rsmbar_ioctl()
6939 adapter = seg->s_adapter; in rsmbar_ioctl()
7000 exportbell_ioctl(rsmseg_t *seg, int cmd /*ARGSUSED*/) in exportbell_ioctl() argument
7009 request.rsmipc_key = seg->s_segid; in exportbell_ioctl()
7012 e = rsmipc_send(seg->s_node, &request, RSM_NO_REPLY); in exportbell_ioctl()
7024 importbell_ioctl(rsmseg_t *seg, int cmd /*ARGSUSED*/) in importbell_ioctl() argument
7034 ASSERT(seg->s_state != RSM_STATE_NEW && in importbell_ioctl()
7035 seg->s_state != RSM_STATE_NEW_QUIESCED); in importbell_ioctl()
7037 request.rsmipc_key = seg->s_segid; in importbell_ioctl()
7040 index = rsmhash(seg->s_segid); in importbell_ioctl()
7045 if (seg->s_key == token->key) { in importbell_ioctl()
7263 rsmseg_t *seg; in rsm_consumeevent_ioctl() local
7279 seg = (rsmseg_t *)rsmresource_lookup(rnum, RSM_LOCK); in rsm_consumeevent_ioctl()
7280 if (seg) { in rsm_consumeevent_ioctl()
7283 seg)); in rsm_consumeevent_ioctl()
7284 if (seg->s_pollevent) { in rsm_consumeevent_ioctl()
7286 atomic_dec_32(&seg->s_pollevent); in rsm_consumeevent_ioctl()
7289 rsmseglock_release(seg); in rsm_consumeevent_ioctl()
7961 rsmseg_t *seg; in rsm_ioctl() local
8095 seg = rsmresource_seg(res, rnum, credp, in rsm_ioctl()
8097 if (seg->s_type == RSM_RESOURCE_EXPORT_SEGMENT) { in rsm_ioctl()
8098 error = rsmexport_ioctl(seg, &msg, cmd, arg, mode, in rsm_ioctl()
8106 seg = rsmresource_seg(res, rnum, credp, in rsm_ioctl()
8108 if (seg->s_type == RSM_RESOURCE_IMPORT_SEGMENT) { in rsm_ioctl()
8109 error = rsmimport_ioctl(seg, &msg, cmd, arg, mode, in rsm_ioctl()
8148 rsm_get_mapinfo(rsmseg_t *seg, off_t off, size_t len, off_t *dev_offset, in rsm_get_mapinfo() argument
8166 p = seg->s_mapinfo; in rsm_get_mapinfo()
8198 rsmseg_t *seg; in rsmmap_map() local
8213 seg = (rsmseg_t *)res; in rsmmap_map()
8215 rsmseglock_acquire(seg); in rsmmap_map()
8217 ASSERT(seg->s_hdr.rsmrc_type == RSM_RESOURCE_IMPORT_SEGMENT); in rsmmap_map()
8227 p->c_next = seg->s_ckl; in rsmmap_map()
8228 seg->s_ckl = p; in rsmmap_map()
8230 *pvtp = (void *)seg; in rsmmap_map()
8232 rsmseglock_release(seg); in rsmmap_map()
8248 rsmseg_t *seg = (rsmseg_t *)pvt; in rsmmap_access() local
8253 rsmseglock_acquire(seg); in rsmmap_access()
8255 ASSERT(seg->s_hdr.rsmrc_type == RSM_RESOURCE_IMPORT_SEGMENT); in rsmmap_access()
8257 while (seg->s_state == RSM_STATE_MAP_QUIESCE) { in rsmmap_access()
8258 if (cv_wait_sig(&seg->s_cv, &seg->s_lock) == 0) { in rsmmap_access()
8261 rsmseglock_release(seg); in rsmmap_access()
8266 ASSERT(seg->s_state == RSM_STATE_DISCONNECT || in rsmmap_access()
8267 seg->s_state == RSM_STATE_ACTIVE); in rsmmap_access()
8269 if (seg->s_state == RSM_STATE_DISCONNECT) in rsmmap_access()
8270 seg->s_flags |= RSM_IMPORT_DUMMY; in rsmmap_access()
8275 rsmseglock_release(seg); in rsmmap_access()
8291 rsmseg_t *seg = (rsmseg_t *)oldpvt; in rsmmap_dup() local
8302 rsmseglock_acquire(seg); in rsmmap_dup()
8304 ASSERT(seg->s_hdr.rsmrc_type == RSM_RESOURCE_IMPORT_SEGMENT); in rsmmap_dup()
8309 for (old = seg->s_ckl; old != NULL; old = old->c_next) { in rsmmap_dup()
8317 rsmseglock_release(seg); in rsmmap_dup()
8326 p->c_next = seg->s_ckl; in rsmmap_dup()
8327 seg->s_ckl = p; in rsmmap_dup()
8329 *newpvt = (void *)seg; in rsmmap_dup()
8331 rsmseglock_release(seg); in rsmmap_dup()
8346 rsmseg_t *seg = (rsmseg_t *)pvtp; in rsmmap_unmap() local
8356 rsmseglock_acquire(seg); in rsmmap_unmap()
8358 ASSERT(seg->s_hdr.rsmrc_type == RSM_RESOURCE_IMPORT_SEGMENT); in rsmmap_unmap()
8370 rsmcookie_t *tmp, **back = &seg->s_ckl; in rsmmap_unmap()
8393 if ((seg->s_ckl == NULL) && (seg->s_state != RSM_STATE_MAPPING)) in rsmmap_unmap()
8394 (void) rsm_unmap(seg); in rsmmap_unmap()
8396 if (seg->s_state == RSM_STATE_END && seg->s_ckl == NULL) { in rsmmap_unmap()
8402 rsmseglock_release(seg); in rsmmap_unmap()
8406 rsmseg_free(seg); in rsmmap_unmap()
8428 rsmseg_t *seg; in rsm_devmap() local
8438 seg = (rsmseg_t *)rsmresource_lookup(rnum, RSM_NOLOCK); in rsm_devmap()
8439 ASSERT(seg != NULL); in rsm_devmap()
8441 if (seg->s_hdr.rsmrc_type == RSM_RESOURCE_BAR) { in rsm_devmap()
8474 ASSERT(seg->s_hdr.rsmrc_type == RSM_RESOURCE_IMPORT_SEGMENT); in rsm_devmap()
8475 ASSERT(seg->s_state == RSM_STATE_MAPPING); in rsm_devmap()
8481 if (seg->s_mode & RSM_PERM_READ) { in rsm_devmap()
8485 if (seg->s_mode & RSM_PERM_WRITE) { in rsm_devmap()
8500 if (seg->s_node != my_nodeid) { in rsm_devmap()
8503 p = rsm_get_mapinfo(seg, off, len, &dev_offset, &cur_len); in rsm_devmap()
8532 seg->s_cookie, off, len, maxprot, in rsm_devmap()
8562 rsmseg_t *seg, *eseg; in rsm_segmap() local
8573 seg = (rsmseg_t *)rsmresource_lookup(rnum, RSM_LOCK); in rsm_segmap()
8575 if (seg == NULL) { in rsm_segmap()
8586 if (seg->s_hdr.rsmrc_type == RSM_RESOURCE_BAR) { in rsm_segmap()
8587 rsmseglock_release(seg); in rsm_segmap()
8616 if (seg->s_hdr.rsmrc_type != RSM_RESOURCE_IMPORT_SEGMENT) { in rsm_segmap()
8617 rsmseglock_release(seg); in rsm_segmap()
8623 ASSERT(seg->s_hdr.rsmrc_num == rnum); in rsm_segmap()
8626 while (seg->s_state == RSM_STATE_CONN_QUIESCE) { in rsm_segmap()
8627 if (cv_wait_sig(&seg->s_cv, &seg->s_lock) == 0) { in rsm_segmap()
8628 rsmseglock_release(seg); in rsm_segmap()
8636 while (seg->s_state == RSM_STATE_MAPPING) in rsm_segmap()
8637 cv_wait(&seg->s_cv, &seg->s_lock); in rsm_segmap()
8645 if ((seg->s_state != RSM_STATE_CONNECT) && in rsm_segmap()
8646 (seg->s_state != RSM_STATE_ACTIVE)) { in rsm_segmap()
8647 rsmseglock_release(seg); in rsm_segmap()
8657 if ((size_t)off + ptob(btopr(len)) > seg->s_len) { in rsm_segmap()
8658 rsmseglock_release(seg); in rsm_segmap()
8668 if (seg->s_mode & RSM_PERM_READ) { in rsm_segmap()
8672 if (seg->s_mode & RSM_PERM_WRITE) { in rsm_segmap()
8678 rsmseglock_release(seg); in rsm_segmap()
8684 old_state = seg->s_state; in rsm_segmap()
8686 ASSERT(seg->s_share != NULL); in rsm_segmap()
8688 rsmsharelock_acquire(seg); in rsm_segmap()
8690 sharedp = seg->s_share; in rsm_segmap()
8697 rsmsharelock_release(seg); in rsm_segmap()
8698 rsmseglock_release(seg); in rsm_segmap()
8709 if (seg->s_node != my_nodeid) { in rsm_segmap()
8715 size_t length_to_map = seg->s_len; in rsm_segmap()
8725 adapter = seg->s_adapter; in rsm_segmap()
8732 while (total_length_mapped < seg->s_len) { in rsm_segmap()
8736 seg->s_handle.in, tmp_off, in rsm_segmap()
8760 seg->s_mapinfo = sharedp->rsmsi_mapinfo; in rsm_segmap()
8769 (void) seg->s_adapter->rsmpi_ops-> in rsm_segmap()
8776 rsmsharelock_release(seg); in rsm_segmap()
8777 rsmseglock_release(seg); in rsm_segmap()
8796 seg->s_mapinfo = sharedp->rsmsi_mapinfo; in rsm_segmap()
8801 rsmsharelock_release(seg); in rsm_segmap()
8804 seg->s_state = RSM_STATE_MAPPING; in rsm_segmap()
8805 rsmseglock_release(seg); in rsm_segmap()
8810 rsmseglock_acquire(seg); in rsm_segmap()
8811 ASSERT(seg->s_state == RSM_STATE_MAPPING); in rsm_segmap()
8814 seg->s_state = RSM_STATE_ACTIVE; in rsm_segmap()
8816 rsmsharelock_acquire(seg); in rsm_segmap()
8831 rsmsharelock_release(seg); in rsm_segmap()
8832 seg->s_state = old_state; in rsm_segmap()
8836 cv_broadcast(&seg->s_cv); in rsm_segmap()
8837 rsmseglock_release(seg); in rsm_segmap()
8859 rsmsharelock_release(seg); in rsm_segmap()
8880 seg->s_state = RSM_STATE_MAPPING; in rsm_segmap()
8881 rsmseglock_release(seg); in rsm_segmap()
8883 eseg = rsmexport_lookup(seg->s_key); in rsm_segmap()
8886 rsmseglock_acquire(seg); in rsm_segmap()
8892 seg->s_state = old_state; in rsm_segmap()
8893 cv_broadcast(&seg->s_cv); in rsm_segmap()
8894 rsmseglock_release(seg); in rsm_segmap()
8896 "rsm_segmap done: key %d not found\n", seg->s_key)); in rsm_segmap()
8900 rsmsharelock_acquire(seg); in rsm_segmap()
8906 rsmsharelock_release(seg); in rsm_segmap()
8916 seg->s_cookie = eseg->s_cookie; in rsm_segmap()
8923 rsmseglock_acquire(seg); in rsm_segmap()
8924 ASSERT(seg->s_state == RSM_STATE_MAPPING); in rsm_segmap()
8926 seg->s_state = RSM_STATE_ACTIVE; in rsm_segmap()
8928 rsmsharelock_acquire(seg); in rsm_segmap()
8937 rsmsharelock_release(seg); in rsm_segmap()
8938 seg->s_state = old_state; in rsm_segmap()
8939 seg->s_cookie = NULL; in rsm_segmap()
8941 cv_broadcast(&seg->s_cv); in rsm_segmap()
8942 rsmseglock_release(seg); in rsm_segmap()