Lines Matching refs:param

369 static struct mapped_device *dm_hash_rename(struct dm_ioctl *param,  in dm_hash_rename()  argument
376 unsigned change_uuid = (param->flags & DM_UUID_FLAG) ? 1 : 0; in dm_hash_rename()
400 param->name, new); in dm_hash_rename()
410 hc = __get_name_cell(param->name); in dm_hash_rename()
413 param->name, change_uuid ? "uuid " : "", new); in dm_hash_rename()
425 param->name, new, hc->uuid); in dm_hash_rename()
445 if (!dm_kobject_uevent(hc->md, KOBJ_CHANGE, param->event_nr)) in dm_hash_rename()
446 param->flags |= DM_UEVENT_GENERATED_FLAG; in dm_hash_rename()
467 typedef int (*ioctl_fn)(struct file *filp, struct dm_ioctl *param, size_t param_size);
469 static int remove_all(struct file *filp, struct dm_ioctl *param, size_t param_size) in remove_all() argument
471 dm_hash_remove_all(true, !!(param->flags & DM_DEFERRED_REMOVE), false); in remove_all()
472 param->data_size = 0; in remove_all()
493 static void *get_result_buffer(struct dm_ioctl *param, size_t param_size, in get_result_buffer() argument
496 param->data_start = align_ptr(param + 1) - (void *) param; in get_result_buffer()
498 if (param->data_start < param_size) in get_result_buffer()
499 *len = param_size - param->data_start; in get_result_buffer()
503 return ((void *) param) + param->data_start; in get_result_buffer()
506 static int list_devices(struct file *filp, struct dm_ioctl *param, size_t param_size) in list_devices() argument
531 nl = orig_nl = get_result_buffer(param, param_size, &len); in list_devices()
533 param->flags |= DM_BUFFER_FULL_FLAG; in list_devices()
536 param->data_size = param->data_start + needed; in list_devices()
579 static void list_version_get_info(struct target_type *tt, void *param) in list_version_get_info() argument
581 struct vers_iter *info = param; in list_version_get_info()
604 static int __list_versions(struct dm_ioctl *param, size_t param_size, const char *name) in __list_versions() argument
629 vers = get_result_buffer(param, param_size, &len); in __list_versions()
631 param->flags |= DM_BUFFER_FULL_FLAG; in __list_versions()
634 param->data_size = param->data_start + needed; in __list_versions()
649 param->flags |= iter_info.flags; in __list_versions()
657 static int list_versions(struct file *filp, struct dm_ioctl *param, size_t param_size) in list_versions() argument
659 return __list_versions(param, param_size, NULL); in list_versions()
662 static int get_target_version(struct file *filp, struct dm_ioctl *param, size_t param_size) in get_target_version() argument
664 return __list_versions(param, param_size, param->name); in get_target_version()
706 struct dm_ioctl *param, in dm_get_live_or_inactive_table() argument
709 return (param->flags & DM_QUERY_INACTIVE_TABLE_FLAG) ? in dm_get_live_or_inactive_table()
717 static void __dev_status(struct mapped_device *md, struct dm_ioctl *param) in __dev_status() argument
723 param->flags &= ~(DM_SUSPEND_FLAG | DM_READONLY_FLAG | in __dev_status()
727 param->flags |= DM_SUSPEND_FLAG; in __dev_status()
730 param->flags |= DM_INTERNAL_SUSPEND_FLAG; in __dev_status()
733 param->flags |= DM_DEFERRED_REMOVE; in __dev_status()
735 param->dev = huge_encode_dev(disk_devt(disk)); in __dev_status()
742 param->open_count = dm_open_count(md); in __dev_status()
744 param->event_nr = dm_get_event_nr(md); in __dev_status()
745 param->target_count = 0; in __dev_status()
749 if (!(param->flags & DM_QUERY_INACTIVE_TABLE_FLAG)) { in __dev_status()
751 param->flags |= DM_READONLY_FLAG; in __dev_status()
752 param->target_count = dm_table_get_num_targets(table); in __dev_status()
755 param->flags |= DM_ACTIVE_PRESENT_FLAG; in __dev_status()
759 if (param->flags & DM_QUERY_INACTIVE_TABLE_FLAG) { in __dev_status()
764 param->flags |= DM_READONLY_FLAG; in __dev_status()
765 param->target_count = dm_table_get_num_targets(table); in __dev_status()
771 static int dev_create(struct file *filp, struct dm_ioctl *param, size_t param_size) in dev_create() argument
776 r = check_name(param->name); in dev_create()
780 if (param->flags & DM_PERSISTENT_DEV_FLAG) in dev_create()
781 m = MINOR(huge_decode_dev(param->dev)); in dev_create()
787 r = dm_hash_insert(param->name, *param->uuid ? param->uuid : NULL, md); in dev_create()
794 param->flags &= ~DM_INACTIVE_PRESENT_FLAG; in dev_create()
796 __dev_status(md, param); in dev_create()
806 static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param) in __find_device_hash_cell() argument
810 if (*param->uuid) { in __find_device_hash_cell()
811 if (*param->name || param->dev) in __find_device_hash_cell()
814 hc = __get_uuid_cell(param->uuid); in __find_device_hash_cell()
817 } else if (*param->name) { in __find_device_hash_cell()
818 if (param->dev) in __find_device_hash_cell()
821 hc = __get_name_cell(param->name); in __find_device_hash_cell()
824 } else if (param->dev) { in __find_device_hash_cell()
825 hc = __get_dev_cell(param->dev); in __find_device_hash_cell()
835 strlcpy(param->name, hc->name, sizeof(param->name)); in __find_device_hash_cell()
837 strlcpy(param->uuid, hc->uuid, sizeof(param->uuid)); in __find_device_hash_cell()
839 param->uuid[0] = '\0'; in __find_device_hash_cell()
842 param->flags |= DM_INACTIVE_PRESENT_FLAG; in __find_device_hash_cell()
844 param->flags &= ~DM_INACTIVE_PRESENT_FLAG; in __find_device_hash_cell()
849 static struct mapped_device *find_device(struct dm_ioctl *param) in find_device() argument
855 hc = __find_device_hash_cell(param); in find_device()
863 static int dev_remove(struct file *filp, struct dm_ioctl *param, size_t param_size) in dev_remove() argument
871 hc = __find_device_hash_cell(param); in dev_remove()
884 r = dm_lock_for_deletion(md, !!(param->flags & DM_DEFERRED_REMOVE), false); in dev_remove()
886 if (r == -EBUSY && param->flags & DM_DEFERRED_REMOVE) { in dev_remove()
905 param->flags &= ~DM_DEFERRED_REMOVE; in dev_remove()
907 if (!dm_kobject_uevent(md, KOBJ_REMOVE, param->event_nr)) in dev_remove()
908 param->flags |= DM_UEVENT_GENERATED_FLAG; in dev_remove()
928 static int dev_rename(struct file *filp, struct dm_ioctl *param, size_t param_size) in dev_rename() argument
931 char *new_data = (char *) param + param->data_start; in dev_rename()
933 unsigned change_uuid = (param->flags & DM_UUID_FLAG) ? 1 : 0; in dev_rename()
935 if (new_data < param->data || in dev_rename()
936 invalid_str(new_data, (void *) param + param_size) || !*new_data || in dev_rename()
948 md = dm_hash_rename(param, new_data); in dev_rename()
952 __dev_status(md, param); in dev_rename()
958 static int dev_set_geometry(struct file *filp, struct dm_ioctl *param, size_t param_size) in dev_set_geometry() argument
964 char *geostr = (char *) param + param->data_start; in dev_set_geometry()
967 md = find_device(param); in dev_set_geometry()
971 if (geostr < param->data || in dev_set_geometry()
972 invalid_str(geostr, (void *) param + param_size)) { in dev_set_geometry()
998 param->data_size = 0; in dev_set_geometry()
1005 static int do_suspend(struct dm_ioctl *param) in do_suspend() argument
1011 md = find_device(param); in do_suspend()
1015 if (param->flags & DM_SKIP_LOCKFS_FLAG) in do_suspend()
1017 if (param->flags & DM_NOFLUSH_FLAG) in do_suspend()
1026 __dev_status(md, param); in do_suspend()
1034 static int do_resume(struct dm_ioctl *param) in do_resume() argument
1044 hc = __find_device_hash_cell(param); in do_resume()
1055 param->flags &= ~DM_INACTIVE_PRESENT_FLAG; in do_resume()
1062 if (param->flags & DM_SKIP_LOCKFS_FLAG) in do_resume()
1064 if (param->flags & DM_NOFLUSH_FLAG) in do_resume()
1085 if (!r && !dm_kobject_uevent(md, KOBJ_CHANGE, param->event_nr)) in do_resume()
1086 param->flags |= DM_UEVENT_GENERATED_FLAG; in do_resume()
1097 __dev_status(md, param); in do_resume()
1107 static int dev_suspend(struct file *filp, struct dm_ioctl *param, size_t param_size) in dev_suspend() argument
1109 if (param->flags & DM_SUSPEND_FLAG) in dev_suspend()
1110 return do_suspend(param); in dev_suspend()
1112 return do_resume(param); in dev_suspend()
1119 static int dev_status(struct file *filp, struct dm_ioctl *param, size_t param_size) in dev_status() argument
1123 md = find_device(param); in dev_status()
1127 __dev_status(md, param); in dev_status()
1137 struct dm_ioctl *param, size_t param_size) in retrieve_status() argument
1146 outptr = outbuf = get_result_buffer(param, param_size, &len); in retrieve_status()
1148 if (param->flags & DM_STATUS_TABLE_FLAG) in retrieve_status()
1161 param->flags |= DM_BUFFER_FULL_FLAG; in retrieve_status()
1176 param->flags |= DM_BUFFER_FULL_FLAG; in retrieve_status()
1182 if (param->flags & DM_NOFLUSH_FLAG) in retrieve_status()
1190 param->flags |= DM_BUFFER_FULL_FLAG; in retrieve_status()
1195 used = param->data_start + (outptr - outbuf); in retrieve_status()
1202 param->data_size = used; in retrieve_status()
1204 param->target_count = num_targets; in retrieve_status()
1210 static int dev_wait(struct file *filp, struct dm_ioctl *param, size_t param_size) in dev_wait() argument
1217 md = find_device(param); in dev_wait()
1224 if (dm_wait_event(md, param->event_nr)) { in dev_wait()
1234 __dev_status(md, param); in dev_wait()
1236 table = dm_get_live_or_inactive_table(md, param, &srcu_idx); in dev_wait()
1238 retrieve_status(table, param, param_size); in dev_wait()
1251 static int dev_arm_poll(struct file *filp, struct dm_ioctl *param, size_t param_size) in dev_arm_poll() argument
1260 static inline fmode_t get_mode(struct dm_ioctl *param) in get_mode() argument
1264 if (param->flags & DM_READONLY_FLAG) in get_mode()
1283 struct dm_ioctl *param, size_t param_size) in populate_table() argument
1287 struct dm_target_spec *spec = (struct dm_target_spec *) param; in populate_table()
1288 uint32_t next = param->data_start; in populate_table()
1289 void *end = (void *) param + param_size; in populate_table()
1292 if (!param->target_count) { in populate_table()
1297 for (i = 0; i < param->target_count; i++) { in populate_table()
1329 static int table_load(struct file *filp, struct dm_ioctl *param, size_t param_size) in table_load() argument
1337 md = find_device(param); in table_load()
1341 r = dm_table_create(&t, get_mode(param), param->target_count, md); in table_load()
1347 r = populate_table(t, param, param_size); in table_load()
1395 param->flags |= DM_INACTIVE_PRESENT_FLAG; in table_load()
1396 __dev_status(md, param); in table_load()
1417 static int table_clear(struct file *filp, struct dm_ioctl *param, size_t param_size) in table_clear() argument
1425 hc = __find_device_hash_cell(param); in table_clear()
1437 param->flags &= ~DM_INACTIVE_PRESENT_FLAG; in table_clear()
1439 __dev_status(hc->md, param); in table_clear()
1455 struct dm_ioctl *param, size_t param_size) in retrieve_deps() argument
1463 deps = get_result_buffer(param, param_size, &len); in retrieve_deps()
1476 param->flags |= DM_BUFFER_FULL_FLAG; in retrieve_deps()
1488 param->data_size = param->data_start + needed; in retrieve_deps()
1491 static int table_deps(struct file *filp, struct dm_ioctl *param, size_t param_size) in table_deps() argument
1497 md = find_device(param); in table_deps()
1501 __dev_status(md, param); in table_deps()
1503 table = dm_get_live_or_inactive_table(md, param, &srcu_idx); in table_deps()
1505 retrieve_deps(table, param, param_size); in table_deps()
1517 static int table_status(struct file *filp, struct dm_ioctl *param, size_t param_size) in table_status() argument
1523 md = find_device(param); in table_status()
1527 __dev_status(md, param); in table_status()
1529 table = dm_get_live_or_inactive_table(md, param, &srcu_idx); in table_status()
1531 retrieve_status(table, param, param_size); in table_status()
1572 static int target_message(struct file *filp, struct dm_ioctl *param, size_t param_size) in target_message() argument
1579 struct dm_target_msg *tmsg = (void *) param + param->data_start; in target_message()
1581 char *result = get_result_buffer(param, param_size, &maxlen); in target_message()
1584 md = find_device(param); in target_message()
1588 if (tmsg < (struct dm_target_msg *) param->data || in target_message()
1589 invalid_str(tmsg->message, (void *) param + param_size)) { in target_message()
1636 __dev_status(md, param); in target_message()
1639 param->flags |= DM_DATA_OUT_FLAG; in target_message()
1641 param->flags |= DM_BUFFER_FULL_FLAG; in target_message()
1643 param->data_size = param->data_start + strlen(result) + 1; in target_message()
1739 static void free_params(struct dm_ioctl *param, size_t param_size, int param_flags) in free_params() argument
1742 memset(param, 0, param_size); in free_params()
1745 kvfree(param); in free_params()
1749 int ioctl_flags, struct dm_ioctl **param, int *param_flags) in copy_params() argument
1801 *param = dmi; in copy_params()
1810 static int validate_params(uint cmd, struct dm_ioctl *param) in validate_params() argument
1813 param->flags &= ~DM_BUFFER_FULL_FLAG; in validate_params()
1814 param->flags &= ~DM_UEVENT_GENERATED_FLAG; in validate_params()
1815 param->flags &= ~DM_SECURE_DATA_FLAG; in validate_params()
1816 param->flags &= ~DM_DATA_OUT_FLAG; in validate_params()
1825 if (!*param->name) { in validate_params()
1829 } else if (*param->uuid && *param->name) { in validate_params()
1835 param->name[DM_NAME_LEN - 1] = '\0'; in validate_params()
1836 param->uuid[DM_UUID_LEN - 1] = '\0'; in validate_params()
1847 struct dm_ioctl *uninitialized_var(param); in ctl_ioctl()
1884 r = copy_params(user, &param_kernel, ioctl_flags, &param, &param_flags); in ctl_ioctl()
1889 input_param_size = param->data_size; in ctl_ioctl()
1890 r = validate_params(cmd, param); in ctl_ioctl()
1894 param->data_size = offsetof(struct dm_ioctl, data); in ctl_ioctl()
1895 r = fn(file, param, input_param_size); in ctl_ioctl()
1897 if (unlikely(param->flags & DM_BUFFER_FULL_FLAG) && in ctl_ioctl()
1907 if (!r && copy_to_user(user, param, param->data_size)) in ctl_ioctl()
1911 free_params(param, input_param_size, param_flags); in ctl_ioctl()