master - tests: drop check for awk
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a16324b0d3ee2e...
Commit: a16324b0d3ee2e3166ca0a9b5c87b5a68e756a68
Parent: ee65528547aaec2076d7dc5bf61285732dbbb534
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Mar 27 13:43:11 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Apr 2 13:38:41 2015 +0200
tests: drop check for awk
---
test/lib/aux.sh | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index b9f63b5..a14b7a3 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -324,9 +324,6 @@ prepare_scsi_debug_dev() {
test -z "$LOOP"
test -n "$DM_DEV_DIR"
- # Skip test if awk isn't available (required for get_sd_devs_)
- which awk || skip
-
# Skip test if scsi_debug module is unavailable or is already in use
modprobe --dry-run scsi_debug || skip
lsmod | not grep -q scsi_debug || skip
7 years, 12 months
master - tests: fix test warning
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ee65528547aaec...
Commit: ee65528547aaec2076d7dc5bf61285732dbbb534
Parent: 536f5fa0a310fe863340768ea1a8b062b63e02ef
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Apr 2 12:37:56 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Apr 2 13:38:41 2015 +0200
tests: fix test warning
We cannot print TEST WARNING within test shell script
(since it's running in debug mode and thus always prints it)
Use 'should false' trick let the string printed in this case.
So 'non cluster cases' should now end properly.
---
test/shell/pvmove-all-segtypes.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/shell/pvmove-all-segtypes.sh b/test/shell/pvmove-all-segtypes.sh
index 457054b..ce95059 100644
--- a/test/shell/pvmove-all-segtypes.sh
+++ b/test/shell/pvmove-all-segtypes.sh
@@ -58,7 +58,7 @@ lvremove -ff $vg
if test -e LOCAL_CLVMD ; then
#FIXME these tests currently fail end require cmirrord
-echo "TEST WARNING, FIXME!!! pvmove in clustered VG not fully supported!"
+echo "$(should false)FIXME!!! pvmove in clustered VG not fully supported!"
else
# Testing pvmove of mirror LV
7 years, 12 months
master - tests: deal with kernel and broken lcm
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=536f5fa0a310fe...
Commit: 536f5fa0a310fe863340768ea1a8b062b63e02ef
Parent: 7a6e3838e961fe072bbaafe9f8b073b1c1b0c242
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Apr 2 12:22:59 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Apr 2 13:38:41 2015 +0200
tests: deal with kernel and broken lcm
If the kernel has 'new lcm()' (3.19) it provides wrong
optimal_io_size value for dm device so lvm2 command cannot
create properly aligned devices.
Use 'should' for this case - so test ends with 'TEST WARNING'.
---
test/shell/profiles-thin.sh | 12 ++++++++++--
test/shell/topology-support.sh | 35 ++++++++++++++---------------------
2 files changed, 24 insertions(+), 23 deletions(-)
diff --git a/test/shell/profiles-thin.sh b/test/shell/profiles-thin.sh
index 3519985..e8110d9 100644
--- a/test/shell/profiles-thin.sh
+++ b/test/shell/profiles-thin.sh
@@ -24,7 +24,15 @@ aux prepare_profiles "thin-performance"
# Create scsi debug dev with sector size of 4096B and 1MiB optimal_io_size
aux prepare_scsi_debug_dev $DEV_SIZE sector_size=4096 opt_blks=256 || skip
+EXPECT=1048576
+check sysfs_queue "$(basename $(< SCSI_DEBUG_DEV))" optimal_io_size "$EXPECT"
aux prepare_pvs 1 $DEV_SIZE
+
+# Check we are not running on buggy kernel (broken lcm())
+# If so, turn chunk_size test into 'should'
+MINOR=$(stat -c %T "$dev1")
+check sysfs_queue "dm-$MINOR" optimal_io_size "$EXPECT" || SHOULD=should
+
vgcreate $vg "$dev1"
# By default, "generic" policy is used to
@@ -43,7 +51,7 @@ check lv_field $vg/pool_generic zero "zero"
# under "thin-perforance" profile.
lvcreate --profile thin-performance -L8m -T $vg/pool_performance
check lv_field $vg/pool_performance profile "thin-performance"
-check lv_field $vg/pool_performance chunk_size 1.00m
+$SHOULD check lv_field $vg/pool_performance chunk_size 1.00m
check lv_field $vg/pool_performance zero ""
vgremove -ff $vg
@@ -55,5 +63,5 @@ lvcreate -L8m -T $vg/pool_performance_inherited
# ...the LV does not have the profile attached, but VG does!
check vg_field $vg profile "thin-performance"
check lv_field $vg/pool_performance_inherited profile ""
-check lv_field $vg/pool_performance_inherited chunk_size 1.00m
+$SHOULD check lv_field $vg/pool_performance_inherited chunk_size 1.00m
check lv_field $vg/pool_performance_inherited zero ""
diff --git a/test/shell/topology-support.sh b/test/shell/topology-support.sh
index caebb3d..2e63da8 100644
--- a/test/shell/topology-support.sh
+++ b/test/shell/topology-support.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (C) 2010 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2010-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
@@ -13,20 +13,6 @@
which mkfs.ext3 || skip
-check_logical_block_size() {
- # Verify logical_block_size - requires Linux >= 2.6.31
- SYSFS_LOGICAL_BLOCK_SIZE="/sys/block/$(basename $(< SCSI_DEBUG_DEV))/queue/logical_block_size"
- test -f "$SYSFS_LOGICAL_BLOCK_SIZE" || return 0
- test "$(< $SYSFS_LOGICAL_BLOCK_SIZE)" -eq "$1" # ACTUAL_LOGICAL_BLOCK_SIZE
-}
-
-check_optimal_io_size() {
- # Verify optimal_io_size
- SYSFS_OPTIMAL_IO_SIZE="/sys/block/$(basename $(< SCSI_DEBUG_DEV))/queue/optimal_io_size"
- test -f "$SYSFS_OPTIMAL_IO_SIZE" || return 0
- test "$(< $SYSFS_OPTIMAL_IO_SIZE)" -eq "$1" # ACTUAL_OPTIMAL_IO_SIZE
-}
-
lvdev_() {
echo "$DM_DEV_DIR/$1/$2"
}
@@ -70,7 +56,7 @@ aux cleanup_scsi_debug_dev
LOGICAL_BLOCK_SIZE=512
aux prepare_scsi_debug_dev $DEV_SIZE \
sector_size=$LOGICAL_BLOCK_SIZE physblk_exp=3
-check_logical_block_size $LOGICAL_BLOCK_SIZE
+check sysfs_queue "$(basename $(< SCSI_DEBUG_DEV))" logical_block_size $LOGICAL_BLOCK_SIZE
aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE
get_devs
@@ -87,7 +73,7 @@ aux cleanup_scsi_debug_dev
LOGICAL_BLOCK_SIZE=512
aux prepare_scsi_debug_dev $DEV_SIZE \
sector_size=$LOGICAL_BLOCK_SIZE physblk_exp=3 lowest_aligned=7
-check_logical_block_size $LOGICAL_BLOCK_SIZE
+check sysfs_queue "$(basename $(< SCSI_DEBUG_DEV))" logical_block_size $LOGICAL_BLOCK_SIZE
aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE
vgcreate $vg "${DEVICES[@]}"
@@ -102,7 +88,7 @@ aux cleanup_scsi_debug_dev
LOGICAL_BLOCK_SIZE=4096
aux prepare_scsi_debug_dev $DEV_SIZE \
sector_size=$LOGICAL_BLOCK_SIZE
-check_logical_block_size $LOGICAL_BLOCK_SIZE
+check sysfs_queue "$(basename $(< SCSI_DEBUG_DEV))" logical_block_size $LOGICAL_BLOCK_SIZE
aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE
vgcreate $vg "${DEVICES[@]}"
@@ -118,10 +104,17 @@ aux cleanup_scsi_debug_dev
LOGICAL_BLOCK_SIZE=512
aux prepare_scsi_debug_dev $DEV_SIZE \
sector_size=$LOGICAL_BLOCK_SIZE opt_blks=1536
-check_logical_block_size $LOGICAL_BLOCK_SIZE
-check_optimal_io_size 786432
+
+TDEV="$(basename $(< SCSI_DEBUG_DEV))"
+check sysfs_queue "$TDEV" logical_block_size $LOGICAL_BLOCK_SIZE
+check sysfs_queue "$TDEV" optimal_io_size 786432
aux prepare_pvs 1 $PER_DEV_SIZE
-check pv_field "${DEVICES[@]}" pe_start 768.00k
+
+# Kernel (3.19) could provide wrong results - in this case skip
+# test with incorrect result - lvm2 can't figure out good values.
+MINOR=$(stat -c %T "$dev1")
+check sysfs_queue "dm-$MINOR" optimal_io_size 786432 || SHOULD=should
+$SHOULD check pv_field "${DEVICES[@]}" pe_start 768.00k
aux cleanup_scsi_debug_dev
7 years, 12 months
master - tests: add check sysfs_queue
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7a6e3838e961fe...
Commit: 7a6e3838e961fe072bbaafe9f8b073b1c1b0c242
Parent: 95dbedb301976e176315a95c34be2f3e71a281f2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Apr 2 12:21:55 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Apr 2 13:38:41 2015 +0200
tests: add check sysfs_queue
Add check function for content of /sys/block/$1/queue/$2 == $3
---
test/lib/check.sh | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/test/lib/check.sh b/test/lib/check.sh
index add8fb8..12c5e23 100644
--- a/test/lib/check.sh
+++ b/test/lib/check.sh
@@ -365,6 +365,14 @@ dev_md5sum() {
die "LV $1/$2 has different MD5 check sum!")
}
+sysfs_queue() {
+ # Verify optimal_io_size
+ local P="/sys/block/$1/queue/$2"
+ test -f "$P" || return 0
+ test "$(< $P)" -eq "$3" || \
+ die "$P = $(< $P) differs from expected value $3!"
+}
+
#set -x
unset LVM_VALGRIND
"$@"
7 years, 12 months
master - tests: move exa test to separate file
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=95dbedb301976e...
Commit: 95dbedb301976e176315a95c34be2f3e71a281f2
Parent: 6d1c9a0eb814a7eca55c67cfd89bbf056c65f13e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Mar 27 14:31:08 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Apr 2 13:38:41 2015 +0200
tests: move exa test to separate file
Make it visible the 'exa' test passed on an arch.
---
test/shell/snapshot-usage-exa.sh | 39 ++++++++++++++++++++++++++++++++++++++
test/shell/snapshot-usage.sh | 24 -----------------------
2 files changed, 39 insertions(+), 24 deletions(-)
diff --git a/test/shell/snapshot-usage-exa.sh b/test/shell/snapshot-usage-exa.sh
new file mode 100644
index 0000000..ae5ca6d
--- /dev/null
+++ b/test/shell/snapshot-usage-exa.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+# 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
+
+# Check very large device size (upto 15Exa bytes)
+# this needs 64bit arch
+
+. lib/inittest
+
+aux can_use_16T || skip
+
+aux prepare_pvs 1
+
+# Prepare large enough backend device
+vgcreate -s 4M $vg $(cat DEVICES)
+lvcreate --type snapshot -s -l 100%FREE -n $lv $vg --virtualsize 15P
+aux extend_filter_LVMTEST
+
+# Check usability with largest extent size
+pvcreate "$DM_DEV_DIR/$vg/$lv"
+vgcreate -s 4G $vg1 "$DM_DEV_DIR/$vg/$lv"
+
+lvcreate -an -Zn -l50%FREE -n $lv1 $vg1
+lvcreate -s -l100%FREE -n $lv2 $vg1/$lv1
+check lv_field $vg1/$lv2 size "7.50p"
+lvremove -ff $vg1
+
+lvcreate --type snapshot -V15E -l1 -n $lv1 -s $vg1
+check lv_field $vg1/$lv1 origin_size "15.00e"
+
+vgremove -ff $vg1
+vgremove -ff $vg
diff --git a/test/shell/snapshot-usage.sh b/test/shell/snapshot-usage.sh
index 74f54de..e3db1fb 100644
--- a/test/shell/snapshot-usage.sh
+++ b/test/shell/snapshot-usage.sh
@@ -208,27 +208,3 @@ fsck -n "$DM_DEV_DIR/$vg1/snap"
check lv_field $vg1/snap data_percent "$EXPECT4"
vgremove -ff $vg1
-
-
-# Can't test >= 16T devices on 32bit
-test "$TSIZE" = 15P || exit 0
-
-# synchronize with udev activity
-# FIXME - otherwise sequence of vgremove followed by vgcreate may fail...
-# as there could be still remaing links in /dev
-# Unusure if 'vgcreate' should do this type of detection in udev mode.
-aux udev_wait
-
-# Check usability with largest extent size
-pvcreate "$DM_DEV_DIR/$vg/$lv"
-vgcreate -s 4G $vg1 "$DM_DEV_DIR/$vg/$lv"
-
-lvcreate -an -Zn -l50%FREE -n $lv1 $vg1
-lvcreate -s -l100%FREE -n $lv2 $vg1/$lv1
-check lv_field $vg1/$lv2 size "7.50p"
-lvremove -ff $vg1
-
-lvcreate --type snapshot -V15E -l1 -n $lv1 -s $vg1
-check lv_field $vg1/$lv1 origin_size "15.00e"
-
-vgremove -ff $vg1
7 years, 12 months
master - tests: more duplicate testing
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6d1c9a0eb814a7...
Commit: 6d1c9a0eb814a7eca55c67cfd89bbf056c65f13e
Parent: 53ef14fca0e85fef0df41665a64d21166d8b684d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Apr 2 12:42:56 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Apr 2 13:38:41 2015 +0200
tests: more duplicate testing
---
test/shell/pv-duplicate.sh | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/test/shell/pv-duplicate.sh b/test/shell/pv-duplicate.sh
index ede9600..9b218e6 100644
--- a/test/shell/pv-duplicate.sh
+++ b/test/shell/pv-duplicate.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (C) 2011 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2011-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
@@ -15,6 +15,10 @@
aux prepare_devs 3
+pvcreate "$dev1"
+
+dd if="$dev1" of=backup_dev1 bs=256K count=1
+
vgcreate --metadatasize 128k $vg1 "$dev1"
# copy mda
@@ -22,4 +26,12 @@ dd if="$dev1" of="$dev2" bs=256K count=1
dd if="$dev1" of="$dev3" bs=256K count=1
pvs "$dev3" -o pv_uuid
+
vgs $vg1
+
+dd if=backup_dev1 of="$dev3" bs=256K count=1
+pvs
+#-vvvv
+# TODO: Surely needs more inspecition about correct
+# behavior for such case
+# vgs $vg1
7 years, 12 months
master - debug: log scanned value
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=53ef14fca0e85f...
Commit: 53ef14fca0e85fef0df41665a64d21166d8b684d
Parent: e28e22b9e1e4f7243608aa24ddf43ec63afd1751
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Mar 27 13:43:24 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Apr 2 13:38:41 2015 +0200
debug: log scanned value
Fix verbose print of scanned value for topology attribute.
Result is set afterwards in sectors.
---
lib/device/dev-type.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index 882c08d..d3407d1 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -799,7 +799,7 @@ static unsigned long _dev_topology_attribute(struct dev_types *dt,
}
log_very_verbose("Device %s: %s is %lu%s.",
- dev_name(dev), attribute, result, default_value ? "" : " bytes");
+ dev_name(dev), attribute, value, default_value ? "" : " bytes");
result = value >> SECTOR_SHIFT;
7 years, 12 months
master - lvmcache: skip drop when vg_write lock is not held
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e28e22b9e1e4f7...
Commit: e28e22b9e1e4f7243608aa24ddf43ec63afd1751
Parent: f199aeb9eaa1821811f98308565ccc54ab52edf8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Apr 2 12:42:18 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Apr 2 13:38:32 2015 +0200
lvmcache: skip drop when vg_write lock is not held
Commit 80f4b4b8039a88dfa2648a9b5bb5e16f41b81f87
introduced undesirable side-effects for lvm2app user
which happens to be our own python binding.
It appear obtaing pvs list keeps global lock.
So restricting this to VG_GLOBAL READ locks and skip
the drop skip if WRITE lock is held.
---
WHATS_NEW | 1 +
lib/cache/lvmcache.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 0a5d797..79136f9 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.119 -
==================================
+ Don't skip invalidation of cached orphans if vg write lck is held (2.02.118).
Log relevant PV tags when using cling allocation.
Add str_list_add_list() to combine two lists.
Fix LV processing with selection to always do the selection on initial state.
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 2b4e2c6..27b4292 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -287,7 +287,7 @@ void lvmcache_commit_metadata(const char *vgname)
void lvmcache_drop_metadata(const char *vgname, int drop_precommitted)
{
- if (lvmcache_vgname_is_locked(VG_GLOBAL))
+ if (lvmcache_vgname_is_locked(VG_GLOBAL) && !vg_write_lock_held())
return;
/* For VG_ORPHANS, we need to invalidate all labels on orphan PVs. */
7 years, 12 months
master - polldaemon: alter few lines related to interval
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f199aeb9eaa182...
Commit: f199aeb9eaa1821811f98308565ccc54ab52edf8
Parent: 7abb7894e4143021b003aaa906aa1945dcb59f06
Author: Ondrej Kozina <okozina(a)redhat.com>
AuthorDate: Tue Mar 17 18:44:25 2015 +0100
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Wed Apr 1 20:41:52 2015 +0200
polldaemon: alter few lines related to interval
we do not allow 0 interval for pvmove command issued
without parameters with classical polldaemon. It would
query the kernel too often with possibly many pvmoves
in-progress.
---
tools/polldaemon.c | 13 ++++---------
1 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/tools/polldaemon.c b/tools/polldaemon.c
index 466cfc6..6cdcbbb 100644
--- a/tools/polldaemon.c
+++ b/tools/polldaemon.c
@@ -282,14 +282,6 @@ static int _poll_daemon(struct cmd_context *cmd, const char *name,
int daemon_mode = 0;
int ret = ECMD_PROCESSED;
- if (!parms->interval) {
- parms->progress_display = 0;
-
- /* FIXME Disabled multiple-copy wait_event */
- if (!name)
- parms->interval = find_config_tree_int(cmd, activation_polling_interval_CFG, NULL);
- }
-
if (parms->background) {
daemon_mode = become_daemon(cmd, 0);
if (daemon_mode == 0)
@@ -309,6 +301,8 @@ static int _poll_daemon(struct cmd_context *cmd, const char *name,
ret = ECMD_FAILED;
}
} else {
+ if (!parms->interval)
+ parms->interval = find_config_tree_int(cmd, activation_polling_interval_CFG, NULL);
if (!(handle = init_processing_handle(cmd))) {
log_error("Failed to initialize processing handle.");
ret = ECMD_FAILED;
@@ -350,7 +344,6 @@ static int _daemon_parms_init(struct cmd_context *cmd, struct daemon_parms *parm
parms->interval = arg_uint_value(cmd, interval_ARG,
find_config_tree_int(cmd, activation_polling_interval_CFG, NULL));
parms->wait_before_testing = (interval_sign == SIGN_PLUS);
- parms->progress_display = 1;
parms->progress_title = progress_title;
parms->lv_type = lv_type;
parms->poll_fns = poll_fns;
@@ -360,6 +353,8 @@ static int _daemon_parms_init(struct cmd_context *cmd, struct daemon_parms *parm
(parms->wait_before_testing ? "after" : "before"),
parms->interval);
+ parms->progress_display = parms->interval ? 1 : 0;
+
return 1;
}
7 years, 12 months
master - polldaemon: separate daemon_parms initialisation
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7abb7894e41430...
Commit: 7abb7894e4143021b003aaa906aa1945dcb59f06
Parent: 3929b00466c3c415a8e82e8346d79ec6c5c0eb76
Author: Ondrej Kozina <okozina(a)redhat.com>
AuthorDate: Tue Mar 17 18:40:43 2015 +0100
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Wed Apr 1 20:41:39 2015 +0200
polldaemon: separate daemon_parms initialisation
---
tools/polldaemon.c | 78 +++++++++++++++++++++++++++++----------------------
1 files changed, 44 insertions(+), 34 deletions(-)
diff --git a/tools/polldaemon.c b/tools/polldaemon.c
index dd53055..466cfc6 100644
--- a/tools/polldaemon.c
+++ b/tools/polldaemon.c
@@ -276,50 +276,26 @@ static void _poll_for_all_vgs(struct cmd_context *cmd,
* if it was requested.
*/
static int _poll_daemon(struct cmd_context *cmd, const char *name,
- const char *uuid, unsigned background, uint64_t lv_type,
- struct poll_functions *poll_fns,
- const char *progress_title)
+ const char *uuid, struct daemon_parms *parms)
{
struct processing_handle *handle = NULL;
- struct daemon_parms parms;
int daemon_mode = 0;
int ret = ECMD_PROCESSED;
- sign_t interval_sign;
- parms.aborting = arg_is_set(cmd, abort_ARG);
- parms.background = background;
- interval_sign = arg_sign_value(cmd, interval_ARG, SIGN_NONE);
- if (interval_sign == SIGN_MINUS) {
- log_error("Argument to --interval cannot be negative");
- return EINVALID_CMD_LINE;
- }
- parms.interval = arg_uint_value(cmd, interval_ARG,
- find_config_tree_int(cmd, activation_polling_interval_CFG, NULL));
- parms.wait_before_testing = (interval_sign == SIGN_PLUS);
- parms.progress_display = 1;
- parms.progress_title = progress_title;
- parms.lv_type = lv_type;
- parms.poll_fns = poll_fns;
-
- if (parms.interval && !parms.aborting)
- log_verbose("Checking progress %s waiting every %u seconds",
- (parms.wait_before_testing ? "after" : "before"),
- parms.interval);
-
- if (!parms.interval) {
- parms.progress_display = 0;
+ if (!parms->interval) {
+ parms->progress_display = 0;
/* FIXME Disabled multiple-copy wait_event */
if (!name)
- parms.interval = find_config_tree_int(cmd, activation_polling_interval_CFG, NULL);
+ parms->interval = find_config_tree_int(cmd, activation_polling_interval_CFG, NULL);
}
- if (parms.background) {
+ if (parms->background) {
daemon_mode = become_daemon(cmd, 0);
if (daemon_mode == 0)
return ECMD_PROCESSED; /* Parent */
else if (daemon_mode == 1)
- parms.progress_display = 0; /* Child */
+ parms->progress_display = 0; /* Child */
/* FIXME Use wait_event (i.e. interval = 0) and */
/* fork one daemon per copy? */
}
@@ -328,7 +304,7 @@ static int _poll_daemon(struct cmd_context *cmd, const char *name,
* Process one specific task or all incomplete tasks?
*/
if (name) {
- if (!_wait_for_single_lv(cmd, name, uuid, &parms)) {
+ if (!_wait_for_single_lv(cmd, name, uuid, parms)) {
stack;
ret = ECMD_FAILED;
}
@@ -337,12 +313,12 @@ static int _poll_daemon(struct cmd_context *cmd, const char *name,
log_error("Failed to initialize processing handle.");
ret = ECMD_FAILED;
} else {
- handle->custom_handle = &parms;
+ handle->custom_handle = parms;
_poll_for_all_vgs(cmd, handle);
}
}
- if (parms.background && daemon_mode == 1) {
+ if (parms->background && daemon_mode == 1) {
destroy_processing_handle(cmd, handle);
/*
* child was successfully forked:
@@ -358,10 +334,44 @@ static int _poll_daemon(struct cmd_context *cmd, const char *name,
return ret;
}
+static int _daemon_parms_init(struct cmd_context *cmd, struct daemon_parms *parms,
+ unsigned background, struct poll_functions *poll_fns,
+ const char *progress_title, uint64_t lv_type)
+{
+ sign_t interval_sign;
+
+ parms->aborting = arg_is_set(cmd, abort_ARG);
+ parms->background = background;
+ interval_sign = arg_sign_value(cmd, interval_ARG, SIGN_NONE);
+ if (interval_sign == SIGN_MINUS) {
+ log_error("Argument to --interval cannot be negative.");
+ return 0;
+ }
+ parms->interval = arg_uint_value(cmd, interval_ARG,
+ find_config_tree_int(cmd, activation_polling_interval_CFG, NULL));
+ parms->wait_before_testing = (interval_sign == SIGN_PLUS);
+ parms->progress_display = 1;
+ parms->progress_title = progress_title;
+ parms->lv_type = lv_type;
+ parms->poll_fns = poll_fns;
+
+ if (parms->interval && !parms->aborting)
+ log_verbose("Checking progress %s waiting every %u seconds.",
+ (parms->wait_before_testing ? "after" : "before"),
+ parms->interval);
+
+ return 1;
+}
+
int poll_daemon(struct cmd_context *cmd, const char *name, const char *uuid,
unsigned background,
uint64_t lv_type, struct poll_functions *poll_fns,
const char *progress_title)
{
- return _poll_daemon(cmd, name, uuid, background, lv_type, poll_fns, progress_title);
+ struct daemon_parms parms;
+
+ if (!_daemon_parms_init(cmd, &parms, background, poll_fns, progress_title, lv_type))
+ return_EINVALID_CMD_LINE;
+
+ return _poll_daemon(cmd, name, uuid, &parms);
}
7 years, 12 months