All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Brassow <jbrassow@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH] cache: Properly rename origin LV tree when adding "_corig" suffix
Date: Thu, 05 Jun 2014 23:26:00 -0500	[thread overview]
Message-ID: <1402028760.4356.4.camel@f16> (raw)

Currently, when creating a cache LV that has a RAID origin LV, the
sub-LVs are not properly renamed.  The reason is that
insert_layer_for_lv does not take sub-LVs into account when adding the
layer suffix.  I've worked around this in lv_cache_create, but I wonder
if the solution should be added to insert_layer_for_lv instead...

 brassow

cache: Properly rename origin LV tree when adding "_corig"

When creating a cache LV with a RAID origin, we need to ensure that
the sub-LVs of that origin properly change their names to include
the "_corig" extention of the top-level LV.  We do this by first
performing a 'lv_rename_update' before making the call to
'insert_layer_for_lv'.

Index: lvm2/lib/metadata/cache_manip.c
===================================================================
--- lvm2.orig/lib/metadata/cache_manip.c
+++ lvm2/lib/metadata/cache_manip.c
@@ -91,6 +91,8 @@ struct logical_volume *lv_cache_create(s
 	struct cmd_context *cmd = pool->vg->cmd;
 	struct logical_volume *cache_lv;
 	struct lv_segment *seg;
+	int origin_name_len = strlen(origin->name);
+	char origin_name[origin_name_len + 7]; /* + "_corig" and NULL */
 
 	if (!lv_is_cache_pool(pool)) {
 		log_error(INTERNAL_ERROR
@@ -122,8 +124,23 @@ struct logical_volume *lv_cache_create(s
 	if (!(segtype = get_segtype_from_string(cmd, "cache")))
 		return_NULL;
 
+	/*
+	 * insert_layer_for_lv does not rename the sub-LVs when adding
+	 * the suffix.  So, we rename everything here and then change
+	 * only the top-level LV back before adding the layer.
+	 */
+	sprintf(origin_name, "%s_corig", origin->name);
+	if (!lv_rename_update(cmd, origin, origin_name, 0)) {
+		log_error("Failed to rename origin LV, %s", origin->name);
+		return NULL;
+	}
+	
+	origin_name[origin_name_len] = '\0';	
+	if (!(origin->name = dm_pool_strdup(origin->vg->vgmem, origin_name)))
+		return_0;
+
 	cache_lv = origin;
-	if (!insert_layer_for_lv(cmd, cache_lv, CACHE, "_corig"))
+	if (!(origin = insert_layer_for_lv(cmd, cache_lv, CACHE, "_corig")))
 		return_NULL;
 
 	seg = first_seg(cache_lv);




                 reply	other threads:[~2014-06-06  4:26 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=1402028760.4356.4.camel@f16 \
    --to=jbrassow@redhat.com \
    --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.