master - cleanup: reformat code of dmeventd
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=01174b8b8b1402...
Commit: 01174b8b8b140280976182c143e764d525c54939
Parent: 88288ab43322c94750c25db249451be769931984
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 21 21:20:01 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jun 25 13:47:39 2013 +0200
cleanup: reformat code of dmeventd
---
daemons/dmeventd/dmeventd.c | 31 +++++++++++++++----------------
1 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index 50bd1df..e9924f6 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -214,7 +214,7 @@ static pthread_mutex_t _timeout_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t _timeout_cond = PTHREAD_COND_INITIALIZER;
/* Allocate/free the status structure for a monitoring thread. */
-static struct thread_status *_alloc_thread_status(struct message_data *data,
+static struct thread_status *_alloc_thread_status(const struct message_data *data,
struct dso_data *dso_data)
{
struct thread_status *ret = (typeof(ret)) dm_zalloc(sizeof(*ret));
@@ -330,8 +330,8 @@ static void _free_message(struct message_data *message_data)
static int _parse_message(struct message_data *message_data)
{
int ret = 0;
- char *p = message_data->msg->data;
struct dm_event_daemon_message *msg = message_data->msg;
+ char *p = msg->data;
if (!msg->data)
return 0;
@@ -358,8 +358,9 @@ static int _parse_message(struct message_data *message_data)
dm_free(msg->data);
msg->data = NULL;
msg->size = 0;
+
return ret;
-};
+}
/* Global mutex to lock access to lists et al. See _global_mutex
above. */
@@ -426,8 +427,8 @@ static struct thread_status *_lookup_thread_status(struct message_data *data)
struct thread_status *thread;
dm_list_iterate_items(thread, &_thread_registry)
- if (!strcmp(data->device_uuid, thread->device.uuid))
- return thread;
+ if (!strcmp(data->device_uuid, thread->device.uuid))
+ return thread;
return NULL;
}
@@ -503,6 +504,7 @@ static void _exit_timeout(void *unused __attribute__((unused)))
/* Wake up monitor threads every so often. */
static void *_timeout_thread(void *unused __attribute__((unused)))
{
+ struct thread_status *thread;
struct timespec timeout;
time_t curr_time;
@@ -511,8 +513,6 @@ static void *_timeout_thread(void *unused __attribute__((unused)))
pthread_mutex_lock(&_timeout_mutex);
while (!dm_list_empty(&_timeout_registry)) {
- struct thread_status *thread;
-
timeout.tv_sec = 0;
curr_time = time(NULL);
@@ -552,7 +552,7 @@ static int _register_for_timeout(struct thread_status *thread)
if (!_timeout_running) {
pthread_t timeout_id;
- if (!(ret = -_pthread_create_smallstack(&timeout_id, _timeout_thread, NULL)))
+ if (!(ret = _pthread_create_smallstack(&timeout_id, _timeout_thread, NULL)))
_timeout_running = 1;
}
@@ -986,11 +986,9 @@ static int _register_for_event(struct message_data *message_data)
events. However, if timeout thread cannot be started, it
usually means we are so starved on resources that we are
almost as good as dead already... */
- if (thread_new->events & DM_EVENT_TIMEOUT) {
- ret = -_register_for_timeout(thread_new);
- if (ret)
- goto outth;
- }
+ if ((thread_new->events & DM_EVENT_TIMEOUT) &&
+ (ret = -_register_for_timeout(thread_new)))
+ goto out;
if (!(thread = _lookup_thread_status(message_data))) {
_unlock_mutex();
@@ -1008,8 +1006,9 @@ static int _register_for_event(struct message_data *message_data)
_do_unregister_device(thread);
_free_thread_status(thread);
goto out;
- } else
- LINK_THREAD(thread);
+ }
+
+ LINK_THREAD(thread);
}
/* Or event # into events bitfield. */
@@ -1452,7 +1451,7 @@ static int _do_process_request(struct dm_event_daemon_message *msg)
if (answer) {
msg->size = dm_asprintf(&(msg->data), "%s %s %d", answer,
msg->cmd == DM_EVENT_CMD_DIE ? "DYING" : "HELLO",
- DM_EVENT_PROTOCOL_VERSION);
+ DM_EVENT_PROTOCOL_VERSION);
dm_free(answer);
} else
msg->size = 0;
10 years, 9 months
master - cleanup: Remove message used for development
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=88288ab43322c9...
Commit: 88288ab43322c94750c25db249451be769931984
Parent: c9e8e7c235a14d8ada78b88d467f659b8e72554b
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Mon Jun 24 06:16:39 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Mon Jun 24 06:16:39 2013 -0500
cleanup: Remove message used for development
Failed to clean out all messages used during development.
---
tools/lvcreate.c | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 05f3b13..972b36a 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -591,9 +591,6 @@ static int _read_raid_params(struct lvcreate_params *lp,
/* Rates are recorded in kiB/sec/disk, not sectors/sec/disk */
lp->min_recovery_rate /= 2;
lp->max_recovery_rate /= 2;
- log_error("min = %u, max = %u",
- lp->min_recovery_rate,
- lp->max_recovery_rate);
if (lp->max_recovery_rate &&
(lp->max_recovery_rate < lp->min_recovery_rate)) {
10 years, 9 months
master - dev-type: dev_get_primary_dev: fix ret value if dev is a partition and we used sysfs
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c9e8e7c235a14d...
Commit: c9e8e7c235a14d8ada78b88d467f659b8e72554b
Parent: bdcfe8c6de26472562a8f907081e0eb94e038488
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Sun Jun 23 11:14:34 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Sun Jun 23 12:39:35 2013 +0200
dev-type: dev_get_primary_dev: fix ret value if dev is a partition and we used sysfs
---
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 a8340b0..642ee27 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -434,7 +434,7 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
goto out;
}
*result = MKDEV((dev_t)major, minor);
- ret = 1;
+ ret = 2;
out:
if (fp && fclose(fp))
log_sys_error("fclose", path);
10 years, 9 months
master - TEST: Test RAID syncaction, writemostly, & refresh under snapshots
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bdcfe8c6de2647...
Commit: bdcfe8c6de26472562a8f907081e0eb94e038488
Parent: 8215846aa52b727c3c639d9b354d611319be26c6
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Thu Jun 20 11:48:15 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Thu Jun 20 11:48:15 2013 -0500
TEST: Test RAID syncaction, writemostly, & refresh under snapshots
Test the different RAID lvchange scenarios under snapshot as well.
This patch also updates calculations for where to write to an
underlying PV when testing various syncactions.
---
test/lib/check.sh | 8 +++--
test/shell/lvchange-raid.sh | 68 ++++++++++++++++++++++++++++++++++---------
2 files changed, 59 insertions(+), 17 deletions(-)
diff --git a/test/lib/check.sh b/test/lib/check.sh
index 6cb33ac..8db0c65 100644
--- a/test/lib/check.sh
+++ b/test/lib/check.sh
@@ -158,6 +158,7 @@ in_sync() {
local b
local idx
local type
+ local snap=""
local lvm_name="$1/$2"
local dm_name=$(echo $lvm_name | sed s:-:--: | sed s:/:-:)
@@ -167,6 +168,7 @@ in_sync() {
if ! a=(`dmsetup status ${dm_name}-real`); then
die "Unable to get sync status of $1"
fi
+ snap=": under snapshot"
fi
if [ ${a[2]} = "raid" ]; then
@@ -184,15 +186,15 @@ in_sync() {
b=( $(echo ${a[$idx]} | sed s:/:' ':) )
if [ ${b[0]} != ${b[1]} ]; then
- echo "$lvm_name ($type) is not in-sync"
+ echo "$lvm_name ($type$snap) is not in-sync"
return 1
fi
if [[ ${a[$(($idx - 1))]} =~ a ]]; then
- die "$lvm_name in-sync, but 'a' characters in health status"
+ die "$lvm_name ($type$snap) in-sync, but 'a' characters in health status"
fi
- echo "$lvm_name ($type) is in-sync"
+ echo "$lvm_name ($type$snap) is in-sync"
return 0
}
diff --git a/test/shell/lvchange-raid.sh b/test/shell/lvchange-raid.sh
index da9c76e..1dbd42a 100644
--- a/test/shell/lvchange-raid.sh
+++ b/test/shell/lvchange-raid.sh
@@ -9,18 +9,20 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-# This test ensures that 'lvchange --refresh vg/raid_lv' properly restores
-# a transiently failed device in RAID LVs.
-
. lib/test
# dm-raid v1.4.1+ contains RAID10 support
aux target_at_least dm-raid 1 4 1 || skip
-aux prepare_vg 5
+aux prepare_vg 6
# run_writemostly_check <VG> <LV>
run_writemostly_check() {
+ local d0
+ local d1
+
+ printf "#\n#\n#\n# %s/%s (%s): run_writemostly_check\n#\n#\n#\n" \
+ $1 $2 `lvs --noheadings -o segtype $1/$2`
d0=`lvs -a --noheadings -o devices $1/${2}_rimage_0 | sed s/\(.\)//`
d0=$(sed s/^[[:space:]]*// <<< "$d0")
d1=`lvs -a --noheadings -o devices $1/${2}_rimage_1 | sed s/\(.\)//`
@@ -115,26 +117,40 @@ run_syncaction_check() {
local device
local seek
local size
+ local tmp
+ printf "#\n#\n#\n# %s/%s (%s): run_syncaction_check\n#\n#\n#\n" \
+ $1 $2 `lvs --noheadings -o segtype $1/$2`
aux wait_for_sync $1 $2
device=`lvs -a --noheadings -o devices $1/${2}_rimage_1 | sed s/\(.\)//`
device=$(sed s/^[[:space:]]*// <<< "$device")
- size=`lvs -a --noheadings -o size --units 1k $1/$2 | sed s/\.00k//`
+
+ size=`lvs -a --noheadings -o size --units 1k $1/${2}_rimage_1 | sed s/\.00k//`
size=$(sed s/^[[:space:]]*// <<< "$size")
size=$(($size / 2))
- seek=`pvs --noheadings -o mda_size --units 1k $device | sed s/\.00k//`
- seek=$(sed s/^[[:space:]]*// <<< "$seek")
- seek=$(($size + $seek))
+
+ tmp=`pvs --noheadings -o mda_size --units 1k $device | sed s/\.00k//`
+ tmp=$(sed s/^[[:space:]]*// <<< "$tmp")
+ seek=$tmp # Jump over MDA
+
+ tmp=`lvs -a --noheadings -o size --units 1k $1/${2}_rmeta_1 | sed s/\.00k//`
+ tmp=$(sed s/^[[:space:]]*// <<< "$tmp")
+ seek=$(($seek + $tmp)) # Jump over RAID metadata image
+
+ seek=$(($seek + $size)) # Jump halfway through the RAID image
# Check all is normal
if ! lvs --noheadings -o lv_attr $1/$2 | grep '.*-$' ||
[ `lvs --noheadings -o mismatches $1/$2` != 0 ]; then
- #
+
# I think this is a kernel bug. It happens randomly after
# a RAID device creation. I think the mismatch count
# should not be set unless a check or repair is run.
#
+ # Neil Brown disagrees that it is a bug. Says mismatch
+ # count can be anything until a 'check' or 'repair' is
+ # run.
echo "Strange... RAID has mismatch count after creation."
# Run "check" should turn up clean
@@ -179,6 +195,9 @@ run_syncaction_check() {
run_refresh_check() {
local size
+ printf "#\n#\n#\n# %s/%s (%s): run_refresh_check\n#\n#\n#\n" \
+ $1 $2 `lvs --noheadings -o segtype $1/$2`
+
aux wait_for_sync $1 $2
size=`lvs -a --noheadings -o size --units 1k $1/$2 | sed s/\.00k//`
@@ -197,6 +216,8 @@ run_refresh_check() {
lvs --noheadings -o lv_attr $1/$2 | grep '.*r$'
lvchange --refresh $1/$2
+ aux wait_for_sync $1 $2
+ lvs --noheadings -o lv_attr $1/$2 | grep '.*-$'
# Writing random data above should mean that the devices
# were out-of-sync. The refresh should have taken care
@@ -207,7 +228,9 @@ run_refresh_check() {
lvs --noheadings -o lv_attr $1/$2 | grep '.*-$'
}
+# run_checks <VG> <LV> [snapshot_dev]
run_checks() {
+ # Without snapshots
if aux target_at_least dm-raid 1 1 0; then
run_writemostly_check $1 $2
fi
@@ -219,6 +242,23 @@ run_checks() {
if aux target_at_least dm-raid 1 5 1; then
run_refresh_check $1 $2
fi
+
+ # With snapshots
+ if [ ! -z $3 ]; then
+ lvcreate -s $1/$2 -l 4 -n snap $3
+ if aux target_at_least dm-raid 1 1 0; then
+ run_writemostly_check $1 $2
+ fi
+
+ if aux target_at_least dm-raid 1 5 0; then
+ run_syncaction_check $1 $2
+ fi
+
+ if aux target_at_least dm-raid 1 5 1; then
+ run_refresh_check $1 $2
+ fi
+ lvremove -ff $1/snap
+ fi
}
########################################################
@@ -226,23 +266,23 @@ run_checks() {
########################################################
lvcreate --type raid1 -m 1 -l 2 -n $lv1 $vg "$dev1" "$dev2"
-run_checks $vg $lv1
+run_checks $vg $lv1 "$dev3"
lvremove -ff $vg
lvcreate --type raid4 -i 2 -l 4 -n $lv1 $vg "$dev1" "$dev2" "$dev3" "$dev4"
-run_checks $vg $lv1
+run_checks $vg $lv1 "$dev5"
lvremove -ff $vg
lvcreate --type raid5 -i 2 -l 4 -n $lv1 $vg "$dev1" "$dev2" "$dev3" "$dev4"
-run_checks $vg $lv1
+run_checks $vg $lv1 "$dev5"
lvremove -ff $vg
lvcreate --type raid6 -i 3 -l 6 -n $lv1 $vg \
"$dev1" "$dev2" "$dev3" "$dev4" "$dev5"
-run_checks $vg $lv1
+run_checks $vg $lv1 "$dev6"
lvremove -ff $vg
lvcreate --type raid10 -m 1 -i 2 -l 4 -n $lv1 $vg \
"$dev1" "$dev2" "$dev3" "$dev4"
-run_checks $vg $lv1
+run_checks $vg $lv1 "$dev5"
lvremove -ff $vg
10 years, 9 months
master - Clean-up: WHATS_NEW
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8215846aa52b72...
Commit: 8215846aa52b727c3c639d9b354d611319be26c6
Parent: a6d13308ec0baca9a5bd48f80d02e5c71a54287f
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Wed Jun 19 19:55:34 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Wed Jun 19 19:55:34 2013 -0500
Clean-up: WHATS_NEW
Choosing between two entries and forgot to remove one.
---
WHATS_NEW | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index d527854..c24f576 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,7 +1,6 @@
Version 2.02.99 -
===================================
Use mirror_segtype_default if type not specified for linear->mirror upconvert.
- Make upconvert from linear use mirror_segtype_default to determine segtype.
Fix use of too big chunks of memory when communication with lvmetad.
Fix vgcfgrestore crash when specified incorrect vg name.
Refine lvm.conf and man page documentation for autoactivation feature.
10 years, 9 months
master - RAID/MIRROR: Honor mirror_segtype_default when upconverting linear LVs
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a6d13308ec0bac...
Commit: a6d13308ec0baca9a5bd48f80d02e5c71a54287f
Parent: 4d2aa6a7aa6f8208bc27b7f0579e7d85562af2d0
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Wed Jun 19 17:50:10 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Wed Jun 19 17:50:10 2013 -0500
RAID/MIRROR: Honor mirror_segtype_default when upconverting linear LVs
If the user would upconvert a linear LV to a mirror without specifying
the segment type ("--type mirror" vs "--type raid1"), the "mirror"
segment type would be chosen without consulting the 'default_mirror_segtype'
setting in lvm.conf. This is now used as the basis for determining
which should be used if left unspecified.
---
WHATS_NEW | 2 ++
test/shell/lvconvert-mirror.sh | 12 ++++++++++--
test/shell/lvconvert-raid.sh | 18 ++++++++++++++++++
tools/lvconvert.c | 2 +-
4 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 19bcf82..d527854 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,7 @@
Version 2.02.99 -
===================================
+ Use mirror_segtype_default if type not specified for linear->mirror upconvert.
+ Make upconvert from linear use mirror_segtype_default to determine segtype.
Fix use of too big chunks of memory when communication with lvmetad.
Fix vgcfgrestore crash when specified incorrect vg name.
Refine lvm.conf and man page documentation for autoactivation feature.
diff --git a/test/shell/lvconvert-mirror.sh b/test/shell/lvconvert-mirror.sh
index 420241a..e3c01fa 100644
--- a/test/shell/lvconvert-mirror.sh
+++ b/test/shell/lvconvert-mirror.sh
@@ -16,9 +16,17 @@ aux prepare_pvs 5 10
DEVRANGE="0-32"
vgcreate -s 32k $vg $(cat DEVICES)
-# convert from linear to 2-way mirror
+# convert from linear to 2-way mirror ("mirror" default type)
lvcreate -aey -l2 -n $lv1 $vg "$dev1"
-lvconvert -i1 -m+1 $vg/$lv1 "$dev2" "$dev3:0-1"
+lvconvert -i1 -m+1 $vg/$lv1 "$dev2" "$dev3:0-1" \
+ --config 'global { mirror_segtype_default = "mirror" }'
+check mirror $vg $lv1 "$dev3"
+lvremove -ff $vg
+
+# convert from linear to 2-way mirror (override "raid1" default type)
+lvcreate -aey -l2 -n $lv1 $vg "$dev1"
+lvconvert --type mirror -i1 -m+1 $vg/$lv1 "$dev2" "$dev3:0-1" \
+ --config 'global { mirror_segtype_default = "raid1" }'
check mirror $vg $lv1 "$dev3"
lvremove -ff $vg
diff --git a/test/shell/lvconvert-raid.sh b/test/shell/lvconvert-raid.sh
index 61345da..8693cf3 100644
--- a/test/shell/lvconvert-raid.sh
+++ b/test/shell/lvconvert-raid.sh
@@ -136,6 +136,24 @@ lvconvert --merge $vg/${lv1}_rimage_2
lvremove -ff $vg
###########################################
+# Linear to RAID1 conversion ("raid1" default segtype)
+###########################################
+lvcreate -l 2 -n $lv1 $vg
+lvconvert -m 1 $vg/$lv1 \
+ --config 'global { mirror_segtype_default = "raid1" }'
+lvs --noheadings -o attr $vg/$lv1 | grep '^r*'
+lvremove -ff $vg
+
+###########################################
+# Linear to RAID1 conversion (override "mirror" default segtype)
+###########################################
+lvcreate -l 2 -n $lv1 $vg
+lvconvert --type raid1 -m 1 $vg/$lv1 \
+ --config 'global { mirror_segtype_default = "mirror" }'
+lvs --noheadings -o attr $vg/$lv1 | grep '^r*'
+lvremove -ff $vg
+
+###########################################
# Mirror to RAID1 conversion
###########################################
for i in 1 2 3 ; do
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 46f996a..be6b55f 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -490,7 +490,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
return 0;
}
- lp->segtype = get_segtype_from_string(cmd, arg_str_value(cmd, type_ARG, "mirror"));
+ lp->segtype = get_segtype_from_string(cmd, arg_str_value(cmd, type_ARG, find_config_tree_str(cmd, global_mirror_segtype_default_CFG)));
if (!lp->segtype)
return_0;
}
10 years, 9 months
master - cleanup: use parsed yes_no_arg
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4d2aa6a7aa6f82...
Commit: 4d2aa6a7aa6f8208bc27b7f0579e7d85562af2d0
Parent: f990b7298d46280d50e2813ea92212a7e595e567
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jun 17 19:55:02 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jun 18 22:13:42 2013 +0200
cleanup: use parsed yes_no_arg
Do not parse yes_no_arg inside tools code and use already
available result as uint.
---
tools/lvchange.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 6e5fd25..d645da6 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -596,7 +596,7 @@ static int lvchange_persistent(struct cmd_context *cmd,
int active = 0;
int32_t major, minor;
- if (!strcmp(arg_str_value(cmd, persistent_ARG, "n"), "n")) {
+ if (!arg_uint_value(cmd, persistent_ARG, 0)) {
if (!(lv->status & FIXED_MINOR)) {
log_error("Minor number is already not persistent "
"for \"%s\"", lv->name);
10 years, 9 months
master - cleanup: return lv_is_ as 1 or 0
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f990b7298d4628...
Commit: f990b7298d46280d50e2813ea92212a7e595e567
Parent: c5957ee2ffc2cfce1f1304349e2304bd489c5903
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jun 17 19:46:22 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jun 18 22:13:42 2013 +0200
cleanup: return lv_is_ as 1 or 0
Do not return 64bit values - return just plain int 0 or 1
---
lib/metadata/metadata-exported.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 5fb5b6c..10aea9e 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -150,9 +150,9 @@
#define lv_is_thin_type(lv) ((lv)->status & (THIN_POOL | THIN_VOLUME | THIN_POOL_DATA | THIN_POOL_METADATA) ? 1 : 0)
#define lv_is_mirror_type(lv) ((lv)->status & (MIRROR_LOG | MIRROR_IMAGE | MIRRORED | PVMOVE) ? 1 : 0)
-#define lv_is_raid_type(lv) ((lv)->status & (RAID | RAID_IMAGE | RAID_META))
+#define lv_is_raid_type(lv) (((lv)->status & (RAID | RAID_IMAGE | RAID_META)) ? 1 : 0)
-#define lv_is_virtual(lv) ((lv)->status & VIRTUAL)
+#define lv_is_virtual(lv) (((lv)->status & VIRTUAL) ? 1 : 0)
/* Ordered list - see lv_manip.c */
typedef enum {
10 years, 9 months
master - cleanup: easier to read loop code
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c5957ee2ffc2cf...
Commit: c5957ee2ffc2cfce1f1304349e2304bd489c5903
Parent: 155841c349c58e2332802d85f3c39b8933cdd761
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jun 18 11:59:22 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jun 18 22:13:41 2013 +0200
cleanup: easier to read loop code
buffer_write now accepts const pointer
Simplify loops and drop goto when not needed.
---
libdaemon/client/daemon-io.c | 65 ++++++++++++++++++------------------------
libdaemon/client/daemon-io.h | 2 +-
2 files changed, 29 insertions(+), 38 deletions(-)
diff --git a/libdaemon/client/daemon-io.c b/libdaemon/client/daemon-io.c
index 6ede8a8..906f375 100644
--- a/libdaemon/client/daemon-io.c
+++ b/libdaemon/client/daemon-io.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2012 Red Hat, Inc.
+ * Copyright (C) 2011-2013 Red Hat, Inc.
*
* This file is part of LVM2.
*
@@ -29,34 +29,32 @@
* See also write_buffer about blocking (read_buffer has identical behaviour).
*/
int buffer_read(int fd, struct buffer *buffer) {
+ int result;
+
if (!buffer_realloc(buffer, 32)) /* ensure we have some space */
- goto fail;
+ return 0;
while (1) {
- int result = read(fd, buffer->mem + buffer->used, buffer->allocated - buffer->used);
+ result = read(fd, buffer->mem + buffer->used, buffer->allocated - buffer->used);
if (result > 0) {
buffer->used += result;
if (!strncmp((buffer->mem) + buffer->used - 4, "\n##\n", 4)) {
- *(buffer->mem + buffer->used - 4) = 0;
buffer->used -= 4;
+ buffer->mem[buffer->used] = 0;
break; /* success, we have the full message now */
}
- if (buffer->allocated - buffer->used < 32)
- if (!buffer_realloc(buffer, 1024))
- goto fail;
- continue;
- }
- if (result == 0) {
+ if ((buffer->allocated - buffer->used < 32) &&
+ !buffer_realloc(buffer, 1024))
+ return 0;
+ } else if (result == 0) {
errno = ECONNRESET;
- goto fail; /* we should never encounter EOF here */
- }
- if (result < 0 && errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR)
- goto fail;
+ return 0; /* we should never encounter EOF here */
+ } else if (result < 0 && errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR)
+ return 0;
/* TODO call select here if we encountered EAGAIN/EWOULDBLOCK/EINTR */
}
+
return 1;
-fail:
- return 0;
}
/*
@@ -65,28 +63,21 @@ fail:
*
* TODO use select on EWOULDBLOCK/EAGAIN/EINTR to avoid useless spinning
*/
-int buffer_write(int fd, struct buffer *buffer) {
- struct buffer terminate = { .mem = (char *) "\n##\n", .used = 4 };
- int done = 0;
- int written = 0;
- struct buffer *use = buffer;
-write:
- while (1) {
- int result = write(fd, use->mem + written, use->used - written);
- if (result > 0)
- written += result;
- if (result < 0 && errno != EWOULDBLOCK && errno != EAGAIN && errno != EINTR)
- return 0; /* too bad */
- if (written == use->used) {
- if (done)
- return 1;
- else
- break; /* done */
+int buffer_write(int fd, const struct buffer *buffer) {
+ static const struct buffer _terminate = { .mem = (char *) "\n##\n", .used = 4 };
+ const struct buffer *use;
+ int done, written, result;
+
+ for (done = 0; done < 2; ++done) {
+ use = (done == 0) ? buffer : &_terminate;
+ for (written = 0; written < use->used;) {
+ result = write(fd, use->mem + written, use->used - written);
+ if (result > 0)
+ written += result;
+ else if (result < 0 && errno != EWOULDBLOCK && errno != EAGAIN && errno != EINTR)
+ return 0; /* too bad */
}
}
- use = &terminate;
- written = 0;
- done = 1;
- goto write;
+ return 1;
}
diff --git a/libdaemon/client/daemon-io.h b/libdaemon/client/daemon-io.h
index 1f55af7..52aaa9c 100644
--- a/libdaemon/client/daemon-io.h
+++ b/libdaemon/client/daemon-io.h
@@ -26,6 +26,6 @@
/* TODO function names */
int buffer_read(int fd, struct buffer *buffer);
-int buffer_write(int fd, struct buffer *buffer);
+int buffer_write(int fd, const struct buffer *buffer);
#endif /* _LVM_DAEMON_SHARED_H */
10 years, 9 months
master - lvmetad: fix compare function
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=155841c349c58e...
Commit: 155841c349c58e2332802d85f3c39b8933cdd761
Parent: e3d39217794731402cedddb9cbaebf75c08c97ba
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jun 18 21:58:13 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jun 18 22:12:51 2013 +0200
lvmetad: fix compare function
Check for enough space in preallocated buffer.
Fixes problem, when lvm code started to suddenly allocate
too big memory chunks.
TODO: lvmetad protocol should announce needed size ahead,
so if metadata have 1MB we are not reallocating memory...
---
WHATS_NEW | 1 +
libdaemon/client/daemon-io.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 1eb440f..19bcf82 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Fix use of too big chunks of memory when communication with lvmetad.
Fix vgcfgrestore crash when specified incorrect vg name.
Refine lvm.conf and man page documentation for autoactivation feature.
Add support for thin volumes in vgsplit.
diff --git a/libdaemon/client/daemon-io.c b/libdaemon/client/daemon-io.c
index 37f2744..6ede8a8 100644
--- a/libdaemon/client/daemon-io.c
+++ b/libdaemon/client/daemon-io.c
@@ -41,7 +41,7 @@ int buffer_read(int fd, struct buffer *buffer) {
buffer->used -= 4;
break; /* success, we have the full message now */
}
- if (buffer->used - buffer->allocated < 32)
+ if (buffer->allocated - buffer->used < 32)
if (!buffer_realloc(buffer, 1024))
goto fail;
continue;
10 years, 9 months