Lines Matching refs:hc

94 		struct hash_cell *hc = container_of(n, struct hash_cell, name_node);  in __get_name_cell()  local
97 c = strcmp(hc->name, str); in __get_name_cell()
99 dm_get(hc->md); in __get_name_cell()
100 return hc; in __get_name_cell()
113 struct hash_cell *hc = container_of(n, struct hash_cell, uuid_node); in __get_uuid_cell() local
116 c = strcmp(hc->uuid, str); in __get_uuid_cell()
118 dm_get(hc->md); in __get_uuid_cell()
119 return hc; in __get_uuid_cell()
127 static void __unlink_name(struct hash_cell *hc) in __unlink_name() argument
129 if (hc->name_set) { in __unlink_name()
130 hc->name_set = false; in __unlink_name()
131 rb_erase(&hc->name_node, &name_rb_tree); in __unlink_name()
135 static void __unlink_uuid(struct hash_cell *hc) in __unlink_uuid() argument
137 if (hc->uuid_set) { in __unlink_uuid()
138 hc->uuid_set = false; in __unlink_uuid()
139 rb_erase(&hc->uuid_node, &uuid_rb_tree); in __unlink_uuid()
155 struct hash_cell *hc = container_of(*n, struct hash_cell, name_node); in __link_name() local
158 c = strcmp(hc->name, new_hc->name); in __link_name()
161 n = c >= 0 ? &hc->name_node.rb_left : &hc->name_node.rb_right; in __link_name()
180 struct hash_cell *hc = container_of(*n, struct hash_cell, uuid_node); in __link_uuid() local
183 c = strcmp(hc->uuid, new_hc->uuid); in __link_uuid()
186 n = c > 0 ? &hc->uuid_node.rb_left : &hc->uuid_node.rb_right; in __link_uuid()
196 struct hash_cell *hc; in __get_dev_cell() local
202 hc = dm_get_mdptr(md); in __get_dev_cell()
203 if (!hc) { in __get_dev_cell()
208 return hc; in __get_dev_cell()
219 struct hash_cell *hc; in alloc_cell() local
221 hc = kmalloc(sizeof(*hc), GFP_KERNEL); in alloc_cell()
222 if (!hc) in alloc_cell()
225 hc->name = kstrdup(name, GFP_KERNEL); in alloc_cell()
226 if (!hc->name) { in alloc_cell()
227 kfree(hc); in alloc_cell()
232 hc->uuid = NULL; in alloc_cell()
235 hc->uuid = kstrdup(uuid, GFP_KERNEL); in alloc_cell()
236 if (!hc->uuid) { in alloc_cell()
237 kfree(hc->name); in alloc_cell()
238 kfree(hc); in alloc_cell()
243 hc->name_set = hc->uuid_set = false; in alloc_cell()
244 hc->md = md; in alloc_cell()
245 hc->new_map = NULL; in alloc_cell()
246 return hc; in alloc_cell()
249 static void free_cell(struct hash_cell *hc) in free_cell() argument
251 if (hc) { in free_cell()
252 kfree(hc->name); in free_cell()
253 kfree(hc->uuid); in free_cell()
254 kfree(hc); in free_cell()
264 struct hash_cell *cell, *hc; in dm_hash_insert() local
277 hc = __get_name_cell(name); in dm_hash_insert()
278 if (hc) { in dm_hash_insert()
279 dm_put(hc->md); in dm_hash_insert()
286 hc = __get_uuid_cell(uuid); in dm_hash_insert()
287 if (hc) { in dm_hash_insert()
289 dm_put(hc->md); in dm_hash_insert()
308 static struct dm_table *__hash_remove(struct hash_cell *hc) in __hash_remove() argument
316 __unlink_name(hc); in __hash_remove()
317 __unlink_uuid(hc); in __hash_remove()
319 dm_set_mdptr(hc->md, NULL); in __hash_remove()
322 table = dm_get_live_table(hc->md, &srcu_idx); in __hash_remove()
325 dm_put_live_table(hc->md, srcu_idx); in __hash_remove()
328 if (hc->new_map) in __hash_remove()
329 table = hc->new_map; in __hash_remove()
330 dm_put(hc->md); in __hash_remove()
331 free_cell(hc); in __hash_remove()
340 struct hash_cell *hc; in dm_hash_remove_all() local
350 hc = container_of(n, struct hash_cell, name_node); in dm_hash_remove_all()
351 md = hc->md; in dm_hash_remove_all()
361 t = __hash_remove(hc); in dm_hash_remove_all()
394 static void __set_cell_uuid(struct hash_cell *hc, char *new_uuid) in __set_cell_uuid() argument
397 hc->uuid = new_uuid; in __set_cell_uuid()
400 __link_uuid(hc); in __set_cell_uuid()
407 static char *__change_cell_name(struct hash_cell *hc, char *new_name) in __change_cell_name() argument
414 __unlink_name(hc); in __change_cell_name()
415 old_name = hc->name; in __change_cell_name()
418 hc->name = new_name; in __change_cell_name()
421 __link_name(hc); in __change_cell_name()
430 struct hash_cell *hc; in dm_hash_rename() local
449 hc = __get_uuid_cell(new); in dm_hash_rename()
451 hc = __get_name_cell(new); in dm_hash_rename()
453 if (hc) { in dm_hash_rename()
457 dm_put(hc->md); in dm_hash_rename()
466 hc = __get_name_cell(param->name); in dm_hash_rename()
467 if (!hc) { in dm_hash_rename()
478 if (change_uuid && hc->uuid) { in dm_hash_rename()
481 param->name, new, hc->uuid); in dm_hash_rename()
482 dm_put(hc->md); in dm_hash_rename()
489 __set_cell_uuid(hc, new_data); in dm_hash_rename()
491 old_name = __change_cell_name(hc, new_data); in dm_hash_rename()
496 table = dm_get_live_table(hc->md, &srcu_idx); in dm_hash_rename()
499 dm_put_live_table(hc->md, srcu_idx); in dm_hash_rename()
501 if (!dm_kobject_uevent(hc->md, KOBJ_CHANGE, param->event_nr, false)) in dm_hash_rename()
504 md = hc->md; in dm_hash_rename()
567 static bool filter_device(struct hash_cell *hc, const char *pfx_name, const char *pfx_uuid) in filter_device() argument
572 val = hc->name; in filter_device()
580 val = hc->uuid ? hc->uuid : ""; in filter_device()
594 struct hash_cell *hc; in list_devices() local
607 hc = container_of(n, struct hash_cell, name_node); in list_devices()
608 if (!filter_device(hc, param->name, param->uuid)) in list_devices()
610 needed += align_val(offsetof(struct dm_name_list, name) + strlen(hc->name) + 1); in list_devices()
612 if (param->flags & DM_UUID_FLAG && hc->uuid) in list_devices()
613 needed += align_val(strlen(hc->uuid) + 1); in list_devices()
634 hc = container_of(n, struct hash_cell, name_node); in list_devices()
635 if (!filter_device(hc, param->name, param->uuid)) in list_devices()
640 disk = dm_disk(hc->md); in list_devices()
643 strcpy(nl->name, hc->name); in list_devices()
646 event_nr = align_ptr(nl->name + strlen(hc->name) + 1); in list_devices()
647 event_nr[0] = dm_get_event_nr(hc->md); in list_devices()
651 if (hc->uuid) { in list_devices()
653 strcpy(uuid_ptr, hc->uuid); in list_devices()
654 uuid_ptr = align_ptr(uuid_ptr + strlen(hc->uuid) + 1); in list_devices()
791 struct hash_cell *hc; in dm_get_inactive_table() local
798 hc = dm_get_mdptr(md); in dm_get_inactive_table()
799 if (!hc) { in dm_get_inactive_table()
804 table = hc->new_map; in dm_get_inactive_table()
916 struct hash_cell *hc = NULL; in __find_device_hash_cell() local
925 hc = __get_uuid_cell(param->uuid); in __find_device_hash_cell()
926 if (!hc) in __find_device_hash_cell()
935 hc = __get_name_cell(param->name); in __find_device_hash_cell()
936 if (!hc) in __find_device_hash_cell()
939 hc = __get_dev_cell(param->dev); in __find_device_hash_cell()
940 if (!hc) in __find_device_hash_cell()
949 strscpy(param->name, hc->name, sizeof(param->name)); in __find_device_hash_cell()
950 if (hc->uuid) in __find_device_hash_cell()
951 strscpy(param->uuid, hc->uuid, sizeof(param->uuid)); in __find_device_hash_cell()
955 if (hc->new_map) in __find_device_hash_cell()
960 return hc; in __find_device_hash_cell()
965 struct hash_cell *hc; in find_device() local
969 hc = __find_device_hash_cell(param); in find_device()
970 if (hc) in find_device()
971 md = hc->md; in find_device()
979 struct hash_cell *hc; in dev_remove() local
985 hc = __find_device_hash_cell(param); in dev_remove()
987 if (!hc) { in dev_remove()
993 md = hc->md; in dev_remove()
1005 DMDEBUG_LIMIT("unable to remove open device %s", hc->name); in dev_remove()
1011 t = __hash_remove(hc); in dev_remove()
1153 struct hash_cell *hc; in do_resume() local
1160 hc = __find_device_hash_cell(param); in do_resume()
1161 if (!hc) { in do_resume()
1167 md = hc->md; in do_resume()
1169 new_map = hc->new_map; in do_resume()
1170 hc->new_map = NULL; in do_resume()
1188 hc = dm_get_mdptr(md); in do_resume()
1189 if (hc && !hc->new_map) { in do_resume()
1190 hc->new_map = new_map; in do_resume()
1517 struct hash_cell *hc; in table_load() local
1566 hc = dm_get_mdptr(md); in table_load()
1567 if (!hc) { in table_load()
1574 if (hc->new_map) in table_load()
1575 old_map = hc->new_map; in table_load()
1576 hc->new_map = t; in table_load()
1603 struct hash_cell *hc; in table_clear() local
1610 hc = __find_device_hash_cell(param); in table_clear()
1611 if (!hc) { in table_clear()
1617 if (hc->new_map) { in table_clear()
1618 old_map = hc->new_map; in table_clear()
1619 hc->new_map = NULL; in table_clear()
1623 md = hc->md; in table_clear()
2225 struct hash_cell *hc; in dm_copy_name_and_uuid() local
2231 hc = dm_get_mdptr(md); in dm_copy_name_and_uuid()
2232 if (!hc) { in dm_copy_name_and_uuid()
2238 strcpy(name, hc->name); in dm_copy_name_and_uuid()
2240 strcpy(uuid, hc->uuid ? : ""); in dm_copy_name_and_uuid()