Commit Graph

8 Commits

Author SHA1 Message Date
Mike Fleetwood ea1c0c023e Warn when an LVM2 PV is a member of a damaged VG (#160878)
Generate a warning for each LVM2 Physical Volume which is a member of a
Volume Group which has other members missing.

Bug #160787 - lvm support
2012-02-12 11:02:55 -07:00
Mike Fleetwood 6d665d669d Display VG export status with an LVM2 PVs busy status (#160787)
Also update to use LVM terminology, such that a Physical Volume is
referred to as a member of a Volume Group.  Status of an LVM2 PV is now
displayed using one of the following messages:
    Not active (Not a member of any volume group)
    VGNAME not active
    VGNAME not active and exported
    VGNAME active

Bug #160787 - lvm support
2012-02-12 10:43:01 -07:00
Mike Fleetwood 3fbdb8055f Prevent crash in the LVM2 PV information cache (#160787)
GParted would crash if there were any embeded spaces in the output from
the command used to query LVM2 PVs.  There aren't normally any embeded
spaces, but they can occur in certain degrated situations.  For example
if one of the PVs in a VG spanning two PVs is lost the PV is displayed
as "unknown device" rather than its actual device name:

    # lvm pvs --nosuffix --units b --separator , -o pv_name,pv_free,vg_name,lv_name,lv_attr
      Couldn't find device with uuid DMEi8r-9Vvy-w0Ok-CSSn-oLmY-YrY3-1PBznz.
      PV,PFree,VG,LV,Attr
      /dev/sda11,2143289344,GParted-VG1,,
      unknown device,1619001344,GParted-VG1,lvol0,-wi---
      unknown device,1619001344,GParted-VG1,,

This was loaded into the cache as:

    ["/dev/sda11,2143289344,GParted-VG1,,",
     "unknown",
     "device,1619001344,GParted-VG1,lvol0,-wi---",
     "unknown",
     "device,1619001344,GParted-VG1,,"]

The crash would happen when trying to access the VG name or LV flags on
a line without enough comma separated fields.

Improve parsing of the output from "lvm pvs" so that lines are not split
on embeded spaces.  Don't crash on lines without without enough comma
separated fields.

Bug #160787 - lvm support
2012-02-12 10:42:40 -07:00
Mike Fleetwood c24170927d Display any errors from querying LVM2 PVs to the user (#160787)
Previously any errors which occurred when running LVM commands used to
load the LVM2_PV_Info cache were simply ignored and the cache wasn't
loaded.  This lead to missing information about LVM2 PVs, but the user
had no indication as to why.

Now when any errors occur the command ran and all output is captured.
This is displayed to the user, along with a suitable warning message, in
the Partition Information dialog.

Bug #160787 - lvm support
2012-02-12 10:24:02 -07:00
Mike Fleetwood 4b30a2ddbf Fix detection of LVM2 PV busy status when exported VGs exist (#160787)
If a Volume Group is exported the "lvm lvs" command returns non-zero
exit status causing its output to not be loaded into the LVM2_PV_Info
cache and detection of busy Physical Volumes completely fail.

    # lvm lvs -o lv_name,vg_name,lv_attr
      Volume group GParted_VG4 is exported
      LV    VG          Attr
      lvol0 GParted-VG2 -wi---
      lvol0 GParted_VG3 -wi-a-
      lvol1 GParted_VG3 -wi-a-
    # echo $?
    5

Switch to using "lvm pvs" to query all cached information using one
command, which doesn't return non-zero when exported VGs exist.

    # lvm pvs --nosuffix --units b -o pv_name,pv_free,vg_name,lv_name,lv_attr
      PV         PFree      VG          LV    Attr
      /dev/sda10 2147483648
      /dev/sda11 2143289344 GParted-VG1
      /dev/sda12 1619001344 GParted-VG2 lvol0 -wi---
      /dev/sda12 1619001344 GParted-VG2
      /dev/sda13  830472192 GParted_VG3 lvol0 -wi-a-
      /dev/sda13  830472192 GParted_VG3 lvol1 -wi-a-
      /dev/sda13  830472192 GParted_VG3
      /dev/sda14 1619001344 GParted_VG4 lvol0 -wi---
      /dev/sda14 1619001344 GParted_VG4
    # echo $?
    0

Bug #160787 - lvm support
2012-02-12 10:24:02 -07:00
Mike Fleetwood 820242635a Switch to using lvs to identify active LVM LVs (#160787)
Previously used "dmsetup info" to directly list device-mapper mapping
names in the kernel to identify active Logical Volumes.  However GParted
failed to recognise active LVs if the VGNAME contains any hyphens (-).
This is because LVM encodes hyphens as double hyphens in the mapping
name.

To avoid having to duplicate the LVM hyphen encoding in GParted, switch
to using "lvm lvs" to list LVs.

    # dmsetup info --columns --noheadings --separator , -o name
    GParted_VG1-lvol_00
    GParted--VG2-lvol--00

    # lvm lvs --noheadings --separator , -o lv_name,vg_name,lv_attr
      lvol_00,GParted_VG1,-wi-a-
      lvol-00,GParted-VG2,-wi-a-
      lvol-01,GParted-VG3,-wi---
                             .^.
(-) not active, (a) or any other character considered active.  Reference
lvs(8).

Bug #160787 - lvm support
2012-02-02 10:24:31 -07:00
Mike Fleetwood ff8ad04120 Lazy initialize the cache from querying LVM2 PVs (#160787)
Previously when GParted was started LVM2_PV_Info cache was loaded twice,
executing LVM2 PV querying commands twice.  Firstly when
lvm2_pv::get_filesystem_support() was checking if LVM2 PV support was
available, and secondly when forced by a refresh in
GParted_Core::set_devices().

Implement lazy initialization.  Only load the cache when forced by the
above mentioned refresh or having to return a value when the cache is
not yet loaded.  Do not initialize the cache when just checking if LVM2
PV support is available.

Bug #160787 - lvm support
2012-02-02 10:24:31 -07:00
Mike Fleetwood 608d992e82 Cache results from querying all LVM2 PVs (#160787)
Cache results from querying all LVM2 PVs in one go to minimise the
number of times lvm commands are executed.  Take inspiration from
caching performed by FS_Info and Proc_Partitions_Info.

Bug #160787 - lvm support
2012-02-02 10:24:28 -07:00