master - tests: more snaps
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0ce9ae3cda9411...
Commit: 0ce9ae3cda9411f8f2a5491b07a6c4f06ab44da1
Parent: 3f6ade4b0d5901bb01bcbdfdb926823415a01703
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Dec 4 22:27:57 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Dec 5 17:12:42 2016 +0100
tests: more snaps
Check lvs reports 'origin' not openned.
---
test/shell/snapshot-merge-stack.sh | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/test/shell/snapshot-merge-stack.sh b/test/shell/snapshot-merge-stack.sh
index 3ee9eaa..bfafe71 100644
--- a/test/shell/snapshot-merge-stack.sh
+++ b/test/shell/snapshot-merge-stack.sh
@@ -37,14 +37,17 @@ snap_and_merge() {
lvconvert -b --merge $vg/$lv2
lvs -a -o+lv_merging,lv_merge_failed $vg
+ get lv_field $vg/$lv1 lv_attr | grep "Owi-ao"
+ get lv_field $vg/$lv2 lv_attr | grep "Swi-a-s---"
kill $SLEEP_PID
aux delay_dev "$dev1" 0 200 $(get first_extent_sector "$dev1"):
lvchange --poll n --refresh $vg/$lv1
dmsetup table
- lvs -a -o+lv_merging,lv_merge_failed $vg
+ lvs -av -o+lv_merging,lv_merge_failed $vg
+ # Origin is closed and snapshot merge could run
+ get lv_field $vg/$lv1 lv_attr | grep "Owi-a-"
sleep 1
- check lv_attr_bit state $vg/$lv1 "a"
check lv_attr_bit state $vg/$lv2 "a"
aux error_dev "$dev2" $(get first_extent_sector "$dev2"):
aux enable_dev "$dev1"
6 years, 3 months
master - tests: apostrof
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3f6ade4b0d5901...
Commit: 3f6ade4b0d5901bb01bcbdfdb926823415a01703
Parent: 022d3af06853ba4e627e098ac04ef1a8f9806edc
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 28 17:36:43 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Dec 5 17:12:42 2016 +0100
tests: apostrof
---
test/lib/aux.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index e4c3780..7f3c84a 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -322,9 +322,9 @@ prepare_lvmdbusd() {
# Setup the python path so we can run
export PYTHONPATH=$abs_top_builddir/daemons
else
- daemon="$(which lvmdbusd || :)"
+ daemon=$(which lvmdbusd || :)
fi
- [[ -n $daemon && -x $daemon ]] || skip "The daemon is missing"
+ [[ -n "$daemon" && -x "$daemon" ]] || skip "The daemon is missing"
which python3 >/dev/null || skip "Missing python3"
python3 -c "import pyudev, dbus, gi.repository" || skip "Missing python modules"
6 years, 3 months
master - tests: check we recognize broken table entry
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=022d3af06853ba...
Commit: 022d3af06853ba4e627e098ac04ef1a8f9806edc
Parent: 36b211b464a02cf054a838ccf9139379897cf973
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Dec 1 10:45:37 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Dec 5 17:12:42 2016 +0100
tests: check we recognize broken table entry
One (initial) test to recognize we see a mismatching
table entry for cache LV.
---
test/shell/lvs-cache.sh | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvs-cache.sh b/test/shell/lvs-cache.sh
index a06a023..2c518d0 100644
--- a/test/shell/lvs-cache.sh
+++ b/test/shell/lvs-cache.sh
@@ -22,6 +22,25 @@ SKIP_WITH_LVMPOLLD=1
aux have_cache 1 3 0 || skip
aux prepare_vg 5 8000
+# Use 10M origin size
+lvcreate -L10 -n $lv1 $vg
+lvcreate -H -L5 $vg/$lv1
+
+# replace 10M size with 5M size of cache device
+NEWCLINE=$(dmsetup table $vg-$lv1 | sed 's/20480/10240/')
+dmsetup reload $vg-$lv1 --table "$NEWCLINE"
+dmsetup resume $vg-$lv1
+
+# Check that mismatching cache target is shown by lvs
+lvs -a $vg 2>&1 | grep "WARNING"
+check lv_attr_bit state $vg/$lv1 "X"
+
+lvs -o+lv_active $vg
+
+lvremove -f $vg
+
+
+
lvcreate --type cache-pool -L10 $vg/cpool
lvcreate --type cache -l 1 --cachepool $vg/cpool -n corigin $vg
lvs -o lv_name,cache_policy
6 years, 3 months
master - debug: add missing backtrace
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=36b211b464a02c...
Commit: 36b211b464a02cf054a838ccf9139379897cf973
Parent: 3331199cc9f4b3935bc531428f03fbf3bb017d4c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Dec 4 22:29:18 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Dec 5 17:12:42 2016 +0100
debug: add missing backtrace
---
lib/metadata/lv.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 4a9fed7..8f13f6b 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -255,7 +255,8 @@ char *lvseg_kernel_discards_dup(struct dm_pool *mem, const struct lv_segment *se
if (!(status.info_ok = lv_info_with_seg_status(seg->lv->vg->cmd, seg, &status, 0, 0)))
goto_bad;
- ret = lvseg_kernel_discards_dup_with_info_and_seg_status(mem, &status);
+ if (!(ret = lvseg_kernel_discards_dup_with_info_and_seg_status(mem, &status)))
+ stack;
bad:
dm_pool_destroy(status.seg_status.mem);
6 years, 3 months
master - cleanup: simplier code
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3331199cc9f4b3...
Commit: 3331199cc9f4b3935bc531428f03fbf3bb017d4c
Parent: 81ef4eb4f887381d67546884be5a717030fb505a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Dec 1 14:59:02 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Dec 5 17:12:42 2016 +0100
cleanup: simplier code
---
lib/activate/dev_manager.c | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 6a8e487..581e900 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -728,15 +728,13 @@ int dev_manager_info(struct cmd_context *cmd, const struct logical_volume *lv,
struct lv_seg_status *seg_status)
{
char *dlid, *name;
- int r;
+ int r = 0;
if (!(name = dm_build_dm_name(cmd->mem, lv->vg->name, lv->name, layer)))
return_0;
- if (!(dlid = build_dm_uuid(cmd->mem, lv, layer))) {
- r = 0;
+ if (!(dlid = build_dm_uuid(cmd->mem, lv, layer)))
goto_out;
- }
log_debug_activation("Getting device info for %s [%s].", name, dlid);
r = _info(cmd, dlid, with_open_count, with_read_ahead,
@@ -1446,13 +1444,13 @@ int dev_manager_thin_pool_percent(struct dev_manager *dm,
{
char *name;
const char *dlid;
+ const char *layer = lv_layer(lv);
/* Build a name for the top layer */
- if (!(name = dm_build_dm_name(dm->mem, lv->vg->name, lv->name,
- lv_layer(lv))))
+ if (!(name = dm_build_dm_name(dm->mem, lv->vg->name, lv->name, layer)))
return_0;
- if (!(dlid = build_dm_uuid(dm->mem, lv, lv_layer(lv))))
+ if (!(dlid = build_dm_uuid(dm->mem, lv, layer)))
return_0;
log_debug_activation("Getting device status percentage for %s.", name);
6 years, 3 months
master - cleanup: indent and messsages updates
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=81ef4eb4f88738...
Commit: 81ef4eb4f887381d67546884be5a717030fb505a
Parent: 69c79ed2f486a9092cdf1586fcf320634e3cd44d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Dec 1 14:53:35 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Dec 5 17:12:42 2016 +0100
cleanup: indent and messsages updates
---
lib/activate/activate.c | 4 ++
lib/activate/dev_manager.c | 77 +++++++++++++++++++++++++-------------------
lib/metadata/lv.c | 1 +
3 files changed, 49 insertions(+), 33 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 3128f36..b4c8a2c 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -655,6 +655,10 @@ int target_present(struct cmd_context *cmd, const char *target_name,
&maj, &min, &patchlevel);
}
+/*
+ * When '*info' is NULL, returns 1 only when LV is active.
+ * When '*info' != NULL, returns 1 when info structure is populated.
+ */
static int _lv_info(struct cmd_context *cmd, const struct logical_volume *lv,
int use_layer, struct lvinfo *info,
const struct lv_segment *seg,
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index af7f5d8..6a8e487 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -136,6 +136,7 @@ static struct dm_task *_setup_task_run(int task, struct dm_info *info,
out:
dm_task_destroy(dmt);
+
return NULL;
}
@@ -236,7 +237,7 @@ static int _info_run(info_type_t type, const char *dlid,
with_flush = 0;
break;
default:
- log_error(INTERNAL_ERROR "_info_run: unhandled info type");
+ log_error(INTERNAL_ERROR "_info_run: unhandled info type.");
return 0;
}
@@ -274,6 +275,7 @@ static int _info_run(info_type_t type, const char *dlid,
out:
dm_task_destroy(dmt);
+
return r;
}
@@ -326,14 +328,14 @@ static int _ignore_blocked_mirror_devices(struct device *dev,
for (i = 0; i < sm->dev_count; ++i)
if (sm->devs[i].health != DM_STATUS_MIRROR_ALIVE) {
- log_debug_activation("%s: Mirror image %d marked as failed",
+ log_debug_activation("%s: Mirror image %d marked as failed.",
dev_name(dev), i);
check_for_blocking = 1;
}
if (!check_for_blocking && sm->log_count) {
if (sm->logs[0].health != DM_STATUS_MIRROR_ALIVE) {
- log_debug_activation("%s: Mirror log device marked as failed",
+ log_debug_activation("%s: Mirror log device marked as failed.",
dev_name(dev));
check_for_blocking = 1;
} else {
@@ -382,7 +384,7 @@ static int _ignore_blocked_mirror_devices(struct device *dev,
(p[15] == '\0' || p[15] == ' ')) ||
((p = strstr(params, " handle_errors")) &&
(p[14] == '\0' || p[14] == ' '))) {
- log_debug_activation("%s: I/O blocked to mirror device",
+ log_debug_activation("%s: I/O blocked to mirror device.",
dev_name(dev));
goto out;
}
@@ -447,6 +449,7 @@ static int _ignore_suspended_snapshot_component(struct device *dev)
out:
dm_task_destroy(dmt);
+
return r;
}
@@ -735,7 +738,7 @@ int dev_manager_info(struct cmd_context *cmd, const struct logical_volume *lv,
goto_out;
}
- log_debug_activation("Getting device info for %s [%s]", name, dlid);
+ log_debug_activation("Getting device info for %s [%s].", name, dlid);
r = _info(cmd, dlid, with_open_count, with_read_ahead,
dminfo, read_ahead, seg_status);
out:
@@ -874,7 +877,8 @@ bad:
return (device_id == id);
}
-int add_linear_area_to_dtree(struct dm_tree_node *node, uint64_t size, uint32_t extent_size, int use_linear_target, const char *vgname, const char *lvname)
+int add_linear_area_to_dtree(struct dm_tree_node *node, uint64_t size, uint32_t extent_size,
+ int use_linear_target, const char *vgname, const char *lvname)
{
uint32_t page_size;
@@ -895,10 +899,12 @@ int add_linear_area_to_dtree(struct dm_tree_node *node, uint64_t size, uint32_t
if (!dm_tree_node_add_striped_target(node, size, extent_size))
return_0;
return 1;
- } else
- /* Some exotic cases are unsupported by striped. */
- log_warn("WARNING: Using linear target for %s/%s: Striped requires extent size (%" PRIu32 " sectors) >= page size (%" PRIu32 ").",
- vgname, lvname, extent_size, page_size);
+ }
+
+ /* Some exotic cases are unsupported by striped. */
+ log_warn("WARNING: Using linear target for %s/%s: Striped requires extent size "
+ "(" FMTu32 " sectors) >= page size (" FMTu32 ").",
+ vgname, lvname, extent_size, page_size);
}
/*
@@ -1148,6 +1154,7 @@ struct dev_manager *dev_manager_create(struct cmd_context *cmd,
bad:
dm_pool_destroy(mem);
+
return NULL;
}
@@ -1236,10 +1243,10 @@ int dev_manager_mirror_percent(struct dev_manager *dm,
if (!(dlid = build_dm_uuid(dm->mem, lv, layer)))
return_0;
- log_debug_activation("Getting device %s status percentage for %s",
+ log_debug_activation("Getting device %s status percentage for %s.",
target_type, name);
- if (!_percent(dm, name, dlid, target_type, wait, lv, percent,
- event_nr, 0))
+
+ if (!_percent(dm, name, dlid, target_type, wait, lv, percent, event_nr, 0))
return_0;
return 1;
@@ -1269,9 +1276,9 @@ int dev_manager_raid_status(struct dev_manager *dm,
dm_get_next_target(dmt, NULL, &start, &length, &type, ¶ms);
- if (!type || strcmp(type, "raid")) {
- log_error("Expected raid segment type but got %s instead",
- type ? type : "NULL");
+ if (!type || strcmp(type, TARGET_NAME_RAID)) {
+ log_error("Expected %s segment type but got %s instead.",
+ TARGET_NAME_RAID, type ? type : "NULL");
goto out;
}
@@ -1297,7 +1304,7 @@ int dev_manager_raid_message(struct dev_manager *dm,
const char *layer = lv_layer(lv);
if (!lv_is_raid(lv)) {
- log_error(INTERNAL_ERROR "%s is not a RAID logical volume",
+ log_error(INTERNAL_ERROR "%s is not a RAID logical volume.",
display_lvname(lv));
return 0;
}
@@ -1310,7 +1317,7 @@ int dev_manager_raid_message(struct dev_manager *dm,
strcmp(msg, "check") &&
strcmp(msg, "repair") &&
strcmp(msg, "reshape")) {
- log_error(INTERNAL_ERROR "Unknown RAID message: %s", msg);
+ log_error(INTERNAL_ERROR "Unknown RAID message: %s.", msg);
return 0;
}
@@ -1361,8 +1368,8 @@ int dev_manager_cache_status(struct dev_manager *dm,
dm_get_next_target(dmt, NULL, &start, &length, &type, ¶ms);
if (!type || strcmp(type, TARGET_NAME_CACHE)) {
- log_error("Expected cache segment type but got %s instead",
- type ? type : "NULL");
+ log_error("Expected %s segment type but got %s instead.",
+ TARGET_NAME_CACHE, type ? type : "NULL");
goto out;
}
@@ -1448,7 +1455,8 @@ int dev_manager_thin_pool_percent(struct dev_manager *dm,
if (!(dlid = build_dm_uuid(dm->mem, lv, lv_layer(lv))))
return_0;
- log_debug_activation("Getting device status percentage for %s", name);
+ log_debug_activation("Getting device status percentage for %s.", name);
+
if (!(_percent(dm, name, dlid, TARGET_NAME_THIN_POOL, 0,
(metadata) ? lv : NULL, percent, NULL, 1)))
return_0;
@@ -1472,6 +1480,7 @@ int dev_manager_thin_percent(struct dev_manager *dm,
return_0;
log_debug_activation("Getting device status percentage for %s", name);
+
if (!(_percent(dm, name, dlid, TARGET_NAME_THIN, 0,
(mapped) ? NULL : lv, percent, NULL, 1)))
return_0;
@@ -1706,7 +1715,8 @@ static int _add_dev_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
if (!(dlid = build_dm_uuid(dm->mem, lv, layer)))
return_0;
- log_debug_activation("Getting device info for %s [%s]", name, dlid);
+ log_debug_activation("Getting device info for %s [%s].", name, dlid);
+
if (!_info(dm->cmd, dlid, 1, 0, &info, NULL, NULL)) {
log_error("Failed to get info for %s [%s].", name, dlid);
return 0;
@@ -1723,7 +1733,7 @@ static int _add_dev_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
if (info.exists && ((int) info.minor != lv->minor)) {
log_error("Volume %s (%" PRIu32 ":%" PRIu32")"
" differs from already active device "
- "(%" PRIu32 ":%" PRIu32")",
+ "(%" PRIu32 ":%" PRIu32").",
display_lvname(lv), lv->major, lv->minor,
info.major, info.minor);
return 0;
@@ -1731,7 +1741,7 @@ static int _add_dev_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
if (!info.exists && _info_by_dev(lv->major, lv->minor, &info2) &&
info2.exists) {
log_error("The requested major:minor pair "
- "(%" PRIu32 ":%" PRIu32") is already used",
+ "(%" PRIu32 ":%" PRIu32") is already used.",
lv->major, lv->minor);
return 0;
}
@@ -1739,7 +1749,7 @@ static int _add_dev_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
if (info.exists && !dm_tree_add_dev_with_udev_flags(dtree, info.major, info.minor,
_get_udev_flags(dm, lv, layer, 0, 0))) {
- log_error("Failed to add device (%" PRIu32 ":%" PRIu32") to dtree",
+ log_error("Failed to add device (%" PRIu32 ":%" PRIu32") to dtree.",
info.major, info.minor);
return 0;
}
@@ -1868,7 +1878,7 @@ static int _pool_callback(struct dm_tree_node *node,
for (cv = cn->v; cv && args < 16; cv = cv->next) {
if (cv->type != DM_CFG_STRING) {
log_error("Invalid string in config file: "
- "global/%s_check_options",
+ "global/%s_check_options.",
data->global);
return 0;
}
@@ -2491,7 +2501,7 @@ static int _add_target_to_dtree(struct dev_manager *dm,
if (!seg->segtype->ops->add_target_line) {
log_error(INTERNAL_ERROR "_emit_target cannot handle "
- "segment type %s", seg->segtype->name);
+ "segment type %s.", seg->segtype->name);
return 0;
}
@@ -2947,11 +2957,11 @@ static int _create_lv_symlinks(struct dev_manager *dm, struct dm_tree_node *root
if (name && lvlayer->old_name && *lvlayer->old_name && strcmp(name, lvlayer->old_name)) {
if (!dm_split_lvm_name(dm->mem, lvlayer->old_name, &old_vgname, &old_lvname, &old_layer)) {
- log_error("_create_lv_symlinks: Couldn't split up old device name %s", lvlayer->old_name);
+ log_error("_create_lv_symlinks: Couldn't split up old device name %s.", lvlayer->old_name);
return 0;
}
if (!dm_split_lvm_name(dm->mem, name, &new_vgname, &new_lvname, &new_layer)) {
- log_error("_create_lv_symlinks: Couldn't split up new device name %s", name);
+ log_error("_create_lv_symlinks: Couldn't split up new device name %s.", name);
return 0;
}
if (!fs_rename_lv(lvlayer->lv, name, old_vgname, old_lvname))
@@ -3079,7 +3089,7 @@ static int _tree_action(struct dev_manager *dm, const struct logical_volume *lv,
return_0;
if (!(root = dm_tree_find_node(dtree, 0, 0))) {
- log_error("Lost dependency tree root node");
+ log_error("Lost dependency tree root node.");
goto out_no_root;
}
@@ -3226,14 +3236,14 @@ int dev_manager_device_uses_vg(struct device *dev,
int r = 1;
if (!(dtree = dm_tree_create())) {
- log_error("partial dtree creation failed");
+ log_error("Failed to create partial dtree.");
return r;
}
dm_tree_set_optional_uuid_suffixes(dtree, &uuid_suffix_list[0]);
if (!dm_tree_add_dev(dtree, (uint32_t) MAJOR(dev->dev), (uint32_t) MINOR(dev->dev))) {
- log_error("Failed to add device %s (%" PRIu32 ":%" PRIu32") to dtree",
+ log_error("Failed to add device %s (%" PRIu32 ":%" PRIu32") to dtree.",
dev_name(dev), (uint32_t) MAJOR(dev->dev), (uint32_t) MINOR(dev->dev));
goto out;
}
@@ -3242,7 +3252,7 @@ int dev_manager_device_uses_vg(struct device *dev,
memcpy(dlid + sizeof(UUID_PREFIX) - 1, &vg->id.uuid[0], sizeof(vg->id));
if (!(root = dm_tree_find_node(dtree, 0, 0))) {
- log_error("Lost dependency tree root node");
+ log_error("Lost dependency tree root node.");
goto out;
}
@@ -3253,5 +3263,6 @@ int dev_manager_device_uses_vg(struct device *dev,
out:
dm_tree_free(dtree);
+
return r;
}
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 081df71..4a9fed7 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -258,6 +258,7 @@ char *lvseg_kernel_discards_dup(struct dm_pool *mem, const struct lv_segment *se
ret = lvseg_kernel_discards_dup_with_info_and_seg_status(mem, &status);
bad:
dm_pool_destroy(status.seg_status.mem);
+
return ret;
}
6 years, 3 months
master - cleanup: simplify code
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=69c79ed2f486a9...
Commit: 69c79ed2f486a9092cdf1586fcf320634e3cd44d
Parent: 114f7e62854e7b62f613925881ad321c3d5f6ff3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Dec 5 14:30:13 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Dec 5 17:12:42 2016 +0100
cleanup: simplify code
Drop unneeded assignemnt in structs (var is set by called function).
---
lib/metadata/lv.c | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 087b564..081df71 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -243,10 +243,7 @@ char *lvseg_kernel_discards_dup(struct dm_pool *mem, const struct lv_segment *se
{
char *ret = NULL;
struct lv_with_info_and_seg_status status = {
- .seg_status = {
- .type = SEG_STATUS_NONE,
- .seg = seg
- },
+ .seg_status.type = SEG_STATUS_NONE
};
if (!lv_is_thin_pool(seg->lv))
@@ -416,8 +413,8 @@ dm_percent_t lvseg_percent_with_info_and_seg_status(const struct lv_with_info_an
else {
log_warn("WARNING: Thin volume %s maps %s while the size is only %s.",
display_lvname(seg->lv),
- display_size(lvdm->lv->vg->cmd, s->thin->mapped_sectors),
- display_size(lvdm->lv->vg->cmd, csize));
+ display_size(seg->lv->vg->cmd, s->thin->mapped_sectors),
+ display_size(seg->lv->vg->cmd, csize));
/* Don't show nonsense numbers like i.e. 1000% full */
p = DM_PERCENT_100;
}
@@ -1312,7 +1309,6 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv)
char *ret = NULL;
struct lv_with_info_and_seg_status status = {
.seg_status.type = SEG_STATUS_NONE,
- .lv = lv
};
if (!(status.seg_status.mem = dm_pool_create("reporter_pool", 1024)))
6 years, 3 months
master - dev_manager: use setup_task_run for mknod
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=114f7e62854e7b...
Commit: 114f7e62854e7b62f613925881ad321c3d5f6ff3
Parent: 5163b8f697191caf13ae8192781f65b3f6335e74
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Dec 2 13:46:47 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Dec 5 17:12:39 2016 +0100
dev_manager: use setup_task_run for mknod
Simplify info run for use only for INFO & STATUS.
Drop handling MKNODES within _info_run() call
and use more advanced _setup_task_run() directly.
This allows to further simplify _info_run().
---
WHATS_NEW | 1 +
lib/activate/dev_manager.c | 36 +++++++++++++++++-------------------
2 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index eb64542..595b667 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Simplify internal _info_run() and use _setup_task_run() for mknod.
Better API for internal function _setup_task_run.
Avoid using lv_has_target_type() call within lv_info_with_seg_status.
Simplify internal lv_info_with_seg_status API.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index a90b6c0..af7f5d8 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -211,10 +211,9 @@ static int _get_segment_status_from_target_params(const char *target_name,
typedef enum {
INFO, /* DM_DEVICE_INFO ioctl */
STATUS, /* DM_DEVICE_STATUS ioctl */
- MKNODES
} info_type_t;
-static int _info_run(info_type_t type, const char *name, const char *dlid,
+static int _info_run(info_type_t type, const char *dlid,
struct dm_info *dminfo, uint32_t *read_ahead,
struct lv_seg_status *seg_status,
int with_open_count, int with_read_ahead,
@@ -236,17 +235,13 @@ static int _info_run(info_type_t type, const char *name, const char *dlid,
dmtask = DM_DEVICE_STATUS;
with_flush = 0;
break;
- case MKNODES:
- dmtask = DM_DEVICE_MKNODES;
- break;
default:
log_error(INTERNAL_ERROR "_info_run: unhandled info type");
return 0;
}
if (!(dmt = _setup_task_run(dmtask, dminfo,
- (type == MKNODES) ? name : NULL, dlid, 0,
- major, minor, with_open_count, with_flush, 0)))
+ NULL, dlid, 0, major, minor, with_open_count, with_flush, 0)))
return_0;
if (with_read_ahead && dminfo->exists) {
@@ -686,7 +681,7 @@ static int _info(struct cmd_context *cmd, const char *dlid, int with_open_count,
unsigned i = 0;
/* Check for dlid */
- if ((r = _info_run(seg_status ? STATUS : INFO, NULL, dlid, dminfo, read_ahead,
+ if ((r = _info_run(seg_status ? STATUS : INFO, dlid, dminfo, read_ahead,
seg_status, with_open_count, with_read_ahead, 0, 0)) && dminfo->exists)
return 1;
@@ -698,7 +693,7 @@ static int _info(struct cmd_context *cmd, const char *dlid, int with_open_count,
(void) strncpy(old_style_dlid, dlid, sizeof(old_style_dlid));
old_style_dlid[sizeof(old_style_dlid) - 1] = '\0';
- if ((r = _info_run(seg_status ? STATUS : INFO, NULL, old_style_dlid, dminfo,
+ if ((r = _info_run(seg_status ? STATUS : INFO, old_style_dlid, dminfo,
read_ahead, seg_status, with_open_count,
with_read_ahead, 0, 0)) && dminfo->exists)
return 1;
@@ -710,7 +705,7 @@ static int _info(struct cmd_context *cmd, const char *dlid, int with_open_count,
return r;
/* Check for dlid before UUID_PREFIX was added */
- if ((r = _info_run(seg_status ? STATUS : INFO, NULL, dlid + sizeof(UUID_PREFIX) - 1,
+ if ((r = _info_run(seg_status ? STATUS : INFO, dlid + sizeof(UUID_PREFIX) - 1,
dminfo, read_ahead, seg_status, with_open_count,
with_read_ahead, 0, 0)) && dminfo->exists)
return 1;
@@ -720,7 +715,7 @@ static int _info(struct cmd_context *cmd, const char *dlid, int with_open_count,
static int _info_by_dev(uint32_t major, uint32_t minor, struct dm_info *info)
{
- return _info_run(INFO, NULL, NULL, info, NULL, 0, 0, 0, major, minor);
+ return _info_run(INFO, NULL, info, NULL, 0, 0, 0, major, minor);
}
int dev_manager_info(struct cmd_context *cmd, const struct logical_volume *lv,
@@ -1561,21 +1556,24 @@ static int _lv_has_mknode(const struct logical_volume *lv)
int dev_manager_mknodes(const struct logical_volume *lv)
{
struct dm_info dminfo;
+ struct dm_task *dmt;
char *name;
int r = 0;
if (!(name = dm_build_dm_name(lv->vg->cmd->mem, lv->vg->name, lv->name, NULL)))
return_0;
- if ((r = _info_run(MKNODES, name, NULL, &dminfo, NULL, NULL, 0, 0, 0, 0))) {
- if (dminfo.exists) {
- if (_lv_has_mknode(lv))
- r = _dev_manager_lv_mknodes(lv);
- } else
- r = _dev_manager_lv_rmnodes(lv);
- }
+ if (!(dmt = _setup_task_run(DM_DEVICE_MKNODES, &dminfo, name, NULL, 0, 0, 0, 0, 0, 0)))
+ return_0;
+
+ if (dminfo.exists) {
+ if (_lv_has_mknode(lv))
+ r = _dev_manager_lv_mknodes(lv);
+ } else
+ r = _dev_manager_lv_rmnodes(lv);
+
+ dm_task_destroy(dmt);
- dm_pool_free(lv->vg->cmd->mem, name);
return r;
}
6 years, 3 months
master - dev_manager: extend setup_task
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5163b8f697191c...
Commit: 5163b8f697191caf13ae8192781f65b3f6335e74
Parent: e2c7e0ad1196cc9323b63807ed199bcf4b10807c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Dec 1 14:56:32 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Dec 5 17:11:49 2016 +0100
dev_manager: extend setup_task
Integrate also query for inactive table and
handle dm_task_run() and dm_task_get_info()
(thus switching to setup_task_run)
Add one exception case for DM_DEVICE_TARGET_MSG.
This allows further shortening and simplification of all
other users of this function.
---
WHATS_NEW | 1 +
lib/activate/dev_manager.c | 185 ++++++++++++++++----------------------------
2 files changed, 67 insertions(+), 119 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index df4c49e..eb64542 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Better API for internal function _setup_task_run.
Avoid using lv_has_target_type() call within lv_info_with_seg_status.
Simplify internal lv_info_with_seg_status API.
Decide which status is needed in one place for lv_info_with_seg_status.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index a72d5a9..a90b6c0 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -81,12 +81,16 @@ int read_only_lv(const struct logical_volume *lv, const struct lv_activate_opts
/*
* Low level device-layer operations.
+ *
+ * Unless task is DM_DEVICE_TARGET_MSG, also calls dm_task_run()
*/
-static struct dm_task *_setup_task(const char *name, const char *uuid,
- uint32_t *event_nr, int task,
- uint32_t major, uint32_t minor,
- int with_open_count,
- int with_flush)
+static struct dm_task *_setup_task_run(int task, struct dm_info *info,
+ const char *name, const char *uuid,
+ uint32_t *event_nr,
+ uint32_t major, uint32_t minor,
+ int with_open_count,
+ int with_flush,
+ int query_inactive)
{
struct dm_task *dmt;
@@ -108,14 +112,29 @@ static struct dm_task *_setup_task(const char *name, const char *uuid,
if (activation_checks() && !dm_task_enable_checks(dmt))
goto_out;
+ if (query_inactive && !dm_task_query_inactive_table(dmt)) {
+ log_error("Failed to set query_inactive_table.");
+ goto out;
+ }
+
if (!with_open_count && !dm_task_no_open_count(dmt))
log_warn("WARNING: Failed to disable open_count.");
if (!with_flush && !dm_task_no_flush(dmt))
log_warn("WARNING: Failed to set no_flush.");
+ if (task == DM_DEVICE_TARGET_MSG)
+ return dmt; /* TARGET_MSG needs more local tweaking before task_run() */
+
+ if (!dm_task_run(dmt))
+ goto_out;
+
+ if (info && !dm_task_get_info(dmt, info))
+ goto_out;
+
return dmt;
- out:
+
+out:
dm_task_destroy(dmt);
return NULL;
}
@@ -225,16 +244,11 @@ static int _info_run(info_type_t type, const char *name, const char *dlid,
return 0;
}
- if (!(dmt = _setup_task((type == MKNODES) ? name : NULL, dlid, 0, dmtask,
- major, minor, with_open_count, with_flush)))
+ if (!(dmt = _setup_task_run(dmtask, dminfo,
+ (type == MKNODES) ? name : NULL, dlid, 0,
+ major, minor, with_open_count, with_flush, 0)))
return_0;
- if (!dm_task_run(dmt))
- goto_out;
-
- if (!dm_task_get_info(dmt, dminfo))
- goto_out;
-
if (with_read_ahead && dminfo->exists) {
if (!dm_task_get_read_ahead(dmt, read_ahead))
goto_out;
@@ -357,11 +371,8 @@ static int _ignore_blocked_mirror_devices(struct device *dev,
* We avoid another system call if we can, but if a device is
* dead, we have no choice but to look up the table too.
*/
- if (!(dmt = _setup_task(NULL, NULL, NULL, DM_DEVICE_TABLE,
- MAJOR(dev->dev), MINOR(dev->dev), 0, 1)))
- goto_out;
-
- if (!dm_task_run(dmt))
+ if (!(dmt = _setup_task_run(DM_DEVICE_TABLE, NULL, NULL, NULL, NULL,
+ MAJOR(dev->dev), MINOR(dev->dev), 0, 1, 0)))
goto_out;
do {
@@ -397,22 +408,15 @@ static int _device_is_suspended(int major, int minor)
{
struct dm_task *dmt;
struct dm_info info;
- int r = 0;
- if (!(dmt = _setup_task(NULL, NULL, NULL, DM_DEVICE_INFO,
- major, minor, 0, 0)))
+ if (!(dmt = _setup_task_run(DM_DEVICE_INFO, &info,
+ NULL, NULL, NULL,
+ major, minor, 0, 0, 0)))
return_0;
- if (!dm_task_run(dmt) ||
- !dm_task_get_info(dmt, &info)) {
- log_error("Failed to get info for device %d:%d", major, minor);
- goto out;
- }
-
- r = info.exists && info.suspended;
-out:
dm_task_destroy(dmt);
- return r;
+
+ return (info.exists && info.suspended);
}
static int _ignore_suspended_snapshot_component(struct device *dev)
@@ -424,15 +428,11 @@ static int _ignore_suspended_snapshot_component(struct device *dev)
int major1, minor1, major2, minor2;
int r = 0;
- if (!(dmt = _setup_task(NULL, NULL, NULL, DM_DEVICE_TABLE,
- MAJOR(dev->dev), MINOR(dev->dev), 0, 1)))
+ if (!(dmt = _setup_task_run(DM_DEVICE_TABLE, NULL,
+ NULL, NULL, NULL,
+ MAJOR(dev->dev), MINOR(dev->dev), 0, 1, 0)))
return_0;
- if (!dm_task_run(dmt)) {
- log_error("Failed to get state of snapshot or snapshot origin device.");
- goto out;
- }
-
do {
next = dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms);
if (!target_type || !strcmp(target_type, TARGET_NAME_SNAPSHOT)) {
@@ -471,14 +471,10 @@ static int _ignore_unusable_thins(struct device *dev)
if (!(mem = dm_pool_create("unusable_thins", 128)))
return_0;
- if (!(dmt = _setup_task(NULL, NULL, NULL, DM_DEVICE_TABLE,
- MAJOR(dev->dev), MINOR(dev->dev), 0, 1)))
+ if (!(dmt = _setup_task_run(DM_DEVICE_TABLE, NULL, NULL, NULL, NULL,
+ MAJOR(dev->dev), MINOR(dev->dev), 0, 1, 0)))
goto_out;
- if (!dm_task_run(dmt)) {
- log_error("Failed to get state of mapped device.");
- goto out;
- }
dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms);
if (!params || sscanf(params, "%d:%d", &major, &minor) != 2) {
log_error("Failed to get thin-pool major:minor for thin device %d:%d.",
@@ -487,15 +483,10 @@ static int _ignore_unusable_thins(struct device *dev)
}
dm_task_destroy(dmt);
- if (!(dmt = _setup_task(NULL, NULL, NULL, DM_DEVICE_STATUS,
- major, minor, 0, 0)))
+ if (!(dmt = _setup_task_run(DM_DEVICE_STATUS, NULL, NULL, NULL, NULL,
+ major, minor, 0, 0, 0)))
goto_out;
- if (!dm_task_run(dmt)) {
- log_error("Failed to get state of mapped device.");
- goto out;
- }
-
dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms);
if (!dm_get_status_thin_pool(mem, params, &status))
goto_out;
@@ -544,18 +535,10 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check)
int only_error_target = 1;
int r = 0;
- if (!(dmt = _setup_task(NULL, NULL, NULL, DM_DEVICE_STATUS,
- MAJOR(dev->dev), MINOR(dev->dev), 0, 0)))
+ if (!(dmt = _setup_task_run(DM_DEVICE_STATUS, &info, NULL, NULL, NULL,
+ MAJOR(dev->dev), MINOR(dev->dev), 0, 0, 0)))
return_0;
- if (!dm_task_run(dmt)) {
- log_error("Failed to get state of mapped device");
- goto out;
- }
-
- if (!dm_task_get_info(dmt, &info))
- goto_out;
-
if (!info.exists)
goto out;
@@ -810,29 +793,20 @@ int lv_has_target_type(struct dm_pool *mem, const struct logical_volume *lv,
if (!(dlid = build_dm_uuid(mem, lv, layer)))
return_0;
- if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_STATUS, 0, 0, 0, 0)))
+ if (!(dmt = _setup_task_run(DM_DEVICE_STATUS, &info, NULL, dlid, 0, 0, 0, 0, 0, 0)))
goto_bad;
- if (!dm_task_run(dmt))
- goto_out;
-
- if (!dm_task_get_info(dmt, &info) || !info.exists)
+ if (!info.exists)
goto_out;
/* If there is a preloaded table, use that in preference. */
if (info.inactive_table) {
dm_task_destroy(dmt);
- if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_STATUS, 0, 0, 0, 0)))
+ if (!(dmt = _setup_task_run(DM_DEVICE_STATUS, &info, NULL, dlid, 0, 0, 0, 0, 0, 1)))
goto_bad;
- if (!dm_task_query_inactive_table(dmt))
- goto_out;
-
- if (!dm_task_run(dmt))
- goto_out;
-
- if (!dm_task_get_info(dmt, &info) || !info.exists || !info.inactive_table)
+ if (!info.exists || !info.inactive_table)
goto_out;
}
@@ -868,29 +842,20 @@ static int _thin_lv_has_device_id(struct dm_pool *mem, const struct logical_volu
if (!(dlid = build_dm_uuid(mem, lv, layer)))
return_0;
- if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_TABLE, 0, 0, 0, 1)))
+ if (!(dmt = _setup_task_run(DM_DEVICE_TABLE, &info, NULL, dlid, 0, 0, 0, 0, 1, 0)))
goto_bad;
- if (!dm_task_run(dmt))
- goto_out;
-
- if (!dm_task_get_info(dmt, &info) || !info.exists)
+ if (!info.exists)
goto_out;
/* If there is a preloaded table, use that in preference. */
if (info.inactive_table) {
dm_task_destroy(dmt);
- if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_TABLE, 0, 0, 0, 1)))
+ if (!(dmt = _setup_task_run(DM_DEVICE_TABLE, &info, NULL, dlid, 0, 0, 0, 0, 1, 1)))
goto_bad;
- if (!dm_task_query_inactive_table(dmt))
- goto_out;
-
- if (!dm_task_run(dmt))
- goto_out;
-
- if (!dm_task_get_info(dmt, &info) || !info.exists || !info.inactive_table)
+ if (!info.exists || !info.inactive_table)
goto_out;
}
@@ -993,14 +958,11 @@ static int _percent_run(struct dev_manager *dm, const char *name,
if (!(segtype = get_segtype_from_string(dm->cmd, target_type)))
return_0;
- if (!(dmt = _setup_task(name, dlid, event_nr,
- wait ? DM_DEVICE_WAITEVENT : DM_DEVICE_STATUS, 0, 0, 0, 0)))
+ if (!(dmt = _setup_task_run(wait ? DM_DEVICE_WAITEVENT : DM_DEVICE_STATUS, &info,
+ name, dlid, event_nr, 0, 0, 0, 0, 0)))
return_0;
- if (!dm_task_run(dmt))
- goto_out;
-
- if (!dm_task_get_info(dmt, &info) || !info.exists)
+ if (!info.exists)
goto_out;
if (event_nr)
@@ -1111,13 +1073,10 @@ int dev_manager_transient(struct dev_manager *dm, const struct logical_volume *l
if (!(dlid = build_dm_uuid(dm->mem, lv, layer)))
return_0;
- if (!(dmt = _setup_task(0, dlid, NULL, DM_DEVICE_STATUS, 0, 0, 0, 0)))
+ if (!(dmt = _setup_task_run(DM_DEVICE_STATUS, &info, NULL, dlid, NULL, 0, 0, 0, 0, 0)))
return_0;
- if (!dm_task_run(dmt))
- goto_out;
-
- if (!dm_task_get_info(dmt, &info) || !info.exists)
+ if (!info.exists)
goto_out;
do {
@@ -1307,13 +1266,10 @@ int dev_manager_raid_status(struct dev_manager *dm,
if (!(dlid = build_dm_uuid(dm->mem, lv, layer)))
return_0;
- if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_STATUS, 0, 0, 0, 0)))
+ if (!(dmt = _setup_task_run(DM_DEVICE_STATUS, &info, NULL, dlid, 0, 0, 0, 0, 0, 0)))
return_0;
- if (!dm_task_run(dmt))
- goto_out;
-
- if (!dm_task_get_info(dmt, &info) || !info.exists)
+ if (!info.exists)
goto_out;
dm_get_next_target(dmt, NULL, &start, &length, &type, ¶ms);
@@ -1366,7 +1322,7 @@ int dev_manager_raid_message(struct dev_manager *dm,
if (!(dlid = build_dm_uuid(dm->mem, lv, layer)))
return_0;
- if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_TARGET_MSG, 0, 0, 0, 1)))
+ if (!(dmt = _setup_task_run(DM_DEVICE_TARGET_MSG, NULL, NULL, dlid, 0, 0, 0, 0, 1, 0)))
return_0;
if (!dm_task_set_message(dmt, msg))
@@ -1401,13 +1357,10 @@ int dev_manager_cache_status(struct dev_manager *dm,
if (!(*status = dm_pool_zalloc(dm->mem, sizeof(struct lv_status_cache))))
return_0;
- if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_STATUS, 0, 0, 0, 0)))
+ if (!(dmt = _setup_task_run(DM_DEVICE_STATUS, &info, NULL, dlid, 0, 0, 0, 0, 0, 0)))
return_0;
- if (!dm_task_run(dmt))
- goto_out;
-
- if (!dm_task_get_info(dmt, &info) || !info.exists)
+ if (!info.exists)
goto_out;
dm_get_next_target(dmt, NULL, &start, &length, &type, ¶ms);
@@ -1465,13 +1418,10 @@ int dev_manager_thin_pool_status(struct dev_manager *dm,
if (!(dlid = build_dm_uuid(dm->mem, lv, lv_layer(lv))))
return_0;
- if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_STATUS, 0, 0, 0, flush)))
+ if (!(dmt = _setup_task_run(DM_DEVICE_STATUS, &info, NULL, dlid, 0, 0, 0, 0, flush, 0)))
return_0;
- if (!dm_task_run(dmt))
- goto_out;
-
- if (!dm_task_get_info(dmt, &info) || !info.exists)
+ if (!info.exists)
goto_out;
dm_get_next_target(dmt, NULL, &start, &length, &type, ¶ms);
@@ -1549,13 +1499,10 @@ int dev_manager_thin_device_id(struct dev_manager *dm,
if (!(dlid = build_dm_uuid(dm->mem, lv, lv_layer(lv))))
return_0;
- if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_TABLE, 0, 0, 0, 1)))
+ if (!(dmt = _setup_task_run(DM_DEVICE_TABLE, &info, NULL, dlid, 0, 0, 0, 0, 1, 0)))
return_0;
- if (!dm_task_run(dmt))
- goto_out;
-
- if (!dm_task_get_info(dmt, &info) || !info.exists)
+ if (!info.exists)
goto_out;
if (dm_get_next_target(dmt, NULL, &start, &length,
6 years, 3 months
master - activation: optimize away lv_has_target_type
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e2c7e0ad1196cc...
Commit: e2c7e0ad1196cc9323b63807ed199bcf4b10807c
Parent: 6fd20be629b6dceb96702c5f875a2e612e6f465d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Dec 5 15:23:18 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Dec 5 17:10:14 2016 +0100
activation: optimize away lv_has_target_type
It's actually not needed to call extra lv_has_target_type() to detect
snapshot merge is in progress - decode this right during status
capturing and save even few extra ioctl calls.
---
WHATS_NEW | 1 +
lib/activate/activate.c | 50 ++++++++++++++++++++++++++++------------------
2 files changed, 31 insertions(+), 20 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index a097477..df4c49e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Avoid using lv_has_target_type() call within lv_info_with_seg_status.
Simplify internal lv_info_with_seg_status API.
Decide which status is needed in one place for lv_info_with_seg_status.
Fix matching of LV segment when checking for it info status.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index afdf518..3128f36 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -757,7 +757,7 @@ int lv_info_with_seg_status(struct cmd_context *cmd,
struct lv_with_info_and_seg_status *status,
int with_open_count, int with_read_ahead)
{
- const struct logical_volume *lv = status->lv = lv_seg->lv;
+ const struct logical_volume *olv, *lv = status->lv = lv_seg->lv;
if (!activation())
return 0;
@@ -780,36 +780,46 @@ int lv_info_with_seg_status(struct cmd_context *cmd,
status->info.exists = 0; /* So pool LV is not active */
}
return 1;
- } else if (lv_is_origin(lv) &&
- (!lv_is_merging_origin(lv) ||
- !lv_has_target_type(cmd->mem, lv, NULL, TARGET_NAME_SNAPSHOT_MERGE))) {
+ } else if (lv_is_origin(lv)) {
/* Query segment status for 'layered' (-real) device most of the time,
* only for merging snapshot, query its progress.
* TODO: single LV may need couple status to be exposed at once....
* but this needs more logical background
*/
- /* Show INFO for actual origin */
- if (!_lv_info(cmd, lv, 0, &status->info, NULL, NULL, with_open_count, with_read_ahead))
+ /* Show INFO for actual origin and grab status for merging origin */
+ if (!_lv_info(cmd, lv, 0, &status->info, lv_seg,
+ lv_is_merging_origin(lv) ? &status->seg_status : NULL,
+ with_open_count, with_read_ahead))
return_0;
- if (status->info.exists)
+ if (status->info.exists &&
+ (status->seg_status.type != SEG_STATUS_SNAPSHOT)) /* Not merging */
/* Grab STATUS from layered -real */
(void) _lv_info(cmd, lv, 1, NULL, lv_seg, &status->seg_status, 0, 0);
return 1;
} else if (lv_is_cow(lv)) {
- if (lv_is_merging_cow(lv) &&
- lv_has_target_type(cmd->mem, origin_from_cow(lv), NULL, TARGET_NAME_SNAPSHOT_MERGE)) {
- /*
- * When merge is in progress, query merging origin LV instead.
- * COW volume is already mapped as error target in this case.
- */
- status->lv = lv = origin_from_cow(lv);
- lv_seg = first_seg(lv);
- log_debug_activation("Snapshot merge is in progress, querying status of %s instead.",
- display_lvname(lv));
- } else
- /* Hadle fictional lvm2 snapshot and query snapshotX volume */
- lv_seg = find_snapshot(lv);
+ if (lv_is_merging_cow(lv)) {
+ olv = origin_from_cow(lv);
+
+ if (!_lv_info(cmd, olv, 0, &status->info, first_seg(olv), &status->seg_status,
+ with_open_count, with_read_ahead))
+ return_0;
+
+ if (status->seg_status.type == SEG_STATUS_SNAPSHOT) {
+ log_debug_activation("Snapshot merge is in progress, querying status of %s instead.",
+ display_lvname(lv));
+ /*
+ * When merge is in progress, query merging origin LV instead.
+ * COW volume is already mapped as error target in this case.
+ */
+ status->lv = olv;
+ return 1;
+ }
+
+ /* Merge not yet started, still a snapshot... */
+ }
+ /* Hadle fictional lvm2 snapshot and query snapshotX volume */
+ lv_seg = find_snapshot(lv);
}
return _lv_info(cmd, lv, 0, &status->info, lv_seg, &status->seg_status,
6 years, 3 months