mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Display all filtered devices, not just PVs, with pvs -a.
This commit is contained in:
parent
01c263e9fe
commit
c29d24650d
@ -1,5 +1,6 @@
|
||||
Version 2.00.17 -
|
||||
=============================
|
||||
Display all filtered devices, not just PVs, with pvs -a.
|
||||
Fix sync_dir() when no / in filename
|
||||
vgcfgbackup -f accepts template with %s for VG name.
|
||||
Extend hash functions to handle non-null-terminated data.
|
||||
|
@ -39,7 +39,7 @@ static int _add_pv_to_vg(struct format_instance *fid, struct volume_group *vg,
|
||||
}
|
||||
|
||||
list_init(&mdas);
|
||||
if (!(pv = pv_read(fid->fmt->cmd, pv_name, &mdas, NULL))) {
|
||||
if (!(pv = pv_read(fid->fmt->cmd, pv_name, &mdas, NULL, 1))) {
|
||||
log_error("%s not identified as an existing physical volume",
|
||||
pv_name);
|
||||
return 0;
|
||||
@ -426,7 +426,7 @@ struct physical_volume *find_pv_by_name(struct cmd_context *cmd,
|
||||
{
|
||||
struct physical_volume *pv;
|
||||
|
||||
if (!(pv = pv_read(cmd, pv_name, NULL, NULL))) {
|
||||
if (!(pv = pv_read(cmd, pv_name, NULL, NULL, 1))) {
|
||||
log_error("Physical volume %s not found", pv_name);
|
||||
return NULL;
|
||||
}
|
||||
@ -605,7 +605,7 @@ static struct volume_group *_vg_read_orphans(struct cmd_context *cmd)
|
||||
|
||||
list_iterate(ih, &vginfo->infos) {
|
||||
dev = list_item(ih, struct lvmcache_info)->dev;
|
||||
if (!(pv = pv_read(cmd, dev_name(dev), NULL, NULL))) {
|
||||
if (!(pv = pv_read(cmd, dev_name(dev), NULL, NULL, 1))) {
|
||||
continue;
|
||||
}
|
||||
if (!(pvl = pool_zalloc(cmd->mem, sizeof(*pvl)))) {
|
||||
@ -814,7 +814,8 @@ struct logical_volume *lv_from_lvid(struct cmd_context *cmd, const char *lvid_s)
|
||||
|
||||
/* FIXME Use label functions instead of PV functions */
|
||||
struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
|
||||
struct list *mdas, uint64_t *label_sector)
|
||||
struct list *mdas, uint64_t *label_sector,
|
||||
int warnings)
|
||||
{
|
||||
struct physical_volume *pv;
|
||||
struct label *label;
|
||||
@ -827,7 +828,9 @@ struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
|
||||
}
|
||||
|
||||
if (!(label_read(dev, &label))) {
|
||||
log_error("No physical volume label read from %s", pv_name);
|
||||
if (warnings)
|
||||
log_error("No physical volume label read from %s",
|
||||
pv_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -369,7 +369,8 @@ struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name,
|
||||
int *consistent);
|
||||
struct volume_group *vg_read_by_vgid(struct cmd_context *cmd, const char *vgid);
|
||||
struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
|
||||
struct list *mdas, uint64_t *label_sector);
|
||||
struct list *mdas, uint64_t *label_sector,
|
||||
int warnings);
|
||||
struct list *get_pvs(struct cmd_context *cmd);
|
||||
|
||||
/* Set full_scan to 1 to re-read every (filtered) device label */
|
||||
|
@ -1063,6 +1063,7 @@ int report_object(void *handle, struct volume_group *vg,
|
||||
struct row *row;
|
||||
struct field *field;
|
||||
void *data = NULL;
|
||||
int skip;
|
||||
|
||||
if (lv && pv) {
|
||||
log_error("report_object: One of *lv and *pv must be NULL!");
|
||||
@ -1090,6 +1091,8 @@ int report_object(void *handle, struct volume_group *vg,
|
||||
list_iterate(fh, &rh->field_props) {
|
||||
fp = list_item(fh, struct field_properties);
|
||||
|
||||
skip = 0;
|
||||
|
||||
if (!(field = pool_zalloc(rh->mem, sizeof(*field)))) {
|
||||
log_error("struct field allocation failed");
|
||||
return 0;
|
||||
@ -1101,6 +1104,10 @@ int report_object(void *handle, struct volume_group *vg,
|
||||
data = (void *) lv + _fields[fp->field_num].offset;
|
||||
break;
|
||||
case VGS:
|
||||
if (!vg) {
|
||||
skip = 1;
|
||||
break;
|
||||
}
|
||||
data = (void *) vg + _fields[fp->field_num].offset;
|
||||
break;
|
||||
case PVS:
|
||||
@ -1110,7 +1117,10 @@ int report_object(void *handle, struct volume_group *vg,
|
||||
data = (void *) seg + _fields[fp->field_num].offset;
|
||||
}
|
||||
|
||||
if (!_fields[fp->field_num].report_fn(rh, field, data)) {
|
||||
if (skip) {
|
||||
field->report_string = "";
|
||||
field->sort_value = (const void *) field->report_string;
|
||||
} else if (!_fields[fp->field_num].report_fn(rh, field, data)) {
|
||||
log_error("report function failed for field %s",
|
||||
_fields[fp->field_num].id);
|
||||
return 0;
|
||||
|
@ -479,6 +479,7 @@ xx(pvs,
|
||||
"Display information about physical volumes",
|
||||
"pvs" "\n"
|
||||
"\t[--aligned]\n"
|
||||
"\t[-a|--all]\n"
|
||||
"\t[-d|--debug]" "\n"
|
||||
"\t[-h|-?|--help] " "\n"
|
||||
"\t[--noheadings]\n"
|
||||
@ -493,9 +494,9 @@ xx(pvs,
|
||||
"\t[--version]\n"
|
||||
"\t[PhysicalVolume [PhysicalVolume...]]\n",
|
||||
|
||||
aligned_ARG, ignorelockingfailure_ARG, noheadings_ARG, nolocking_ARG,
|
||||
nosuffix_ARG, options_ARG, separator_ARG, sort_ARG, unbuffered_ARG,
|
||||
units_ARG)
|
||||
aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG,
|
||||
nolocking_ARG, nosuffix_ARG, options_ARG, separator_ARG, sort_ARG,
|
||||
unbuffered_ARG, units_ARG)
|
||||
|
||||
xx(pvscan,
|
||||
"List all physical volumes",
|
||||
|
@ -107,7 +107,7 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(pv = pv_read(cmd, pv_name, &mdas, §or))) {
|
||||
if (!(pv = pv_read(cmd, pv_name, &mdas, §or, 1))) {
|
||||
unlock_vg(cmd, ORPHAN);
|
||||
log_error("Unable to read PV \"%s\"", pv_name);
|
||||
return 0;
|
||||
@ -236,9 +236,8 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
for (; opt < argc; opt++) {
|
||||
pv_name = argv[opt];
|
||||
/* FIXME Read VG instead - pv_read will fail */
|
||||
if (!(pv = pv_read(cmd, pv_name, &mdas, NULL))) {
|
||||
log_error
|
||||
("Failed to read physical volume \"%s\"",
|
||||
if (!(pv = pv_read(cmd, pv_name, &mdas, NULL, 1))) {
|
||||
log_error("Failed to read physical volume %s",
|
||||
pv_name);
|
||||
continue;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name)
|
||||
|
||||
/* is there a pv here already */
|
||||
/* FIXME Use partial mode here? */
|
||||
if (!(pv = pv_read(cmd, name, NULL, NULL)))
|
||||
if (!(pv = pv_read(cmd, name, NULL, NULL, 0)))
|
||||
return 1;
|
||||
|
||||
/* orphan ? */
|
||||
|
@ -34,7 +34,7 @@ static int pvremove_check(struct cmd_context *cmd, const char *name)
|
||||
}
|
||||
|
||||
/* is there a pv here already */
|
||||
if (!(pv = pv_read(cmd, name, NULL, NULL)))
|
||||
if (!(pv = pv_read(cmd, name, NULL, NULL, 1)))
|
||||
return 1;
|
||||
|
||||
/* orphan ? */
|
||||
|
@ -60,6 +60,7 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
int consistent = 0;
|
||||
int ret = ECMD_PROCESSED;
|
||||
|
||||
if (pv->vg_name) {
|
||||
if (!lock_vol(cmd, pv->vg_name, LCK_VG_READ)) {
|
||||
log_error("Can't lock %s: skipping", pv->vg_name);
|
||||
return ECMD_FAILED;
|
||||
@ -70,11 +71,14 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
unlock_vg(cmd, pv->vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
if (!report_object(handle, vg, NULL, pv, NULL))
|
||||
ret = ECMD_FAILED;
|
||||
|
||||
if (pv->vg_name)
|
||||
unlock_vg(cmd, pv->vg_name);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -463,6 +463,44 @@ int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
||||
return ret_max;
|
||||
}
|
||||
|
||||
static int _process_all_devs(struct cmd_context *cmd, void *handle,
|
||||
int (*process_single) (struct cmd_context * cmd,
|
||||
struct volume_group * vg,
|
||||
struct physical_volume * pv,
|
||||
void *handle))
|
||||
{
|
||||
struct physical_volume *pv;
|
||||
struct physical_volume pv_dummy;
|
||||
struct dev_iter *iter;
|
||||
struct device *dev;
|
||||
|
||||
int ret_max = 0;
|
||||
int ret = 0;
|
||||
|
||||
if (!(iter = dev_iter_create(cmd->filter))) {
|
||||
log_error("dev_iter creation failed");
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
while ((dev = dev_iter_get(iter))) {
|
||||
if (!(pv = pv_read(cmd, dev_name(dev), NULL, NULL, 0))) {
|
||||
memset(&pv_dummy, 0, sizeof(pv_dummy));
|
||||
list_init(&pv_dummy.segments);
|
||||
list_init(&pv_dummy.tags);
|
||||
pv_dummy.dev = dev;
|
||||
pv_dummy.fmt = NULL;
|
||||
pv = &pv_dummy;
|
||||
}
|
||||
ret = process_single(cmd, NULL, pv, handle);
|
||||
if (ret > ret_max)
|
||||
ret_max = ret;
|
||||
}
|
||||
|
||||
dev_iter_destroy(iter);
|
||||
|
||||
return ret_max;
|
||||
}
|
||||
|
||||
int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
|
||||
struct volume_group *vg, void *handle,
|
||||
int (*process_single) (struct cmd_context * cmd,
|
||||
@ -516,7 +554,8 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
|
||||
}
|
||||
pv = pvl->pv;
|
||||
} else {
|
||||
if (!(pv = pv_read(cmd, argv[opt], NULL, NULL))) {
|
||||
if (!(pv = pv_read(cmd, argv[opt], NULL,
|
||||
NULL, 1))) {
|
||||
log_error("Failed to read physical "
|
||||
"volume \"%s\"", argv[opt]);
|
||||
ret_max = ECMD_FAILED;
|
||||
@ -549,6 +588,10 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
|
||||
process_single);
|
||||
if (ret > ret_max)
|
||||
ret_max = ret;
|
||||
} else if (arg_count(cmd, all_ARG)) {
|
||||
ret = _process_all_devs(cmd, handle, process_single);
|
||||
if (ret > ret_max)
|
||||
ret_max = ret;
|
||||
} else {
|
||||
log_verbose("Scanning for physical volume names");
|
||||
if (!(pvslist = get_pvs(cmd)))
|
||||
|
Loading…
Reference in New Issue
Block a user