master - cleanup: reuse _setup_task
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=74e704bb446596...
Commit: 74e704bb4465960b361711c890733cbae1f06e42
Parent: a09d65891fcf97130dd595eba320b647638d9a07
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 8 19:28:35 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Apr 8 20:20:16 2016 +0200
cleanup: reuse _setup_task
Shorten code and use common code from _setup_task.
Reorder naming of major:minor sscanf (as later it's been
also used swapped there was no real bug).
---
lib/activate/dev_manager.c | 58 ++++++++++++-------------------------------
1 files changed, 16 insertions(+), 42 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index f2e3826..8c01b43 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -337,13 +337,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 = dm_task_create(DM_DEVICE_TABLE)))
- goto_out;
-
- if (!dm_task_set_major_minor(dmt, MAJOR(dev->dev), MINOR(dev->dev), 1))
- goto_out;
-
- if (activation_checks() && !dm_task_enable_checks(dmt))
+ if (!(dmt = _setup_task(NULL, NULL, NULL, DM_DEVICE_TABLE,
+ MAJOR(dev->dev), MINOR(dev->dev), 0)))
goto_out;
if (!dm_task_run(dmt))
@@ -384,13 +379,8 @@ static int _device_is_suspended(int major, int minor)
struct dm_info info;
int r = 0;
- if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
- return 0;
-
- if (!dm_task_set_major_minor(dmt, major, minor, 1))
- goto_out;
-
- if (activation_checks() && !dm_task_enable_checks(dmt))
+ if (!(dmt = _setup_task(NULL, NULL, NULL, DM_DEVICE_INFO,
+ major, minor, 0)))
goto_out;
if (!dm_task_run(dmt) ||
@@ -414,13 +404,8 @@ static int _ignore_suspended_snapshot_component(struct device *dev)
int major1, minor1, major2, minor2;
int r = 0;
- if (!(dmt = dm_task_create(DM_DEVICE_TABLE)))
- return_0;
-
- if (!dm_task_set_major_minor(dmt, MAJOR(dev->dev), MINOR(dev->dev), 1))
- goto_out;
-
- if (activation_checks() && !dm_task_enable_checks(dmt))
+ if (!(dmt = _setup_task(NULL, NULL, NULL, DM_DEVICE_TABLE,
+ MAJOR(dev->dev), MINOR(dev->dev), 0)))
goto_out;
if (!dm_task_run(dmt)) {
@@ -466,32 +451,29 @@ static int _ignore_unusable_thins(struct device *dev)
if (!(mem = dm_pool_create("unusable_thins", 128)))
return_0;
- if (!(dmt = dm_task_create(DM_DEVICE_TABLE)))
- goto_out;
- if (!dm_task_no_open_count(dmt))
- goto_out;
- if (!dm_task_set_major_minor(dmt, MAJOR(dev->dev), MINOR(dev->dev), 1))
+ if (!(dmt = _setup_task(NULL, NULL, NULL, DM_DEVICE_TABLE,
+ MAJOR(dev->dev), MINOR(dev->dev), 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", &minor, &major) != 2) {
+ if (!params || sscanf(params, "%d:%d", &major, &minor) != 2) {
log_error("Failed to get thin-pool major:minor for thin device %d:%d.",
(int)MAJOR(dev->dev), (int)MINOR(dev->dev));
goto out;
}
dm_task_destroy(dmt);
- if (!(dmt = dm_task_create(DM_DEVICE_STATUS)))
+ if (!(dmt = _setup_task(NULL, NULL, NULL, DM_DEVICE_STATUS,
+ major, minor, 0)))
goto_out;
+
if (!dm_task_no_flush(dmt))
log_warn("Can't set no_flush.");
- if (!dm_task_no_open_count(dmt))
- goto_out;
- if (!dm_task_set_major_minor(dmt, minor, major, 1))
- goto_out;
+
if (!dm_task_run(dmt)) {
log_error("Failed to get state of mapped device.");
goto out;
@@ -545,22 +527,14 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check)
int only_error_target = 1;
int r = 0;
- if (!(dmt = dm_task_create(DM_DEVICE_STATUS)))
- return_0;
-
- if (!dm_task_set_major_minor(dmt, MAJOR(dev->dev), MINOR(dev->dev), 1))
- goto_out;
-
- if (activation_checks() && !dm_task_enable_checks(dmt))
+ if (!(dmt = _setup_task(NULL, NULL, NULL, DM_DEVICE_STATUS,
+ MAJOR(dev->dev), MINOR(dev->dev), 0)))
goto_out;
/* Non-blocking status read */
if (!dm_task_no_flush(dmt))
log_warn("WARNING: Can't set no_flush for dm status.");
- if (!dm_task_no_open_count(dmt))
- goto_out;
-
if (!dm_task_run(dmt)) {
log_error("Failed to get state of mapped device");
goto out;
7 years, 5 months
master - dev_manager: device_is_usable does not flush
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a09d65891fcf97...
Commit: a09d65891fcf97130dd595eba320b647638d9a07
Parent: f40dfb48ad0114c89ac5fc0a8670a3792565e9a9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 8 16:00:03 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Apr 8 20:20:04 2016 +0200
dev_manager: device_is_usable does not flush
When scanning if device is being usable as PV,
we call STATUS - but this status should not cause
any flushing.
Skip also open_count information as it's not needed.
---
WHATS_NEW | 1 +
lib/activate/dev_manager.c | 9 ++++++++-
2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 21970a8..0fa9f50 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.150 -
=================================
+ Avoid using flushing dm status ioctl when checking for usable DM device.
Check for devices without LVM- uuid prefix only with kernels < 3.X.
Reuse %FREE size aproximation with lvcreate -l%PVS thin-pool.
Allow the lvmdump directory to exist already provided it is empty.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 89fa9e9..f2e3826 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -553,7 +553,14 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check)
if (activation_checks() && !dm_task_enable_checks(dmt))
goto_out;
-
+
+ /* Non-blocking status read */
+ if (!dm_task_no_flush(dmt))
+ log_warn("WARNING: Can't set no_flush for dm status.");
+
+ if (!dm_task_no_open_count(dmt))
+ goto_out;
+
if (!dm_task_run(dmt)) {
log_error("Failed to get state of mapped device");
goto out;
7 years, 5 months
master - activation: Skip another non-prefixed info ioctl.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f40dfb48ad0114...
Commit: f40dfb48ad0114c89ac5fc0a8670a3792565e9a9
Parent: e6768997e192e26aaf091b6ed2700a3391f178b5
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Apr 8 16:27:12 2016 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Apr 8 16:27:12 2016 +0100
activation: Skip another non-prefixed info ioctl.
_percent() also does a lookup by dm uuid.
Also get kernel version from cmd->kernel_vsn.
---
lib/activate/activate.c | 4 +-
lib/activate/dev_manager.c | 60 ++++++++++++++++++++++++-------------------
lib/activate/dev_manager.h | 3 +-
3 files changed, 37 insertions(+), 30 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 985d6b9..ca82518 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -660,7 +660,7 @@ static int _lv_info(struct cmd_context *cmd, const struct logical_volume *lv,
/* New thin-pool has no layer, but -tpool suffix needs to be queried */
if (!use_layer && lv_is_new_thin_pool(lv)) {
/* Check if there isn't existing old thin pool mapping in the table */
- if (!dev_manager_info(cmd->mem, lv, NULL, 0, 0, &dminfo, NULL, NULL))
+ if (!dev_manager_info(cmd, lv, NULL, 0, 0, &dminfo, NULL, NULL))
return_0;
if (!dminfo.exists)
use_layer = 1;
@@ -669,7 +669,7 @@ static int _lv_info(struct cmd_context *cmd, const struct logical_volume *lv,
if (seg_status)
seg_status->seg = seg;
- if (!dev_manager_info(cmd->mem, lv,
+ if (!dev_manager_info(cmd, lv,
(use_layer) ? lv_layer(lv) : NULL,
with_open_count, with_read_ahead,
&dminfo, (info) ? &info->read_ahead : NULL,
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 18e2081..89fa9e9 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -29,7 +29,6 @@
#include <limits.h>
#include <dirent.h>
-#include <sys/utsname.h>
#define MAX_TARGET_PARAMSIZE 50000
#define LVM_UDEV_NOSCAN_FLAG DM_SUBSYSTEM_UDEV_FLAG0
@@ -675,25 +674,31 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check)
return r;
}
-/* Returns 1 for kernels >= 3.X, otherwise 0 */
-static int _check_new_kernel(void)
+/*
+ * If active LVs were activated by a version of LVM2 before 2.02.00 we must
+ * perform additional checks to find them because they do not have the LVM-
+ * prefix on their dm uuids.
+ * As of 2.02.150, we've chosen to disable this compatibility arbitrarily if
+ * we're running kernel version 3 or above.
+ */
+#define MIN_KERNEL_MAJOR 3
+
+static int _original_uuid_format_check_required(struct cmd_context *cmd)
{
- static int major = 0;
- struct utsname _uts;
+ static int _kernel_major = 0;
- if (!major) {
- if (uname(&_uts) ||
- (sscanf(_uts.release, "%d", &major) != 1))
- major = 1;
- else if (major >= 3)
- log_debug("Not checking for devices without prefix "
- UUID_PREFIX " with newer kernel.");
+ if (!_kernel_major) {
+ if ((sscanf(cmd->kernel_vsn, "%d", &_kernel_major) != 1))
+ _kernel_major = 1;
+ else if (_kernel_major >= MIN_KERNEL_MAJOR)
+ log_debug_activation("Skipping checks for old devices without " UUID_PREFIX
+ " dm uuid prefix (kernel vsn %d >= %d).", _kernel_major, MIN_KERNEL_MAJOR);
}
- return (major >= 3);
+ return (_kernel_major < MIN_KERNEL_MAJOR);
}
-static int _info(const char *dlid, int with_open_count, int with_read_ahead,
+static int _info(struct cmd_context *cmd, const char *dlid, int with_open_count, int with_read_ahead,
struct dm_info *dminfo, uint32_t *read_ahead,
struct lv_seg_status *seg_status)
{
@@ -722,8 +727,8 @@ static int _info(const char *dlid, int with_open_count, int with_read_ahead,
}
}
- /* With kernels > 3.X skip checking for devices without UUID_PREFIX */
- if (_check_new_kernel())
+ /* Must we still check for the pre-2.02.00 dm uuid format? */
+ if (!_original_uuid_format_check_required(cmd))
return r;
/* Check for dlid before UUID_PREFIX was added */
@@ -740,7 +745,7 @@ 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);
}
-int dev_manager_info(struct dm_pool *mem, const struct logical_volume *lv,
+int dev_manager_info(struct cmd_context *cmd, const struct logical_volume *lv,
const char *layer,
int with_open_count, int with_read_ahead,
struct dm_info *dminfo, uint32_t *read_ahead,
@@ -749,19 +754,19 @@ int dev_manager_info(struct dm_pool *mem, const struct logical_volume *lv,
char *dlid, *name;
int r;
- if (!(name = dm_build_dm_name(mem, lv->vg->name, lv->name, layer)))
+ if (!(name = dm_build_dm_name(cmd->mem, lv->vg->name, lv->name, layer)))
return_0;
- if (!(dlid = build_dm_uuid(mem, lv, layer))) {
+ if (!(dlid = build_dm_uuid(cmd->mem, lv, layer))) {
r = 0;
goto_out;
}
log_debug_activation("Getting device info for %s [%s]", name, dlid);
- r = _info(dlid, with_open_count, with_read_ahead,
+ r = _info(cmd, dlid, with_open_count, with_read_ahead,
dminfo, read_ahead, seg_status);
out:
- dm_pool_free(mem, name);
+ dm_pool_free(cmd->mem, name);
return r;
}
@@ -1008,7 +1013,8 @@ static int _percent(struct dev_manager *dm, const char *name, const char *dlid,
if (_percent_run(dm, NULL, dlid, target_type, wait, lv, percent,
event_nr, fail_if_percent_unsupported))
return 1;
- else if (_percent_run(dm, NULL, dlid + sizeof(UUID_PREFIX) - 1,
+ else if (_original_uuid_format_check_required(dm->cmd) &&
+ _percent_run(dm, NULL, dlid + sizeof(UUID_PREFIX) - 1,
target_type, wait, lv, percent,
event_nr, fail_if_percent_unsupported))
return 1;
@@ -1686,7 +1692,7 @@ static int _add_dev_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
return_0;
log_debug_activation("Getting device info for %s [%s]", name, dlid);
- if (!_info(dlid, 1, 0, &info, NULL, NULL)) {
+ if (!_info(dm->cmd, dlid, 1, 0, &info, NULL, NULL)) {
log_error("Failed to get info for %s [%s].", name, dlid);
return 0;
}
@@ -1884,8 +1890,8 @@ static int _pool_callback(struct dm_tree_node *node,
log_sys_error("close", argv[args]);
if (ret == (int) DM_ARRAY_SIZE(buf)) {
- log_debug("%s skipped, detect empty disk header on %s.",
- argv[0], argv[args]);
+ log_debug_activation("%s skipped, detect empty disk header on %s.",
+ argv[0], argv[args]);
return 1;
}
}
@@ -2210,7 +2216,7 @@ static char *_add_error_device(struct dev_manager *dm, struct dm_tree *dtree,
return_NULL;
log_debug_activation("Getting device info for %s [%s]", name, dlid);
- if (!_info(dlid, 1, 0, &info, NULL, NULL)) {
+ if (!_info(dm->cmd, dlid, 1, 0, &info, NULL, NULL)) {
log_error("Failed to get info for %s [%s].", name, dlid);
return 0;
}
diff --git a/lib/activate/dev_manager.h b/lib/activate/dev_manager.h
index bcfb226..3744a61 100644
--- a/lib/activate/dev_manager.h
+++ b/lib/activate/dev_manager.h
@@ -45,11 +45,12 @@ void dev_manager_exit(void);
* (eg, an origin is created before its snapshot, but is not
* unsuspended until the snapshot is also created.)
*/
-int dev_manager_info(struct dm_pool *mem, const struct logical_volume *lv,
+int dev_manager_info(struct cmd_context *cmd, const struct logical_volume *lv,
const char *layer,
int with_open_count, int with_read_ahead,
struct dm_info *dminfo, uint32_t *read_ahead,
struct lv_seg_status *seg_status);
+
int dev_manager_snapshot_percent(struct dev_manager *dm,
const struct logical_volume *lv,
dm_percent_t *percent);
7 years, 5 months
master - test: Fix testing of installed lvmdbusd
by Marian Csontos
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e6768997e192e2...
Commit: e6768997e192e26aaf091b6ed2700a3391f178b5
Parent: ed0c779bd120e7c36cb7f100df3c6edc98e8cc52
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Fri Apr 1 09:28:31 2016 +0200
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Fri Apr 8 16:26:25 2016 +0200
test: Fix testing of installed lvmdbusd
If lvmdbusd is missing expression triggers ERR trap instead of skipping
the test.
---
test/lib/aux.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index c8985ed..3a44ae6 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -321,7 +321,7 @@ 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"
7 years, 5 months
master - report: remove superfluous SEGSSTATUS report type
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ed0c779bd120e7...
Commit: ed0c779bd120e7c36cb7f100df3c6edc98e8cc52
Parent: 50866034a2e612250c45116674765da08820fb27
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Apr 8 14:18:00 2016 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Apr 8 14:21:47 2016 +0200
report: remove superfluous SEGSSTATUS report type
We don't have any report field of this type yet. Return this patch into
the play if we really need that. Currenly we always report status
(result of "status" dm ioctl) for an LV as a whole where we choose
segment which represents the LV, not calling status for each possible
segment it contains - we don't need this now so I'm removing it to
not make the code more complex uselessly.
---
lib/report/report.c | 1 -
lib/report/report.h | 7 +++----
tools/reporter.c | 8 +++-----
3 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index 5009ecc..08a6097 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -3667,7 +3667,6 @@ static const struct dm_report_object_type _report_types[] = {
{ PVS, "Physical Volume", "pv_", _obj_get_pv },
{ LABEL, "Physical Volume Label", "pv_", _obj_get_label },
{ SEGS, "Logical Volume Segment", "seg_", _obj_get_seg },
- { SEGSSTATUS, "Logical Volume Device Segment Status", "seg_", _obj_get_lv_with_info_and_seg_status },
{ PVSEGS, "Physical Volume Segment", "pvseg_", _obj_get_pvseg },
{ 0, "", "", NULL },
};
diff --git a/lib/report/report.h b/lib/report/report.h
index 182f294..088a1ca 100644
--- a/lib/report/report.h
+++ b/lib/report/report.h
@@ -28,10 +28,9 @@ typedef enum {
PVS = 16,
VGS = 32,
SEGS = 64,
- SEGSSTATUS = 128,
- PVSEGS = 256,
- LABEL = 512,
- DEVTYPES = 1024
+ PVSEGS = 128,
+ LABEL = 256,
+ DEVTYPES = 512
} report_type_t;
/*
diff --git a/tools/reporter.c b/tools/reporter.c
index 220e307..a4cae60 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -409,10 +409,10 @@ static int _get_final_report_type(int args_are_pvs,
*lv_info_needed = (report_type & (LVSINFO | LVSINFOSTATUS)) ? 1 : 0;
/* Do we need to acquire LV device status in addition? */
- *lv_segment_status_needed = (report_type & (SEGSSTATUS | LVSSTATUS | LVSINFOSTATUS)) ? 1 : 0;
+ *lv_segment_status_needed = (report_type & (LVSSTATUS | LVSINFOSTATUS)) ? 1 : 0;
/* Ensure options selected are compatible */
- if (report_type & (SEGS | SEGSSTATUS))
+ if (report_type & SEGS)
report_type |= LVS;
if (report_type & PVSEGS)
report_type |= PVS;
@@ -429,7 +429,7 @@ static int _get_final_report_type(int args_are_pvs,
else if ((report_type & PVS) ||
((report_type & LABEL) && (report_type & VGS)))
report_type = PVS;
- else if (report_type & (SEGS | SEGSSTATUS))
+ else if (report_type & SEGS)
report_type = SEGS;
else if (report_type & (LVS | LVSINFO | LVSSTATUS | LVSINFOSTATUS))
report_type = LVS;
@@ -907,8 +907,6 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
r = process_each_vg(cmd, argc, argv, NULL, 0,
handle, &_pvs_in_vg);
break;
- case SEGSSTATUS:
- /* fall through */
case SEGS:
r = process_each_lv(cmd, argc, argv, 0, handle,
lv_info_needed && !lv_segment_status_needed ? &_lvsegs_with_info_single :
7 years, 5 months
master - cleanup: use common init/destroy_processing_handle in _report fn and cleanup error paths
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=50866034a2e612...
Commit: 50866034a2e612250c45116674765da08820fb27
Parent: f2e59e05eda9283911a8c7ea14c73ea4c30f8fa8
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Apr 8 11:01:19 2016 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Apr 8 11:01:19 2016 +0200
cleanup: use common init/destroy_processing_handle in _report fn and cleanup error paths
---
tools/reporter.c | 58 +++++++++++++++++++++++++++--------------------------
1 files changed, 30 insertions(+), 28 deletions(-)
diff --git a/tools/reporter.c b/tools/reporter.c
index 1a708c4..220e307 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -733,10 +733,10 @@ out:
static int _report(struct cmd_context *cmd, int argc, char **argv,
report_type_t report_type)
{
- void *report_handle;
- struct processing_handle handle = {0};
+ void *report_handle = NULL;
+ struct processing_handle *handle = NULL;
const char *keys = NULL, *options = NULL, *selection = NULL, *separator;
- int r = ECMD_PROCESSED;
+ int r = ECMD_FAILED;
int aligned, buffered, headings, field_prefixes, quoted;
int columns_as_rows;
unsigned args_are_pvs;
@@ -809,13 +809,13 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
break;
default:
log_error(INTERNAL_ERROR "Unknown report type.");
- return ECMD_FAILED;
+ goto out;
}
/* If -o supplied use it, else use default for report_type */
if (arg_count(cmd, options_ARG) &&
((r = _get_report_options(cmd, report_type, &options, &fields_to_compact) != ECMD_PROCESSED)))
- return r;
+ goto_out;
/* -O overrides default sort settings */
keys = arg_str_value(cmd, sort_ARG, keys);
@@ -841,19 +841,24 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
if (arg_count(cmd, select_ARG))
selection = arg_str_value(cmd, select_ARG, NULL);
+ if (!(handle = init_processing_handle(cmd)))
+ goto_out;
+
if (!(report_handle = report_init(cmd, options, keys, &report_type,
separator, aligned, buffered,
headings, field_prefixes, quoted,
columns_as_rows, selection)))
- return_ECMD_FAILED;
+ goto_out;
+
+ handle->internal_report_for_select = 0;
+ handle->include_historical_lvs = cmd->include_historical_lvs;
+ handle->custom_handle = report_handle;
if (!_get_final_report_type(args_are_pvs,
report_type, &lv_info_needed,
&lv_segment_status_needed,
- &report_type)) {
- dm_report_free(report_handle);
- return ECMD_FAILED;
- }
+ &report_type))
+ goto_out;
/*
* We lock VG_GLOBAL to enable use of metadata cache.
@@ -864,18 +869,13 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
lock_global = 1;
if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_READ, NULL)) {
log_error("Unable to obtain global lock.");
- dm_report_free(report_handle);
- return ECMD_FAILED;
+ goto out;
}
}
- handle.internal_report_for_select = 0;
- handle.include_historical_lvs = cmd->include_historical_lvs;
- handle.custom_handle = report_handle;
-
switch (report_type) {
case DEVTYPES:
- r = _process_each_devtype(cmd, argc, &handle);
+ r = _process_each_devtype(cmd, argc, handle);
break;
case LVSINFO:
/* fall through */
@@ -884,7 +884,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
case LVSINFOSTATUS:
/* fall through */
case LVS:
- r = process_each_lv(cmd, argc, argv, 0, &handle,
+ r = process_each_lv(cmd, argc, argv, 0, handle,
lv_info_needed && !lv_segment_status_needed ? &_lvs_with_info_single :
!lv_info_needed && lv_segment_status_needed ? &_lvs_with_status_single :
lv_info_needed && lv_segment_status_needed ? &_lvs_with_info_and_status_single :
@@ -892,25 +892,25 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
break;
case VGS:
r = process_each_vg(cmd, argc, argv, NULL, 0,
- &handle, &_vgs_single);
+ handle, &_vgs_single);
break;
case LABEL:
r = process_each_label(cmd, argc, argv,
- &handle, &_label_single);
+ handle, &_label_single);
break;
case PVS:
if (args_are_pvs)
r = process_each_pv(cmd, argc, argv, NULL,
arg_is_set(cmd, all_ARG), 0,
- &handle, &_pvs_single);
+ handle, &_pvs_single);
else
r = process_each_vg(cmd, argc, argv, NULL, 0,
- &handle, &_pvs_in_vg);
+ handle, &_pvs_in_vg);
break;
case SEGSSTATUS:
/* fall through */
case SEGS:
- r = process_each_lv(cmd, argc, argv, 0, &handle,
+ r = process_each_lv(cmd, argc, argv, 0, handle,
lv_info_needed && !lv_segment_status_needed ? &_lvsegs_with_info_single :
!lv_info_needed && lv_segment_status_needed ? &_lvsegs_with_status_single :
lv_info_needed && lv_segment_status_needed ? &_lvsegs_with_info_and_status_single :
@@ -920,14 +920,14 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
if (args_are_pvs)
r = process_each_pv(cmd, argc, argv, NULL,
arg_is_set(cmd, all_ARG), 0,
- &handle,
+ handle,
lv_info_needed && !lv_segment_status_needed ? &_pvsegs_with_lv_info_single :
!lv_info_needed && lv_segment_status_needed ? &_pvsegs_with_lv_status_single :
lv_info_needed && lv_segment_status_needed ? &_pvsegs_with_lv_info_and_status_single :
&_pvsegs_single);
else
r = process_each_vg(cmd, argc, argv, NULL, 0,
- &handle, &_pvsegs_in_vg);
+ handle, &_pvsegs_in_vg);
break;
}
@@ -942,11 +942,13 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
dm_report_output(report_handle);
- dm_report_free(report_handle);
-
if (lock_global)
unlock_vg(cmd, VG_GLOBAL);
-
+out:
+ if (handle)
+ destroy_processing_handle(cmd, handle);
+ if (report_handle)
+ dm_report_free(report_handle);
return r;
}
7 years, 5 months
master - cleanup: use #define for field's quote and pair character and also for the error msg while extending output line
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f2e59e05eda928...
Commit: f2e59e05eda9283911a8c7ea14c73ea4c30f8fa8
Parent: 248f47d489df42ce29f74f71185a4e266a9e78e0
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Apr 8 10:55:13 2016 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Apr 8 10:55:13 2016 +0200
cleanup: use #define for field's quote and pair character and also for the error msg while extending output line
---
libdm/libdm-report.c | 31 ++++++++++++++++++-------------
1 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index 8250a35..3896b3c 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -4175,6 +4175,11 @@ static int _sort_rows(struct dm_report *rh)
return 1;
}
+#define STANDARD_QUOTE "\'"
+#define STANDARD_PAIR "="
+
+#define UNABLE_TO_EXTEND_OUTPUT_LINE_MSG "dm_report: Unable to extend output line"
+
/*
* Produce report output
*/
@@ -4196,27 +4201,27 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
}
if (!dm_pool_grow_object(rh->mem, rh->output_field_name_prefix, 0)) {
- log_error("dm_report: Unable to extend output line");
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
dm_free(field_id);
return 0;
}
if (!dm_pool_grow_object(rh->mem, _toupperstr(field_id), 0)) {
- log_error("dm_report: Unable to extend output line");
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
dm_free(field_id);
return 0;
}
dm_free(field_id);
- if (!dm_pool_grow_object(rh->mem, "=", 1)) {
- log_error("dm_report: Unable to extend output line");
+ if (!dm_pool_grow_object(rh->mem, STANDARD_PAIR, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
return 0;
}
if (!(rh->flags & DM_REPORT_OUTPUT_FIELD_UNQUOTED) &&
- !dm_pool_grow_object(rh->mem, "\'", 1)) {
- log_error("dm_report: Unable to extend output line");
+ !dm_pool_grow_object(rh->mem, STANDARD_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
return 0;
}
}
@@ -4225,7 +4230,7 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
width = field->props->width;
if (!(rh->flags & DM_REPORT_OUTPUT_ALIGNED)) {
if (!dm_pool_grow_object(rh->mem, repstr, 0)) {
- log_error("dm_report: Unable to extend output line");
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
return 0;
}
} else {
@@ -4248,7 +4253,7 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
goto bad;
}
if (!dm_pool_grow_object(rh->mem, buf, width)) {
- log_error("dm_report: Unable to extend output line");
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
goto bad;
}
} else if (align & DM_REPORT_FIELD_ALIGN_RIGHT) {
@@ -4258,7 +4263,7 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
goto bad;
}
if (!dm_pool_grow_object(rh->mem, buf, width)) {
- log_error("dm_report: Unable to extend output line");
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
goto bad;
}
}
@@ -4266,8 +4271,8 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
if ((rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) &&
!(rh->flags & DM_REPORT_OUTPUT_FIELD_UNQUOTED))
- if (!dm_pool_grow_object(rh->mem, "\'", 1)) {
- log_error("dm_report: Unable to extend output line");
+ if (!dm_pool_grow_object(rh->mem, STANDARD_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
goto bad;
}
@@ -4345,7 +4350,7 @@ static int _output_as_rows(struct dm_report *rh)
if (!dm_list_end(&rh->rows, &row->list))
if (!dm_pool_grow_object(rh->mem, rh->separator, 0)) {
- log_error("dm_report: Unable to extend output line");
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
goto bad;
}
}
@@ -4393,7 +4398,7 @@ static int _output_as_columns(struct dm_report *rh)
if (!dm_list_end(&row->fields, fh))
if (!dm_pool_grow_object(rh->mem, rh->separator, 0)) {
- log_error("dm_report: Unable to extend output line");
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
goto bad;
}
7 years, 5 months
master - tests: require newer cache target
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=248f47d489df42...
Commit: 248f47d489df42ce29f74f71185a4e266a9e78e0
Parent: 9ab53dddf553867ba9a19367bf74307a36c43c9f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Apr 8 00:04:26 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Apr 8 00:04:26 2016 +0200
tests: require newer cache target
Older cache target is likely not updating status at all...
---
test/shell/lvconvert-repair-cache.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvconvert-repair-cache.sh b/test/shell/lvconvert-repair-cache.sh
index 1fdfd3f..756fd12 100644
--- a/test/shell/lvconvert-repair-cache.sh
+++ b/test/shell/lvconvert-repair-cache.sh
@@ -25,7 +25,7 @@ which "$FSCK" || skip
#
# Main
#
-aux have_cache 1 3 0 || skip
+aux have_cache 1 5 0 || skip
aux prepare_vg 4
7 years, 5 months
master - tests: use mkfs.ext3
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9ab53dddf55386...
Commit: 9ab53dddf553867ba9a19367bf74307a36c43c9f
Parent: 8b2108e6b16cbcb528a138413e9050dd6f420e0d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Apr 7 22:07:41 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Apr 7 22:32:09 2016 +0200
tests: use mkfs.ext3
mkfs.ext4 is not really needed so use more widespread mkfs.ext3
so test runs on older system.
---
test/shell/lvconvert-repair-mirror.sh | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/test/shell/lvconvert-repair-mirror.sh b/test/shell/lvconvert-repair-mirror.sh
index 242028d..e40f9aa 100644
--- a/test/shell/lvconvert-repair-mirror.sh
+++ b/test/shell/lvconvert-repair-mirror.sh
@@ -12,10 +12,13 @@
SKIP_WITH_LVMLOCKD=1
SKIP_WITH_LVMPOLLD=1
+MKFS=mkfs.ext3
MOUNT_DIR=mnt
. lib/inittest
+which "$MKFS" || skp
+
cleanup_mounted_and_teardown()
{
umount "$MOUNT_DIR" || true
@@ -33,7 +36,7 @@ aux prepare_vg 5
# with the default 512K - my C2D T61 reads just couple MB/s!
#
lvcreate -aey --type mirror -L10 --regionsize 1M -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3"
-mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
+"$MKFS" "$DM_DEV_DIR/$vg/$lv1"
mkdir "$MOUNT_DIR"
aux delay_dev "$dev2" 0 500 $(get first_extent_sector "$dev2"):
@@ -42,7 +45,7 @@ aux delay_dev "$dev4" 0 500 $(get first_extent_sector "$dev4"):
# Enforce syncronization
# ATM requires unmounted/unused LV??
#
-lvchange --yes --resync --noudevsync $vg/$lv1
+lvchange --yes --resync $vg/$lv1
trap 'cleanup_mounted_and_teardown' EXIT
mount "$DM_DEV_DIR/$vg/$lv1" "$MOUNT_DIR"
@@ -52,7 +55,8 @@ dd if=/dev/zero of=mnt/zero bs=4K count=100 conv=fdatasync 2>err &
PERCENT=$(get lv_field $vg/$lv1 copy_percent)
PERCENT=${PERCENT%%\.*} # cut decimal
-test "$PERCENT" -lt 50 # and check less then 50% mirror is in sync
+# and check less then 50% mirror is in sync (could be unusable delay_dev ?)
+test "$PERCENT" -lt 50 || skip
#lvs -a -o+devices $vg
#aux disable_dev "$dev3"
7 years, 5 months
master - activation: do not check for devs without LVM-
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8b2108e6b16cbc...
Commit: 8b2108e6b16cbcb528a138413e9050dd6f420e0d
Parent: 097a724bda160e4c0b5c7760e7a710d3e00b898c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Apr 7 21:37:26 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Apr 7 22:32:08 2016 +0200
activation: do not check for devs without LVM-
Devices without "LVM-" uuid prefix have been generated by very old
version of lvm2 2.00 and 2.01.
Since version 2.02 all lvm2 devices are using prefix "LVM-".
However checking for present of ancient non prefixed devices does
take extra IOCTL per every call and for majority of todays user
it will not find anything new.
So use the assumption that users with kernel 3.X and newer are not
really using such old versions of lvm2 (year <2005) and with their
new kernel they are also using new version of lvm2 and skip
checking for them.
This change also makes trace logs more readable.
---
WHATS_NEW | 1 +
lib/activate/dev_manager.c | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 8387eab..21970a8 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.150 -
=================================
+ Check for devices without LVM- uuid prefix only with kernels < 3.X.
Reuse %FREE size aproximation with lvcreate -l%PVS thin-pool.
Allow the lvmdump directory to exist already provided it is empty.
Show lvconverted percentage with 2 decimal digits.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index b3e97db..18e2081 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -29,6 +29,7 @@
#include <limits.h>
#include <dirent.h>
+#include <sys/utsname.h>
#define MAX_TARGET_PARAMSIZE 50000
#define LVM_UDEV_NOSCAN_FLAG DM_SUBSYSTEM_UDEV_FLAG0
@@ -674,6 +675,24 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check)
return r;
}
+/* Returns 1 for kernels >= 3.X, otherwise 0 */
+static int _check_new_kernel(void)
+{
+ static int major = 0;
+ struct utsname _uts;
+
+ if (!major) {
+ if (uname(&_uts) ||
+ (sscanf(_uts.release, "%d", &major) != 1))
+ major = 1;
+ else if (major >= 3)
+ log_debug("Not checking for devices without prefix "
+ UUID_PREFIX " with newer kernel.");
+ }
+
+ return (major >= 3);
+}
+
static int _info(const char *dlid, int with_open_count, int with_read_ahead,
struct dm_info *dminfo, uint32_t *read_ahead,
struct lv_seg_status *seg_status)
@@ -703,6 +722,10 @@ static int _info(const char *dlid, int with_open_count, int with_read_ahead,
}
}
+ /* With kernels > 3.X skip checking for devices without UUID_PREFIX */
+ if (_check_new_kernel())
+ return r;
+
/* Check for dlid before UUID_PREFIX was added */
if ((r = _info_run(seg_status ? STATUS : INFO, NULL, dlid + sizeof(UUID_PREFIX) - 1,
dminfo, read_ahead, seg_status, with_open_count,
7 years, 5 months