Skip to content

Commit

Permalink
lvm: Enhancements for LVM2 RAID support
Browse files Browse the repository at this point in the history
  • Loading branch information
mvollmer committed Jul 5, 2022
1 parent b4a260a commit 35aa780
Show file tree
Hide file tree
Showing 15 changed files with 616 additions and 17 deletions.
83 changes: 82 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,12 @@
-->
<property name="NeedsPolling" type="b" access="read"/>

<!-- MissingPhysicalVolumes:
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 +257,26 @@
<arg name="options" direction="in" type="a{sv}"/>
</method>

<!-- RemoveMissingPhysicalVolumes:
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 +287,29 @@
<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.
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 +478,29 @@
-->
<property name="Type" type="s" access="read"/>

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

<!-- Structure:
The detailed structure of how this logical volume is stored on physical volumes.
-->
<property name="Structure" type="a{sv}" access="read"/>

<!-- SyncRatio:
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 +622,22 @@
<arg name="options" type="a{sv}" direction="in"/>
</method>

<!-- Repair:
@pvs: A list of physical volumes to use for the repair.
@options: Additional options.
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 35aa780

Please sign in to comment.