master - dmsetup: fix error propagation in _display_info_cols()
by Bryn Reeves
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=29b9ccd261be025aaf7...
Commit: 29b9ccd261be025aaf75e58e5d2547e818ef22c3
Parent: f96fd9961d1a80999a38b45c1d173e3df1de83e5
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Thu Jun 28 14:25:30 2018 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Jun 28 14:25:30 2018 +0100
dmsetup: fix error propagation in _display_info_cols()
Commit 3f35146 added a check on the value returned by the
_display_info_cols() function:
1024 if (!_switches[COLS_ARG])
1025 _display_info_long(dmt, &info);
1026 else
1027 r = _display_info_cols(dmt, &info);
1028
1029 return r;
This exposes a bug in the dmstats code in _display_info_cols:
the fact that a device has no regions is explicitly not an error
(and is documented as such in the code), but since the return
code is not changed before leaving the function it is now treated
as an error leading to:
# dmstats list
Command failed.
When no regions exist.
Set the return code to the correct value before returning.
---
libdm/dm-tools/dmsetup.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/libdm/dm-tools/dmsetup.c b/libdm/dm-tools/dmsetup.c
index 44386a6..fb1a574 100644
--- a/libdm/dm-tools/dmsetup.c
+++ b/libdm/dm-tools/dmsetup.c
@@ -943,8 +943,10 @@ static int _display_info_cols(struct dm_task *dmt, struct dm_info *info)
goto_out;
/* No regions to report is not an error */
- if (!dm_stats_get_nr_regions(obj.stats))
+ if (!dm_stats_get_nr_regions(obj.stats)) {
+ r = 1;
goto out;
+ }
}
/* group report with no groups? */
5 years, 3 months
master - dmsetup: fix error propagation in _display_info_cols()
by Bryn Reeves
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=29b9ccd261be025aaf7...
Commit: 29b9ccd261be025aaf75e58e5d2547e818ef22c3
Parent: f96fd9961d1a80999a38b45c1d173e3df1de83e5
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Thu Jun 28 14:25:30 2018 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Jun 28 14:25:30 2018 +0100
dmsetup: fix error propagation in _display_info_cols()
Commit 3f35146 added a check on the value returned by the
_display_info_cols() function:
1024 if (!_switches[COLS_ARG])
1025 _display_info_long(dmt, &info);
1026 else
1027 r = _display_info_cols(dmt, &info);
1028
1029 return r;
This exposes a bug in the dmstats code in _display_info_cols:
the fact that a device has no regions is explicitly not an error
(and is documented as such in the code), but since the return
code is not changed before leaving the function it is now treated
as an error leading to:
# dmstats list
Command failed.
When no regions exist.
Set the return code to the correct value before returning.
---
libdm/dm-tools/dmsetup.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/libdm/dm-tools/dmsetup.c b/libdm/dm-tools/dmsetup.c
index 44386a6..fb1a574 100644
--- a/libdm/dm-tools/dmsetup.c
+++ b/libdm/dm-tools/dmsetup.c
@@ -943,8 +943,10 @@ static int _display_info_cols(struct dm_task *dmt, struct dm_info *info)
goto_out;
/* No regions to report is not an error */
- if (!dm_stats_get_nr_regions(obj.stats))
+ if (!dm_stats_get_nr_regions(obj.stats)) {
+ r = 1;
goto out;
+ }
}
/* group report with no groups? */
5 years, 3 months
master - Revert "man: fix lvreduce example"
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f96fd9961d1a80999a3...
Commit: f96fd9961d1a80999a38b45c1d173e3df1de83e5
Parent: 163a30d7844e07a678c5eea8f38b5f5b2ea58d24
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Jun 27 09:19:01 2018 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Jun 27 09:20:21 2018 -0500
Revert "man: fix lvreduce example"
-l -3 is correct, meaning reduce by 3.
This reverts commit d5bcc56eefde8349ffee93d0411c6f9fd71ceb84.
---
man/lvreduce.8_end | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/man/lvreduce.8_end b/man/lvreduce.8_end
index a9cb035..53f1ac7 100644
--- a/man/lvreduce.8_end
+++ b/man/lvreduce.8_end
@@ -2,4 +2,4 @@
Reduce the size of an LV by 3 logical extents:
.br
-.B lvreduce -l 3 vg00/lvol1
+.B lvreduce -l -3 vg00/lvol1
5 years, 3 months
master - man: fix lvreduce example
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=163a30d7844e07a678c...
Commit: 163a30d7844e07a678c5eea8f38b5f5b2ea58d24
Parent: a14f21bf1ddbb93b13a917cad8720fed6c94d6de
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Jun 27 08:58:22 2018 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Jun 27 08:59:41 2018 -0500
man: fix lvreduce example
---
man/lvreduce.8_end | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/man/lvreduce.8_end b/man/lvreduce.8_end
index 53f1ac7..a9cb035 100644
--- a/man/lvreduce.8_end
+++ b/man/lvreduce.8_end
@@ -2,4 +2,4 @@
Reduce the size of an LV by 3 logical extents:
.br
-.B lvreduce -l -3 vg00/lvol1
+.B lvreduce -l 3 vg00/lvol1
5 years, 3 months
master - bcache: Fix null pointer dereferencing
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a14f21bf1ddbb93b13a...
Commit: a14f21bf1ddbb93b13a917cad8720fed6c94d6de
Parent: 4194fc9bbdc9107120ba09c22e56612d854fdd41
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Tue Jun 26 17:04:18 2018 +0200
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Tue Jun 26 17:04:18 2018 +0200
bcache: Fix null pointer dereferencing
---
lib/device/bcache.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/device/bcache.c b/lib/device/bcache.c
index f315b2a..8d55c36 100644
--- a/lib/device/bcache.c
+++ b/lib/device/bcache.c
@@ -528,11 +528,13 @@ static bool _init_free_list(struct bcache *cache, unsigned count, unsigned pgsiz
if (!data)
return false;
- cache->raw_data = data;
cache->raw_blocks = malloc(count * sizeof(*cache->raw_blocks));
+ if (!cache->raw_blocks) {
+ free(data);
+ return false;
+ }
- if (!cache->raw_blocks)
- free(cache->raw_data);
+ cache->raw_data = data;
for (i = 0; i < count; i++) {
struct block *b = cache->raw_blocks + i;
5 years, 3 months
master - device_mapper: add new _dm_task_create_device_status
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4194fc9bbdc9107120b...
Commit: 4194fc9bbdc9107120ba09c22e56612d854fdd41
Parent: 739a213d2ee01cc95861c342fde73e87088de6bb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Jun 23 23:02:24 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jun 25 15:07:55 2018 +0200
device_mapper: add new _dm_task_create_device_status
Introduce new function _dm_task_create_device_status for grabbing
status of device for better code sharing.
---
device_mapper/libdm-deptree.c | 32 +++++++++++++++++++++++---------
1 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/device_mapper/libdm-deptree.c b/device_mapper/libdm-deptree.c
index 5327b2e..bb552b6 100644
--- a/device_mapper/libdm-deptree.c
+++ b/device_mapper/libdm-deptree.c
@@ -1382,20 +1382,14 @@ out:
return r;
}
-static int _thin_pool_get_status(struct dm_tree_node *dnode,
- struct dm_status_thin_pool *s)
+static struct dm_task *_dm_task_create_device_status(uint32_t major, uint32_t minor)
{
struct dm_task *dmt;
- int r = 0;
- uint64_t start, length;
- char *type = NULL;
- char *params = NULL;
if (!(dmt = dm_task_create(DM_DEVICE_STATUS)))
- return_0;
+ return_NULL;
- if (!dm_task_set_major(dmt, dnode->info.major) ||
- !dm_task_set_minor(dmt, dnode->info.minor)) {
+ if (!dm_task_set_major(dmt, major) || !dm_task_set_minor(dmt, minor)) {
log_error("Failed to set major minor.");
goto out;
}
@@ -1406,6 +1400,26 @@ static int _thin_pool_get_status(struct dm_tree_node *dnode,
if (!dm_task_run(dmt))
goto_out;
+ return dmt;
+out:
+ dm_task_destroy(dmt);
+
+ return NULL;
+}
+
+static int _thin_pool_get_status(struct dm_tree_node *dnode,
+ struct dm_status_thin_pool *s)
+{
+ struct dm_task *dmt;
+ int r = 0;
+ uint64_t start, length;
+ char *type = NULL;
+ char *params = NULL;
+
+ if (!(dmt = _dm_task_create_device_status(dnode->info.major,
+ dnode->info.minor)))
+ return_0;
+
dm_get_next_target(dmt, NULL, &start, &length, &type, ¶ms);
if (!type || (strcmp(type, "thin-pool") != 0)) {
5 years, 3 months
master - device_mapper: split code for sending message
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=739a213d2ee01cc9586...
Commit: 739a213d2ee01cc95861c342fde73e87088de6bb
Parent: a1c81c009a59c2476ffca8a8cf2cd06f0674e46d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Jun 23 21:00:40 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jun 25 15:07:55 2018 +0200
device_mapper: split code for sending message
Move message sending from _thin_pool_node_message to
new _node_message for possible better code sharing.
---
device_mapper/libdm-deptree.c | 63 ++++++++++++++++++++++++-----------------
1 files changed, 37 insertions(+), 26 deletions(-)
diff --git a/device_mapper/libdm-deptree.c b/device_mapper/libdm-deptree.c
index 4875858..5327b2e 100644
--- a/device_mapper/libdm-deptree.c
+++ b/device_mapper/libdm-deptree.c
@@ -1428,9 +1428,42 @@ out:
return r;
}
-static int _thin_pool_node_message(struct dm_tree_node *dnode, struct thin_message *tm)
+static int _node_message(uint32_t major, uint32_t minor,
+ int expected_errno, const char *message)
{
struct dm_task *dmt;
+ int r;
+
+ if (!(dmt = dm_task_create(DM_DEVICE_TARGET_MSG)))
+ return_0;
+
+ if (!dm_task_set_major(dmt, major) ||
+ !dm_task_set_minor(dmt, minor)) {
+ log_error("Failed to set message major minor.");
+ goto out;
+ }
+
+ if (!dm_task_set_message(dmt, message))
+ goto_out;
+
+ /* Internal functionality of dm_task */
+ dmt->expected_errno = expected_errno;
+
+ if (!dm_task_run(dmt)) {
+ log_error("Failed to process message \"%s\".", message);
+ goto out;
+ }
+
+ r = 1;
+out:
+ dm_task_destroy(dmt);
+
+ return r;
+}
+
+
+static int _thin_pool_node_message(struct dm_tree_node *dnode, struct thin_message *tm)
+{
struct dm_thin_message *m = &tm->message;
char buf[64];
int r;
@@ -1470,33 +1503,11 @@ static int _thin_pool_node_message(struct dm_tree_node *dnode, struct thin_messa
return 0;
}
- r = 0;
-
- if (!(dmt = dm_task_create(DM_DEVICE_TARGET_MSG)))
+ if (!_node_message(dnode->info.major, dnode->info.minor,
+ tm->expected_errno, buf))
return_0;
- if (!dm_task_set_major(dmt, dnode->info.major) ||
- !dm_task_set_minor(dmt, dnode->info.minor)) {
- log_error("Failed to set message major minor.");
- goto out;
- }
-
- if (!dm_task_set_message(dmt, buf))
- goto_out;
-
- /* Internal functionality of dm_task */
- dmt->expected_errno = tm->expected_errno;
-
- if (!dm_task_run(dmt)) {
- log_error("Failed to process thin pool message \"%s\".", buf);
- goto out;
- }
-
- r = 1;
-out:
- dm_task_destroy(dmt);
-
- return r;
+ return 1;
}
static struct load_segment *_get_last_load_segment(struct dm_tree_node *node)
5 years, 3 months
master - device_mapper: split _node_send_message
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a1c81c009a59c2476ff...
Commit: a1c81c009a59c2476ffca8a8cf2cd06f0674e46d
Parent: 19b92ae3f3185919a0a1cef849a9a003101d4429
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Jun 23 20:50:36 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jun 25 15:07:55 2018 +0200
device_mapper: split _node_send_message
For better code reuse split _node_send_messages into commont
messaging part and separate _thin_pool_node_send_messages.
Patch makes it possible to better reuse common code for messaging
other targets.
---
device_mapper/libdm-deptree.c | 56 ++++++++++++++++++++++++-----------------
1 files changed, 33 insertions(+), 23 deletions(-)
diff --git a/device_mapper/libdm-deptree.c b/device_mapper/libdm-deptree.c
index d177374..4875858 100644
--- a/device_mapper/libdm-deptree.c
+++ b/device_mapper/libdm-deptree.c
@@ -1510,34 +1510,14 @@ static struct load_segment *_get_last_load_segment(struct dm_tree_node *node)
}
/* For preload pass only validate pool's transaction_id */
-static int _node_send_messages(struct dm_tree_node *dnode,
- const char *uuid_prefix,
- size_t uuid_prefix_len,
- int send)
+static int _thin_pool_node_send_messages(struct dm_tree_node *dnode,
+ struct load_segment *seg,
+ int send)
{
- struct load_segment *seg;
struct thin_message *tmsg;
struct dm_status_thin_pool stp;
- const char *uuid;
int have_messages;
- if (!dnode->info.exists)
- return 1;
-
- if (!(seg = _get_last_load_segment(dnode)))
- return_0;
-
- if (seg->type != SEG_THIN_POOL)
- return 1;
-
- if (!(uuid = dm_tree_node_get_uuid(dnode)))
- return_0;
-
- if (!_uuid_prefix_matches(uuid, uuid_prefix, uuid_prefix_len)) {
- log_debug_activation("UUID \"%s\" does not match.", uuid);
- return 1;
- }
-
if (!_thin_pool_get_status(dnode, &stp))
return_0;
@@ -1582,6 +1562,36 @@ static int _node_send_messages(struct dm_tree_node *dnode,
return 1;
}
+static int _node_send_messages(struct dm_tree_node *dnode,
+ const char *uuid_prefix,
+ size_t uuid_prefix_len,
+ int send)
+{
+ struct load_segment *seg;
+ const char *uuid;
+
+ if (!dnode->info.exists || !dnode->info.live_table)
+ return 1;
+
+ if (!(uuid = dm_tree_node_get_uuid(dnode)))
+ return_0;
+
+ if (!_uuid_prefix_matches(uuid, uuid_prefix, uuid_prefix_len)) {
+ log_debug_activation("UUID \"%s\" does not match.", uuid);
+ return 1;
+ }
+
+ if (!(seg = _get_last_load_segment(dnode)))
+ return_0;
+
+ switch (seg->type) {
+ case SEG_THIN_POOL: return _thin_pool_node_send_messages(dnode, seg, send);
+ }
+
+ return 1;
+}
+
+
/*
* FIXME Don't attempt to deactivate known internal dependencies.
*/
5 years, 3 months
master - tests: update with --yes
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=19b92ae3f3185919a0a...
Commit: 19b92ae3f3185919a0a1cef849a9a003101d4429
Parent: cea88a9e4ee5a2aa28b52d673fba66327e88ff6e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Jun 24 20:49:59 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jun 25 15:07:55 2018 +0200
tests: update with --yes
vgcfgrestore needs to confirm restore while LVs from VG are present.
---
test/shell/thin-restore.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/shell/thin-restore.sh b/test/shell/thin-restore.sh
index 3682a8c..d8bae3c 100644
--- a/test/shell/thin-restore.sh
+++ b/test/shell/thin-restore.sh
@@ -33,7 +33,7 @@ vgcfgbackup -f backup $vg
# use of --force is mandatory
not vgcfgrestore -f backup $vg
-vgcfgrestore -f backup --force $vg
+vgcfgrestore -y -f backup --force $vg
check lv_field $vg/pool transaction_id 1
5 years, 3 months
master - lv_manip: use vgmem pool
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=cea88a9e4ee5a2aa28b...
Commit: cea88a9e4ee5a2aa28b52d673fba66327e88ff6e
Parent: 357e9f9572361ec2ea89ca0bf165a30545fa747f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Jun 23 11:59:35 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jun 25 15:07:55 2018 +0200
lv_manip: use vgmem pool
Switch to vgmem pool for allocation associated with modification
of particular VG.
---
lib/metadata/lv_manip.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 11a6927..7b68313 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5901,7 +5901,7 @@ struct dm_list *build_parallel_areas_from_lv(struct logical_volume *lv,
uint32_t raid_multiple;
struct lv_segment *seg = first_seg(lv);
- if (!(parallel_areas = dm_pool_alloc(cmd->mem, sizeof(*parallel_areas)))) {
+ if (!(parallel_areas = dm_pool_alloc(lv->vg->vgmem, sizeof(*parallel_areas)))) {
log_error("parallel_areas allocation failed");
return NULL;
}
@@ -5910,7 +5910,7 @@ struct dm_list *build_parallel_areas_from_lv(struct logical_volume *lv,
do {
if (!spvs || !create_single_list) {
- if (!(spvs = dm_pool_zalloc(cmd->mem, sizeof(*spvs)))) {
+ if (!(spvs = dm_pool_zalloc(lv->vg->vgmem, sizeof(*spvs)))) {
log_error("allocation failed");
return NULL;
}
5 years, 3 months