Lines Matching refs:hc

88 		struct hash_cell *hc = container_of(n, struct hash_cell, name_node);  in __get_name_cell()  local
89 int c = strcmp(hc->name, str); in __get_name_cell()
91 dm_get(hc->md); in __get_name_cell()
92 return hc; in __get_name_cell()
105 struct hash_cell *hc = container_of(n, struct hash_cell, uuid_node); in __get_uuid_cell() local
106 int c = strcmp(hc->uuid, str); in __get_uuid_cell()
108 dm_get(hc->md); in __get_uuid_cell()
109 return hc; in __get_uuid_cell()
117 static void __unlink_name(struct hash_cell *hc) in __unlink_name() argument
119 if (hc->name_set) { in __unlink_name()
120 hc->name_set = false; in __unlink_name()
121 rb_erase(&hc->name_node, &name_rb_tree); in __unlink_name()
125 static void __unlink_uuid(struct hash_cell *hc) in __unlink_uuid() argument
127 if (hc->uuid_set) { in __unlink_uuid()
128 hc->uuid_set = false; in __unlink_uuid()
129 rb_erase(&hc->uuid_node, &uuid_rb_tree); in __unlink_uuid()
145 struct hash_cell *hc = container_of(*n, struct hash_cell, name_node); in __link_name() local
146 int c = strcmp(hc->name, new_hc->name); in __link_name()
149 n = c >= 0 ? &hc->name_node.rb_left : &hc->name_node.rb_right; in __link_name()
168 struct hash_cell *hc = container_of(*n, struct hash_cell, uuid_node); in __link_uuid() local
169 int c = strcmp(hc->uuid, new_hc->uuid); in __link_uuid()
172 n = c > 0 ? &hc->uuid_node.rb_left : &hc->uuid_node.rb_right; in __link_uuid()
182 struct hash_cell *hc; in __get_dev_cell() local
188 hc = dm_get_mdptr(md); in __get_dev_cell()
189 if (!hc) { in __get_dev_cell()
194 return hc; in __get_dev_cell()
203 struct hash_cell *hc; in alloc_cell() local
205 hc = kmalloc(sizeof(*hc), GFP_KERNEL); in alloc_cell()
206 if (!hc) in alloc_cell()
209 hc->name = kstrdup(name, GFP_KERNEL); in alloc_cell()
210 if (!hc->name) { in alloc_cell()
211 kfree(hc); in alloc_cell()
216 hc->uuid = NULL; in alloc_cell()
219 hc->uuid = kstrdup(uuid, GFP_KERNEL); in alloc_cell()
220 if (!hc->uuid) { in alloc_cell()
221 kfree(hc->name); in alloc_cell()
222 kfree(hc); in alloc_cell()
227 hc->name_set = hc->uuid_set = false; in alloc_cell()
228 hc->md = md; in alloc_cell()
229 hc->new_map = NULL; in alloc_cell()
230 return hc; in alloc_cell()
233 static void free_cell(struct hash_cell *hc) in free_cell() argument
235 if (hc) { in free_cell()
236 kfree(hc->name); in free_cell()
237 kfree(hc->uuid); in free_cell()
238 kfree(hc); in free_cell()
248 struct hash_cell *cell, *hc; in dm_hash_insert() local
261 hc = __get_name_cell(name); in dm_hash_insert()
262 if (hc) { in dm_hash_insert()
263 dm_put(hc->md); in dm_hash_insert()
270 hc = __get_uuid_cell(uuid); in dm_hash_insert()
271 if (hc) { in dm_hash_insert()
273 dm_put(hc->md); in dm_hash_insert()
292 static struct dm_table *__hash_remove(struct hash_cell *hc) in __hash_remove() argument
298 __unlink_name(hc); in __hash_remove()
299 __unlink_uuid(hc); in __hash_remove()
301 dm_set_mdptr(hc->md, NULL); in __hash_remove()
304 table = dm_get_live_table(hc->md, &srcu_idx); in __hash_remove()
307 dm_put_live_table(hc->md, srcu_idx); in __hash_remove()
310 if (hc->new_map) in __hash_remove()
311 table = hc->new_map; in __hash_remove()
312 dm_put(hc->md); in __hash_remove()
313 free_cell(hc); in __hash_remove()
322 struct hash_cell *hc; in dm_hash_remove_all() local
332 hc = container_of(n, struct hash_cell, name_node); in dm_hash_remove_all()
333 md = hc->md; in dm_hash_remove_all()
343 t = __hash_remove(hc); in dm_hash_remove_all()
376 static void __set_cell_uuid(struct hash_cell *hc, char *new_uuid) in __set_cell_uuid() argument
379 hc->uuid = new_uuid; in __set_cell_uuid()
382 __link_uuid(hc); in __set_cell_uuid()
389 static char *__change_cell_name(struct hash_cell *hc, char *new_name) in __change_cell_name() argument
396 __unlink_name(hc); in __change_cell_name()
397 old_name = hc->name; in __change_cell_name()
400 hc->name = new_name; in __change_cell_name()
403 __link_name(hc); in __change_cell_name()
412 struct hash_cell *hc; in dm_hash_rename() local
431 hc = __get_uuid_cell(new); in dm_hash_rename()
433 hc = __get_name_cell(new); in dm_hash_rename()
435 if (hc) { in dm_hash_rename()
440 dm_put(hc->md); in dm_hash_rename()
449 hc = __get_name_cell(param->name); in dm_hash_rename()
450 if (!hc) { in dm_hash_rename()
461 if (change_uuid && hc->uuid) { in dm_hash_rename()
464 param->name, new, hc->uuid); in dm_hash_rename()
465 dm_put(hc->md); in dm_hash_rename()
472 __set_cell_uuid(hc, new_data); in dm_hash_rename()
474 old_name = __change_cell_name(hc, new_data); in dm_hash_rename()
479 table = dm_get_live_table(hc->md, &srcu_idx); in dm_hash_rename()
482 dm_put_live_table(hc->md, srcu_idx); in dm_hash_rename()
484 if (!dm_kobject_uevent(hc->md, KOBJ_CHANGE, param->event_nr)) in dm_hash_rename()
487 md = hc->md; in dm_hash_rename()
548 static bool filter_device(struct hash_cell *hc, const char *pfx_name, const char *pfx_uuid) in filter_device() argument
553 val = hc->name; in filter_device()
561 val = hc->uuid ? hc->uuid : ""; in filter_device()
575 struct hash_cell *hc; in list_devices() local
588 hc = container_of(n, struct hash_cell, name_node); in list_devices()
589 if (!filter_device(hc, param->name, param->uuid)) in list_devices()
591 needed += align_val(offsetof(struct dm_name_list, name) + strlen(hc->name) + 1); in list_devices()
593 if (param->flags & DM_UUID_FLAG && hc->uuid) in list_devices()
594 needed += align_val(strlen(hc->uuid) + 1); in list_devices()
614 hc = container_of(n, struct hash_cell, name_node); in list_devices()
615 if (!filter_device(hc, param->name, param->uuid)) in list_devices()
620 disk = dm_disk(hc->md); in list_devices()
623 strcpy(nl->name, hc->name); in list_devices()
626 event_nr = align_ptr(nl->name + strlen(hc->name) + 1); in list_devices()
627 event_nr[0] = dm_get_event_nr(hc->md); in list_devices()
631 if (hc->uuid) { in list_devices()
633 strcpy(uuid_ptr, hc->uuid); in list_devices()
634 uuid_ptr = align_ptr(uuid_ptr + strlen(hc->uuid) + 1); in list_devices()
766 struct hash_cell *hc; in dm_get_inactive_table() local
773 hc = dm_get_mdptr(md); in dm_get_inactive_table()
774 if (!hc || hc->md != md) { in dm_get_inactive_table()
779 table = hc->new_map; in dm_get_inactive_table()
890 struct hash_cell *hc = NULL; in __find_device_hash_cell() local
896 hc = __get_uuid_cell(param->uuid); in __find_device_hash_cell()
897 if (!hc) in __find_device_hash_cell()
903 hc = __get_name_cell(param->name); in __find_device_hash_cell()
904 if (!hc) in __find_device_hash_cell()
907 hc = __get_dev_cell(param->dev); in __find_device_hash_cell()
908 if (!hc) in __find_device_hash_cell()
917 strlcpy(param->name, hc->name, sizeof(param->name)); in __find_device_hash_cell()
918 if (hc->uuid) in __find_device_hash_cell()
919 strlcpy(param->uuid, hc->uuid, sizeof(param->uuid)); in __find_device_hash_cell()
923 if (hc->new_map) in __find_device_hash_cell()
928 return hc; in __find_device_hash_cell()
933 struct hash_cell *hc; in find_device() local
937 hc = __find_device_hash_cell(param); in find_device()
938 if (hc) in find_device()
939 md = hc->md; in find_device()
947 struct hash_cell *hc; in dev_remove() local
953 hc = __find_device_hash_cell(param); in dev_remove()
955 if (!hc) { in dev_remove()
961 md = hc->md; in dev_remove()
973 DMDEBUG_LIMIT("unable to remove open device %s", hc->name); in dev_remove()
979 t = __hash_remove(hc); in dev_remove()
1122 struct hash_cell *hc; in do_resume() local
1128 hc = __find_device_hash_cell(param); in do_resume()
1129 if (!hc) { in do_resume()
1135 md = hc->md; in do_resume()
1137 new_map = hc->new_map; in do_resume()
1138 hc->new_map = NULL; in do_resume()
1422 struct hash_cell *hc; in table_load() local
1471 hc = dm_get_mdptr(md); in table_load()
1472 if (!hc || hc->md != md) { in table_load()
1479 if (hc->new_map) in table_load()
1480 old_map = hc->new_map; in table_load()
1481 hc->new_map = t; in table_load()
1508 struct hash_cell *hc; in table_clear() local
1515 hc = __find_device_hash_cell(param); in table_clear()
1516 if (!hc) { in table_clear()
1522 if (hc->new_map) { in table_clear()
1523 old_map = hc->new_map; in table_clear()
1524 hc->new_map = NULL; in table_clear()
1530 __dev_status(hc->md, param); in table_clear()
1531 md = hc->md; in table_clear()
2113 struct hash_cell *hc; in dm_copy_name_and_uuid() local
2119 hc = dm_get_mdptr(md); in dm_copy_name_and_uuid()
2120 if (!hc || hc->md != md) { in dm_copy_name_and_uuid()
2126 strcpy(name, hc->name); in dm_copy_name_and_uuid()
2128 strcpy(uuid, hc->uuid ? : ""); in dm_copy_name_and_uuid()