master - report: support "-o -field_name1, field_name2, ...."
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3e18b101a0845f...
Commit: 3e18b101a0845f826de29cfd0c554c5e2be2baa5
Parent: df190dcfa58ee3c7cc9959da6af3ae22e9618992
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Oct 21 15:36:26 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Oct 30 15:47:56 2015 +0100
report: support "-o -field_name1,field_name2,...."
---
tools/reporter.c | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/tools/reporter.c b/tools/reporter.c
index f053b08..591f4ed 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -604,11 +604,26 @@ static void _check_pv_list(struct cmd_context *cmd, int argc, char **argv,
}
}
+static void _del_option_from_list(struct dm_list *sll, const char *str)
+{
+ struct dm_list *slh;
+ struct dm_str_list *sl;
+
+ dm_list_uniterate(slh, sll, sll) {
+ sl = dm_list_item(slh, struct dm_str_list);
+ if (!strcmp(str, sl->str)) {
+ dm_list_del(slh);
+ return;
+ }
+ }
+}
+
static int _get_report_options(struct cmd_context *cmd, const char **options)
{
struct arg_value_group_list *current_group;
struct dm_list *final_opts_list;
struct dm_list *opts_list = NULL;
+ struct dm_str_list *sl;
const char *opts;
int r = ECMD_PROCESSED;
@@ -630,11 +645,18 @@ static int _get_report_options(struct cmd_context *cmd, const char **options)
switch (*opts) {
case '+':
+ /* fall through */
+ case '-':
if (!(opts_list = str_to_str_list(NULL, opts + 1, ",", 1))) {
r = ECMD_FAILED;
goto_out;
}
- dm_list_splice(final_opts_list, opts_list);
+ if (*opts == '+') {
+ dm_list_splice(final_opts_list, opts_list);
+ } else if (*opts == '-') {
+ dm_list_iterate_items(sl, opts_list)
+ _del_option_from_list(final_opts_list, sl->str);
+ }
str_list_destroy(opts_list, 1);
opts_list = NULL;
break;
8 years, 6 months
master - report: make report options defined by "-o" groupable
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=df190dcfa58ee3...
Commit: df190dcfa58ee3c7cc9959da6af3ae22e9618992
Parent: e149fe7fdfd22b496bbd870d19412b0e9f090149
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Oct 21 14:57:49 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Oct 30 15:47:56 2015 +0100
report: make report options defined by "-o" groupable
Also, besides making "-o" groupable, use string lists to store
lists of options temporarily while processing all instances of
the "-o" group.
---
tools/args.h | 2 +-
tools/reporter.c | 61 ++++++++++++++++++++++++++++++++++++++++-------------
2 files changed, 47 insertions(+), 16 deletions(-)
diff --git a/tools/args.h b/tools/args.h
index c887774..210545e 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -185,7 +185,7 @@ arg(name_ARG, 'n', "name", string_arg, 0)
arg(nofsck_ARG, 'n', "nofsck", NULL, 0)
arg(novolumegroup_ARG, 'n', "novolumegroup", NULL, 0)
arg(oldpath_ARG, 'n', "oldpath", NULL, 0)
-arg(options_ARG, 'o', "options", string_arg, 0)
+arg(options_ARG, 'o', "options", string_arg, ARG_GROUPABLE)
arg(sort_ARG, 'O', "sort", string_arg, 0)
arg(maxphysicalvolumes_ARG, 'p', "maxphysicalvolumes", int_arg, 0)
arg(permission_ARG, 'p', "permission", permission_arg, 0)
diff --git a/tools/reporter.c b/tools/reporter.c
index 4cf099b..f053b08 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -606,26 +606,57 @@ static void _check_pv_list(struct cmd_context *cmd, int argc, char **argv,
static int _get_report_options(struct cmd_context *cmd, const char **options)
{
+ struct arg_value_group_list *current_group;
+ struct dm_list *final_opts_list;
+ struct dm_list *opts_list = NULL;
const char *opts;
- char *str;
+ int r = ECMD_PROCESSED;
- opts = arg_str_value(cmd, options_ARG, "");
- if (!opts || !*opts) {
- log_error("Invalid options string: %s", opts);
- return EINVALID_CMD_LINE;
+ if (!(final_opts_list = str_to_str_list(NULL, *options, ",", 1))) {
+ r = ECMD_FAILED;
+ goto_out;
}
- if (*opts == '+') {
- if (!(str = dm_pool_alloc(cmd->mem,
- strlen(*options) + strlen(opts) + 1))) {
- log_error("options string allocation failed");
- return ECMD_FAILED;
+
+ dm_list_iterate_items(current_group, &cmd->arg_value_groups) {
+ if (!grouped_arg_is_set(current_group->arg_values, options_ARG))
+ continue;
+
+ opts = grouped_arg_str_value(current_group->arg_values, options_ARG, NULL);
+ if (!opts || !*opts) {
+ log_error("Invalid options string: %s", opts);
+ r = EINVALID_CMD_LINE;
+ goto out;
}
- (void) sprintf(str, "%s,%s", *options, opts + 1);
- *options = str;
- } else
- *options = opts;
- return ECMD_PROCESSED;
+ switch (*opts) {
+ case '+':
+ if (!(opts_list = str_to_str_list(NULL, opts + 1, ",", 1))) {
+ r = ECMD_FAILED;
+ goto_out;
+ }
+ dm_list_splice(final_opts_list, opts_list);
+ str_list_destroy(opts_list, 1);
+ opts_list = NULL;
+ break;
+ default:
+ str_list_destroy(final_opts_list, 1);
+ if (!(final_opts_list = str_to_str_list(NULL, opts, ",", 1))) {
+ r = ECMD_FAILED;
+ goto out;
+ }
+ }
+ }
+
+ if (!(*options = str_list_to_str(cmd->mem, final_opts_list, ","))) {
+ r = ECMD_FAILED;
+ goto out;
+ }
+out:
+ if (opts_list)
+ str_list_destroy(final_opts_list, 1);
+ if (final_opts_list)
+ str_list_destroy(final_opts_list, 1);
+ return r;
}
static int _report(struct cmd_context *cmd, int argc, char **argv,
8 years, 6 months
master - refactor: move code detecting report options to a separate function
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e149fe7fdfd22b...
Commit: e149fe7fdfd22b496bbd870d19412b0e9f090149
Parent: 77605457e7cf550364355b03cb5544b57d3c046d
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Oct 20 16:36:11 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Oct 30 15:47:56 2015 +0100
refactor: move code detecting report options to a separate function
---
tools/reporter.c | 46 +++++++++++++++++++++++++++-------------------
1 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/tools/reporter.c b/tools/reporter.c
index 6c93739..4cf099b 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -604,13 +604,35 @@ static void _check_pv_list(struct cmd_context *cmd, int argc, char **argv,
}
}
+static int _get_report_options(struct cmd_context *cmd, const char **options)
+{
+ const char *opts;
+ char *str;
+
+ opts = arg_str_value(cmd, options_ARG, "");
+ if (!opts || !*opts) {
+ log_error("Invalid options string: %s", opts);
+ return EINVALID_CMD_LINE;
+ }
+ if (*opts == '+') {
+ if (!(str = dm_pool_alloc(cmd->mem,
+ strlen(*options) + strlen(opts) + 1))) {
+ log_error("options string allocation failed");
+ return ECMD_FAILED;
+ }
+ (void) sprintf(str, "%s,%s", *options, opts + 1);
+ *options = str;
+ } else
+ *options = opts;
+
+ return ECMD_PROCESSED;
+}
+
static int _report(struct cmd_context *cmd, int argc, char **argv,
report_type_t report_type)
{
void *report_handle;
struct processing_handle handle = {0};
- const char *opts;
- char *str;
const char *keys = NULL, *options = NULL, *selection = NULL, *separator;
int r = ECMD_PROCESSED;
int aligned, buffered, headings, field_prefixes, quoted;
@@ -689,23 +711,9 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
}
/* If -o supplied use it, else use default for report_type */
- if (arg_count(cmd, options_ARG)) {
- opts = arg_str_value(cmd, options_ARG, "");
- if (!opts || !*opts) {
- log_error("Invalid options string: %s", opts);
- return EINVALID_CMD_LINE;
- }
- if (*opts == '+') {
- if (!(str = dm_pool_alloc(cmd->mem,
- strlen(options) + strlen(opts) + 1))) {
- log_error("options string allocation failed");
- return ECMD_FAILED;
- }
- (void) sprintf(str, "%s,%s", options, opts + 1);
- options = str;
- } else
- options = opts;
- }
+ if (arg_count(cmd, options_ARG) &&
+ ((r = _get_report_options(cmd, &options) != ECMD_PROCESSED)))
+ return r;
/* -O overrides default sort settings */
keys = arg_str_value(cmd, sort_ARG, keys);
8 years, 6 months
master - str_list: add str_list_destroy function
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=77605457e7cf55...
Commit: 77605457e7cf550364355b03cb5544b57d3c046d
Parent: 0d5b1294f0350e10698232eb764c28b3ca54df1a
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Oct 20 16:12:16 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Oct 30 15:47:56 2015 +0100
str_list: add str_list_destroy function
The str_list_destroy function may be called to cleanup memory when
the list is not used anymore and the list itself was not allocated
from the memory pool.
---
lib/datastruct/str_list.c | 13 +++++++++++++
lib/datastruct/str_list.h | 2 ++
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/lib/datastruct/str_list.c b/lib/datastruct/str_list.c
index a600f60..73b5534 100644
--- a/lib/datastruct/str_list.c
+++ b/lib/datastruct/str_list.c
@@ -247,3 +247,16 @@ bad:
dm_pool_free(mem, list);
return NULL;
}
+
+void str_list_destroy(struct dm_list *list, int deallocate_strings)
+{
+ struct dm_str_list *sl, *tmp_sl;
+
+ dm_list_iterate_items_safe(sl, tmp_sl, list) {
+ dm_list_del(&sl->list);
+ if (deallocate_strings)
+ dm_free((char *)sl->str);
+ dm_free(sl);
+ }
+ dm_free(list);
+}
diff --git a/lib/datastruct/str_list.h b/lib/datastruct/str_list.h
index 268a3cf..92ff8c5 100644
--- a/lib/datastruct/str_list.h
+++ b/lib/datastruct/str_list.h
@@ -32,5 +32,7 @@ int str_list_dup(struct dm_pool *mem, struct dm_list *sllnew,
const struct dm_list *sllold);
char *str_list_to_str(struct dm_pool *mem, const struct dm_list *list, const char *delim);
struct dm_list *str_to_str_list(struct dm_pool *mem, const char *str, const char *delim, int ignore_multiple_delim);
+/* Only for lists which were *not* allocated from the mem pool! */
+void str_list_destroy(struct dm_list *list, int deallocate_strings);
#endif
8 years, 6 months
master - str_list: add str_list_to_str and str_to_str_list functions
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0d5b1294f0350e...
Commit: 0d5b1294f0350e10698232eb764c28b3ca54df1a
Parent: 097d14e64e845bdb1c0b8106e33f38f775e54fe5
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Oct 20 16:01:10 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Oct 30 15:47:56 2015 +0100
str_list: add str_list_to_str and str_to_str_list functions
The str_list_to_str and str_to_str_list are helper functions to
convert string list to a single string and vice versa.
---
lib/datastruct/str_list.c | 87 +++++++++++++++++++++++++++++++++++++++++++++
lib/datastruct/str_list.h | 2 +
2 files changed, 89 insertions(+), 0 deletions(-)
diff --git a/lib/datastruct/str_list.c b/lib/datastruct/str_list.c
index 25ffddd..a600f60 100644
--- a/lib/datastruct/str_list.c
+++ b/lib/datastruct/str_list.c
@@ -16,6 +16,8 @@
#include "lib.h"
#include "str_list.h"
+#include <ctype.h>
+
struct dm_list *str_list_create(struct dm_pool *mem)
{
struct dm_list *sl;
@@ -160,3 +162,88 @@ int str_list_lists_equal(const struct dm_list *sll, const struct dm_list *sll2)
return 1;
}
+
+char *str_list_to_str(struct dm_pool *mem, const struct dm_list *list,
+ const char *delim)
+{
+ size_t delim_len = strlen(delim);
+ unsigned list_size = dm_list_size(list);
+ struct dm_str_list *sl;
+ char *str, *p;
+ size_t len = 0;
+ unsigned i = 0;
+
+ dm_list_iterate_items(sl, list)
+ len += strlen(sl->str);
+ if (list_size > 1)
+ len += ((list_size - 1) * delim_len);
+
+ str = mem ? dm_pool_alloc(mem, len+1) : dm_malloc(len+1);
+ if (!str) {
+ log_error("str_list_to_str: string allocation failed.");
+ return NULL;
+ }
+ str[len] = '\0';
+ p = str;
+
+ dm_list_iterate_items(sl, list) {
+ len = strlen(sl->str);
+ memcpy(p, sl->str, len);
+ p += len;
+
+ if (++i != list_size) {
+ memcpy(p, delim, delim_len);
+ p += delim_len;
+ }
+ }
+
+ return str;
+}
+
+struct dm_list *str_to_str_list(struct dm_pool *mem, const char *str,
+ const char *delim, int ignore_multiple_delim)
+{
+ size_t delim_len = strlen(delim);
+ struct dm_list *list;
+ const char *p1, *p2, *next;
+ char *str_item;
+ size_t len;
+
+ if (!(list = str_list_create(mem))) {
+ log_error("str_to_str_list: string list allocation failed.");
+ return NULL;
+ }
+
+ p1 = p2 = str;
+ while (*p1) {
+ if (!(p2 = strstr(p1, delim)))
+ next = p2 = str + strlen(str);
+ else
+ next = p2 + delim_len;
+
+ len = p2 - p1;
+ str_item = mem ? dm_pool_alloc(mem, len+1) : dm_malloc(len+1);
+ if (!str_item) {
+ log_error("str_to_str_list: string list item allocation failed.");
+ goto bad;
+ }
+ memcpy(str_item, p1, len);
+ str_item[len] = '\0';
+
+ if (!str_list_add_no_dup_check(mem, list, str_item))
+ goto_bad;
+
+ if (ignore_multiple_delim) {
+ while (!strncmp(next, delim, delim_len))
+ next += delim_len;
+ }
+
+ p1 = next;
+ }
+
+ return list;
+bad:
+ if (mem)
+ dm_pool_free(mem, list);
+ return NULL;
+}
diff --git a/lib/datastruct/str_list.h b/lib/datastruct/str_list.h
index 3121a28..268a3cf 100644
--- a/lib/datastruct/str_list.h
+++ b/lib/datastruct/str_list.h
@@ -30,5 +30,7 @@ int str_list_match_list(const struct dm_list *sll, const struct dm_list *sll2, c
int str_list_lists_equal(const struct dm_list *sll, const struct dm_list *sll2);
int str_list_dup(struct dm_pool *mem, struct dm_list *sllnew,
const struct dm_list *sllold);
+char *str_list_to_str(struct dm_pool *mem, const struct dm_list *list, const char *delim);
+struct dm_list *str_to_str_list(struct dm_pool *mem, const char *str, const char *delim, int ignore_multiple_delim);
#endif
8 years, 6 months
master - str_list: also allow memory allocation without memory pool
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=097d14e64e845b...
Commit: 097d14e64e845bdb1c0b8106e33f38f775e54fe5
Parent: 17196103e018a34eda016f6bdcd74395210cb114
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Oct 20 14:09:09 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Oct 30 15:47:55 2015 +0100
str_list: also allow memory allocation without memory pool
---
lib/datastruct/str_list.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/datastruct/str_list.c b/lib/datastruct/str_list.c
index 1d3f08a..25ffddd 100644
--- a/lib/datastruct/str_list.c
+++ b/lib/datastruct/str_list.c
@@ -20,7 +20,8 @@ struct dm_list *str_list_create(struct dm_pool *mem)
{
struct dm_list *sl;
- if (!(sl = dm_pool_alloc(mem, sizeof(struct dm_list)))) {
+ if (!(sl = mem ? dm_pool_alloc(mem, sizeof(struct dm_list))
+ : dm_malloc(sizeof(struct dm_list)))) {
log_errno(ENOMEM, "str_list allocation failed");
return NULL;
}
@@ -37,7 +38,8 @@ static int _str_list_add_no_dup_check(struct dm_pool *mem, struct dm_list *sll,
if (!str)
return_0;
- if (!(sln = dm_pool_alloc(mem, sizeof(*sln))))
+ if (!(sln = mem ? dm_pool_alloc(mem, sizeof(*sln))
+ : dm_malloc(sizeof(*sln))))
return_0;
sln->str = str;
8 years, 6 months
master - New entries for pvs related fixes.
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=17196103e018a3...
Commit: 17196103e018a34eda016f6bdcd74395210cb114
Parent: ccfc09f79b8d7ba15798a2b6f76545bb7fa3681e
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Oct 30 09:05:21 2015 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Oct 30 09:05:21 2015 -0500
New entries for pvs related fixes.
---
WHATS_NEW | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 00e807e..415efc7 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,7 @@
Version 2.02.133 -
======================================
+ Fix missing PVs from pvs output if vgremove is run concurrently.
+ Remove unwanted error message when running pvs/vgs/lvs and vgremove at once.
Check newly created VG's metadata do not overlap in metadata ring buffer.
Check metadata area size is at least the minimum size defined for the format.
Thin pool targets uses low_water_mark from profile.
8 years, 6 months
master - metadata: format_text: also count with calculated mda size of 0
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ccfc09f79b8d7b...
Commit: ccfc09f79b8d7ba15798a2b6f76545bb7fa3681e
Parent: 9a3b64e81ad1988f4143b5a4b4ac06eaf3035e58
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Oct 30 12:02:29 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Oct 30 12:02:34 2015 +0100
metadata: format_text: also count with calculated mda size of 0
When checking minimum mda size, make sure the mda_size after alignment
and calculation is more than 0 - if there's no place for an MDA at the
end of the disk, the _text_pv_add_metadata_area does not try to add it
there and it returns (because we already have the MDA at the start of
the disk at least).
---
lib/format_text/format-text.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 29e9bd2..d4f2c89 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -2241,13 +2241,13 @@ static int _text_pv_add_metadata_area(const struct format_type *fmt,
FMTu64 ").", pv_dev_name(pv),
mda_size, limit_name, limit);
- if (mda_size < MDA_SIZE_MIN) {
- log_error("Metadata area size too small. "
- "It must be at least %u bytes.", MDA_SIZE_MIN);
- goto bad;
- }
-
if (mda_size) {
+ if (mda_size < MDA_SIZE_MIN) {
+ log_error("Metadata area size too small: %" PRIu64" bytes. "
+ "It must be at least %u bytes.", mda_size, MDA_SIZE_MIN);
+ goto bad;
+ }
+
/* Wipe metadata area with zeroes. */
if (!dev_set((struct device *) pv->dev, mda_start,
(size_t) ((mda_size > wipe_size) ?
8 years, 6 months
master - tests: add test for minimum mda size
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9a3b64e81ad198...
Commit: 9a3b64e81ad1988f4143b5a4b4ac06eaf3035e58
Parent: c2e88d1107c496d2c1b39bbbfb9795e88b3a6b60
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Oct 30 10:02:00 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Oct 30 10:02:00 2015 +0100
tests: add test for minimum mda size
---
test/shell/pvcreate-usage.sh | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/test/shell/pvcreate-usage.sh b/test/shell/pvcreate-usage.sh
index 5b74ed3..c6aab26 100644
--- a/test/shell/pvcreate-usage.sh
+++ b/test/shell/pvcreate-usage.sh
@@ -12,6 +12,8 @@
test_description='Test pvcreate option values'
SKIP_WITH_LVMPOLLD=1
PAGESIZE=$(getconf PAGESIZE)
+# MDA_SIZE_MIN defined in lib/format_text/layout.h
+MDA_SIZE_MIN=$((8*$PAGESIZE))
. lib/inittest
@@ -23,6 +25,13 @@ not pvcreate --setphysicalvolumesize -1024 "$dev1"
#COMM 'pvcreate rejects negative metadatasize'
not pvcreate --metadatasize -1024 "$dev1"
+#COMM 'pvcreate rejects metadatasize that is less than minimum size'
+not pvcreate --dataalignment $((${MDA_SIZE_MIN}/2))b --metadatasize $((${MDA_SIZE_MIN}/2))b "$dev1" 2>err
+grep "Metadata area size too small" err
+
+#COMM 'pvcreate accepts metadatasize that is at least the minimum size'
+pvcreate --dataalignment ${MDA_SIZE_MIN}b --metadatasize ${MDA_SIZE_MIN}b "$dev1"
+
# x. metadatasize 0, defaults to 255
# FIXME: unable to check default value, not in reporting cmds
# should default to 255 according to code
8 years, 6 months
master - metadata: format_text: better check for metadata overlap
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c2e88d1107c496...
Commit: c2e88d1107c496d2c1b39bbbfb9795e88b3a6b60
Parent: 406d8ff3323dde6860d88b603701aa4dace47af0
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Oct 30 08:57:34 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Oct 30 08:57:34 2015 +0100
metadata: format_text: better check for metadata overlap
Actually, we don't need extra condition as introduced in commit
00348c0a630a7e5578edf48052ec695b15de752f. We should fix the last
condition:
(mdac->rlocn.size >= mdah->size)
...which should be:
(MDA_HEADER_SIZE + (rlocn ? rlocn->size : 0) + mdac->rlocn.size >= mdah->size))
Where the "mdac" is new metadata, the "rlocn" is old metadata.
So the main problem with the previous condition was that it
didn't count in MDA_HEADER_SIZE properly (and possible existing
metadata - the "rlocn"). This could have caused the error state
where metadata in ring buffer overlap to not be hit.
Replace the new condition introduced in 00348c0a630a7e5578edf48052ec695b15de752f
with the improved one for the condition that existed there
already but it was just incomplete.
---
lib/format_text/format-text.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 84d0947..29e9bd2 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -654,8 +654,7 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
if ((new_wrap && old_wrap) ||
(rlocn && (new_wrap || old_wrap) && (new_end > rlocn->offset)) ||
- (!rlocn && new_wrap && (new_end > mdac->rlocn.offset)) ||
- (mdac->rlocn.size >= mdah->size)) {
+ (MDA_HEADER_SIZE + (rlocn ? rlocn->size : 0) + mdac->rlocn.size >= mdah->size)) {
log_error("VG %s metadata too large for circular buffer",
vg->name);
goto out;
8 years, 6 months