diff options
| -rw-r--r-- | meta-oe/recipes-extended/libblockdev/files/0001-lvm-Do-not-include-duplicate-entries-in-bd_lvm_lvs-o.patch | 100 | ||||
| -rw-r--r-- | meta-oe/recipes-extended/libblockdev/libblockdev_2.26.bb | 4 |
2 files changed, 103 insertions, 1 deletions
diff --git a/meta-oe/recipes-extended/libblockdev/files/0001-lvm-Do-not-include-duplicate-entries-in-bd_lvm_lvs-o.patch b/meta-oe/recipes-extended/libblockdev/files/0001-lvm-Do-not-include-duplicate-entries-in-bd_lvm_lvs-o.patch new file mode 100644 index 0000000000..e608358bf7 --- /dev/null +++ b/meta-oe/recipes-extended/libblockdev/files/0001-lvm-Do-not-include-duplicate-entries-in-bd_lvm_lvs-o.patch | |||
| @@ -0,0 +1,100 @@ | |||
| 1 | From d10fb2c0ee60c97f4dfeab4506a347c26cb389df Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Vojtech Trefny <vtrefny@redhat.com> | ||
| 3 | Date: Tue, 7 Dec 2021 15:50:45 +0800 | ||
| 4 | Subject: [PATCH] lvm: Do not include duplicate entries in bd_lvm_lvs output | ||
| 5 | |||
| 6 | We use "-o segtypes" for the "lvs" command which means multisegment | ||
| 7 | LVs will be twice in the output. | ||
| 8 | |||
| 9 | Signed-off-by: Vojtech Trefny <vtrefny@redhat.com> | ||
| 10 | |||
| 11 | Upstream-Status: Backport [https://github.com/storaged-project/libblockdev/pull/671] | ||
| 12 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> | ||
| 13 | --- | ||
| 14 | src/plugins/lvm.c | 17 +++++++++++++++-- | ||
| 15 | tests/lvm_test.py | 41 +++++++++++++++++++++++++++++++++++++++++ | ||
| 16 | 2 files changed, 56 insertions(+), 2 deletions(-) | ||
| 17 | |||
| 18 | diff --git a/src/plugins/lvm.c b/src/plugins/lvm.c | ||
| 19 | index 2be1dbd..acd5b84 100644 | ||
| 20 | --- a/src/plugins/lvm.c | ||
| 21 | +++ b/src/plugins/lvm.c | ||
| 22 | @@ -1810,8 +1810,21 @@ BDLVMLVdata** bd_lvm_lvs (const gchar *vg_name, GError **error) { | ||
| 23 | if (table && (num_items == 15)) { | ||
| 24 | /* valid line, try to parse and record it */ | ||
| 25 | lvdata = get_lv_data_from_table (table, TRUE); | ||
| 26 | - if (lvdata) | ||
| 27 | - g_ptr_array_add (lvs, lvdata); | ||
| 28 | + if (lvdata) { | ||
| 29 | + /* ignore duplicate entries in lvs output, these are caused by multi segments LVs */ | ||
| 30 | + for (gsize i = 0; i < lvs->len; i++) { | ||
| 31 | + if (g_strcmp0 (((BDLVMLVdata *) g_ptr_array_index (lvs, i))->lv_name, lvdata->lv_name) == 0) { | ||
| 32 | + g_debug("Duplicate LV entry for '%s' found in lvs output", | ||
| 33 | + lvdata->lv_name); | ||
| 34 | + bd_lvm_lvdata_free (lvdata); | ||
| 35 | + lvdata = NULL; | ||
| 36 | + break; | ||
| 37 | + } | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + if (lvdata) | ||
| 41 | + g_ptr_array_add (lvs, lvdata); | ||
| 42 | + } | ||
| 43 | } else | ||
| 44 | if (table) | ||
| 45 | g_hash_table_destroy (table); | ||
| 46 | diff --git a/tests/lvm_test.py b/tests/lvm_test.py | ||
| 47 | index eb94c91..ab0de21 100644 | ||
| 48 | --- a/tests/lvm_test.py | ||
| 49 | +++ b/tests/lvm_test.py | ||
| 50 | @@ -915,6 +915,47 @@ class LvmTestLVs(LvmPVVGLVTestCase): | ||
| 51 | lvs = BlockDev.lvm_lvs("testVG") | ||
| 52 | self.assertEqual(len(lvs), 1) | ||
| 53 | |||
| 54 | +class LvmTestLVsMultiSegment(LvmPVVGLVTestCase): | ||
| 55 | + def _clean_up(self): | ||
| 56 | + try: | ||
| 57 | + BlockDev.lvm_lvremove("testVG", "testLV2", True, None) | ||
| 58 | + except: | ||
| 59 | + pass | ||
| 60 | + | ||
| 61 | + LvmPVVGLVTestCase._clean_up(self) | ||
| 62 | + | ||
| 63 | + def test_lvs(self): | ||
| 64 | + """Verify that it's possible to gather info about LVs""" | ||
| 65 | + | ||
| 66 | + succ = BlockDev.lvm_pvcreate(self.loop_dev, 0, 0, None) | ||
| 67 | + self.assertTrue(succ) | ||
| 68 | + | ||
| 69 | + succ = BlockDev.lvm_vgcreate("testVG", [self.loop_dev], 0, None) | ||
| 70 | + self.assertTrue(succ) | ||
| 71 | + | ||
| 72 | + succ = BlockDev.lvm_lvcreate("testVG", "testLV", 10 * 1024**2) | ||
| 73 | + self.assertTrue(succ) | ||
| 74 | + | ||
| 75 | + lvs = BlockDev.lvm_lvs("testVG") | ||
| 76 | + self.assertEqual(len(lvs), 1) | ||
| 77 | + self.assertListEqual([lv.lv_name for lv in lvs], ["testLV"]) | ||
| 78 | + | ||
| 79 | + # add second LV | ||
| 80 | + succ = BlockDev.lvm_lvcreate("testVG", "testLV2", 10 * 1024**2) | ||
| 81 | + self.assertTrue(succ) | ||
| 82 | + | ||
| 83 | + lvs = BlockDev.lvm_lvs("testVG") | ||
| 84 | + self.assertEqual(len(lvs), 2) | ||
| 85 | + self.assertListEqual([lv.lv_name for lv in lvs], ["testLV", "testLV2"]) | ||
| 86 | + | ||
| 87 | + # by resizing the first LV we will create two segments | ||
| 88 | + succ = BlockDev.lvm_lvresize("testVG", "testLV", 20 * 1024**2, None) | ||
| 89 | + self.assertTrue(succ) | ||
| 90 | + | ||
| 91 | + lvs = BlockDev.lvm_lvs("testVG") | ||
| 92 | + self.assertEqual(len(lvs), 2) | ||
| 93 | + self.assertListEqual([lv.lv_name for lv in lvs], ["testLV", "testLV2"]) | ||
| 94 | + | ||
| 95 | class LvmPVVGthpoolTestCase(LvmPVVGTestCase): | ||
| 96 | def _clean_up(self): | ||
| 97 | try: | ||
| 98 | -- | ||
| 99 | 2.27.0 | ||
| 100 | |||
diff --git a/meta-oe/recipes-extended/libblockdev/libblockdev_2.26.bb b/meta-oe/recipes-extended/libblockdev/libblockdev_2.26.bb index c884b11339..b9c3bbb407 100644 --- a/meta-oe/recipes-extended/libblockdev/libblockdev_2.26.bb +++ b/meta-oe/recipes-extended/libblockdev/libblockdev_2.26.bb | |||
| @@ -10,7 +10,9 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=c07cb499d259452f324bb90c3067d85c" | |||
| 10 | 10 | ||
| 11 | inherit autotools gobject-introspection pkgconfig | 11 | inherit autotools gobject-introspection pkgconfig |
| 12 | 12 | ||
| 13 | SRC_URI = "git://github.com/storaged-project/libblockdev;branch=2.x-branch;protocol=https" | 13 | SRC_URI = "git://github.com/storaged-project/libblockdev;branch=2.x-branch;protocol=https \ |
| 14 | file://0001-lvm-Do-not-include-duplicate-entries-in-bd_lvm_lvs-o.patch \ | ||
| 15 | " | ||
| 14 | SRCREV = "47ff12242c89e36a33259d18b7068b26c3bb1c64" | 16 | SRCREV = "47ff12242c89e36a33259d18b7068b26c3bb1c64" |
| 15 | S = "${WORKDIR}/git" | 17 | S = "${WORKDIR}/git" |
| 16 | 18 | ||
