mirror of
git://sourceware.org/git/lvm2.git
synced 2025-02-24 17:57:48 +03:00
report: display 'unknown' value for LVSINFO fields if unable to get info
If the lv_info call fails for whatever reason/INFO dm ioctl fails or the dm driver communication is disabled (--driverloaded n), make sure we always display "unknown" for LVSINFO fields as that's exactly what happens - we don't know the state. Before the patch: $ lvs -o name,device_open --driverloaded n WARNING: Activation disabled. No device-mapper interaction will be attempted. Command failed with status code 5. With this patch applied: $ lvs -o name,device_open --driverloaded n WARNING: Activation disabled. No device-mapper interaction will be attempted. LV DevOpen lvol1 unknown
This commit is contained in:
parent
f33d75e2e5
commit
52af0dfbc0
@ -1394,7 +1394,9 @@ static int _lvpermissions_disp(struct dm_report *rh, struct dm_pool *mem,
|
||||
|
||||
if (!(lvi->lv->status & PVMOVE)) {
|
||||
if (lvi->lv->status & LVM_WRITE) {
|
||||
if (lvi->info->read_only)
|
||||
if (!lvi->info->exists)
|
||||
perms = _str_unknown;
|
||||
else if (lvi->info->read_only)
|
||||
perms = FIRST_NAME(lv_permissions_r_override);
|
||||
else
|
||||
perms = FIRST_NAME(lv_permissions_rw);
|
||||
|
@ -48,14 +48,20 @@ static int _lvs_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
static void _get_lv_info_for_report(struct cmd_context *cmd,
|
||||
struct logical_volume *lv,
|
||||
struct lvinfo *lvinfo)
|
||||
{
|
||||
if (!lv_info(cmd, lv, 0, lvinfo, 1, 1))
|
||||
lvinfo->exists = 0;
|
||||
}
|
||||
|
||||
static int _lvs_with_info_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
void *handle)
|
||||
{
|
||||
struct lvinfo lvinfo;
|
||||
|
||||
if (!lv_info(cmd, lv, 0, &lvinfo, 1, 1))
|
||||
return_ECMD_FAILED;
|
||||
|
||||
_get_lv_info_for_report(cmd, lv, &lvinfo);
|
||||
if (!report_object(handle, lv->vg, lv, NULL, NULL, NULL, &lvinfo, NULL))
|
||||
return_ECMD_FAILED;
|
||||
|
||||
@ -76,8 +82,8 @@ static int _segs_with_lv_info_single(struct cmd_context *cmd __attribute__((unus
|
||||
{
|
||||
struct lvinfo lvinfo;
|
||||
|
||||
if (!lv_info(cmd, seg->lv, 0, &lvinfo, 1, 1) ||
|
||||
!report_object(handle, seg->lv->vg, seg->lv, NULL, seg, NULL, &lvinfo, NULL))
|
||||
_get_lv_info_for_report(cmd, seg->lv, &lvinfo);
|
||||
if (!report_object(handle, seg->lv->vg, seg->lv, NULL, seg, NULL, &lvinfo, NULL))
|
||||
return_ECMD_FAILED;
|
||||
|
||||
return ECMD_PROCESSED;
|
||||
@ -137,10 +143,8 @@ static int _do_pvsegs_sub_single(struct cmd_context *cmd,
|
||||
dm_list_init(&_free_logical_volume.snapshot_segs);
|
||||
|
||||
lvinfo.exists = 0;
|
||||
if (seg && lv_info_needed && !lv_info(cmd, seg->lv, 0, &lvinfo, 1, 1)) {
|
||||
ret = ECMD_FAILED;
|
||||
goto_out;
|
||||
}
|
||||
if (seg && lv_info_needed)
|
||||
_get_lv_info_for_report(cmd, seg->lv, &lvinfo);
|
||||
|
||||
if (!report_object(handle, vg, seg ? seg->lv : &_free_logical_volume, pvseg->pv,
|
||||
seg ? : &_free_lv_segment, pvseg, &lvinfo, pv_label(pvseg->pv))) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user