Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6b73d21ba940804e…
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
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f18ee04fab76a3d8…
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"
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=731c298e12e36e33…
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,
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c1df1f3a81a0ff24…
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
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f8b20fb8e8e54561…
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.",