@@ -4034,11 +4034,69 @@ gboolean bd_lvm_vdo_pool_resize (const gchar *vg_name, const gchar *pool_name, g
40344034 *
40354035 * Tech category: %BD_LVM_TECH_VDO-%BD_LVM_TECH_MODE_CREATE&%BD_LVM_TECH_MODE_MODIFY
40364036 */
4037- gboolean bd_lvm_vdo_pool_convert (const gchar * vg_name G_GNUC_UNUSED , const gchar * pool_lv G_GNUC_UNUSED , const gchar * name G_GNUC_UNUSED ,
4038- guint64 virtual_size G_GNUC_UNUSED , guint64 index_memory G_GNUC_UNUSED , gboolean compression G_GNUC_UNUSED ,
4039- gboolean deduplication G_GNUC_UNUSED , BDLVMVDOWritePolicy write_policy G_GNUC_UNUSED ,
4040- const BDExtraArg * * extra G_GNUC_UNUSED , GError * * error ) {
4041- return bd_lvm_is_tech_avail (BD_LVM_TECH_VDO , BD_LVM_TECH_MODE_CREATE | BD_LVM_TECH_MODE_MODIFY , error );
4037+ gboolean bd_lvm_vdo_pool_convert (const gchar * vg_name , const gchar * pool_lv , const gchar * name ,
4038+ guint64 virtual_size , guint64 index_memory , gboolean compression ,
4039+ gboolean deduplication , BDLVMVDOWritePolicy write_policy ,
4040+ const BDExtraArg * * extra , GError * * error ) {
4041+ GVariantBuilder builder ;
4042+ GVariant * params = NULL ;
4043+ GVariant * extra_params = NULL ;
4044+ g_autofree gchar * obj_id = NULL ;
4045+ g_autofree gchar * pool_lv_path = NULL ;
4046+ g_autofree gchar * lvname = NULL ;
4047+ gchar * old_config = NULL ;
4048+ const gchar * write_policy_str = NULL ;
4049+ gboolean ret = FALSE;
4050+
4051+ obj_id = g_strdup_printf ("%s/%s" , vg_name , pool_lv );
4052+ pool_lv_path = get_object_path (obj_id , error );
4053+ if (!pool_lv_path )
4054+ return FALSE;
4055+
4056+ write_policy_str = bd_lvm_get_vdo_write_policy_str (write_policy , error );
4057+ if (write_policy_str == NULL )
4058+ return FALSE;
4059+
4060+ /* build the params tuple */
4061+ g_variant_builder_init (& builder , G_VARIANT_TYPE_TUPLE );
4062+
4063+ g_variant_builder_add_value (& builder , g_variant_new ("o" , pool_lv_path ));
4064+
4065+ if (!name ) {
4066+ lvname = g_strdup_printf ("%s_vdolv" , pool_lv );
4067+ g_variant_builder_add_value (& builder , g_variant_new ("s" , lvname ));
4068+ } else
4069+ g_variant_builder_add_value (& builder , g_variant_new ("s" , name ));
4070+
4071+ g_variant_builder_add_value (& builder , g_variant_new ("t" , virtual_size ));
4072+ params = g_variant_builder_end (& builder );
4073+ g_variant_builder_clear (& builder );
4074+
4075+ /* and now the extra_params params */
4076+ g_variant_builder_init (& builder , G_VARIANT_TYPE_DICTIONARY );
4077+ g_variant_builder_add_value (& builder , g_variant_new ("{sv}" , "--compression" , g_variant_new ("s" , compression ? "y" : "n" )));
4078+ g_variant_builder_add_value (& builder , g_variant_new ("{sv}" , "--deduplication" , g_variant_new ("s" , deduplication ? "y" : "n" )));
4079+ extra_params = g_variant_builder_end (& builder );
4080+ g_variant_builder_clear (& builder );
4081+
4082+ /* index_memory and write_policy can be specified only using the config */
4083+ g_mutex_lock (& global_config_lock );
4084+ old_config = global_config_str ;
4085+ if (index_memory != 0 )
4086+ global_config_str = g_strdup_printf ("%s allocation {vdo_index_memory_size_mb=%" G_GUINT64_FORMAT " vdo_write_policy=\"%s\"}" , old_config ? old_config : "" ,
4087+ index_memory / (1024 * 1024 ),
4088+ write_policy_str );
4089+ else
4090+ global_config_str = g_strdup_printf ("%s allocation {vdo_write_policy=\"%s\"}" , old_config ? old_config : "" ,
4091+ write_policy_str );
4092+
4093+ ret = call_lvm_obj_method_sync (vg_name , VG_VDO_INTF , "CreateVdoPool" , params , extra_params , extra , FALSE, error );
4094+
4095+ g_free (global_config_str );
4096+ global_config_str = old_config ;
4097+ g_mutex_unlock (& global_config_lock );
4098+
4099+ return ret ;
40424100}
40434101
40444102/**
0 commit comments