99
int pvscan(struct cmd_context *cmd, int argc __attribute__((unused)),
100
char **argv __attribute__((unused)))
102
static int _pvscan_lvmetad_all_devs(struct cmd_context *cmd)
104
struct dev_iter *iter;
108
if (!(iter = dev_iter_create(cmd->filter, 1))) {
109
log_error("dev_iter creation failed");
113
while ((dev = dev_iter_get(iter))) {
114
if (!pvscan_lvmetad_single(cmd, dev)) {
123
dev_iter_destroy(iter);
128
static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
130
int ret = ECMD_PROCESSED;
136
struct arg_value_group_list *current_group;
140
if (arg_count(cmd, major_ARG) + arg_count(cmd, minor_ARG))
143
if (devno_args && (!arg_count(cmd, major_ARG) || !arg_count(cmd, minor_ARG))) {
144
log_error("Both --major and --minor required to identify devices.");
145
return EINVALID_CMD_LINE;
148
if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_READ)) {
149
log_error("Unable to obtain global lock.");
153
/* Scan everything? */
154
if (!argc && !devno_args) {
155
if (!_pvscan_lvmetad_all_devs(cmd))
160
log_verbose("Using physical volume(s) on command line");
162
/* Process any command line PVs first. */
165
dev = dev_cache_get(pv_name, NULL);
167
log_error("Physical Volume %s not found.", pv_name);
172
if (!pvscan_lvmetad_single(cmd, dev)) {
183
/* Process any grouped --major --minor args */
184
dm_list_iterate_items(current_group, &cmd->arg_value_groups) {
185
major = grouped_arg_int_value(current_group->arg_values, major_ARG, major);
186
minor = grouped_arg_int_value(current_group->arg_values, minor_ARG, minor);
188
if (major < 0 || minor < 0)
191
devno = MKDEV(major, minor);
193
if (!(dev = dev_cache_get_by_devt(devno, NULL))) {
194
if (!dm_asprintf(&buf, "%" PRIi32 ":%" PRIi32, major, minor))
197
if (!lvmetad_pv_gone(devno, buf ? : "")) {
204
log_print("Device %s not found. "
205
"Cleared from lvmetad cache.", buf ? : "");
211
if (!pvscan_lvmetad_single(cmd, dev)) {
221
unlock_vg(cmd, VG_GLOBAL);
226
int pvscan(struct cmd_context *cmd, int argc, char **argv)
102
228
int new_pvs_found = 0;
103
229
int pvs_found = 0;
113
239
pv_max_name_len = 0;
114
240
vg_max_name_len = 0;
242
if (arg_count(cmd, cache_ARG))
243
return _pvscan_lvmetad(cmd, argc, argv);
245
if (arg_count(cmd, major_ARG) + arg_count(cmd, minor_ARG)) {
246
log_error("--major and --minor are only valid with --cache.");
247
return EINVALID_CMD_LINE;
116
250
if (arg_count(cmd, novolumegroup_ARG) && arg_count(cmd, exported_ARG)) {
117
251
log_error("Options -e and -n are incompatible");
118
252
return EINVALID_CMD_LINE;