master - clean-up: Another functiont that can use 'lv_layer'
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f5cd9c3563a77f...
Commit: f5cd9c3563a77f65b039923833ee13f3e22a959f
Parent: a4870c79cad46e6063862d7cc828a2bbef9251c3
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Mon Feb 4 17:10:16 2013 -0600
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Mon Feb 4 17:10:16 2013 -0600
clean-up: Another functiont that can use 'lv_layer'
lib/activate/dev_manager.c:dev_manager_raid_status() can also use
the new 'lv_layer' function.
---
lib/activate/dev_manager.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 1916d3e..e8f449c 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1031,7 +1031,7 @@ int dev_manager_raid_status(struct dev_manager *dm,
uint64_t start, length;
char *type = NULL;
char *params = NULL;
- const char *layer = (lv_is_origin(lv)) ? "real" : NULL;
+ const char *layer = lv_layer(lv);
/* Build dlid for the thin pool layer */
if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, layer)))
11 years, 3 months
master - thin: use noflush for obtaining transaction_id
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a4870c79cad46e...
Commit: a4870c79cad46e6063862d7cc828a2bbef9251c3
Parent: 153ce89af36e716ace78182d8fe0668a6e98053d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 17 10:54:41 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 4 19:05:56 2013 +0100
thin: use noflush for obtaining transaction_id
Do not flush thin pool data, when reading transation_id status.
---
WHATS_NEW | 1 +
lib/activate/activate.c | 2 +-
lib/activate/dev_manager.c | 6 +++++-
lib/activate/dev_manager.h | 3 ++-
libdm/libdm-deptree.c | 3 +++
5 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index cfaa152..272c6c8 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Avoid flushing thin pool when quering for transaction_id.
Add internal function lv_layer() to obtain layer name for LV.
Report partial and in-sync RAID attribute based on kernel status
Fix blkdeactivate to handle nested mountpoints and mangled mount paths.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index e39c04a..6187828 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -888,7 +888,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)))
+ if (!(r = dev_manager_thin_pool_status(dm, lv, &status, 1)))
stack;
else
*transaction_id = status->transaction_id;
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index e4cb0c3..1916d3e 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1124,7 +1124,8 @@ static int _belong_to_vg(const char *vgname, const char *name)
int dev_manager_thin_pool_status(struct dev_manager *dm,
const struct logical_volume *lv,
- struct dm_status_thin_pool **status)
+ struct dm_status_thin_pool **status,
+ int noflush)
{
const char *dlid;
struct dm_task *dmt;
@@ -1146,6 +1147,9 @@ int dev_manager_thin_pool_status(struct dev_manager *dm,
if (!dm_task_no_open_count(dmt))
log_error("Failed to disable open_count.");
+ if (noflush && !dm_task_no_flush(dmt))
+ log_warn("Can't set no_flush.");
+
if (!dm_task_run(dmt))
goto_out;
diff --git a/lib/activate/dev_manager.h b/lib/activate/dev_manager.h
index e363aed..a4556e7 100644
--- a/lib/activate/dev_manager.h
+++ b/lib/activate/dev_manager.h
@@ -59,7 +59,8 @@ int dev_manager_raid_status(struct dev_manager *dm,
struct dm_status_raid **status);
int dev_manager_thin_pool_status(struct dev_manager *dm,
const struct logical_volume *lv,
- struct dm_status_thin_pool **status);
+ struct dm_status_thin_pool **status,
+ int noflush);
int dev_manager_thin_pool_percent(struct dev_manager *dm,
const struct logical_volume *lv,
int metadata, percent_t *percent);
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 6a73859..5e938d7 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -1360,6 +1360,9 @@ static int _thin_pool_status_transaction_id(struct dm_tree_node *dnode, uint64_t
goto out;
}
+ if (!dm_task_no_flush(dmt))
+ log_warn("Can't set no_flush flag."); /* Non fatal */
+
if (!dm_task_run(dmt))
goto_out;
11 years, 3 months
master - cleanup: comment update
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=153ce89af36e71...
Commit: 153ce89af36e716ace78182d8fe0668a6e98053d
Parent: b37a0a39e3c80abdab2c3dc4522411c7aa9eec5e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jan 25 15:29:42 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 4 19:05:43 2013 +0100
cleanup: comment update
Just update code comment and use single line if().
---
lib/metadata/lv_manip.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index c1437eb..50e42dc 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -273,7 +273,7 @@ struct lv_segment *alloc_lv_segment(const struct segment_type *segtype,
dm_list_init(&seg->thin_messages);
if (thin_pool_lv) {
- /* If this thin volume, thin snapshot is being created */
+ /* If this is thin volume, thin snapshot is being created */
if (lv_is_thin_volume(thin_pool_lv)) {
seg->transaction_id = first_seg(first_seg(thin_pool_lv)->pool_lv)->transaction_id;
if (!attach_pool_lv(seg, first_seg(thin_pool_lv)->pool_lv, thin_pool_lv))
@@ -565,10 +565,8 @@ static int _lv_reduce(struct logical_volume *lv, uint32_t extents, int delete)
if (seg->metadata_lv && !lv_remove(seg->metadata_lv))
return_0;
- if (seg->pool_lv) {
- if (!detach_pool_lv(seg))
- return_0;
- }
+ if (seg->pool_lv && !detach_pool_lv(seg))
+ return_0;
dm_list_del(&seg->list);
reduction = seg->len;
11 years, 3 months
master - cleanup: indent line
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b37a0a39e3c80a...
Commit: b37a0a39e3c80abdab2c3dc4522411c7aa9eec5e
Parent: d2eae42c0e3553fa13b8bc8f25b9c87fb2554861
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Jan 19 12:04:17 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 4 19:01:11 2013 +0100
cleanup: indent line
---
lib/config/config.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/config/config.h b/lib/config/config.h
index d789ade..5c36f4d 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -31,7 +31,7 @@ struct dm_config_tree *config_file_open(const char *filename, int keep_open);
int config_file_read_fd(struct dm_config_tree *cft, struct device *dev,
off_t offset, size_t size, off_t offset2, size_t size2,
checksum_fn_t checksum_fn, uint32_t checksum);
- int config_file_read(struct dm_config_tree *cft);
+int config_file_read(struct dm_config_tree *cft);
int config_write(struct dm_config_tree *cft, const char *file,
int argc, char **argv);
void config_file_destroy(struct dm_config_tree *cft);
11 years, 3 months
master - libdm: support newer thin pool status parameters
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d2eae42c0e3553...
Commit: d2eae42c0e3553fa13b8bc8f25b9c87fb2554861
Parent: c1becaefe5792a3cd9484e76bb8738f6082a1249
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Dec 10 10:23:17 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 4 19:01:10 2013 +0100
libdm: support newer thin pool status parameters
Support read_only and discards information.
---
WHATS_NEW_DM | 1 +
libdm/libdevmapper.h | 8 ++++++++
libdm/libdm-deptree.c | 15 +++++++++++++--
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 2b820e1..0052e5a 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.78 -
===================================
+ Extend support for status info of thin pool target.
Fix segfault for truncated string token in config file after the first '"'.
Close open dmeventd FIFO file descriptors on exec (FD_CLOEXEC).
Fix resource leak in error path of dmeventd's umount of thin volume.
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index eaa68e9..458d642 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -279,6 +279,12 @@ int dm_get_status_raid(struct dm_pool *mem, const char *params,
/*
* Parse params from STATUS call for thin_pool target
*/
+typedef enum {
+ DM_THIN_DISCARDS_IGNORE,
+ DM_THIN_DISCARDS_NO_PASSDOWN,
+ DM_THIN_DISCARDS_PASSDOWN
+} dm_thin_discards_t;
+
struct dm_status_thin_pool {
uint64_t transaction_id;
uint64_t used_metadata_blocks;
@@ -286,6 +292,8 @@ struct dm_status_thin_pool {
uint64_t used_data_blocks;
uint64_t total_data_blocks;
uint64_t held_metadata_root;
+ uint32_t read_only;
+ dm_thin_discards_t discards;
};
int dm_get_status_thin_pool(struct dm_pool *mem, const char *params,
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index de4958e..6a73859 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -3295,6 +3295,7 @@ int dm_get_status_thin_pool(struct dm_pool *mem, const char *params,
struct dm_status_thin_pool **status)
{
struct dm_status_thin_pool *s;
+ int pos;
if (!(s = dm_pool_zalloc(mem, sizeof(struct dm_status_thin_pool)))) {
log_error("Failed to allocate thin_pool status structure.");
@@ -3302,16 +3303,26 @@ int dm_get_status_thin_pool(struct dm_pool *mem, const char *params,
}
/* FIXME: add support for held metadata root */
- if (sscanf(params, "%" PRIu64 " %" PRIu64 "/%" PRIu64 " %" PRIu64 "/%" PRIu64,
+ if (sscanf(params, "%" PRIu64 " %" PRIu64 "/%" PRIu64 " %" PRIu64 "/%" PRIu64 "%n",
&s->transaction_id,
&s->used_metadata_blocks,
&s->total_metadata_blocks,
&s->used_data_blocks,
- &s->total_data_blocks) != 5) {
+ &s->total_data_blocks, &pos) < 5) {
log_error("Failed to parse thin pool params: %s.", params);
return 0;
}
+ /* New status flags */
+ if (strstr(params + pos, "no_discard_passdown"))
+ s->discards = DM_THIN_DISCARDS_NO_PASSDOWN;
+ else if (strstr(params + pos, "ignore_discard"))
+ s->discards = DM_THIN_DISCARDS_IGNORE;
+ else /* default discard_passdown */
+ s->discards = DM_THIN_DISCARDS_PASSDOWN;
+
+ s->read_only = (strstr(params + pos, "ro ")) ? 1 : 0;
+
*status = s;
return 1;
11 years, 3 months
master - test: regression test for lvmetad error
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c1becaefe5792a...
Commit: c1becaefe5792a3cd9484e76bb8738f6082a1249
Parent: 8ed0b6f312e0e9b5566934c5d30f79c1450fba2f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jan 7 10:57:59 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 4 19:01:10 2013 +0100
test: regression test for lvmetad error
---
test/shell/snapshot-lvm1.sh | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/test/shell/snapshot-lvm1.sh b/test/shell/snapshot-lvm1.sh
new file mode 100644
index 0000000..cb55ed6
--- /dev/null
+++ b/test/shell/snapshot-lvm1.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+# Copyright (C) 2013 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# regression test for lvmetad reporting error:
+# Internal error: LV snap_with_lvm1_meta (00000000000000000000000000000001) missing from preload metadata
+
+. lib/test
+
+aux prepare_devs 2
+
+vgcreate --metadatatype 1 $vg $(cat DEVICES)
+
+# Make origin volume
+lvcreate -l5 $vg -n origin
+
+# Create a snap of origin
+lvcreate -s $vg/origin -n snap_with_lvm1_meta -l4
+
+# Remove volume snapper/snap_with_lvm1_meta
+lvremove -f $vg/snap_with_lvm1_meta
11 years, 3 months
master - thin: replace is_active with send_messages
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8ed0b6f312e0e9...
Commit: 8ed0b6f312e0e9b5566934c5d30f79c1450fba2f
Parent: 4af4241ba4f749ee64375e7e80fecf6bda67f1e8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 17 10:35:27 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 4 19:01:10 2013 +0100
thin: replace is_active with send_messages
Since is_active is only used for thinp
replace struct member with more meaningful
send_messages flag
---
lib/activate/activate.h | 2 +-
lib/activate/dev_manager.c | 3 +--
lib/thin/thin.c | 2 +-
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index 4db7183..df4120c 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -35,7 +35,7 @@ struct lv_activate_opts {
int origin_only;
int no_merging;
int real_pool;
- int is_activate;
+ int send_messages;
int skip_in_use;
unsigned revert;
unsigned read_only;
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index de42b3b..e4cb0c3 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -2388,8 +2388,6 @@ static int _tree_action(struct dev_manager *dm, struct logical_volume *lv,
char *dlid;
int r = 0;
- laopts->is_activate = (action == ACTIVATE);
-
if (!(dtree = _create_partial_dtree(dm, lv, laopts->origin_only)))
return_0;
@@ -2471,6 +2469,7 @@ out_no_root:
int dev_manager_activate(struct dev_manager *dm, struct logical_volume *lv,
struct lv_activate_opts *laopts)
{
+ laopts->send_messages = 1;
if (!_tree_action(dm, lv, laopts, ACTIVATE))
return_0;
diff --git a/lib/thin/thin.c b/lib/thin/thin.c
index 3f74588..8c0ec82 100644
--- a/lib/thin/thin.c
+++ b/lib/thin/thin.c
@@ -305,7 +305,7 @@ static int _thin_pool_add_target_line(struct dev_manager *dm,
* Also transation_id is checked only when snapshot origin is active.
* (This might change later)
*/
- if (!laopts->is_activate)
+ if (!laopts->send_messages)
return 1;
dm_list_iterate_items(lmsg, &seg->thin_messages) {
11 years, 3 months
master - use lv_layer
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4af4241ba4f749...
Commit: 4af4241ba4f749ee64375e7e80fecf6bda67f1e8
Parent: ca7abbce8a705c1e690bcc2b0c08c4b510843046
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Feb 2 00:16:36 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 4 19:01:10 2013 +0100
use lv_layer
---
lib/activate/dev_manager.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index fda5bdc..de42b3b 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-2012 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2013 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -827,7 +827,7 @@ int dev_manager_transient(struct dev_manager *dm, struct logical_volume *lv)
char *type = NULL;
char *params = NULL;
char *dlid = NULL;
- const char *layer = lv_is_origin(lv) ? "real" : NULL;
+ const char *layer = lv_layer(lv);
const struct dm_list *segh = &lv->segments;
struct lv_segment *seg = NULL;
@@ -998,7 +998,7 @@ int dev_manager_mirror_percent(struct dev_manager *dm,
char *name;
const char *dlid;
const char *target_type = first_seg(lv)->segtype->name;
- const char *layer = (lv_is_origin(lv)) ? "real" : NULL;
+ const char *layer = lv_layer(lv);
/*
* Build a name for the top layer.
@@ -1193,7 +1193,7 @@ int dev_manager_thin_percent(struct dev_manager *dm,
{
char *name;
const char *dlid;
- const char *layer = lv_is_origin(lv) ? "real" : NULL;
+ const char *layer = lv_layer(lv);
/* Build a name for the top layer */
if (!(name = dm_build_dm_name(dm->mem, lv->vg->name, lv->name, layer)))
11 years, 3 months
master - activate: add lv_layer function
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ca7abbce8a705c...
Commit: ca7abbce8a705c1e690bcc2b0c08c4b510843046
Parent: 4f439707fd4a8837f930c14076bc662ca5c19844
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Feb 1 11:09:34 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 4 19:01:10 2013 +0100
activate: add lv_layer function
Add function to return layer name for LV.
---
WHATS_NEW | 1 +
lib/activate/activate.c | 14 ++++----------
lib/metadata/lv.c | 10 ++++++++++
lib/metadata/lv.h | 1 +
4 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index ba8d148..cfaa152 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Add internal function lv_layer() to obtain layer name for LV.
Report partial and in-sync RAID attribute based on kernel status
Fix blkdeactivate to handle nested mountpoints and mangled mount paths.
Set locales with LC_ALL instead of lower priority LANG variable.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index ac19bd2..e39c04a 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -604,7 +604,6 @@ int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, int use_la
struct lvinfo *info, int with_open_count, int with_read_ahead)
{
struct dm_info dminfo;
- const char *layer;
if (!activation())
return 0;
@@ -621,15 +620,10 @@ int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, int use_la
fs_unlock(); /* For non clustered - wait if there are non-delete ops */
}
- if (use_layer && lv_is_thin_pool(lv))
- layer = "tpool";
- else if (use_layer && lv_is_origin(lv))
- layer = "real";
- else
- layer = NULL;
-
- if (!dev_manager_info(lv->vg->cmd->mem, lv, layer, with_open_count,
- with_read_ahead, &dminfo, &info->read_ahead))
+ if (!dev_manager_info(lv->vg->cmd->mem, lv,
+ (use_layer) ? lv_layer(lv) : NULL,
+ with_open_count, with_read_ahead,
+ &dminfo, &info->read_ahead))
return_0;
info->exists = dminfo.exists;
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index b571ffd..c27ef08 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -225,6 +225,16 @@ char *lv_metadata_lv_dup(struct dm_pool *mem, const struct logical_volume *lv)
dm_pool_strdup(mem, first_seg(lv)->metadata_lv->name) : NULL;
}
+const char *lv_layer(const struct logical_volume *lv)
+{
+ if (lv_is_thin_pool(lv))
+ return "tpool";
+ else if (lv_is_origin(lv))
+ return "real";
+
+ return NULL;
+}
+
int lv_kernel_minor(const struct logical_volume *lv)
{
struct lvinfo info;
diff --git a/lib/metadata/lv.h b/lib/metadata/lv.h
index 838b002..b1078bb 100644
--- a/lib/metadata/lv.h
+++ b/lib/metadata/lv.h
@@ -82,4 +82,5 @@ char *lv_time_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_host_dup(struct dm_pool *mem, const struct logical_volume *lv);
int lv_set_creation(struct logical_volume *lv,
const char *hostname, uint64_t timestamp);
+const char *lv_layer(const struct logical_volume *lv);
#endif /* _LVM_LV_H */
11 years, 3 months
master - libdm: fix segault for truncated string token.
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4f439707fd4a88...
Commit: 4f439707fd4a8837f930c14076bc662ca5c19844
Parent: 9f433e6ee34c0ff94017c940aac301bc28d7e233
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Feb 1 11:07:44 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 4 19:01:10 2013 +0100
libdm: fix segault for truncated string token.
This patch fixes problem reported here:
https://www.redhat.com/archives/dm-devel/2013-January/msg00311.html
Fixing it by separating function for duplicating string token.
---
When /etc/lvm/lvm.conf is truncated at the first '"' of a line, all LVM
utilities crash with a segfault.
The segfault only seems to occur if the last character is the first '"'
(double quote) of a line. If you truncate it at any other point, lvm
detects the error and report parse error
lvm.conf ends like this.
$hexdump -C lvm.conf
....
69 72 20 3d 20 22 2f 64 65 76 22 0a 0a 0a 20 20 |ir = "/dev"... |
20 20 23 20 41 6e 20 61 72 72 61 79 20 6f 66 20 | # An array of |
64 69 72 65 63 74 6f 72 69 65 73 20 74 68 61 74 |directories that|
20 63 6f 6e 74 61 69 6e 20 74 68 65 20 64 65 76 | contain the dev|
69 63 65 20 6e 6f 64 65 73 20 79 6f 75 20 77 69 |ice nodes you wi|
73 68 0a 20 20 20 20 23 20 74 6f 20 75 73 65 20 |sh. # to use |
77 69 74 68 20 4c 56 4d 32 2e 0a 20 20 20 20 73 |with LVM2.. s|
63 61 6e 20 3d 20 5b 20 22 2f 78 22 2c 0a 20 20 |can = [ "/x",. |
20 20 20 20 20 20 20 20 20 20 20 22 | "|
...
Reported-by: dongmao zhang <dmzhang suse com>
---
WHATS_NEW_DM | 1 +
libdm/libdm-config.c | 30 ++++++++++++++++++++++++------
2 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 12ba71e..2b820e1 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.78 -
===================================
+ Fix segfault for truncated string token in config file after the first '"'.
Close open dmeventd FIFO file descriptors on exec (FD_CLOEXEC).
Fix resource leak in error path of dmeventd's umount of thin volume.
Automatically deactivate failed preloaded dm tree node.
diff --git a/libdm/libdm-config.c b/libdm/libdm-config.c
index c19f51d..cc726ae 100644
--- a/libdm/libdm-config.c
+++ b/libdm/libdm-config.c
@@ -360,6 +360,27 @@ int dm_config_write_node(const struct dm_config_node *cn, dm_putline_fn putline,
/*
* parser
*/
+static char *_dup_string_tok(struct parser *p)
+{
+ char *str;
+
+ p->tb++, p->te--; /* strip "'s */
+
+ if (p->te < p->tb) {
+ log_error("Parse error at byte %" PRIptrdiff_t " (line %d): "
+ "expected a string token.",
+ p->tb - p->fb + 1, p->line);
+ return NULL;
+ }
+
+ if (!(str = _dup_tok(p)))
+ return_NULL;
+
+ p->te++;
+
+ return str;
+}
+
static struct dm_config_node *_file(struct parser *p)
{
struct dm_config_node *root = NULL, *n, *l = NULL;
@@ -480,22 +501,19 @@ static struct dm_config_value *_type(struct parser *p)
case TOK_STRING:
v->type = DM_CFG_STRING;
- p->tb++, p->te--; /* strip "'s */
- if (!(v->v.str = _dup_tok(p)))
+ if (!(v->v.str = _dup_string_tok(p)))
return_NULL;
- p->te++;
+
match(TOK_STRING);
break;
case TOK_STRING_ESCAPED:
v->type = DM_CFG_STRING;
- p->tb++, p->te--; /* strip "'s */
- if (!(str = _dup_tok(p)))
+ if (!(str = _dup_string_tok(p)))
return_NULL;
dm_unescape_double_quotes(str);
v->v.str = str;
- p->te++;
match(TOK_STRING_ESCAPED);
break;
11 years, 3 months