master - cleanup: substract integers
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cb49ceeabaa011...
Commit: cb49ceeabaa011f51aa20c1a66c85ecbcb2c36a7
Parent: 1c07e6746234e361ea68073b47a47df4bf4a7b2a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri May 27 10:39:25 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri May 27 15:47:24 2016 +0200
cleanup: substract integers
Instead of doing float arithmetic, do integer math first and
convert result to float.
---
tools/lvconvert_poll.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/lvconvert_poll.c b/tools/lvconvert_poll.c
index 3f3beaf..36db1c7 100644
--- a/tools/lvconvert_poll.c
+++ b/tools/lvconvert_poll.c
@@ -153,10 +153,10 @@ progress_t poll_merge_progress(struct cmd_context *cmd,
if (parms->progress_display)
log_print_unless_silent("%s: %s: %.2f%%", lv->name, parms->progress_title,
- 100.0 - dm_percent_to_float(percent));
+ dm_percent_to_float(DM_PERCENT_100 - percent));
else
log_verbose("%s: %s: %.2f%%", lv->name, parms->progress_title,
- 100.0 - dm_percent_to_float(percent));
+ dm_percent_to_float(DM_PERCENT_100 - percent));
if (percent == DM_PERCENT_0)
return PROGRESS_FINISHED_ALL;
7 years, 11 months
master - cache: enhance lv_cache_wait_for_clean
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1c07e6746234e3...
Commit: 1c07e6746234e361ea68073b47a47df4bf4a7b2a
Parent: 0424277c00a8c576082389e0f4cdd8fd64052a54
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri May 27 14:19:29 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri May 27 15:47:24 2016 +0200
cache: enhance lv_cache_wait_for_clean
Handle passthrough mode when checking cache mode state explicitely.
---
WHATS_NEW | 1 +
lib/metadata/cache_manip.c | 27 +++++++++++++++------------
2 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index a6957bc..213bc72 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.155 -
================================
+ Support passthrough cache mode when waiting for clean cache.
Check cache status only for 'in-use' cache pools.
Extend setup_task() to preset flushing for dm_task object.
When checking LV is a merging COW, validate its a COW LV first.
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index a39549d..3e8c5c7 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -425,8 +425,11 @@ int lv_cache_remove(struct logical_volume *cache_lv)
log_error("Cannot deactivate remotely active cache lv.");
return 0;
}
- /* For inactive writethrough just drop cache layer */
- if (first_seg(cache_seg->pool_lv)->cache_mode == CACHE_MODE_WRITETHROUGH) {
+
+ switch (first_seg(cache_seg->pool_lv)->cache_mode) {
+ case CACHE_MODE_WRITETHROUGH:
+ case CACHE_MODE_PASSTHROUGH:
+ /* For inactive pass/writethrough just drop cache layer */
corigin_lv = seg_lv(cache_seg, 0);
if (!detach_pool_lv(cache_seg))
return_0;
@@ -435,17 +438,17 @@ int lv_cache_remove(struct logical_volume *cache_lv)
if (!lv_remove(corigin_lv))
return_0;
return 1;
+ default:
+ /* Otherwise localy activate volume to sync dirty blocks */
+ cache_lv->status |= LV_TEMPORARY;
+ if (!activate_lv_excl_local(cache_lv->vg->cmd, cache_lv) ||
+ !lv_is_active_locally(cache_lv)) {
+ log_error("Failed to active cache locally %s.",
+ display_lvname(cache_lv));
+ return 0;
+ }
+ cache_lv->status &= ~LV_TEMPORARY;
}
-
- /* Otherwise localy active volume is need to sync dirty blocks */
- cache_lv->status |= LV_TEMPORARY;
- if (!activate_lv_excl_local(cache_lv->vg->cmd, cache_lv) ||
- !lv_is_active_locally(cache_lv)) {
- log_error("Failed to active cache locally %s.",
- display_lvname(cache_lv));
- return 0;
- }
- cache_lv->status &= ~LV_TEMPORARY;
}
/*
7 years, 11 months
master - cache: call status only on cache pool in use
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0424277c00a8c5...
Commit: 0424277c00a8c576082389e0f4cdd8fd64052a54
Parent: a4f8d1165cfed1a3d62b4b11fd46302fb7e9563c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue May 24 15:19:01 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri May 27 15:47:24 2016 +0200
cache: call status only on cache pool in use
Check show cache status only for cache pool in use.
---
WHATS_NEW | 1 +
lib/metadata/metadata-exported.h | 1 +
lib/report/properties.c | 4 ++--
lib/report/report.c | 6 +++---
4 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 44be410..a6957bc 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.155 -
================================
+ Check cache status only for 'in-use' cache pools.
Extend setup_task() to preset flushing for dm_task object.
When checking LV is a merging COW, validate its a COW LV first.
Correcting value in copy_percent() for 100%.
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index a850492..1a9d5d9 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -230,6 +230,7 @@
#define lv_is_cache(lv) (((lv)->status & CACHE) ? 1 : 0)
#define lv_is_cache_pool(lv) (((lv)->status & CACHE_POOL) ? 1 : 0)
+#define lv_is_used_cache_pool(lv) (lv_is_cache_pool(lv) && !dm_list_empty(&(lv)->segs_using_this_lv))
#define lv_is_cache_pool_data(lv) (((lv)->status & CACHE_POOL_DATA) ? 1 : 0)
#define lv_is_cache_pool_metadata(lv) (((lv)->status & CACHE_POOL_METADATA) ? 1 : 0)
#define lv_is_cache_type(lv) (((lv)->status & (CACHE | CACHE_POOL | CACHE_POOL_DATA | CACHE_POOL_METADATA)) ? 1 : 0)
diff --git a/lib/report/properties.c b/lib/report/properties.c
index 46f58be..d3feb07 100644
--- a/lib/report/properties.c
+++ b/lib/report/properties.c
@@ -109,7 +109,7 @@ static dm_percent_t _data_percent(const struct logical_volume *lv)
if (lv_is_cow(lv))
return _snap_percent(lv);
- if (lv_is_cache(lv) || lv_is_cache_pool(lv)) {
+ if (lv_is_cache(lv) || lv_is_used_cache_pool(lv)) {
if (!lv_cache_status(lv, &status)) {
stack;
return DM_PERCENT_INVALID;
@@ -130,7 +130,7 @@ static dm_percent_t _metadata_percent(const struct logical_volume *lv)
dm_percent_t percent;
struct lv_status_cache *status;
- if (lv_is_cache(lv) || lv_is_cache_pool(lv)) {
+ if (lv_is_cache(lv) || lv_is_used_cache_pool(lv)) {
if (!lv_cache_status(lv, &status)) {
stack;
return DM_PERCENT_INVALID;
diff --git a/lib/report/report.c b/lib/report/report.c
index 8fa9daf..fd084f1 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -2849,7 +2849,7 @@ static int _copypercent_disp(struct dm_report *rh,
(lv_is_mirror(lv) && lv_mirror_percent(lv->vg->cmd, lv, 0, &percent, NULL))) &&
(percent != DM_PERCENT_INVALID)) {
percent = copy_percent(lv);
- } else if (lv_is_cache(lv) || lv_is_cache_pool(lv)) {
+ } else if (lv_is_cache(lv) || lv_is_used_cache_pool(lv)) {
if (lv_cache_status(lv, &status)) {
percent = status->dirty_usage;
dm_pool_destroy(status->mem);
@@ -2947,7 +2947,7 @@ static int _datapercent_disp(struct dm_report *rh, struct dm_pool *mem,
(void) lv_thin_pool_percent(lv, 0, &percent);
else if (lv_is_thin_volume(lv))
(void) lv_thin_percent(lv, 0, &percent);
- else if (lv_is_cache(lv) || lv_is_cache_pool(lv)) {
+ else if (lv_is_cache(lv) || lv_is_used_cache_pool(lv)) {
if (lv_cache_status(lv, &status)) {
percent = status->data_usage;
dm_pool_destroy(status->mem);
@@ -2970,7 +2970,7 @@ static int _metadatapercent_disp(struct dm_report *rh,
(void) lv_thin_pool_percent(lv, 1, &percent);
else if (lv_is_thin_volume(lv))
(void) lv_thin_percent(lv, 1, &percent);
- else if (lv_is_cache(lv) || lv_is_cache_pool(lv)) {
+ else if (lv_is_cache(lv) || lv_is_used_cache_pool(lv)) {
if (lv_cache_status(lv, &status)) {
percent = status->metadata_usage;
dm_pool_destroy(status->mem);
7 years, 11 months
master - setup_task: add with_flush
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a4f8d1165cfed1...
Commit: a4f8d1165cfed1a3d62b4b11fd46302fb7e9563c
Parent: 26889b3bb636b5655620f25c38db2c6759bf708d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri May 27 13:45:47 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri May 27 15:47:24 2016 +0200
setup_task: add with_flush
To get better control when flushing is used add extra arg when
setting up dm task.
By default now check dm device status without flush.
(At this moment this should effect only thin and cache volumes).
Also switch dev_manager_thin_pool_status() to use more
readable 'flush' parameter instead of 'no_flush'.
---
WHATS_NEW | 1 +
lib/activate/activate.c | 2 +-
lib/activate/dev_manager.c | 63 +++++++++++++++++++-------------------------
lib/activate/dev_manager.h | 2 +-
4 files changed, 30 insertions(+), 38 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index aa352a2..44be410 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.155 -
================================
+ Extend setup_task() to preset flushing for dm_task object.
When checking LV is a merging COW, validate its a COW LV first.
Correcting value in copy_percent() for 100%.
Update vgreduce to use process_each_vg.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 1ef83d3..d5e416d 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -1202,7 +1202,7 @@ int lv_thin_pool_transaction_id(const struct logical_volume *lv,
if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1)))
return_0;
- if (!(r = dev_manager_thin_pool_status(dm, lv, &status, 1)))
+ if (!(r = dev_manager_thin_pool_status(dm, lv, &status, 0)))
stack;
else
*transaction_id = status->transaction_id;
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 32295fb..63cfe9c 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2015 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2016 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -85,7 +85,8 @@ int read_only_lv(const struct logical_volume *lv, const struct lv_activate_opts
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_open_count,
+ int with_flush)
{
struct dm_task *dmt;
@@ -110,6 +111,9 @@ static struct dm_task *_setup_task(const char *name, const char *uuid,
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.");
+
return dmt;
out:
dm_task_destroy(dmt);
@@ -192,6 +196,7 @@ static int _info_run(info_type_t type, const char *name, const char *dlid,
uint64_t target_start, target_length;
char *target_name, *target_params, *params_to_process = NULL;
uint32_t extent_size;
+ int with_flush = 1; /* TODO: arg for _info_run */
switch (type) {
case INFO:
@@ -199,6 +204,7 @@ static int _info_run(info_type_t type, const char *name, const char *dlid,
break;
case STATUS:
dmtask = DM_DEVICE_STATUS;
+ with_flush = 0;
break;
case MKNODES:
dmtask = DM_DEVICE_MKNODES;
@@ -209,7 +215,7 @@ static int _info_run(info_type_t type, const char *name, const char *dlid,
}
if (!(dmt = _setup_task((type == MKNODES) ? name : NULL, dlid, 0, dmtask,
- major, minor, with_open_count)))
+ major, minor, with_open_count, with_flush)))
return_0;
if (!dm_task_run(dmt))
@@ -338,7 +344,7 @@ static int _ignore_blocked_mirror_devices(struct device *dev,
* 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)))
+ MAJOR(dev->dev), MINOR(dev->dev), 0, 1)))
goto_out;
if (!dm_task_run(dmt))
@@ -380,7 +386,7 @@ static int _device_is_suspended(int major, int minor)
int r = 0;
if (!(dmt = _setup_task(NULL, NULL, NULL, DM_DEVICE_INFO,
- major, minor, 0)))
+ major, minor, 0, 0)))
return_0;
if (!dm_task_run(dmt) ||
@@ -405,7 +411,7 @@ static int _ignore_suspended_snapshot_component(struct device *dev)
int r = 0;
if (!(dmt = _setup_task(NULL, NULL, NULL, DM_DEVICE_TABLE,
- MAJOR(dev->dev), MINOR(dev->dev), 0)))
+ MAJOR(dev->dev), MINOR(dev->dev), 0, 1)))
return_0;
if (!dm_task_run(dmt)) {
@@ -452,7 +458,7 @@ static int _ignore_unusable_thins(struct device *dev)
return_0;
if (!(dmt = _setup_task(NULL, NULL, NULL, DM_DEVICE_TABLE,
- MAJOR(dev->dev), MINOR(dev->dev), 0)))
+ MAJOR(dev->dev), MINOR(dev->dev), 0, 1)))
goto_out;
if (!dm_task_run(dmt)) {
@@ -468,12 +474,9 @@ 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)))
+ major, minor, 0, 0)))
goto_out;
- if (!dm_task_no_flush(dmt))
- log_warn("Can't set no_flush.");
-
if (!dm_task_run(dmt)) {
log_error("Failed to get state of mapped device.");
goto out;
@@ -528,13 +531,9 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check)
int r = 0;
if (!(dmt = _setup_task(NULL, NULL, NULL, DM_DEVICE_STATUS,
- MAJOR(dev->dev), MINOR(dev->dev), 0)))
+ MAJOR(dev->dev), MINOR(dev->dev), 0, 0)))
return_0;
- /* Non-blocking status read */
- if (!dm_task_no_flush(dmt))
- log_warn("WARNING: Can't set no_flush for dm status.");
-
if (!dm_task_run(dmt)) {
log_error("Failed to get state of mapped device");
goto out;
@@ -797,7 +796,7 @@ 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)))
+ if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_STATUS, 0, 0, 0, 0)))
goto_bad;
if (!dm_task_run(dmt))
@@ -810,7 +809,7 @@ int lv_has_target_type(struct dm_pool *mem, const struct logical_volume *lv,
if (info.inactive_table) {
dm_task_destroy(dmt);
- if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_STATUS, 0, 0, 0)))
+ if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_STATUS, 0, 0, 0, 0)))
goto_bad;
if (!dm_task_query_inactive_table(dmt))
@@ -855,7 +854,7 @@ 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)))
+ if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_TABLE, 0, 0, 0, 1)))
goto_bad;
if (!dm_task_run(dmt))
@@ -868,7 +867,7 @@ static int _thin_lv_has_device_id(struct dm_pool *mem, const struct logical_volu
if (info.inactive_table) {
dm_task_destroy(dmt);
- if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_TABLE, 0, 0, 0)))
+ if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_TABLE, 0, 0, 0, 1)))
goto_bad;
if (!dm_task_query_inactive_table(dmt))
@@ -981,14 +980,9 @@ static int _percent_run(struct dev_manager *dm, const char *name,
return_0;
if (!(dmt = _setup_task(name, dlid, event_nr,
- wait ? DM_DEVICE_WAITEVENT : DM_DEVICE_STATUS, 0, 0, 0)))
+ wait ? DM_DEVICE_WAITEVENT : DM_DEVICE_STATUS, 0, 0, 0, 0)))
return_0;
- /* No freeze on overfilled thin-pool, read existing slightly outdated data */
- if (segtype_is_thin(segtype) &&
- !dm_task_no_flush(dmt))
- log_warn("Can't set no_flush flag."); /* Non fatal */
-
if (!dm_task_run(dmt))
goto_out;
@@ -1103,7 +1097,7 @@ 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)))
+ if (!(dmt = _setup_task(0, dlid, NULL, DM_DEVICE_STATUS, 0, 0, 0, 0)))
return_0;
if (!dm_task_run(dmt))
@@ -1299,7 +1293,7 @@ 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)))
+ if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_STATUS, 0, 0, 0, 0)))
return_0;
if (!dm_task_run(dmt))
@@ -1358,7 +1352,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)))
+ if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_TARGET_MSG, 0, 0, 0, 1)))
return_0;
if (!dm_task_set_message(dmt, msg))
@@ -1393,7 +1387,7 @@ 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)))
+ if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_STATUS, 0, 0, 0, 0)))
return_0;
if (!dm_task_run(dmt))
@@ -1442,7 +1436,7 @@ out:
int dev_manager_thin_pool_status(struct dev_manager *dm,
const struct logical_volume *lv,
struct dm_status_thin_pool **status,
- int noflush)
+ int flush)
{
const char *dlid;
struct dm_task *dmt;
@@ -1456,12 +1450,9 @@ 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)))
+ if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_STATUS, 0, 0, 0, flush)))
return_0;
- if (noflush && !dm_task_no_flush(dmt))
- log_warn("Can't set no_flush.");
-
if (!dm_task_run(dmt))
goto_out;
@@ -1543,7 +1534,7 @@ 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)))
+ if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_TABLE, 0, 0, 0, 1)))
return_0;
if (!dm_task_run(dmt))
diff --git a/lib/activate/dev_manager.h b/lib/activate/dev_manager.h
index 3744a61..ba198f5 100644
--- a/lib/activate/dev_manager.h
+++ b/lib/activate/dev_manager.h
@@ -69,7 +69,7 @@ int dev_manager_cache_status(struct dev_manager *dm,
int dev_manager_thin_pool_status(struct dev_manager *dm,
const struct logical_volume *lv,
struct dm_status_thin_pool **status,
- int noflush);
+ int flush);
int dev_manager_thin_pool_percent(struct dev_manager *dm,
const struct logical_volume *lv,
int metadata, dm_percent_t *percent);
7 years, 11 months
master - snapshot: check merging_cow is cow
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=26889b3bb636b5...
Commit: 26889b3bb636b5655620f25c38db2c6759bf708d
Parent: e9ee2cb6b6cf20893ab753d7129f759ba8faa931
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri May 27 13:49:30 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri May 27 15:47:24 2016 +0200
snapshot: check merging_cow is cow
Check first the LV is cow before even checking it's a merging COW.
Note: previosly merging_cow was also merging origin, so without
this explicit check it used to return '1' also when passed
LV has been merging origin.
---
WHATS_NEW | 1 +
lib/metadata/snapshot_manip.c | 7 ++++++-
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 2b6e0fb..aa352a2 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.155 -
================================
+ When checking LV is a merging COW, validate its a COW LV first.
Correcting value in copy_percent() for 100%.
Update vgreduce to use process_each_vg.
Update lvconvert to use process_each_lv.
diff --git a/lib/metadata/snapshot_manip.c b/lib/metadata/snapshot_manip.c
index 29b851f..2f13ac9 100644
--- a/lib/metadata/snapshot_manip.c
+++ b/lib/metadata/snapshot_manip.c
@@ -139,7 +139,12 @@ int lv_is_visible(const struct logical_volume *lv)
int lv_is_merging_cow(const struct logical_volume *cow)
{
- struct lv_segment *snap_seg = find_snapshot(cow);
+ struct lv_segment *snap_seg;
+
+ if (!lv_is_cow(cow))
+ return 0;
+
+ snap_seg = find_snapshot(cow);
/* checks lv_segment's status to see if snapshot is merging */
return (snap_seg && (snap_seg->status & MERGING)) ? 1 : 0;
7 years, 11 months
master - report: fix report copy_percent value
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e9ee2cb6b6cf20...
Commit: e9ee2cb6b6cf20893ab753d7129f759ba8faa931
Parent: 780424639afe3e9a91e85bf3f88142606833f310
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri May 27 13:48:30 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri May 27 15:47:24 2016 +0200
report: fix report copy_percent value
When mirror/raid called copy_percent function to return,
when 100% was supposed to be returned, wrong float 100.0 value
could have been reported back instead of dm_percent_t DM_PERCENT_100.
There is broken API somewhere, since the function here rely on
actively being modifid VG content even when doing 'lvs' operation.
(extents_copies)
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index fa13ac8..2b6e0fb 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.155 -
================================
+ Correcting value in copy_percent() for 100%.
Update vgreduce to use process_each_vg.
Update lvconvert to use process_each_lv.
Update pvscan to use process_each_vg for autoactivation.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 6c2d4e5..b941979 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -872,7 +872,7 @@ dm_percent_t copy_percent(const struct logical_volume *lv)
numerator += seg->area_len;
}
- return denominator ? dm_make_percent(numerator, denominator) : 100.0;
+ return denominator ? dm_make_percent(numerator, denominator) : DM_PERCENT_100;
}
/* Round up extents to next stripe boundary for number of stripes */
7 years, 11 months
master - Revert "libdm: trace missing settings"
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=780424639afe3e...
Commit: 780424639afe3e9a91e85bf3f88142606833f310
Parent: b762c37555dec3c2e99df05a721787d2223807b6
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri May 27 14:35:11 2016 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri May 27 14:35:11 2016 +0100
Revert "libdm: trace missing settings"
This reverts commit 8fd886f735125de4b3e32fc0a188af0192a0d173.
This was a deliberate omission because logging token-by-token metadata
parsing greatly increases the amount of logging for hardly any benefit.
In general, only LVM config file settings need to be logged, and in
places where it's considered important to log particular elements of
metadata that should be done using specific log_* lines.
This area can be revisited.
---
WHATS_NEW_DM | 1 -
libdm/libdm-config.c | 15 +++------------
2 files changed, 3 insertions(+), 13 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 165cb90..d446997 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -12,7 +12,6 @@ Version 1.02.124 - 30th April 2016
Version 1.02.123 - 23rd April 2016
==================================
- Trace more settings in very verbose mode for libdm-config.
Do not strip LVM- when debug reporting not found uuid.
Version 1.02.122 - 9th April 2016
diff --git a/libdm/libdm-config.c b/libdm/libdm-config.c
index 86955c5..dcb7c3f 100644
--- a/libdm/libdm-config.c
+++ b/libdm/libdm-config.c
@@ -1154,11 +1154,8 @@ int dm_config_get_uint32(const struct dm_config_node *cn, const char *path,
if (!n || !n->v || n->v->type != DM_CFG_INT)
return 0;
- if (result) {
- log_very_verbose("Setting %s to %u", path, (uint32_t) n->v->v.i);
+ if (result)
*result = n->v->v.i;
- }
-
return 1;
}
@@ -1172,11 +1169,8 @@ int dm_config_get_uint64(const struct dm_config_node *cn, const char *path,
if (!n || !n->v || n->v->type != DM_CFG_INT)
return 0;
- if (result) {
- log_very_verbose("Setting %s to " FMTu64 , path, (uint64_t) n->v->v.i);
+ if (result)
*result = (uint64_t) n->v->v.i;
- }
-
return 1;
}
@@ -1190,11 +1184,8 @@ int dm_config_get_str(const struct dm_config_node *cn, const char *path,
if (!n || !n->v || n->v->type != DM_CFG_STRING)
return 0;
- if (result) {
- log_very_verbose("Setting %s to %s", path, n->v->v.str);
+ if (result)
*result = n->v->v.str;
- }
-
return 1;
}
7 years, 11 months
master - WHATS_NEW: include recent changes
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b762c37555dec3...
Commit: b762c37555dec3c2e99df05a721787d2223807b6
Parent: 5dc2ed0c71eab9081ef6245150f5efad2a7c77b9
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu May 26 09:13:30 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu May 26 09:13:30 2016 -0500
WHATS_NEW: include recent changes
---
WHATS_NEW | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index eac3477..fa13ac8 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,8 @@
Version 2.02.155 -
================================
+ Update vgreduce to use process_each_vg.
+ Update lvconvert to use process_each_lv.
+ Update pvscan to use process_each_vg for autoactivation.
Add basic support for --type raid0 using md.
Add support for lvchange --cachemode for cached LV.
Fix liblvm2app error handling when setting up context.
7 years, 11 months
master - vgreduce: use process_each_vg
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5dc2ed0c71eab9...
Commit: 5dc2ed0c71eab9081ef6245150f5efad2a7c77b9
Parent: 2f2b3c9100443593d94ed4ed2ed014b56537c0e0
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed May 25 15:04:30 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed May 25 16:41:59 2016 -0500
vgreduce: use process_each_vg
---
lib/metadata/metadata.c | 1 +
tools/vgreduce.c | 140 ++++++++++++++++++++--------------------------
2 files changed, 62 insertions(+), 79 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 9e31ba4..bd97cd2 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -773,6 +773,7 @@ bad:
* . find_pv_by_name()
* . get_pvs()
* . the vg->pvs_to_write list and pv_to_write struct
+ * . vg_reduce()
*/
/*
diff --git a/tools/vgreduce.c b/tools/vgreduce.c
index e7c66fe..a10e12c 100644
--- a/tools/vgreduce.c
+++ b/tools/vgreduce.c
@@ -15,6 +15,12 @@
#include "tools.h"
+struct vgreduce_params {
+ int force;
+ int fixed;
+ int already_consistent;
+};
+
static int _remove_pv(struct volume_group *vg, struct pv_list *pvl, int silent)
{
char uuid[64] __attribute__((aligned(8)));
@@ -137,16 +143,43 @@ static int _vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
return ECMD_PROCESSED;
}
+static int _vgreduce_repair_single(struct cmd_context *cmd, const char *vg_name,
+ struct volume_group *vg, struct processing_handle *handle)
+{
+ struct vgreduce_params *vp = (struct vgreduce_params *) handle->custom_handle;
+
+ if (!vg_missing_pv_count(vg)) {
+ vp->already_consistent = 1;
+ return ECMD_PROCESSED;
+ }
+
+ if (!archive(vg))
+ return_ECMD_FAILED;
+
+ if (vp->force) {
+ if (!_make_vg_consistent(cmd, vg))
+ return_ECMD_FAILED;
+ vp->fixed = 1;
+ } else
+ vp->fixed = _consolidate_vg(cmd, vg);
+
+ if (!vg_write(vg) || !vg_commit(vg)) {
+ log_error("Failed to write out a consistent VG for %s", vg_name);
+ return ECMD_FAILED;
+ }
+
+ backup(vg);
+ return ECMD_PROCESSED;
+}
+
int vgreduce(struct cmd_context *cmd, int argc, char **argv)
{
- struct volume_group *vg;
+ struct processing_handle *handle;
+ struct vgreduce_params vp = { 0 };
const char *vg_name;
- uint32_t lockd_state = 0;
- int ret = ECMD_FAILED;
- int fixed = 1;
int repairing = arg_count(cmd, removemissing_ARG);
int saved_ignore_suspended_devices = ignore_suspended_devices();
- int locked = 0;
+ int ret;
if (!argc && !repairing) {
log_error("Please give volume group name and "
@@ -184,99 +217,48 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
argv++;
argc--;
- if (!repairing)
+ if (!(handle = init_processing_handle(cmd))) {
+ log_error("Failed to initialize processing handle.");
+ return ECMD_FAILED;
+ }
+ handle->custom_handle = &vp;
+
+ if (!repairing) {
/* FIXME: Pass private struct through to all these functions */
/* and update in batch afterwards? */
- return process_each_pv(cmd, argc, argv, vg_name,
- 0, READ_FOR_UPDATE, NULL,
- _vgreduce_single);
+ ret = process_each_pv(cmd, argc, argv, vg_name, 0, READ_FOR_UPDATE, handle, _vgreduce_single);
+ goto out;
+ }
- log_verbose("Finding volume group \"%s\"", vg_name);
+ /*
+ * VG repair (removemissing)
+ */
- init_ignore_suspended_devices(1);
- cmd->handles_missing_pvs = 1;
+ vp.force = arg_count(cmd, force_ARG);
/* Needed to change the set of orphan PVs. */
if (!lockd_gl(cmd, "ex", 0))
return_ECMD_FAILED;
+ cmd->lockd_gl_disable = 1;
- if (!lockd_vg(cmd, vg_name, "ex", 0, &lockd_state))
- return_ECMD_FAILED;
-
- vg = vg_read_for_update(cmd, vg_name, NULL, READ_ALLOW_EXPORTED, lockd_state);
- if (vg_read_error(vg) == FAILED_ALLOCATION ||
- vg_read_error(vg) == FAILED_NOTFOUND)
- goto_out;
+ cmd->handles_missing_pvs = 1;
- /* FIXME We want to allow read-only VGs to be changed here? */
- if (vg_read_error(vg) &&
- (vg_read_error(vg) != FAILED_READ_ONLY) &&
- !arg_count(cmd, removemissing_ARG))
- goto_out;
+ init_ignore_suspended_devices(1);
- locked = !vg_read_error(vg);
+ process_each_vg(cmd, 0, NULL, vg_name, NULL,
+ READ_FOR_UPDATE | READ_ALLOW_EXPORTED,
+ handle, &_vgreduce_repair_single);
- if (!vg_read_error(vg) && !vg_missing_pv_count(vg)) {
- log_error("Volume group \"%s\" is already consistent", vg_name);
+ if (vp.already_consistent) {
+ log_print_unless_silent("Volume group \"%s\" is already consistent", vg_name);
ret = ECMD_PROCESSED;
- goto out;
- }
-
- release_vg(vg);
- log_verbose("Trying to open VG %s for recovery...", vg_name);
-
- vg = vg_read_for_update(cmd, vg_name, NULL,
- READ_ALLOW_INCONSISTENT | READ_ALLOW_EXPORTED, lockd_state);
-
- locked |= !vg_read_error(vg);
-
- if (vg_read_error(vg) &&
- (vg_read_error(vg) != FAILED_READ_ONLY) &&
- (vg_read_error(vg) != FAILED_INCONSISTENT))
- goto_out;
-
- if (!archive(vg))
- goto_out;
-
- if (arg_count(cmd, force_ARG)) {
- if (!_make_vg_consistent(cmd, vg))
- goto_out;
- } else
- fixed = _consolidate_vg(cmd, vg);
-
- if (!vg_write(vg) || !vg_commit(vg)) {
- log_error("Failed to write out a consistent VG for %s", vg_name);
- goto out;
- }
-
- backup(vg);
-
- if (fixed) {
+ } else if (vp.fixed) {
log_print_unless_silent("Wrote out consistent volume group %s", vg_name);
ret = ECMD_PROCESSED;
} else
ret = ECMD_FAILED;
-
out:
init_ignore_suspended_devices(saved_ignore_suspended_devices);
- if (locked)
- unlock_vg(cmd, vg_name);
-
- release_vg(vg);
return ret;
-
-/******* FIXME
- log_error ("no empty physical volumes found in volume group \"%s\"", vg_name);
-
- log_verbose("volume group \"%s\" will be reduced by %d physical volume%s",
- vg_name, np, np > 1 ? "s" : "");
- log_verbose("reducing volume group \"%s\" by physical volume \"%s\"",
- vg_name, pv_names[p]);
-
- log_print("volume group \"%s\" %ssuccessfully reduced by physical volume%s:",
- vg_name, error > 0 ? "NOT " : "", p > 1 ? "s" : "");
- log_print("%s", pv_this[p]->pv_name);
-********/
-
}
7 years, 11 months
master - lvconvert: use process_each_lv
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2f2b3c91004435...
Commit: 2f2b3c9100443593d94ed4ed2ed014b56537c0e0
Parent: 7fffcce9247cba8ecb40a1c7b0c6d18a5cde2165
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon May 23 13:42:17 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed May 25 15:05:49 2016 -0500
lvconvert: use process_each_lv
In the same way that process_each_vg() can be passed
a single VG name to process, also allow process_each_lv()
to be passed a single VG name and LV name to process.
---
tools/lvchange.c | 2 +-
tools/lvconvert.c | 98 +++++++++++++++++-----------------------------------
tools/lvdisplay.c | 2 +-
tools/lvremove.c | 2 +-
tools/lvscan.c | 3 +-
tools/reporter.c | 4 +-
tools/toollib.c | 39 +++++++++++++++++++--
tools/toollib.h | 1 +
tools/vgmknodes.c | 3 +-
9 files changed, 76 insertions(+), 78 deletions(-)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 1ce19c5..ad27786 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1330,7 +1330,7 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
cmd->lockd_vg_enforce_sh = 1;
}
- return process_each_lv(cmd, argc, argv,
+ return process_each_lv(cmd, argc, argv, NULL, NULL,
update ? READ_FOR_UPDATE : 0, NULL,
&_lvchange_single);
}
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 39ce759..a4e7023 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3245,11 +3245,10 @@ static int _lvconvert_cache(struct cmd_context *cmd,
return 1;
}
-static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
- void *handle)
+static int _lvconvert(struct cmd_context *cmd, struct logical_volume *lv,
+ struct lvconvert_params *lp)
{
struct logical_volume *origin = NULL;
- struct lvconvert_params *lp = handle;
struct dm_list *failed_pvs;
if (lv_is_locked(lv)) {
@@ -3426,16 +3425,16 @@ static struct convert_poll_id_list* _convert_poll_id_list_create(struct cmd_cont
return idl;
}
-static int _convert_and_add_to_poll_list(struct cmd_context *cmd,
- struct lvconvert_params *lp,
- struct logical_volume *lv)
+static int _lvconvert_and_add_to_poll_list(struct cmd_context *cmd,
+ struct lvconvert_params *lp,
+ struct logical_volume *lv)
{
int ret;
struct lvinfo info;
struct convert_poll_id_list *idl;
- /* _lvconvert_single() call may alter the reference in lp->lv_to_poll */
- if ((ret = _lvconvert_single(cmd, lv, lp)) != ECMD_PROCESSED)
+ /* _lvconvert() call may alter the reference in lp->lv_to_poll */
+ if ((ret = _lvconvert(cmd, lv, lp)) != ECMD_PROCESSED)
stack;
else if (lp->need_polling) {
if (!lv_info(cmd, lp->lv_to_poll, 0, &info, 0, 0) || !info.exists)
@@ -3450,57 +3449,24 @@ static int _convert_and_add_to_poll_list(struct cmd_context *cmd,
return ret;
}
-static int lvconvert_single(struct cmd_context *cmd, struct lvconvert_params *lp)
+static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
+ struct processing_handle *handle)
{
- struct logical_volume *lv;
- struct volume_group *vg;
- int ret = ECMD_FAILED;
- int saved_ignore_suspended_devices = ignore_suspended_devices();
- uint32_t lockd_state = 0;
-
- if (lp->repair || lp->uncache) {
- init_ignore_suspended_devices(1);
- cmd->handles_missing_pvs = 1;
- }
-
- /* Unlock on error paths not required, it's automatic when command exits. */
- if (!lockd_vg(cmd, lp->vg_name, "ex", 0, &lockd_state))
- goto_out;
-
- vg = vg_read(cmd, lp->vg_name, NULL, READ_FOR_UPDATE, lockd_state);
- if (vg_read_error(vg)) {
- release_vg(vg);
- goto_out;
- }
+ struct lvconvert_params *lp = (struct lvconvert_params *) handle->custom_handle;
+ struct volume_group *vg = lv->vg;
if (test_mode() && is_lockd_type(vg->lock_type)) {
log_error("Test mode is not yet supported with lock type %s",
vg->lock_type);
- unlock_and_release_vg(cmd, vg, lp->vg_name);
- goto_out;
- }
-
- if (!(lv = find_lv(vg, lp->lv_name))) {
- log_error("Can't find LV %s in VG %s", lp->lv_name, lp->vg_name);
- unlock_and_release_vg(cmd, vg, lp->vg_name);
- goto_out;
+ return ECMD_FAILED;
}
/*
- * Request a transient lock. If the LV is active, it has a persistent
- * lock already, and this request does nothing. If the LV is not
- * active, this acquires a transient lock that will be released when
- * the command exits.
- */
- if (!lockd_lv(cmd, lv, "ex", 0))
- goto_bad;
-
- /*
* lp->pvh holds the list of PVs available for allocation or removal
*/
if (lp->pv_count) {
if (!(lp->pvh = create_pv_list(cmd->mem, vg, lp->pv_count, lp->pvs, 0)))
- goto_bad;
+ return_ECMD_FAILED;
} else
lp->pvh = &vg->pvs;
@@ -3508,22 +3474,11 @@ static int lvconvert_single(struct cmd_context *cmd, struct lvconvert_params *lp
!(lp->replace_pvh = create_pv_list(cmd->mem, vg,
lp->replace_pv_count,
lp->replace_pvs, 0)))
- goto_bad;
+ return_ECMD_FAILED;
lp->lv_to_poll = lv;
- ret = _convert_and_add_to_poll_list(cmd, lp, lv);
-bad:
- unlock_vg(cmd, lp->vg_name);
-
- /* Unlock here so it's not held during polling. */
- if (!lockd_vg(cmd, lp->vg_name, "un", 0, &lockd_state))
- stack;
-
- release_vg(vg);
-out:
- init_ignore_suspended_devices(saved_ignore_suspended_devices);
- return ret;
+ return _lvconvert_and_add_to_poll_list(cmd, lp, lv);
}
static int _lvconvert_merge_single(struct cmd_context *cmd, struct logical_volume *lv,
@@ -3533,7 +3488,7 @@ static int _lvconvert_merge_single(struct cmd_context *cmd, struct logical_volum
lp->lv_to_poll = lv;
- return _convert_and_add_to_poll_list(cmd, lp, lv);
+ return _lvconvert_and_add_to_poll_list(cmd, lp, lv);
}
int lvconvert(struct cmd_context * cmd, int argc, char **argv)
@@ -3558,11 +3513,22 @@ int lvconvert(struct cmd_context * cmd, int argc, char **argv)
goto_out;
}
- if (lp.merge)
- ret = process_each_lv(cmd, argc, argv, READ_FOR_UPDATE, handle,
- &_lvconvert_merge_single);
- else
- ret = lvconvert_single(cmd, &lp);
+ if (lp.merge) {
+ ret = process_each_lv(cmd, argc, argv, NULL, NULL,
+ READ_FOR_UPDATE, handle, &_lvconvert_merge_single);
+ } else {
+ int saved_ignore_suspended_devices = ignore_suspended_devices();
+
+ if (lp.repair || lp.uncache) {
+ init_ignore_suspended_devices(1);
+ cmd->handles_missing_pvs = 1;
+ }
+
+ ret = process_each_lv(cmd, 0, NULL, lp.vg_name, lp.lv_name,
+ READ_FOR_UPDATE, handle, &_lvconvert_single);
+
+ init_ignore_suspended_devices(saved_ignore_suspended_devices);
+ }
dm_list_iterate_items(idl, &lp.idls) {
poll_ret = _lvconvert_poll_by_id(cmd, idl->id,
diff --git a/tools/lvdisplay.c b/tools/lvdisplay.c
index dd0ba48..e4d8bae 100644
--- a/tools/lvdisplay.c
+++ b/tools/lvdisplay.c
@@ -58,5 +58,5 @@ int lvdisplay(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- return process_each_lv(cmd, argc, argv, 0, NULL, &_lvdisplay_single);
+ return process_each_lv(cmd, argc, argv, NULL, NULL, 0, NULL, &_lvdisplay_single);
}
diff --git a/tools/lvremove.c b/tools/lvremove.c
index 18da1fa..d807d04 100644
--- a/tools/lvremove.c
+++ b/tools/lvremove.c
@@ -26,6 +26,6 @@ int lvremove(struct cmd_context *cmd, int argc, char **argv)
cmd->handles_missing_pvs = 1;
cmd->include_historical_lvs = 1;
- return process_each_lv(cmd, argc, argv, READ_FOR_UPDATE, NULL,
+ return process_each_lv(cmd, argc, argv, NULL, NULL, READ_FOR_UPDATE, NULL,
&lvremove_single);
}
diff --git a/tools/lvscan.c b/tools/lvscan.c
index 23d3d7f..528e54a 100644
--- a/tools/lvscan.c
+++ b/tools/lvscan.c
@@ -119,6 +119,5 @@ int lvscan(struct cmd_context *cmd, int argc, char **argv)
*/
}
- return process_each_lv(cmd, argc, argv, 0, NULL,
- &lvscan_single);
+ return process_each_lv(cmd, argc, argv, NULL, NULL, 0, NULL, &lvscan_single);
}
diff --git a/tools/reporter.c b/tools/reporter.c
index 04ef8f2..bd77513 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -833,7 +833,7 @@ static int _do_report(struct cmd_context *cmd, struct report_args *args)
case LVSINFOSTATUS:
/* fall through */
case LVS:
- r = process_each_lv(cmd, args->argc, args->argv, 0, handle,
+ r = process_each_lv(cmd, args->argc, args->argv, NULL, NULL, 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 :
@@ -857,7 +857,7 @@ static int _do_report(struct cmd_context *cmd, struct report_args *args)
0, handle, &_pvs_in_vg);
break;
case SEGS:
- r = process_each_lv(cmd, args->argc, args->argv, 0, handle,
+ r = process_each_lv(cmd, args->argc, args->argv, NULL, NULL, 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 :
diff --git a/tools/toollib.c b/tools/toollib.c
index 5383734..12dddc8 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -2489,6 +2489,7 @@ out:
*/
static int _get_arg_lvnames(struct cmd_context *cmd,
int argc, char **argv,
+ const char *one_vgname, const char *one_lvname,
struct dm_list *arg_vgnames,
struct dm_list *arg_lvnames,
struct dm_list *arg_tags)
@@ -2503,6 +2504,34 @@ static int _get_arg_lvnames(struct cmd_context *cmd,
const char *vgname_def;
unsigned dev_dir_found;
+ if (one_vgname) {
+ if (!str_list_add(cmd->mem, arg_vgnames,
+ dm_pool_strdup(cmd->mem, one_vgname))) {
+ log_error("strlist allocation failed.");
+ return ECMD_FAILED;
+ }
+
+ if (!one_lvname) {
+ if (!str_list_add(cmd->mem, arg_lvnames,
+ dm_pool_strdup(cmd->mem, one_vgname))) {
+ log_error("strlist allocation failed.");
+ return ECMD_FAILED;
+ }
+ } else {
+ vglv_sz = strlen(one_vgname) + strlen(one_lvname) + 2;
+ if (!(vglv = dm_pool_alloc(cmd->mem, vglv_sz)) ||
+ dm_snprintf(vglv, vglv_sz, "%s/%s", one_vgname, one_lvname) < 0) {
+ log_error("vg/lv string alloc failed.");
+ return ECMD_FAILED;
+ }
+ if (!str_list_add(cmd->mem, arg_lvnames, vglv)) {
+ log_error("strlist allocation failed.");
+ return ECMD_FAILED;
+ }
+ }
+ return ret_max;
+ }
+
for (; opt < argc; opt++) {
lv_name = argv[opt];
dev_dir_found = 0;
@@ -2687,8 +2716,12 @@ endvg:
/*
* Call process_single_lv() for each LV selected by the command line arguments.
*/
-int process_each_lv(struct cmd_context *cmd, int argc, char **argv, uint32_t read_flags,
- struct processing_handle *handle, process_single_lv_fn_t process_single_lv)
+int process_each_lv(struct cmd_context *cmd,
+ int argc, char **argv,
+ const char *one_vgname, const char *one_lvname,
+ uint32_t read_flags,
+ struct processing_handle *handle,
+ process_single_lv_fn_t process_single_lv)
{
int handle_supplied = handle != NULL;
struct dm_list arg_tags; /* str_list */
@@ -2713,7 +2746,7 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv, uint32_t rea
/*
* Find any LVs, VGs or tags explicitly provided on the command line.
*/
- if ((ret = _get_arg_lvnames(cmd, argc, argv, &arg_vgnames, &arg_lvnames, &arg_tags) != ECMD_PROCESSED)) {
+ if ((ret = _get_arg_lvnames(cmd, argc, argv, one_vgname, one_lvname, &arg_vgnames, &arg_lvnames, &arg_tags) != ECMD_PROCESSED)) {
ret_max = ret;
goto_out;
}
diff --git a/tools/toollib.h b/tools/toollib.h
index a79c426..a366e68 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -121,6 +121,7 @@ int process_each_segment_in_pv(struct cmd_context *cmd,
process_single_pvseg_fn_t process_single_pvseg);
int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
+ const char *one_vgname, const char *one_lvname,
uint32_t flags, struct processing_handle *handle,
process_single_lv_fn_t process_single_lv);
diff --git a/tools/vgmknodes.c b/tools/vgmknodes.c
index 41b1c6a..81580b7 100644
--- a/tools/vgmknodes.c
+++ b/tools/vgmknodes.c
@@ -33,6 +33,5 @@ int vgmknodes(struct cmd_context *cmd, int argc, char **argv)
if (!lv_mknodes(cmd, NULL))
return_ECMD_FAILED;
- return process_each_lv(cmd, argc, argv, LCK_VG_READ, NULL,
- &_vgmknodes_single);
+ return process_each_lv(cmd, argc, argv, NULL, NULL, LCK_VG_READ, NULL, &_vgmknodes_single);
}
7 years, 11 months