Skip to contentSkip to conversation

master - lvmdbusd: Add support for LVM writecache

PATCH Tony Asleson 1 participant 1 message Aug 6, 2020

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8f1068c02d06e9104c47db0131617c8f98d31718
Commit:        8f1068c02d06e9104c47db0131617c8f98d31718
Parent:        e12bdd591a1e60f055baee6cf5e9a144ea245a33
Author:        Vojtech Trefny <[email protected]>
AuthorDate:    Wed Jul 1 13:27:46 2020 +0200
Committer:     Tony Asleson <[email protected]>
CommitterDate: Thu Aug 6 13:54:34 2020 -0500

lvmdbusd: Add support for LVM writecache

---
 daemons/lvmdbusd/cmdhandler.py |  9 +++++++++
 daemons/lvmdbusd/lv.py         | 43 ++++++++++++++++++++++++++++++++++++++++++
 test/dbus/lvmdbustest.py       | 30 +++++++++++++++++++++++++++++
 3 files changed, 82 insertions(+)
daemons/lvmdbusd/cmdhandler.py +9 -0
index 7d2f4c4ba..1c15b7888 100644
@@ -453,6 +453,15 @@ def lv_cache_lv(cache_pool_full_name, lv_full_name, cache_options):
 	return call(cmd)
 
 
+def lv_writecache_lv(cache_lv_full_name, lv_full_name, cache_options):
+	# lvconvert --type writecache --cachevol VG/CacheLV VG/OriginLV
+	cmd = ['lvconvert']
+	cmd.extend(options_to_cli_args(cache_options))
+	cmd.extend(['-y', '--type', 'writecache', '--cachevol',
+				cache_lv_full_name, lv_full_name])
+	return call(cmd)
+
+
 def lv_detach_cache(lv_full_name, detach_options, destroy_cache):
 	cmd = ['lvconvert']
 	if destroy_cache:
daemons/lvmdbusd/lv.py +43 -0

49 lines not on this page · raw message

test/dbus/lvmdbustest.py +30 -0
index 8753e65d0..efa1afb26 100755
@@ -1558,6 +1558,36 @@ class TestDbusService(unittest.TestCase):
 			cached_lv.Lv.Rename(dbus.String(new_name), dbus.Int32(g_tmo), EOD))
 		verify_cache_lv_count()
 
+	def test_writecache_lv(self):
+		vg = self._vg_create().Vg
+		data_lv = self._create_lv(size=mib(16), vg=vg)
+		cache_lv = self._create_lv(size=mib(16), vg=vg)
+
+		# both LVs need to be inactive
+		self.handle_return(data_lv.Lv.Deactivate(
+			dbus.UInt64(0), dbus.Int32(g_tmo), EOD))
+		data_lv.update()
+		self.handle_return(cache_lv.Lv.Deactivate(
+			dbus.UInt64(0), dbus.Int32(g_tmo), EOD))
+		cache_lv.update()
+
+		cached_lv_path = self.handle_return(
+			cache_lv.Lv.WriteCacheLv(
+				dbus.ObjectPath(data_lv.object_path),
+				dbus.Int32(g_tmo),
+				EOD))
+
+		intf = (LV_COMMON_INT, LV_INT, CACHE_LV_INT)
+		cached_lv = ClientProxy(self.bus, cached_lv_path, interfaces=intf)
+		self.assertEqual(cached_lv.LvCommon.SegType, ["writecache"])
+
+		uncached_lv_path = self.handle_return(
+				cached_lv.CachedLv.DetachCachePool(
+					dbus.Boolean(True),
+					dbus.Int32(g_tmo),
+					EOD))
+		self.assertTrue('/com/redhat/lvmdbus1/Lv' in uncached_lv_path)
+
 	def test_vg_change(self):
 		vg_proxy = self._vg_create()