Lines Matching defs:mdeg

37 #include <sys/mdeg.h>
59 * mdeg.lock - lock used to synchronize system-wide MD updates. An
64 * mdeg.rwlock - lock used to synchronize access to the table of
69 static struct mdeg {
79 } mdeg;
145 if ((mdeg.md_curr = md_get_handle()) == NULL) {
153 mdeg.maxclnts = MDEG_MAX_CLNTS_INIT;
155 tblsz = mdeg.maxclnts * sizeof (mdeg_clnt_t);
156 mdeg.tbl = kmem_zalloc(tblsz, KM_SLEEP);
158 rw_init(&mdeg.rwlock, NULL, RW_DRIVER, NULL);
160 mdeg.nclnts = 0;
165 mutex_init(&mdeg.lock, NULL, MUTEX_DRIVER, NULL);
170 mdeg.taskq = taskq_create("mdeg_taskq", 1, minclsyspri, 1,
174 mdeg.enabled = B_TRUE;
187 mdeg.enabled = B_FALSE;
190 taskq_destroy(mdeg.taskq);
195 kmem_free(mdeg.tbl, mdeg.maxclnts * sizeof (mdeg_clnt_t));
196 rw_destroy(&mdeg.rwlock);
201 if (mdeg.md_curr)
202 (void) md_fini_handle(mdeg.md_curr);
204 if (mdeg.md_prev)
205 (void) md_fini_handle(mdeg.md_prev);
207 mutex_destroy(&mdeg.lock);
220 ASSERT(RW_WRITE_HELD(&mdeg.rwlock));
223 for (idx = 0; idx < mdeg.maxclnts; idx++) {
224 clnt = &mdeg.tbl[idx];
231 if (idx != mdeg.maxclnts) {
243 newmaxclnts = mdeg.maxclnts * 2;
249 oldtblsz = mdeg.maxclnts * sizeof (mdeg_clnt_t);
250 bcopy(mdeg.tbl, newtbl, oldtblsz);
257 clnt = &newtbl[mdeg.maxclnts];
260 kmem_free(mdeg.tbl, oldtblsz);
261 mdeg.tbl = newtbl;
262 mdeg.maxclnts = newmaxclnts;
281 if ((idx < 0) || (idx >= mdeg.maxclnts)) {
286 clnt = &mdeg.tbl[idx];
328 mutex_enter(&mdeg.lock);
393 mutex_exit(&mdeg.lock);
426 ASSERT(!taskq_member(mdeg.taskq, curthread));
435 rw_enter(&mdeg.rwlock, RW_WRITER);
456 mdeg.nclnts++;
460 rw_exit(&mdeg.rwlock);
464 rw_exit(&mdeg.rwlock);
478 ASSERT(!taskq_member(mdeg.taskq, curthread));
480 rw_enter(&mdeg.rwlock, RW_WRITER);
484 rw_exit(&mdeg.rwlock);
497 mdeg.nclnts--;
499 rw_exit(&mdeg.rwlock);
519 rw_enter(&mdeg.rwlock, RW_READER);
520 mutex_enter(&mdeg.lock);
530 if (mdeg.md_prev) {
531 (void) md_fini_handle(mdeg.md_prev);
534 mdeg.md_prev = mdeg.md_curr;
535 mdeg.md_curr = md_new;
537 if (mdeg.nclnts == 0) {
543 for (idx = 0, nclnt = 0; idx < mdeg.maxclnts; idx++) {
544 clnt = &mdeg.tbl[idx];
550 ++nclnt, mdeg.nclnts);
552 (void) taskq_dispatch(mdeg.taskq, mdeg_notify_client,
558 * finish while we are still holding mdeg.rwlock.
560 taskq_wait(mdeg.taskq);
563 mutex_exit(&mdeg.lock);
564 rw_exit(&mdeg.rwlock);
577 * mdeg.rwlock must be held as a reader while this function
590 ASSERT(RW_READ_HELD(&mdeg.rwlock));
592 if (!mdeg.enabled) {
594 MDEG_DBG("mdeg_notify_client: mdeg disabled, aborting\n");
612 md_prev_start = mdeg_find_start_node(mdeg.md_prev, clnt->pspec);
617 md_curr_start = mdeg_find_start_node(mdeg.md_curr, clnt->pspec);
623 mdd = md_diff_init(mdeg.md_prev, md_prev_start, mdeg.md_curr,
735 res->added.mdp = mdeg.md_curr;
745 res->removed.mdp = mdeg.md_prev;
755 res->match_curr.mdp = mdeg.md_curr;
756 res->match_prev.mdp = mdeg.md_prev;
915 for (idx = 0; idx < mdeg.maxclnts; idx++) {
916 clnt = &(mdeg.tbl[idx]);