1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

check: add internal errors for unexpected paths

Adding couple INTERNAL_ERROR reports for unwanted parameters:

Ensure the 'top' metadata node cannot be NULL for lvmetad.

Make obvious vginfo2 cannot be NULL.

Report internal error if handler and vg is undefined.

Check for handle in poll_vg().

Ensure seg is not NULL in dev_manager_transient().

Report missing read_ahead for _lv_read_ahead_single().

Check for report handler in dm_report_object().

Check missing VG in _vgreduce_single().
This commit is contained in:
Zdenek Kabelac 2012-06-21 12:43:31 +02:00
parent 15891d366d
commit fd417db274
7 changed files with 42 additions and 6 deletions

View File

@ -668,6 +668,11 @@ int dev_manager_transient(struct dev_manager *dm, struct logical_volume *lv)
if (!type || !params)
continue;
if (!seg) {
log_error(INTERNAL_ERROR "Segment is not selected.");
goto out;
}
if (seg->segtype->ops->check_transient_status &&
!seg->segtype->ops->check_transient_status(seg, params))
goto_out;

View File

@ -1005,12 +1005,14 @@ static int _free_vginfo(struct lvmcache_vginfo *vginfo)
vginfo->vgname);
r = 0;
}
} else do
} else
while (vginfo2) {
if (vginfo2->next == vginfo) {
vginfo2->next = vginfo->next;
break;
}
while ((vginfo2 = vginfo2->next));
vginfo2 = vginfo2->next;
}
dm_free(vginfo->vgname);
dm_free(vginfo->creation_host);

11
lib/cache/lvmetad.c vendored
View File

@ -199,7 +199,11 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgna
if (!strcmp(daemon_reply_str(reply, "response", ""), "OK")) {
top = dm_config_find_node(reply.cft->root, "metadata");
if (!(top = dm_config_find_node(reply.cft->root, "metadata"))) {
log_error(INTERNAL_ERROR "metadata config node not found.");
goto out;
}
name = daemon_reply_str(reply, "name", NULL);
/* fall back to lvm2 if we don't know better */
@ -593,6 +597,11 @@ int lvmetad_pv_found(struct id pvid, struct device *device, const struct format_
"metadata = %b", strchr(buf, '{'),
NULL);
} else {
if (handler) {
log_error(INTERNAL_ERROR "Handler needs existing VG.");
dm_free(pvmeta);
return 0;
}
/* There are no MDAs on this PV. */
reply = daemon_send_simple(_lvmetad,
"pv_found",

View File

@ -2221,6 +2221,11 @@ static int _lv_read_ahead_single(struct logical_volume *lv, void *data)
struct lv_segment *seg = first_seg(lv);
uint32_t seg_read_ahead = 0, *read_ahead = data;
if (!read_ahead) {
log_error(INTERNAL_ERROR "Read ahead data missing.");
return 0;
}
if (seg && seg->area_count && seg_type(seg, 0) == AREA_PV)
dev_get_read_ahead(seg_pv(seg, 0)->dev, &seg_read_ahead);

View File

@ -695,6 +695,11 @@ int dm_report_object(struct dm_report *rh, void *object)
struct dm_report_field *field;
void *data = NULL;
if (!rh) {
log_error(INTERNAL_ERROR "dm_report handler is NULL.");
return 0;
}
if (!(row = dm_pool_zalloc(rh->mem, sizeof(*row)))) {
log_error("dm_report_object: struct row allocation failed");
return 0;

View File

@ -261,6 +261,11 @@ static int _poll_vg(struct cmd_context *cmd, const char *vgname,
const char *name;
int finished;
if (!parms) {
log_error(INTERNAL_ERROR "Handle is undefined.");
return ECMD_FAILED;
}
dm_list_iterate_items(lvl, &vg->lvs) {
lv = lvl->lv;
if (!(lv->status & parms->lv_type))

View File

@ -124,6 +124,11 @@ static int _vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
int r = ECMD_FAILED;
const char *name = pv_dev_name(pv);
if (!vg) {
log_error(INTERNAL_ERROR "VG is NULL.");
return ECMD_FAILED;
}
if (pv_pe_alloc_count(pv)) {
log_error("Physical volume \"%s\" still in use", name);
return ECMD_FAILED;