master - Misc: New function for reading lvm config file fields
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=94377dfd5ee7bb...
Commit: 94377dfd5ee7bbbdeb8836eeeea2198bc32c07f5
Parent: 6b73d21ba940804ebe91641343ee76f52d6a138e
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Mon Jan 27 05:26:19 2014 -0600
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Mon Jan 27 05:26:19 2014 -0600
Misc: New function for reading lvm config file fields
Introduce 'dm_config_get_int', which will be used by the upcoming
cachepool segment type.
---
libdm/libdevmapper.h | 1 +
libdm/libdm-config.c | 14 ++++++++++++++
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index adfbb76..3bf8bd6 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -1661,6 +1661,7 @@ int dm_config_tree_find_bool(const struct dm_config_tree *cft, const char *path,
int dm_config_find_bool(const struct dm_config_node *cn, const char *path, int fail);
int dm_config_value_is_bool(const struct dm_config_value *v);
+int dm_config_get_int(const struct dm_config_node *cn, const char *path, int *result);
int dm_config_get_uint32(const struct dm_config_node *cn, const char *path, uint32_t *result);
int dm_config_get_uint64(const struct dm_config_node *cn, const char *path, uint64_t *result);
int dm_config_get_str(const struct dm_config_node *cn, const char *path, const char **result);
diff --git a/libdm/libdm-config.c b/libdm/libdm-config.c
index ea1af2f..3297621 100644
--- a/libdm/libdm-config.c
+++ b/libdm/libdm-config.c
@@ -1047,6 +1047,20 @@ int dm_config_tree_find_bool(const struct dm_config_tree *cft, const char *path,
/************************************/
+int dm_config_get_int(const struct dm_config_node *cn, const char *path,
+ int *result)
+{
+ const struct dm_config_node *n;
+
+ n = _find_config_node(cn, path);
+
+ if (!n || !n->v || n->v->type != DM_CFG_INT)
+ return 0;
+
+ if (result)
+ *result = n->v->v.i;
+ return 1;
+}
int dm_config_get_uint32(const struct dm_config_node *cn, const char *path,
uint32_t *result)
10 years, 3 months
master - locking: avoid dropping locks
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6b73d21ba94080...
Commit: 6b73d21ba940804ebe91641343ee76f52d6a138e
Parent: f18ee04fab76a3d817e7be9da76a589700878830
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jan 27 12:11:09 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jan 27 12:13:29 2014 +0100
locking: avoid dropping locks
When lvm2 command forks, it calls reset_locking(),
which as an unwanted side effect unlinked lock file from filesystem.
Patch changes the behavior to just close locked file descriptor
in children - so the lock is being still properly hold in the parent.
---
WHATS_NEW | 1 +
lib/locking/file_locking.c | 17 +++++++++++++----
test/shell/lock-parallel.sh | 39 +++++++++++++++++++++++++++++++++++++++
3 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index d674161..f56ad20 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Fix unwanted drop of hold flocks on forked children.
Respect LVM_LVMETAD_PIDFILE env var for lvm command.
Avoid exposing temporary devices when initializing thin pool volume.
Fix test when checking target version for available thin features.
diff --git a/lib/locking/file_locking.c b/lib/locking/file_locking.c
index 1fa23b3..fb84c5b 100644
--- a/lib/locking/file_locking.c
+++ b/lib/locking/file_locking.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.
*
@@ -44,6 +44,15 @@ static sig_t _oldhandler;
static sigset_t _fullsigset, _intsigset;
static volatile sig_atomic_t _handler_installed;
+/* Drop lock known to be shared with another file descriptor. */
+static void _drop_shared_flock(const char *file, int fd)
+{
+ log_debug_locking("_drop_shared_flock %s.", file);
+
+ if (close(fd) < 0)
+ log_sys_debug("close", file);
+}
+
static void _undo_flock(const char *file, int fd)
{
struct stat buf1, buf2;
@@ -74,9 +83,9 @@ static int _release_lock(const char *file, int unlock)
log_very_verbose("Unlocking %s", ll->res);
if (flock(ll->lf, LOCK_NB | LOCK_UN))
log_sys_debug("flock", ll->res);
- }
-
- _undo_flock(ll->res, ll->lf);
+ _undo_flock(ll->res, ll->lf);
+ } else
+ _drop_shared_flock(ll->res, ll->lf);
dm_free(ll->res);
dm_free(llh);
diff --git a/test/shell/lock-parallel.sh b/test/shell/lock-parallel.sh
new file mode 100644
index 0000000..f8e72c3
--- /dev/null
+++ b/test/shell/lock-parallel.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+# Copyright (C) 2014 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 parallel use of lvm commands and check locks aren't dropped
+# RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1049296
+
+. lib/test
+
+aux prepare_vg
+test -e LOCAL_CLVMD && skip
+
+lvcreate -L10 -n $lv1 $vg
+lvcreate -l1 -n $lv2 $vg
+mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
+
+# Slowdown PV for resized LV
+aux delay_dev "$dev1" 40 40
+
+lvresize -L-5 -r $vg/$lv1 &
+
+# Let's wait till resize start
+sleep 2
+
+lvremove -f $vg/$lv2
+
+wait
+
+aux enable_dev "$dev1"
+
+# Check removed $lv2 does not reappear
+not check lv_exists $vg $lv2
10 years, 3 months
master - lvmetad: respect LVM_LVMETAD_PIDFILE settings in lvm
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f18ee04fab76a3...
Commit: f18ee04fab76a3d817e7be9da76a589700878830
Parent: 89d77326170d020ebba6ae1c717c08ac4b07996a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jan 24 15:59:38 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jan 24 15:59:38 2014 +0100
lvmetad: respect LVM_LVMETAD_PIDFILE settings in lvm
Test LVM_LVMETAD_PIDFILE for pid for lvm command.
Fix WHATS_NEW envvar name usage
Fix init order in prepare_lvmetad to respect set vars
and avoid clash with system settings.
Update test to really test the 'is running' message.
---
WHATS_NEW | 3 ++-
lib/cache/lvmetad.c | 2 +-
man/lvm.8.in | 6 ++++++
test/lib/test.sh | 2 +-
test/shell/lvmetad-disabled.sh | 13 ++++++++-----
5 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 6818026..d674161 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Respect LVM_LVMETAD_PIDFILE env var for lvm command.
Avoid exposing temporary devices when initializing thin pool volume.
Fix test when checking target version for available thin features.
Detect thin feature external_origin_extend and limit extend when missing.
@@ -41,7 +42,7 @@ Version 2.02.105 - 20th January 2014
Add --splitsnapshot to lvconvert to separate out cow LV.
Reinstate origin reload to complete lvconvert -s with active LVs. (2.02.98)
Select only active volume groups if vgdisplay -A is used.
- Add -p and LVM_LVMETAD_PID env var to lvmetad to change pid file.
+ Add -p and LVM_LVMETAD_PIDFILE env var to lvmetad to change pid file.
Allow lvmetad to reuse stale socket.
Only unlink lvmetad socket on error if created by the same process.
Append missing newline to lvmetad missing socket path error message.
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index aec6a71..61361ed 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -40,7 +40,7 @@ void lvmetad_disconnect(void)
void lvmetad_init(struct cmd_context *cmd)
{
- if (!_lvmetad_use && !access(LVMETAD_PIDFILE, F_OK))
+ if (!_lvmetad_use && !access(getenv("LVM_LVMETAD_PIDFILE") ? : LVMETAD_PIDFILE, F_OK))
log_warn("WARNING: lvmetad is running but disabled."
" Restart lvmetad before enabling it!");
_lvmetad_cmd = cmd;
diff --git a/man/lvm.8.in b/man/lvm.8.in
index d78281a..c377b35 100644
--- a/man/lvm.8.in
+++ b/man/lvm.8.in
@@ -301,6 +301,12 @@ is executed.
The Volume Group name that is assumed for
any reference to a Logical Volume that doesn't specify a path.
Not set by default.
+.TP
+.B LVM_LVMETAD_PIDFILE
+Path for the lvmetad pid file.
+.TP
+.B LVM_LVMETAD_SOCKET
+Path for the lvmetad socket file.
.SH VALID NAMES
The following characters are valid for VG and LV names:
.B a-z A-Z 0-9 + _ . -
diff --git a/test/lib/test.sh b/test/lib/test.sh
index 265d61d..71ad55d 100644
--- a/test/lib/test.sh
+++ b/test/lib/test.sh
@@ -81,9 +81,9 @@ test -n "$BASH" && set -eE -o pipefail
aux lvmconf
aux prepare_clvmd
test -n "$LVM_TEST_LVMETAD" && {
- aux prepare_lvmetad
export LVM_LVMETAD_SOCKET="$TESTDIR/lvmetad.socket"
export LVM_LVMETAD_PIDFILE="$TESTDIR/lvmetad.pid"
+ aux prepare_lvmetad
}
echo "@TESTDIR=$TESTDIR"
echo "@PREFIX=$PREFIX"
diff --git a/test/shell/lvmetad-disabled.sh b/test/shell/lvmetad-disabled.sh
index 41a3a19..c344d7f 100644
--- a/test/shell/lvmetad-disabled.sh
+++ b/test/shell/lvmetad-disabled.sh
@@ -13,14 +13,17 @@
test -e LOCAL_LVMETAD || skip
kill $(cat LOCAL_LVMETAD)
+while test -e "$TESTDIR/lvmetad.socket"; do echo -n .; sleep .1; done # wait for the socket close
+test ! -e "$LVM_LVMETAD_PIDFILE"
-test -e $LVMETAD_PIDFILE && skip
lvmetad
-test -e $LVMETAD_PIDFILE
-cp $LVMETAD_PIDFILE LOCAL_LVMETAD
+while ! test -e "$TESTDIR/lvmetad.socket"; do echo -n .; sleep .1; done # wait for the socket
+test -e "$LVM_LVMETAD_PIDFILE"
+cp "$LVM_LVMETAD_PIDFILE" LOCAL_LVMETAD
+
pvs 2>&1 | not grep "lvmetad is running"
aux lvmconf "global/use_lvmetad = 0"
pvs 2>&1 | grep "lvmetad is running"
-kill $(cat $LVMETAD_PIDFILE)
-not ls $LVMETAD_PIDFILE
+kill $(cat "$LVM_LVMETAD_PIDFILE")
+not ls "$LVM_LVMETAD_PIDFILE"
10 years, 3 months
master - thin: fix missing ~ in previous commit
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=89d77326170d02...
Commit: 89d77326170d020ebba6ae1c717c08ac4b07996a
Parent: 731c298e12e36e338afdbda029e6cffb2c98b3eb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jan 24 13:13:37 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jan 24 13:13:37 2014 +0100
thin: fix missing ~ in previous commit
---
lib/metadata/pool_manip.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index 2cb0c27..18dfad5 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -255,7 +255,7 @@ int create_pool(struct logical_volume *pool_lv,
pool_lv->name);
goto bad;
}
- pool_lv->status &= LV_TEMPORARY;
+ pool_lv->status &= ~LV_TEMPORARY;
}
if (dm_snprintf(name, sizeof(name), "%s_%s", pool_lv->name,
10 years, 3 months
master - thin: use LV_TEMPORARY for metadata initialization
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=731c298e12e36e...
Commit: 731c298e12e36e338afdbda029e6cffb2c98b3eb
Parent: 432ff4bd720596bd3e56290c29646e8ba43575fb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jan 24 12:28:35 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jan 24 12:30:28 2014 +0100
thin: use LV_TEMPORARY for metadata initialization
This flag need to be specified when we create thin pool - to avoid
scanning device with watch rules.
---
WHATS_NEW | 1 +
lib/metadata/metadata-exported.h | 7 ++++---
lib/metadata/pool_manip.c | 9 ++++++++-
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 04d62e5..6818026 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Avoid exposing temporary devices when initializing thin pool volume.
Fix test when checking target version for available thin features.
Detect thin feature external_origin_extend and limit extend when missing.
Rename internal pool_can_resize_metadata() to thin_pool_feature_supported().
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 6e7987d..2f1f9ec 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -105,9 +105,10 @@
#define LV_NOSCAN UINT64_C(0x0000080000000000) /* LV - internal use only - the LV
should not be scanned */
#define LV_TEMPORARY UINT64_C(0x0000100000000000) /* LV - internal use only - the LV
- is supposed to be created and
- removed during single LVM
- command execution. */
+ is supposed to be created and
+ removed or reactivated with
+ this flag dropped during single
+ LVM command execution. */
/* Format features flags */
#define FMT_SEGMENTS 0x00000001U /* Arbitrary segment params? */
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index 148b30c..2cb0c27 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -241,7 +241,13 @@ int create_pool(struct logical_volume *pool_lv,
*
* FIXME: implement lazy clearing when activation is disabled
*/
- /* pool_lv is a new LV so the VG lock protects us */
+ /*
+ * pool_lv is a new LV so the VG lock protects us
+ * Pass in LV_TEMPORARY flag, since device is activated purely for wipe
+ * and later it is either deactivated (in cluster)
+ * or directly converted to invisible device via suspend/resume
+ */
+ pool_lv->status |= LV_TEMPORARY;
if (!activate_lv_local(pool_lv->vg->cmd, pool_lv) ||
/* Clear 4KB of metadata device for new thin-pool. */
!wipe_lv(pool_lv, (struct wipe_params) { .do_zero = 1 })) {
@@ -249,6 +255,7 @@ int create_pool(struct logical_volume *pool_lv,
pool_lv->name);
goto bad;
}
+ pool_lv->status &= LV_TEMPORARY;
}
if (dm_snprintf(name, sizeof(name), "%s_%s", pool_lv->name,
10 years, 3 months
master - cleanup: indent
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=432ff4bd720596...
Commit: 432ff4bd720596bd3e56290c29646e8ba43575fb
Parent: 5e4647ec99b1de0923a311004e86649b50f81c1f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jan 24 10:49:31 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jan 24 12:30:28 2014 +0100
cleanup: indent
---
lib/metadata/thin_manip.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 92c4177..b26723b 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -86,9 +86,9 @@ int attach_pool_message(struct lv_segment *pool_seg, dm_thin_message_t type,
dm_list_add(&pool_seg->thin_messages, &tmsg->list);
- log_debug_metadata("Added %s message",
+ log_debug_metadata("Added %s message.",
(type == DM_THIN_MESSAGE_CREATE_SNAP ||
- type == DM_THIN_MESSAGE_CREATE_THIN) ? "create" :
+ type == DM_THIN_MESSAGE_CREATE_THIN) ? "create" :
(type == DM_THIN_MESSAGE_DELETE) ? "delete" : "unknown");
return 1;
10 years, 3 months
master - Typo: s/Unale/Unable/
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5e4647ec99b1de...
Commit: 5e4647ec99b1de0923a311004e86649b50f81c1f
Parent: c1df1f3a81a0ff24ba2e25ed6680fcb653655dee
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Wed Jan 22 23:04:27 2014 -0600
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Wed Jan 22 23:04:27 2014 -0600
Typo: s/Unale/Unable/
---
lib/metadata/pool_manip.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index a36c0c7..148b30c 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -46,7 +46,7 @@ int attach_pool_data_lv(struct lv_segment *pool_seg,
{
if (!seg_is_thin_pool(pool_seg)) {
log_error(INTERNAL_ERROR
- "Unale to attach pool data LV to %s segtype.",
+ "Unable to attach pool data LV to %s segtype.",
pool_seg->segtype->ops->name(pool_seg));
return 0;
}
10 years, 3 months
master - tests: thin external origin resize
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c1df1f3a81a0ff...
Commit: c1df1f3a81a0ff24ba2e25ed6680fcb653655dee
Parent: f8b20fb8e8e54561321b030fae7249ac2c2ac950
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 23 14:17:00 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jan 23 14:22:34 2014 +0100
tests: thin external origin resize
---
test/shell/lvresize-thin-external-origin.sh | 42 +++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvresize-thin-external-origin.sh b/test/shell/lvresize-thin-external-origin.sh
new file mode 100644
index 0000000..d9739c0
--- /dev/null
+++ b/test/shell/lvresize-thin-external-origin.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+# Copyright (C) 2014 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 resize of thin volume with external origin
+. lib/test
+
+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 prepare_pvs 2
+
+vgcreate -s 1M $vg $(cat DEVICES)
+
+lvcreate -L10 -n $lv1 $vg
+
+# Prepare thin pool
+lvcreate -L20 -T $vg/pool
+
+# Convert $lv1 into thin LV with external origin
+lvconvert -T $vg/$lv1 --thinpool $vg/pool --originname ext
+
+lvs -a $vg
+
+# Bigger size is not supported without feature external_origin_extend
+not lvresize -L+10 $vg/$lv1
+
+# But reduction works
+lvresize -L-5 -f $vg/$lv1
+not lvresize -L+15 -y $vg/$lv1
+# We may size again back up to the size of external origin
+# TODO: hmm do we really want this???
+lvresize -L+5 -f $vg/$lv1
10 years, 3 months
master - thin: fix feature compare function
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f8b20fb8e8e545...
Commit: f8b20fb8e8e54561321b030fae7249ac2c2ac950
Parent: 902b343e0ed071e684dfe89086c740db2e20c663
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 23 13:47:23 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jan 23 14:22:31 2014 +0100
thin: fix feature compare function
Comparing for available feature missed the code path, when
maj is already bigger.
The bug would be only hit in the case, thin pool target would have
increased major version.
---
WHATS_NEW | 1 +
lib/thin/thin.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c385951..04d62e5 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Fix test when checking target version for available thin features.
Detect thin feature external_origin_extend and limit extend when missing.
Rename internal pool_can_resize_metadata() to thin_pool_feature_supported().
Issue error if libbblkid detects signature and fails to return offset/length.
diff --git a/lib/thin/thin.c b/lib/thin/thin.c
index cf74964..0b8eaf8 100644
--- a/lib/thin/thin.c
+++ b/lib/thin/thin.c
@@ -651,7 +651,8 @@ static int _thin_target_present(struct cmd_context *cmd,
}
for (i = 0; i < sizeof(_features)/sizeof(*_features); i++)
- if (maj >= _features[i].maj && min >= _features[i].min)
+ if ((maj > _features[i].maj) ||
+ (maj == _features[i].maj && min >= _features[i].min))
_attrs |= _features[i].thin_feature;
else
log_very_verbose("Target %s does not support %s.",
10 years, 3 months
master - thin: validate resize of thin LV with ext. origin
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=902b343e0ed071...
Commit: 902b343e0ed071e684dfe89086c740db2e20c663
Parent: 2dae78b722cff63eb6e11aa6cedad1ee3545871b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 23 13:10:29 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jan 23 14:20:34 2014 +0100
thin: validate resize of thin LV with ext. origin
When thin volume is using external origin, current thin target
is not able to supply 'extended' size with empty pages.
lvm2 detects version and disables extension of LV past the external
origin size in this case.
Thin LV could be however still reduced and extended freely bellow
this size.
---
WHATS_NEW | 1 +
conf/example.conf.in | 1 +
lib/activate/activate.h | 1 +
lib/metadata/lv_manip.c | 8 ++++++++
lib/thin/thin.c | 11 +++++++++++
5 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index e491ed8..c385951 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Detect thin feature external_origin_extend and limit extend when missing.
Rename internal pool_can_resize_metadata() to thin_pool_feature_supported().
Issue error if libbblkid detects signature and fails to return offset/length.
Update autoconf config.guess/sub to 2014-01-01.
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 0c2fc0a..0f73cf3 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -691,6 +691,7 @@ global {
# discards_non_power_2
# external_origin
# metadata_resize
+ # external_origin_extend
#
# thin_disabled_features = [ "discards", "block_size" ]
}
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index 1881f75..f748a04 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -64,6 +64,7 @@ enum {
THIN_FEATURE_BLOCK_SIZE = (1 << 3),
THIN_FEATURE_DISCARDS_NON_POWER_2 = (1 << 4),
THIN_FEATURE_METADATA_RESIZE = (1 << 5),
+ THIN_FEATURE_EXTERNAL_ORIGIN_EXTEND = (1 << 6),
};
void set_activation(int activation);
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 6333ef6..c875b69 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -2452,6 +2452,14 @@ int lv_add_virtual_segment(struct logical_volume *lv, uint64_t status,
lv->le_count += extents;
lv->size += (uint64_t) extents *lv->vg->extent_size;
+ /* Validate thin target supports bigger size of thin volume then external origin */
+ if (lv_is_thin_volume(lv) && first_seg(lv)->external_lv &&
+ first_seg(lv)->external_lv->size < lv->size &&
+ !thin_pool_feature_supported(first_seg(lv)->pool_lv, THIN_FEATURE_EXTERNAL_ORIGIN_EXTEND)) {
+ log_error("Thin target does not support external origin smaller then thin volume.");
+ return 0;
+ }
+
return 1;
}
diff --git a/lib/thin/thin.c b/lib/thin/thin.c
index 6011d77..cf74964 100644
--- a/lib/thin/thin.c
+++ b/lib/thin/thin.c
@@ -528,6 +528,7 @@ static int _thin_add_target_line(struct dev_manager *dm,
{
char *pool_dlid, *external_dlid;
uint32_t device_id = seg->device_id;
+ unsigned attr;
if (!seg->pool_lv) {
log_error(INTERNAL_ERROR "Segment %s has no pool.",
@@ -560,6 +561,15 @@ static int _thin_add_target_line(struct dev_manager *dm,
/* Add external origin LV */
if (seg->external_lv) {
+ if (seg->external_lv->size < seg->lv->size) {
+ /* Validate target supports smaller external origin */
+ if (!_thin_target_present(cmd, first_seg(seg->pool_lv), &attr) ||
+ !(attr & THIN_FEATURE_EXTERNAL_ORIGIN_EXTEND)) {
+ log_error("Thin target does not support smaller size of external origin LV %s.",
+ seg->external_lv->name);
+ return 0;
+ }
+ }
if (!(external_dlid = build_dm_uuid(mem, seg->external_lv->lvid.s,
lv_layer(seg->external_lv)))) {
log_error("Failed to build uuid for external origin LV %s.",
@@ -619,6 +629,7 @@ 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" },
};
static const char _lvmconf[] = "global/thin_disabled_features";
10 years, 3 months