mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
report: avoid passing NULL label
Internal reporting function cannot handle NULL reporting value, so ensure there is at least dummy label. So move dummy_lable from tools/reporter.c and use it for all report_object() calls in lib/report/report.c. (Fixes RHBZ 1108394) Simlify lvm_report_object initialization.
This commit is contained in:
parent
c230ae95ab
commit
922f884abe
@ -1,5 +1,6 @@
|
||||
Version 2.02.107 -
|
||||
==================================
|
||||
Fix crash when reporting of empty labels on pvs.
|
||||
Use retry_deactivation also when cleaning orphan devices.
|
||||
Prompt when setting the VG cluster attr if the cluster is not setup.
|
||||
Allow --yes to skip prompt in vgextend (worked only with -f).
|
||||
|
@ -1274,19 +1274,35 @@ int report_object(void *handle, struct volume_group *vg,
|
||||
struct lv_segment *seg, struct pv_segment *pvseg,
|
||||
struct label *label)
|
||||
{
|
||||
struct lvm_report_object obj;
|
||||
struct device dummy_device = { .dev = 0 };
|
||||
struct label dummy_label = { .dev = &dummy_device };
|
||||
struct lvm_report_object obj = {
|
||||
.vg = vg,
|
||||
.lv = lv,
|
||||
.pv = pv,
|
||||
.seg = seg,
|
||||
.pvseg = pvseg,
|
||||
.label = label ? : (pv ? pv_label(pv) : NULL)
|
||||
};
|
||||
|
||||
/* FIXME workaround for pv_label going through cache; remove once struct
|
||||
* physical_volume gains a proper "label" pointer */
|
||||
if (!obj.label) {
|
||||
if (pv) {
|
||||
if (pv->fmt)
|
||||
dummy_label.labeller = pv->fmt->labeller;
|
||||
if (pv->dev)
|
||||
dummy_label.dev = pv->dev;
|
||||
else
|
||||
memcpy(dummy_device.pvid, &pv->id, ID_LEN);
|
||||
}
|
||||
obj.label = &dummy_label;
|
||||
}
|
||||
|
||||
/* The two format fields might as well match. */
|
||||
if (!vg && pv)
|
||||
_dummy_fid.fmt = pv->fmt;
|
||||
|
||||
obj.vg = vg;
|
||||
obj.lv = lv;
|
||||
obj.pv = pv;
|
||||
obj.seg = seg;
|
||||
obj.pvseg = pvseg;
|
||||
obj.label = label ? label : (pv ? pv_label(pv) : NULL);
|
||||
|
||||
return dm_report_object(handle, &obj);
|
||||
}
|
||||
|
||||
|
@ -140,9 +140,6 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
const char *vg_name = NULL;
|
||||
struct volume_group *old_vg = vg;
|
||||
char uuid[64] __attribute__((aligned(8)));
|
||||
struct label *label;
|
||||
struct label dummy_label = { .dev = 0 };
|
||||
struct device dummy_device = { .dev = 0 };
|
||||
|
||||
if (is_pv(pv) && !is_orphan(pv) && !vg) {
|
||||
vg_name = pv_vg_name(pv);
|
||||
@ -180,22 +177,7 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
pv = pvl->pv;
|
||||
}
|
||||
|
||||
/* FIXME workaround for pv_label going through cache; remove once struct
|
||||
* physical_volume gains a proper "label" pointer */
|
||||
if (!(label = pv_label(pv))) {
|
||||
if (pv->fmt)
|
||||
dummy_label.labeller = pv->fmt->labeller;
|
||||
|
||||
if (pv->dev)
|
||||
dummy_label.dev = pv->dev;
|
||||
else {
|
||||
dummy_label.dev = &dummy_device;
|
||||
memcpy(dummy_device.pvid, &pv->id, ID_LEN);
|
||||
}
|
||||
label = &dummy_label;
|
||||
}
|
||||
|
||||
if (!report_object(handle, vg, NULL, pv, NULL, NULL, label)) {
|
||||
if (!report_object(handle, vg, NULL, pv, NULL, NULL, NULL)) {
|
||||
stack;
|
||||
ret = ECMD_FAILED;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user