master - Merge branch 'master' into 2018-04-30-vdo-support
by Joe Thornber
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e649f710227a9425869...
Commit: e649f710227a94258699399b02971e010b89b737
Parent: d2840b0ec1249a5c1890956ad42c6c617e240018 3600caa71def68d8f0b1389f0ee3b230ff1bfe56
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Thu May 10 12:34:04 2018 +0100
Committer: Joe Thornber <ejt(a)redhat.com>
CommitterDate: Thu May 10 12:34:04 2018 +0100
Merge branch 'master' into 2018-04-30-vdo-support
doc/lvm-disk-reading.txt | 189 ++++++++++++++++++++
lib/device/bcache-utils.c | 43 +++++
lib/device/bcache.h | 1 +
test/shell/component-raid.sh | 2 +-
test/shell/lvconvert-raid-reshape-load.sh | 2 +-
.../lvconvert-raid-reshape-stripes-load-fail.sh | 5 +-
test/shell/lvconvert-raid-reshape-stripes-load.sh | 2 +-
test/unit/bcache_utils_t.c | 90 +++++++---
8 files changed, 302 insertions(+), 32 deletions(-)
6 years
master - Merge branch 'master' into 2018-04-30-vdo-support
by Joe Thornber
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d2840b0ec1249a5c189...
Commit: d2840b0ec1249a5c1890956ad42c6c617e240018
Parent: 6abc3f10aea3e18a34e9bf1e5995ffa4cb496a5e bc50dc6e70453c98e45aaa845db2828e586f9370
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Fri May 4 13:32:07 2018 +0100
Committer: Joe Thornber <ejt(a)redhat.com>
CommitterDate: Fri May 4 13:32:07 2018 +0100
Merge branch 'master' into 2018-04-30-vdo-support
WHATS_NEW | 1 +
configure | 30 +---
configure.ac | 21 +--
daemons/clvmd/lvm-functions.c | 1 -
daemons/cmirrord/logging.h | 1 -
lib/Makefile.in | 1 +
lib/activate/activate.c | 54 +++--
lib/cache/lvmcache.c | 378 ++++++++++++++++++------------
lib/cache/lvmcache.h | 11 +-
lib/commands/toolcontext.c | 14 +-
lib/commands/toolcontext.h | 2 +-
lib/device/bcache-utils.c | 229 ++++++++++++++++++
lib/device/bcache.c | 158 +------------
lib/device/bcache.h | 27 ++-
lib/label/label.c | 2 +-
lib/metadata/metadata.c | 4 +-
lib/metadata/raid_manip.c | 57 ++++--
lib/misc/lib.h | 1 -
make.tmpl.in | 20 ++-
test/lib/aux.sh | 4 -
test/shell/lvconvert-m-raid1-degraded.sh | 47 ++++
test/unit/Makefile.in | 1 +
test/unit/bcache_utils_t.c | 352 ++++++++++++++++++++++++++++
test/unit/matcher_t.c | 40 ++++
test/unit/units.h | 2 +
tools/tool.h | 1 -
tools/toollib.c | 4 +-
27 files changed, 1032 insertions(+), 431 deletions(-)
6 years
master - vdo: get status parser compiling
by Joe Thornber
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6abc3f10aea3e18a34e...
Commit: 6abc3f10aea3e18a34e9bf1e5995ffa4cb496a5e
Parent: 11d9b0cae7ef451e282ad17f6085450afc91b2ca
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Wed May 2 11:15:35 2018 +0100
Committer: Joe Thornber <ejt(a)redhat.com>
CommitterDate: Wed May 2 11:15:35 2018 +0100
vdo: get status parser compiling
---
device-mapper/vdo/status.c | 75 +++++++++++++++++++++++++++++++------------
device-mapper/vdo/target.h | 2 +-
2 files changed, 55 insertions(+), 22 deletions(-)
diff --git a/device-mapper/vdo/status.c b/device-mapper/vdo/status.c
index ccebc83..895ebc4 100644
--- a/device-mapper/vdo/status.c
+++ b/device-mapper/vdo/status.c
@@ -3,11 +3,13 @@
// For DM_ARRAY_SIZE!
#include "libdevmapper.h"
+#include <ctype.h>
#include <stdlib.h>
+#include <string.h>
//----------------------------------------------------------------
-static const char *_tok_cpy(const char *b, const char *e, const char *str)
+static char *_tok_cpy(const char *b, const char *e)
{
char *new = malloc((e - b) + 1);
char *ptr = new;
@@ -32,8 +34,7 @@ static bool _tok_eq(const char *b, const char *e, const char *str)
return !*str;
}
-static bool _parse_operating_mode(const char *b, const char *e,
- enum vdo_operating_mode *r)
+static bool _parse_operating_mode(const char *b, const char *e, void *context)
{
static struct {
const char *str;
@@ -44,6 +45,7 @@ static bool _parse_operating_mode(const char *b, const char *e,
{"normal", VDO_MODE_NORMAL}
};
+ enum vdo_operating_mode *r = context;
unsigned i;
for (i = 0; i < DM_ARRAY_SIZE(_table); i++) {
if (_tok_eq(b, e, _table[i].str)) {
@@ -55,8 +57,7 @@ static bool _parse_operating_mode(const char *b, const char *e,
return false;
}
-static bool _parse_compression_state(const char *b, const char *e,
- enum vdo_compression_state *r)
+static bool _parse_compression_state(const char *b, const char *e, void *context)
{
static struct {
const char *str;
@@ -66,6 +67,7 @@ static bool _parse_compression_state(const char *b, const char *e,
{"offline", VDO_COMPRESSION_OFFLINE}
};
+ enum vdo_compression_state *r = context;
unsigned i;
for (i = 0; i < DM_ARRAY_SIZE(_table); i++) {
if (_tok_eq(b, e, _table[i].str)) {
@@ -77,8 +79,10 @@ static bool _parse_compression_state(const char *b, const char *e,
return false;
}
-static bool _parse_recovering(const char *b, const char *e, bool *r)
+static bool _parse_recovering(const char *b, const char *e, void *context)
{
+ bool *r = context;
+
if (_tok_eq(b, e, "recovering"))
*r = true;
@@ -91,8 +95,7 @@ static bool _parse_recovering(const char *b, const char *e, bool *r)
return true;
}
-static bool _parse_index_state(const char *b, const char *e,
- enum vdo_index_state *r)
+static bool _parse_index_state(const char *b, const char *e, void *context)
{
static struct {
const char *str;
@@ -107,6 +110,7 @@ static bool _parse_index_state(const char *b, const char *e,
{"unknown", VDO_INDEX_UNKNOWN}
};
+ enum vdo_index_state *r = context;
unsigned i;
for (i = 0; i < DM_ARRAY_SIZE(_table); i++) {
if (_tok_eq(b, e, _table[i].str)) {
@@ -118,6 +122,23 @@ static bool _parse_index_state(const char *b, const char *e,
return false;
}
+static bool _parse_uint64(const char *b, const char *e, void *context)
+{
+ uint64_t *r = context, n;
+
+ n = 0;
+ while (b != e) {
+ if (!isdigit(*b))
+ return false;
+
+ n = (n << 1) + (*b - '0');
+ b++;
+ }
+
+ *r = n;
+ return true;
+}
+
static const char *_eat_space(const char *b, const char *e)
{
while (b != e && isspace(*b))
@@ -134,8 +155,20 @@ static const char *_next_tok(const char *b, const char *e)
return b == e ? NULL : b;
}
+static void _set_error(struct parse_result *result, const char *fmt, ...)
+ __attribute__ ((format(printf, 2, 3)));
+
+static void _set_error(struct parse_result *result, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vsnprintf(result->error, sizeof(result->error), fmt, ap);
+ va_end(ap);
+}
+
static bool _parse_field(const char **b, const char *e,
- bool (*p_fn)(const char *, const char *, void *)
+ bool (*p_fn)(const char *, const char *, void *),
void *field, const char *field_name,
struct parse_result *result)
{
@@ -143,53 +176,53 @@ static bool _parse_field(const char **b, const char *e,
te = _next_tok(*b, e);
if (!te) {
- snprintf(result->error, sizeof(result->error),
- "couldn't get token for '%s'", field_name);
+ _set_error(result, "couldn't get token for '%s'", field_name);
return false;
}
- if (!p_fn(*b, te, field) {
- snprintf(result->error, sizeof(result->error),
- "couldn't parse '%s'", field_name);
+ if (!p_fn(*b, te, field)) {
+ _set_error(result, "couldn't parse '%s'", field_name);
return false;
}
- *b = _eat_space(te);
+ *b = _eat_space(te, e);
return true;
}
bool parse_vdo_status(const char *input, struct parse_result *result)
{
- const char *b = _eat_space(input);
+ const char *b = b = input;
const char *e = input + strlen(input);
const char *te;
struct vdo_status *s = malloc(sizeof(*s));
if (!s) {
- result->error = "out of memory";
+ _set_error(result, "out of memory");
return false;
}
+ b = _eat_space(b, e);
te = _next_tok(b, e);
if (!te) {
- result->error = "couldn't get token for device";
+ _set_error(result, "couldn't get token for device");
free(s);
return false;
}
s->device = _tok_cpy(b, te);
if (!s->device) {
- result->error = "out of memory";
+ _set_error(result, "out of memory");
free(s);
return false;
}
- b = _eat_space(te);
+ b = _eat_space(te, e);
#define XX(p, f, fn) if (!_parse_field(&b, e, p, f, fn, result)) goto bad;
+ XX(_parse_operating_mode, &s->operating_mode, "operating mode");
XX(_parse_recovering, &s->recovering, "recovering");
- XX(_parse_index, &s->index_state, "index state");
+ XX(_parse_index_state, &s->index_state, "index state");
XX(_parse_compression_state, &s->compression_state, "compression state");
XX(_parse_uint64, &s->used_blocks, "used blocks");
XX(_parse_uint64, &s->total_blocks, "total blocks");
diff --git a/device-mapper/vdo/target.h b/device-mapper/vdo/target.h
index e3c6788..118ec93 100644
--- a/device-mapper/vdo/target.h
+++ b/device-mapper/vdo/target.h
@@ -42,7 +42,7 @@ enum vdo_index_state {
};
struct vdo_status {
- const char *device;
+ char *device;
enum vdo_operating_mode operating_mode;
bool recovering;
enum vdo_index_state index_state;
6 years
master - Merge branch 'master' into 2018-04-30-vdo-support
by Joe Thornber
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=11d9b0cae7ef451e282...
Commit: 11d9b0cae7ef451e282ad17f6085450afc91b2ca
Parent: 52ebad31bae64edd92244a244c8928fb2171c209 11436b00e0fa4a54ce504beba72b23bbf0682b27
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Wed May 2 10:09:20 2018 +0100
Committer: Joe Thornber <ejt(a)redhat.com>
CommitterDate: Wed May 2 10:09:20 2018 +0100
Merge branch 'master' into 2018-04-30-vdo-support
Makefile.in | 2 -
WHATS_NEW | 1 +
configure | 111 +-----
configure.ac | 69 +---
daemons/clvmd/clvmd-command.c | 1 -
daemons/clvmd/lvm-functions.c | 10 -
daemons/clvmd/lvm-functions.h | 1 -
daemons/dmeventd/plugins/Makefile.in | 2 +-
daemons/lvmetad/lvmetad-client.h | 1 -
daemons/lvmetad/lvmetad-core.c | 9 +-
include/.gitignore | 6 +-
include/.symlinks.in | 80 ++++
include/Makefile.in | 20 +-
include/activate.h | 1 -
include/archiver.h | 1 -
include/bcache.h | 1 -
include/btree.h | 1 -
include/clvm.h | 1 -
include/config-util.h | 1 -
include/config.h | 1 -
include/config_settings.h | 1 -
include/configure.h.in | 14 -
include/crc.h | 1 -
include/daemon-client.h | 1 -
include/daemon-io.h | 1 -
include/defaults.h | 1 -
include/dev-cache.h | 1 -
include/dev-ext-udev-constants.h | 1 -
include/dev-type.h | 1 -
include/device-types.h | 1 -
include/device.h | 1 -
include/display.h | 1 -
include/dm-ioctl.h | 1 -
include/dm-log-userspace.h | 1 -
include/dm-logging.h | 1 -
include/dmlib.h | 1 -
include/filter.h | 1 -
include/format-text.h | 1 -
include/format1.h | 1 -
include/format_pool.h | 1 -
include/intl.h | 1 -
include/kdev_t.h | 1 -
include/label.h | 1 -
include/last-path-component.h | 1 -
include/lib.h | 1 -
include/libdevmapper-event.h | 1 -
include/libdevmapper.h | 1 -
include/locking.h | 1 -
include/log.h | 1 -
include/lv.h | 1 -
include/lv_alloc.h | 1 -
include/lvm-exec.h | 1 -
include/lvm-file.h | 1 -
include/lvm-flock.h | 1 -
include/lvm-globals.h | 1 -
include/lvm-logging.h | 1 -
include/lvm-maths.h | 1 -
include/lvm-percent.h | 1 -
include/lvm-signal.h | 1 -
include/lvm-string.h | 1 -
include/lvm-wrappers.h | 1 -
include/lvm2app.h | 1 -
include/lvm2cmd.h | 1 -
include/lvmcache.h | 1 -
include/lvmetad-client.h | 1 -
include/lvmetad.h | 1 -
include/lvmlockd-client.h | 1 -
include/lvmlockd.h | 1 -
include/lvmnotify.h | 1 -
include/lvmpolld-client.h | 1 -
include/lvmpolld-protocol.h | 1 -
include/memlock.h | 1 -
include/metadata-exported.h | 1 -
include/metadata.h | 1 -
include/pogen.h | 1 -
include/polldaemon.h | 1 -
include/polling_ops.h | 1 -
include/prop_common.h | 1 -
include/properties.h | 1 -
include/pv.h | 1 -
include/pv_alloc.h | 1 -
include/report.h | 1 -
include/segtype.h | 1 -
include/sharedlib.h | 1 -
include/str_list.h | 1 -
include/targets.h | 1 -
include/text_export.h | 1 -
include/text_import.h | 1 -
include/tool.h | 1 -
include/toolcontext.h | 1 -
include/util.h | 1 -
include/uuid.h | 1 -
include/vg.h | 1 -
include/xlate.h | 1 -
lib/Makefile.in | 31 +--
lib/activate/activate.c | 13 -
lib/activate/activate.h | 1 -
lib/cache/lvmcache.c | 10 +-
lib/cache/lvmetad.c | 23 +-
lib/commands/toolcontext.c | 29 +-
lib/config/config_settings.h | 20 +-
lib/device/bcache.c | 118 +++---
lib/device/dev-lvm1-pool.c | 174 ++++++++
lib/device/dev-type.h | 3 +
lib/display/display.c | 9 +-
lib/filters/filter-signature.c | 96 +++++
lib/filters/filter.h | 1 +
lib/format1/.exported_symbols | 1 -
lib/format1/Makefile.in | 33 --
lib/format1/disk-rep.c | 761 ----------------------------------
lib/format1/disk-rep.h | 250 -----------
lib/format1/format1.c | 631 ----------------------------
lib/format1/format1.h | 29 --
lib/format1/import-export.c | 680 ------------------------------
lib/format1/import-extents.c | 377 -----------------
lib/format1/layout.c | 172 --------
lib/format1/lvm1-label.c | 129 ------
lib/format1/lvm1-label.h | 23 -
lib/format1/vg_number.c | 60 ---
lib/format_pool/.exported_symbols | 1 -
lib/format_pool/Makefile.in | 30 --
lib/format_pool/disk_rep.c | 409 ------------------
lib/format_pool/disk_rep.h | 156 -------
lib/format_pool/format_pool.c | 338 ---------------
lib/format_pool/format_pool.h | 28 --
lib/format_pool/import_export.c | 285 -------------
lib/format_pool/pool_label.c | 104 -----
lib/format_pool/pool_label.h | 23 -
lib/format_pool/sptype_names.h | 42 --
lib/format_text/export.c | 2 -
lib/format_text/format-text.c | 4 +-
lib/format_text/import_vsn1.c | 9 +-
lib/label/label.c | 18 +-
lib/locking/locking.c | 40 --
lib/metadata/lv_manip.c | 26 --
lib/metadata/metadata-exported.h | 10 +-
lib/metadata/metadata.c | 27 +-
lib/metadata/segtype.h | 2 +-
lib/metadata/snapshot_manip.c | 11 -
lib/metadata/vg.c | 17 +-
lib/metadata/vg.h | 1 -
lib/report/report.c | 4 +-
lib/striped/striped.c | 2 +-
make.tmpl.in | 11 +-
man/vgconvert.8_des | 7 +-
test/lib/aux.sh | 4 -
test/shell/format-lvm1.sh | 38 --
test/shell/lvm1-basic.sh | 36 --
test/shell/lvmetad-disabled.sh | 24 +-
test/shell/pool-labels.sh | 11 +-
test/shell/snapshot-lvm1.sh | 35 --
test/shell/vgcreate-usage.sh | 4 -
test/unit/bcache_t.c | 39 ++-
test/unit/io_engine_t.c | 83 ++++-
tools/args.h | 3 +-
tools/lvconvert.c | 5 -
tools/lvmcmdline.c | 58 +---
tools/pvscan.c | 5 +-
tools/stub.h | 1 -
tools/toollib.c | 31 +--
tools/vals.h | 4 +-
tools/vgchange.c | 10 -
tools/vgconvert.c | 53 +--
tools/vgscan.c | 4 +-
164 files changed, 668 insertions(+), 5468 deletions(-)
diff --cc Makefile.in
index 1b16945,746be15..3274f17
--- a/Makefile.in
+++ b/Makefile.in
@@@ -210,12 -210,8 +210,10 @@@ endi
endif
- ifeq ("$(TESTING)", "yes")
include test/unit/Makefile
- endif
+include device-mapper/Makefile
+
ifneq ($(shell which ctags),)
.PHONY: tags
tags:
6 years
master - vdo: Code drop for status parsing.
by Joe Thornber
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=52ebad31bae64edd922...
Commit: 52ebad31bae64edd92244a244c8928fb2171c209
Parent: 9384b2b5c59e9bca8c2054f76b62155a64c51c38
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Mon Apr 30 16:16:58 2018 +0100
Committer: Joe Thornber <ejt(a)redhat.com>
CommitterDate: Mon Apr 30 16:16:58 2018 +0100
vdo: Code drop for status parsing.
Doesn't even compile yet. Squash this patch.
---
Makefile.in | 2 +
device-mapper/Makefile | 20 ++++
device-mapper/vdo/status.c | 207 ++++++++++++++++++++++++++++++++++++++++++++
device-mapper/vdo/target.h | 69 +++++++++++++++
4 files changed, 298 insertions(+), 0 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 916f54d..1b16945 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -214,6 +214,8 @@ ifeq ("$(TESTING)", "yes")
include test/unit/Makefile
endif
+include device-mapper/Makefile
+
ifneq ($(shell which ctags),)
.PHONY: tags
tags:
diff --git a/device-mapper/Makefile b/device-mapper/Makefile
new file mode 100644
index 0000000..76e19f0
--- /dev/null
+++ b/device-mapper/Makefile
@@ -0,0 +1,20 @@
+# Copyright (C) 2018 Red Hat, Inc. All rights reserved.
+#
+# This file is part of LVM2.
+#
+# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+DM_SOURCE=\
+ device-mapper/vdo/status.c
+
+DM_DEPENDS=$(subst .c,.d,$(DM_SOURCE))
+DM_OBJECTS=$(DM_SOURCE:%.c=%.o)
+CLEAN_TARGETS+=$(DM_DEPENDS) $(DM_OBJECTS)
+
+-include $(DM_DEPENDS)
diff --git a/device-mapper/vdo/status.c b/device-mapper/vdo/status.c
new file mode 100644
index 0000000..ccebc83
--- /dev/null
+++ b/device-mapper/vdo/status.c
@@ -0,0 +1,207 @@
+#include "target.h"
+
+// For DM_ARRAY_SIZE!
+#include "libdevmapper.h"
+
+#include <stdlib.h>
+
+//----------------------------------------------------------------
+
+static const char *_tok_cpy(const char *b, const char *e, const char *str)
+{
+ char *new = malloc((e - b) + 1);
+ char *ptr = new;
+
+ if (new)
+ while (b != e)
+ *ptr++ = *b++;
+
+ return new;
+}
+
+static bool _tok_eq(const char *b, const char *e, const char *str)
+{
+ while (b != e) {
+ if (!*str || *b != *str)
+ return false;
+
+ b++;
+ str++;
+ }
+
+ return !*str;
+}
+
+static bool _parse_operating_mode(const char *b, const char *e,
+ enum vdo_operating_mode *r)
+{
+ static struct {
+ const char *str;
+ enum vdo_operating_mode mode;
+ } _table[] = {
+ {"recovering", VDO_MODE_RECOVERING},
+ {"read-only", VDO_MODE_READ_ONLY},
+ {"normal", VDO_MODE_NORMAL}
+ };
+
+ unsigned i;
+ for (i = 0; i < DM_ARRAY_SIZE(_table); i++) {
+ if (_tok_eq(b, e, _table[i].str)) {
+ *r = _table[i].mode;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static bool _parse_compression_state(const char *b, const char *e,
+ enum vdo_compression_state *r)
+{
+ static struct {
+ const char *str;
+ enum vdo_compression_state state;
+ } _table[] = {
+ {"online", VDO_COMPRESSION_ONLINE},
+ {"offline", VDO_COMPRESSION_OFFLINE}
+ };
+
+ unsigned i;
+ for (i = 0; i < DM_ARRAY_SIZE(_table); i++) {
+ if (_tok_eq(b, e, _table[i].str)) {
+ *r = _table[i].state;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static bool _parse_recovering(const char *b, const char *e, bool *r)
+{
+ if (_tok_eq(b, e, "recovering"))
+ *r = true;
+
+ else if (_tok_eq(b, e, "-"))
+ *r = false;
+
+ else
+ return false;
+
+ return true;
+}
+
+static bool _parse_index_state(const char *b, const char *e,
+ enum vdo_index_state *r)
+{
+ static struct {
+ const char *str;
+ enum vdo_index_state state;
+ } _table[] = {
+ {"error", VDO_INDEX_ERROR},
+ {"closed", VDO_INDEX_CLOSED},
+ {"opening", VDO_INDEX_OPENING},
+ {"closing", VDO_INDEX_CLOSING},
+ {"offline", VDO_INDEX_OFFLINE},
+ {"online", VDO_INDEX_ONLINE},
+ {"unknown", VDO_INDEX_UNKNOWN}
+ };
+
+ unsigned i;
+ for (i = 0; i < DM_ARRAY_SIZE(_table); i++) {
+ if (_tok_eq(b, e, _table[i].str)) {
+ *r = _table[i].state;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static const char *_eat_space(const char *b, const char *e)
+{
+ while (b != e && isspace(*b))
+ b++;
+
+ return b;
+}
+
+static const char *_next_tok(const char *b, const char *e)
+{
+ while (b != e && !isspace(*b))
+ b++;
+
+ return b == e ? NULL : b;
+}
+
+static bool _parse_field(const char **b, const char *e,
+ bool (*p_fn)(const char *, const char *, void *)
+ void *field, const char *field_name,
+ struct parse_result *result)
+{
+ const char *te;
+
+ te = _next_tok(*b, e);
+ if (!te) {
+ snprintf(result->error, sizeof(result->error),
+ "couldn't get token for '%s'", field_name);
+ return false;
+ }
+
+ if (!p_fn(*b, te, field) {
+ snprintf(result->error, sizeof(result->error),
+ "couldn't parse '%s'", field_name);
+ return false;
+ }
+
+ *b = _eat_space(te);
+ return true;
+
+}
+
+bool parse_vdo_status(const char *input, struct parse_result *result)
+{
+ const char *b = _eat_space(input);
+ const char *e = input + strlen(input);
+ const char *te;
+ struct vdo_status *s = malloc(sizeof(*s));
+
+ if (!s) {
+ result->error = "out of memory";
+ return false;
+ }
+
+ te = _next_tok(b, e);
+ if (!te) {
+ result->error = "couldn't get token for device";
+ free(s);
+ return false;
+ }
+
+ s->device = _tok_cpy(b, te);
+ if (!s->device) {
+ result->error = "out of memory";
+ free(s);
+ return false;
+ }
+
+ b = _eat_space(te);
+
+#define XX(p, f, fn) if (!_parse_field(&b, e, p, f, fn, result)) goto bad;
+ XX(_parse_recovering, &s->recovering, "recovering");
+ XX(_parse_index, &s->index_state, "index state");
+ XX(_parse_compression_state, &s->compression_state, "compression state");
+ XX(_parse_uint64, &s->used_blocks, "used blocks");
+ XX(_parse_uint64, &s->total_blocks, "total blocks");
+#undef XX
+
+ result->result = s;
+ return true;
+
+bad:
+ free(s->device);
+ free(s);
+ return false;
+}
+
+//----------------------------------------------------------------
diff --git a/device-mapper/vdo/target.h b/device-mapper/vdo/target.h
new file mode 100644
index 0000000..e3c6788
--- /dev/null
+++ b/device-mapper/vdo/target.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2018 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of the device-mapper userspace tools.
+ *
+ * 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 Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef DEVICE_MAPPER_VDO_TARGET_H
+#define DEVICE_MAPPER_VDO_TARGET_H
+
+#include <stdbool.h>
+#include <stdint.h>
+
+//----------------------------------------------------------------
+
+enum vdo_operating_mode {
+ VDO_MODE_RECOVERING,
+ VDO_MODE_READ_ONLY,
+ VDO_MODE_NORMAL
+};
+
+enum vdo_compression_state {
+ VDO_COMPRESSION_ONLINE,
+ VDO_COMPRESSION_OFFLINE
+};
+
+enum vdo_index_state {
+ VDO_INDEX_ERROR,
+ VDO_INDEX_CLOSED,
+ VDO_INDEX_OPENING,
+ VDO_INDEX_CLOSING,
+ VDO_INDEX_OFFLINE,
+ VDO_INDEX_ONLINE,
+ VDO_INDEX_UNKNOWN
+};
+
+struct vdo_status {
+ const char *device;
+ enum vdo_operating_mode operating_mode;
+ bool recovering;
+ enum vdo_index_state index_state;
+ enum vdo_compression_state compression_state;
+ uint64_t used_blocks;
+ uint64_t total_blocks;
+};
+
+void vdo_status_destroy(struct vdo_status *s);
+
+#define VDO_MAX_ERROR 256
+
+struct parse_result {
+ char error[VDO_MAX_ERROR];
+ struct vdo_status *result;
+};
+
+// Parses the status line from the kernel target.
+bool parse_vdo_status(const char *input, struct parse_result *result);
+
+
+//----------------------------------------------------------------
+
+#endif
6 years
master - doc: add filter info to scanning
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=38f33251b182fdf4a19...
Commit: 38f33251b182fdf4a1963dcd249d8d77ab6357ad
Parent: 9a5bd01b0cf9526b3eb98c7521c281cbcee52732
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed May 9 11:14:05 2018 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed May 9 12:54:38 2018 -0500
doc: add filter info to scanning
---
doc/lvm-disk-reading.txt | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/doc/lvm-disk-reading.txt b/doc/lvm-disk-reading.txt
index 241a7ab..1255ae8 100644
--- a/doc/lvm-disk-reading.txt
+++ b/doc/lvm-disk-reading.txt
@@ -187,3 +187,45 @@ For each VG name:
command-specific work
+
+Filter i/o
+----------
+
+Some filters must be applied before reading a device, and other filters
+must be applied after reading a device. In all cases, the filters must be
+applied before lvm processes the device, i.e. before it looks for an lvm
+label.
+
+1. Some filters need to be applied prior to reading any devices
+ because the purpose of the filter is to avoid submitting any
+ io on the excluded devices. The regex filter is the primary
+ example. Other filters benefit from being applied prior to
+ reading devices because they can tell which devices to
+ exclude without doing io to the device. An example of this
+ is the mpath filter.
+
+2. Some filters need to be applied after reading a device because
+ they are based on data/signatures seen on the device.
+ The partitioned filter is an example of this; lvm needs to
+ read a device to see if it has a partition table before it can
+ know whether to exclude the device from further processing.
+
+We apply filters from 1 before reading devices, and we apply filters from
+2 after populating bcache, but before processing the device (i.e. before
+checking for an lvm label, which is the first step in processing.)
+
+The current implementation of this makes filters return -EAGAIN if they
+want to read the device, but bcache data is not yet available. This will
+happen when filtering runs prior to populating bcache. In this case the
+device is flagged. After bcache is populated, the filters are reapplied
+to the flagged devices. The filters which need to look at device content
+are now able to get it from bcache. Devices that do not pass filters at
+this point are excluded just like devices which were excluded earlier.
+
+(Some filters from 2 can be skipped by consulting udev for the information
+instead of reading the device. This is not entirely reliable, so it is
+disabled by default with the config setting external_device_info_source.
+It may be worthwhile to change the filters to use the udev info as a hint,
+or only use udev info for filtering in reporting commands where
+inaccuracies are not a big problem.)
+
6 years
master - io: replace dev_set with bcache equivalents
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9a5bd01b0cf9526b3eb...
Commit: 9a5bd01b0cf9526b3eb98c7521c281cbcee52732
Parent: 3600caa71def68d8f0b1389f0ee3b230ff1bfe56
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed May 9 10:34:28 2018 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed May 9 11:29:52 2018 -0500
io: replace dev_set with bcache equivalents
---
lib/label/label.c | 53 +++++++++++++++++++++++++++++++---------
lib/label/label.h | 7 +++--
lib/locking/lvmlockd.c | 11 ++------
lib/metadata/lv_manip.c | 22 ++++++++++-------
lib/metadata/metadata-liblvm.c | 10 +-------
5 files changed, 62 insertions(+), 41 deletions(-)
diff --git a/lib/label/label.c b/lib/label/label.c
index d6a5727..8b60780 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -884,7 +884,7 @@ int label_scan_open(struct device *dev)
return 1;
}
-bool dev_read_bytes(struct device *dev, off_t start, size_t len, void *data)
+bool dev_read_bytes(struct device *dev, uint64_t start, size_t len, void *data)
{
int ret;
@@ -918,7 +918,7 @@ bool dev_read_bytes(struct device *dev, off_t start, size_t len, void *data)
}
-bool dev_write_bytes(struct device *dev, off_t start, size_t len, void *data)
+bool dev_write_bytes(struct device *dev, uint64_t start, size_t len, void *data)
{
int ret;
@@ -961,7 +961,7 @@ bool dev_write_bytes(struct device *dev, off_t start, size_t len, void *data)
return true;
}
-bool dev_write_zeros(struct device *dev, off_t start, size_t len)
+bool dev_write_zeros(struct device *dev, uint64_t start, size_t len)
{
int ret;
@@ -969,15 +969,8 @@ bool dev_write_zeros(struct device *dev, off_t start, size_t len)
return true;
if (!scan_bcache) {
- if (!dev_open(dev))
- return false;
-
- ret = dev_set(dev, start, len, 0, 0);
-
- if (!dev_close(dev))
- stack;
-
- return ret ? true : false;
+ log_error("dev_write_zeros %s bcache not set up", dev_name(dev));
+ return false;
}
if (dev->bcache_fd <= 0) {
@@ -1004,3 +997,39 @@ bool dev_write_zeros(struct device *dev, off_t start, size_t len)
return true;
}
+bool dev_set_bytes(struct device *dev, uint64_t start, size_t len, uint8_t val)
+{
+ int ret;
+
+ if (test_mode())
+ return true;
+
+ if (!scan_bcache) {
+ log_error("dev_set_bytes %s bcache not set up", dev_name(dev));
+ return false;
+ }
+
+ if (dev->bcache_fd <= 0) {
+ /* This is not often needed, perhaps only with lvmetad. */
+ if (!label_scan_open(dev)) {
+ log_error("dev_set_bytes %s cannot open dev", dev_name(dev));
+ return false;
+ }
+ }
+
+ if (!bcache_set_bytes(scan_bcache, dev->bcache_fd, start, len, val)) {
+ log_error("dev_set_bytes %s at %u bcache write failed invalidate fd %d",
+ dev_name(dev), (uint32_t)start, dev->bcache_fd);
+ label_scan_invalidate(dev);
+ return false;
+ }
+
+ if (!bcache_flush(scan_bcache)) {
+ log_error("dev_set_bytes %s at %u bcache flush failed invalidate fd %d",
+ dev_name(dev), (uint32_t)start, dev->bcache_fd);
+ label_scan_invalidate(dev);
+ return false;
+ }
+ return true;
+}
+
diff --git a/lib/label/label.h b/lib/label/label.h
index 55e92e8..bccf777 100644
--- a/lib/label/label.h
+++ b/lib/label/label.h
@@ -119,8 +119,9 @@ int label_scan_open(struct device *dev);
* Wrappers around bcache equivalents.
* (these make it easier to disable bcache and revert to direct rw if needed)
*/
-bool dev_read_bytes(struct device *dev, off_t start, size_t len, void *data);
-bool dev_write_bytes(struct device *dev, off_t start, size_t len, void *data);
-bool dev_write_zeros(struct device *dev, off_t start, size_t len);
+bool dev_read_bytes(struct device *dev, uint64_t start, size_t len, void *data);
+bool dev_write_bytes(struct device *dev, uint64_t start, size_t len, void *data);
+bool dev_write_zeros(struct device *dev, uint64_t start, size_t len);
+bool dev_set_bytes(struct device *dev, uint64_t start, size_t len, uint8_t val);
#endif
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index 0521ede..d78b35c 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -403,22 +403,17 @@ static int _extend_sanlock_lv(struct cmd_context *cmd, struct volume_group *vg,
return 0;
}
- if (!dev_open_quiet(dev)) {
+ if (!label_scan_open(dev)) {
log_error("Extend sanlock LV %s cannot open device.", display_lvname(lv));
return 0;
}
- if (!dev_set(dev, old_size_bytes, new_size_bytes - old_size_bytes, DEV_IO_LV, 0)) {
+ if (!dev_write_zeros(dev, old_size_bytes, new_size_bytes - old_size_bytes)) {
log_error("Extend sanlock LV %s cannot zero device.", display_lvname(lv));
- dev_close_immediate(dev);
return 0;
}
- dev_flush(dev);
-
- if (!dev_close_immediate(dev))
- stack;
-
+ label_scan_invalidate(dev);
return 1;
}
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 8bf9379..84953bb 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7155,8 +7155,10 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
return 0;
}
- if (!dev_open_quiet(dev))
- return_0;
+ if (!label_scan_open(dev)) {
+ log_error("Failed to open %s/%s for wiping and zeroing.", lv->vg->name, lv->name);
+ goto out;
+ }
if (wp.do_wipe_signatures) {
log_verbose("Wiping known signatures on logical volume \"%s/%s\"",
@@ -7177,15 +7179,17 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
display_size(lv->vg->cmd, zero_sectors),
lv->vg->name, lv->name, wp.zero_value);
- if (!dev_set(dev, UINT64_C(0), (size_t) zero_sectors << SECTOR_SHIFT, DEV_IO_LV, wp.zero_value))
- stack;
+ if (!wp.zero_value) {
+ if (!dev_write_zeros(dev, UINT64_C(0), (size_t) zero_sectors << SECTOR_SHIFT))
+ stack;
+ } else {
+ if (!dev_set_bytes(dev, UINT64_C(0), (size_t) zero_sectors << SECTOR_SHIFT, (uint8_t)wp.zero_value))
+ stack;
+ }
}
- dev_flush(dev);
-
- if (!dev_close_immediate(dev))
- stack;
-
+ label_scan_invalidate(dev);
+out:
lv->status &= ~LV_NOSCAN;
return 1;
diff --git a/lib/metadata/metadata-liblvm.c b/lib/metadata/metadata-liblvm.c
index 2dc3757..f7a07a5 100644
--- a/lib/metadata/metadata-liblvm.c
+++ b/lib/metadata/metadata-liblvm.c
@@ -66,19 +66,11 @@ static int _pvcreate_write(struct cmd_context *cmd, struct pv_to_write *pvw)
if (pvw->pp->zero) {
log_verbose("Zeroing start of device %s", pv_name);
- if (!dev_open_quiet(dev)) {
- log_error("%s not opened: device not zeroed", pv_name);
- return 0;
- }
- if (!dev_set(dev, UINT64_C(0), (size_t) 2048, DEV_IO_LABEL, 0)) {
+ if (!dev_write_zeros(dev, UINT64_C(0), (size_t) 2048)) {
log_error("%s not wiped: aborting", pv_name);
- if (!dev_close(dev))
- stack;
return 0;
}
- if (!dev_close(dev))
- stack;
}
}
6 years
master - bcache-utils: bcache_set_bytes()
by Joe Thornber
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1c5c99afceb28f6ee46...
Commit: 1c5c99afceb28f6ee464a705f1337866d29a9819
Parent: 2e1869b9231181cbd5c3cfa7dbbb3ef237ffa4a9
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Wed May 9 11:05:29 2018 +0100
Committer: Joe Thornber <ejt(a)redhat.com>
CommitterDate: Wed May 9 11:05:29 2018 +0100
bcache-utils: bcache_set_bytes()
---
lib/device/bcache-utils.c | 43 ++++++++++++++++++++++++++++
lib/device/bcache.h | 1 +
test/unit/bcache_utils_t.c | 66 ++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 108 insertions(+), 2 deletions(-)
diff --git a/lib/device/bcache-utils.c b/lib/device/bcache-utils.c
index 92e25c8..1487732 100644
--- a/lib/device/bcache-utils.c
+++ b/lib/device/bcache-utils.c
@@ -227,3 +227,46 @@ bool bcache_zero_bytes(struct bcache *cache, int fd, uint64_t start, size_t len)
}
//----------------------------------------------------------------
+
+static bool _set_partial(struct updater *u, int fd, block_address bb, uint64_t offset, size_t len)
+{
+ struct block *b;
+ uint8_t val = *((uint8_t *) u->data);
+
+ if (!bcache_get(u->cache, fd, bb, GF_DIRTY, &b, NULL))
+ return false;
+
+ memset(((unsigned char *) b->data) + offset, val, len);
+ bcache_put(b);
+
+ return true;
+}
+
+static bool _set_whole(struct updater *u, int fd, block_address bb, block_address be)
+{
+ struct block *b;
+ uint8_t val = *((uint8_t *) u->data);
+ uint64_t len = bcache_block_sectors(u->cache) * 512;
+
+ for (; bb != be; bb++) {
+ if (!bcache_get(u->cache, fd, bb, GF_ZERO, &b, NULL))
+ return false;
+ memset((unsigned char *) b->data, val, len);
+ bcache_put(b);
+ }
+
+ return true;
+}
+
+bool bcache_set_bytes(struct bcache *cache, int fd, uint64_t start, size_t len, uint8_t val)
+{
+ struct updater u;
+
+ u.cache = cache;
+ u.partial_fn = _set_partial;
+ u.whole_fn = _set_whole;
+ u.data = &val;
+
+ return _update_bytes(&u, fd, start, len);
+}
+
diff --git a/lib/device/bcache.h b/lib/device/bcache.h
index c07f012..599b4c6 100644
--- a/lib/device/bcache.h
+++ b/lib/device/bcache.h
@@ -162,6 +162,7 @@ void bcache_prefetch_bytes(struct bcache *cache, int fd, uint64_t start, size_t
bool bcache_read_bytes(struct bcache *cache, int fd, uint64_t start, size_t len, void *data);
bool bcache_write_bytes(struct bcache *cache, int fd, uint64_t start, size_t len, void *data);
bool bcache_zero_bytes(struct bcache *cache, int fd, uint64_t start, size_t len);
+bool bcache_set_bytes(struct bcache *cache, int fd, uint64_t start, size_t len, uint8_t val);
//----------------------------------------------------------------
diff --git a/test/unit/bcache_utils_t.c b/test/unit/bcache_utils_t.c
index d3ddb9a..255caff 100644
--- a/test/unit/bcache_utils_t.c
+++ b/test/unit/bcache_utils_t.c
@@ -140,7 +140,7 @@ static void _verify(struct fixture *f, uint64_t byte_b, uint64_t byte_e, uint8_t
}
}
-static void _verify_zeroes(struct fixture *f, uint64_t byte_b, uint64_t byte_e)
+static void _verify_set(struct fixture *f, uint64_t byte_b, uint64_t byte_e, uint8_t val)
{
int err;
unsigned i;
@@ -155,7 +155,7 @@ static void _verify_zeroes(struct fixture *f, uint64_t byte_b, uint64_t byte_e)
blen = _min(T_BLOCK_SIZE - offset, len);
for (i = 0; i < blen; i++)
- T_ASSERT(((uint8_t *) b->data)[offset + i] == 0);
+ T_ASSERT(((uint8_t *) b->data)[offset + i] == val);
offset = 0;
len -= blen;
@@ -164,6 +164,11 @@ static void _verify_zeroes(struct fixture *f, uint64_t byte_b, uint64_t byte_e)
}
}
+static void _verify_zeroes(struct fixture *f, uint64_t byte_b, uint64_t byte_e)
+{
+ _verify_set(f, byte_b, byte_e, 0);
+}
+
static void _do_write(struct fixture *f, uint64_t byte_b, uint64_t byte_e, uint8_t pat)
{
unsigned i;
@@ -183,6 +188,11 @@ static void _do_zero(struct fixture *f, uint64_t byte_b, uint64_t byte_e)
T_ASSERT(bcache_zero_bytes(f->cache, f->fd, byte_b, byte_e - byte_b));
}
+static void _do_set(struct fixture *f, uint64_t byte_b, uint64_t byte_e, uint8_t val)
+{
+ T_ASSERT(bcache_set_bytes(f->cache, f->fd, byte_b, byte_e - byte_b, val));
+}
+
static void _reopen(struct fixture *f)
{
struct io_engine *engine;
@@ -296,6 +306,51 @@ static void _test_zero_many_boundaries(void *fixture)
//----------------------------------------------------------------
+static void _set_cycle(struct fixture *f, uint64_t b, uint64_t e)
+{
+ uint8_t val = random();
+
+ _verify(f, b, e, INIT_PATTERN);
+ _do_set(f, b, e, val);
+ _reopen(f);
+ _verify(f, b < 128 ? 0 : b - 128, b, INIT_PATTERN);
+ _verify_set(f, b, e, val);
+ _verify(f, e, _min(e + 128, _max_byte()), INIT_PATTERN);
+}
+
+static void _test_set_first_block(void *fixture)
+{
+ _set_cycle(fixture, byte(0, 0), byte(0, T_BLOCK_SIZE));
+}
+
+static void _test_set_last_block(void *fixture)
+{
+ uint64_t last_block = NR_BLOCKS - 1;
+ _set_cycle(fixture, byte(last_block, 0), byte(last_block, T_BLOCK_SIZE));
+}
+
+static void _test_set_several_whole_blocks(void *fixture)
+{
+ _set_cycle(fixture, byte(5, 0), byte(10, 0));
+}
+
+static void _test_set_within_single_block(void *fixture)
+{
+ _set_cycle(fixture, byte(7, 3), byte(7, T_BLOCK_SIZE / 2));
+}
+
+static void _test_set_cross_one_boundary(void *fixture)
+{
+ _set_cycle(fixture, byte(13, 43), byte(14, 43));
+}
+
+static void _test_set_many_boundaries(void *fixture)
+{
+ _set_cycle(fixture, byte(13, 13), byte(23, 13));
+}
+
+//----------------------------------------------------------------
+
#define T(path, desc, fn) register_test(ts, "/base/device/bcache/utils/" path, desc, fn)
static struct test_suite *_tests(void)
@@ -320,6 +375,13 @@ static struct test_suite *_tests(void)
T("zero-cross-one-boundary", "zero across one boundary", _test_zero_cross_one_boundary);
T("zero-many-boundaries", "zero many boundaries", _test_zero_many_boundaries);
+ T("set-first-block", "set the first block", _test_set_first_block);
+ T("set-last-block", "set the last block", _test_set_last_block);
+ T("set-several-blocks", "set several whole blocks", _test_set_several_whole_blocks);
+ T("set-within-single-block", "set within single block", _test_set_within_single_block);
+ T("set-cross-one-boundary", "set across one boundary", _test_set_cross_one_boundary);
+ T("set-many-boundaries", "set many boundaries", _test_set_many_boundaries);
+
return ts;
}
6 years
master - unit-test/bcache-utils: Tweak zero tests
by Joe Thornber
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2e1869b9231181cbd5c...
Commit: 2e1869b9231181cbd5c3cfa7dbbb3ef237ffa4a9
Parent: bc50dc6e70453c98e45aaa845db2828e586f9370
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Wed May 9 10:50:31 2018 +0100
Committer: Joe Thornber <ejt(a)redhat.com>
CommitterDate: Wed May 9 10:50:31 2018 +0100
unit-test/bcache-utils: Tweak zero tests
---
test/unit/bcache_utils_t.c | 26 ++------------------------
1 files changed, 2 insertions(+), 24 deletions(-)
diff --git a/test/unit/bcache_utils_t.c b/test/unit/bcache_utils_t.c
index 9c82068..d3ddb9a 100644
--- a/test/unit/bcache_utils_t.c
+++ b/test/unit/bcache_utils_t.c
@@ -102,11 +102,6 @@ static void _verify_bytes(struct block *b, uint64_t base,
T_ASSERT_EQUAL(((uint8_t *) b->data)[offset + i], _pattern_at(pat, base + offset + i));
}
-static void _zero_bytes(struct block *b, uint64_t offset, uint64_t len)
-{
- memset(((uint8_t *) b->data) + offset, 0, len);
-}
-
static uint64_t _min(uint64_t lhs, uint64_t rhs)
{
return rhs < lhs ? rhs : lhs;
@@ -179,30 +174,13 @@ static void _do_write(struct fixture *f, uint64_t byte_b, uint64_t byte_e, uint8
for (i = 0; i < len; i++)
buffer[i] = _pattern_at(pat, byte_b + i);
- T_ASSERT(bcache_write_bytes(f->cache, f->fd, byte_b, i, buffer));
+ T_ASSERT(bcache_write_bytes(f->cache, f->fd, byte_b, byte_e - byte_b, buffer));
free(buffer);
}
static void _do_zero(struct fixture *f, uint64_t byte_b, uint64_t byte_e)
{
- int err;
- struct block *b;
- block_address bb = byte_b / T_BLOCK_SIZE;
- block_address be = (byte_e + T_BLOCK_SIZE - 1) / T_BLOCK_SIZE;
- uint64_t offset = byte_b % T_BLOCK_SIZE;
- uint64_t blen, len = byte_e - byte_b;
-
- for (; bb != be; bb++) {
- T_ASSERT(bcache_get(f->cache, f->fd, bb, GF_DIRTY, &b, &err));
-
- blen = _min(T_BLOCK_SIZE - offset, len);
- _zero_bytes(b, offset, blen);
-
- offset = 0;
- len -= blen;
-
- bcache_put(b);
- }
+ T_ASSERT(bcache_zero_bytes(f->cache, f->fd, byte_b, byte_e - byte_b));
}
static void _reopen(struct fixture *f)
6 years