Skip to contentSkip to conversation

master - cache: Ability to convert an existing LV into a cached LV

PATCH Jonathan Brassow 1 participant 1 message Feb 12, 2014

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0912cf67aae21446a10b3a22067aee1e8f792856
Commit:        0912cf67aae21446a10b3a22067aee1e8f792856
Parent:        c8b6c4aee9a298a4c415d45c9e144d641bc7c6c6
Author:        Jonathan Brassow <[email protected]>
AuthorDate:    Wed Feb 12 09:55:35 2014 -0600
Committer:     Jonathan Brassow <[email protected]>
CommitterDate: Wed Feb 12 09:55:35 2014 -0600

cache: Ability to convert an existing LV into a cached LV

Users now have the ability to convert their existing logical volumes into cached logical volumes. A cache pool LV must be specified using the '--cachepool' argument. The cachepool is the small, fast LV used to cache the large, slow LV that is being converted.

---
 lib/metadata/cache_manip.c |    7 +++++
 tools/args.h               |    1 +
 tools/commands.h           |    9 +++++-
 tools/lvconvert.c          |   54 ++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 67 insertions(+), 4 deletions(-)
lib/metadata/cache_manip.c +7 -0
index f7518b0..673d90e 100644
@@ -104,6 +104,13 @@ struct logical_volume *lv_cache_create(struct logical_volume *pool,
 		return NULL;
 	}
 
+	if (!dm_list_empty(&pool->segs_using_this_lv)) {
+		seg = get_only_segment_using_this_lv(pool);
+		log_error("%s is already in use by %s",
+			  pool->name, seg ? seg->lv->name : "another LV");
+		return NULL;
+	}
+
 	if (lv_is_cache_type(origin)) {
 		/*
 		 * FIXME: We can layer caches, insert_layer_for_lv() would
tools/args.h +1 -0
index 5f26511..f1a4ef4 100644
@@ -63,6 +63,7 @@ arg(config_ARG, '\0', "config", string_arg, 0)
 arg(trustcache_ARG, '\0', "trustcache", NULL, 0)
 arg(cache_ARG, '\0', "cache", NULL, 0)
 arg(cachemode_ARG, '\0', "cachemode", string_arg, 0)
+arg(cachepool_ARG, '\0', "cachepool", string_arg, 0)
 arg(ignoremonitoring_ARG, '\0', "ignoremonitoring", NULL, 0)
 arg(nameprefixes_ARG, '\0', "nameprefixes", NULL, 0)
 arg(unquoted_ARG, '\0', "unquoted", NULL, 0)
tools/commands.h +7 -2
index a078b16..b0d608b 100644
@@ -221,9 +221,14 @@ xx(lvconvert,
    "\t[--poolmetadata CacheMetadataLogicalVolume[Path] |\n"
    "\t [--poolmetadatasize size]\n"
    "\t [--poolmetadataspare {y|n}]]\n"
-   "\tCacheDataLogicalVolume[Path]\n\n",
+   "\tCacheDataLogicalVolume[Path]\n\n"
 
-   alloc_ARG, background_ARG, cachemode_ARG, chunksize_ARG,
+   "lvconvert "
+   "--type cache\n"
+   "\t--cachepool CachePoolLogicalVolume[Path]\n"
+   "\tLogicalVolume[Path]\n\n",
+
+   alloc_ARG, background_ARG, cachemode_ARG, cachepool_ARG, chunksize_ARG,
    corelog_ARG, discards_ARG, force_ARG, interval_ARG, merge_ARG, mirrorlog_ARG,
    mirrors_ARG, name_ARG, noudevsync_ARG, originname_ARG, poolmetadata_ARG,
    poolmetadatasize_ARG, poolmetadataspare_ARG, readahead_ARG, regionsize_ARG,
tools/lvconvert.c +52 -2

84 lines not on this page · raw message