Lines Matching refs:hc
89 struct hash_cell *hc = container_of(n, struct hash_cell, name_node); in __get_name_cell() local
90 int c = strcmp(hc->name, str); in __get_name_cell()
92 dm_get(hc->md); in __get_name_cell()
93 return hc; in __get_name_cell()
106 struct hash_cell *hc = container_of(n, struct hash_cell, uuid_node); in __get_uuid_cell() local
107 int c = strcmp(hc->uuid, str); in __get_uuid_cell()
109 dm_get(hc->md); in __get_uuid_cell()
110 return hc; in __get_uuid_cell()
118 static void __unlink_name(struct hash_cell *hc) in __unlink_name() argument
120 if (hc->name_set) { in __unlink_name()
121 hc->name_set = false; in __unlink_name()
122 rb_erase(&hc->name_node, &name_rb_tree); in __unlink_name()
126 static void __unlink_uuid(struct hash_cell *hc) in __unlink_uuid() argument
128 if (hc->uuid_set) { in __unlink_uuid()
129 hc->uuid_set = false; in __unlink_uuid()
130 rb_erase(&hc->uuid_node, &uuid_rb_tree); in __unlink_uuid()
146 struct hash_cell *hc = container_of(*n, struct hash_cell, name_node); in __link_name() local
147 int c = strcmp(hc->name, new_hc->name); in __link_name()
150 n = c >= 0 ? &hc->name_node.rb_left : &hc->name_node.rb_right; in __link_name()
169 struct hash_cell *hc = container_of(*n, struct hash_cell, uuid_node); in __link_uuid() local
170 int c = strcmp(hc->uuid, new_hc->uuid); in __link_uuid()
173 n = c > 0 ? &hc->uuid_node.rb_left : &hc->uuid_node.rb_right; in __link_uuid()
183 struct hash_cell *hc; in __get_dev_cell() local
189 hc = dm_get_mdptr(md); in __get_dev_cell()
190 if (!hc) { in __get_dev_cell()
195 return hc; in __get_dev_cell()
204 struct hash_cell *hc; in alloc_cell() local
206 hc = kmalloc(sizeof(*hc), GFP_KERNEL); in alloc_cell()
207 if (!hc) in alloc_cell()
210 hc->name = kstrdup(name, GFP_KERNEL); in alloc_cell()
211 if (!hc->name) { in alloc_cell()
212 kfree(hc); in alloc_cell()
217 hc->uuid = NULL; in alloc_cell()
220 hc->uuid = kstrdup(uuid, GFP_KERNEL); in alloc_cell()
221 if (!hc->uuid) { in alloc_cell()
222 kfree(hc->name); in alloc_cell()
223 kfree(hc); in alloc_cell()
228 hc->name_set = hc->uuid_set = false; in alloc_cell()
229 hc->md = md; in alloc_cell()
230 hc->new_map = NULL; in alloc_cell()
231 return hc; in alloc_cell()
234 static void free_cell(struct hash_cell *hc) in free_cell() argument
236 if (hc) { in free_cell()
237 kfree(hc->name); in free_cell()
238 kfree(hc->uuid); in free_cell()
239 kfree(hc); in free_cell()
249 struct hash_cell *cell, *hc; in dm_hash_insert() local
262 hc = __get_name_cell(name); in dm_hash_insert()
263 if (hc) { in dm_hash_insert()
264 dm_put(hc->md); in dm_hash_insert()
271 hc = __get_uuid_cell(uuid); in dm_hash_insert()
272 if (hc) { in dm_hash_insert()
274 dm_put(hc->md); in dm_hash_insert()
293 static struct dm_table *__hash_remove(struct hash_cell *hc) in __hash_remove() argument
299 __unlink_name(hc); in __hash_remove()
300 __unlink_uuid(hc); in __hash_remove()
302 dm_set_mdptr(hc->md, NULL); in __hash_remove()
305 table = dm_get_live_table(hc->md, &srcu_idx); in __hash_remove()
308 dm_put_live_table(hc->md, srcu_idx); in __hash_remove()
311 if (hc->new_map) in __hash_remove()
312 table = hc->new_map; in __hash_remove()
313 dm_put(hc->md); in __hash_remove()
314 free_cell(hc); in __hash_remove()
323 struct hash_cell *hc; in dm_hash_remove_all() local
333 hc = container_of(n, struct hash_cell, name_node); in dm_hash_remove_all()
334 md = hc->md; in dm_hash_remove_all()
344 t = __hash_remove(hc); in dm_hash_remove_all()
377 static void __set_cell_uuid(struct hash_cell *hc, char *new_uuid) in __set_cell_uuid() argument
380 hc->uuid = new_uuid; in __set_cell_uuid()
383 __link_uuid(hc); in __set_cell_uuid()
390 static char *__change_cell_name(struct hash_cell *hc, char *new_name) in __change_cell_name() argument
397 __unlink_name(hc); in __change_cell_name()
398 old_name = hc->name; in __change_cell_name()
401 hc->name = new_name; in __change_cell_name()
404 __link_name(hc); in __change_cell_name()
413 struct hash_cell *hc; in dm_hash_rename() local
432 hc = __get_uuid_cell(new); in dm_hash_rename()
434 hc = __get_name_cell(new); in dm_hash_rename()
436 if (hc) { in dm_hash_rename()
441 dm_put(hc->md); in dm_hash_rename()
450 hc = __get_name_cell(param->name); in dm_hash_rename()
451 if (!hc) { in dm_hash_rename()
462 if (change_uuid && hc->uuid) { in dm_hash_rename()
465 param->name, new, hc->uuid); in dm_hash_rename()
466 dm_put(hc->md); in dm_hash_rename()
473 __set_cell_uuid(hc, new_data); in dm_hash_rename()
475 old_name = __change_cell_name(hc, new_data); in dm_hash_rename()
480 table = dm_get_live_table(hc->md, &srcu_idx); in dm_hash_rename()
483 dm_put_live_table(hc->md, srcu_idx); in dm_hash_rename()
485 if (!dm_kobject_uevent(hc->md, KOBJ_CHANGE, param->event_nr)) in dm_hash_rename()
488 md = hc->md; in dm_hash_rename()
549 static bool filter_device(struct hash_cell *hc, const char *pfx_name, const char *pfx_uuid) in filter_device() argument
554 val = hc->name; in filter_device()
562 val = hc->uuid ? hc->uuid : ""; in filter_device()
576 struct hash_cell *hc; in list_devices() local
589 hc = container_of(n, struct hash_cell, name_node); in list_devices()
590 if (!filter_device(hc, param->name, param->uuid)) in list_devices()
592 needed += align_val(offsetof(struct dm_name_list, name) + strlen(hc->name) + 1); in list_devices()
594 if (param->flags & DM_UUID_FLAG && hc->uuid) in list_devices()
595 needed += align_val(strlen(hc->uuid) + 1); in list_devices()
615 hc = container_of(n, struct hash_cell, name_node); in list_devices()
616 if (!filter_device(hc, param->name, param->uuid)) in list_devices()
621 disk = dm_disk(hc->md); in list_devices()
624 strcpy(nl->name, hc->name); in list_devices()
627 event_nr = align_ptr(nl->name + strlen(hc->name) + 1); in list_devices()
628 event_nr[0] = dm_get_event_nr(hc->md); in list_devices()
632 if (hc->uuid) { in list_devices()
634 strcpy(uuid_ptr, hc->uuid); in list_devices()
635 uuid_ptr = align_ptr(uuid_ptr + strlen(hc->uuid) + 1); in list_devices()
767 struct hash_cell *hc; in dm_get_inactive_table() local
774 hc = dm_get_mdptr(md); in dm_get_inactive_table()
775 if (!hc || hc->md != md) { in dm_get_inactive_table()
780 table = hc->new_map; in dm_get_inactive_table()
891 struct hash_cell *hc = NULL; in __find_device_hash_cell() local
900 hc = __get_uuid_cell(param->uuid); in __find_device_hash_cell()
901 if (!hc) in __find_device_hash_cell()
910 hc = __get_name_cell(param->name); in __find_device_hash_cell()
911 if (!hc) in __find_device_hash_cell()
914 hc = __get_dev_cell(param->dev); in __find_device_hash_cell()
915 if (!hc) in __find_device_hash_cell()
924 strlcpy(param->name, hc->name, sizeof(param->name)); in __find_device_hash_cell()
925 if (hc->uuid) in __find_device_hash_cell()
926 strlcpy(param->uuid, hc->uuid, sizeof(param->uuid)); in __find_device_hash_cell()
930 if (hc->new_map) in __find_device_hash_cell()
935 return hc; in __find_device_hash_cell()
940 struct hash_cell *hc; in find_device() local
944 hc = __find_device_hash_cell(param); in find_device()
945 if (hc) in find_device()
946 md = hc->md; in find_device()
954 struct hash_cell *hc; in dev_remove() local
960 hc = __find_device_hash_cell(param); in dev_remove()
962 if (!hc) { in dev_remove()
968 md = hc->md; in dev_remove()
980 DMDEBUG_LIMIT("unable to remove open device %s", hc->name); in dev_remove()
986 t = __hash_remove(hc); in dev_remove()
1129 struct hash_cell *hc; in do_resume() local
1135 hc = __find_device_hash_cell(param); in do_resume()
1136 if (!hc) { in do_resume()
1142 md = hc->md; in do_resume()
1144 new_map = hc->new_map; in do_resume()
1145 hc->new_map = NULL; in do_resume()
1429 struct hash_cell *hc; in table_load() local
1478 hc = dm_get_mdptr(md); in table_load()
1479 if (!hc || hc->md != md) { in table_load()
1486 if (hc->new_map) in table_load()
1487 old_map = hc->new_map; in table_load()
1488 hc->new_map = t; in table_load()
1515 struct hash_cell *hc; in table_clear() local
1522 hc = __find_device_hash_cell(param); in table_clear()
1523 if (!hc) { in table_clear()
1529 if (hc->new_map) { in table_clear()
1530 old_map = hc->new_map; in table_clear()
1531 hc->new_map = NULL; in table_clear()
1537 __dev_status(hc->md, param); in table_clear()
1538 md = hc->md; in table_clear()
2124 struct hash_cell *hc; in dm_copy_name_and_uuid() local
2130 hc = dm_get_mdptr(md); in dm_copy_name_and_uuid()
2131 if (!hc || hc->md != md) { in dm_copy_name_and_uuid()
2137 strcpy(name, hc->name); in dm_copy_name_and_uuid()
2139 strcpy(uuid, hc->uuid ? : ""); in dm_copy_name_and_uuid()