All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Teigland <teigland@sourceware.org>
To: lvm-devel@redhat.com
Subject: main - writecache: allow attaching to thin pool data
Date: Thu,  6 May 2021 21:32:41 +0000 (GMT)	[thread overview]
Message-ID: <20210506213241.F0105384C003@sourceware.org> (raw)

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6b00c8c9109b0b6111d4adb9918cccc407ac448f
Commit:        6b00c8c9109b0b6111d4adb9918cccc407ac448f
Parent:        92fcfc59b2b0a81121771cab3b21ec5dde797510
Author:        David Teigland <teigland@redhat.com>
AuthorDate:    Thu May 6 16:18:50 2021 -0500
Committer:     David Teigland <teigland@redhat.com>
CommitterDate: Thu May 6 16:23:03 2021 -0500

writecache: allow attaching to thin pool data

---
 tools/command-lines.in |  4 ++--
 tools/lvconvert.c      | 14 ++++++++++++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/tools/command-lines.in b/tools/command-lines.in
index 164516a2e..1107c1e02 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -493,7 +493,7 @@ AUTOTYPE: cache
 
 ---
 
-lvconvert --type writecache --cachevol LV LV_linear_striped_raid
+lvconvert --type writecache --cachevol LV LV_linear_striped_raid_thinpool
 OO: OO_LVCONVERT, --cachesettings String
 ID: lvconvert_to_writecache
 DESC: Attach a writecache to an LV, converts the LV to type writecache.
@@ -520,7 +520,7 @@ FLAGS: SECONDARY_SYNTAX
 
 ---
 
-lvconvert --type writecache --cachedevice PV LV_linear_striped_raid
+lvconvert --type writecache --cachedevice PV LV_linear_striped_raid_thinpool
 OO: OO_LVCONVERT, --cachesize SizeMB, --cachesettings String
 ID: lvconvert_to_writecache_with_device
 DESC: Add a writecache to an LV, using a specified cache device.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 990a723b6..8dd8a15c4 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -6106,6 +6106,7 @@ int lvconvert_writecache_attach_single(struct cmd_context *cmd,
 					struct processing_handle *handle)
 {
 	struct volume_group *vg = lv->vg;
+	struct logical_volume *lv_update;
 	struct logical_volume *lv_wcorig;
 	struct logical_volume *lv_fast;
 	struct writecache_settings settings = { 0 };
@@ -6228,6 +6229,15 @@ int lvconvert_writecache_attach_single(struct cmd_context *cmd,
 
 	lv_fast->status |= LV_CACHE_VOL;
 
+	/* When the lv arg is a thinpool, redirect update to data sub lv. */
+
+	if (lv_is_thin_pool(lv)) {
+		lv_update = seg_lv(first_seg(lv), 0);
+		log_verbose("Redirecting operation to data sub LV %s.", display_lvname(lv_update));
+	} else {
+		lv_update = lv;
+	}
+
 	/*
 	 * Changes the vg struct to match the desired state.
 	 *
@@ -6240,7 +6250,7 @@ int lvconvert_writecache_attach_single(struct cmd_context *cmd,
 	 *   gets new id, becomes hidden, gets segments from lv.
 	 */
 
-	if (!(lv_wcorig = _lv_writecache_create(cmd, lv, lv_fast, block_size_sectors, &settings)))
+	if (!(lv_wcorig = _lv_writecache_create(cmd, lv_update, lv_fast, block_size_sectors, &settings)))
 		goto_bad;
 
 	/*
@@ -6248,7 +6258,7 @@ int lvconvert_writecache_attach_single(struct cmd_context *cmd,
 	 * where the old LV is suspended and the new LV is resumed.
 	 */
 
-	if (!lv_update_and_reload(lv))
+	if (!lv_update_and_reload(lv_update))
 		goto_bad;
 
 	lockd_lv(cmd, lv, "un", 0);



                 reply	other threads:[~2021-05-06 21:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210506213241.F0105384C003@sourceware.org \
    --to=teigland@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.