Lines Matching refs:head
67 dm_table_busy(dm_table_head_t *head, uint8_t table_id)
71 mutex_enter(&head->table_mtx);
74 id = head->cur_active_table;
76 id = 1 - head->cur_active_table;
78 head->io_cnt++;
80 mutex_exit(&head->table_mtx);
88 dm_table_unbusy(dm_table_head_t *head)
91 KASSERT(head->io_cnt != 0);
93 mutex_enter(&head->table_mtx);
95 if (--head->io_cnt == 0)
96 cv_broadcast(&head->table_cv);
98 mutex_exit(&head->table_mtx);
105 dm_table_get_entry(dm_table_head_t *head, uint8_t table_id)
109 id = dm_table_busy(head, table_id);
111 return &head->tables[id];
117 dm_table_release(dm_table_head_t *head, uint8_t table_id)
120 dm_table_unbusy(head);
127 dm_table_switch_tables(dm_table_head_t *head)
130 mutex_enter(&head->table_mtx);
132 while (head->io_cnt != 0)
133 cv_wait(&head->table_cv, &head->table_mtx);
135 head->cur_active_table = 1 - head->cur_active_table;
137 mutex_exit(&head->table_mtx);
147 dm_table_destroy(dm_table_head_t *head, uint8_t table_id)
153 mutex_enter(&head->table_mtx);
155 aprint_debug("dm_Table_destroy called with %d--%d\n", table_id, head->io_cnt);
157 while (head->io_cnt != 0)
158 cv_wait(&head->table_cv, &head->table_mtx);
161 id = head->cur_active_table;
163 id = 1 - head->cur_active_table;
165 tbl = &head->tables[id];
176 mutex_exit(&head->table_mtx);
185 dm_table_size_impl(dm_table_head_t *head, int table)
194 id = dm_table_busy(head, table);
197 tbl = &head->tables[id];
206 dm_table_unbusy(head);
215 dm_table_size(dm_table_head_t *head)
218 return dm_table_size_impl(head, DM_TABLE_ACTIVE);
225 dm_inactive_table_size(dm_table_head_t *head)
228 return dm_table_size_impl(head, DM_TABLE_INACTIVE);
235 dm_table_disksize(dm_table_head_t *head, uint64_t *numsecp,
246 id = dm_table_busy(head, DM_TABLE_ACTIVE);
249 tbl = &head->tables[id];
271 dm_table_unbusy(head);
281 dm_table_get_target_count(dm_table_head_t *head, uint8_t table_id)
290 id = dm_table_busy(head, table_id);
291 tbl = &head->tables[id];
296 dm_table_unbusy(head);
306 dm_table_head_init(dm_table_head_t *head)
309 head->cur_active_table = 0;
310 head->io_cnt = 0;
313 SLIST_INIT(&head->tables[0]);
314 SLIST_INIT(&head->tables[1]);
316 mutex_init(&head->table_mtx, MUTEX_DEFAULT, IPL_NONE);
317 cv_init(&head->table_cv, "dm_io");
324 dm_table_head_destroy(dm_table_head_t *head)
327 KASSERT(!mutex_owned(&head->table_mtx));
328 KASSERT(!cv_has_waiters(&head->table_cv));
331 KASSERT(head->io_cnt == 0);
333 cv_destroy(&head->table_cv);
334 mutex_destroy(&head->table_mtx);
340 dm_table_head_t *head;
346 head = &table_en->dm_dev->table_head;
347 mutex_enter(&head->table_mtx);
352 mutex_exit(&head->table_mtx);
362 mutex_exit(&head->table_mtx);