master - cleanup: avoid printing gcc warning
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9c86d33e68ceb7...
Commit: 9c86d33e68ceb7a5a5e6754f4551545d915e403d
Parent: 50d70eff352fd651a68b8edbd9a7fcbe30300726
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jun 23 11:03:46 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jun 23 11:06:02 2015 +0200
cleanup: avoid printing gcc warning
Casting to (void) with gcc doesn't remove unused_result warning.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509
---
.../lvm2_activation_generator_systemd_red_hat.c | 2 +-
test/lib/not.c | 8 ++++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/scripts/lvm2_activation_generator_systemd_red_hat.c b/scripts/lvm2_activation_generator_systemd_red_hat.c
index 92c08d3..cd71b9c 100644
--- a/scripts/lvm2_activation_generator_systemd_red_hat.c
+++ b/scripts/lvm2_activation_generator_systemd_red_hat.c
@@ -64,7 +64,7 @@ static void kmsg(int log_level, const char *format, ...)
return;
/* The n+4: +3 for "<n>" prefix and +1 for '\0' suffix */
- (void) write(kmsg_fd, message, n + 4);
+ if (write(kmsg_fd, message, n + 4)) { /* Ignore result code */; }
}
static void lvm_get_use_lvmetad_and_lvmpolld(int *use_lvmetad, int *use_lvmpolld)
diff --git a/test/lib/not.c b/test/lib/not.c
index 5d28599..93c115a 100644
--- a/test/lib/not.c
+++ b/test/lib/not.c
@@ -33,9 +33,13 @@ static int _finished(const char *cmd, int status, int pid) {
if (WIFEXITED(ret) && WEXITSTATUS(ret) == 0) {
printf("## timing off\n<======== Debug log ========>\n"); /* timing off */
fflush(stdout);
- (void) system("sed -e 's,^,## DEBUG: ,' debug.log*${LVM_LOG_FILE_EPOCH}* 2>/dev/null");
+ if (system("sed -e 's,^,## DEBUG: ,' debug.log*${LVM_LOG_FILE_EPOCH}* 2>/dev/null")) {
+ /* Ignore result code */;
+ }
printf("## timing on\n"); /* timing on */
- (void) system("rm -f debug.log*${LVM_LOG_FILE_EPOCH}*");
+ if (system("rm -f debug.log*${LVM_LOG_FILE_EPOCH}*")) {
+ /* Ignore result code */;
+ }
fflush(stdout);
}
}
8 years, 10 months
master - post-release
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=50d70eff352fd6...
Commit: 50d70eff352fd651a68b8edbd9a7fcbe30300726
Parent: 134b727b4f577c3e4b1a210e41d20136bc8bd876
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Sat Jun 20 01:05:21 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Sat Jun 20 01:05:21 2015 +0100
post-release
---
VERSION | 2 +-
VERSION_DM | 2 +-
WHATS_NEW | 3 +++
WHATS_NEW_DM | 3 +++
4 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/VERSION b/VERSION
index 9f836eb..737d5a2 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.02.122(2)-git (2015-06-20)
+2.02.123(2)-git (2015-06-20)
diff --git a/VERSION_DM b/VERSION_DM
index 00645cd..7d2906a 100644
--- a/VERSION_DM
+++ b/VERSION_DM
@@ -1 +1 @@
-1.02.99-git (2015-06-20)
+1.02.100-git (2015-06-20)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5d97a43..7da2b51 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,3 +1,6 @@
+Version 2.02.123 -
+=================================
+
Version 2.02.122 - 20th June 2015
=================================
Flush stdout before printing to stderr.
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 25fd2f9..d4b1639 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,3 +1,6 @@
+Version 1.02.100 -
+================================
+
Version 1.02.99 - 20th June 2015
================================
New dm_tree_node_set_thin_pool_read_only(DM_1_02_99) for read-only thin pool.
8 years, 10 months
v2_02_122 annotated tag has been created
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b954451675ce88...
Commit: b954451675ce88799e5bd03339201033a245a8cd
Parent: 0000000000000000000000000000000000000000
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: 2015-06-19 23:58 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: 2015-06-19 23:58 +0000
annotated tag: v2_02_122 has been created
at b954451675ce88799e5bd03339201033a245a8cd (tag)
tagging 134b727b4f577c3e4b1a210e41d20136bc8bd876 (commit)
replaces v2_02_121
Release 2.02.122.
36 files changed, 585 insertions(+), 229 deletions(-)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
iEYEABECAAYFAlWErK0ACgkQIoGRwVZ+LBfXuQCgpgDX9iPgKTcxMsytAxjgefOu
trgAoNXEjJOlFvacGMP1zPsPJBng7+e7
=aB5W
-----END PGP SIGNATURE-----
Alasdair G Kergon (2):
post-release
pre-release
David Teigland (9):
lvmcache: mention lvconvert --cachemode
xlate: add new variants
Ignore hyphens in long option names
Add the 's' activation mode
man lvm: mention hyphens in option names
man vgchange lvchange: mention activation option s
lv_refresh: move the bulk of the function into lib
Add a global get_cmd_name()
libdaemon: move compare_config to lib
Peter Rajnoha (4):
config: fix some settings incorrectly marked as CFG_DEFAULT_COMMENTED instead of CFG_DEFAULT_UNDEFINED and causing segfault
filter: filter-usable: consider snapshot and origin LV as unusable if its component is suspended
cleanup: || instead of |
cleanup: missing target_type check in device_is_usable filter
Zdenek Kabelac (13):
dmeventd: drop pthread_cancel
dmeventd: drop stack
dmeventd: better debug
cleanup: drop double const
libdm: better debug message
debug: better tracing messages
libdm: add dm_tree_node_set_thin_pool_read_only
thin: drop limitation for extension of reduced thin volume
thin: support unaligned size of external origin and thin pool
display: drop allocation from display_lvname
lvm: move hyphen mangling code
log: flush stdout before print to stderr
tests: external origin updates
8 years, 10 months
master - pre-release
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=134b727b4f577c...
Commit: 134b727b4f577c3e4b1a210e41d20136bc8bd876
Parent: b45e9183bc276da207c62072726b973e3d6a429c
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Sat Jun 20 00:57:35 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Sat Jun 20 00:57:35 2015 +0100
pre-release
---
VERSION | 2 +-
VERSION_DM | 2 +-
WHATS_NEW | 11 ++++++-----
WHATS_NEW_DM | 4 +++-
4 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/VERSION b/VERSION
index ac44695..9f836eb 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.02.122(2)-git (2015-06-12)
+2.02.122(2)-git (2015-06-20)
diff --git a/VERSION_DM b/VERSION_DM
index eb763e0..00645cd 100644
--- a/VERSION_DM
+++ b/VERSION_DM
@@ -1 +1 @@
-1.02.99-git (2015-06-12)
+1.02.99-git (2015-06-20)
diff --git a/WHATS_NEW b/WHATS_NEW
index 8ea02cd..5d97a43 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,11 +1,12 @@
-Version 2.02.122 -
+Version 2.02.122 - 20th June 2015
=================================
- Avoid allocation in display_lvname internal function.
+ Flush stdout before printing to stderr.
+ Use pre-allocated buffer for printed LV names in display_lvname.
Support thins with size of external origin unaligned with thin pool chunk.
- Allow to extend reduced thin volumes with external origins.
- Consider snapshot and origin LV as unusable if its component is suspended.
+ Allow extension of reduced thin volumes with external origins.
+ Consider snapshot and origin LV as unusable if component devices suspended.
Fix lvmconfig segfault on settings with undefined default value (2.02.120).
- Add explicit 's' (shared) activation mode.
+ Add explicit 's' (shared) LV activation mode.
Ignore hyphens in long options names (i.e. --long-option == --longoption).
Version 2.02.121 - 12th June 2015
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index d87e2bd..25fd2f9 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,7 +1,9 @@
-Version 1.02.99 -
+Version 1.02.99 - 20th June 2015
================================
New dm_tree_node_set_thin_pool_read_only(DM_1_02_99) for read-only thin pool.
Enhance error message when thin-pool message fails.
+ Fix dmeventd logging to avoid threaded use of static variable.
+ Remove redundant dmeventd SIGALRM coded.
Version 1.02.98 - 12th June 2015
================================
8 years, 10 months
master - tests: external origin updates
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b45e9183bc276d...
Commit: b45e9183bc276da207c62072726b973e3d6a429c
Parent: 00d028fd7739ea1f4a49f1f3df6ce1dfb7188fe0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jun 19 16:26:18 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jun 19 16:33:29 2015 +0200
tests: external origin updates
Update test for recent updates to support unalligned sizes
and extension of reduced volume.
---
test/shell/lvconvert-thin-external.sh | 2 ++
test/shell/lvresize-thin-external-origin.sh | 10 +++++++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/test/shell/lvconvert-thin-external.sh b/test/shell/lvconvert-thin-external.sh
index eba9e36..479d23c 100644
--- a/test/shell/lvconvert-thin-external.sh
+++ b/test/shell/lvconvert-thin-external.sh
@@ -57,6 +57,8 @@ lvcreate -l10 -T $vg/pool1 -c 192k
not lvconvert -T --thinpool $vg/pool1 $vg/pool --originname origin
# Create pool1 chunk_size unaligned LV and check failing conversion
lvcreate -l2 -n $lv1 $vg
+# Newer thin-pool target (>= 1.13) supports unaligned external origin
+aux lvmconf 'global/thin_disabled_features = [ "external_origin_extend" ]'
not lvconvert -T --thinpool $vg/pool1 $vg/$lv1
lvremove -f $vg/pool1 $vg/$lv1
diff --git a/test/shell/lvresize-thin-external-origin.sh b/test/shell/lvresize-thin-external-origin.sh
index 66de5f8..090cb06 100644
--- a/test/shell/lvresize-thin-external-origin.sh
+++ b/test/shell/lvresize-thin-external-origin.sh
@@ -20,7 +20,7 @@ test -e LOCAL_LVMPOLLD && skip
aux have_thin 1 2 0 || skip
# Pretend we miss the external_origin_extend feature
-aux lvmconf "global/thin_disabled_features = [ \"external_origin_extend\" ]"
+aux lvmconf 'global/thin_disabled_features = [ "external_origin_extend" ]'
aux prepare_pvs 2
@@ -41,7 +41,11 @@ not lvresize -L+10 $vg/$lv1
# But reduction works
lvresize -L-5 -f $vg/$lv1
+check lv_field $vg/$lv1 lv_size "5.00" --units m --nosuffix
+
not lvresize -L+15 -y $vg/$lv1
+check lv_field $vg/$lv1 lv_size "5.00" --units m --nosuffix
+
# Try to resize again back up to the size of external origin
-# But for now we do not support zeroing for rexetended areas.
-not lvresize -L+5 -f $vg/$lv1
+lvresize -L+5 -f $vg/$lv1
+check lv_field $vg/$lv1 lv_size "10.00" --units m --nosuffix
8 years, 10 months
master - log: flush stdout before print to stderr
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=00d028fd7739ea...
Commit: 00d028fd7739ea1f4a49f1f3df6ce1dfb7188fe0
Parent: 3173442984dd8d31e43cb50db385f31c75cc9839
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jun 19 16:24:32 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jun 19 16:33:20 2015 +0200
log: flush stdout before print to stderr
Keep logging readable and fflush stdout before printing to stderr.
---
lib/log/log.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/lib/log/log.c b/lib/log/log.c
index d8d65ee..20ca293 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -385,6 +385,8 @@ void print_log(int level, const char *file, int line, int dm_errno_or_class,
default:
/* Typically only log_warn goes to stdout */
stream = (use_stderr || (level != _LOG_WARN)) ? stderr : stdout;
+ if (stream == stderr)
+ fflush(stdout);
fprintf(stream, "%s%s%s%s", buf, log_command_name(),
_msg_prefix, indent_spaces);
vfprintf(stream, trformat, ap);
8 years, 10 months
master - lvm: move hyphen mangling code
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3173442984dd8d...
Commit: 3173442984dd8d31e43cb50db385f31c75cc9839
Parent: 438a65dfdb13abd10b3311e96786770d70868de1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jun 19 09:44:14 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jun 19 09:51:48 2015 +0200
lvm: move hyphen mangling code
Relocate hyphen code from lvm main into lvm_run_command()
so all command and library user will have it.
Update WHATS_NEW with missing changes.
---
WHATS_NEW | 2 ++
tools/lvm.c | 25 -------------------------
tools/lvmcmdline.c | 23 +++++++++++++++++++++++
3 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 3ef783f..8ea02cd 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -5,6 +5,8 @@ Version 2.02.122 -
Allow to extend reduced thin volumes with external origins.
Consider snapshot and origin LV as unusable if its component is suspended.
Fix lvmconfig segfault on settings with undefined default value (2.02.120).
+ Add explicit 's' (shared) activation mode.
+ Ignore hyphens in long options names (i.e. --long-option == --longoption).
Version 2.02.121 - 12th June 2015
=================================
diff --git a/tools/lvm.c b/tools/lvm.c
index 00cd16f..f9ab438 100644
--- a/tools/lvm.c
+++ b/tools/lvm.c
@@ -16,33 +16,8 @@
#include "tools.h"
#include "lvm2cmdline.h"
-#define MAX_ARG_LEN 64
-
int main(int argc, char **argv)
{
- char arg_new[MAX_ARG_LEN];
- char *arg;
- int i, j, j_new;
-
- for (i = 1; i < argc; i++) {
- arg = argv[i];
-
- if (arg[0] == '-' && arg[1] == '-' && strlen(arg) < MAX_ARG_LEN) {
- memset(arg_new, 0, sizeof(arg_new));
- arg_new[0] = '-';
- arg_new[1] = '-';
-
- for (j = 2, j_new = 2; j < strlen(arg) + 1; j++) {
- if (arg[j] == '-')
- continue;
- arg_new[j_new] = arg[j];
- j_new++;
- }
-
- memcpy(argv[i], arg_new, strlen(arg_new) + 1);
- }
- }
-
return lvm2_main(argc, argv);
}
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 792dc41..023a3d6 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1414,12 +1414,35 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
int ret = 0;
int locking_type;
int monitoring;
+ char *arg_new, *arg;
+ int i;
init_error_message_produced(0);
/* each command should start out with sigint flag cleared */
sigint_clear();
+ /* eliminate '-' from all options starting with -- */
+ for (i = 1; i < argc; ++i) {
+
+ if (argv[i][0] != '-' || argv[i][1] != '-')
+ continue;
+
+ arg_new = arg = argv[i] + 2;
+
+ while (*arg) {
+ if (*arg != '-') {
+ if (arg_new != arg)
+ *arg_new = *arg;
+ ++arg_new;
+ }
+ ++arg;
+ }
+
+ if (arg_new != arg)
+ *arg_new = 0;
+ }
+
if (!(cmd->cmd_line = _copy_command_line(cmd, argc, argv)))
return_ECMD_FAILED;
8 years, 10 months
master - display: drop allocation from display_lvname
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=438a65dfdb13ab...
Commit: 438a65dfdb13abd10b3311e96786770d70868de1
Parent: a3e0d830bde952a83da3ba60936fff2fa7b40966
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jun 16 13:47:43 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 18 18:50:37 2015 +0200
display: drop allocation from display_lvname
Use of display_lvname() in plain log_debug() may accumulate memory in
command context mempool. Use instead small ringbuffer which allows to
store cuple (10 ATM) names so upto 10 full names can be used at one.
We are not keeping full VG/LV names as it may eventually consume larger
amount of RAM resouces if vgname is longer and lots of LVs are in use.
Note: if there would be ever needed for displaing more names at once,
the limit should be raised (e.g. log_debug() would need to print more
then 10 LVs on a single line).
---
WHATS_NEW | 1 +
lib/commands/toolcontext.h | 2 ++
lib/display/display.c | 19 +++++++++++++++++--
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 8d6e7f2..3ef783f 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.122 -
=================================
+ Avoid allocation in display_lvname internal function.
Support thins with size of external origin unaligned with thin pool chunk.
Allow to extend reduced thin volumes with external origins.
Consider snapshot and origin LV as unusable if its component is suspended.
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 28f5a2c..66bea5f 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -146,6 +146,8 @@ struct cmd_context {
char system_dir[PATH_MAX];
char dev_dir[PATH_MAX];
char proc_dir[PATH_MAX];
+ char display_buffer[NAME_LEN * 10]; /* Ring buffer for upto 10 longest vg/lv names */
+ unsigned display_lvname_idx; /* Index to ring buffer */
};
/*
diff --git a/lib/display/display.c b/lib/display/display.c
index 2cc5d27..8f075d9 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -95,8 +95,23 @@ const char *get_percent_string(percent_type_t def)
const char *display_lvname(const struct logical_volume *lv)
{
- /* On allocation failure, just return the LV name. */
- return lv_fullname_dup(lv->vg->cmd->mem, lv) ? : lv->name;
+ char *name;
+ int r;
+
+ if ((lv->vg->cmd->display_lvname_idx + NAME_LEN) >= sizeof((lv->vg->cmd->display_buffer)))
+ lv->vg->cmd->display_lvname_idx = 0;
+
+ name = lv->vg->cmd->display_buffer + lv->vg->cmd->display_lvname_idx;
+ r = dm_snprintf(name, NAME_LEN, "%s/%s", lv->vg->name, lv->name);
+
+ if (r < 0) {
+ log_error("Full LV name \"%s/%s\" is too long.", lv->vg->name, lv->name);
+ return NULL;
+ }
+
+ lv->vg->cmd->display_lvname_idx += r;
+
+ return name;
}
#define BASE_UNKNOWN 0
8 years, 10 months
master - thin: support unaligned size of external origin and thin pool
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a3e0d830bde952...
Commit: a3e0d830bde952a83da3ba60936fff2fa7b40966
Parent: 6f2a617c318d3e7b4535563b72ddcaad67da62ed
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 18 14:38:57 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 18 18:50:36 2015 +0200
thin: support unaligned size of external origin and thin pool
With thin-pool kernel target module 1.13 it's now support usage of
external origin with sizes which are not 'alligned' with chunk size
of thin-pool.
Enable lvm2 support for this and also fix reporting of data_percent
usage for case sizes are not alligned.
---
WHATS_NEW | 1 +
lib/metadata/thin_manip.c | 9 +--
lib/thin/thin.c | 10 ++-
test/shell/lvcreate-thin-external-size.sh | 90 +++++++++++++++++++++++++++++
4 files changed, 102 insertions(+), 8 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 42a2571..8d6e7f2 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.122 -
=================================
+ Support thins with size of external origin unaligned with thin pool chunk.
Allow to extend reduced thin volumes with external origins.
Consider snapshot and origin LV as unusable if its component is suspended.
Fix lvmconfig segfault on settings with undefined default value (2.02.120).
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index e617b3c..1620d62 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -243,12 +243,11 @@ int pool_supports_external_origin(const struct lv_segment *pool_seg, const struc
{
uint32_t csize = pool_seg->chunk_size;
- if ((external_lv->size < csize) || (external_lv->size % csize)) {
- /* TODO: Validate with thin feature flag once, it will be supported */
- log_error("Can't use \"%s/%s\" as external origin with \"%s/%s\" pool. "
+ if (((external_lv->size < csize) || (external_lv->size % csize)) &&
+ !thin_pool_feature_supported(pool_seg->lv, THIN_FEATURE_EXTERNAL_ORIGIN_EXTEND)) {
+ log_error("Can't use \"%s\" as external origin with \"%s\" pool. "
"Size %s is not a multiple of pool's chunk size %s.",
- external_lv->vg->name, external_lv->name,
- pool_seg->lv->vg->name, pool_seg->lv->name,
+ display_lvname(external_lv), display_lvname(pool_seg->lv),
display_size(external_lv->vg->cmd, external_lv->size),
display_size(external_lv->vg->cmd, csize));
return 0;
diff --git a/lib/thin/thin.c b/lib/thin/thin.c
index e250603..e098744 100644
--- a/lib/thin/thin.c
+++ b/lib/thin/thin.c
@@ -609,14 +609,18 @@ static int _thin_target_percent(void **target_state __attribute__((unused)),
uint64_t *total_denominator)
{
struct dm_status_thin *s;
+ uint64_t csize;
/* Status for thin device is in sectors */
if (!dm_get_status_thin(mem, params, &s))
return_0;
if (seg) {
- *percent = dm_make_percent(s->mapped_sectors, seg->lv->size);
- *total_denominator += seg->lv->size;
+ /* Pool allocates whole chunk so round-up to nearest one */
+ csize = first_seg(seg->pool_lv)->chunk_size;
+ csize = ((seg->lv->size + csize - 1) / csize) * csize;
+ *percent = dm_make_percent(s->mapped_sectors, csize);
+ *total_denominator += csize;
} else {
/* No lv_segment info here */
*percent = DM_PERCENT_INVALID;
@@ -645,8 +649,8 @@ static int _thin_target_present(struct cmd_context *cmd,
{ 1, 4, THIN_FEATURE_BLOCK_SIZE, "block_size" },
{ 1, 5, THIN_FEATURE_DISCARDS_NON_POWER_2, "discards_non_power_2" },
{ 1, 10, THIN_FEATURE_METADATA_RESIZE, "metadata_resize" },
- { 9, 11, THIN_FEATURE_EXTERNAL_ORIGIN_EXTEND, "external_origin_extend" },
{ 1, 10, THIN_FEATURE_ERROR_IF_NO_SPACE, "error_if_no_space" },
+ { 1, 13, THIN_FEATURE_EXTERNAL_ORIGIN_EXTEND, "external_origin_extend" },
};
static const char _lvmconf[] = "global/thin_disabled_features";
diff --git a/test/shell/lvcreate-thin-external-size.sh b/test/shell/lvcreate-thin-external-size.sh
new file mode 100644
index 0000000..73e36ea
--- /dev/null
+++ b/test/shell/lvcreate-thin-external-size.sh
@@ -0,0 +1,90 @@
+#!/bin/sh
+
+# Copyright (C) 2015 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Test unaligned size of external origin and thin pool chunk size
+
+export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false}
+
+. lib/inittest
+
+test -e LOCAL_LVMPOLLD && skip
+
+which cmp || skip
+
+#
+# Main
+#
+aux have_thin 1 3 0 || skip
+
+aux prepare_pvs 2 640
+
+# Use 8K extent size
+vgcreate $vg -s 8K $(cat DEVICES)
+
+# Prepare some numeric pattern with ~64K size
+seq -s ' ' -w 0 10922 > 64K
+
+d1="$DM_DEV_DIR/$vg/$lv1"
+d2="$DM_DEV_DIR/$vg/$lv2"
+
+# Prepare external origin LV with size not being a multiple of thin pool chunk size
+lvcreate -l47 -n $lv1 $vg
+
+# Fill end with pattern
+dd if=64K of="$d1" bs=8192 seek=45 count=2
+
+# Switch to read-only volume
+lvchange -an $vg/$lv1
+lvchange -pr $vg/$lv1
+
+lvcreate -L2M -T $vg/pool -c 192K
+lvcreate -s $vg/$lv1 --name $lv2 --thinpool $vg/pool
+
+# Check the tail of $lv2 matches $lv1
+dd if="$d2" of=16K bs=8192 skip=45 count=2
+cmp -n 16384 -l 64K 16K
+
+# Now extend and rewrite
+lvextend -l+2 $vg/$lv2
+
+dd if=64K of="$d2" bs=8192 seek=46 count=3 oflag=direct
+dd if="$d2" of=24K bs=8192 skip=46 count=3 iflag=direct
+cmp -n 24576 -l 64K 24K
+
+# Consumes 2 192K chunks -> 66.67%
+check lv_field $vg/$lv2 data_percent "66.67"
+
+lvreduce -f -l-24 $vg/$lv2
+
+dd if=64K of="$d2" bs=8192 seek=24 count=1 oflag=direct
+dd if="$d2" of=8K bs=8192 skip=24 count=1 iflag=direct
+cmp -n 8192 -l 64K 8K
+
+# Check extension still works
+lvextend -l+2 $vg/$lv2
+
+lvremove -f $vg/pool
+
+lvcreate -L256M -T $vg/pool -c 64M
+lvcreate -s $vg/$lv1 --name $lv2 --thinpool $vg/pool
+lvextend -l+2 $vg/$lv2
+
+dd if=64K of="$d2" bs=8192 seek=45 count=4 oflag=direct
+dd if="$d2" of=32K bs=8192 skip=45 count=4 iflag=direct
+cmp -n 32768 -l 64K 32K
+
+lvextend -L+64M $vg/$lv2
+
+# Consumes 64M chunk -> 50%
+check lv_field $vg/$lv2 data_percent "50.00"
+
+vgremove -ff $vg
8 years, 10 months
master - thin: drop limitation for extension of reduced thin volume
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6f2a617c318d3e...
Commit: 6f2a617c318d3e7b4535563b72ddcaad67da62ed
Parent: 69132f55eafb6a797e86b449783f9cd2f518c3dd
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 18 14:38:05 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 18 18:48:59 2015 +0200
thin: drop limitation for extension of reduced thin volume
Drop check which has prevented resize of reduce thin volume with
external origin. User is supposed to use 'zeroing' to get 'clean'
chunks.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 10 ----------
2 files changed, 1 insertions(+), 10 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9e2a3dd..42a2571 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.122 -
=================================
+ Allow to extend reduced thin volumes with external origins.
Consider snapshot and origin LV as unusable if its component is suspended.
Fix lvmconfig segfault on settings with undefined default value (2.02.120).
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 9983793..07f119a 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5084,16 +5084,6 @@ static int _lvresize_check_type(struct cmd_context *cmd, const struct logical_vo
if (lv_is_thin_volume(lv) && first_seg(lv)->external_lv &&
(lp->resize == LV_EXTEND)) {
- /*
- * TODO: currently we do not support extension of already reduced thin volume.
- * But it might be possible to create combined mapping of some part of
- * the external origin followed by zero target.
- */
- if (first_seg(lv)->external_lv->size > lv->size) {
- log_error("Extension of reduced thin volume with external origin is unsupported.");
- return 0;
- }
-
/* Validate thin target supports bigger size of thin volume then external origin */
if (first_seg(lv)->external_lv->size <= lv->size &&
!thin_pool_feature_supported(first_seg(lv)->pool_lv, THIN_FEATURE_EXTERNAL_ORIGIN_EXTEND)) {
8 years, 10 months