Skip to content

Commit

Permalink
Add support for creating and managing LVM VDO volumes
Browse files Browse the repository at this point in the history
New interface 'org.freedesktop.UDisks2.VDOVolume' was added for
the LVM VDO volumes. New volumes can be created using the new
'CreateVDOVolume' method.
  • Loading branch information
vojtechtrefny committed Feb 12, 2020
1 parent db5f487 commit 492f9c3
Show file tree
Hide file tree
Showing 16 changed files with 763 additions and 10 deletions.
1 change: 1 addition & 0 deletions doc/udisks2-docs.xml.lvm2.dbus.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<xi:include href="../modules/lvm2/udisks-generated-doc-org.freedesktop.UDisks2.Block.LVM2.xml"/>
<xi:include href="../modules/lvm2/udisks-generated-doc-org.freedesktop.UDisks2.LogicalVolume.xml"/>
<xi:include href="../modules/lvm2/udisks-generated-doc-org.freedesktop.UDisks2.VDOVolume.xml"/>
<xi:include href="../modules/lvm2/udisks-generated-doc-org.freedesktop.UDisks2.Manager.LVM2.xml"/>
<xi:include href="../modules/lvm2/udisks-generated-doc-org.freedesktop.UDisks2.PhysicalVolume.xml"/>
<xi:include href="../modules/lvm2/udisks-generated-doc-org.freedesktop.UDisks2.VolumeGroup.xml"/>
1 change: 1 addition & 0 deletions doc/udisks2-docs.xml.lvm2.generated.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
<xi:include href="../doc/xml/UDisksPhysicalVolume.xml"/>
<xi:include href="../doc/xml/UDisksVolumeGroup.xml"/>
<xi:include href="../doc/xml/UDisksLogicalVolume.xml"/>
<xi:include href="../doc/xml/UDisksVDOVolume.xml"/>
76 changes: 76 additions & 0 deletions doc/udisks2-sections.txt.lvm2.sections.in
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ udisks_volume_group_complete_remove_device
udisks_volume_group_complete_create_plain_volume
udisks_volume_group_complete_create_thin_pool_volume
udisks_volume_group_complete_create_thin_volume
udisks_volume_group_complete_create_vdo_volume
udisks_volume_group_proxy_new
udisks_volume_group_proxy_new_finish
udisks_volume_group_proxy_new_sync
Expand Down Expand Up @@ -243,3 +244,78 @@ udisks_logical_volume_skeleton_notify
udisks_logical_volume_skeleton_parent_class
udisks_logical_volume_skeleton_set_property
</SECTION>

<SECTION>
<FILE>UDisksVDOVolume</FILE>
UDisksVDOVolume
UDisksVDOVolumeIface
UDisksVDOVolumeProxy
UDisksVDOVolumeProxyClass
UDisksVDOVolumeSkeleton
UDisksVDOVolumeSkeletonClass
udisks_vdo_volume_call_enable_compression
udisks_vdo_volume_call_enable_deduplication
udisks_vdo_volume_complete_enable_compression
udisks_vdo_volume_complete_enable_deduplication
udisks_vdo_volume_dup_operating_mode
udisks_vdo_volume_dup_compression_state
udisks_vdo_volume_dup_index_state
udisks_vdo_volume_dup_used_size
udisks_vdo_volume_get_compression
udisks_vdo_volume_get_deduplication
udisks_vdo_volume_get_operating_mode
udisks_vdo_volume_get_compression_state
udisks_vdo_volume_get_index_state
udisks_vdo_volume_get_used_size
udisks_vdo_volume_interface_info
udisks_vdo_volume_override_properties
udisks_vdo_volume_proxy_class_init
udisks_vdo_volume_proxy_class_intern_init
udisks_vdo_volume_proxy_finalize
udisks_vdo_volume_proxy_get_compression
udisks_vdo_volume_proxy_get_deduplication
udisks_vdo_volume_proxy_get_data_allocated_ratio
udisks_vdo_volume_proxy_get_instance_private
udisks_vdo_volume_proxy_get_metadata_allocated_ratio
udisks_vdo_volume_proxy_get_operating_mode
udisks_vdo_volume_proxy_get_property
udisks_vdo_volume_proxy_get_index_state
udisks_vdo_volume_proxy_get_used_size
udisks_vdo_volume_proxy_g_properties_changed
udisks_vdo_volume_proxy_g_signal
udisks_vdo_volume_proxy_iface_init
udisks_vdo_volume_proxy_init
udisks_vdo_volume_proxy_new
udisks_vdo_volume_proxy_new_finish
udisks_vdo_volume_proxy_new_for_bus
udisks_vdo_volume_proxy_new_for_bus_finish
udisks_vdo_volume_proxy_new_for_bus_sync
udisks_vdo_volume_proxy_new_sync
udisks_vdo_volume_proxy_parent_class
udisks_vdo_volume_proxy_set_property
udisks_vdo_volume_proxy_set_property_cb
udisks_vdo_volume_set_compression
udisks_vdo_volume_set_deduplication
udisks_vdo_volume_set_operating_mode
udisks_vdo_volume_set_index_state
udisks_vdo_volume_set_used_size
udisks_vdo_volume_skeleton_class_init
udisks_vdo_volume_skeleton_class_intern_init
udisks_vdo_volume_skeleton_dbus_interface_flush
udisks_vdo_volume_skeleton_dbus_interface_get_info
udisks_vdo_volume_skeleton_dbus_interface_get_properties
udisks_vdo_volume_skeleton_dbus_interface_get_vtable
udisks_vdo_volume_skeleton_finalize
udisks_vdo_volume_skeleton_get_compression
udisks_vdo_volume_skeleton_get_deduplication
udisks_vdo_volume_skeleton_get_instance_private
udisks_vdo_volume_skeleton_get_operating_mode
udisks_vdo_volume_skeleton_get_property
udisks_vdo_volume_skeleton_get_used_size
udisks_vdo_volume_skeleton_iface_init
udisks_vdo_volume_skeleton_init
udisks_vdo_volume_skeleton_new
udisks_vdo_volume_skeleton_notify
udisks_vdo_volume_skeleton_parent_class
udisks_vdo_volume_skeleton_set_property
</SECTION>
1 change: 1 addition & 0 deletions modules/lvm2/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ libudisks2_lvm2_la_SOURCES = \
udiskslinuxphysicalvolume.h udiskslinuxphysicalvolume.c \
udiskslinuxvolumegroup.h udiskslinuxvolumegroup.c \
udiskslinuxvolumegroupobject.h udiskslinuxvolumegroupobject.c \
udiskslinuxvdovolume.h udiskslinuxvdovolume.c \
udiskslinuxblocklvm2.h udiskslinuxblocklvm2.c \
udiskslvm2daemonutil.h udiskslvm2daemonutil.c \
udiskslvm2dbusutil.h udiskslvm2dbusutil.c \
Expand Down
143 changes: 143 additions & 0 deletions modules/lvm2/data/org.freedesktop.UDisks2.lvm2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,53 @@
<arg name="result" type="o" direction="out"/>
</method>

<!-- CreateVDOVolume:
@lv_name: The name of the to-be-created VDO LV.
@pool_name: The name of the to-be-created VDO pool LV.
@data_size: The size of the data VDO LV (physical size of the @pool_name VDO pool LV).
@virtual_size: The virtual_size of the @lv_name VDO LV or 0 for default (@data_size minus metadata).
@index_memory: Amount of index memory in bytes or 0 for default.
@compression: Enables or disables compression when creating the VDO volume.
@deduplication: Enables or disables deduplication when creating the VDO volume.
@write_policy: Specifies the write policy.
@options: Additional options.
@result: The object path of the new VDO logical volume.
@since: 2.9.0
Create a new VDO logical volume that is backed by a newly created
VDO pool. The VDO data logical volume and VDO pool logical volume
are created together, VDO pool supports only a single VDO LV.
The @data_size parameter is the total amount of space
taken out of the volume group and it's the size of the @pool_name
VDO pool logical volume.
The @virtual_size is the size of the @lv_name VDO logical volume
and represents expected amount of the data that can be stored
after deduplication and compression.
No additional options are currently defined.
Known @write_policy values include:
<variablelist>
<varlistentry><term>sync</term><listitem><para>Writes are acknowledged only after data is on stable storage. 'sync' policy is not supported if the underlying storage is not also synchronous.</para></listitem></varlistentry>
<varlistentry><term>async</term><listitem><para>Writes are acknowledged when data has been cached for writing to stable storage; data which has not been flushed is not guaranteed to persist in this mode.</para></listitem></varlistentry>
<varlistentry><term>auto</term><listitem><para>VDO will check the storage device and determine whether it supports flushes. If it does, VDO will run in async mode, otherwise it will run in sync mode.</para></listitem></varlistentry>
</variablelist>
-->
<method name="CreateVDOVolume">
<arg name="lv_name" type="s" direction="in"/>
<arg name="pool_name" type="s" direction="in"/>
<arg name="data_size" type="t" direction="in"/>
<arg name="virtual_size" type="t" direction="in"/>
<arg name="index_memory" type="t" direction="in" />
<arg name="compression" type="b" direction="in" />
<arg name="deduplication" type="b" direction="in" />
<arg name="write_policy" type="s" direction="in" />
<arg name="options" type="a{sv}" direction="in"/>
<arg name="result" type="o" direction="out"/>
<annotation name="org.gtk.GDBus.C.Name" value="Create_VDO_Volume"/>
</method>

</interface>

<!-- ********************************************************************** -->
Expand Down Expand Up @@ -578,4 +625,100 @@

<!-- ********************************************************************** -->

<!--
org.freedesktop.UDisks2.VDOVolume:
@short_description: A VDO logical volume
@since: 2.9.0
Objects with this interface represent VDO logical volumes in a
volume group.
VDO logical volume objects are children of their VDO pool
object, and also link to it via the #VDOPool property.
-->
<interface name="org.freedesktop.UDisks2.VDOVolume">
<annotation name="org.gtk.GDBus.C.Name" value="VDO_Volume"/>

<!-- VDOPool:
Object path of the VDO pool for this volume.
-->

<property name="VDOPool" type="o" access="read">
<annotation name="org.gtk.GDBus.C.Name" value="VDO_Pool"/>
</property>

<!-- OperatingMode:
Operating mode of the VDO volume.
One of "normal", "read-only" or "recovering".
-->
<property name="OperatingMode" type="s" access="read"/>

<!-- CompressionState:
Compression state of the VDO volume.
One of "online" or "offline".
-->
<property name="CompressionState" type="s" access="read"/>

<!-- IndexState:
State of the VDO index of the volume.
One of "online", "offline", "opening", "closing", "closed"
or "error".
-->
<property name="IndexState" type="s" access="read"/>

<!-- UsedSize:
The total physical size used by this VDO volume.
-->
<property name="UsedSize" type="t" access="read"/>

<!-- Compression:
Indicates whether compression is enabled.
-->
<property name="Compression" type="b" access="read" />

<!-- Deduplication:
Indicates whether deduplication is enabled.
-->
<property name="Deduplication" type="b" access="read" />

<!--
EnableCompression:
@enable: A boolean value indicating whether compression should be enabled.
@options: Additional options (currently unused except for <link linkend="udisks-std-options">standard options</link>).
Enables or disables compression on the VDO volume. If the VDO volume
is running, takes effect immediately.
-->
<method name="EnableCompression">
<arg name="enable" direction="in" type="b" />
<arg name="options" direction="in" type="a{sv}" />
</method>

<!--
EnableDeduplication:
@enable: A boolean value indicating whether deduplication should be enabled.
@options: Additional options (currently unused except for <link linkend="udisks-std-options">standard options</link>).
Enables or disables deduplication on the VDO volume. If the VDO volume
is running, takes effect immediately.
-->
<method name="EnableDeduplication">
<arg name="enable" direction="in" type="b" />
<arg name="options" direction="in" type="a{sv}" />
</method>

</interface>

<!-- ********************************************************************** -->

</node>
42 changes: 42 additions & 0 deletions modules/lvm2/jobhelpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,24 @@ gboolean lvcreate_thin_job_func (UDisksThreadedJob *job,
return bd_lvm_thlvcreate (data->vg_name, data->pool_name, data->new_lv_name, data->new_lv_size, NULL /* extra_args */, error);
}

gboolean lvcreate_vdo_job_func (UDisksThreadedJob *job,
GCancellable *cancellable,
gpointer user_data,
GError **error)
{
LVJobData *data = user_data;
BDLVMVDOWritePolicy policy;

policy = bd_lvm_get_vdo_write_policy_from_str (data->write_policy, error);
if (policy == BD_LVM_VDO_WRITE_POLICY_UNKNOWN)
return FALSE;

return bd_lvm_vdo_pool_create (data->vg_name, data->new_lv_name, data->pool_name, data->new_lv_size,
data->virtual_size, data->index_memory, data->compression, data->deduplication,
policy, NULL /* extra_args */, error);

}

gboolean lvremove_job_func (UDisksThreadedJob *job,
GCancellable *cancellable,
gpointer user_data,
Expand Down Expand Up @@ -165,6 +183,30 @@ gboolean lvcache_detach_job_func (UDisksThreadedJob *job,
return bd_lvm_cache_detach (data->vg_name, data->lv_name, data->destroy, NULL /* extra_args */, error);
}

gboolean lv_vdo_compression_job_func (UDisksThreadedJob *job,
GCancellable *cancellable,
gpointer user_data,
GError **error)
{
LVJobData *data = user_data;
if (data->compression)
return bd_lvm_vdo_enable_compression (data->vg_name, data->lv_name, NULL /* extra_args */, error);
else
return bd_lvm_vdo_disable_compression (data->vg_name, data->lv_name, NULL /* extra_args */, error);
}

gboolean lv_vdo_deduplication_job_func (UDisksThreadedJob *job,
GCancellable *cancellable,
gpointer user_data,
GError **error)
{
LVJobData *data = user_data;
if (data->deduplication)
return bd_lvm_vdo_enable_deduplication (data->vg_name, data->lv_name, NULL /* extra_args */, error);
else
return bd_lvm_vdo_disable_deduplication (data->vg_name, data->lv_name, NULL /* extra_args */, error);
}

gboolean vgcreate_job_func (UDisksThreadedJob *job,
GCancellable *cancellable,
gpointer user_data,
Expand Down
19 changes: 19 additions & 0 deletions modules/lvm2/jobhelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,15 @@ typedef struct {
const gchar *new_lv_name;
const gchar *pool_name;
guint64 new_lv_size;
guint64 virtual_size;
guint64 extent_size;
gboolean resize_fs;
gboolean force;
gboolean destroy;
gboolean deduplication;
gboolean compression;
guint64 index_memory;
const gchar *write_policy;
} LVJobData;

typedef struct {
Expand Down Expand Up @@ -73,6 +78,11 @@ gboolean lvcreate_thin_job_func (UDisksThreadedJob *job,
gpointer user_data,
GError **error);

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

gboolean lvremove_job_func (UDisksThreadedJob *job,
GCancellable *cancellable,
gpointer user_data,
Expand Down Expand Up @@ -113,6 +123,15 @@ gboolean lvcache_detach_job_func (UDisksThreadedJob *job,
gpointer user_data,
GError **error);

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

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

gboolean vgcreate_job_func (UDisksThreadedJob *job,
GCancellable *cancellable,
Expand Down

0 comments on commit 492f9c3

Please sign in to comment.