master - thin: fix forbidden discards checks
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a5b9b4bf02b42b...
Commit: a5b9b4bf02b42baf1f1c033eaa98c5fe23951b43
Parent: 11eaf1c98c3fac8524f227956f57c3d486740a1a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Feb 2 12:48:52 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 5 14:38:16 2013 +0100
thin: fix forbidden discards checks
Instead of check for lv_is_active() for thin pool LV,
query the whole pool via new pool_is_active().
Fixes a problem when we cannot change discards settings
for active pool device where the actual layer for pool
device was inactive, but thin volumes using thin pool
have been active.
---
WHATS_NEW | 1 +
test/shell/discards-thin.sh | 22 ++++++++++++++++++----
tools/lvchange.c | 4 ++--
3 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 1b26317..b6c1785 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Fix check for some forbidden discards conversion of thin pools.
Add pool_is_active() to check for any pool related active LV.
Report blank field if the LV doesn't have an origin instead of 0.
Do not take a free lv name argument for lvconvert --thinpool option.
diff --git a/test/shell/discards-thin.sh b/test/shell/discards-thin.sh
index 84688b4..525f106 100644
--- a/test/shell/discards-thin.sh
+++ b/test/shell/discards-thin.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2012-2013 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
@@ -34,16 +34,30 @@ check lv_field $vg/pool2 discards "passdown"
lvchange --discards nopassdown $vg/pool2
-# cannot convert active ignore -> passdown
+lvcreate -V1M -n origin -T $vg/pool
+lvcreate -s $vg/origin -n snap
+
+# Cannot convert active nopassdown -> ignore
+not lvchange --discards nopassdown $vg/pool
+
+# Cannot convert active ignore -> passdown
not lvchange --discards passdown $vg/pool
-# cannot convert active nopassdown -> ignore
+# Cannot convert active nopassdown -> ignore
not lvchange --discards ignore $vg/pool1
-# deactivate
+# Deactivate pool only
lvchange -an $vg/pool $vg/pool1
+
+# Cannot convert, since thin volumes are still active
+not lvchange --discards passdown $vg/pool
+
+# Deactive thin volumes
+lvchange -an $vg/origin $vg/snap
+
lvchange --discards passdown $vg/pool
check lv_field $vg/pool discards "passdown"
+
lvchange --discards ignore $vg/pool1
check lv_field $vg/pool1 discards "ignore"
diff --git a/tools/lvchange.c b/tools/lvchange.c
index c3c993a..0ea2e78 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -113,9 +113,9 @@ static int lvchange_pool_update(struct cmd_context *cmd,
if (discards != first_seg(lv)->discards) {
if (((discards == THIN_DISCARDS_IGNORE) ||
(first_seg(lv)->discards == THIN_DISCARDS_IGNORE)) &&
- lv_is_active(lv))
+ pool_is_active(first_seg(lv)))
log_error("Cannot change discards state for active "
- "logical volume \"%s\".", lv->name);
+ "pool volume \"%s\".", lv->name);
else {
first_seg(lv)->discards = discards;
update++;
11 years, 2 months
master - thin: add function pool_is_active
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=11eaf1c98c3fac...
Commit: 11eaf1c98c3fac8524f227956f57c3d486740a1a
Parent: 9d445f371c7658969d6580748233dc33c3ba0453
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 5 10:52:39 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 5 14:35:44 2013 +0100
thin: add function pool_is_active
This internal function check for active pool device.
For cluster it checks every thin volume,
On the non-clustered VG we need to check just
for presence of -tpool device.
---
WHATS_NEW | 1 +
lib/metadata/metadata.h | 1 +
lib/metadata/thin_manip.c | 27 +++++++++++++++++++++++++++
3 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 64b811e..1b26317 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Add pool_is_active() to check for any pool related active LV.
Report blank field if the LV doesn't have an origin instead of 0.
Do not take a free lv name argument for lvconvert --thinpool option.
Avoid flushing thin pool when quering for transaction_id.
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 19bf742..8a80147 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -472,6 +472,7 @@ int attach_pool_message(struct lv_segment *pool_seg, dm_thin_message_t type,
int auto_increment);
int pool_has_message(const struct lv_segment *seg,
const struct logical_volume *lv, uint32_t device_id);
+int pool_is_active(const struct lv_segment *pool_seg);
int pool_below_threshold(const struct lv_segment *pool_seg);
int extend_pool(struct logical_volume *lv, const struct segment_type *segtype,
struct alloc_handle *ah, uint32_t stripes, uint32_t stripe_size);
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 016f776..51f3d16 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -230,6 +230,33 @@ int pool_has_message(const struct lv_segment *seg,
return 0;
}
+int pool_is_active(const struct lv_segment *pool_seg)
+{
+ struct lvinfo info;
+ const struct seg_list *sl;
+ const struct logical_volume *lv = pool_seg->lv;
+
+ if (!seg_is_thin_pool(pool_seg)) {
+ log_error(INTERNAL_ERROR "LV %s is not pool.", lv->name);
+ return 0;
+ }
+
+ /* On clustered VG, query every related thin pool volume */
+ if (vg_is_clustered(lv->vg)) {
+ if (lv_is_active(lv))
+ return 1;
+
+ dm_list_iterate_items(sl, &lv->segs_using_this_lv)
+ if (lv_is_active(sl->seg->lv)) {
+ log_debug("Thin volume \"%s\" is active.", sl->seg->lv->name);
+ return 1;
+ }
+ } else if (lv_info(lv->vg->cmd, lv, 1, &info, 0, 0) && info.exists)
+ return 1; /* Non clustered VG - just checks for '-tpool' */
+
+ return 0;
+}
+
int pool_below_threshold(const struct lv_segment *pool_seg)
{
percent_t percent;
11 years, 2 months
master - report: leave empty report field for 0
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9d445f371c7658...
Commit: 9d445f371c7658969d6580748233dc33c3ba0453
Parent: 15115b61c0893a4abc660b1625b96fb14d073993
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 5 13:59:15 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 5 14:32:37 2013 +0100
report: leave empty report field for 0
Since we do not support LVs with 0 size, use this value
as 'error' value for devices without origin, and leave this
field blank as in other cases.
---
WHATS_NEW | 1 +
lib/report/report.c | 7 +++++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 84a3590..64b811e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Report blank field if the LV doesn't have an origin instead of 0.
Do not take a free lv name argument for lvconvert --thinpool option.
Avoid flushing thin pool when quering for transaction_id.
Add internal function lv_layer() to obtain layer name for LV.
diff --git a/lib/report/report.c b/lib/report/report.c
index 1833458..5a4e4df 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2013 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -590,7 +590,10 @@ static int _originsize_disp(struct dm_report *rh, struct dm_pool *mem,
const struct logical_volume *lv = (const struct logical_volume *) data;
uint64_t size;
- size = lv_origin_size(lv);
+ if (!(size = lv_origin_size(lv))) {
+ dm_report_field_set_value(field, "", NULL);
+ return 1;
+ }
return _size64_disp(rh, mem, field, &size, private);
}
11 years, 2 months
master - lvconvert: update error path
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=15115b61c0893a...
Commit: 15115b61c0893a4abc660b1625b96fb14d073993
Parent: be5ad90703ca789becc10d56c19f6dc24f4c7eae
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 5 11:21:21 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 5 14:31:34 2013 +0100
lvconvert: update error path
Update the error path after problems with suspend_lv or vg_commit.
It's not exactly well defined what should happen, and this
code seems to appear in many different instancies<F2> in the
whole source code tree - we should probably pick the best version.
---
tools/lvconvert.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 94767b6..0e15888 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2007 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2005-2013 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -503,10 +503,13 @@ static int _reload_lv(struct cmd_context *cmd,
if (!suspend_lv(cmd, lv)) {
log_error("Failed to lock %s", lv->name);
vg_revert(vg);
+ if (!resume_lv(cmd, lv))
+ stack;
goto out;
}
if (!vg_commit(vg)) {
+ vg_revert(vg);
if (!resume_lv(cmd, lv))
stack;
goto_out;
@@ -520,8 +523,8 @@ static int _reload_lv(struct cmd_context *cmd,
}
r = 1;
-out:
backup(vg);
+out:
return r;
}
11 years, 2 months
master - lvconvert: fix accepting second lv name
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=be5ad90703ca78...
Commit: be5ad90703ca789becc10d56c19f6dc24f4c7eae
Parent: d3b8f270eac7314767e9098ef28e2f8b89fbf296
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Feb 4 13:56:54 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 5 14:31:17 2013 +0100
lvconvert: fix accepting second lv name
Do not allow to accept second LV name on lvconvert --thinpool
command line.
---
WHATS_NEW | 1 +
tools/lvconvert.c | 7 ++++++-
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 272c6c8..84a3590 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Do not take a free lv name argument for lvconvert --thinpool option.
Avoid flushing thin pool when quering for transaction_id.
Add internal function lv_layer() to obtain layer name for LV.
Report partial and in-sync RAID attribute based on kernel status
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 5bda00f..94767b6 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -92,7 +92,12 @@ static int _lvconvert_name_params(struct lvconvert_params *lp,
lp->origin = ptr + 1;
}
- if (!*pargc && lp->pool_data_lv_name) {
+ if (lp->pool_data_lv_name) {
+ if (*pargc) {
+ log_error("More then one logical volume name name specified.");
+ return 0;
+ }
+
if (!lp->vg_name || !validate_name(lp->vg_name)) {
log_error("Please provide a valid volume group name.");
return 0;
11 years, 2 months
master - headers: add headers for musl libc
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d3b8f270eac731...
Commit: d3b8f270eac7314767e9098ef28e2f8b89fbf296
Parent: 7cd25062acc5c54959e892381600257372ef071f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 5 09:33:30 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 5 14:27:25 2013 +0100
headers: add headers for musl libc
On glibc, those are erroneously (namespace pollution) pulled in via
other headers. this doesn't work with conformant libcs (musl libc in
this case), we simply need to include all needed headers.
Signed-Off-By: John Spencer <maillist-lvm(a)barfooze.de>
---
daemons/dmeventd/dmeventd.c | 1 +
libdm/mm/pool-fast.c | 1 +
.../lvm2_activation_generator_systemd_red_hat.c | 1 +
3 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index 55b940f..06c0c92 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -37,6 +37,7 @@
#include <unistd.h>
#include <signal.h>
#include <arpa/inet.h> /* for htonl, ntohl */
+#include <fcntl.h>
#ifdef linux
/*
diff --git a/libdm/mm/pool-fast.c b/libdm/mm/pool-fast.c
index 61e076a..0e13416 100644
--- a/libdm/mm/pool-fast.c
+++ b/libdm/mm/pool-fast.c
@@ -18,6 +18,7 @@
#endif
#include "dmlib.h"
+#include <stddef.h>
#include <malloc.h>
struct chunk {
diff --git a/scripts/lvm2_activation_generator_systemd_red_hat.c b/scripts/lvm2_activation_generator_systemd_red_hat.c
index dfd6fc4..6fc2865 100644
--- a/scripts/lvm2_activation_generator_systemd_red_hat.c
+++ b/scripts/lvm2_activation_generator_systemd_red_hat.c
@@ -19,6 +19,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <limits.h> /* for PATH_MAX */
#include "lvm2app.h"
#define KMSG_DEV_PATH "/dev/kmsg"
11 years, 2 months
master - cleanup: avoid overflow warning
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7cd25062acc5c5...
Commit: 7cd25062acc5c54959e892381600257372ef071f
Parent: d7ea12f222bb40d0bdd523a6072c5771053f75c1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Feb 4 20:32:21 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 5 14:27:25 2013 +0100
cleanup: avoid overflow warning
Even we do not expect to support chunks bigger then 2GB.
---
tools/toollib.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 669d772..1abe837 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1617,7 +1617,7 @@ int update_pool_params(struct cmd_context *cmd, unsigned attr,
(2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE *
(SECTOR_SIZE / UINT64_C(64)));
log_warn("WARNING: Chunk size is too small for pool, suggested minimum is %s.",
- display_size(cmd, 1 << (int)(ffs(estimate_chunk_size) + 1)));
+ display_size(cmd, UINT64_C(1) << (ffs(estimate_chunk_size) + 1)));
}
/* Round up to extent size */
11 years, 2 months
master - cleanup: remove extra braces
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d7ea12f222bb40...
Commit: d7ea12f222bb40d0bdd523a6072c5771053f75c1
Parent: 6d74ff2bf8313dae0cc27530eebf63be06a7bae6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Feb 4 20:31:56 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 5 14:27:24 2013 +0100
cleanup: remove extra braces
---
tools/dmsetup.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 196c170..8b1145f 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -3672,7 +3672,7 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
}
if (ind == INACTIVE_ARG)
_switches[INACTIVE_ARG]++;
- if ((ind == MANGLENAME_ARG)) {
+ if (ind == MANGLENAME_ARG) {
_switches[MANGLENAME_ARG]++;
if (!strcasecmp(optarg, "none"))
_int_args[MANGLENAME_ARG] = DM_STRING_MANGLING_NONE;
11 years, 2 months
master - cleanup: malloc attributes
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6d74ff2bf8313d...
Commit: 6d74ff2bf8313dae0cc27530eebf63be06a7bae6
Parent: ddeb37f282caf053687d447cd7f52cb7d5a1f702
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Feb 4 20:29:59 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 5 14:27:24 2013 +0100
cleanup: malloc attributes
---
libdm/libdevmapper.h | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 458d642..b08a549 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -770,15 +770,15 @@ uint32_t dm_tree_get_cookie(struct dm_tree_node *node);
*******************/
void *dm_malloc_aux(size_t s, const char *file, int line)
- __attribute__((malloc)) __attribute__((__warn_unused_result__));
+ __attribute__((__malloc__)) __attribute__((__warn_unused_result__));
void *dm_malloc_aux_debug(size_t s, const char *file, int line)
__attribute__((__warn_unused_result__));
void *dm_zalloc_aux(size_t s, const char *file, int line)
- __attribute__((malloc)) __attribute__((__warn_unused_result__));
+ __attribute__((__malloc__)) __attribute__((__warn_unused_result__));
void *dm_zalloc_aux_debug(size_t s, const char *file, int line)
__attribute__((__warn_unused_result__));
char *dm_strdup_aux(const char *str, const char *file, int line)
- __attribute__((malloc)) __attribute__((__warn_unused_result__));
+ __attribute__((__malloc__)) __attribute__((__warn_unused_result__));
void dm_free_aux(void *p);
void *dm_realloc_aux(void *p, unsigned int s, const char *file, int line)
__attribute__((__warn_unused_result__));
11 years, 2 months
master - cleanup: add internal error check
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ddeb37f282caf0...
Commit: ddeb37f282caf053687d447cd7f52cb7d5a1f702
Parent: f5cd9c3563a77f65b039923833ee13f3e22a959f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Dec 14 19:42:28 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 5 14:27:24 2013 +0100
cleanup: add internal error check
Check if 'is_removable' is defined and report internal error,
if it's missing.
---
lib/metadata/mirror.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index 4fee763..2a78508 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -864,8 +864,13 @@ static int _remove_mirror_images(struct logical_volume *lv,
s >= 0 && old_area_count - new_area_count < orig_removed;
s--) {
sub_lv = seg_lv(mirrored_seg, s);
- if (!(is_temporary_mirror_layer(sub_lv) && lv_mirror_count(sub_lv) != 1) &&
- is_removable(sub_lv, removable_baton)) {
+ if (!(is_temporary_mirror_layer(sub_lv) && lv_mirror_count(sub_lv) != 1)) {
+ if (!is_removable) {
+ log_error(INTERNAL_ERROR "Test is_removable undefined.");
+ return 0;
+ }
+ if (!is_removable(sub_lv, removable_baton))
+ continue;
/*
* Check if the user is trying to pull the
* primary mirror image when the mirror is
11 years, 2 months