master - pool: use validation
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=59ced3c28186e6...
Commit: 59ced3c28186e6d45e2e8374b04e32256f636a82
Parent: a2aa609810d7d0d6b8ff5b9fe8c6e1e13fbfbbac
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 6 12:22:51 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 6 15:23:07 2014 +0200
pool: use validation
---
lib/metadata/cache_manip.c | 18 ++++--------------
lib/metadata/metadata-exported.h | 6 ++++--
lib/metadata/pool_manip.c | 4 ++--
lib/metadata/thin_manip.c | 16 ++++------------
4 files changed, 14 insertions(+), 30 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 350a18e..895eaff 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -39,7 +39,8 @@ const char *get_cachepool_cachemode_name(const struct lv_segment *seg)
return "unknown";
}
-int update_cache_pool_params(struct volume_group *vg, unsigned attr,
+int update_cache_pool_params(const struct segment_type *segtype,
+ struct volume_group *vg, unsigned attr,
int passed_args, uint32_t data_extents,
uint64_t *pool_metadata_size,
int *chunk_size_calc_method, uint32_t *chunk_size)
@@ -50,19 +51,8 @@ int update_cache_pool_params(struct volume_group *vg, unsigned attr,
if (!(passed_args & PASS_ARG_CHUNK_SIZE))
*chunk_size = DEFAULT_CACHE_POOL_CHUNK_SIZE * 2;
- if ((*chunk_size < DM_CACHE_MIN_DATA_BLOCK_SIZE) ||
- (*chunk_size > DM_CACHE_MAX_DATA_BLOCK_SIZE)) {
- log_error("Chunk size must be in the range %s to %s.",
- display_size(vg->cmd, DM_CACHE_MIN_DATA_BLOCK_SIZE),
- display_size(vg->cmd, DM_CACHE_MAX_DATA_BLOCK_SIZE));
- return 0;
- }
-
- if (*chunk_size & (DM_CACHE_MIN_DATA_BLOCK_SIZE - 1)) {
- log_error("Chunk size must be a multiple of %s.",
- display_size(vg->cmd, DM_CACHE_MIN_DATA_BLOCK_SIZE));
- return 0;
- }
+ if (!validate_pool_chunk_size(vg->cmd, segtype, *chunk_size))
+ return_0;
/*
* Default meta size is:
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index b8e7415..f8a84de 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -743,7 +743,8 @@ int update_profilable_pool_params(struct cmd_context *cmd, struct profile *profi
int passed_args, int *chunk_size_calc_method,
uint32_t *chunk_size, thin_discards_t *discards,
int *zero);
-int update_thin_pool_params(struct volume_group *vg, unsigned attr,
+int update_thin_pool_params(const struct segment_type *segtype,
+ struct volume_group *vg, unsigned attr,
int passed_args, uint32_t data_extents,
uint64_t *pool_metadata_size,
int *chunk_size_calc_method, uint32_t *chunk_size,
@@ -1071,7 +1072,8 @@ int partial_raid_lv_supports_degraded_activation(const struct logical_volume *lv
/* ++ metadata/cache_manip.c */
const char *get_cachepool_cachemode_name(const struct lv_segment *seg);
-int update_cache_pool_params(struct volume_group *vg, unsigned attr,
+int update_cache_pool_params(const struct segment_type *segtype,
+ struct volume_group *vg, unsigned attr,
int passed_args, uint32_t data_extents,
uint64_t *pool_metadata_size,
int *chunk_size_calc_method, uint32_t *chunk_size);
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index 4621c57..6e2f2fe 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -364,11 +364,11 @@ int update_pool_params(const struct segment_type *segtype,
thin_discards_t *discards, int *zero)
{
if (segtype_is_cache_pool(segtype) || segtype_is_cache(segtype)) {
- if (!update_cache_pool_params(vg, target_attr, passed_args,
+ if (!update_cache_pool_params(segtype, vg, target_attr, passed_args,
data_extents, pool_metadata_size,
chunk_size_calc_policy, chunk_size))
return_0;
- } else if (!update_thin_pool_params(vg, target_attr, passed_args,
+ } else if (!update_thin_pool_params(segtype, vg, target_attr, passed_args,
data_extents, pool_metadata_size,
chunk_size_calc_policy, chunk_size,
discards, zero)) /* thin-pool */
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index b781e02..b830350 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -394,7 +394,8 @@ int update_pool_lv(struct logical_volume *lv, int activate)
return ret;
}
-int update_thin_pool_params(struct volume_group *vg,
+int update_thin_pool_params(const struct segment_type *segtype,
+ struct volume_group *vg,
unsigned attr, int passed_args, uint32_t data_extents,
uint64_t *pool_metadata_size,
int *chunk_size_calc_method, uint32_t *chunk_size,
@@ -425,13 +426,8 @@ int update_thin_pool_params(struct volume_group *vg,
}
}
- if ((*chunk_size < DM_THIN_MIN_DATA_BLOCK_SIZE) ||
- (*chunk_size > DM_THIN_MAX_DATA_BLOCK_SIZE)) {
- log_error("Chunk size must be in the range %s to %s.",
- display_size(cmd, DM_THIN_MIN_DATA_BLOCK_SIZE),
- display_size(cmd, DM_THIN_MAX_DATA_BLOCK_SIZE));
- return 0;
- }
+ if (!validate_pool_chunk_size(cmd, segtype, *chunk_size))
+ return_0;
if (!(passed_args & PASS_ARG_DISCARDS)) {
if (!(str = find_config_tree_str(cmd, allocation_thin_pool_discards_CFG, profile))) {
@@ -449,10 +445,6 @@ int update_thin_pool_params(struct volume_group *vg,
(*chunk_size & (*chunk_size - 1))) {
log_error("Chunk size must be a power of 2 for this thin target version.");
return 0;
- } else if (*chunk_size & (DM_THIN_MIN_DATA_BLOCK_SIZE - 1)) {
- log_error("Chunk size must be multiple of %s.",
- display_size(cmd, DM_THIN_MIN_DATA_BLOCK_SIZE));
- return 0;
}
if (!*pool_metadata_size) {
9 years, 6 months
master - pool: validate_pool_chunk_size
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a2aa609810d7d0...
Commit: a2aa609810d7d0d6b8ff5b9fe8c6e1e13fbfbbac
Parent: 7783fe3e93b6fee0e8ea8198917b2d1a3072bdab
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 6 12:18:57 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 6 15:23:01 2014 +0200
pool: validate_pool_chunk_size
Introduce pool function for validation of chunk size.
It's good idea to be able to reject invalid chunk size
when entered on command line before we open VG.
---
WHATS_NEW | 1 +
lib/metadata/metadata-exported.h | 1 +
lib/metadata/pool_manip.c | 40 ++++++++++++++++++++++++++++++++++++++
3 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 3855bb1..875ab20 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Introduce single validation routine for pool chunk size.
Support --yes like --force in vg/lvremove to skip y|n prompt.
Support --yes with lvconvert --splitsnapshot.
Fix detection of unsupported thin external lvconversions.
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index d04d987..b8e7415 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -731,6 +731,7 @@ int thin_pool_feature_supported(const struct logical_volume *pool_lv, int featur
int recalculate_pool_chunk_size_with_dev_hints(struct logical_volume *pool_lv,
int passed_args,
int chunk_size_calc_policy);
+int validate_pool_chunk_size(struct cmd_context *cmd, const struct segment_type *segtype, uint32_t chunk_size);
int update_pool_lv(struct logical_volume *lv, int activate);
int update_pool_params(const struct segment_type *segtype,
struct volume_group *vg, unsigned target_attr,
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index 0c66c77..4621c57 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -232,6 +232,46 @@ struct lv_segment *find_pool_seg(const struct lv_segment *seg)
return pool_seg;
}
+int validate_pool_chunk_size(struct cmd_context *cmd,
+ const struct segment_type *segtype,
+ uint32_t chunk_size)
+{
+ uint32_t min_size, max_size;
+ const char *name;
+ int r = 1;
+
+ if (segtype_is_cache(segtype) || segtype_is_cache_pool(segtype)) {
+ min_size = DM_CACHE_MIN_DATA_BLOCK_SIZE;
+ max_size = DM_CACHE_MAX_DATA_BLOCK_SIZE;
+ name = "Cache";
+ } else if (segtype_is_thin(segtype)) {
+ min_size = DM_THIN_MIN_DATA_BLOCK_SIZE;
+ max_size = DM_THIN_MAX_DATA_BLOCK_SIZE;
+ name = "Thin";
+ } else {
+ log_error(INTERNAL_ERROR "Cannot validate chunk size of "
+ "%s segtype.", segtype->name);
+ return 0;
+ }
+
+ if ((chunk_size < min_size) || (chunk_size > max_size)) {
+ log_error("%s pool chunk size %s is not in the range %s to %s.",
+ name, display_size(cmd, chunk_size),
+ display_size(cmd, min_size),
+ display_size(cmd, max_size));
+ r = 0;
+ }
+
+ if (chunk_size & (min_size - 1)) {
+ log_error("%s pool chunk size %s must be a multiple of %s.",
+ name, display_size(cmd, chunk_size),
+ display_size(cmd, min_size));
+ r = 0;
+ }
+
+ return r;
+}
+
/* Greatest common divisor */
static unsigned long _gcd(unsigned long n1, unsigned long n2)
{
9 years, 6 months
master - man: document -ff for removal
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7783fe3e93b6fe...
Commit: 7783fe3e93b6fee0e8ea8198917b2d1a3072bdab
Parent: 79ca382b2c24fd01aa25c98c0ab29b97a4358270
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 4 17:06:51 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 6 15:22:24 2014 +0200
man: document -ff for removal
Make it visible in man page that -ff could make removal
process proceed in case of damaged pool.
---
man/lvremove.8.in | 2 ++
man/vgremove.8.in | 1 +
2 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/man/lvremove.8.in b/man/lvremove.8.in
index b0bb477..8426cac 100644
--- a/man/lvremove.8.in
+++ b/man/lvremove.8.in
@@ -31,6 +31,8 @@ See \fBlvm\fP(8) for common options.
.TP
.BR \-f ", " \-\-force
Remove active logical volumes without confirmation.
+Tool will try to deactivate \fIunused\fP volume.
+To proceed with damaged pools use \-ff
.TP
.B \-\-noudevsync
Disable udev synchronisation. The
diff --git a/man/vgremove.8.in b/man/vgremove.8.in
index f824a56..10a431f 100644
--- a/man/vgremove.8.in
+++ b/man/vgremove.8.in
@@ -28,6 +28,7 @@ See \fBlvm\fP(8) for common options.
.BR \-f ", " \-\-force
Force the removal of any logical volumes on the volume group
without confirmation.
+To remove also damaged pool volumes use \-ff.
.TP
.BR \-\-noudevsync
Disable udev synchronisation. The
9 years, 6 months
master - vg/lvremove: support --yes
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=79ca382b2c24fd...
Commit: 79ca382b2c24fd01aa25c98c0ab29b97a4358270
Parent: fbf14b12d8710f10b7a7f1a0a23347ac5ad1a826
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 4 17:05:29 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 6 15:22:24 2014 +0200
vg/lvremove: support --yes
Make --yes equivalent to DONT_PROMT (--force).
So user could use 'lvremove --yes vg/lvol1' skipping prompt.
---
WHATS_NEW | 1 +
tools/lvremove.c | 12 ++++++++++--
tools/vgremove.c | 11 ++++++++---
3 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index d2b5303..3855bb1 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Support --yes like --force in vg/lvremove to skip y|n prompt.
Support --yes with lvconvert --splitsnapshot.
Fix detection of unsupported thin external lvconversions.
Fix detection of unsupported cache and thin pool lvconversions.
diff --git a/tools/lvremove.c b/tools/lvremove.c
index dfc435c..7d2fec1 100644
--- a/tools/lvremove.c
+++ b/tools/lvremove.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2014 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -18,7 +18,15 @@
static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
void *handle __attribute__((unused)))
{
- if (!lv_remove_with_dependencies(cmd, lv, (force_t) arg_count(cmd, force_ARG), 0))
+ /*
+ * Single force is equivalent to sinle --yes
+ * Even multiple --yes are equivalent to single --force
+ * When we require -ff it cannot be replaces with -f -y
+ */
+ force_t force = (force_t) arg_count(cmd, force_ARG)
+ ? : (arg_is_set(cmd, yes_ARG) ? DONT_PROMPT : PROMPT);
+
+ if (!lv_remove_with_dependencies(cmd, lv, force, 0))
return_ECMD_FAILED;
return ECMD_PROCESSED;
diff --git a/tools/vgremove.c b/tools/vgremove.c
index 52bdd2b..0bbca76 100644
--- a/tools/vgremove.c
+++ b/tools/vgremove.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2014 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -19,15 +19,20 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg,
void *handle __attribute__((unused)))
{
+ /*
+ * Single force is equivalent to sinle --yes
+ * Even multiple --yes are equivalent to single --force
+ * When we require -ff it cannot be replaces with -f -y
+ */
+ force_t force = (force_t) arg_count(cmd, force_ARG)
+ ? : (arg_is_set(cmd, yes_ARG) ? DONT_PROMPT : PROMPT);
unsigned lv_count, missing;
- force_t force;
if (!vg_check_status(vg, EXPORTED_VG))
return_ECMD_FAILED;
lv_count = vg_visible_lvs(vg);
- force = (force_t) arg_count(cmd, force_ARG);
if (lv_count) {
if (force == PROMPT) {
if ((missing = vg_missing_pv_count(vg)))
9 years, 6 months
master - man: lvconvert new split options
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fbf14b12d8710f...
Commit: fbf14b12d8710f10b7a7f1a0a23347ac5ad1a826
Parent: cb49dd4aa4e6fecb80c163f0279803d4036e48c5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 6 14:43:25 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 6 15:22:24 2014 +0200
man: lvconvert new split options
Update man page with info how to split/uncache cached logical
volumes.
lvconvert: splitsnapshot support --yes
Allow to use --yes to skip prompt.
---
man/lvconvert.8.in | 84 +++++++++++++++++++++++++++++++++++++++------------
1 files changed, 64 insertions(+), 20 deletions(-)
diff --git a/man/lvconvert.8.in b/man/lvconvert.8.in
index b8951e2..b08e420 100644
--- a/man/lvconvert.8.in
+++ b/man/lvconvert.8.in
@@ -32,6 +32,25 @@ lvconvert \(em convert a logical volume from linear to mirror or snapshot
.IR LogicalVolume [ Path ]
.RI [ PhysicalVolume [ Path ][ :PE [ \-PE ]]...]
.sp
+.B lvconvert
+.BR \-\-split
+.RB [ \-\-commandprofile
+.IR ProfileName ]
+.RB [ \-h | \-? | \-\-help ]
+.RB [ \-\-noudevsync ]
+.RB [ \-v | \-\-verbose ]
+.IR SplitableLogicalVolume { Name | Path }
+.sp
+.B lvconvert
+.BR \-\-splitcache | \-\-uncache
+.RB [ \-\-commandprofile
+.IR ProfileName ]
+.RB [ \-h | \-? | \-\-help ]
+.RB [ \-\-noudevsync ]
+.RB [ \-v | \-\-verbose ]
+.RB [ \-\-version ]
+.IR CacheLogicalVolume { Name | Path }
+.sp
.B lvconvert \-\-splitmirrors \fIImages
.RB [ \-\-name
.IR SplitLogicalVolumeName ]
@@ -122,20 +141,20 @@ lvconvert \(em convert a logical volume from linear to mirror or snapshot
.RB [ \-\-poolmetadataspare
.RI { y | n }]
.RB [ \-Z | \-\-zero \ { \fIy | \fIn }]]
-.RI [[ ExternalOrigin | ThinPool ] LogicalVolume { Name | Path }]
-.RI [ PhysicalVolume [ Path ][ :PE
-.RI [ \-PE ]]...]
.RB [ \-\-commandprofile
.IR ProfileName ]
.RB [ \-h | \-? | \-\-help ]
.RB [ \-v | \-\-verbose ]
.RB [ \-\-version ]
+.RI [[ ExternalOrigin | ThinPool ] LogicalVolume { Name | Path }]
+.RI [ PhysicalVolume [ Path ][ :PE
+.RI [ \-PE ]]...]
.sp
.B lvconvert
.RB [ \-\-type
-.BR \fIcache [ \fI\-pool ]| \-\-cache ]
+.BR \fIcache [ \fI\-pool ]| \-H | \-\-cache ]
.RB [ \-\-cachepool
-.IR CachePoolLV { Name | Path }]
+.IR CachePoolLogicalVolume { Name | Path }]
.RB [ \-c | \-\-chunksize
.IR ChunkSize [ bBsSkKmMgG ]]
.RB [ \-\-cachemode
@@ -147,13 +166,13 @@ lvconvert \(em convert a logical volume from linear to mirror or snapshot
.IR CachePoolMetadataSize [ bBsSkKmMgG ]}]
.RB [ \-\-poolmetadataspare
.RI { y | n }]
-.IR LogicalVolume { Name | Path }
-.RI [ PhysicalVolume [ Path ][ :PE [ \-PE ]]...]
.RB [ \-\-commandprofile
.IR ProfileName ]
.RB [ \-h | \-? | \-\-help ]
.RB [ \-v | \-\-verbose ]
.RB [ \-\-version ]
+.IR LogicalVolume { Name | Path }
+.RI [ PhysicalVolume [ Path ][ :PE [ \-PE ]]...]
.sp
.SH DESCRIPTION
@@ -181,18 +200,21 @@ Exactly one of
.BR \-\-mirrors ,
.BR \-\-repair ,
.BR \-\-replace ,
-.BR \-\-splitsnapshot ,
.BR \-\-snapshot ,
+.BR \-\-split ,
+.BR \-\-splitcache ,
+.BR \-\-splitsnapshot ,
.BR \-\-splitmirrors ,
-.BR \-\-thin
-or
+.BR \-\-thin ,
.BR \-\-type
+or
+.BR \-\-uncache
arguments is required.
.TP
.BR \-b ", " \-\-background
Run the daemon in the background.
.TP
-.BR \-\-cache ", " \-\-type\ \fIcache
+.BR \-H ", " \-\-cache ", " \-\-type\ \fIcache
Converts logical volume to a cached LV with the use of cache pool
specified with \fB\-\-cachepool\fP.
For more information on cache pool LVs and cache LVs, see \fBlvmcache\fP(8).
@@ -277,6 +299,19 @@ the data changed get resynchronized.
Please note that this feature is only supported with the new md-based mirror
implementation and not with the original device-mapper mirror implementation.
.TP
+.B \-\-split
+Separates \fISplitableLogicalVolume\fP.
+Option is agregating various split commands and tries to detect necessary split
+operation from its arguments.
+.TP
+.BR \-\-splitcache ", " \-\-uncache
+Separates \fICacheLogicalVolume\fP from cache pool.
+Before volume becomes uncached, cache is flushed.
+With \-\-split the cache pool volume is then left unused and
+could be i.e. used for caching other volumes.
+The inverse of \-\-cache is \-\-uncache where the cache pool
+component volumes are automatically removed.
+.TP
.B \-\-splitsnapshot
Separates \fISnapshotLogicalVolume\fP from its origin.
The volume that is split off contains the chunks that differ from the origin
@@ -347,7 +382,7 @@ Without this option a default name of "lvol<n>" will be generated where
This volume will be read-only and cannot be further modified as long,
as it is being used as the external origin.
.TP
-.BR \-\-poolmetadata " " \fIThinPoolMetadataLogicalVolume { \fIName | \fIPath }
+.BR \-\-poolmetadata " " \fIPoolMetadataLogicalVolume { \fIName | \fIPath }
Specifies cache or thin pool metadata logical volume.
The size should be in between 2MiB and 16GiB.
Cache pool is specified with the option
@@ -369,12 +404,12 @@ thin provisioning tools
and
.BR thin_restore (8).
.TP
-.BR \-\-poolmetadatasize " " \fIThinPoolMetadataSize [ \fIbBsSkKmMgG ]
-Sets the size of thin pool's metadata logical volume,
+.BR \-\-poolmetadatasize " " \fIPoolMetadataSize [ \fIbBsSkKmMgG ]
+Sets the size of cache or thin pool's metadata logical volume,
if the pool metadata volume is undefined.
-Thin pool is specified with the option
-\fB\-\-thinpool\fP.
-Supported value is in the range between 2MiB and 16GiB.
+Pool is specified with the option
+\B\-\-cachepool\P or \fB\-\-thinpool\fP.
+For thin pool supported value is in the range between 2MiB and 16GiB.
The default value is estimated with this formula
(Pool_LV_size / Pool_LV_chunk_size * 64b).
Default unit is megabytes.
@@ -554,11 +589,20 @@ given cache metadata LV.
.B lvconvert \-\-type cache-pool \-\-poolmetadata vg00/lvx_meta vg00/lvx_data
.br
.B lvrename vg00/lvx_data vg00/lvx_cachepool
-
+.sp
Convert an existing logical volume to a cache LV using the given
-cache pool LV.
+cache pool LV and chunk size 128KiB.
+.sp
+.B lvconvert \-\-cache \-\-cachepool vg00/lvx_cachepool -c 128 vg00/lvx
+.sp
+Detach cache pool from an existing cached logical volume "vg00/lvol1" and
+leave cache pool unused.
+.sp
+.B lvconvert \-\-splitcache vg00/lvol1
+.sp
+Drop cache pool from an existing cached logical volume "vg00/lvol1".
.sp
-.B lvconvert \-\-cache \-\-cachepool vg00/lvx_cachepool vg00/lvx
+.B lvconvert \-\-uncache vg00/lvol1
.SH SEE ALSO
.BR lvm (8),
9 years, 6 months
master - lvconvert: splitsnapshot supports --yes
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cb49dd4aa4e6fe...
Commit: cb49dd4aa4e6fecb80c163f0279803d4036e48c5
Parent: b2b18a5f8b4f6c5b116655f7e9e7c102462f693f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 6 14:42:47 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 6 15:22:22 2014 +0200
lvconvert: splitsnapshot supports --yes
Handle --yes arg to skip prompt.
---
WHATS_NEW | 1 +
tools/lvconvert.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 6b768ea..d2b5303 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Support --yes with lvconvert --splitsnapshot.
Fix detection of unsupported thin external lvconversions.
Fix detection of unsupported cache and thin pool lvconversions.
Fix detection of unsupported lvconversion of cache to snapshot.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 070c5e4..4bf4306 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2002,7 +2002,7 @@ static int _lvconvert_splitsnapshot(struct cmd_context *cmd, struct logical_volu
if (!lv_check_not_in_use(cow))
return_ECMD_FAILED;
- if ((lp->force == PROMPT) &&
+ if ((lp->force == PROMPT) && !lp->yes &&
lv_is_visible(cow) &&
lv_is_active(cow)) {
if (yes_no_prompt("Do you really want to split off active "
9 years, 6 months
master - lvconvert more test for thin external origin
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b2b18a5f8b4f6c...
Commit: b2b18a5f8b4f6c5b116655f7e9e7c102462f693f
Parent: 60d2a63368686d309c01f1e59d695d0ee8ec9153
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 6 13:15:31 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 6 15:21:36 2014 +0200
lvconvert more test for thin external origin
Some LV types were not properly disallowed to be used as external origin.
---
WHATS_NEW | 1 +
tools/lvconvert.c | 9 +++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5fc42d6..6b768ea 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Fix detection of unsupported thin external lvconversions.
Fix detection of unsupported cache and thin pool lvconversions.
Fix detection of unsupported lvconversion of cache to snapshot.
Improve code for creation of cache and cache pool volumes.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 36fafbe..070c5e4 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2664,8 +2664,13 @@ static int _lvconvert_thin(struct cmd_context *cmd,
return 0;
}
- if (lv_is_pool(lv)) {
- log_error("Can't use pool %s as external origin.",
+ if (lv_is_cache_type(lv) ||
+ lv_is_cow(lv) ||
+ lv_is_pool(lv) ||
+ lv_is_thin_pool_data(lv) ||
+ lv_is_thin_pool_metadata(lv)) {
+ log_error("Can't use %s %s as external origin.",
+ first_seg(lv)->segtype->name,
display_lvname(lv));
return 0;
}
9 years, 6 months
master - lvconvert: cache and thin conversion validation
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=60d2a63368686d...
Commit: 60d2a63368686d309c01f1e59d695d0ee8ec9153
Parent: ee344f1a9ee8536eab235ea3d971f59ed769cdd5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 6 13:44:59 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 6 15:18:06 2014 +0200
lvconvert: cache and thin conversion validation
More test for supported conversion.
---
WHATS_NEW | 1 +
tools/lvconvert.c | 28 ++++++++++++++++++++++++++--
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 980809c..5fc42d6 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Fix detection of unsupported cache and thin pool lvconversions.
Fix detection of unsupported lvconversion of cache to snapshot.
Improve code for creation of cache and cache pool volumes.
Check cluster-wide (not local) active status before removing LV.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 1a5d559..36fafbe 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2802,13 +2802,18 @@ static int _lvconvert_pool(struct cmd_context *cmd,
}
if (lv_is_thin_pool(pool_lv) && (segtype_is_cache_pool(lp->segtype) || lp->cache)) {
- log_error("Cannot convert thin pool volume %s as cache pool data volume.",
+ log_error("Can't convert thin pool LV %s.", display_lvname(pool_lv));
+ return 0;
+ }
+
+ if (lv_is_cache(pool_lv) && !segtype_is_thin_pool(lp->segtype)) {
+ log_error("Cached LV %s could be only converted into a thin pool volume.",
display_lvname(pool_lv));
return 0;
}
if (lv_is_cache_pool(pool_lv) && (segtype_is_thin_pool(lp->segtype) || lp->thin)) {
- log_error("Cannot convert cache pool %s as thin pool data volume.",
+ log_error("Cannot convert cache pool %s as pool data volume.",
display_lvname(pool_lv));
return 0;
}
@@ -3250,6 +3255,25 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
return ECMD_PROCESSED;
}
+ if (lp->cache) {
+ if (lv_is_thin_pool(lv))
+ lv = seg_lv(first_seg(lv), 0); /* cache _tdata */
+ if (!validate_lv_cache_create(NULL, lv))
+ return_ECMD_FAILED;
+ }
+
+ if (lp->thin) {
+ if (lv_is_cache_type(lv) ||
+ lv_is_pool(lv) ||
+ lv_is_thin_pool_data(lv) ||
+ lv_is_thin_pool_metadata(lv)) {
+ log_error("Can't convert %s %s to external origin.",
+ first_seg(lv)->segtype->name,
+ display_lvname(lv));
+ return ECMD_FAILED;
+ }
+ }
+
if (arg_count(cmd, repair_ARG)) {
if (lv_is_pool(lv)) {
if (!_lvconvert_pool_repair(cmd, lv, lp))
9 years, 6 months
master - lvconvert: validate cache conversion to snapshot
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ee344f1a9ee853...
Commit: ee344f1a9ee8536eab235ea3d971f59ed769cdd5
Parent: f76f2ce1df4e95774b8fded602a8e35f8ae71fe1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 6 12:27:35 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 6 15:18:06 2014 +0200
lvconvert: validate cache conversion to snapshot
Cache cannot be converted into snapshot cow nor origin.
---
WHATS_NEW | 1 +
tools/lvconvert.c | 22 ++++++++++++++++++----
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 0ffb048..980809c 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Fix detection of unsupported lvconversion of cache to snapshot.
Improve code for creation of cache and cache pool volumes.
Check cluster-wide (not local) active status before removing LV.
Properly check if activation of removed cached LV really activated.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 11a10f7..1a5d559 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2139,6 +2139,12 @@ static int _lvconvert_snapshot(struct cmd_context *cmd,
{
struct logical_volume *org;
+ if (lv_is_cache_type(lv)) {
+ log_error("Snapshots are not yet supported with cache type LVs %s.",
+ display_lvname(lv));
+ return 0;
+ }
+
if (lv_is_mirrored(lv)) {
log_error("Unable to convert mirrored LV \"%s\" into a snapshot.", lv->name);
return 0;
@@ -2150,14 +2156,15 @@ static int _lvconvert_snapshot(struct cmd_context *cmd,
return 0;
}
- if (lv_is_cache_type(lv)) {
- log_error("Snapshots are not yet supported with cache type LVs %s.",
+ if (lv_is_pool(lv)) {
+ log_error("Unable to convert pool LVs %s into a snapshot.",
display_lvname(lv));
return 0;
}
if (!(org = find_lv(lv->vg, lp->origin_lv_name))) {
- log_error("Couldn't find origin volume %s.", lp->origin_lv_name);
+ log_error("Couldn't find origin volume %s in Volume group %s.",
+ lp->origin_lv_name, lv->vg->name);
return 0;
}
@@ -2170,9 +2177,16 @@ static int _lvconvert_snapshot(struct cmd_context *cmd,
if (!cow_has_min_chunks(lv->vg, lv->le_count, lp->chunk_size))
return_0;
- if (lv_is_locked(org) || lv_is_pvmove(org) || lv_is_mirrored(org) || lv_is_cow(org)) {
+ if (lv_is_locked(org) ||
+ lv_is_cache_type(org) ||
+ lv_is_thin_type(org) ||
+ lv_is_pvmove(org) ||
+ lv_is_mirrored(org) ||
+ lv_is_cow(org)) {
log_error("Unable to convert an LV into a snapshot of a %s LV.",
lv_is_locked(org) ? "locked" :
+ lv_is_cache_type(org) ? "cache type" :
+ lv_is_thin_type(org) ? "thin type" :
lv_is_pvmove(org) ? "pvmove" :
lv_is_mirrored(org) ? "mirrored" :
"snapshot");
9 years, 6 months
master - cache: use same alg for cache size calc
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f76f2ce1df4e95...
Commit: f76f2ce1df4e95774b8fded602a8e35f8ae71fe1
Parent: d46c2f1c946e21393537a730eaa624665cb96bbc
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 6 12:22:03 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 6 15:18:06 2014 +0200
cache: use same alg for cache size calc
Use the same algorithm for cache metadata size as the cache tool is using.
---
lib/metadata/cache_manip.c | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index ed08726..350a18e 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -22,6 +22,12 @@
#include "activate.h"
#include "defaults.h"
+/* https://github.com/jthornber/thin-provisioning-tools/blob/master/caching/... */
+#define DM_TRANSACTION_OVERHEAD 4096 /* KiB */
+#define DM_BYTES_PER_BLOCK 16 /* bytes */
+#define DM_HINT_OVERHEAD_PER_BLOCK 8 /* bytes */
+#define DM_MAX_HINT_WIDTH (4+16) /* bytes, TODO: configurable ?? */
+
const char *get_cachepool_cachemode_name(const struct lv_segment *seg)
{
if (seg->feature_flags & DM_CACHE_FEATURE_WRITEBACK)
@@ -39,6 +45,7 @@ int update_cache_pool_params(struct volume_group *vg, unsigned attr,
int *chunk_size_calc_method, uint32_t *chunk_size)
{
uint64_t min_meta_size;
+ uint32_t extent_size = vg->extent_size;
if (!(passed_args & PASS_ARG_CHUNK_SIZE))
*chunk_size = DEFAULT_CACHE_POOL_CHUNK_SIZE * 2;
@@ -59,15 +66,16 @@ int update_cache_pool_params(struct volume_group *vg, unsigned attr,
/*
* Default meta size is:
- * (4MiB + (16 Bytes for each chunk-sized block))
- * ... plus a good amount of padding (2x) to cover any
- * policy hint data that may be added in the future.
+ * (Overhead + mapping size + hint size)
*/
- min_meta_size = (uint64_t)data_extents * vg->extent_size * 16;
- min_meta_size /= *chunk_size; /* # of Bytes we need */
- min_meta_size *= 2; /* plus some padding */
- min_meta_size /= 512; /* in sectors */
- min_meta_size += 4*1024*2; /* plus 4MiB */
+ min_meta_size = (uint64_t) data_extents * extent_size / *chunk_size; /* nr_chunks */
+ min_meta_size *= (DM_BYTES_PER_BLOCK + DM_MAX_HINT_WIDTH + DM_HINT_OVERHEAD_PER_BLOCK);
+ min_meta_size = (min_meta_size + (SECTOR_SIZE - 1)) >> SECTOR_SHIFT; /* in sectors */
+ min_meta_size += DM_TRANSACTION_OVERHEAD * (1024 >> SECTOR_SHIFT);
+
+ /* Round up to extent size */
+ if (min_meta_size % extent_size)
+ min_meta_size += extent_size - min_meta_size % extent_size;
if (!*pool_metadata_size)
*pool_metadata_size = min_meta_size;
@@ -79,7 +87,7 @@ int update_cache_pool_params(struct volume_group *vg, unsigned attr,
display_size(vg->cmd, *pool_metadata_size));
} else if (*pool_metadata_size < min_meta_size) {
if (passed_args & PASS_ARG_POOL_METADATA_SIZE)
- log_warn("WARNING: Minimum supported pool metadata size is %s "
+ log_warn("WARNING: Minimum required pool metadata size is %s "
"(needs extra %s).",
display_size(vg->cmd, min_meta_size),
display_size(vg->cmd, min_meta_size - *pool_metadata_size));
9 years, 6 months