master - pvcreate: switch to "none" dev-ext source during pvcreate
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ed420fb6917162...
Commit: ed420fb6917162ed17af69a9a0ec9ae26e61e209
Parent: 69b1e32c8a06c77023d2e3440e0abfaeb86808f7
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Feb 19 14:30:20 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Feb 19 14:34:55 2015 +0100
pvcreate: switch to "none" dev-ext source during pvcreate
The dev ext source must be reset for the dev_cache_get call
(which evaluates filters), not lvmcache_label_scan - so fix
original commit 727c7ff85d448743f751bc5218e73c41314ed5f1.
Also, add comments in _pvcreate_check fn explaining why
refresh filter and rescan is needed and exactly in which
situations.
---
lib/metadata/metadata.c | 82 +++++++++++++++++++++++++++++++++-------------
1 files changed, 59 insertions(+), 23 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index a4c3033..5acb2b4 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -1416,18 +1416,18 @@ int vg_split_mdas(struct cmd_context *cmd __attribute__((unused)),
* 0 indicates we may not.
*/
static int _pvcreate_check(struct cmd_context *cmd, const char *name,
- struct pvcreate_params *pp)
+ struct pvcreate_params *pp, int *wiped)
{
struct physical_volume *pv;
struct device *dev;
int r = 0;
- int wiped;
int scan_needed = 0;
int filter_refresh_needed = 0;
- dev_ext_t dev_ext_src = external_device_info_source();
/* FIXME Check partition type is LVM unless --force is given */
+ *wiped = 0;
+
/* Is there a pv here already? */
pv = find_pv_by_name(cmd, name, 1, 1);
@@ -1452,6 +1452,33 @@ static int _pvcreate_check(struct cmd_context *cmd, const char *name,
dev = dev_cache_get(name, cmd->full_filter);
+ /*
+ * Refresh+rescan at the end is needed if:
+ * - we don't obtain device list from udev,
+ * hence persistent cache file is used
+ * and we need to trash it and reevaluate
+ * for any changes done outside - adding
+ * any new foreign signature which may affect
+ * filtering - before we do pvcreate, we
+ * need to be sure that we have up-to-date
+ * view for filters
+ *
+ * - we have wiped existing foreign signatures
+ * from dev as this may affect what's filtered
+ * as well
+ *
+ *
+ * Only rescan at the end is needed if:
+ * - we've just checked whether dev is fileterd
+ * by MD filter. We do the refresh in-situ,
+ * so no need to require the refresh at the
+ * end of this fn. This is to allow for
+ * wiping MD signature during pvcreate for
+ * the dev - the dev would normally be
+ * filtered because of MD filter.
+ * This is an exception.
+ */
+
/* Is there an md superblock here? */
if (!dev && md_filtering()) {
if (!refresh_filters(cmd))
@@ -1462,7 +1489,8 @@ static int _pvcreate_check(struct cmd_context *cmd, const char *name,
init_md_filtering(1);
scan_needed = 1;
- }
+ } else if (!obtain_device_list_from_udev())
+ filter_refresh_needed = scan_needed = 1;
if (!dev) {
log_error("Device %s not found (or ignored by filtering).", name);
@@ -1481,26 +1509,13 @@ static int _pvcreate_check(struct cmd_context *cmd, const char *name,
if (!wipe_known_signatures(cmd, dev, name,
TYPE_LVM1_MEMBER | TYPE_LVM2_MEMBER,
- 0, pp->yes, pp->force, &wiped)) {
+ 0, pp->yes, pp->force, wiped)) {
log_error("Aborting pvcreate on %s.", name);
goto out;
}
- if (wiped) {
- if (dev_ext_src == DEV_EXT_UDEV)
- /*
- * wipe_known_signatures called later fires WATCH event
- * to update udev database. But at the moment, we have
- * no way to synchronize with such event - we may end
- * up still seeing the old info in udev db and pvcreate
- * can fail to proceed because of the device still
- * being filtered (because of the stale info in udev db).
- * Disable udev dev-ext source temporarily here for
- * this reason.
- */
- init_external_device_info_source(DEV_EXT_NONE);
+ if (wiped)
filter_refresh_needed = scan_needed = 1;
- }
if (sigint_caught())
goto_out;
@@ -1521,14 +1536,14 @@ out:
r = 0;
}
- if (scan_needed)
+ if (scan_needed) {
if (!lvmcache_label_scan(cmd, 2)) {
stack;
r = 0;
}
+ }
free_pv_fid(pv);
- init_external_device_info_source(dev_ext_src);
return r;
}
@@ -1637,9 +1652,11 @@ struct physical_volume *pvcreate_vol(struct cmd_context *cmd, const char *pv_nam
{
struct physical_volume *pv = NULL;
struct device *dev;
+ int wiped = 0;
struct dm_list mdas;
struct pvcreate_params default_pp;
char buffer[64] __attribute__((aligned(8)));
+ dev_ext_t dev_ext_src;
pvcreate_params_set_defaults(&default_pp);
if (!pp)
@@ -1661,13 +1678,32 @@ struct physical_volume *pvcreate_vol(struct cmd_context *cmd, const char *pv_nam
}
}
- if (!_pvcreate_check(cmd, pv_name, pp))
+ if (!_pvcreate_check(cmd, pv_name, pp, &wiped))
goto_bad;
if (sigint_caught())
goto_bad;
- if (!(dev = dev_cache_get(pv_name, cmd->full_filter))) {
+ /*
+ * wipe_known_signatures called in _pvcreate_check fires
+ * WATCH event to update udev database. But at the moment,
+ * we have no way to synchronize with such event - we may
+ * end up still seeing the old info in udev db and pvcreate
+ * can fail to proceed because of the device still being
+ * filtered (because of the stale info in udev db).
+ * Disable udev dev-ext source temporarily here for
+ * this reason and rescan with DEV_EXT_NONE dev-ext
+ * source (so filters use DEV_EXT_NONE source).
+ */
+ dev_ext_src = external_device_info_source();
+ if (wiped && (dev_ext_src == DEV_EXT_UDEV))
+ init_external_device_info_source(DEV_EXT_NONE);
+
+ dev = dev_cache_get(pv_name, cmd->full_filter);
+
+ init_external_device_info_source(dev_ext_src);
+
+ if (!dev) {
log_error("%s: Couldn't find device. Check your filters?",
pv_name);
goto bad;
9 years, 2 months
master - wiping: blkid: do not count skipped signatures in final number of wipes
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=69b1e32c8a06c7...
Commit: 69b1e32c8a06c77023d2e3440e0abfaeb86808f7
Parent: 373f8556847a8fdbed3cedd687691d716dca4c5a
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Feb 19 13:20:01 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Feb 19 13:30:05 2015 +0100
wiping: blkid: do not count skipped signatures in final number of wipes
We exclude some signatures from being wiped when using blkid wiping.
These are signatures which we simply overwrite. For example, the
LVM2_member signature which denotes a PV - if we call pvcreate on
existing PV, we just overwrite the PV header, no need to wipe it.
Previously, we counted such signatures as if they were wiped
and they were counted in the final number of wiped signatures
that _wipe_known_signatures_with_blkid fn returned in the "wiped"
output arg. Then the code checking this output arg could be
mislead that wiping happened while no wiping took place in real
and we could fire some code uselessly based on this information
(e.g. refreshing filters/rescanning - see also
commit 6b4066585f73df7328ea16f6cb3713cd49cf2d2d).
---
lib/device/dev-type.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index c7624ac..1649a3a 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -540,7 +540,7 @@ static int _blkid_wipe(blkid_probe probe, struct device *dev, const char *name,
if (!blkid_probe_lookup_value(probe, "TYPE", &type, NULL)) {
if (_type_in_flag_list(type, types_to_exclude))
- return 1;
+ return 2;
if (blkid_probe_lookup_value(probe, "SBMAGIC_OFFSET", &offset, NULL)) {
log_error(_msg_failed_offset, type, name);
return 0;
@@ -600,6 +600,7 @@ static int _wipe_known_signatures_with_blkid(struct device *dev, const char *nam
{
blkid_probe probe = NULL;
int found = 0, left = 0, wiped_tmp;
+ int r_wipe;
int r = 0;
if (!wiped)
@@ -626,9 +627,11 @@ static int _wipe_known_signatures_with_blkid(struct device *dev, const char *nam
BLKID_SUBLKS_BADCSUM);
while (!blkid_do_probe(probe)) {
- found++;
- if (_blkid_wipe(probe, dev, name, types_to_exclude, types_no_prompt, yes, force))
+ if ((r_wipe = _blkid_wipe(probe, dev, name, types_to_exclude, types_no_prompt, yes, force)) == 1)
(*wiped)++;
+ /* do not count excluded types */
+ if (r_wipe != 2)
+ found++;
}
if (!found)
9 years, 2 months
master - clvmd: Fix BZ 1140095 by updating lastfd upon EINTR.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=373f8556847a8f...
Commit: 373f8556847a8fdbed3cedd687691d716dca4c5a
Parent: 88411fb6f97937c6cac573e2720ae30fafe96761
Author: Petr Rockai <me(a)mornfall.net>
AuthorDate: Wed Feb 18 12:45:43 2015 +0100
Committer: Petr Rockai <me(a)mornfall.net>
CommitterDate: Wed Feb 18 12:45:43 2015 +0100
clvmd: Fix BZ 1140095 by updating lastfd upon EINTR.
---
daemons/clvmd/clvmd.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c
index 5cd6874..a7f98a0 100644
--- a/daemons/clvmd/clvmd.c
+++ b/daemons/clvmd/clvmd.c
@@ -899,8 +899,10 @@ static void main_loop(int cmd_timeout)
ret = thisfd->callback(thisfd, buf, sizeof(buf),
csid, &newfd);
/* Ignore EAGAIN */
- if (ret < 0 && (errno == EAGAIN || errno == EINTR))
+ if (ret < 0 && (errno == EAGAIN || errno == EINTR)) {
+ lastfd = thisfd;
continue;
+ }
/* Got error or EOF: Remove it from the list safely */
if (ret <= 0) {
9 years, 2 months
master - test: Avoid a race in pvmove-restart.sh.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=88411fb6f97937...
Commit: 88411fb6f97937c6cac573e2720ae30fafe96761
Parent: 733e3f6f983d26c346c5426915abfd9594e85a49
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Feb 18 12:27:47 2015 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Wed Feb 18 12:27:47 2015 +0100
test: Avoid a race in pvmove-restart.sh.
---
test/shell/pvmove-restart.sh | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/test/shell/pvmove-restart.sh b/test/shell/pvmove-restart.sh
index 5e4fd8b..398095b 100644
--- a/test/shell/pvmove-restart.sh
+++ b/test/shell/pvmove-restart.sh
@@ -15,7 +15,9 @@
aux prepare_pvs 3 60
-vgcreate -s 128k $vg "$dev1" "$dev2" "$dev3"
+vgcreate -s 128k $vg "$dev1" "$dev2"
+pvcreate --metadatacopies 0 "$dev3"
+vgextend $vg "$dev3"
for mode in "--atomic" ""
do
@@ -32,7 +34,7 @@ aux delay_dev "$dev3" 0 100
pvmove -i0 -n $vg/$lv1 "$dev1" "$dev3" &
PVMOVE=$!
# Let's wait a bit till pvmove starts and kill it
-sleep 1
+while not dmsetup status "$vg-pvmove0"; do sleep .1; done
kill -9 $PVMOVE
wait
9 years, 2 months
master - test: Make pvmove0 device removal more robust, in pvmove-restart.sh.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=733e3f6f983d26...
Commit: 733e3f6f983d26c346c5426915abfd9594e85a49
Parent: 10b8d2a4ea538c21cf991fd608de47a9c18f85f4
Author: Petr Rockai <me(a)mornfall.net>
AuthorDate: Wed Feb 18 10:17:43 2015 +0100
Committer: Petr Rockai <me(a)mornfall.net>
CommitterDate: Wed Feb 18 10:21:06 2015 +0100
test: Make pvmove0 device removal more robust, in pvmove-restart.sh.
---
test/shell/pvmove-restart.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/shell/pvmove-restart.sh b/test/shell/pvmove-restart.sh
index 98ff6b4..5e4fd8b 100644
--- a/test/shell/pvmove-restart.sh
+++ b/test/shell/pvmove-restart.sh
@@ -39,8 +39,8 @@ wait
# Simulate reboot - forcibly remove related devices
# First take down $lv1 then it's pvmove0
-dmsetup ls --exec echo | grep "${vg}-$lv1" | xargs -r dmsetup remove
-dmsetup ls --exec echo | grep "${vg}-pvmove0" | xargs -r dmsetup remove
+while dmsetup status "$vg-$lv1"; do dmsetup remove "$vg-$lv1" || true; done
+while dmsetup status "$vg-pvmove0"; do dmsetup remove "$vg-pvmove0" || true; done
# Check we really have pvmove volume
check lv_attr_bit type $vg/pvmove0 "p"
9 years, 2 months
master - tests: hide uninteresting output
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=10b8d2a4ea538c...
Commit: 10b8d2a4ea538c21cf991fd608de47a9c18f85f4
Parent: 973afcbb2064ad5ca264d9262ed5fd0a7bdac50e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 17 15:53:24 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 17 15:54:21 2015 +0100
tests: hide uninteresting output
We don't care about diff output.
---
test/lib/aux.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index f33b62e..d3a3382 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -193,7 +193,7 @@ teardown_devs() {
test ! -f LOOPFILE || rm -f $(< LOOPFILE)
fi
rm -f DEVICES # devs is set in prepare_devs()
- not diff LOOP BACKING_DEV || rm -f BACKING_DEV
+ not diff LOOP BACKING_DEV >/dev/null 2>&1 || rm -f BACKING_DEV
rm -f LOOP
# Attempt to remove any loop devices that failed to get torn down if earlier tests aborted
9 years, 2 months
master - NIX: Fix a typo that broke evaluation of fc19+.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=973afcbb2064ad...
Commit: 973afcbb2064ad5ca264d9262ed5fd0a7bdac50e
Parent: a009c0fb407ec3a16e0432cb29434b9e9e79d81b
Author: Petr Rockai <me(a)mornfall.net>
AuthorDate: Tue Feb 17 14:41:51 2015 +0100
Committer: Petr Rockai <me(a)mornfall.net>
CommitterDate: Tue Feb 17 15:32:04 2015 +0100
NIX: Fix a typo that broke evaluation of fc19+.
---
nix/default.nix | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/nix/default.nix b/nix/default.nix
index c5f044f..da1fa08 100644
--- a/nix/default.nix
+++ b/nix/default.nix
@@ -326,7 +326,7 @@ let
"dlm" "systemd-devel" "perl-Digest-MD5" "kernel-modules-extra" ];
fedora18u = fedora18;
- fedora19 = centos70 + [ "kernel-modules-extra" ];
+ fedora19 = centos70 ++ [ "kernel-modules-extra" ];
fedora19u = fedora19;
fedora20 = fedora19;
9 years, 2 months
master - cleanup: fix compate of return value
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a009c0fb407ec3...
Commit: a009c0fb407ec3a16e0432cb29434b9e9e79d81b
Parent: 4bb60c05bfc5b1be101807302e0697a4508dd98c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 17 13:40:35 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 17 13:40:35 2015 +0100
cleanup: fix compate of return value
Drop '!' for 'ret' compare.
Since the effect of false compare was only stack trace printing,
it present no real code flow change.
---
tools/lvconvert.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 3bbe65f..935cbf9 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3519,7 +3519,7 @@ static int _lvconvert_merge_single(struct cmd_context *cmd, struct logical_volum
*/
unlock_vg(cmd, vg_name);
- if (!(ret = _poll_logical_volume(cmd, lp->lv_to_poll,
+ if ((ret = _poll_logical_volume(cmd, lp->lv_to_poll,
lp->wait_completion)) != ECMD_PROCESSED)
stack;
9 years, 2 months
master - cleanup: drop !! from code
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4bb60c05bfc5b1...
Commit: 4bb60c05bfc5b1be101807302e0697a4508dd98c
Parent: cb144c0097fe111d9881457de7c686c190c07944
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 17 13:39:47 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 17 13:39:47 2015 +0100
cleanup: drop !! from code
It's unused piece of code - but gcc5 noticed problem with
usage of !! on the leftside.
---
tools/vgsplit.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index 362f854..607f8e0 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -350,7 +350,7 @@ static int _move_cache(struct volume_group *vg_from,
data = seg_lv(first_seg(seg->pool_lv), 0);
meta = first_seg(seg->pool_lv)->metadata_lv;
/* Ensure all components are coming along */
- is_moving = !!_lv_is_in_vg(vg_to, orig);
+ is_moving = _lv_is_in_vg(vg_to, orig);
} else {
if (!dm_list_empty(&seg->lv->segs_using_this_lv) &&
!(cache_seg = get_only_segment_using_this_lv(seg->lv)))
@@ -364,20 +364,20 @@ static int _move_cache(struct volume_group *vg_from,
is_moving = 1;
}
- if (orig && (!!_lv_is_in_vg(vg_to, orig) != is_moving)) {
+ if (orig && (_lv_is_in_vg(vg_to, orig) != is_moving)) {
log_error("Can't split %s and its origin (%s)"
" into separate VGs", lv->name, orig->name);
return 0;
}
- if (data && (!!_lv_is_in_vg(vg_to, data) != is_moving)) {
+ if (data && (_lv_is_in_vg(vg_to, data) != is_moving)) {
log_error("Can't split %s and its cache pool"
" data LV (%s) into separate VGs",
lv->name, data->name);
return 0;
}
- if (meta && (!!_lv_is_in_vg(vg_to, meta) != is_moving)) {
+ if (meta && (_lv_is_in_vg(vg_to, meta) != is_moving)) {
log_error("Can't split %s and its cache pool"
" metadata LV (%s) into separate VGs",
lv->name, meta->name);
9 years, 2 months
master - cleanup: drop unused val
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cb144c0097fe11...
Commit: cb144c0097fe111d9881457de7c686c190c07944
Parent: cd1a76a49222feb975b440199881d7c70faf103a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 17 13:39:26 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 17 13:39:26 2015 +0100
cleanup: drop unused val
---
libdaemon/client/daemon-io.c | 6 ------
1 files changed, 0 insertions(+), 6 deletions(-)
diff --git a/libdaemon/client/daemon-io.c b/libdaemon/client/daemon-io.c
index d19acd6..5ce9dde 100644
--- a/libdaemon/client/daemon-io.c
+++ b/libdaemon/client/daemon-io.c
@@ -51,10 +51,7 @@ int buffer_read(int fd, struct buffer *buffer) {
return 0; /* we should never encounter EOF here */
} else if (result < 0 && ( errno == EAGAIN || errno == EWOULDBLOCK ||
errno == EINTR || errno == EIO)) {
- struct timeval tval;
fd_set in;
- tval.tv_sec = 1;
- tval.tv_usec = 0;
FD_ZERO(&in);
FD_SET(fd, &in);
/* ignore the result, this is just a glorified sleep */
@@ -83,10 +80,7 @@ int buffer_write(int fd, const struct buffer *buffer) {
written += result;
else if (result < 0 && ( errno == EAGAIN || errno == EWOULDBLOCK ||
errno == EINTR || errno == EIO)) {
- struct timeval tval;
fd_set out;
- tval.tv_sec = 1;
- tval.tv_usec = 0;
FD_ZERO(&out);
FD_SET(fd, &out);
/* ignore the result, this is just a glorified sleep */
9 years, 2 months