Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/plugins/lvm/lvm-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <glib.h>
#include <math.h>
#include <stdio.h>
#include <blockdev/utils.h>
#include <libdevmapper.h>

#include "lvm.h"
Expand Down Expand Up @@ -223,6 +224,19 @@ void bd_lvm_lvdata_free (BDLVMLVdata *data) {
g_free (data);
}

/* Valid vdo_index_memory_size_mb values: 256, 512, 768, or any multiple of 1024 */
void _lvm_check_vdo_index_memory (guint64 index_memory) {
guint64 index_memory_mb = index_memory / (1024 * 1024);

if (index_memory_mb != 256 && index_memory_mb != 512 && index_memory_mb != 768 &&
(index_memory_mb < 1024 || index_memory_mb % 1024 != 0))
bd_utils_log_format (BD_UTILS_LOG_WARNING,
"VDO index memory size %"G_GUINT64_FORMAT" MiB is not a valid value, "
"it will be rounded by LVM. "
"Valid values are 256, 512, 768, or a multiple of 1024.",
index_memory_mb);
}

BDLVMVDOPooldata* bd_lvm_vdopooldata_copy (BDLVMVDOPooldata *data) {
if (data == NULL)
return NULL;
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/lvm/lvm-dbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -3774,6 +3774,9 @@ gboolean bd_lvm_vdo_pool_create (const gchar *vg_name, const gchar *lv_name, con
extra_params = g_variant_builder_end (&builder);
g_variant_builder_clear (&builder);

if (index_memory != 0)
_lvm_check_vdo_index_memory (index_memory);

/* index_memory and write_policy can be specified only using the config */
g_mutex_lock (&global_config_lock);
old_config = global_config_str;
Expand Down Expand Up @@ -3998,6 +4001,9 @@ gboolean bd_lvm_vdo_pool_convert (const gchar *vg_name, const gchar *pool_lv, co
extra_params = g_variant_builder_end (&builder);
g_variant_builder_clear (&builder);

if (index_memory != 0)
_lvm_check_vdo_index_memory (index_memory);

/* index_memory and write_policy can be specified only using the config */
g_mutex_lock (&global_config_lock);
old_config = global_config_str;
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/lvm/lvm-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ extern gchar *global_config_str;

extern gchar *global_devices_str;

void _lvm_check_vdo_index_memory (guint64 index_memory);

#endif /* BD_LVM_PRIVATE */
6 changes: 6 additions & 0 deletions src/plugins/lvm/lvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2542,6 +2542,9 @@ gboolean bd_lvm_vdo_pool_create (const gchar *vg_name, const gchar *lv_name, con
} else
args[14] = vg_name;

if (index_memory != 0)
_lvm_check_vdo_index_memory (index_memory);

/* index_memory and write_policy can be specified only using the config */
g_mutex_lock (&global_config_lock);
old_config = global_config_str;
Expand Down Expand Up @@ -2789,6 +2792,9 @@ gboolean bd_lvm_vdo_pool_convert (const gchar *vg_name, const gchar *pool_lv, co
lv_spec = g_strdup_printf ("%s/%s", vg_name, pool_lv);
args[next_arg++] = lv_spec;

if (index_memory != 0)
_lvm_check_vdo_index_memory (index_memory);

/* index_memory and write_policy can be specified only using the config */
g_mutex_lock (&global_config_lock);
old_config = global_config_str;
Expand Down
16 changes: 7 additions & 9 deletions tests/_lvm_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2013,7 +2013,7 @@ def test_writecache_attach_detach(self):

class LvmVDOTest(LvmTestCase):

loop_size = 8 * 1024**3
loop_size = 9 * 1024**3

@classmethod
def setUpClass(cls):
Expand Down Expand Up @@ -2117,15 +2117,15 @@ def test_vdo_pool_create(self):

@tag_test(TestTags.SLOW)
def test_vdo_pool_create_options(self):
# set index size to 300 MiB, disable compression and write policy to sync
# set index size to 512 MiB, disable compression and write policy to sync
policy = BlockDev.lvm_get_vdo_write_policy_from_str("sync")
succ = BlockDev.lvm_vdo_pool_create("testVDOVG", "vdoLV", "vdoPool", 7 * 1024**3, 35 * 1024**3,
300 * 1024**2, False, True, policy)
succ = BlockDev.lvm_vdo_pool_create("testVDOVG", "vdoLV", "vdoPool", 8 * 1024**3, 35 * 1024**3,
512 * 1024**2, False, True, policy)
self.assertTrue(succ)

vdo_info = BlockDev.lvm_vdo_info("testVDOVG", "vdoPool")
self.assertIsNotNone(vdo_info)
self.assertEqual(vdo_info.index_memory_size, 300 * 1024**2)
self.assertEqual(vdo_info.index_memory_size, 512 * 1024**2)
self.assertFalse(vdo_info.compression)
self.assertTrue(vdo_info.deduplication)
self.assertEqual(BlockDev.lvm_get_vdo_write_policy_str(vdo_info.write_policy), "sync")
Expand Down Expand Up @@ -2166,8 +2166,7 @@ def test_resize(self):

@tag_test(TestTags.SLOW)
def test_enable_disable_compression(self):
succ = BlockDev.lvm_vdo_pool_create("testVDOVG", "vdoLV", "vdoPool", 7 * 1024**3, 35 * 1024**3,
300 * 1024**2)
succ = BlockDev.lvm_vdo_pool_create("testVDOVG", "vdoLV", "vdoPool", 7 * 1024**3, 35 * 1024**3)
self.assertTrue(succ)

# enabled by default
Expand All @@ -2193,8 +2192,7 @@ def test_enable_disable_compression(self):

@tag_test(TestTags.SLOW)
def test_enable_disable_deduplication(self):
succ = BlockDev.lvm_vdo_pool_create("testVDOVG", "vdoLV", "vdoPool", 7 * 1024**3, 35 * 1024**3,
300 * 1024**2)
succ = BlockDev.lvm_vdo_pool_create("testVDOVG", "vdoLV", "vdoPool", 7 * 1024**3, 35 * 1024**3)
self.assertTrue(succ)

# enabled by default
Expand Down
Loading