master - cleanup: reorder commonly available devs in system to the front
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=710c0df68a74c8...
Commit: 710c0df68a74c8da03eba62b43ae9080dd4a6ffe
Parent: 5097463fb326df3f1dde654da4b59011b6135f1f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Feb 20 17:06:26 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 24 21:13:35 2014 +0100
cleanup: reorder commonly available devs in system to the front
Just shorting strcmp....
---
lib/device/device-types.h | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/device/device-types.h b/lib/device/device-types.h
index 666f7b6..463f847 100644
--- a/lib/device/device-types.h
+++ b/lib/device/device-types.h
@@ -28,11 +28,13 @@ typedef struct {
* The list can be supplemented with devices/types in the config file.
*/
static const dev_known_type_t _dev_known_types[] = {
- {"ide", 64, "IDE disk"},
{"sd", 16, "SCSI disk"},
+ {"ide", 64, "IDE disk"},
{"md", 1, "Multiple Disk (MD/SoftRAID)"},
- {"mdp", 1, "Partitionable MD"},
{"loop", 1, "Loop device"},
+ {"ramdisk", 1, "RAM disk"},
+ {"device-mapper", 1, "Mapped device"},
+ {"mdp", 1, "Partitionable MD"},
{"dasd", 4, "DASD disk (IBM S/390, zSeries)"},
{"dac960", 8, "DAC960"},
{"nbd", 16, "Network Block Device"},
@@ -46,9 +48,7 @@ static const dev_known_type_t _dev_known_types[] = {
{"i2o_block", 16, "i2o Block Disk"},
{"iseries/vd", 8, "iSeries disks"},
{"gnbd", 1, "Network block device"},
- {"ramdisk", 1, "RAM disk"},
{"aoe", 16, "ATA over Ethernet"},
- {"device-mapper", 1, "Mapped device"},
{"xvd", 16, "Xen virtual block device"},
{"vdisk", 8, "SUN's LDOM virtual block device"},
{"ps3disk", 16, "PlayStation 3 internal disk"},
10 years, 3 months
master - mirror: detect attrs just once
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5097463fb326df...
Commit: 5097463fb326df3f1dde654da4b59011b6135f1f
Parent: 95fe823eba5432bc395847076fbf187889c55cb1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Feb 24 14:18:26 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 24 21:13:11 2014 +0100
mirror: detect attrs just once
Reorder detection of cmirrord. Now if cmirrord is not
running, target will not try to load kernel log module,
for communication with cmirrord.
Whole check for attrs now also happens just once.
---
WHATS_NEW | 1 +
lib/mirror/mirrored.c | 47 +++++++++++++++++++++--------------------------
2 files changed, 22 insertions(+), 26 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 29d1554..005a321 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Improve detection of clustered mirror support.
Enhance raid code with feature flags, for now checks for raid10.
Move parsing of VG metadata from vg_commit() back to vg_write() (2.02.99)
Avoid a PV label scan while in a critical section.
diff --git a/lib/mirror/mirrored.c b/lib/mirror/mirrored.c
index c3eb27b..57c6bba 100644
--- a/lib/mirror/mirrored.c
+++ b/lib/mirror/mirrored.c
@@ -150,7 +150,6 @@ static int _mirrored_text_export(const struct lv_segment *seg, struct formatter
#ifdef DEVMAPPER_SUPPORT
static int _block_on_error_available = 0;
-static unsigned _mirror_attributes = 0;
static struct mirror_state *_mirrored_init_target(struct dm_pool *mem,
struct cmd_context *cmd)
@@ -462,6 +461,7 @@ static int _mirrored_target_present(struct cmd_context *cmd,
{
static int _mirrored_checked = 0;
static int _mirrored_present = 0;
+ static unsigned _mirror_attributes = 0;
uint32_t maj, min, patchlevel;
unsigned maj2, min2, patchlevel2;
char vsn[80];
@@ -469,6 +469,7 @@ static int _mirrored_target_present(struct cmd_context *cmd,
unsigned kmaj, kmin, krel;
if (!_mirrored_checked) {
+ _mirrored_checked = 1;
_mirrored_present = target_present(cmd, "mirror", 1);
/*
@@ -492,14 +493,14 @@ static int _mirrored_target_present(struct cmd_context *cmd,
sscanf(vsn, "%u.%u.%u", &maj2, &min2, &patchlevel2) == 3 &&
maj2 == 4 && min2 == 5 && patchlevel2 == 0))) /* RHEL4U3 */
_block_on_error_available = 1;
- }
- /*
- * Check only for modules if atttributes requested and no previous check.
- * FIXME: Fails incorrectly if cmirror was built into kernel.
- */
- if (attributes) {
- if (!_mirror_attributes) {
+#ifdef CMIRRORD_PIDFILE
+ /*
+ * The cluster mirror log daemon must be running,
+ * otherwise, the kernel module will fail to make
+ * contact.
+ */
+ if (dm_daemon_is_running(CMIRRORD_PIDFILE)) {
/*
* The dm-log-userspace module was added to the
* 2.6.31 kernel.
@@ -508,31 +509,25 @@ static int _mirrored_target_present(struct cmd_context *cmd,
(sscanf(uts.release, "%u.%u.%u", &kmaj, &kmin, &krel) == 3) &&
KERNEL_VERSION(kmaj, kmin, krel) < KERNEL_VERSION(2, 6, 31)) {
if (module_present(cmd, "log-clustered"))
- _mirror_attributes |= MIRROR_LOG_CLUSTERED;
+ _mirror_attributes |= MIRROR_LOG_CLUSTERED;
} else if (module_present(cmd, "log-userspace"))
_mirror_attributes |= MIRROR_LOG_CLUSTERED;
if (!(_mirror_attributes & MIRROR_LOG_CLUSTERED))
- log_verbose("Cluster mirror log module is not available");
-
- /*
- * The cluster mirror log daemon must be running,
- * otherwise, the kernel module will fail to make
- * contact.
- */
-#ifdef CMIRRORD_PIDFILE
- if (!dm_daemon_is_running(CMIRRORD_PIDFILE)) {
- log_verbose("Cluster mirror log daemon is not running");
- _mirror_attributes &= ~MIRROR_LOG_CLUSTERED;
- }
+ log_verbose("Cluster mirror log module is not available.");
+ } else
+ log_verbose("Cluster mirror log daemon is not running.");
#else
- log_verbose("Cluster mirror log daemon not included in build");
- _mirror_attributes &= ~MIRROR_LOG_CLUSTERED;
+ log_verbose("Cluster mirror log daemon not included in build.");
#endif
- }
- *attributes = _mirror_attributes;
}
- _mirrored_checked = 1;
+
+ /*
+ * Check only for modules if atttributes requested and no previous check.
+ * FIXME: Fails incorrectly if cmirror was built into kernel.
+ */
+ if (attributes)
+ *attributes = _mirror_attributes;
return _mirrored_present;
}
10 years, 3 months
master - raid: use feature attributes for raid10
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=95fe823eba5432...
Commit: 95fe823eba5432bc395847076fbf187889c55cb1
Parent: 23c069d16f40adb9c59caa686904bb3f23ab6fca
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Feb 24 13:15:40 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 24 21:10:13 2014 +0100
raid: use feature attributes for raid10
Test raid10 availability as a target feature (instead of doing
it in all the places where raid10 should be checked).
TODO: activation needs runtime validation - so metadata with raid10
are skipped from activation in user-friendly way in lvm2.
---
WHATS_NEW | 1 +
lib/activate/activate.h | 5 +++++
lib/raid/raid.c | 36 +++++++++++++++++++++++++++++++++---
tools/lvcreate.c | 19 ++++++++-----------
4 files changed, 47 insertions(+), 14 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 05f5042..29d1554 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Enhance raid code with feature flags, for now checks for raid10.
Move parsing of VG metadata from vg_commit() back to vg_write() (2.02.99)
Avoid a PV label scan while in a critical section.
Remove (always 0) skip argument from lv_activation_skip().
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index 3da83ea..c3cf3d9 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -67,6 +67,11 @@ enum {
THIN_FEATURE_EXTERNAL_ORIGIN_EXTEND = (1 << 6),
};
+/* raid target attribute flags */
+enum {
+ RAID_FEATURE_RAID10 = (1 << 0), /* version 1.3 */
+};
+
void set_activation(int activation);
int activation(void);
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index 9f7bbd1..e592573 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -326,15 +326,45 @@ static int _raid_target_percent(void **target_state,
static int _raid_target_present(struct cmd_context *cmd,
const struct lv_segment *seg __attribute__((unused)),
- unsigned *attributes __attribute__((unused)))
+ unsigned *attributes)
{
+ /* List of features with their kernel target version */
+ static const struct feature {
+ uint32_t maj;
+ uint32_t min;
+ unsigned raid_feature;
+ const char *feature;
+ } const _features[] = {
+ { 1, 3, RAID_FEATURE_RAID10, "raid10" },
+ };
+
static int _raid_checked = 0;
static int _raid_present = 0;
+ static int _raid_attrs = 0;
+ uint32_t maj, min, patchlevel;
+ unsigned i;
- if (!_raid_checked)
+ if (!_raid_checked) {
_raid_present = target_present(cmd, "raid", 1);
- _raid_checked = 1;
+ if (!target_version("raid", &maj, &min, &patchlevel)) {
+ log_error("Cannot read target version of RAID kernel module.");
+ return 0;
+ }
+
+ for (i = 0; i < sizeof(_features)/sizeof(*_features); i++)
+ if ((maj > _features[i].maj) ||
+ (maj == _features[i].maj && min >= _features[i].min))
+ _raid_attrs |= _features[i].raid_feature;
+ else
+ log_very_verbose("Target raid does not support %s.",
+ _features[i].feature);
+
+ _raid_checked = 1;
+ }
+
+ if (attributes)
+ *attributes = _raid_attrs;
return _raid_present;
}
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index c56cc7c..6da0d61 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -977,19 +977,16 @@ static int _lvcreate_params(struct lvcreate_params *lp,
}
}
- if (activation() && lp->segtype->ops->target_present &&
- !lp->segtype->ops->target_present(cmd, NULL, &lp->target_attr)) {
- log_error("%s: Required device-mapper target(s) not "
- "detected in your kernel", lp->segtype->name);
- return 0;
- } else if (!strcmp(lp->segtype->name, "raid10")) {
- uint32_t maj, min, patchlevel;
- if (!target_version("raid", &maj, &min, &patchlevel)) {
- log_error("Failed to determine version of RAID kernel module");
+ if (activation() && lp->segtype->ops->target_present) {
+ if (!lp->segtype->ops->target_present(cmd, NULL, &lp->target_attr)) {
+ log_error("%s: Required device-mapper target(s) not detected in your kernel.",
+ lp->segtype->name);
return 0;
}
- if ((maj != 1) || (min < 3)) {
- log_error("RAID module does not support RAID10");
+
+ if ((strcmp(lp->segtype->name, "raid10") == 0) &&
+ !(lp->target_attr & RAID_FEATURE_RAID10)) {
+ log_error("RAID module does not support RAID10.");
return 0;
}
}
10 years, 3 months
master - thin: cleanup target_present call
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=23c069d16f40ad...
Commit: 23c069d16f40adb9c59caa686904bb3f23ab6fca
Parent: 8c878438f5a75310d09a1ee035d9caf8e2b9e50b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Feb 24 13:13:20 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 24 21:09:29 2014 +0100
thin: cleanup target_present call
Mark 'seg' as unused attribute.
Pass seg as NULL (as it is unused) in this function.
---
lib/thin/thin.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/thin/thin.c b/lib/thin/thin.c
index 92767a8..7c989f8 100644
--- a/lib/thin/thin.c
+++ b/lib/thin/thin.c
@@ -215,7 +215,7 @@ static int _thin_pool_text_export(const struct lv_segment *seg, struct formatter
#ifdef DEVMAPPER_SUPPORT
static int _thin_target_present(struct cmd_context *cmd,
- const struct lv_segment *seg,
+ const struct lv_segment *seg __attribute__((unused)),
unsigned *attributes);
static int _thin_pool_modules_needed(struct dm_pool *mem,
@@ -262,7 +262,7 @@ static int _thin_pool_add_target_line(struct dev_manager *dm,
uint64_t transaction_id = 0;
unsigned attr;
- if (!_thin_target_present(cmd, seg, &attr))
+ if (!_thin_target_present(cmd, NULL, &attr))
return_0;
if (!seg->metadata_lv) {
@@ -566,7 +566,7 @@ static int _thin_add_target_line(struct dev_manager *dm,
return_0;
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) ||
+ if (!_thin_target_present(cmd, NULL, &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);
@@ -617,7 +617,7 @@ static int _thin_target_percent(void **target_state __attribute__((unused)),
}
static int _thin_target_present(struct cmd_context *cmd,
- const struct lv_segment *seg,
+ const struct lv_segment *seg __attribute__((unused)),
unsigned *attributes)
{
/* List of features with their kernel target version */
10 years, 3 months
master - metadata: move vg parsing to vg_write
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8c878438f5a753...
Commit: 8c878438f5a75310d09a1ee035d9caf8e2b9e50b
Parent: 203affffc70622e1b0db4734bc631cd7caf22442
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Feb 22 01:44:21 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 24 21:08:53 2014 +0100
metadata: move vg parsing to vg_write
Parsing vg structure during supend/commit/resume may require a lot of
memory - so move this into vg_write.
FIXME: there are now multiple cache layers which our doing some thing
multiple times at different levels. Moreover there is now different
caching path with and without lvmetad - this should be unified
and both path should use same mechanism.
---
WHATS_NEW | 1 +
lib/metadata/metadata.c | 52 ++++++++++++++++++++++++++++++++--------------
lib/metadata/vg.c | 1 +
lib/metadata/vg.h | 1 +
4 files changed, 39 insertions(+), 16 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 23f7424..05f5042 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Move parsing of VG metadata from vg_commit() back to vg_write() (2.02.99)
Avoid a PV label scan while in a critical section.
Remove (always 0) skip argument from lv_activation_skip().
Create /dev/disk/by-id/lvm-pv-uuid-<PV_UUID> symlink for each PV via udev.
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 74f23b0..8643b75 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -856,30 +856,45 @@ int vgcreate_params_validate(struct cmd_context *cmd,
return 1;
}
-static int _vg_update_vg_ondisk(struct volume_group *vg)
+/*
+ * Update content of precommitted VG
+ *
+ * TODO: Optimize in the future, since lvmetad needs similar
+ * config tree processing in lvmetad_vg_update().
+ */
+static int _vg_update_vg_precommitted(struct volume_group *vg)
{
struct dm_config_tree *cft;
- int pool_locked;
- if (vg->vg_ondisk || is_orphan_vg(vg->name)) /* we already have it */
- return 1;
+ release_vg(vg->vg_precommitted);
+ vg->vg_precommitted = NULL;
- pool_locked = dm_pool_locked(vg->vgmem);
- if (pool_locked && !dm_pool_unlock(vg->vgmem, 0))
+ if (!(cft = export_vg_to_config_tree(vg)))
return_0;
- cft = export_vg_to_config_tree(vg);
- if (!cft)
- return 0;
+ if (!(vg->vg_precommitted = import_vg_from_config_tree(cft, vg->fid)))
+ stack;
- vg->vg_ondisk = import_vg_from_config_tree(cft, vg->fid);
dm_config_destroy(cft);
- /* recompute the pool crc */
- if (pool_locked && !dm_pool_lock(vg->vgmem, 1))
+ return vg->vg_precommitted ? 1 : 0;
+}
+
+static int _vg_update_vg_ondisk(struct volume_group *vg)
+{
+ if (dm_pool_locked(vg->vgmem))
+ return 1;
+
+ if (vg->vg_ondisk || is_orphan_vg(vg->name)) /* we already have it */
+ return 1;
+
+ if (!_vg_update_vg_precommitted(vg))
return_0;
- return vg->vg_ondisk ? 1 : 0;
+ vg->vg_ondisk = vg->vg_precommitted;
+ vg->vg_precommitted = NULL;
+
+ return 1;
}
/*
@@ -2687,6 +2702,9 @@ int vg_write(struct volume_group *vg)
if (!(vg->fid->fmt->features & FMT_PRECOMMIT) && !lvmetad_vg_update(vg))
return_0;
+ if (!_vg_update_vg_precommitted(vg)) /* prepare precommited */
+ return_0;
+
return 1;
}
@@ -2753,9 +2771,8 @@ int vg_commit(struct volume_group *vg)
/* This *is* the original now that it's commited. */
release_vg(vg->vg_ondisk);
- vg->vg_ondisk = NULL;
- if (!_vg_update_vg_ondisk(vg)) /* make a new one for future edits */
- return_0;
+ vg->vg_ondisk = vg->vg_precommitted;
+ vg->vg_precommitted = NULL;
}
/* If update failed, remove any cached precommitted metadata. */
@@ -2772,6 +2789,9 @@ void vg_revert(struct volume_group *vg)
{
struct metadata_area *mda;
+ release_vg(vg->vg_precommitted); /* VG is no longer needed */
+ vg->vg_precommitted = NULL;
+
dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use) {
if (mda->ops->vg_revert &&
!mda->ops->vg_revert(vg->fid, vg, mda)) {
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index 877371e..8f23d56 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -89,6 +89,7 @@ void release_vg(struct volume_group *vg)
return;
release_vg(vg->vg_ondisk);
+ release_vg(vg->vg_precommitted);
_free_vg(vg);
}
diff --git a/lib/metadata/vg.h b/lib/metadata/vg.h
index 43d27bf..028471b 100644
--- a/lib/metadata/vg.h
+++ b/lib/metadata/vg.h
@@ -57,6 +57,7 @@ struct volume_group {
* _vg_update_vg_ondisk.
*/
struct volume_group *vg_ondisk;
+ struct volume_group *vg_precommitted; /* Parsed from precommitted */
alloc_policy_t alloc;
struct profile *profile;
10 years, 3 months
master - libdm: enhance thin transaction_id validation
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=203affffc70622...
Commit: 203affffc70622e1b0db4734bc631cd7caf22442
Parent: c7b7cb60e4de1aff7f9ea9e3a8116f851ef3089c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Feb 24 09:43:14 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 24 21:06:31 2014 +0100
libdm: enhance thin transaction_id validation
Reuse _node_send_messages for just checking
for valid transaction_id with preload.
This allows earlier detection of incosistent thin pool.
Code does the same thing, except for sending messages.
---
WHATS_NEW_DM | 1 +
libdm/libdm-deptree.c | 21 +++++++++++++++++++--
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index c29cb39..32c2265 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.85 -
===================================
+ Reuse _node_send_messages() for validation of transaction_id in preload.
Transaction_id could be lower by one only when messages are prepared.
Do not call callback when preload fails.
Wrap is_selinux_enabled() to be called just once.
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 56ddd1a..fad14d6 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -1478,9 +1478,11 @@ out:
return r;
}
+/* For preload pass only validate pool's transaction_id */
static int _node_send_messages(struct dm_tree_node *dnode,
const char *uuid_prefix,
- size_t uuid_prefix_len)
+ size_t uuid_prefix_len,
+ int send)
{
struct load_segment *seg;
struct thin_message *tmsg;
@@ -1522,6 +1524,9 @@ static int _node_send_messages(struct dm_tree_node *dnode,
return 0;
}
+ if (!send)
+ return 1; /* transaction_id is matching */
+
dm_list_iterate_items(tmsg, &seg->thin_messages)
if (!(_thin_pool_node_message(dnode, tmsg)))
return_0;
@@ -1865,7 +1870,7 @@ int dm_tree_activate_children(struct dm_tree_node *dnode,
* has to report failure.
*/
if (r && dnode->props.send_messages &&
- !(r = _node_send_messages(dnode, uuid_prefix, uuid_prefix_len)))
+ !(r = _node_send_messages(dnode, uuid_prefix, uuid_prefix_len, 1)))
stack;
return r;
@@ -2713,6 +2718,18 @@ int dm_tree_preload_children(struct dm_tree_node *dnode,
if (!child->info.live_table) {
/* Collect newly introduced devices for revert */
dm_list_add_h(&dnode->activated, &child->activated_list);
+
+ /* When creating new node also check transaction_id. */
+ if (child->props.send_messages &&
+ !_node_send_messages(child, uuid_prefix, uuid_prefix_len, 0)) {
+ stack;
+ if (!dm_udev_wait(dm_tree_get_cookie(dnode)))
+ stack;
+ dm_tree_set_cookie(dnode, 0);
+ (void) _dm_tree_revert_activated(dnode);
+ r = 0;
+ continue;
+ }
}
/* Update cached info */
10 years, 3 months
master - libdm: hardening transaction_id validation
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c7b7cb60e4de1a...
Commit: c7b7cb60e4de1aff7f9ea9e3a8116f851ef3089c
Parent: 6116333ccc4969e69bfd10aa0fe64238dc7f4dab
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Feb 24 10:19:50 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 24 21:04:50 2014 +0100
libdm: hardening transaction_id validation
Improve testing of transation_id to not allow other difference
then either kernel TID is equal or is lower by oned and there
are queued messages for transaction.
Mark messages as submitted if the transaction_id is already matching.
Do not try to deactivate node on failure here and leave it on
proper error path of the caller.
---
WHATS_NEW_DM | 1 +
libdm/libdm-deptree.c | 35 ++++++++++++++++-------------------
2 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 072d21e..c29cb39 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.85 -
===================================
+ Transaction_id could be lower by one only when messages are prepared.
Do not call callback when preload fails.
Wrap is_selinux_enabled() to be called just once.
Use correctly signed 64b constant when working with raid volumes.
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 764074d..56ddd1a 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -1486,6 +1486,7 @@ static int _node_send_messages(struct dm_tree_node *dnode,
struct thin_message *tmsg;
uint64_t trans_id;
const char *uuid;
+ int have_messages;
if (!dnode->info.exists || (dm_list_size(&dnode->props.segs) != 1))
return 1;
@@ -1503,32 +1504,31 @@ static int _node_send_messages(struct dm_tree_node *dnode,
}
if (!_thin_pool_status_transaction_id(dnode, &trans_id))
- goto_bad;
+ return_0;
+ have_messages = !dm_list_empty(&seg->thin_messages) ? 1 : 0;
if (trans_id == seg->transaction_id) {
- if (!dm_list_empty(&seg->thin_messages))
+ dnode->props.send_messages = 0; /* messages already committed */
+ if (have_messages)
log_debug_activation("Thin pool transaction_id matches %" PRIu64
", skipping messages.", trans_id);
- return 1; /* In sync - skip messages */
+ return 1;
}
- if (trans_id != (seg->transaction_id - 1)) {
+ /* Error if there are no stacked messages or id mismatches */
+ if (trans_id != (seg->transaction_id - have_messages)) {
log_error("Thin pool transaction_id=%" PRIu64 ", while expected: %" PRIu64 ".",
- trans_id, seg->transaction_id - 1);
- goto bad; /* Nothing to send */
+ trans_id, seg->transaction_id - have_messages);
+ return 0;
}
dm_list_iterate_items(tmsg, &seg->thin_messages)
if (!(_thin_pool_node_message(dnode, tmsg)))
- goto_bad;
+ return_0;
- return 1;
-bad:
- /* Try to deactivate */
- if (!(dm_tree_deactivate_children(dnode, uuid_prefix, uuid_prefix_len)))
- log_error("Failed to deactivate %s", dnode->name);
+ dnode->props.send_messages = 0; /* messages posted */
- return 0;
+ return 1;
}
/*
@@ -1864,12 +1864,9 @@ int dm_tree_activate_children(struct dm_tree_node *dnode,
* resume should continue further, just whole command
* has to report failure.
*/
- if (r && dnode->props.send_messages) {
- if (!(r = _node_send_messages(dnode, uuid_prefix, uuid_prefix_len)))
- stack;
- else
- dnode->props.send_messages = 0; /* messages posted */
- }
+ if (r && dnode->props.send_messages &&
+ !(r = _node_send_messages(dnode, uuid_prefix, uuid_prefix_len)))
+ stack;
return r;
}
10 years, 3 months
master - libdm: proper traversion of revert list
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6116333ccc4969...
Commit: 6116333ccc4969e69bfd10aa0fe64238dc7f4dab
Parent: 1911c61639164296d953eef6f1476a040648d5ec
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Feb 24 09:36:38 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 24 21:01:59 2014 +0100
libdm: proper traversion of revert list
Deactivation of top level node has to happen,
before traversing subtree.
Swap list logic and rather append new nodes to the head
and then use normal iteration.
(in-release update)
---
libdm/libdm-deptree.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 7fcc7ed..764074d 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -2625,13 +2625,16 @@ out:
return r;
}
+/*
+ * Currently try to deactivate only nodes created during preload.
+ * New node is always attached to the front of activated_list
+ */
static int _dm_tree_revert_activated(struct dm_tree_node *parent)
{
struct dm_tree_node *child;
- dm_list_iterate_back_items_gen(child, &parent->activated, activated_list) {
- _dm_tree_revert_activated(child);
- log_debug("Reverting preloaded %s.", child->name);
+ dm_list_iterate_items_gen(child, &parent->activated, activated_list) {
+ log_debug_activation("Reverting %s.", child->name);
if (!_deactivate_node(child->name, child->info.major, child->info.minor,
&child->dtree->cookie, child->udev_flags, 0)) {
log_error("Unable to deactivate %s (%" PRIu32
@@ -2639,6 +2642,8 @@ static int _dm_tree_revert_activated(struct dm_tree_node *parent)
child->info.minor);
return 0;
}
+ if (!_dm_tree_revert_activated(child))
+ return_0;
}
return 1;
@@ -2708,9 +2713,10 @@ int dm_tree_preload_children(struct dm_tree_node *dnode,
continue;
}
- if (!child->info.live_table)
+ if (!child->info.live_table) {
/* Collect newly introduced devices for revert */
- dm_list_add(&dnode->activated, &child->activated_list);
+ dm_list_add_h(&dnode->activated, &child->activated_list);
+ }
/* Update cached info */
child->info = newinfo;
10 years, 3 months
master - libdm: call preload callback only when success
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1911c616391642...
Commit: 1911c61639164296d953eef6f1476a040648d5ec
Parent: c132fc3ff6d031c136528ef00ecfbed417dae941
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Feb 23 23:10:36 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 24 21:01:13 2014 +0100
libdm: call preload callback only when success
Do not call node's preload callback, if there is
any failure during preload.
---
WHATS_NEW_DM | 1 +
libdm/libdm-deptree.c | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index a0b8066..072d21e 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.85 -
===================================
+ Do not call callback when preload fails.
Wrap is_selinux_enabled() to be called just once.
Use correctly signed 64b constant when working with raid volumes.
Exit dmeventd with pidfile cleanup instead of raising SIGKILL on DIE request.
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 8592cdb..7fcc7ed 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -2724,12 +2724,12 @@ int dm_tree_preload_children(struct dm_tree_node *dnode,
}
if (update_devs_flag ||
- (!dnode->info.exists && dnode->callback)) {
+ (r && !dnode->info.exists && dnode->callback)) {
if (!dm_udev_wait(dm_tree_get_cookie(dnode)))
stack;
dm_tree_set_cookie(dnode, 0);
- if (!dnode->info.exists && dnode->callback &&
+ if (r && !dnode->info.exists && dnode->callback &&
!dnode->callback(dnode, DM_NODE_CALLBACK_PRELOADED,
dnode->callback_data))
{
10 years, 3 months
master - libdm: drop unneded assignment
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c132fc3ff6d031...
Commit: c132fc3ff6d031c136528ef00ecfbed417dae941
Parent: 8346f106b448caeb9625d05eb9d196cced860288
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Feb 24 09:44:54 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 24 20:59:10 2014 +0100
libdm: drop unneded assignment
---
libdm/libdm-deptree.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index cede734..8592cdb 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -1871,8 +1871,6 @@ int dm_tree_activate_children(struct dm_tree_node *dnode,
dnode->props.send_messages = 0; /* messages posted */
}
- handle = NULL;
-
return r;
}
10 years, 3 months