Skip to content

Commit

Permalink
Merge pull request #969 from mvollmer/lvm2-plain-layouts
Browse files Browse the repository at this point in the history
lvm: Enhancements for LVM2 RAID support
  • Loading branch information
tbzatek authored Nov 15, 2022
2 parents 190a4fa + 2de5f59 commit 18d8873
Show file tree
Hide file tree
Showing 15 changed files with 683 additions and 19 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ fi
# Libraries
#

PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.50])
PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.68])
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)

Expand Down
129 changes: 128 additions & 1 deletion modules/lvm2/data/org.freedesktop.UDisks2.lvm2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@
-->
<property name="NeedsPolling" type="b" access="read"/>

<!-- MissingPhysicalVolumes:
@since: 2.10.0
A list of the UUIDs of missing physical volumes.
-->
<property name="MissingPhysicalVolumes" type="as" access="read"/>

<!-- Poll:
Make sure that all properties of this volume group and of all
Expand Down Expand Up @@ -251,13 +258,27 @@
<arg name="options" direction="in" type="a{sv}"/>
</method>

<!-- RemoveMissingPhysicalVolumes:
@since: 2.10.0
Forget about all physical volumes that went missing.
No additional options are currently defined.
-->
<method name="RemoveMissingPhysicalVolumes">
<arg name="options" direction="in" type="a{sv}"/>
</method>

<!-- CreatePlainVolume:
@name: The name of the new logical volume.
@size: The size.
@options: Additional options.
@result: The object path of the new logical volume.
Create a 'normal' new logical volume.
Create a 'normal' new logical volume. Calling this method is
equivalent to calling CreatePlainVolumeWithLayout with
"linear" as the layout type and an empty array of physical
volumes.
No additional options are currently defined.
-->
Expand All @@ -268,6 +289,30 @@
<arg name="result" type="o" direction="out"/>
</method>

<!-- CreatePlainVolumeWithLayout:
@name: The name of the new logical volume.
@size: The size.
@layout: The layout type, like "linear", "raid5"
@pvs: The physical volumes to use
@options: Additional options.
@result: The object path of the new logical volume.
@since: 2.10.0
Create a 'normal' new logical volume with the given layout
type on the given physical volumes. It is okay to leave
"pvs" empty; LVM2 will then choose suitable ones on its own.
No additional options are currently defined.
-->
<method name="CreatePlainVolumeWithLayout">
<arg name="name" type="s" direction="in"/>
<arg name="size" type="t" direction="in"/>
<arg name="layout" type="s" direction="in"/>
<arg name="pvs" type="ao" direction="in"/>
<arg name="options" type="a{sv}" direction="in"/>
<arg name="result" type="o" direction="out"/>
</method>

<!-- CreateThinPoolVolume:
@name: The name of the new logical volume.
@size: The total size.
Expand Down Expand Up @@ -436,6 +481,71 @@
-->
<property name="Type" type="s" access="read"/>

<!-- Layout:
@since: 2.10.0
The layout of this logical volume, such as "linear", "raid5",
etc.
-->
<property name="Layout" type="s" access="read"/>

<!-- Structure:
@since: 2.10.0
The detailed structure of how this logical volume is stored on physical volumes.
The following fields are present:
- name (s): The name of the logical volume.
- type (s): The layout type of the logical volume.
- size (t): The size in bytes of the logical volume.
If the logical volume is stored directly on physical volumes,
this field is present as well:
- segs (a(tto)): Information about the segments of the logical volume (see below).
A segment is represented by a "(tto)" tuple, where the fields
have these meanings:
- (t): The start of this segement on the physical volume, in bytes.
- (t): The size of the segment, in bytes.
- (o): The path of the org.freedesktop.UDisks.Block object of the physical volume.
For a healthy logical volume, the sizes of its segments will
add up exactly to its own size. If a volume group has lost
some physical volumes, a affected logical volume will have a
list of segments here that do not add up to its full size.
If the logical volume is stored on other logical volumes,
these fields are present in the "Structure" value instead of
"segs":
- data (aa{sv}): The list of "Structure" objects for the data sub-volumes.
- metadata (aa{sv}): The list of "Structure" objects for the metadata sub-volumes.
For example, a minimal "raid5" layout will have three "data"
sub-volumes (and three parallel "metadata" sub-volumes),
which are the three stripes of the RAID configuration. Each
of those sub-volume will be stored directly on physical
volumes and one can inspect the "segs" field of those to
figure out how many are damaged. From that, one can deduce
whether the RAID is degraded (exactly one damaged), or has
lost data (more than one damaged).
-->
<property name="Structure" type="a{sv}" access="read"/>

<!-- SyncRatio:
@since: 2.10.0
How far along the logical volume is with resynchronizing. A
value of 1.0 corresponds to fully synchronized and indicates
that no operation is in progress. This is only relevant for
logical volumes with some redundancy, like "raid1" or
"raid5".
-->
<property name="SyncRatio" type="d" access="read"/>

<!-- ThinPool:
For a thin volume, the object path of its pool.
Expand Down Expand Up @@ -557,6 +667,23 @@
<arg name="options" type="a{sv}" direction="in"/>
</method>

<!-- Repair:
@pvs: A list of physical volumes to use for the repair.
@options: Additional options.
@since: 2.10.0
Attempt a repair of this logical volume after it has lost
some physical volumes. Space is allocated from the given
physical volumes as needed. A empty list means to allocate
from all physical volumes.
No additional options are currently defined.
-->
<method name="Repair">
<arg name="pvs" type="ao" direction="in"/>
<arg name="options" direction="in" type="a{sv}"/>
</method>

<!-- CreateSnapshot:
@name: The name of the snapshot.
@size: The size of the backing store for the snapshot, in bytes.
Expand Down
13 changes: 11 additions & 2 deletions modules/lvm2/jobhelpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ gboolean lvcreate_job_func (UDisksThreadedJob *job,
GError **error)
{
LVJobData *data = user_data;
return bd_lvm_lvcreate (data->vg_name, data->new_lv_name, data->new_lv_size, NULL /* type */, NULL /* pvs */, NULL /* extra_args */, error);
return bd_lvm_lvcreate (data->vg_name, data->new_lv_name, data->new_lv_size, data->new_lv_layout, data->new_lv_pvs, NULL /* extra_args */, error);
}

gboolean lvcreate_thin_pool_job_func (UDisksThreadedJob *job,
Expand Down Expand Up @@ -207,6 +207,15 @@ gboolean lv_vdo_deduplication_job_func (UDisksThreadedJob *job,
return bd_lvm_vdo_disable_deduplication (data->vg_name, data->lv_name, NULL /* extra_args */, error);
}

gboolean lvrepair_job_func (UDisksThreadedJob *job,
GCancellable *cancellable,
gpointer user_data,
GError **error)
{
LVJobData *data = user_data;
return bd_lvm_lvrepair (data->vg_name, data->lv_name, data->new_lv_pvs, NULL /* extra_args */, error);
}

gboolean vgcreate_job_func (UDisksThreadedJob *job,
GCancellable *cancellable,
gpointer user_data,
Expand Down Expand Up @@ -349,7 +358,7 @@ void lvs_task_func (GTask *task,
BDLVMLVdata **ret = NULL;
gchar *vg_name = (gchar*) task_data;

ret = bd_lvm_lvs (vg_name, &error);
ret = bd_lvm_lvs_tree (vg_name, &error);
if (!ret)
g_task_return_error (task, error);
else
Expand Down
7 changes: 7 additions & 0 deletions modules/lvm2/jobhelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ typedef struct {
const gchar *vg_name;
const gchar *lv_name;
const gchar *new_lv_name;
const gchar *new_lv_layout;
const gchar **new_lv_pvs;
const gchar *pool_name;
guint64 new_lv_size;
guint64 virtual_size;
Expand Down Expand Up @@ -98,6 +100,11 @@ gboolean lvresize_job_func (UDisksThreadedJob *job,
gpointer user_data,
GError **error);

gboolean lvrepair_job_func (UDisksThreadedJob *job,
GCancellable *cancellable,
gpointer user_data,
GError **error);

gboolean lvactivate_job_func (UDisksThreadedJob *job,
GCancellable *cancellable,
gpointer user_data,
Expand Down
Loading

0 comments on commit 18d8873

Please sign in to comment.