master - [device/bcache] fix bug in _alloc_block
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=19647d1cd44d029a8aa...
Commit: 19647d1cd44d029a8aa2f7e74dbdbd1f114a8c08
Parent: 1563b936911d26c665b590f200884c9ed31ab7c3
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Fri Feb 2 14:34:45 2018 +0000
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 20 11:12:50 2018 -0500
[device/bcache] fix bug in _alloc_block
---
lib/device/bcache.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/device/bcache.c b/lib/device/bcache.c
index 4283ce5..e5d0e1b 100644
--- a/lib/device/bcache.c
+++ b/lib/device/bcache.c
@@ -449,8 +449,10 @@ static void _exit_free_list(struct bcache *cache)
static struct block *_alloc_block(struct bcache *cache)
{
- struct block *b = dm_list_struct_base(_list_pop(&cache->free), struct block, list);
- return b;
+ if (dm_list_empty(&cache->free))
+ return NULL;
+
+ return dm_list_struct_base(_list_pop(&cache->free), struct block, list);
}
/*----------------------------------------------------------------
5 years, 12 months
master - [device/bcache] Add bcache_max_prefetches()
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1563b936911d26c665b...
Commit: 1563b936911d26c665b590f200884c9ed31ab7c3
Parent: c4c4acfd423323cbe8fbfbdb8c1882edb4a92b29
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Fri Feb 2 12:06:14 2018 +0000
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 20 11:12:50 2018 -0500
[device/bcache] Add bcache_max_prefetches()
Ignore prefetches if max io is in flight.
---
lib/device/bcache.c | 23 +++++++++++++++--------
lib/device/bcache.h | 1 +
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/lib/device/bcache.c b/lib/device/bcache.c
index 09ef6ef..4283ce5 100644
--- a/lib/device/bcache.c
+++ b/lib/device/bcache.c
@@ -216,17 +216,18 @@ static bool _engine_issue(struct io_engine *e, enum dir d, int fd,
return true;
}
-#define MAX_IO 64
+#define MAX_IO 1024
+#define MAX_EVENT 64
typedef void complete_fn(void *context, int io_error);
static bool _engine_wait(struct io_engine *e, complete_fn fn)
{
int i, r;
- struct io_event event[MAX_IO];
+ struct io_event event[MAX_EVENT];
struct control_block *cb;
memset(&event, 0, sizeof(event));
- r = io_getevents(e->aio_context, 1, MAX_IO, event, NULL);
+ r = io_getevents(e->aio_context, 1, MAX_EVENT, event, NULL);
if (r < 0) {
log_sys_warn("io_getevents");
return false;
@@ -300,6 +301,7 @@ struct bcache {
sector_t block_sectors;
uint64_t nr_data_blocks;
uint64_t nr_cache_blocks;
+ unsigned max_io;
struct io_engine *engine;
@@ -762,8 +764,8 @@ struct bcache *bcache_create(sector_t block_sectors, unsigned nr_cache_blocks)
cache->block_sectors = block_sectors;
cache->nr_cache_blocks = nr_cache_blocks;
-
- cache->engine = _engine_create(nr_cache_blocks < 1024u ? nr_cache_blocks : 1024u);
+ cache->max_io = nr_cache_blocks < MAX_IO ? nr_cache_blocks : MAX_IO;
+ cache->engine = _engine_create(cache->max_io);
if (!cache->engine) {
dm_free(cache);
return NULL;
@@ -820,16 +822,21 @@ unsigned bcache_nr_cache_blocks(struct bcache *cache)
return cache->nr_cache_blocks;
}
+unsigned bcache_max_prefetches(struct bcache *cache)
+{
+ return cache->max_io;
+}
+
void bcache_prefetch(struct bcache *cache, int fd, block_address index)
{
struct block *b = _hash_lookup(cache, fd, index);
if (!b) {
- cache->prefetches++;
-
b = _new_block(cache, fd, index);
- if (b)
+ if (b && (cache->nr_io_pending < cache->max_io)) {
+ cache->prefetches++;
_issue_read(b);
+ }
}
}
diff --git a/lib/device/bcache.h b/lib/device/bcache.h
index 5c68e3c..14204be 100644
--- a/lib/device/bcache.h
+++ b/lib/device/bcache.h
@@ -62,6 +62,7 @@ enum bcache_get_flags {
typedef uint64_t block_address;
unsigned bcache_nr_cache_blocks(struct bcache *cache);
+unsigned bcache_max_prefetches(struct bcache *cache);
/*
* Use the prefetch method to take advantage of asynchronous IO. For example,
5 years, 12 months
master - [device/bcache] Add a couple of invalidate methods
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c4c4acfd423323cbe8f...
Commit: c4c4acfd423323cbe8fbfbdb8c1882edb4a92b29
Parent: 0f0eb04edb00cb5e95c47cb9ca2e70574e6e49ce
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Fri Feb 2 07:59:49 2018 +0000
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 20 11:12:50 2018 -0500
[device/bcache] Add a couple of invalidate methods
---
lib/device/bcache.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++
lib/device/bcache.h | 13 +++++++++++
2 files changed, 73 insertions(+), 0 deletions(-)
diff --git a/lib/device/bcache.c b/lib/device/bcache.c
index 5a7b2f9..09ef6ef 100644
--- a/lib/device/bcache.c
+++ b/lib/device/bcache.c
@@ -884,5 +884,65 @@ int bcache_flush(struct bcache *cache)
return dm_list_empty(&cache->errored) ? 0 : -EIO;
}
+static void _recycle_block(struct bcache *cache, struct block *b)
+{
+ _unlink_block(b);
+ _hash_remove(b);
+ dm_list_add(&cache->free, &b->list);
+}
+
+/*
+ * You can safely call this with a NULL block.
+ */
+static void _invalidate_block(struct bcache *cache, struct block *b)
+{
+ if (!b)
+ return;
+
+ if (_test_flags(b, BF_IO_PENDING))
+ _wait_specific(b);
+
+ if (b->ref_count)
+ log_warn("bcache_invalidate: block (%d, %llu) still held",
+ b->fd, (unsigned long long) index);
+ else {
+ if (_test_flags(b, BF_DIRTY)) {
+ _issue_write(b);
+ _wait_specific(b);
+ }
+
+ _recycle_block(cache, b);
+ }
+}
+
+void bcache_invalidate(struct bcache *cache, int fd, block_address index)
+{
+ _invalidate_block(cache, _hash_lookup(cache, fd, index));
+}
+
+// FIXME: switch to a trie, or maybe 1 hash table per fd? To save iterating
+// through the whole cache.
+void bcache_invalidate_fd(struct bcache *cache, int fd)
+{
+ struct block *b, *tmp;
+
+ // Start writing back any dirty blocks on this fd.
+ dm_list_iterate_items_safe (b, tmp, &cache->dirty)
+ if (b->fd == fd)
+ _issue_write(b);
+
+ _wait_all(cache);
+
+ // Everything should be in the clean list now.
+ dm_list_iterate_items_safe (b, tmp, &cache->clean)
+ if (b->fd == fd)
+ _invalidate_block(cache, b);
+
+ // Except they could be in the errored list :)
+ dm_list_iterate_items_safe (b, tmp, &cache->errored)
+ if (b->fd == fd)
+ _recycle_block(cache, b);
+}
+
//----------------------------------------------------------------
diff --git a/lib/device/bcache.h b/lib/device/bcache.h
index 2730347..5c68e3c 100644
--- a/lib/device/bcache.h
+++ b/lib/device/bcache.h
@@ -93,6 +93,19 @@ void bcache_put(struct block *b);
int bcache_flush(struct bcache *cache);
+/*
+ * Removes a block from the cache. If the block is dirty it will be written
+ * back first. If the block is currently held a warning will be issued, and it
+ * will not be removed.
+ */
+void bcache_invalidate(struct bcache *cache, int fd, block_address index);
+
+/*
+ * Invalidates all blocks on the given descriptor. Call this before closing
+ * the descriptor to make sure everything is written back.
+ */
+void bcache_invalidate_fd(struct bcache *cache, int fd);
+
/*----------------------------------------------------------------*/
#endif
5 years, 12 months
master - [device/bcache] some more work on bcache
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0f0eb04edb00cb5e95c...
Commit: 0f0eb04edb00cb5e95c47cb9ca2e70574e6e49ce
Parent: 46867a45d28ecb667d08df8d8cb497fffc10814d
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Thu Feb 1 14:52:43 2018 +0000
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 20 11:12:50 2018 -0500
[device/bcache] some more work on bcache
---
lib/device/bcache.c | 99 ++++++++++++++++++++++-----------
lib/device/bcache.h | 2 +-
test/unit/Makefile.in | 2 +-
test/unit/bcache_t.c | 147 +++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 216 insertions(+), 34 deletions(-)
diff --git a/lib/device/bcache.c b/lib/device/bcache.c
index 3b8cf78..5a7b2f9 100644
--- a/lib/device/bcache.c
+++ b/lib/device/bcache.c
@@ -167,12 +167,19 @@ static struct io_engine *_engine_create(unsigned max_io)
static void _engine_destroy(struct io_engine *e)
{
+ int r;
+
_cb_set_destroy(e->cbs);
- io_destroy(e->aio_context);
+
+ // io_destroy is really slow
+ r = io_destroy(e->aio_context);
+ if (r)
+ log_sys_warn("io_destroy");
+
dm_free(e);
}
-static bool _engine_issue(struct io_engine *e, int fd, enum dir d,
+static bool _engine_issue(struct io_engine *e, enum dir d, int fd,
sector_t sb, sector_t se, void *data, void *context)
{
int r;
@@ -290,7 +297,6 @@ enum block_flags {
};
struct bcache {
- int fd;
sector_t block_sectors;
uint64_t nr_data_blocks;
uint64_t nr_cache_blocks;
@@ -488,6 +494,30 @@ static void _relink(struct block *b)
*
*--------------------------------------------------------------*/
+static void _complete_io(void *context, int err)
+{
+ struct block *b = context;
+ struct bcache *cache = b->cache;
+
+ b->error = err;
+ _clear_flags(b, BF_IO_PENDING);
+ cache->nr_io_pending--;
+
+ /*
+ * b is on the io_pending list, so we don't want to use unlink_block.
+ * Which would incorrectly adjust nr_dirty.
+ */
+ dm_list_del(&b->list);
+
+ if (b->error)
+ dm_list_add(&cache->errored, &b->list);
+
+ else {
+ _clear_flags(b, BF_DIRTY);
+ _link_block(b);
+ }
+}
+
/*
* |b->list| should be valid (either pointing to itself, on one of the other
* lists.
@@ -502,7 +532,13 @@ static bool _issue_low_level(struct block *b, enum dir d)
return false;
_set_flags(b, BF_IO_PENDING);
- return _engine_issue(cache->engine, cache->fd, d, sb, se, b->data, b);
+ if (!_engine_issue(cache->engine, d, b->fd, sb, se, b->data, b)) {
+ _complete_io(b, -EIO);
+ return false;
+ }
+
+ return true;
+
}
static inline bool _issue_read(struct block *b)
@@ -515,30 +551,6 @@ static inline bool _issue_write(struct block *b)
return _issue_low_level(b, DIR_WRITE);
}
-static void _complete_io(void *context, int err)
-{
- struct block *b = context;
- struct bcache *cache = b->cache;
-
- b->error = err;
- _clear_flags(b, BF_IO_PENDING);
- cache->nr_io_pending--;
-
- /*
- * b is on the io_pending list, so we don't want to use unlink_block.
- * Which would incorrectly adjust nr_dirty.
- */
- dm_list_del(&b->list);
-
- if (b->error)
- dm_list_add(&cache->errored, &b->list);
-
- else {
- _clear_flags(b, BF_DIRTY);
- _link_block(b);
- }
-}
-
static bool _wait_io(struct bcache *cache)
{
return _engine_wait(cache->engine, _complete_io);
@@ -598,7 +610,7 @@ static struct block *_find_unused_clean_block(struct bcache *cache)
return NULL;
}
-static struct block *_new_block(struct bcache *cache, block_address index)
+static struct block *_new_block(struct bcache *cache, int fd, block_address index)
{
struct block *b;
@@ -616,6 +628,7 @@ static struct block *_new_block(struct bcache *cache, block_address index)
dm_list_init(&b->list);
dm_list_init(&b->hash);
b->flags = 0;
+ b->fd = fd;
b->index = index;
b->ref_count = 0;
b->error = 0;
@@ -685,7 +698,7 @@ static struct block *_lookup_or_read_block(struct bcache *cache,
} else {
_miss(cache, flags);
- b = _new_block(cache, index);
+ b = _new_block(cache, fd, index);
if (b) {
if (flags & GF_ZERO)
_zero_block(b);
@@ -728,6 +741,21 @@ struct bcache *bcache_create(sector_t block_sectors, unsigned nr_cache_blocks)
{
struct bcache *cache;
+ if (!nr_cache_blocks) {
+ log_warn("bcache must have at least one cache block");
+ return NULL;
+ }
+
+ if (!block_sectors) {
+ log_warn("bcache must have a non zero block size");
+ return NULL;
+ }
+
+ if (block_sectors & ((PAGE_SIZE >> SECTOR_SHIFT) - 1)) {
+ log_warn("bcache block size must be a multiple of page size");
+ return NULL;
+ }
+
cache = dm_malloc(sizeof(*cache));
if (!cache)
return NULL;
@@ -787,6 +815,11 @@ void bcache_destroy(struct bcache *cache)
dm_free(cache);
}
+unsigned bcache_nr_cache_blocks(struct bcache *cache)
+{
+ return cache->nr_cache_blocks;
+}
+
void bcache_prefetch(struct bcache *cache, int fd, block_address index)
{
struct block *b = _hash_lookup(cache, fd, index);
@@ -794,7 +827,7 @@ void bcache_prefetch(struct bcache *cache, int fd, block_address index)
if (!b) {
cache->prefetches++;
- b = _new_block(cache, index);
+ b = _new_block(cache, fd, index);
if (b)
_issue_read(b);
}
@@ -803,7 +836,9 @@ void bcache_prefetch(struct bcache *cache, int fd, block_address index)
bool bcache_get(struct bcache *cache, int fd, block_address index,
unsigned flags, struct block **result)
{
- struct block *b = _lookup_or_read_block(cache, fd, index, flags);
+ struct block *b;
+
+ b = _lookup_or_read_block(cache, fd, index, flags);
if (b) {
if (!b->ref_count)
cache->nr_locked++;
diff --git a/lib/device/bcache.h b/lib/device/bcache.h
index 0747b5a..2730347 100644
--- a/lib/device/bcache.h
+++ b/lib/device/bcache.h
@@ -61,7 +61,7 @@ enum bcache_get_flags {
typedef uint64_t block_address;
-unsigned bcache_get_max_prefetches(struct bcache *cache);
+unsigned bcache_nr_cache_blocks(struct bcache *cache);
/*
* Use the prefetch method to take advantage of asynchronous IO. For example,
diff --git a/test/unit/Makefile.in b/test/unit/Makefile.in
index 8127ec0..5cf92ba 100644
--- a/test/unit/Makefile.in
+++ b/test/unit/Makefile.in
@@ -47,7 +47,7 @@ $(TARGETS): $(OBJECTS) $(top_builddir)/libdm/libdevmapper.$(LIB_SUFFIX)
$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) -L$(top_builddir)/libdm \
-o $@ $(OBJECTS) $(LDLIBS)
-unit: $(TARGETS)
+unit: $(TARGETS) $(top_builddir)/lib/liblvm-internal.a
@echo Running unit tests
LD_LIBRARY_PATH=$(top_builddir)/libdm ./$(TARGETS)
endif
diff --git a/test/unit/bcache_t.c b/test/unit/bcache_t.c
index da274a9..ef92721 100644
--- a/test/unit/bcache_t.c
+++ b/test/unit/bcache_t.c
@@ -12,9 +12,21 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#define _GNU_SOURCE
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
#include "units.h"
#include "bcache.h"
+#define MEG 2048
+#define SECTOR_SHIFT 9
+
+static const char *_test_path = "test.bin";
+
int bcache_init(void)
{
return 0;
@@ -25,6 +37,42 @@ int bcache_fini(void)
return 0;
}
+static int open_file(const char *path)
+{
+ return open(path, O_EXCL | O_RDWR | O_DIRECT, 0666);
+}
+
+static int _prep_file(const char *path)
+{
+ int fd, r;
+
+ fd = open(path, O_CREAT | O_TRUNC | O_EXCL | O_RDWR | O_DIRECT, 0666);
+ if (fd < 0)
+ return -1;
+
+ r = fallocate(fd, FALLOC_FL_ZERO_RANGE, 0, (16 * MEG) << SECTOR_SHIFT);
+ if (r) {
+ close(fd);
+ return -1;
+ }
+
+ close(fd);
+ return 0;
+}
+
+
+static int test_init(void)
+{
+ unlink(_test_path);
+ return _prep_file(_test_path);
+}
+
+static int test_exit(void)
+{
+ unlink(_test_path);
+ return 0;
+}
+
static void test_create(void)
{
struct bcache *cache = bcache_create(8, 16);
@@ -32,7 +80,106 @@ static void test_create(void)
bcache_destroy(cache);
}
+static void test_nr_cache_blocks_must_be_positive(void)
+{
+ struct bcache *cache = bcache_create(8, 0);
+ CU_ASSERT_PTR_NULL(cache);
+}
+
+static void test_block_size_must_be_positive(void)
+{
+ struct bcache *cache = bcache_create(0, 16);
+ CU_ASSERT_PTR_NULL(cache);
+}
+
+static void test_block_size_must_be_multiple_of_page_size(void)
+{
+ unsigned i;
+ struct bcache *cache;
+
+ {
+ static unsigned _bad_examples[] = {3, 9, 13, 1025};
+
+ for (i = 0; i < DM_ARRAY_SIZE(_bad_examples); i++) {
+ cache = bcache_create(_bad_examples[i], 16);
+ CU_ASSERT_PTR_NULL(cache);
+ }
+ }
+
+ {
+ // Only testing a few sizes because io_destroy is seriously
+ // slow.
+ for (i = 1; i < 25; i++) {
+ cache = bcache_create(8 * i, 16);
+ CU_ASSERT_PTR_NOT_NULL(cache);
+ bcache_destroy(cache);
+ }
+ }
+}
+
+static void test_reads_work(void)
+{
+ int fd;
+
+ // FIXME: add fixtures.
+ test_init();
+ fd = open_file("./test.bin");
+ CU_ASSERT(fd >= 0);
+
+ {
+ int i;
+ struct block *b;
+ struct bcache *cache = bcache_create(8, 16);
+
+ CU_ASSERT(bcache_get(cache, fd, 0, 0, &b));
+ for (i = 0; i < 8 << SECTOR_SHIFT; i++)
+ CU_ASSERT(((unsigned char *) b->data)[i] == 0);
+ bcache_put(b);
+
+ bcache_destroy(cache);
+ }
+
+ close(fd);
+
+ test_exit();
+}
+
+static void test_prefetch_works(void)
+{
+ int fd;
+
+ // FIXME: add fixtures.
+ test_init();
+ fd = open_file("./test.bin");
+ CU_ASSERT(fd >= 0);
+
+ {
+ int i;
+ struct block *b;
+ struct bcache *cache = bcache_create(8, 16);
+
+ for (i = 0; i < 16; i++)
+ bcache_prefetch(cache, fd, i);
+
+ for (i = 0; i < 16; i++) {
+ CU_ASSERT(bcache_get(cache, fd, i, 0, &b));
+ bcache_put(b);
+ }
+
+ bcache_destroy(cache);
+ }
+
+ close(fd);
+
+ test_exit();
+}
+
CU_TestInfo bcache_list[] = {
{ (char*)"create", test_create },
+ { (char*)"nr cache block must be positive", test_nr_cache_blocks_must_be_positive },
+ { (char*)"block size must be positive", test_block_size_must_be_positive },
+ { (char*)"block size must be multiple of page size", test_block_size_must_be_multiple_of_page_size },
+ { (char*)"reads work", test_reads_work },
+ { (char*)"prefetch works", test_prefetch_works },
CU_TEST_INFO_NULL
};
5 years, 12 months
master - [device/bcache] stub a unit test
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=46867a45d28ecb667d0...
Commit: 46867a45d28ecb667d08df8d8cb497fffc10814d
Parent: cb2c4542a6028ef09d30bfdcdaef4e7ddb740ca7
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Thu Feb 1 09:54:56 2018 +0000
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 20 11:12:50 2018 -0500
[device/bcache] stub a unit test
---
include/.symlinks.in | 1 +
lib/device/bcache.h | 1 +
test/unit/Makefile.in | 3 ++-
test/unit/bcache_t.c | 38 ++++++++++++++++++++++++++++++++++++++
test/unit/run.c | 1 +
test/unit/units.h | 1 +
6 files changed, 44 insertions(+), 1 deletions(-)
diff --git a/include/.symlinks.in b/include/.symlinks.in
index a1b5c1e..3d50750 100644
--- a/include/.symlinks.in
+++ b/include/.symlinks.in
@@ -14,6 +14,7 @@
@top_srcdir(a)/lib/config/defaults.h
@top_srcdir(a)/lib/datastruct/btree.h
@top_srcdir(a)/lib/datastruct/str_list.h
+@top_srcdir(a)/lib/device/bcache.h
@top_srcdir(a)/lib/device/dev-cache.h
@top_srcdir(a)/lib/device/dev-ext-udev-constants.h
@top_srcdir(a)/lib/device/dev-type.h
diff --git a/lib/device/bcache.h b/lib/device/bcache.h
index 3227744..0747b5a 100644
--- a/lib/device/bcache.h
+++ b/lib/device/bcache.h
@@ -16,6 +16,7 @@
#define BCACHE_H
#include <stdint.h>
+#include <stdbool.h>
#include "libdevmapper.h"
diff --git a/test/unit/Makefile.in b/test/unit/Makefile.in
index 3de30f2..8127ec0 100644
--- a/test/unit/Makefile.in
+++ b/test/unit/Makefile.in
@@ -16,6 +16,7 @@ top_builddir = @top_builddir@
VPATH = $(srcdir)
UNITS = \
+ bcache_t.c \
bitset_t.c\
config_t.c\
dmlist_t.c\
@@ -37,7 +38,7 @@ SOURCES = $(UNITS)
endif
ifeq ("$(TESTING)", "yes")
-LDLIBS += -ldevmapper @CUNIT_LIBS@
+LDLIBS += $(LVMINTERNAL_LIBS) -ldevmapper -laio @CUNIT_LIBS@
CFLAGS += @CUNIT_CFLAGS@
check: unit
diff --git a/test/unit/bcache_t.c b/test/unit/bcache_t.c
new file mode 100644
index 0000000..da274a9
--- /dev/null
+++ b/test/unit/bcache_t.c
@@ -0,0 +1,38 @@
+/*
+ * 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
+ */
+
+#include "units.h"
+#include "bcache.h"
+
+int bcache_init(void)
+{
+ return 0;
+}
+
+int bcache_fini(void)
+{
+ return 0;
+}
+
+static void test_create(void)
+{
+ struct bcache *cache = bcache_create(8, 16);
+ CU_ASSERT_PTR_NOT_NULL(cache);
+ bcache_destroy(cache);
+}
+
+CU_TestInfo bcache_list[] = {
+ { (char*)"create", test_create },
+ CU_TEST_INFO_NULL
+};
diff --git a/test/unit/run.c b/test/unit/run.c
index 7372138..82090ba 100644
--- a/test/unit/run.c
+++ b/test/unit/run.c
@@ -13,6 +13,7 @@
.pTests = n##_list }
CU_SuiteInfo suites[] = {
+ USE(bcache),
USE(bitset),
USE(config),
USE(dmlist),
diff --git a/test/unit/units.h b/test/unit/units.h
index 9eaa82f..319e7ce 100644
--- a/test/unit/units.h
+++ b/test/unit/units.h
@@ -23,6 +23,7 @@
int n ## _init(void); \
int n ## _fini(void);
+DECL(bcache);
DECL(bitset);
DECL(config);
DECL(dmlist);
5 years, 12 months
master - [unit tests] remove old unit tests that weren't built or run.
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=38d77898ae7a824b3a0...
Commit: 38d77898ae7a824b3a05ee2a1812d7a85cca6373
Parent: 7a475bef323cae74d602f2aae8074b106ddb3f4b
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Wed Jan 31 11:28:51 2018 +0000
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 20 11:10:46 2018 -0500
[unit tests] remove old unit tests that weren't built or run.
---
configure | 5 +-
configure.in | 3 -
old-tests/config/.gitignore | 1 -
old-tests/config/Makefile | 5 -
old-tests/config/config_t.c | 37 --
old-tests/config/empty_array.conf | 1 -
old-tests/config/vg0 | 169 -------
old-tests/datastruct/hash_t.c | 106 ----
old-tests/dev-mgr/dev_cache_t.c | 54 --
old-tests/device/Makefile.in | 29 --
old-tests/device/dev_cache_t.c | 70 ---
old-tests/device/fill_device.c | 27 -
old-tests/device/random.c | 116 -----
old-tests/device/random.h | 32 --
old-tests/filters/Makefile.in | 35 --
old-tests/filters/pfilter_t.c | 121 -----
old-tests/filters/rfilter_t.c | 92 ----
old-tests/filters/sample.cfg | 21 -
old-tests/format1/Makefile.in | 52 --
old-tests/format1/get_pvs_t.c | 73 ---
old-tests/format1/get_vgs_t.c | 69 ---
old-tests/format1/pretty_print.c | 86 ----
old-tests/format1/pretty_print.h | 28 --
old-tests/format1/read_pv_t.c | 75 ---
old-tests/format1/read_vg_t.c | 75 ---
old-tests/format1/write_vg_t.c | 77 ---
old-tests/mm/Makefile.in | 33 --
old-tests/mm/dbg_malloc_t.c | 156 ------
unit-tests/datastruct/Makefile.in | 32 --
unit-tests/datastruct/TESTS | 1 -
unit-tests/datastruct/bitset_t.c | 133 -----
unit-tests/mm/Makefile.in | 31 --
unit-tests/mm/TESTS | 1 -
unit-tests/mm/check_results | 31 --
unit-tests/mm/pool_valgrind_t.c | 181 -------
unit-tests/regex/Makefile.in | 37 --
unit-tests/regex/TESTS | 3 -
unit-tests/regex/dev_patterns | 2 -
unit-tests/regex/devices.list | 880 ----------------------------------
unit-tests/regex/matcher_t.c | 156 ------
unit-tests/regex/matcher_t.expected | 16 -
unit-tests/regex/matcher_t.expected2 | 1 -
unit-tests/regex/matcher_t.expected3 | 3 -
unit-tests/regex/nonprint_input | 4 -
unit-tests/regex/nonprint_regexes | 3 -
unit-tests/regex/parse_t.c | 118 -----
unit-tests/regex/random_regexes | 100 ----
47 files changed, 1 insertions(+), 3380 deletions(-)
diff --git a/configure b/configure
index 7f41249..5011089 100755
--- a/configure
+++ b/configure
@@ -15860,7 +15860,7 @@ _ACEOF
################################################################################
-ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/raid/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile daemons/dmeventd/plugins/thin/Makefile daemons/dmfilemapd/Makefile daemons/lvmdbusd/Makefile daemons/lvmdbusd/lvmdbusd daemons/lvmdbusd/lvmdb.py daemons/lvmdbusd/lvm_shell_proxy.py daemons/lvmdbusd/path.py daemons/lvmetad/Makefile daemons/lvmpolld/Makefile daemons/lvmlockd/Makefile conf/Makefile conf/example.conf conf/lvmlocal.conf conf/command_profile_template.profile conf/metadata_profile_template.profile include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile include/lvm-version.h lib/raid/Makefile lib/snapshot/Makefile lib/thin/
Makefile lib/cache_segtype/Makefile libdaemon/Makefile libdaemon/client/Makefile libdaemon/server/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile python/Makefile python/setup.py scripts/blkdeactivate.sh scripts/blk_availability_init_red_hat scripts/blk_availability_systemd_red_hat.service scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/com.redhat.lvmdbus1.service scripts/dm_event_systemd_red_hat.service scripts/dm_event_systemd_red_hat.socket scripts/lvm2_cluster_activation_red_hat.sh scripts/lvm2_cluster_activation_systemd_red_hat.service scripts/lvm2_clvmd_systemd_red_hat.service scripts/lvm2_cmirrord_systemd_red_hat.service scripts/lvm2_lvmdbusd_systemd_red_hat.service scripts/lvm2_lvmetad_init_red_hat scripts/lvm2_lvmetad_systemd_red_hat.service scripts/lvm2_lvmetad_systemd_red_hat.socket scripts/lvm2_lvmpolld_init_red_hat scripts/lvm2_lvmpolld_systemd_red_hat.service scripts/lvm2_lvmpolld_systemd_red_h
at.socket scripts/lvm2_lvmlockd_systemd_red_hat.service scripts/lvm2_lvmlocking_systemd_red_hat.service scripts/lvm2_monitoring_init_red_hat scripts/lvm2_monitoring_systemd_red_hat.service scripts/lvm2_pvscan_systemd_red_hat@.service scripts/lvm2_tmpfiles_red_hat.conf scripts/lvmdump.sh scripts/Makefile test/Makefile test/api/Makefile test/unit/Makefile tools/Makefile udev/Makefile unit-tests/datastruct/Makefile unit-tests/regex/Makefile unit-tests/mm/Makefile"
+ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/raid/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile daemons/dmeventd/plugins/thin/Makefile daemons/dmfilemapd/Makefile daemons/lvmdbusd/Makefile daemons/lvmdbusd/lvmdbusd daemons/lvmdbusd/lvmdb.py daemons/lvmdbusd/lvm_shell_proxy.py daemons/lvmdbusd/path.py daemons/lvmetad/Makefile daemons/lvmpolld/Makefile daemons/lvmlockd/Makefile conf/Makefile conf/example.conf conf/lvmlocal.conf conf/command_profile_template.profile conf/metadata_profile_template.profile include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile include/lvm-version.h lib/raid/Makefile lib/snapshot/Makefile lib/thin/
Makefile lib/cache_segtype/Makefile libdaemon/Makefile libdaemon/client/Makefile libdaemon/server/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile python/Makefile python/setup.py scripts/blkdeactivate.sh scripts/blk_availability_init_red_hat scripts/blk_availability_systemd_red_hat.service scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/com.redhat.lvmdbus1.service scripts/dm_event_systemd_red_hat.service scripts/dm_event_systemd_red_hat.socket scripts/lvm2_cluster_activation_red_hat.sh scripts/lvm2_cluster_activation_systemd_red_hat.service scripts/lvm2_clvmd_systemd_red_hat.service scripts/lvm2_cmirrord_systemd_red_hat.service scripts/lvm2_lvmdbusd_systemd_red_hat.service scripts/lvm2_lvmetad_init_red_hat scripts/lvm2_lvmetad_systemd_red_hat.service scripts/lvm2_lvmetad_systemd_red_hat.socket scripts/lvm2_lvmpolld_init_red_hat scripts/lvm2_lvmpolld_systemd_red_hat.service scripts/lvm2_lvmpolld_systemd_red_h
at.socket scripts/lvm2_lvmlockd_systemd_red_hat.service scripts/lvm2_lvmlocking_systemd_red_hat.service scripts/lvm2_monitoring_init_red_hat scripts/lvm2_monitoring_systemd_red_hat.service scripts/lvm2_pvscan_systemd_red_hat@.service scripts/lvm2_tmpfiles_red_hat.conf scripts/lvmdump.sh scripts/Makefile test/Makefile test/api/Makefile test/unit/Makefile tools/Makefile udev/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -16637,9 +16637,6 @@ do
"test/unit/Makefile") CONFIG_FILES="$CONFIG_FILES test/unit/Makefile" ;;
"tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;;
"udev/Makefile") CONFIG_FILES="$CONFIG_FILES udev/Makefile" ;;
- "unit-tests/datastruct/Makefile") CONFIG_FILES="$CONFIG_FILES unit-tests/datastruct/Makefile" ;;
- "unit-tests/regex/Makefile") CONFIG_FILES="$CONFIG_FILES unit-tests/regex/Makefile" ;;
- "unit-tests/mm/Makefile") CONFIG_FILES="$CONFIG_FILES unit-tests/mm/Makefile" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
diff --git a/configure.in b/configure.in
index b8e1623..0d268e8 100644
--- a/configure.in
+++ b/configure.in
@@ -2254,9 +2254,6 @@ test/api/Makefile
test/unit/Makefile
tools/Makefile
udev/Makefile
-unit-tests/datastruct/Makefile
-unit-tests/regex/Makefile
-unit-tests/mm/Makefile
])
AC_OUTPUT
diff --git a/old-tests/config/.gitignore b/old-tests/config/.gitignore
deleted file mode 100644
index 2460008..0000000
--- a/old-tests/config/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-!Makefile
diff --git a/old-tests/config/Makefile b/old-tests/config/Makefile
deleted file mode 100644
index d753b64..0000000
--- a/old-tests/config/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-config_t: config_t.c
- gcc -g -I../../include config_t.c -L../../lib -llvm -o config_t
-
-clean:
- rm config_t
\ No newline at end of file
diff --git a/old-tests/config/config_t.c b/old-tests/config/config_t.c
deleted file mode 100644
index 9b9e56e..0000000
--- a/old-tests/config/config_t.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Test program that reads, then writes a config file.
- */
-#include <stdio.h>
-
-#include "config.h"
-
-int main(int argc, char **argv)
-{
- struct config_file *cf;
-
- if (argc != 2) {
- fprintf(stderr, "Usage: %s <config_file>\n", argv[0]);
- exit(1);
- }
-
- cf = create_config_file();
- if (cf == NULL) {
- fprintf(stderr, "Couldn't create config_file object.\n");
- exit(1);
- }
-
-
- if (!read_config(cf, argv[1])) {
- fprintf(stderr, "Couldn't read config file '%s'\n", argv[0]);
- exit(1);
- }
-
- if (!write_config(cf, "out")) {
- fprintf(stderr, "Couldn't write config file 'out'\n");
- exit(1);
- }
-
- destroy_config_file(cf);
- dump_memory();
- return 0;
-}
diff --git a/old-tests/config/empty_array.conf b/old-tests/config/empty_array.conf
deleted file mode 100644
index 0cc2f28..0000000
--- a/old-tests/config/empty_array.conf
+++ /dev/null
@@ -1 +0,0 @@
-foo = []
\ No newline at end of file
diff --git a/old-tests/config/vg0 b/old-tests/config/vg0
deleted file mode 100644
index bfa9567..0000000
--- a/old-tests/config/vg0
+++ /dev/null
@@ -1,169 +0,0 @@
-# This file was originally generated by the LVM2 library
-# Generated: Wed Jul 17 22:41:37 2002
-
-
-description = "Created *after* executing 'lvcreate --quiet -s -n snap -c 512k -L200M vg0/origin /dev/hda8'"
-creation_time = 1026942097
-
-vg0 {
- id = "Qmd96y-771S-Esbb-Zp6u-8xo9-Cfmt-YvndHY"
- seqno = 2
- status = ["RESIZEABLE", "READ", "WRITE"]
- system_id = "reti1014805292"
- extent_size = 8192 # 4 Megabytes
- max_lv = 255
- max_pv = 255
-
- physical_volumes {
-
- pv0 {
- id = "8nRQub-EquY-VR1C-Ipdv-6hEO-FuFT-wnlN5R"
- device = "/dev/discs/disc0/part8" # Hint only
-
- status = ["ALLOCATABLE"]
- pe_start = 256
- pe_count = 501 # 1.95703 Gigabytes
- }
-
- pv1 {
- id = "mRU6Mf-z1Sv-Kuqw-Ct1v-eC42-mnqs-YD1RrL"
- device = "/dev/discs/disc1/part2" # Hint only
-
- status = ["ALLOCATABLE"]
- pe_start = 384
- pe_count = 7269 # 28.3945 Gigabytes
- }
- }
-
- logical_volumes {
-
- music {
- id = "000000-0000-0000-0000-0000-0000-000000"
- status = ["READ", "WRITE", "ALLOC_SIMPLE"]
- read_ahead = 0
- segment_count = 2
-
- segment1 {
- start_extent = 0
- extent_count = 1024 # 4 Gigabytes
- stripes = 1
-
- areas = [
- "pv1", 0
- ]
- }
- segment2 {
- start_extent = 1024
- extent_count = 2560 # 10 Gigabytes
- stripes = 1
-
- areas = [
- "pv1", 3584
- ]
- }
- }
-
- photos {
- id = "000000-0000-0000-0000-0000-0000-000002"
- status = ["READ", "WRITE", "ALLOC_SIMPLE"]
- read_ahead = 0
- segment_count = 1
-
- segment1 {
- start_extent = 0
- extent_count = 1024 # 4 Gigabytes
- stripes = 1
-
- areas = [
- "pv1", 2048
- ]
- }
- }
-
- repositories {
- id = "000000-0000-0000-0000-0000-0000-000003"
- status = ["READ", "WRITE", "ALLOC_SIMPLE"]
- read_ahead = 0
- segment_count = 1
-
- segment1 {
- start_extent = 0
- extent_count = 512 # 2 Gigabytes
- stripes = 1
-
- areas = [
- "pv1", 3072
- ]
- }
- }
-
- origin {
- id = "000000-0000-0000-0000-0000-0000-000004"
- status = ["READ", "WRITE", "ALLOC_SIMPLE"]
- read_ahead = 0
- segment_count = 1
-
- segment1 {
- start_extent = 0
- extent_count = 50 # 200 Megabytes
- stripes = 1
-
- areas = [
- "pv1", 6144
- ]
- }
- }
-
- packages {
- id = "000000-0000-0000-0000-0000-0000-000006"
- status = ["READ", "WRITE", "ALLOC_SIMPLE"]
- read_ahead = 0
- segment_count = 2
-
- segment1 {
- start_extent = 0
- extent_count = 451 # 1.76172 Gigabytes
- stripes = 1
-
- areas = [
- "pv0", 50
- ]
- }
- segment2 {
- start_extent = 451
- extent_count = 573 # 2.23828 Gigabytes
- stripes = 1
-
- areas = [
- "pv1", 6194
- ]
- }
- }
-
- snap {
- id = "000000-0000-0000-0000-0000-0000-000001"
- status = ["READ", "WRITE", "ALLOC_SIMPLE"]
- read_ahead = 0
- segment_count = 1
-
- segment1 {
- start_extent = 0
- extent_count = 50 # 200 Megabytes
- stripes = 1
-
- areas = [
- "pv0", 0
- ]
- }
- }
- }
-
- snapshots {
-
- snapshot0 {
- chunk_size = 1024
- origin = "origin"
- cow_store = "snap"
- }
- }
-}
diff --git a/old-tests/datastruct/hash_t.c b/old-tests/datastruct/hash_t.c
deleted file mode 100644
index 7c9e435..0000000
--- a/old-tests/datastruct/hash_t.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004 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
- */
-
-#include <stdio.h>
-
-static void _help(FILE *fp, const char *prog)
-{
- fprintf(fp, "Usage : %s <table size> <num_entries>\n", prog);
-}
-
-struct key_list {
- struct key_list *next;
- char key[1];
-};
-
-static struct key_list *_create_word(int n)
-{
- struct key_list *kl = dbg_malloc(sizeof(*kl) + 32);
- snprintf(kl->key, 32, "abc%ddef%d", n, n);
- kl->next = 0;
- return kl;
-}
-
-static struct key_list *_create_word_from_file(int n)
-{
- char word[128], *ptr;
- struct key_list *kl;
-
- if (!fgets(word, sizeof(word), stdin))
- return 0;
-
- for (ptr = word; *ptr; ptr++) {
- if (*ptr == '\n') {
- *ptr = 0;
- break;
- }
- }
-
- kl = dbg_malloc(sizeof(*kl) + 32);
- snprintf(kl->key, 32, "%s", word);
- kl->next = 0;
- return kl;
-}
-
-static void _do_test(int table_size, int num_entries)
-{
- int i;
- hash_table_t ht = hash_create(table_size);
- struct key_list *tmp, *key, *all = 0;
-
- for (i = 0; i < num_entries; i++) {
- /* make up a word */
- if (!(key = _create_word_from_file(i))) {
- log_error("Ran out of words !\n");
- exit(1);
- }
-
- /* insert it */
- hash_insert(ht, key->key, key);
- key->next = all;
- all = key;
- }
-
- for (key = all; key; key = key->next) {
- tmp = (struct key_list *) hash_lookup(ht, key->key);
- if (!tmp || (tmp != key)) {
- log_error("lookup failed\n");
- exit(1);
- }
- }
-
- for (key = all; key; key = tmp) {
- tmp = key->next;
- dbg_free(key);
- }
-
- hash_destroy(ht);
-}
-
-int main(int argc, char **argv)
-{
- init_log();
-
- if (argc != 3) {
- _help(stderr, argv[0]);
- exit(1);
- }
-
- _do_test(atoi(argv[1]), atoi(argv[2]));
-
- dump_memory();
- fin_log();
- return 0;
-}
diff --git a/old-tests/dev-mgr/dev_cache_t.c b/old-tests/dev-mgr/dev_cache_t.c
deleted file mode 100644
index af9539f..0000000
--- a/old-tests/dev-mgr/dev_cache_t.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004 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
- */
-
-#include "dev-cache.h"
-#include "log.h"
-
-#include <stdio.h>
-
-int main(int argc, char **argv)
-{
- int i;
- struct device *dev;
- struct dev_iter *iter;
-
- init_log();
- if (!dev_cache_init()) {
- log_error("couldn't initialise dev_cache_init failed\n");
- exit(1);
- }
-
- for (i = 1; i < argc; i++) {
- if (!dev_cache_add_dir(argv[i])) {
- log_error("couldn't add '%s' to dev_cache\n");
- exit(1);
- }
- }
-
- if (!(iter = dev_iter_create(NULL))) {
- log_error("couldn't create iterator\n");
- exit(1);
- }
-
- while ((dev = dev_iter_next(iter)))
- printf("%s\n", dev->name);
-
- dev_iter_destroy(iter):
- dev_cache_exit();
-
- dump_memory();
- fin_log();
- return 0;
-}
diff --git a/old-tests/device/Makefile.in b/old-tests/device/Makefile.in
deleted file mode 100644
index a389eb1..0000000
--- a/old-tests/device/Makefile.in
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
-# Copyright (C) 2004 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
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-top_builddir = @top_builddir@
-VPATH = @srcdir@
-
-SOURCES=\
- dev_cache_t.c
-
-TARGETS=dev_cache_t
-
-include $(top_builddir)/make.tmpl
-
-dev_cache_t: dev_cache_t.o $(top_srcdir)/lib/liblvm.a
- $(CC) -o dev_cache_t dev_cache_t.o -L$(top_builddir)/lib -llvm
-
diff --git a/old-tests/device/dev_cache_t.c b/old-tests/device/dev_cache_t.c
deleted file mode 100644
index c3d8c28..0000000
--- a/old-tests/device/dev_cache_t.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004 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
- */
-
-#include "dev-cache.h"
-#include "log.h"
-
-#include <stdio.h>
-
-int main(int argc, char **argv)
-{
- int i;
- struct device *dev;
- struct dev_iter *iter;
- struct list_head *tmp;
- struct dm_str_list *sl;
-
- if (argc < 2) {
- fprintf(stderr, "usage: %s <dir>\n", argv[0]);
- exit(1);
- }
-
- init_log(stderr);
- init_debug(_LOG_INFO);
-
- if (!dev_cache_init()) {
- log_err("couldn't initialise dev_cache_init failed");
- exit(1);
- }
-
- for (i = 1; i < argc; i++) {
- if (!dev_cache_add_dir(argv[i])) {
- log_err("couldn't add '%s' to dev_cache", argv[i]);
- exit(1);
- }
- }
-
- if (!(iter = dev_iter_create(NULL))) {
- log_err("couldn't create iterator");
- exit(1);
- }
-
- while ((dev = dev_iter_get(iter))) {
- printf("%s", dev->name);
-
- list_for_each(tmp, &dev->aliases) {
- sl = list_entry(tmp, struct dm_str_list, list);
- printf(", %s", sl->str);
- }
- printf("\n");
- }
-
- dev_iter_destroy(iter);
- dev_cache_exit();
-
- dump_memory();
- fin_log();
- return 0;
-}
diff --git a/old-tests/device/fill_device.c b/old-tests/device/fill_device.c
deleted file mode 100644
index 5947b61..0000000
--- a/old-tests/device/fill_device.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004 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
- */
-
-#include "device.h"
-#include "random.h"
-
-#include <stdio.h>
-
-
-
-
-int main(int argc, char **argv)
-{
-
-}
diff --git a/old-tests/device/random.c b/old-tests/device/random.c
deleted file mode 100644
index 96479f5..0000000
--- a/old-tests/device/random.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004 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
- */
-
-#include "random.h"
-#include "log.h"
-
-int32_t _a[56];
-int32_t *_r;
-
-static inline int32_t _mod_diff(int32_t x, int32_t y)
-{
- return (x - y) & 0x7fffffff;
-}
-
-static int32_t _flip_cycle(void)
-{
- int32_t *ii, *jj;
- for (ii = _a + 1, jj = _a + 32; jj <= _a + 55; ii++, jj++)
- *ii = _mod_diff(*ii, *jj);
-
- for (jj = _a + 1; ii <= _a + 55; ii++, jj++)
- *ii = _mod_diff(*ii, *jj);
-
- _r = _a + 54;
- return _a[55];
-}
-
-static void rand_init(int32_t seed)
-{
- int64_t i;
- int64_t prev = seed, next = 1;
-
- seed = prev = _mod_diff(prev, 0); /* strip the sign */
- _a[55] = prev;
- for (i = 21; i; i = (i + 21) % 55) {
- _a[i] = next;
- next = _mod_diff(prev, next);
- if(seed & 1)
- seed = 0x40000000L + (seed >> 1);
- else
- seed >>= 1;
-
- next = _mod_diff(next, seed);
- prev = _a[i];
- }
-
- _flip_cycle();
- _flip_cycle();
- _flip_cycle();
- _flip_cycle();
- _flip_cycle();
-}
-
-/*
- * FIXME: move this to be an inline in the
- * header.
- */
-int32_t rand_get(void)
-{
- return (*_r >= 0) ? *_r-- : _flip_cycle();
-}
-
-
-/*
- * just used by rand_check
- */
-#define t31 0x80000000
-static int32_t _uniform(int32_t m)
-{
- uint32_t t = t31 - (t31 % m);
- int32_t r;
-
- do
- r = next_rand(sc);
-
- while (t <= (uint32_t) r);
-
- return r % m;
-}
-
-/*
- * Checks I've copied the code correctly.
- */
-int rand_check(void)
-{
- int j;
-
- rand_init(-314159L);
-
- if (next_rand(sc) != 119318998) {
- log_err("Random number generator failed check 1");
- return 0;
- }
-
- for(j = 1; j <= 133; j++)
- rand_get();
-
- if (_uniform(0x55555555L) != 748103812) {
- log_err("Random number generator failed check 2");
- return 0;
- }
-
- return 1;
-}
diff --git a/old-tests/device/random.h b/old-tests/device/random.h
deleted file mode 100644
index 4663988..0000000
--- a/old-tests/device/random.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004 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
- */
-
-/*
- * Random number generator snarfed from the
- * Stanford Graphbase.
- */
-
-#ifndef _LVM_RANDOM_H
-#define _LVM_RANDOM_H
-
-void rand_init(int32_t seed);
-int32_t rand_get(void);
-
-/*
- * Note this will reset the seed.
- */
-int rand_check(void);
-
-#endif
diff --git a/old-tests/filters/Makefile.in b/old-tests/filters/Makefile.in
deleted file mode 100644
index 69e7ca9..0000000
--- a/old-tests/filters/Makefile.in
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
-# Copyright (C) 2004 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
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-top_builddir = @top_builddir@
-VPATH = @srcdir@
-
-SOURCES=\
- rfilter_t.c \
- pfilter_t.c
-
-TARGETS=\
- rfilter_t \
- pfilter_t
-
-include $(top_builddir)/make.tmpl
-
-rfilter_t: rfilter_t.o $(top_srcdir)/lib/liblvm.a
- $(CC) -o rfilter_t rfilter_t.o -L$(top_builddir)/lib -llvm
-
-pfilter_t: pfilter_t.o $(top_srcdir)/lib/liblvm.a
- $(CC) -o pfilter_t pfilter_t.o -L$(top_builddir)/lib -llvm
-
diff --git a/old-tests/filters/pfilter_t.c b/old-tests/filters/pfilter_t.c
deleted file mode 100644
index e83c3ed..0000000
--- a/old-tests/filters/pfilter_t.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004 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
- */
-
-#include "filter-persistent.h"
-#include "log.h"
-#include "config.h"
-#include "filter-regex.h"
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-
-int main(int argc, char **argv)
-{
- struct config_file *cft;
- struct config_node *cn;
- struct dev_filter *rfilter, *pfilter;
- struct dev_iter *iter;
- struct device *dev;
-
- if (argc < 2) {
- fprintf(stderr, "Usage : %s <regex config>\n",
- argv[0]);
- exit(1);
- }
-
- init_log(stderr);
- init_debug(_LOG_DEBUG);
-
- if (!dev_cache_init()) {
- fprintf(stderr, "couldn't initialise dev_cache_init failed\n");
- exit(1);
- }
-
- if (!dev_cache_add_dir("/dev")) {
- fprintf(stderr, "couldn't add '/dev' to dev_cache\n");
- exit(1);
- }
-
- if (!(cft = create_config_file())) {
- fprintf(stderr, "couldn't create config file\n");
- exit(1);
- }
-
- if (!read_config(cft, argv[1])) {
- fprintf(stderr, "couldn't read config file\n");
- exit(1);
- }
-
- if (!(cn = find_config_node(cft->root, "/devices/filter", '/'))) {
- fprintf(stderr, "couldn't find filter section\n");
- exit(1);
- }
-
- if (!(rfilter = regex_filter_create(cn->v))) {
- fprintf(stderr, "couldn't build filter\n");
- exit(1);
- }
-
- if (!(pfilter = persistent_filter_create(rfilter, "./pfilter.cfg"))) {
- fprintf(stderr, "couldn't build filter\n");
- exit(1);
- }
-
- if (!(iter = dev_iter_create(pfilter))) {
- log_err("couldn't create iterator");
- exit(1);
- }
-
- fprintf(stderr, "filling cache\n");
- while ((dev = dev_iter_get(iter)))
- ;
- dev_iter_destroy(iter);
-
- fprintf(stderr, "dumping\n");
- if (!persistent_filter_dump(pfilter)) {
- fprintf(stderr, "couldn't dump pfilter\n");
- exit(1);
- }
-
- fprintf(stderr, "loading\n");
- if (!persistent_filter_load(pfilter)) {
- fprintf(stderr, "couldn't load pfilter\n");
- exit(1);
- }
-
- if (!(iter = dev_iter_create(pfilter))) {
- log_err("couldn't create iterator");
- exit(1);
- }
-
- while ((dev = dev_iter_get(iter)))
- printf("%s\n", dev_name(dev));
-
- dev_iter_destroy(iter);
- pfilter->destroy(pfilter);
- dev_cache_exit();
- destroy_config_file(cft);
-
- dump_memory();
- fin_log();
- return 0;
-}
-
diff --git a/old-tests/filters/rfilter_t.c b/old-tests/filters/rfilter_t.c
deleted file mode 100644
index 488378d..0000000
--- a/old-tests/filters/rfilter_t.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004 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
- */
-
-#include "filter-regex.h"
-#include "config.h"
-#include "log.h"
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-
-int main(int argc, char **argv)
-{
- struct config_file *cft;
- struct config_node *cn;
- struct dev_filter *filter;
- struct dev_iter *iter;
- struct device *dev;
-
- if (argc < 2) {
- fprintf(stderr, "Usage : %s <config_file>\n", argv[0]);
- exit(1);
- }
-
- init_log(stderr);
- init_debug(_LOG_DEBUG);
-
- if (!(cft = create_config_file())) {
- fprintf(stderr, "couldn't create config file\n");
- exit(1);
- }
-
- if (!read_config(cft, argv[1])) {
- fprintf(stderr, "couldn't read config file\n");
- exit(1);
- }
-
- if (!(cn = find_config_node(cft->root, "/devices/filter", '/'))) {
- fprintf(stderr, "couldn't find filter section\n");
- exit(1);
- }
-
- if (!dev_cache_init()) {
- fprintf(stderr, "couldn't initialise dev_cache_init failed\n");
- exit(1);
- }
-
- if (!dev_cache_add_dir("/dev")) {
- fprintf(stderr, "couldn't add '/dev' to dev_cache\n");
- exit(1);
- }
-
- if (!(filter = regex_filter_create(cn->v))) {
- fprintf(stderr, "couldn't build filter\n");
- exit(1);
- }
-
- if (!(iter = dev_iter_create(filter))) {
- log_err("couldn't create iterator");
- exit(1);
- }
-
- while ((dev = dev_iter_get(iter)))
- printf("%s\n", dev_name(dev));
-
- dev_iter_destroy(iter);
- filter->destroy(filter);
- dev_cache_exit();
- destroy_config_file(cft);
-
- dump_memory();
- fin_log();
- return 0;
-}
-
diff --git a/old-tests/filters/sample.cfg b/old-tests/filters/sample.cfg
deleted file mode 100644
index 02f98de..0000000
--- a/old-tests/filters/sample.cfg
+++ /dev/null
@@ -1,21 +0,0 @@
-devices {
-
- # first match is final, eg. /dev/ide/cdrom
- # get's rejected due to the first pattern
-
- filter=["r/cdrom/", # don't touch the music !
- "a/hd[a-d][0-9]+/",
- "a/ide/",
- "a/sd/",
- "a/md/",
- "a|loop/[0-9]+|", # accept devfs style loop back
- "r/loop/", # and reject old style
- "a/dasd/",
- "a/dac960/",
- "a/nbd/",
- "a/ida/",
- "a/cciss/",
- "a/ubd/",
- "r/.*/"] # reject all others
-
-}
diff --git a/old-tests/format1/Makefile.in b/old-tests/format1/Makefile.in
deleted file mode 100644
index e4b51d2..0000000
--- a/old-tests/format1/Makefile.in
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
-# Copyright (C) 2004 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
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-top_builddir = @top_builddir@
-VPATH = @srcdir@
-
-SOURCES=\
- read_vg_t.c \
- write_vg_t.c \
- pretty_print.c \
- get_pvs_t.c \
- read_pv_t.c \
- get_vgs_t.c
-
-TARGETS=\
- read_vg_t \
- write_vg_t \
- get_pvs_t \
- read_pv_t \
- get_vgs_t
-
-include $(top_builddir)/make.tmpl
-
-read_vg_t: read_vg_t.o pretty_print.o $(top_builddir)/lib/liblvm.a
- $(CC) -o read_vg_t read_vg_t.o pretty_print.o -L$(top_builddir)/lib -llvm
-
-write_vg_t: write_vg_t.o pretty_print.o $(top_builddir)/lib/liblvm.a
- $(CC) -o write_vg_t write_vg_t.o pretty_print.o \
- -L$(top_builddir)/lib -llvm
-
-get_pvs_t: get_pvs_t.o pretty_print.o $(top_builddir)/lib/liblvm.a
- $(CC) -o get_pvs_t get_pvs_t.o pretty_print.o -L$(top_builddir)/lib -llvm
-
-read_pv_t: read_pv_t.o pretty_print.o $(top_builddir)/lib/liblvm.a
- $(CC) -o read_pv_t read_pv_t.o pretty_print.o -L$(top_builddir)/lib -llvm
-
-get_vgs_t: get_vgs_t.o pretty_print.o $(top_builddir)/lib/liblvm.a
- $(CC) -o get_vgs_t get_vgs_t.o pretty_print.o -L$(top_builddir)/lib -llvm
-
diff --git a/old-tests/format1/get_pvs_t.c b/old-tests/format1/get_pvs_t.c
deleted file mode 100644
index d17f0b0..0000000
--- a/old-tests/format1/get_pvs_t.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004 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
- */
-
-#include "log.h"
-#include "format1.h"
-#include "pretty_print.h"
-#include "list.h"
-
-#include <stdio.h>
-
-int main(int argc, char **argv)
-{
- struct io_space *ios;
- struct list_head *pvs, *tmp;
- struct dm_pool *mem;
-
- init_log(stderr);
- init_debug(_LOG_INFO);
-
- if (!dev_cache_init()) {
- fprintf(stderr, "init of dev-cache failed\n");
- exit(1);
- }
-
- if (!dev_cache_add_dir("/dev/loop")) {
- fprintf(stderr, "couldn't add /dev to dir-cache\n");
- exit(1);
- }
-
- if (!(mem = dm_pool_create(10 * 1024))) {
- fprintf(stderr, "couldn't create pool\n");
- exit(1);
- }
-
- ios = create_lvm1_format("/dev", mem, NULL);
-
- if (!ios) {
- fprintf(stderr, "failed to create io_space for format1\n");
- exit(1);
- }
-
- pvs = ios->get_pvs(ios);
-
- if (!pvs) {
- fprintf(stderr, "couldn't read vg %s\n", argv[1]);
- exit(1);
- }
-
- list_for_each(tmp, pvs) {
- struct pv_list *pvl = list_entry(tmp, struct pv_list, list);
- dump_pv(&pvl->pv, stdout);
- }
-
- ios->destroy(ios);
-
- dm_pool_destroy(mem);
- dev_cache_exit();
- dump_memory();
- fin_log();
- return 0;
-}
diff --git a/old-tests/format1/get_vgs_t.c b/old-tests/format1/get_vgs_t.c
deleted file mode 100644
index 4910c6d..0000000
--- a/old-tests/format1/get_vgs_t.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004 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
- */
-
-#include "log.h"
-#include "format1.h"
-#include "pretty_print.h"
-#include "list.h"
-
-#include <stdio.h>
-
-int main(int argc, char **argv)
-{
- struct io_space *ios;
- struct list_head *vgs;
- struct dm_pool *mem;
-
- init_log(stderr);
- init_debug(_LOG_INFO);
-
- if (!dev_cache_init()) {
- fprintf(stderr, "init of dev-cache failed\n");
- exit(1);
- }
-
- if (!dev_cache_add_dir("/dev/loop")) {
- fprintf(stderr, "couldn't add /dev to dir-cache\n");
- exit(1);
- }
-
- if (!(mem = dm_pool_create(10 * 1024))) {
- fprintf(stderr, "couldn't create pool\n");
- exit(1);
- }
-
- ios = create_lvm1_format("/dev", mem, NULL);
-
- if (!ios) {
- fprintf(stderr, "failed to create io_space for format1\n");
- exit(1);
- }
-
- vgs = ios->get_vgs(ios);
-
- if (!vgs) {
- fprintf(stderr, "couldn't read vg names\n");
- exit(1);
- }
-
- dump_vg_names(vgs, stdout);
- ios->destroy(ios);
-
- dm_pool_destroy(mem);
- dev_cache_exit();
- dump_memory();
- fin_log();
- return 0;
-}
diff --git a/old-tests/format1/pretty_print.c b/old-tests/format1/pretty_print.c
deleted file mode 100644
index 62e089a..0000000
--- a/old-tests/format1/pretty_print.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004 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
- */
-
-#include "pretty_print.h"
-
-void dump_pv(struct physical_volume *pv, FILE *fp)
-{
- fprintf(fp, "physical_volume {\n");
- fprintf(fp, "\tname = '%s'\n", pv->dev->name);
- fprintf(fp, "\tvg_name = '%s'\n", pv->vg_name);
- fprintf(fp, "\tsize = %llu\n", pv->size);
- fprintf(fp, "\tpe_size = %llu\n", pv->pe_size);
- fprintf(fp, "\tpe_start = %llu\n", pv->pe_start);
- fprintf(fp, "\tpe_count = %u\n", pv->pe_count);
- fprintf(fp, "\tpe_allocated = %u\n", pv->pe_allocated);
- fprintf(fp, "}\n\n");
-}
-
-void dump_lv(struct logical_volume *lv, FILE *fp)
-{
- int i;
-
- fprintf(fp, "logical_volume {\n");
- fprintf(fp, "\tname = '%s'\n", lv->name);
- fprintf(fp, "\tsize = %llu\n", lv->size);
- fprintf(fp, "\tle_count = %u\n", lv->le_count);
-
- fprintf(fp, "\tmap {\n");
- for (i = 0; i < lv->le_count; i++) {
- struct physical_volume *pv = lv->map[i].pv;
-
- fprintf(fp, "\t\tpv = '%s', ",
- pv ? pv->dev->name : "null ???");
- fprintf(fp, "\textent = %u\n", lv->map[i].pe);
- }
- fprintf(fp, "\t}\n}\n\n");
-}
-
-void dump_vg(struct volume_group *vg, FILE *fp)
-{
- struct list_head *tmp;
-
- fprintf(fp, "volume_group {\n");
- fprintf(fp, "\tname = '%s'\n", vg->name);
- fprintf(fp, "\textent_size = %llu\n", vg->extent_size);
- fprintf(fp, "\textent_count = %d\n", vg->extent_count);
- fprintf(fp, "\tfree_count = %d\n", vg->free_count);
- fprintf(fp, "\tmax_lv = %d\n", vg->max_lv);
- fprintf(fp, "\tmax_pv = %d\n", vg->max_pv);
- fprintf(fp, "\tpv_count = %d\n", vg->pv_count);
- fprintf(fp, "\tlv_count = %d\n", vg->lv_count);
- fprintf(fp, "}\n\n");
-
- list_for_each(tmp, &vg->pvs) {
- struct pv_list *pvl = list_entry(tmp, struct pv_list, list);
- dump_pv(&pvl->pv, fp);
- }
-
- list_for_each(tmp, &vg->lvs) {
- struct lv_list *lvl = list_entry(tmp, struct lv_list, list);
- dump_lv(&lvl->lv, fp);
- }
-}
-
-void dump_vg_names(struct list_head *vg_names, FILE *fp)
-{
- struct list_head *tmp;
- struct name_list *nl;
-
- list_for_each(tmp, vg_names) {
- nl = list_entry(tmp, struct name_list, list);
- fprintf(fp, "%s\n", nl->name);
- }
-}
diff --git a/old-tests/format1/pretty_print.h b/old-tests/format1/pretty_print.h
deleted file mode 100644
index 20bd039..0000000
--- a/old-tests/format1/pretty_print.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004 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
- */
-
-#ifndef _LVM_PRETTY_PRINT
-#define _LVM_PRETTY_PRINT
-
-#include "metadata.h"
-
-#include <stdio.h>
-
-void dump_pv(struct physical_volume *pv, FILE *fp);
-void dump_lv(struct logical_volume *lv, FILE *fp);
-void dump_vg(struct volume_group *vg, FILE *fp);
-void dump_vg_names(struct list_head *vg_names, FILE *fp);
-
-#endif
diff --git a/old-tests/format1/read_pv_t.c b/old-tests/format1/read_pv_t.c
deleted file mode 100644
index 271cc1e..0000000
--- a/old-tests/format1/read_pv_t.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004 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
- */
-
-#include "log.h"
-#include "format1.h"
-#include "pretty_print.h"
-#include "list.h"
-
-#include <stdio.h>
-
-int main(int argc, char **argv)
-{
- struct io_space *ios;
- struct physical_volume *pv;
- struct dm_pool *mem;
- struct device *dev;
-
- if (argc != 2) {
- fprintf(stderr, "usage: read_pv_t <device>\n");
- exit(1);
- }
-
- init_log(stderr);
- init_debug(_LOG_INFO);
-
- if (!dev_cache_init()) {
- fprintf(stderr, "init of dev-cache failed\n");
- exit(1);
- }
-
- if (!dev_cache_add_dir("/dev/loop")) {
- fprintf(stderr, "couldn't add /dev to dir-cache\n");
- exit(1);
- }
-
- if (!(mem = dm_pool_create(10 * 1024))) {
- fprintf(stderr, "couldn't create pool\n");
- exit(1);
- }
-
- ios = create_lvm1_format("/dev", mem, NULL);
-
- if (!ios) {
- fprintf(stderr, "failed to create io_space for format1\n");
- exit(1);
- }
-
- pv = ios->pv_read(ios, argv[1]);
-
- if (!pv) {
- fprintf(stderr, "couldn't read pv %s\n", dev->name);
- exit(1);
- }
-
- dump_pv(pv, stdout);
- ios->destroy(ios);
-
- dm_pool_destroy(mem);
- dev_cache_exit();
- dump_memory();
- fin_log();
- return 0;
-}
diff --git a/old-tests/format1/read_vg_t.c b/old-tests/format1/read_vg_t.c
deleted file mode 100644
index 1fb1414..0000000
--- a/old-tests/format1/read_vg_t.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004 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
- */
-
-#include "log.h"
-#include "format1.h"
-#include "pretty_print.h"
-
-#include <stdio.h>
-
-int main(int argc, char **argv)
-{
- struct io_space *ios;
- struct volume_group *vg;
- struct dm_pool *mem;
-
- if (argc != 2) {
- fprintf(stderr, "usage: read_vg_t <vg_name>\n");
- exit(1);
- }
-
- init_log(stderr);
- init_debug(_LOG_INFO);
-
- if (!dev_cache_init()) {
- fprintf(stderr, "init of dev-cache failed\n");
- exit(1);
- }
-
- if (!dev_cache_add_dir("/dev/loop")) {
- fprintf(stderr, "couldn't add /dev to dir-cache\n");
- exit(1);
- }
-
- if (!(mem = dm_pool_create(10 * 1024))) {
- fprintf(stderr, "couldn't create pool\n");
- exit(1);
- }
-
- ios = create_lvm1_format("/dev", mem, NULL);
-
- if (!ios) {
- fprintf(stderr, "failed to create io_space for format1\n");
- exit(1);
- }
-
- vg = ios->vg_read(ios, argv[1]);
-
- if (!vg) {
- fprintf(stderr, "couldn't read vg %s\n", argv[1]);
- exit(1);
- }
-
- dump_vg(vg, stdout);
-
- ios->destroy(ios);
-
- dm_pool_destroy(mem);
- dev_cache_exit();
- dump_memory();
- fin_log();
- return 0;
-}
-
diff --git a/old-tests/format1/write_vg_t.c b/old-tests/format1/write_vg_t.c
deleted file mode 100644
index 29682ad..0000000
--- a/old-tests/format1/write_vg_t.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004 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
- */
-
-#include "log.h"
-#include "format1.h"
-#include "pretty_print.h"
-
-#include <stdio.h>
-
-int main(int argc, char **argv)
-{
- struct io_space *ios;
- struct volume_group *vg;
- struct dm_pool *mem;
-
- if (argc != 2) {
- fprintf(stderr, "usage: read_vg_t <vg_name>\n");
- exit(1);
- }
-
- init_log(stderr);
- init_debug(_LOG_INFO);
-
- if (!dev_cache_init()) {
- fprintf(stderr, "init of dev-cache failed\n");
- exit(1);
- }
-
- if (!dev_cache_add_dir("/dev/loop")) {
- fprintf(stderr, "couldn't add /dev to dir-cache\n");
- exit(1);
- }
-
- if (!(mem = dm_pool_create(10 * 1024))) {
- fprintf(stderr, "couldn't create pool\n");
- exit(1);
- }
-
- ios = create_lvm1_format("/dev", mem, NULL);
-
- if (!ios) {
- fprintf(stderr, "failed to create io_space for format1\n");
- exit(1);
- }
-
- vg = ios->vg_read(ios, argv[1]);
-
- if (!vg) {
- fprintf(stderr, "couldn't read vg %s\n", argv[1]);
- exit(1);
- }
-
- if (!ios->vg_write(ios, vg)) {
- fprintf(stderr, "couldn't write vg\n");
- exit(1);
- }
-
- ios->destroy(ios);
-
- dm_pool_destroy(mem);
- dev_cache_exit();
- dump_memory();
- fin_log();
- return 0;
-}
diff --git a/old-tests/mm/Makefile.in b/old-tests/mm/Makefile.in
deleted file mode 100644
index ec60fa6..0000000
--- a/old-tests/mm/Makefile.in
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
-# Copyright (C) 2004 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
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-top_builddir = @top_builddir@
-VPATH = @srcdir@
-
-SOURCES=\
- dbg_malloc_t.c
-
-TARGETS=dbg_malloc_t
-
-include $(top_builddir)/make.tmpl
-
-dbg_malloc_t: dbg_malloc_t.o
- $(CC) $(CFLAGS) -o dbg_malloc_t dbg_malloc_t.o \
- -L$(top_builddir)/lib -llvm
-
-pool_t: pool_t.o
- $(CC) $(CFLAGS) -o pool_t pool_t.o -L$(top_builddir)/lib -llvm
-
diff --git a/old-tests/mm/dbg_malloc_t.c b/old-tests/mm/dbg_malloc_t.c
deleted file mode 100644
index 8536405..0000000
--- a/old-tests/mm/dbg_malloc_t.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004 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
- */
-
-#include "log.h"
-
-#include <stdio.h>
-#include <unistd.h>
-
-
-static void _print_help(FILE *out, const char *prog)
-{
- fprintf(out, "usage : %s [-hlbufd]\n\n", prog);
- fprintf(out, " h : this message\n");
- fprintf(out, " l : cause memory leak\n");
- fprintf(out, " b : overrun memory block\n");
- fprintf(out, " u : underrun memory block\n");
- fprintf(out, " f : free random pointer\n");
- fprintf(out, " d : free block twice\n");
-}
-
-struct block_list {
- struct block_list *next;
- char dummy[9];
-};
-
-static void _leak_memory(void)
-{
- int i;
- struct block_list *b, *head, **l = &head, *n;
-
- /* allocate a list of blocks */
- for (i = 0; i < 1000; i++) {
-
- if (!(b = dbg_malloc(sizeof(*b)))) {
- log_fatal("Couldn't allocate memory");
- exit(1);
- }
-
- b->next = 0;
- *l = b;
- l = &b->next;
- }
-
- /* free off every other block */
- for (b = head, i = 0; b; b = n, i++) {
- n = b->next;
- if(i & 0x1)
- dbg_free(b);
- }
-}
-
-static void _bounds_overrun(void)
-{
- char *b;
-
- /* allocate a block */
- b = dbg_malloc(534);
-
- /* overrun */
- b[534] = 56;
-
- /* free it, which should trigger the bounds error */
- dbg_free(b);
-}
-
-static void _bounds_underrun(void)
-{
- char *b;
-
- /* allocate a block */
- b = dbg_malloc(534);
-
- /* underrun */
- *(b - 1) = 56;
-
- /* free it, which should trigger the bounds error */
- dbg_free(b);
-}
-
-static void _free_dud(void)
-{
- char *b;
-
- /* allocate a block */
- b = dbg_malloc(534);
-
- /* free it, which should trigger the bounds error */
- dbg_free(b + 100);
-}
-
-static void _free_twice(void)
-{
- char *b;
-
- /* allocate a block */
- b = dbg_malloc(534);
-
- /* free it, which should trigger the bounds error */
- dbg_free(b);
- dbg_free(b);
-}
-
-int main(int argc, char **argv)
-{
- char opt;
-
- init_log(stderr);
- init_debug(_LOG_DEBUG);
- opt = getopt(argc, argv, "hlbufd");
- switch(opt) {
- case EOF:
- case 'h':
- _print_help(stdout, argv[0]);
- break;
-
- case 'l':
- _leak_memory();
- break;
-
- case 'b':
- _bounds_overrun();
- break;
-
- case 'u':
- _bounds_underrun();
- break;
-
- case 'f':
- _free_dud();
- break;
-
- case 'd':
- _free_twice();
- break;
-
- case '?':
- fprintf(stderr, "Unknown option -%c\n", opt);
- exit(1);
- }
-
- dump_memory();
- fin_log();
- return 0;
-}
diff --git a/unit-tests/datastruct/Makefile.in b/unit-tests/datastruct/Makefile.in
deleted file mode 100644
index 4f0e7a4..0000000
--- a/unit-tests/datastruct/Makefile.in
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
-# Copyright (C) 2004-2010 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
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-top_builddir = @top_builddir@
-
-SOURCES=\
- bitset_t.c
-
-TARGETS=\
- bitset_t
-
-include $(top_builddir)/make.tmpl
-
-INCLUDES += -I$(top_srcdir)/libdm
-DM_DEPS = $(top_builddir)/libdm/libdevmapper.so
-DM_LIBS = -ldevmapper $(LIBS)
-
-bitset_t: bitset_t.o $(DM_DEPS)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ bitset_t.o $(DM_LIBS)
diff --git a/unit-tests/datastruct/TESTS b/unit-tests/datastruct/TESTS
deleted file mode 100644
index ba88fb7..0000000
--- a/unit-tests/datastruct/TESTS
+++ /dev/null
@@ -1 +0,0 @@
-bitset iteration:$TEST_TOOL ./bitset_t
\ No newline at end of file
diff --git a/unit-tests/datastruct/bitset_t.c b/unit-tests/datastruct/bitset_t.c
deleted file mode 100644
index be9b8fd..0000000
--- a/unit-tests/datastruct/bitset_t.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2010 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
- */
-
-#include "libdevmapper.h"
-
-#include <assert.h>
-
-enum {
- NR_BITS = 137
-};
-
-static void test_get_next(struct dm_pool *mem)
-{
- int i, j, last, first;
- dm_bitset_t bs = dm_bitset_create(mem, NR_BITS);
-
- for (i = 0; i < NR_BITS; i++)
- assert(!dm_bit(bs, i));
-
- for (i = 0, j = 1; i < NR_BITS; i += j, j++)
- dm_bit_set(bs, i);
-
- first = 1;
- for (i = 0, j = 1; i < NR_BITS; i += j, j++) {
- if (first) {
- last = dm_bit_get_first(bs);
- first = 0;
- } else
- last = dm_bit_get_next(bs, last);
-
- assert(last == i);
- }
-
- assert(dm_bit_get_next(bs, last) == -1);
-}
-
-static void bit_flip(dm_bitset_t bs, int bit)
-{
- int old = dm_bit(bs, bit);
- if (old)
- dm_bit_clear(bs, bit);
- else
- dm_bit_set(bs, bit);
-}
-
-static void test_equal(struct dm_pool *mem)
-{
- dm_bitset_t bs1 = dm_bitset_create(mem, NR_BITS);
- dm_bitset_t bs2 = dm_bitset_create(mem, NR_BITS);
-
- int i, j;
- for (i = 0, j = 1; i < NR_BITS; i += j, j++) {
- dm_bit_set(bs1, i);
- dm_bit_set(bs2, i);
- }
-
- assert(dm_bitset_equal(bs1, bs2));
- assert(dm_bitset_equal(bs2, bs1));
-
- for (i = 0; i < NR_BITS; i++) {
- bit_flip(bs1, i);
- assert(!dm_bitset_equal(bs1, bs2));
- assert(!dm_bitset_equal(bs2, bs1));
-
- assert(dm_bitset_equal(bs1, bs1)); /* comparing with self */
- bit_flip(bs1, i);
- }
-}
-
-static void test_and(struct dm_pool *mem)
-{
- dm_bitset_t bs1 = dm_bitset_create(mem, NR_BITS);
- dm_bitset_t bs2 = dm_bitset_create(mem, NR_BITS);
- dm_bitset_t bs3 = dm_bitset_create(mem, NR_BITS);
-
- int i, j;
- for (i = 0, j = 1; i < NR_BITS; i += j, j++) {
- dm_bit_set(bs1, i);
- dm_bit_set(bs2, i);
- }
-
- dm_bit_and(bs3, bs1, bs2);
-
- assert(dm_bitset_equal(bs1, bs2));
- assert(dm_bitset_equal(bs1, bs3));
- assert(dm_bitset_equal(bs2, bs3));
-
- dm_bit_clear_all(bs1);
- dm_bit_clear_all(bs2);
-
- for (i = 0; i < NR_BITS; i++) {
- if (i % 2)
- dm_bit_set(bs1, i);
- else
- dm_bit_set(bs2, i);
- }
-
- dm_bit_and(bs3, bs1, bs2);
- for (i = 0; i < NR_BITS; i++)
- assert(!dm_bit(bs3, i));
-}
-
-int main(int argc, char **argv)
-{
- typedef void (*test_fn)(struct dm_pool *);
- static test_fn tests[] = {
- test_get_next,
- test_equal,
- test_and
- };
-
- int i;
- for (i = 0; i < DM_ARRAY_SIZE(tests); ++i) {
- struct dm_pool *mem = dm_pool_create("bitset test", 1024);
- assert(mem);
- tests[i](mem);
- dm_pool_destroy(mem);
- }
-
- return 0;
-}
-
diff --git a/unit-tests/mm/Makefile.in b/unit-tests/mm/Makefile.in
deleted file mode 100644
index a40e2e2..0000000
--- a/unit-tests/mm/Makefile.in
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
-# Copyright (C) 2004 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
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-top_builddir = @top_builddir@
-VPATH = @srcdir@
-
-SOURCES=\
- pool_valgrind_t.c
-
-TARGETS=\
- pool_valgrind_t
-
-include $(top_builddir)/make.tmpl
-DM_LIBS = -ldevmapper $(LIBS)
-
-pool_valgrind_t: pool_valgrind_t.o
- $(CC) $(CFLAGS) -o $@ pool_valgrind_t.o $(LDFLAGS) $(DM_LIBS)
-
diff --git a/unit-tests/mm/TESTS b/unit-tests/mm/TESTS
deleted file mode 100644
index 3bf3154..0000000
--- a/unit-tests/mm/TESTS
+++ /dev/null
@@ -1 +0,0 @@
-valgrind pool awareness:valgrind ./pool_valgrind_t 2>&1 | ./check_results
diff --git a/unit-tests/mm/check_results b/unit-tests/mm/check_results
deleted file mode 100755
index a7b0975..0000000
--- a/unit-tests/mm/check_results
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/env ruby1.9
-
-require 'pp'
-
-patterns = [
- /Invalid read of size 1/,
- /Invalid write of size 1/,
- /Invalid read of size 1/,
- /still reachable: [0-9,]+ bytes in 3 blocks/
- ]
-
-lines = STDIN.readlines
-pp lines
-
-result = catch(:done) do
- patterns.each do |pat|
- loop do
- throw(:done, false) if lines.size == 0
-
- line = lines.shift
- if line =~ pat
- STDERR.puts "matched #{pat}"
- break;
- end
- end
- end
-
- throw(:done, true)
-end
-
-exit(result ? 0 : 1)
diff --git a/unit-tests/mm/pool_valgrind_t.c b/unit-tests/mm/pool_valgrind_t.c
deleted file mode 100644
index 704f116..0000000
--- a/unit-tests/mm/pool_valgrind_t.c
+++ /dev/null
@@ -1,181 +0,0 @@
-#include "libdevmapper.h"
-
-#include <assert.h>
-
-/*
- * Checks that valgrind is picking up unallocated pool memory as
- * uninitialised, even if the chunk has been recycled.
- *
- * $ valgrind --track-origins=yes ./pool_valgrind_t
- *
- * ==7023== Memcheck, a memory error detector
- * ==7023== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
- * ==7023== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
- * ==7023== Command: ./pool_valgrind_t
- * ==7023==
- * first branch worked (as expected)
- * ==7023== Conditional jump or move depends on uninitialised value(s)
- * ==7023== at 0x4009AC: main (in /home/ejt/work/lvm2/unit-tests/mm/pool_valgrind_t)
- * ==7023== Uninitialised value was created by a client request
- * ==7023== at 0x4E40CB8: dm_pool_free (in /home/ejt/work/lvm2/libdm/ioctl/libdevmapper.so.1.02)
- * ==7023== by 0x4009A8: main (in /home/ejt/work/lvm2/unit-tests/mm/pool_valgrind_t)
- * ==7023==
- * second branch worked (valgrind should have flagged this as an error)
- * ==7023==
- * ==7023== HEAP SUMMARY:
- * ==7023== in use at exit: 0 bytes in 0 blocks
- * ==7023== total heap usage: 2 allocs, 2 frees, 2,104 bytes allocated
- * ==7023==
- * ==7023== All heap blocks were freed -- no leaks are possible
- * ==7023==
- * ==7023== For counts of detected and suppressed errors, rerun with: -v
- * ==7023== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 4 from 4)
- */
-
-#define COUNT 10
-
-static void check_free()
-{
- int i;
- char *blocks[COUNT];
- struct dm_pool *p = dm_pool_create("blah", 1024);
-
- for (i = 0; i < COUNT; i++)
- blocks[i] = dm_pool_alloc(p, 37);
-
- /* check we can access the last block */
- blocks[COUNT - 1][0] = 'E';
- if (blocks[COUNT - 1][0] == 'E')
- printf("first branch worked (as expected)\n");
-
- dm_pool_free(p, blocks[5]);
-
- if (blocks[COUNT - 1][0] == 'E')
- printf("second branch worked (valgrind should have flagged this as an error)\n");
-
- dm_pool_destroy(p);
-}
-
-/* Checks that freed chunks are marked NOACCESS */
-static void check_free2()
-{
- struct dm_pool *p = dm_pool_create("", 900); /* 900 will get
- * rounded up to 1024,
- * 1024 would have got
- * rounded up to
- * 2048 */
- char *data1, *data2;
-
- assert(p);
- data1 = dm_pool_alloc(p, 123);
- assert(data1);
-
- data1 = dm_pool_alloc(p, 1024);
- assert(data1);
-
- data2 = dm_pool_alloc(p, 123);
- assert(data2);
-
- data2[0] = 'A'; /* should work fine */
-
- dm_pool_free(p, data1);
-
- /*
- * so now the first chunk is active, the second chunk has become
- * the free one.
- */
- data2[0] = 'B'; /* should prompt an invalid write error */
-
- dm_pool_destroy(p);
-}
-
-static void check_alignment()
-{
- /*
- * Pool always tries to allocate blocks with particular alignment.
- * So there are potentially small gaps between allocations. This
- * test checks that valgrind is spotting illegal accesses to these
- * gaps.
- */
-
- int i, sum;
- struct dm_pool *p = dm_pool_create("blah", 1024);
- char *data1, *data2;
- char buffer[16];
-
-
- data1 = dm_pool_alloc_aligned(p, 1, 4);
- assert(data1);
- data2 = dm_pool_alloc_aligned(p, 1, 4);
- assert(data1);
-
- snprintf(buffer, sizeof(buffer), "%c", *(data1 + 1)); /* invalid read size 1 */
- dm_pool_destroy(p);
-}
-
-/*
- * Looking at the code I'm not sure allocations that are near the chunk
- * size are working. So this test is trying to exhibit a specific problem.
- */
-static void check_allocation_near_chunk_size()
-{
- int i;
- char *data;
- struct dm_pool *p = dm_pool_create("", 900);
-
- /*
- * allocate a lot and then free everything so we know there
- * is a spare chunk.
- */
- for (i = 0; i < 1000; i++) {
- data = dm_pool_alloc(p, 37);
- memset(data, 0, 37);
- assert(data);
- }
-
- dm_pool_empty(p);
-
- /* now we allocate something close to the chunk size ... */
- data = dm_pool_alloc(p, 1020);
- assert(data);
- memset(data, 0, 1020);
-
- dm_pool_destroy(p);
-}
-
-/* FIXME: test the dbg_malloc at exit (this test should be in dbg_malloc) */
-static void check_leak_detection()
-{
- int i;
- struct dm_pool *p = dm_pool_create("", 1024);
-
- for (i = 0; i < 10; i++)
- dm_pool_alloc(p, (i + 1) * 37);
-}
-
-/* we shouldn't get any errors from this one */
-static void check_object_growth()
-{
- int i;
- struct dm_pool *p = dm_pool_create("", 32);
- char data[100] = { 0 };
- void *obj;
-
- dm_pool_begin_object(p, 43);
- for (i = 1; i < 100; i++)
- dm_pool_grow_object(p, data, i);
- obj = dm_pool_end_object(p);
-
- dm_pool_destroy(p);
-}
-
-int main(int argc, char **argv)
-{
- check_free();
- check_free2();
- check_alignment();
- check_allocation_near_chunk_size();
- check_leak_detection();
- check_object_growth();
- return 0;
-}
diff --git a/unit-tests/regex/Makefile.in b/unit-tests/regex/Makefile.in
deleted file mode 100644
index 76b7dee..0000000
--- a/unit-tests/regex/Makefile.in
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
-# Copyright (C) 2004-2010 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
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-top_builddir = @top_builddir@
-
-SOURCES=\
- parse_t.c \
- matcher_t.c
-
-TARGETS=\
- parse_t \
- matcher_t
-
-include $(top_builddir)/make.tmpl
-
-INCLUDES += -I$(top_srcdir)/libdm
-DM_DEPS = $(top_builddir)/libdm/libdevmapper.so
-DM_LIBS = -ldevmapper $(LIBS)
-
-parse_t: parse_t.o $(DM_DEPS)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ parse_t.o $(DM_LIBS)
-
-matcher_t: matcher_t.o $(DM_DEPS)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ matcher_t.o $(DM_LIBS)
diff --git a/unit-tests/regex/TESTS b/unit-tests/regex/TESTS
deleted file mode 100644
index 3297942..0000000
--- a/unit-tests/regex/TESTS
+++ /dev/null
@@ -1,3 +0,0 @@
-dfa matching:$TEST_TOOL ./matcher_t --fingerprint dev_patterns < devices.list > matcher_t.output && diff -u matcher_t.expected matcher_t.output
-dfa matching:$TEST_TOOL ./matcher_t --fingerprint random_regexes < /dev/null > matcher_t.output && diff -u matcher_t.expected2 matcher_t.output
-dfa with non-print regex chars:$TEST_TOOL ./matcher_t nonprint_regexes < nonprint_input > matcher_t.output && diff -u matcher_t.expected3 matcher_t.output
\ No newline at end of file
diff --git a/unit-tests/regex/dev_patterns b/unit-tests/regex/dev_patterns
deleted file mode 100644
index 34459ba..0000000
--- a/unit-tests/regex/dev_patterns
+++ /dev/null
@@ -1,2 +0,0 @@
-"loop/[0-9]+"
-"hd[a-d][0-5]+"
diff --git a/unit-tests/regex/devices.list b/unit-tests/regex/devices.list
deleted file mode 100644
index 91af305..0000000
--- a/unit-tests/regex/devices.list
+++ /dev/null
@@ -1,880 +0,0 @@
-/dev
-/dev/.devfsd
-/dev/cpu
-/dev/cpu/mtrr
-/dev/netlink
-/dev/netlink/route
-/dev/netlink/skip
-/dev/netlink/USERSOCK
-/dev/netlink/fwmonitor
-/dev/netlink/ARPD
-/dev/netlink/ROUTE6
-/dev/netlink/IP6_FW
-/dev/netlink/tap0
-/dev/netlink/tap1
-/dev/netlink/tap2
-/dev/netlink/tap3
-/dev/netlink/tap4
-/dev/netlink/tap5
-/dev/netlink/tap6
-/dev/netlink/tap7
-/dev/netlink/tap8
-/dev/netlink/tap9
-/dev/netlink/tap10
-/dev/netlink/tap11
-/dev/netlink/tap12
-/dev/netlink/tap13
-/dev/netlink/tap14
-/dev/netlink/tap15
-/dev/shm
-/dev/mem
-/dev/kmem
-/dev/null
-/dev/port
-/dev/zero
-/dev/full
-/dev/random
-/dev/urandom
-/dev/tty
-/dev/console
-/dev/vc
-/dev/vc/1
-/dev/vc/2
-/dev/vc/3
-/dev/vc/4
-/dev/vc/5
-/dev/vc/6
-/dev/vc/7
-/dev/vc/8
-/dev/vc/9
-/dev/vc/10
-/dev/vc/11
-/dev/vc/12
-/dev/vc/13
-/dev/vc/14
-/dev/vc/15
-/dev/vc/16
-/dev/vc/17
-/dev/vc/18
-/dev/vc/19
-/dev/vc/20
-/dev/vc/21
-/dev/vc/22
-/dev/vc/23
-/dev/vc/24
-/dev/vc/25
-/dev/vc/26
-/dev/vc/27
-/dev/vc/28
-/dev/vc/29
-/dev/vc/30
-/dev/vc/31
-/dev/vc/32
-/dev/vc/33
-/dev/vc/34
-/dev/vc/35
-/dev/vc/36
-/dev/vc/37
-/dev/vc/38
-/dev/vc/39
-/dev/vc/40
-/dev/vc/41
-/dev/vc/42
-/dev/vc/43
-/dev/vc/44
-/dev/vc/45
-/dev/vc/46
-/dev/vc/47
-/dev/vc/48
-/dev/vc/49
-/dev/vc/50
-/dev/vc/51
-/dev/vc/52
-/dev/vc/53
-/dev/vc/54
-/dev/vc/55
-/dev/vc/56
-/dev/vc/57
-/dev/vc/58
-/dev/vc/59
-/dev/vc/60
-/dev/vc/61
-/dev/vc/62
-/dev/vc/63
-/dev/vc/0
-/dev/ptmx
-/dev/misc
-/dev/misc/psaux
-/dev/pty
-/dev/pty/m0
-/dev/pty/m1
-/dev/pty/m2
-/dev/pty/m3
-/dev/pty/m4
-/dev/pty/m5
-/dev/pty/m6
-/dev/pty/m7
-/dev/pty/m8
-/dev/pty/m9
-/dev/pty/m10
-/dev/pty/m11
-/dev/pty/m12
-/dev/pty/m13
-/dev/pty/m14
-/dev/pty/m15
-/dev/pty/m16
-/dev/pty/m17
-/dev/pty/m18
-/dev/pty/m19
-/dev/pty/m20
-/dev/pty/m21
-/dev/pty/m22
-/dev/pty/m23
-/dev/pty/m24
-/dev/pty/m25
-/dev/pty/m26
-/dev/pty/m27
-/dev/pty/m28
-/dev/pty/m29
-/dev/pty/m30
-/dev/pty/m31
-/dev/pty/m32
-/dev/pty/m33
-/dev/pty/m34
-/dev/pty/m35
-/dev/pty/m36
-/dev/pty/m37
-/dev/pty/m38
-/dev/pty/m39
-/dev/pty/m40
-/dev/pty/m41
-/dev/pty/m42
-/dev/pty/m43
-/dev/pty/m44
-/dev/pty/m45
-/dev/pty/m46
-/dev/pty/m47
-/dev/pty/m48
-/dev/pty/m49
-/dev/pty/m50
-/dev/pty/m51
-/dev/pty/m52
-/dev/pty/m53
-/dev/pty/m54
-/dev/pty/m55
-/dev/pty/m56
-/dev/pty/m57
-/dev/pty/m58
-/dev/pty/m59
-/dev/pty/m60
-/dev/pty/m61
-/dev/pty/m62
-/dev/pty/m63
-/dev/pty/m64
-/dev/pty/m65
-/dev/pty/m66
-/dev/pty/m67
-/dev/pty/m68
-/dev/pty/m69
-/dev/pty/m70
-/dev/pty/m71
-/dev/pty/m72
-/dev/pty/m73
-/dev/pty/m74
-/dev/pty/m75
-/dev/pty/m76
-/dev/pty/m77
-/dev/pty/m78
-/dev/pty/m79
-/dev/pty/m80
-/dev/pty/m81
-/dev/pty/m82
-/dev/pty/m83
-/dev/pty/m84
-/dev/pty/m85
-/dev/pty/m86
-/dev/pty/m87
-/dev/pty/m88
-/dev/pty/m89
-/dev/pty/m90
-/dev/pty/m91
-/dev/pty/m92
-/dev/pty/m93
-/dev/pty/m94
-/dev/pty/m95
-/dev/pty/m96
-/dev/pty/m97
-/dev/pty/m98
-/dev/pty/m99
-/dev/pty/m100
-/dev/pty/m101
-/dev/pty/m102
-/dev/pty/m103
-/dev/pty/m104
-/dev/pty/m105
-/dev/pty/m106
-/dev/pty/m107
-/dev/pty/m108
-/dev/pty/m109
-/dev/pty/m110
-/dev/pty/m111
-/dev/pty/m112
-/dev/pty/m113
-/dev/pty/m114
-/dev/pty/m115
-/dev/pty/m116
-/dev/pty/m117
-/dev/pty/m118
-/dev/pty/m119
-/dev/pty/m120
-/dev/pty/m121
-/dev/pty/m122
-/dev/pty/m123
-/dev/pty/m124
-/dev/pty/m125
-/dev/pty/m126
-/dev/pty/m127
-/dev/pty/m128
-/dev/pty/m129
-/dev/pty/m130
-/dev/pty/m131
-/dev/pty/m132
-/dev/pty/m133
-/dev/pty/m134
-/dev/pty/m135
-/dev/pty/m136
-/dev/pty/m137
-/dev/pty/m138
-/dev/pty/m139
-/dev/pty/m140
-/dev/pty/m141
-/dev/pty/m142
-/dev/pty/m143
-/dev/pty/m144
-/dev/pty/m145
-/dev/pty/m146
-/dev/pty/m147
-/dev/pty/m148
-/dev/pty/m149
-/dev/pty/m150
-/dev/pty/m151
-/dev/pty/m152
-/dev/pty/m153
-/dev/pty/m154
-/dev/pty/m155
-/dev/pty/m156
-/dev/pty/m157
-/dev/pty/m158
-/dev/pty/m159
-/dev/pty/m160
-/dev/pty/m161
-/dev/pty/m162
-/dev/pty/m163
-/dev/pty/m164
-/dev/pty/m165
-/dev/pty/m166
-/dev/pty/m167
-/dev/pty/m168
-/dev/pty/m169
-/dev/pty/m170
-/dev/pty/m171
-/dev/pty/m172
-/dev/pty/m173
-/dev/pty/m174
-/dev/pty/m175
-/dev/pty/m176
-/dev/pty/m177
-/dev/pty/m178
-/dev/pty/m179
-/dev/pty/m180
-/dev/pty/m181
-/dev/pty/m182
-/dev/pty/m183
-/dev/pty/m184
-/dev/pty/m185
-/dev/pty/m186
-/dev/pty/m187
-/dev/pty/m188
-/dev/pty/m189
-/dev/pty/m190
-/dev/pty/m191
-/dev/pty/m192
-/dev/pty/m193
-/dev/pty/m194
-/dev/pty/m195
-/dev/pty/m196
-/dev/pty/m197
-/dev/pty/m198
-/dev/pty/m199
-/dev/pty/m200
-/dev/pty/m201
-/dev/pty/m202
-/dev/pty/m203
-/dev/pty/m204
-/dev/pty/m205
-/dev/pty/m206
-/dev/pty/m207
-/dev/pty/m208
-/dev/pty/m209
-/dev/pty/m210
-/dev/pty/m211
-/dev/pty/m212
-/dev/pty/m213
-/dev/pty/m214
-/dev/pty/m215
-/dev/pty/m216
-/dev/pty/m217
-/dev/pty/m218
-/dev/pty/m219
-/dev/pty/m220
-/dev/pty/m221
-/dev/pty/m222
-/dev/pty/m223
-/dev/pty/m224
-/dev/pty/m225
-/dev/pty/m226
-/dev/pty/m227
-/dev/pty/m228
-/dev/pty/m229
-/dev/pty/m230
-/dev/pty/m231
-/dev/pty/m232
-/dev/pty/m233
-/dev/pty/m234
-/dev/pty/m235
-/dev/pty/m236
-/dev/pty/m237
-/dev/pty/m238
-/dev/pty/m239
-/dev/pty/m240
-/dev/pty/m241
-/dev/pty/m242
-/dev/pty/m243
-/dev/pty/m244
-/dev/pty/m245
-/dev/pty/m246
-/dev/pty/m247
-/dev/pty/m248
-/dev/pty/m249
-/dev/pty/m250
-/dev/pty/m251
-/dev/pty/m252
-/dev/pty/m253
-/dev/pty/m254
-/dev/pty/m255
-/dev/pts
-/dev/pts/0
-/dev/pts/1
-/dev/pts/2
-/dev/pts/3
-/dev/pts/4
-/dev/pts/5
-/dev/pts/6
-/dev/pts/7
-/dev/vcc
-/dev/vcc/0
-/dev/vcc/a
-/dev/vcc/1
-/dev/vcc/a1
-/dev/vcc/2
-/dev/vcc/a2
-/dev/vcc/3
-/dev/vcc/a3
-/dev/vcc/5
-/dev/vcc/a5
-/dev/vcc/4
-/dev/vcc/a4
-/dev/vcc/6
-/dev/vcc/a6
-/dev/vcc/7
-/dev/vcc/a7
-/dev/tts
-/dev/tts/0
-/dev/cua
-/dev/cua/0
-/dev/ide
-/dev/ide/host0
-/dev/ide/host0/bus0
-/dev/ide/host0/bus0/target0
-/dev/ide/host0/bus0/target0/lun0
-/dev/ide/host0/bus0/target0/lun0/disc
-/dev/ide/host0/bus0/target0/lun0/part1
-/dev/ide/host0/bus0/target0/lun0/part2
-/dev/ide/host0/bus0/target0/lun0/part3
-/dev/ide/host0/bus0/target0/lun0/part4
-/dev/ide/host0/bus0/target0/lun0/part5
-/dev/ide/host0/bus0/target0/lun0/part6
-/dev/ide/host0/bus0/target0/lun0/part7
-/dev/ide/host0/bus0/target0/lun0/part8
-/dev/ide/host0/bus0/target1
-/dev/ide/host0/bus0/target1/lun0
-/dev/ide/host0/bus0/target1/lun0/disc
-/dev/ide/host0/bus0/target1/lun0/part1
-/dev/ide/host0/bus1
-/dev/ide/host0/bus1/target0
-/dev/ide/host0/bus1/target0/lun0
-/dev/ide/host0/bus1/target0/lun0/disc
-/dev/ide/host0/bus1/target0/lun0/part1
-/dev/ide/host0/bus1/target1
-/dev/ide/host0/bus1/target1/lun0
-/dev/discs
-/dev/discs/disc0
-/dev/discs/disc1
-/dev/discs/disc2
-/dev/floppy
-/dev/floppy/0u1440
-/dev/floppy/0u1680
-/dev/floppy/0u1722
-/dev/floppy/0u1743
-/dev/floppy/0u1760
-/dev/floppy/0u1920
-/dev/floppy/0u1840
-/dev/floppy/0u1600
-/dev/floppy/0u360
-/dev/floppy/0u720
-/dev/floppy/0u820
-/dev/floppy/0u830
-/dev/floppy/0u1040
-/dev/floppy/0u1120
-/dev/floppy/0u800
-/dev/floppy/0
-/dev/loop
-/dev/loop/0
-/dev/loop/1
-/dev/loop/2
-/dev/loop/3
-/dev/loop/4
-/dev/loop/5
-/dev/loop/6
-/dev/loop/7
-/dev/cdroms
-/dev/sound
-/dev/sound/dsp
-/dev/sound/dsp1
-/dev/sound/mixer
-/dev/sound/midi
-/dev/usb
-/dev/root
-/dev/initctl
-/dev/xconsole
-/dev/fd
-/dev/stdin
-/dev/stdout
-/dev/stderr
-/dev/route
-/dev/skip
-/dev/USERSOCK
-/dev/fwmonitor
-/dev/ARPD
-/dev/ROUTE6
-/dev/IP6_FW
-/dev/tap0
-/dev/tap1
-/dev/tap2
-/dev/tap3
-/dev/tap4
-/dev/tap5
-/dev/tap6
-/dev/tap7
-/dev/tap8
-/dev/tap9
-/dev/tap10
-/dev/tap11
-/dev/tap12
-/dev/tap13
-/dev/tap14
-/dev/tap15
-/dev/tty1
-/dev/tty2
-/dev/tty3
-/dev/tty4
-/dev/tty5
-/dev/tty6
-/dev/tty7
-/dev/tty8
-/dev/tty9
-/dev/tty10
-/dev/tty11
-/dev/tty12
-/dev/tty13
-/dev/tty14
-/dev/tty15
-/dev/tty16
-/dev/tty17
-/dev/tty18
-/dev/tty19
-/dev/tty20
-/dev/tty21
-/dev/tty22
-/dev/tty23
-/dev/tty24
-/dev/tty25
-/dev/tty26
-/dev/tty27
-/dev/tty28
-/dev/tty29
-/dev/tty30
-/dev/tty31
-/dev/tty32
-/dev/tty33
-/dev/tty34
-/dev/tty35
-/dev/tty36
-/dev/tty37
-/dev/tty38
-/dev/tty39
-/dev/tty40
-/dev/tty41
-/dev/tty42
-/dev/tty43
-/dev/tty44
-/dev/tty45
-/dev/tty46
-/dev/tty47
-/dev/tty48
-/dev/tty49
-/dev/tty50
-/dev/tty51
-/dev/tty52
-/dev/tty53
-/dev/tty54
-/dev/tty55
-/dev/tty56
-/dev/tty57
-/dev/tty58
-/dev/tty59
-/dev/tty60
-/dev/tty61
-/dev/tty62
-/dev/tty63
-/dev/tty0
-/dev/psaux
-/dev/ptyp0
-/dev/ptyp1
-/dev/ptyp2
-/dev/ptyp3
-/dev/ptyp4
-/dev/ptyp5
-/dev/ptyp6
-/dev/ptyp7
-/dev/ptyp8
-/dev/ptyp9
-/dev/ptypa
-/dev/ptypb
-/dev/ptypc
-/dev/ptypd
-/dev/ptype
-/dev/ptypf
-/dev/ptyq0
-/dev/ptyq1
-/dev/ptyq2
-/dev/ptyq3
-/dev/ptyq4
-/dev/ptyq5
-/dev/ptyq6
-/dev/ptyq7
-/dev/ptyq8
-/dev/ptyq9
-/dev/ptyqa
-/dev/ptyqb
-/dev/ptyqc
-/dev/ptyqd
-/dev/ptyqe
-/dev/ptyqf
-/dev/ptyr0
-/dev/ptyr1
-/dev/ptyr2
-/dev/ptyr3
-/dev/ptyr4
-/dev/ptyr5
-/dev/ptyr6
-/dev/ptyr7
-/dev/ptyr8
-/dev/ptyr9
-/dev/ptyra
-/dev/ptyrb
-/dev/ptyrc
-/dev/ptyrd
-/dev/ptyre
-/dev/ptyrf
-/dev/ptys0
-/dev/ptys1
-/dev/ptys2
-/dev/ptys3
-/dev/ptys4
-/dev/ptys5
-/dev/ptys6
-/dev/ptys7
-/dev/ptys8
-/dev/ptys9
-/dev/ptysa
-/dev/ptysb
-/dev/ptysc
-/dev/ptysd
-/dev/ptyse
-/dev/ptysf
-/dev/ptyt0
-/dev/ptyt1
-/dev/ptyt2
-/dev/ptyt3
-/dev/ptyt4
-/dev/ptyt5
-/dev/ptyt6
-/dev/ptyt7
-/dev/ptyt8
-/dev/ptyt9
-/dev/ptyta
-/dev/ptytb
-/dev/ptytc
-/dev/ptytd
-/dev/ptyte
-/dev/ptytf
-/dev/ptyu0
-/dev/ptyu1
-/dev/ptyu2
-/dev/ptyu3
-/dev/ptyu4
-/dev/ptyu5
-/dev/ptyu6
-/dev/ptyu7
-/dev/ptyu8
-/dev/ptyu9
-/dev/ptyua
-/dev/ptyub
-/dev/ptyuc
-/dev/ptyud
-/dev/ptyue
-/dev/ptyuf
-/dev/ptyv0
-/dev/ptyv1
-/dev/ptyv2
-/dev/ptyv3
-/dev/ptyv4
-/dev/ptyv5
-/dev/ptyv6
-/dev/ptyv7
-/dev/ptyv8
-/dev/ptyv9
-/dev/ptyva
-/dev/ptyvb
-/dev/ptyvc
-/dev/ptyvd
-/dev/ptyve
-/dev/ptyvf
-/dev/ptyw0
-/dev/ptyw1
-/dev/ptyw2
-/dev/ptyw3
-/dev/ptyw4
-/dev/ptyw5
-/dev/ptyw6
-/dev/ptyw7
-/dev/ptyw8
-/dev/ptyw9
-/dev/ptywa
-/dev/ptywb
-/dev/ptywc
-/dev/ptywd
-/dev/ptywe
-/dev/ptywf
-/dev/ptyx0
-/dev/ptyx1
-/dev/ptyx2
-/dev/ptyx3
-/dev/ptyx4
-/dev/ptyx5
-/dev/ptyx6
-/dev/ptyx7
-/dev/ptyx8
-/dev/ptyx9
-/dev/ptyxa
-/dev/ptyxb
-/dev/ptyxc
-/dev/ptyxd
-/dev/ptyxe
-/dev/ptyxf
-/dev/ptyy0
-/dev/ptyy1
-/dev/ptyy2
-/dev/ptyy3
-/dev/ptyy4
-/dev/ptyy5
-/dev/ptyy6
-/dev/ptyy7
-/dev/ptyy8
-/dev/ptyy9
-/dev/ptyya
-/dev/ptyyb
-/dev/ptyyc
-/dev/ptyyd
-/dev/ptyye
-/dev/ptyyf
-/dev/ptyz0
-/dev/ptyz1
-/dev/ptyz2
-/dev/ptyz3
-/dev/ptyz4
-/dev/ptyz5
-/dev/ptyz6
-/dev/ptyz7
-/dev/ptyz8
-/dev/ptyz9
-/dev/ptyza
-/dev/ptyzb
-/dev/ptyzc
-/dev/ptyzd
-/dev/ptyze
-/dev/ptyzf
-/dev/ptya0
-/dev/ptya1
-/dev/ptya2
-/dev/ptya3
-/dev/ptya4
-/dev/ptya5
-/dev/ptya6
-/dev/ptya7
-/dev/ptya8
-/dev/ptya9
-/dev/ptyaa
-/dev/ptyab
-/dev/ptyac
-/dev/ptyad
-/dev/ptyae
-/dev/ptyaf
-/dev/ptyb0
-/dev/ptyb1
-/dev/ptyb2
-/dev/ptyb3
-/dev/ptyb4
-/dev/ptyb5
-/dev/ptyb6
-/dev/ptyb7
-/dev/ptyb8
-/dev/ptyb9
-/dev/ptyba
-/dev/ptybb
-/dev/ptybc
-/dev/ptybd
-/dev/ptybe
-/dev/ptybf
-/dev/ptyc0
-/dev/ptyc1
-/dev/ptyc2
-/dev/ptyc3
-/dev/ptyc4
-/dev/ptyc5
-/dev/ptyc6
-/dev/ptyc7
-/dev/ptyc8
-/dev/ptyc9
-/dev/ptyca
-/dev/ptycb
-/dev/ptycc
-/dev/ptycd
-/dev/ptyce
-/dev/ptycf
-/dev/ptyd0
-/dev/ptyd1
-/dev/ptyd2
-/dev/ptyd3
-/dev/ptyd4
-/dev/ptyd5
-/dev/ptyd6
-/dev/ptyd7
-/dev/ptyd8
-/dev/ptyd9
-/dev/ptyda
-/dev/ptydb
-/dev/ptydc
-/dev/ptydd
-/dev/ptyde
-/dev/ptydf
-/dev/ptye0
-/dev/ptye1
-/dev/ptye2
-/dev/ptye3
-/dev/ptye4
-/dev/ptye5
-/dev/ptye6
-/dev/ptye7
-/dev/ptye8
-/dev/ptye9
-/dev/ptyea
-/dev/ptyeb
-/dev/ptyec
-/dev/ptyed
-/dev/ptyee
-/dev/ptyef
-/dev/vcs
-/dev/vcsa
-/dev/vcs1
-/dev/vcsa1
-/dev/ttyS0
-/dev/cua0
-/dev/hda
-/dev/hda1
-/dev/hda2
-/dev/hda3
-/dev/hda4
-/dev/hda5
-/dev/hda6
-/dev/hda7
-/dev/hda8
-/dev/hdb
-/dev/hdb1
-/dev/hdc
-/dev/hdc1
-/dev/fd0u1440
-/dev/fd0u1680
-/dev/fd0u1722
-/dev/fd0u1743
-/dev/fd0u1760
-/dev/fd0u1920
-/dev/fd0u1840
-/dev/fd0u1600
-/dev/fd0u360
-/dev/fd0u720
-/dev/fd0u820
-/dev/fd0u830
-/dev/fd0u1040
-/dev/fd0u1120
-/dev/fd0u800
-/dev/fd0
-/dev/loop0
-/dev/loop1
-/dev/loop2
-/dev/loop3
-/dev/loop4
-/dev/loop5
-/dev/loop6
-/dev/loop7
-/dev/dsp
-/dev/dsp1
-/dev/mixer
-/dev/midi
-/dev/lvm
-/dev/vg0
-/dev/vg0/group
-/dev/vg0/packages
-/dev/vg0/photos
-/dev/vg0/music
-/dev/log
-/dev/MAKEDEV
-/dev/printer
-/dev/vcs2
-/dev/vcsa2
-/dev/vcs3
-/dev/vcsa3
-/dev/vcs5
-/dev/vcsa5
-/dev/vcs4
-/dev/vcsa4
-/dev/vcs6
-/dev/vcsa6
-/dev/nvidia0
-/dev/nvidia1
-/dev/nvidia2
-/dev/nvidia3
-/dev/nvidiactl
-/dev/vcs7
-/dev/vcsa7
diff --git a/unit-tests/regex/matcher_t.c b/unit-tests/regex/matcher_t.c
deleted file mode 100644
index 24975a1..0000000
--- a/unit-tests/regex/matcher_t.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2010 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
- */
-
-#include "libdevmapper.h"
-#include "log.h"
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-
-
-static int _read_spec(const char *file, char ***regex, int *nregex)
-{
- char buffer[1024], *start, *ptr;
- FILE *fp = fopen(file, "r");
- int asize = 100;
- char **rx = dm_malloc(sizeof(*rx) * asize);
- int nr = 0;
-
- if (!fp)
- return 0;
-
- while (fgets(buffer, sizeof(buffer),fp)) {
-
- /* trim leading whitespace */
- for (ptr = buffer; *ptr && isspace((int) *ptr); ptr++);
-
- if (!*ptr || *ptr == '#')
- continue;
-
- if (*ptr == '\"') {
- ptr++;
- start = ptr;
- while (*ptr && *ptr != '\"') {
- if (*ptr == '\\')
- ptr++;
- ptr++;
- }
-
- if (!*ptr) {
- fprintf(stderr, "Formatting error : "
- "No terminating quote\n");
- return 0;
- }
-
- rx[nr] = dm_malloc((ptr - start) + 1);
- strncpy(rx[nr], start, ptr - start);
- rx[nr][ptr - start] = '\0';
- nr++;
- } else {
- fprintf(stderr, "%s", ptr);
- fprintf(stderr, "Formatting error : \"<regex>\" "
- "<token_name>\n");
- return 0;
- }
- }
-
- *regex = rx;
- *nregex = nr;
- return 1;
-}
-
-static void _free_regex(char **regex, int nregex)
-{
- int i;
- for (i = 0; i < nregex; i++)
- dm_free(regex[i]);
-
- dm_free(regex);
-}
-
-static void _scan_input(struct dm_regex *m, char **regex)
-{
- char buffer[256], *ptr;
- int r;
-
- while (fgets(buffer, sizeof(buffer), stdin)) {
- if ((ptr = strchr(buffer, '\n')))
- *ptr = '\0';
-
- r = dm_regex_match(m, buffer);
-
- if (r >= 0)
- printf("%s : %s\n", buffer, regex[r]);
- }
-}
-
-int main(int argc, char **argv)
-{
- struct dm_pool *mem;
- struct dm_regex *scanner;
- char **regex;
- int nregex;
- int ret = 0;
- int want_finger_print = 0, i;
- const char *pattern_file = NULL;
-
- for (i = 1; i < argc; i++)
- if (!strcmp(argv[i], "--fingerprint"))
- want_finger_print = 1;
-
- else
- pattern_file = argv[i];
-
- if (!pattern_file) {
- fprintf(stderr, "Usage : %s [--fingerprint] <pattern_file>\n", argv[0]);
- exit(1);
- }
-
- dm_log_init_verbose(_LOG_DEBUG);
-
- if (!(mem = dm_pool_create("match_regex", 10 * 1024))) {
- fprintf(stderr, "Couldn't create pool\n");
- ret = 2;
- goto err;
- }
-
- if (!_read_spec(pattern_file, ®ex, &nregex)) {
- fprintf(stderr, "Couldn't read the lex specification\n");
- ret = 3;
- goto err;
- }
-
- if (!(scanner = dm_regex_create(mem, (const char **)regex, nregex))) {
- fprintf(stderr, "Couldn't build the lexer\n");
- ret = 4;
- goto err;
- }
-
- if (want_finger_print)
- printf("fingerprint: %x\n", dm_regex_fingerprint(scanner));
- _scan_input(scanner, regex);
- _free_regex(regex, nregex);
-
- err:
- dm_pool_destroy(mem);
-
- return ret;
-}
diff --git a/unit-tests/regex/matcher_t.expected b/unit-tests/regex/matcher_t.expected
deleted file mode 100644
index 0b986b0..0000000
--- a/unit-tests/regex/matcher_t.expected
+++ /dev/null
@@ -1,16 +0,0 @@
-fingerprint: 352b6c4f
-/dev/loop/0 : loop/[0-9]+
-/dev/loop/1 : loop/[0-9]+
-/dev/loop/2 : loop/[0-9]+
-/dev/loop/3 : loop/[0-9]+
-/dev/loop/4 : loop/[0-9]+
-/dev/loop/5 : loop/[0-9]+
-/dev/loop/6 : loop/[0-9]+
-/dev/loop/7 : loop/[0-9]+
-/dev/hda1 : hd[a-d][0-5]+
-/dev/hda2 : hd[a-d][0-5]+
-/dev/hda3 : hd[a-d][0-5]+
-/dev/hda4 : hd[a-d][0-5]+
-/dev/hda5 : hd[a-d][0-5]+
-/dev/hdb1 : hd[a-d][0-5]+
-/dev/hdc1 : hd[a-d][0-5]+
diff --git a/unit-tests/regex/matcher_t.expected2 b/unit-tests/regex/matcher_t.expected2
deleted file mode 100644
index 7359937..0000000
--- a/unit-tests/regex/matcher_t.expected2
+++ /dev/null
@@ -1 +0,0 @@
-fingerprint: eed8ceb8
diff --git a/unit-tests/regex/matcher_t.expected3 b/unit-tests/regex/matcher_t.expected3
deleted file mode 100644
index fa56149..0000000
--- a/unit-tests/regex/matcher_t.expected3
+++ /dev/null
@@ -1,3 +0,0 @@
-foo�bar : �
-foo�b : foo�b
-� : �
diff --git a/unit-tests/regex/nonprint_input b/unit-tests/regex/nonprint_input
deleted file mode 100644
index 92a1807..0000000
--- a/unit-tests/regex/nonprint_input
+++ /dev/null
@@ -1,4 +0,0 @@
-foo.bar
-foo�bar
-foo�b
-�
diff --git a/unit-tests/regex/nonprint_regexes b/unit-tests/regex/nonprint_regexes
deleted file mode 100644
index e164c21..0000000
--- a/unit-tests/regex/nonprint_regexes
+++ /dev/null
@@ -1,3 +0,0 @@
-"foo�bar"
-"foo�b"
-"�"
diff --git a/unit-tests/regex/parse_t.c b/unit-tests/regex/parse_t.c
deleted file mode 100644
index d536e5a..0000000
--- a/unit-tests/regex/parse_t.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2010 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
- */
-
-/* hack - using unexported internal function */
-#define DEBUG
-#include "regex/parse_rx.c"
-
-#include <stdio.h>
-#include <ctype.h>
-
-static void _pretty_print(struct rx_node *rx, int depth)
-{
- int i;
- for (i = 0; i < depth; i++)
- printf(" ");
-
- /* display info about the node */
- switch (rx->type) {
- case CAT:
- printf("Cat");
- break;
-
- case OR:
- printf("Or");
- break;
-
- case STAR:
- printf("Star");
- break;
-
- case PLUS:
- printf("Plus");
- break;
-
- case QUEST:
- printf("Quest");
- break;
-
- case CHARSET:
- printf("Charset : ");
- for (i = 0; i < 256; i++) {
- if (dm_bit(rx->charset, i) && isprint(i))
- printf("%c", (char) i);
- }
- break;
-
- default:
- printf("Unknown type");
- }
- printf("\n");
-
- if (rx->left)
- _pretty_print(rx->left, depth + 1);
-
- if (rx->right)
- _pretty_print(rx->right, depth + 1);
-}
-
-int main(int argc, char **argv)
-{
- struct dm_pool *mem;
- struct rx_node *rx;
- int regex_print = 0;
- int show_nodes = 0;
- int regex_arg = 1;
-
- if (argc == 3 && !strcmp(argv[1], "-r")) {
- regex_print++;
- regex_arg++;
- argc--;
- }
-
- if (argc == 3 && !strcmp(argv[1], "-R")) {
- regex_print++;
- show_nodes++;
- regex_arg++;
- argc--;
- }
-
- if (argc != 2) {
- fprintf(stderr, "Usage : %s [-r] <regex>\n", argv[0]);
- exit(0);
- }
-
- dm_log_init_verbose(_LOG_DEBUG);
-
- if (!(mem = dm_pool_create("parse_regex", 1024))) {
- fprintf(stderr, "Couldn't create pool\n");
- exit(1);
- }
-
- if (!(rx = rx_parse_str(mem, argv[regex_arg]))) {
- dm_pool_destroy(mem);
- fprintf(stderr, "Couldn't parse regex\n");
- exit(1);
- }
-
- if (regex_print)
- _regex_print(rx, 0, show_nodes);
- else
- _pretty_print(rx, 0);
-
- dm_pool_destroy(mem);
-
- return 0;
-}
diff --git a/unit-tests/regex/random_regexes b/unit-tests/regex/random_regexes
deleted file mode 100644
index 7b9362d..0000000
--- a/unit-tests/regex/random_regexes
+++ /dev/null
@@ -1,100 +0,0 @@
-"(((a?)(([Ub]*)|z))((([qr]|X)+)([Qn]*)))+"
-"[HZejtuw]*"
-"((B|s)*)|(((([Fv]l)(N+))(([el]|C)(tJ)))?)"
-"((([Ma]?)|(t*))*)|((([cm]E)|(M?))|(([BE][EV])|([Qj][Mh])))"
-"(((([bw]*)|([IO]*))((zK)*))|(((pU)|(i|q))|((z?)|([HL]?))))*"
-"((([Pt]?)|[Tr])?)((Hq)*)"
-"[HOXcfgikosvwxz]"
-"[BCEFGHNPTUWfjlprsy]"
-"((((aD)*)|([Xo]+))+)(([HKn](([Eq]|[JQ])(I*)))*)"
-"([LNWYeghv]|e)*"
-"(((y(L*))*)|((([EP]+)(W+))*))*"
-"U*"
-"((((R+)(W|[Qr]))|([py]+))+)([LM]*)"
-"(([DOjx](D(b?)))|([Ke]*))*"
-"((([ls](c|[FT]))*)([JS]*))*"
-"((l?)|(([Gz]+)|(D*)))*"
-"[ABgjn]"
-"(((q|[dg])?)|([Uk]*))((([Fl]?)|([Ry]+))|(([IR]|c)|(T?)))"
-"((([an]|P)|[Jw])((a*)|(m*)))*"
-"((((R[ht])(h+))?)|(([pz](n?))+))+"
-"(((([Dc]b)([Sp][Ii]))|((k|F)*))|[Uiovz])*"
-"[Res]*"
-"[Zl]|a"
-"^[ANZdf]$"
-"[En]|(((Q+)(U+))([pt]*))"
-"[ADEIMQUWXZhklrsvz]"
-"(((S(y*))*)|(j*))*"
-"n*"
-"[NUau]*"
-"((((Z*)(D|[Nd]))|(([np]|B)+))|(([Xy][Fi])*))+"
-"((([EZ]?)|(d[HR]))*)((([Hg]|q)(P+))*)"
-"q"
-"((m*)|(p|B))|((((x?)|(t+))(([Sb][PX])(O|[HM])))+)"
-"((((A*)(z[RS]))*)|(((z+)(Q*))+))*"
-"(((M*)([Uu]*))+)|[Uk]"
-"[imv]"
-"[GLSchtw](([Yw]((F[Dd])|([Tw]+)))?)"
-"([MOZj]*)(S|[Wknr])"
-"((G|q)*)[BHKN]"
-"((((NW)|([Ao]?))|((l|[UV])+))+)|((i|(z*))*)"
-"((((Z+)|([IR]?))|(L*))|([JKQ]+))+"
-"([Bdin](S*))+"
-"[HLNSTp]*"
-"(((J*)([Bq]|[Yu]))*)|([Kv]*)"
-"(((([BJ]|[Zy])(wI))*)(y*))+"
-"(((hF)+)|(H*))*"
-"((([QU][Pj])([GQ]?))+)|[PWo]"
-"(((([cq][BX])?)|((f[DI])*))*)(([GM]*)[SVYr])"
-"(([Zt]*)|((qx)|(([BV]+)(f?))))*"
-"[ILWYhsx]*"
-"(([Uy]*)|[sv])|([NSc]*)"
-"((c*)|([JUfhy]?))+"
-"(((q*)([So]*))(((g[jq])(j?))+))*"
-"((b+)|(((T+)([fw]T))?))*"
-"((([DS]?)|([Th]|u))(Q*))*"
-"[FKLX]|((([fw](L?))(([gq]*)|(O?)))?)"
-"((([HZ]+)u)*)|[APWijn]"
-"(e*)|(((v?)|((J+)(Hb)))?)"
-"(e|((w+)f))*"
-"[BEHKPQVdelnqy]"
-"((((B|N)(s*))|[Rr])(((g?)|([rv]+))+))+"
-"(((s*)|(K*))([AP]G))*"
-"[CELTp]"
-"(([Fq]?)|([Al]+))*"
-"((((r?)|(y[jx]))|([mp]*))+)|((B(S*))*)"
-"((([Eq]+)|(Y[ds]))|(x|(i|[Ku])))[IJNrvy]"
-"((([NO]*)[Ix])+)([Jenq]+)"
-"(((([HP]*)(j|y))*)[Ylqvy])*"
-"[PTv]+"
-"[AINSZhpx]|([EOYZ]*)"
-"([ABCFQv]*)((([Zx]|h)+)|([ej]*))"
-"((([pr]*)|(([Dq]|p)|(H?)))?)([NRUXmoq]*)"
-"(([er]*)|([mx]*))(((nV)([am]?))+)"
-"[BHPRlpu]"
-"(((([Ah]|[tx])|(e|[uy]))?)((([fl]+)([Vz]|v))*))*"
-"[AGdm]"
-"(((K*)^(O*)$)|(B?))*"
-"((([Ks]|[Ka])*)|([FSTab]?))?"
-"(([kw]+)[ei])(([Hy]*)(([Mc]*)|(G|f)))"
-"((((e*)|(Zf))|(R|[nq]))((([Jz]v)([Rj]+))+))*"
-"(((a?)|(e?))(([Uc]*)(S+)))*"
-"((((E+)([MZ]?))+)|(((s|[Az])|z)*))?"
-"((((i[MO])*)|((LH)*))|(((BA)|([AI]+))|[Ug]))*"
-"[EGHILcho]*"
-"(((Z[vw])?)((z|g)+))(((H|U)([iv]Q))|([qw]?))"
-"(([ehmr]|((L[Uw])*))+)((a+)I)"
-"[EKNSWYagj](((v|[TX])|([Uk]+))*)"
-"(((R[Mo])|(O*))|([Fm]|([qw]*)))((m*)|((S|[Ki])?))"
-"((((kP)|c)?)((([do]+)|([Gi]?))*))*"
-"((^(B|W)$|([Ww]+))([no]*))|((([iv]?)|(M*))|((x|L)?))"
-"[AEGPRSbcfhsy]"
-"[Wbcf]|((([MO]?)|([NT]|m))(([Oo]?)([Wg]*)))"
-"(((YZ)*)[PQVei])*"
-"[GJKYt][AEGWdegmnt]"
-"^[CDEGJKNUVYZagkv]$"
-"([DPWbx]*)|(((q|B)|(P|u))((M[Bq])*))"
-"[FHIJRTVYZdiorsuvz]*"
-"([MWoqvz]*)|^(l*)"
-"(((I|[Rx])*)((X[Mf])([Xa]L)))([Ha]|([HY]*))"
-"(((l|[Sd])*)((([Ix]+)|([XY]?))(Z*)))+"
5 years, 12 months
master - [git] Update .gitignore
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=cb2c4542a6028ef09d3...
Commit: cb2c4542a6028ef09d30bfdcdaef4e7ddb740ca7
Parent: 38d77898ae7a824b3a05ee2a1812d7a85cca6373
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Wed Jan 31 11:35:47 2018 +0000
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 20 11:11:56 2018 -0500
[git] Update .gitignore
---
.gitignore | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
index a890cee..0ac0a32 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,3 +30,51 @@ make.tmpl
/cscope.out
/tags
/tmp/
+
+tools/man-generator
+tools/man-generator.c
+
+test/lib/lvchange
+test/lib/lvconvert
+test/lib/lvcreate
+test/lib/lvdisplay
+test/lib/lvextend
+test/lib/lvmconfig
+test/lib/lvmdiskscan
+test/lib/lvmsadc
+test/lib/lvmsar
+test/lib/lvreduce
+test/lib/lvremove
+test/lib/lvrename
+test/lib/lvresize
+test/lib/lvs
+test/lib/lvscan
+test/lib/pvchange
+test/lib/pvck
+test/lib/pvcreate
+test/lib/pvdisplay
+test/lib/pvmove
+test/lib/pvremove
+test/lib/pvresize
+test/lib/pvs
+test/lib/pvscan
+test/lib/vgcfgbackup
+test/lib/vgcfgrestore
+test/lib/vgchange
+test/lib/vgck
+test/lib/vgconvert
+test/lib/vgcreate
+test/lib/vgdisplay
+test/lib/vgexport
+test/lib/vgextend
+test/lib/vgimport
+test/lib/vgimportclone
+test/lib/vgmerge
+test/lib/vgmknodes
+test/lib/vgreduce
+test/lib/vgremove
+test/lib/vgrename
+test/lib/vgs
+test/lib/vgscan
+test/lib/vgsplit
+
5 years, 12 months
master - [build] Quieten the build down
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7a475bef323cae74d60...
Commit: 7a475bef323cae74d602f2aae8074b106ddb3f4b
Parent: da7e13ef88541c4ca4b067f4f47ad7b43d346501
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Wed Jan 31 10:04:17 2018 +0000
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 20 11:10:45 2018 -0500
[build] Quieten the build down
It was hard to see warnings with the long command lines scrolling by so
quickly.
Use 'make V=1' if you need to see all the gritty details.
---
make.tmpl.in | 62 ++++++++++++++++++++++++++--------------
man/Makefile.in | 81 +++++++++++++++++++++++++----------------------------
tools/Makefile.in | 73 ++++++++++++++++++++++++++++++-----------------
3 files changed, 125 insertions(+), 91 deletions(-)
diff --git a/make.tmpl.in b/make.tmpl.in
index bdf2349..75134ca 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -13,6 +13,12 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ifeq ($(V),1)
+ Q=
+else
+ Q=@
+endif
+
SHELL = @SHELL@
@SET_MAKE@
@@ -438,59 +444,70 @@ endif
.LIBPATTERNS = lib%.so lib%.a
%.o: %.c
- $(CC) -c $(INCLUDES) $(VALGRIND_CFLAGS) $(PROGS_CFLAGS) $(DEFS) $(DEFS_$@) $(WFLAGS) $(WCFLAGS) $(CFLAGS) $(CFLAGS_$@) $< -o $@
+ @echo " [CC] $<"
+ $(Q) $(CC) -c $(INCLUDES) $(VALGRIND_CFLAGS) $(PROGS_CFLAGS) $(DEFS) $(DEFS_$@) $(WFLAGS) $(WCFLAGS) $(CFLAGS) $(CFLAGS_$@) $< -o $@
%.o: %.cpp
- $(CXX) -c $(INCLUDES) $(VALGRIND_CFLAGS) $(DEFS) $(DEFS_$@) $(WFLAGS) $(CXXFLAGS) $(CXXFLAGS_$@) $< -o $@
+ @echo " [CXX] $<"
+ $(Q) $(CXX) -c $(INCLUDES) $(VALGRIND_CFLAGS) $(DEFS) $(DEFS_$@) $(WFLAGS) $(CXXFLAGS) $(CXXFLAGS_$@) $< -o $@
%.pot: %.c Makefile
- $(CC) -E $(INCLUDES) $(VALGRIND_CFLAGS) $(PROGS_CFLAGS) -include $(top_builddir)/include/pogen.h $(DEFS) $(WFLAGS) $(CFLAGS) $< >$@
+ @echo " [CC] $@"
+ $(Q) $(CC) -E $(INCLUDES) $(VALGRIND_CFLAGS) $(PROGS_CFLAGS) -include $(top_builddir)/include/pogen.h $(DEFS) $(WFLAGS) $(CFLAGS) $< >$@
%.so: %.o
- $(CC) -c $(CFLAGS) $(CLDFLAGS) $< $(LIBS) -o $@
+ @echo " [CC] $<"
+ $(Q) $(CC) -c $(CFLAGS) $(CLDFLAGS) $< $(LIBS) -o $@
ifneq (,$(LIB_SHARED))
TARGETS += $(LIB_SHARED).$(LIB_VERSION)
$(LIB_SHARED).$(LIB_VERSION): $(OBJECTS) $(LDDEPS)
+ @echo " [CC] $@"
ifeq ("@LIB_SUFFIX@","so")
- $(CC) -shared -Wl,-soname,$(notdir $@) \
+ $(Q) $(CC) -shared -Wl,-soname,$(notdir $@) \
$(CFLAGS) $(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@
endif
ifeq ("@LIB_SUFFIX@","dylib")
- $(CC) -dynamiclib -dylib_current_version,$(LIB_VERSION) \
+ $(Q) $(CC) -dynamiclib -dylib_current_version,$(LIB_VERSION) \
$(CFLAGS) $(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@
endif
$(LIB_SHARED): $(LIB_SHARED).$(LIB_VERSION)
- $(LN_S) -f $(<F) $@
+ @echo " [LN] $<"
+ $(Q) $(LN_S) -f $(<F) $@
CLEAN_TARGETS += $(LDDEPS) .exported_symbols_generated
install_lib_shared: $(LIB_SHARED)
- $(INSTALL_PROGRAM) -D $< $(libdir)/$(<F).$(LIB_VERSION)
- $(INSTALL_DIR) $(usrlibdir)
- $(LN_S) -f $(USRLIB_RELPATH)$(<F).$(LIB_VERSION) $(usrlibdir)/$(<F)
+ @echo " [INSTALL] $<"
+ $(Q) $(INSTALL_PROGRAM) -D $< $(libdir)/$(<F).$(LIB_VERSION)
+ $(Q) $(INSTALL_DIR) $(usrlibdir)
+ $(Q) $(LN_S) -f $(USRLIB_RELPATH)$(<F).$(LIB_VERSION) $(usrlibdir)/$(<F)
# FIXME: plugins are installed to subdirs
# and for compatibility links in libdir are created
# when the code is fixed links could be removed.
install_dm_plugin: $(LIB_SHARED)
- $(INSTALL_PROGRAM) -D $< $(libdir)/device-mapper/$(<F)
- $(LN_S) -f device-mapper/$(<F) $(libdir)/$(<F)
+ @echo " [INSTALL] $<"
+ $(Q) $(INSTALL_PROGRAM) -D $< $(libdir)/device-mapper/$(<F)
+ $(Q) $(LN_S) -f device-mapper/$(<F) $(libdir)/$(<F)
install_lvm2_plugin: $(LIB_SHARED)
- $(INSTALL_PROGRAM) -D $< $(libdir)/lvm2/$(<F)
- $(LN_S) -f lvm2/$(<F) $(libdir)/$(<F)
- $(LN_S) -f $(<F) $(libdir)/$(<F).$(LIB_VERSION)
+ @echo " [INSTALL] $<"
+ $(Q) $(INSTALL_PROGRAM) -D $< $(libdir)/lvm2/$(<F)
+ $(Q) $(LN_S) -f lvm2/$(<F) $(libdir)/$(<F)
+ $(Q) $(LN_S) -f $(<F) $(libdir)/$(<F).$(LIB_VERSION)
endif
$(LIB_STATIC): $(OBJECTS)
- $(RM) $@
- $(AR) rsv $@ $(OBJECTS)
+ @echo " [AR] $@"
+ $(Q) $(RM) $@
+ $(Q) $(AR) rsv $@ $(OBJECTS) > /dev/null
%.d: %.c $(INC_LNS)
- $(MKDIR_P) $(dir $@); \
+ @echo " [DEP] $<"
+ $(Q) $(MKDIR_P) $(dir $@); \
set -e; \
FILE=`echo $@ | sed 's/\\//\\\\\\//g;s/\\.d//g'`; \
DEPS=`echo $(DEPS) | sed -e 's/\\//\\\\\\//g'`; \
@@ -501,7 +518,8 @@ $(LIB_STATIC): $(OBJECTS)
[ -s $@ ] || $(RM) $@
%.mo: %.po
- $(MSGFMT) -o $@ $<
+ @echo " [MSGFMT] $<"
+ $(Q) $(MSGFMT) -o $@ $<
CLEAN_TARGETS += \
$(SOURCES:%.c=%.d) $(SOURCES:%.c=%.gcno) $(SOURCES:%.c=%.gcda) \
@@ -523,7 +541,7 @@ endif
$(RM) $(DISTCLEAN_TARGETS) Makefile
.exported_symbols_generated: $(EXPORTED_HEADER) .exported_symbols $(DEPS)
- set -e; \
+ $(Q) set -e; \
( cat $(srcdir)/.exported_symbols; \
if test -n "$(EXPORTED_HEADER)"; then \
$(CC) -E -P $(INCLUDES) $(DEFS) $(EXPORTED_HEADER) | \
@@ -536,13 +554,13 @@ EXPORTED_SYMBOLS := $(wildcard $(srcdir)/.exported_symbols.Base $(srcdir)/.expor
.export.sym: .exported_symbols_generated $(EXPORTED_SYMBOLS)
ifeq (,$(firstword $(EXPORTED_SYMBOLS)))
- set -e; (echo "Base {"; echo " global:";\
+ $(Q) set -e; (echo "Base {"; echo " global:";\
$(SED) "s/^/ /;s/$$/;/" $<;\
echo "};";\
echo "Local {"; echo " local:"; echo " *;"; echo "};";\
) > $@
else
- set -e;\
+ $(Q) set -e;\
R=$$($(SORT) $^ | uniq -u);\
test -z "$$R" || { echo "Mismatch between symbols in shared library and lists in .exported_symbols.* files: $$R"; false; } ;\
( for i in $$(echo $(EXPORTED_SYMBOLS) | tr ' ' '\n' | $(SORT) -rnt_ -k5 ); do\
diff --git a/man/Makefile.in b/man/Makefile.in
index cd1106f..a40e168 100644
--- a/man/Makefile.in
+++ b/man/Makefile.in
@@ -16,6 +16,12 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
+ifeq ($(V),1)
+ Q=
+else
+ Q=@
+endif
+
FSADMMAN = fsadm.8
BLKDEACTIVATEMAN = blkdeactivate.8
DMEVENTDMAN = dmeventd.8
@@ -46,20 +52,6 @@ MAN8DM=dmsetup.8 dmstats.8
MAN8CLUSTER=
MAN8SYSTEMD_GENERATORS=lvm2-activation-generator.8
-ifeq ("$(origin V)", "command line")
- BUILD_VERBOSE = $(V)
-endif
-ifndef BUILD_VERBOSE
- BUILD_VERBOSE = 0
-endif
-
-ifeq ($(BUILD_VERBOSE),1)
- Q =
-else
- Q = @
-endif
-
-
ifeq ($(MAKECMDGOALS),all_man)
MAN_ALL="yes"
endif
@@ -164,13 +156,6 @@ SEE_ALSO=$(srcdir)/see_also.end
.PRECIOUS: %.8_gen
%.8_gen: $(srcdir)/%.8_des $(srcdir)/%.8_end $(MANGENERATOR) $(TESTMAN)
- $(Q)( \
- if [ ! -s $(TESTMAN) ] ; then \
- echo "Copying pre-generated template $@" ; \
- else \
- echo "Generating template $@" ; \
- fi \
- )
$(Q)set -e ; ( \
if [ ! -s $(TESTMAN) ] ; then \
cat $(srcdir)/$(@:%.8_gen=%.8_pregen) ; \
@@ -184,7 +169,6 @@ SEE_ALSO=$(srcdir)/see_also.end
) > $@
define SUBSTVARS
-$(Q)echo "Generating $@"
$(Q)$(SED) -e "s+#VERSION#+$(LVM_VERSION)+" \
-e "s+#DEFAULT_SYS_DIR#+$(DEFAULT_SYS_DIR)+" \
-e "s+#DEFAULT_ARCHIVE_DIR#+$(DEFAULT_ARCHIVE_DIR)+" \
@@ -237,51 +221,62 @@ $(Q)$(SED) -i -e "s+\([ [:alpha:]]\)-\{7\}+\1\\\-\\\-\\\-\\\-\\\-\\\-\\\-+g" \
endef
%.5: $(srcdir)/%.5_main
- $(SUBSTVARS)
- $(ESCAPEHYPHENS)
+ @echo " [MAN] $@"
+ $(Q) $(SUBSTVARS)
+ $(Q) $(ESCAPEHYPHENS)
%.7: $(srcdir)/%.7_main
- $(SUBSTVARS)
- $(ESCAPEHYPHENS)
+ @echo " [MAN] $@"
+ $(Q) $(SUBSTVARS)
+ $(Q) $(ESCAPEHYPHENS)
%.8: $(srcdir)/%.8_main
- $(SUBSTVARS)
- $(ESCAPEHYPHENS)
+ @echo " [MAN] $@"
+ $(Q) $(SUBSTVARS)
+ $(Q) $(ESCAPEHYPHENS)
%.8: %.8_gen
- $(SUBSTVARS)
- $(ESCAPEHYPHENS)
+ @echo " [MAN] $@"
+ $(Q) $(SUBSTVARS)
+ $(Q) $(ESCAPEHYPHENS)
$(MAN8SO): lvmconfig.8
- echo ".so $<" > $@
+ @echo " [MAN] $@"
+ $(Q) echo ".so $<" > $@
install_man5: $(MAN5)
- $(INSTALL) -d $(MAN5DIR)
- $(INSTALL_DATA) $(MAN5) $(MAN5DIR)/
+ @echo " [INSTALL] $<"
+ $(Q) $(INSTALL) -d $(MAN5DIR)
+ $(Q) $(INSTALL_DATA) $(MAN5) $(MAN5DIR)/
install_man7: $(MAN7)
- $(INSTALL) -d $(MAN7DIR)
- $(INSTALL_DATA) $(MAN7) $(MAN7DIR)/
+ @echo " [INSTALL] $<"
+ $(Q) $(INSTALL) -d $(MAN7DIR)
+ $(Q) $(INSTALL_DATA) $(MAN7) $(MAN7DIR)/
install_man8: $(MAN8) $(MAN8SO)
- $(INSTALL) -d $(MAN8DIR)
- $(INSTALL_DATA) $(MAN8) $(MAN8SO) $(MAN8DIR)/
+ @echo " [INSTALL] $<"
+ $(Q) $(INSTALL) -d $(MAN8DIR)
+ $(Q) $(INSTALL_DATA) $(MAN8) $(MAN8SO) $(MAN8DIR)/
install_lvm2: install_man5 install_man7 install_man8
install_cluster: $(MAN8CLUSTER)
ifdef MAN8CLUSTER
- $(INSTALL) -d $(MAN8DIR)
- $(INSTALL_DATA) $(MAN8CLUSTER) $(MAN8DIR)/
+ @echo " [INSTALL] $<"
+ $(Q) $(INSTALL) -d $(MAN8DIR)
+ $(Q) $(INSTALL_DATA) $(MAN8CLUSTER) $(MAN8DIR)/
endif
install_device-mapper: $(MAN8DM)
- $(INSTALL) -d $(MAN8DIR)
- $(INSTALL_DATA) $(MAN8DM) $(MAN8DIR)/
+ @echo " [INSTALL] $<"
+ $(Q) $(INSTALL) -d $(MAN8DIR)
+ $(Q) $(INSTALL_DATA) $(MAN8DM) $(MAN8DIR)/
install_systemd_generators: $(MAN8SYSTEMD_GENERATORS)
- $(INSTALL) -d $(MAN8DIR)
- $(INSTALL_DATA) $(MAN8SYSTEMD_GENERATORS) $(MAN8DIR)/
+ @echo " [INSTALL] $<"
+ $(Q) $(INSTALL) -d $(MAN8DIR)
+ $(Q) $(INSTALL_DATA) $(MAN8SYSTEMD_GENERATORS) $(MAN8DIR)/
install: install_lvm2 install_device-mapper install_cluster
diff --git a/tools/Makefile.in b/tools/Makefile.in
index de5b628..61c6f38 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -123,11 +123,13 @@ device-mapper: $(TARGETS_DM)
CFLAGS_dmsetup.o += $(UDEV_CFLAGS) $(EXTRA_EXEC_CFLAGS)
dmsetup: dmsetup.o $(top_builddir)/libdm/libdevmapper.$(LIB_SUFFIX)
- $(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) \
+ @echo " [CC] $@"
+ $(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) \
-o $@ dmsetup.o -ldevmapper $(LIBS)
dmsetup.static: dmsetup.o $(interfacebuilddir)/libdevmapper.a
- $(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) \
+ @echo " [CC] $@"
+ $(Q) $(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) \
-o $@ dmsetup.o -ldevmapper $(M_LIBS) $(PTHREAD_LIBS) $(STATIC_LIBS) $(LIBS)
all: device-mapper
@@ -137,15 +139,18 @@ CFLAGS_lvm.o += $(EXTRA_EXEC_CFLAGS)
INCLUDES += -I$(top_builddir)/tools
lvm: $(OBJECTS) lvm.o $(top_builddir)/lib/liblvm-internal.a
- $(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) -o $@ $(OBJECTS) lvm.o \
+ @echo " [CC] $@"
+ $(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) -o $@ $(OBJECTS) lvm.o \
$(LVMLIBS) $(READLINE_LIBS) $(LIBS)
DEFS_man-generator.o += -DMAN_PAGE_GENERATOR
man-generator.c: command.c
- $(LN_S) -f $< $@
+ @echo " [LN] $@"
+ $(Q) $(LN_S) -f $< $@
man-generator: man-generator.o
+ @echo " [CC] $@"
$(CC) $(CFLAGS) -o $@ $<
ifeq ("@BUILD_LVMETAD@", "yes")
@@ -153,32 +158,39 @@ lvm: $(top_builddir)/libdaemon/client/libdaemonclient.a
endif
lvm.static: $(OBJECTS) lvm-static.o $(top_builddir)/lib/liblvm-internal.a $(interfacebuilddir)/libdevmapper.a
- $(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) -o $@ \
+ @echo " [CC] $@"
+ $(Q) $(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) -o $@ \
$(OBJECTS) lvm-static.o $(LVMLIBS) $(STATIC_LIBS) $(LIBS)
liblvm2cmd.a: $(top_builddir)/lib/liblvm-internal.a $(OBJECTS) lvmcmdlib.o lvm2cmd.o
- cat $(top_builddir)/lib/liblvm-internal.a > $@
- $(AR) rs $@ $(OBJECTS) lvmcmdlib.o lvm2cmd.o
+ @echo " [AR] $@"
+ $(Q) cat $(top_builddir)/lib/liblvm-internal.a > $@
+ $(Q) $(AR) rs $@ $(OBJECTS) lvmcmdlib.o lvm2cmd.o > /dev/null
liblvm2cmd-static.a: $(top_builddir)/lib/liblvm-internal.a $(OBJECTS) lvmcmdlib.o lvm2cmd-static.o
- cat $(top_builddir)/lib/liblvm-internal.a > $@
- $(AR) rs $@ $(OBJECTS) lvmcmdlib.o lvm2cmd-static.o
+ @echo " [AR] $@"
+ $(Q) cat $(top_builddir)/lib/liblvm-internal.a > $@
+ $(Q) $(AR) rs $@ $(OBJECTS) lvmcmdlib.o lvm2cmd-static.o > /dev/null
liblvm2cmd.$(LIB_SUFFIX): liblvm2cmd.a $(LDDEPS)
- $(CC) -shared -Wl,-soname,$@.$(LIB_VERSION) \
+ @echo " [CC] $@"
+ $(Q) $(CC) -shared -Wl,-soname,$@.$(LIB_VERSION) \
$(CFLAGS) $(CLDFLAGS) -o $@ \
@CLDWHOLEARCHIVE@ liblvm2cmd.a @CLDNOWHOLEARCHIVE@ \
$(LVMLIBS) $(LIBS)
liblvm2cmd.$(LIB_SUFFIX).$(LIB_VERSION): liblvm2cmd.$(LIB_SUFFIX)
- $(LN_S) -f $< $@
+ @echo " [LN] $@"
+ $(Q) $(LN_S) -f $< $@
.commands: $(srcdir)/commands.h $(srcdir)/cmdnames.h Makefile
- $(CC) -E -P $(srcdir)/cmdnames.h 2> /dev/null | \
+ @echo " [CC] $<"
+ $(Q) $(CC) -E -P $(srcdir)/cmdnames.h 2> /dev/null | \
$(EGREP) -v '^ *(|#.*|config|devtypes|dumpconfig|formats|fullreport|help|lastlog|lvmchange|lvpoll|pvdata|segtypes|systemid|tags|version) *$$' > .commands
command-count.h: $(srcdir)/command-lines.in Makefile
- set -o pipefail && \
+ @echo " [GEN] $@"
+ $(Q) set -o pipefail && \
( cat $(top_srcdir)/tools/license.inc && \
echo "/* Do not edit. This file is generated by the Makefile. */" && \
echo -n "#define COMMAND_COUNT " && \
@@ -186,7 +198,8 @@ command-count.h: $(srcdir)/command-lines.in Makefile
) > $@
cmds.h: $(srcdir)/command-lines.in Makefile
- set -o pipefail && \
+ @echo " [GEN] $@"
+ $(Q) set -o pipefail && \
( cat $(top_srcdir)/tools/license.inc && \
echo "/* Do not edit. This file is generated by the Makefile. */" && \
echo "cmd(CMD_NONE, none)" && \
@@ -195,7 +208,8 @@ cmds.h: $(srcdir)/command-lines.in Makefile
) > $@
command-lines-input.h: $(srcdir)/command-lines.in Makefile
- set -o pipefail && \
+ @echo " [GEN] $@"
+ $(Q) set -o pipefail && \
( cat $(top_srcdir)/tools/license.inc && \
echo "/* Do not edit. This file is generated by the Makefile. */" && \
echo -en "const char _command_input[] =\n\n\"" && \
@@ -217,18 +231,22 @@ endif
install_dmsetup_dynamic install_dmsetup_static
install_cmdlib_include: $(srcdir)/lvm2cmd.h
- $(INSTALL_DATA) -D $< $(includedir)/$(<F)
+ @echo " [INSTALL] $<"
+ $(Q) $(INSTALL_DATA) -D $< $(includedir)/$(<F)
install_cmdlib_dynamic: liblvm2cmd.$(LIB_SUFFIX)
- $(INSTALL_PROGRAM) -D $< $(libdir)/$(<F).$(LIB_VERSION)
- $(INSTALL_DIR) $(usrlibdir)
- $(LN_S) -f $(USRLIB_RELPATH)$(<F).$(LIB_VERSION) $(usrlibdir)/$(<F)
+ @echo " [INSTALL] $<"
+ $(Q) $(INSTALL_PROGRAM) -D $< $(libdir)/$(<F).$(LIB_VERSION)
+ $(Q) $(INSTALL_DIR) $(usrlibdir)
+ $(Q) $(LN_S) -f $(USRLIB_RELPATH)$(<F).$(LIB_VERSION) $(usrlibdir)/$(<F)
install_cmdlib_static: liblvm2cmd-static.a
- $(INSTALL_DATA) -D $< $(usrlibdir)/liblvm2cmd.a
+ @echo " [INSTALL] $<"
+ $(Q) $(INSTALL_DATA) -D $< $(usrlibdir)/liblvm2cmd.a
install_tools_dynamic: lvm .commands
- $(INSTALL_PROGRAM) -D lvm $(sbindir)/lvm
+ @echo " [INSTALL] $<"
+ $(Q) $(INSTALL_PROGRAM) -D lvm $(sbindir)/lvm
@echo Creating symbolic links for individual commands in $(sbindir)
@for v in `cat .commands`; do \
echo "$(LN_S) -f lvm $(sbindir)/$$v"; \
@@ -236,15 +254,18 @@ install_tools_dynamic: lvm .commands
done;
install_tools_static: lvm.static
- $(INSTALL_PROGRAM) -D $< $(staticdir)/$(<F)
+ @echo " [INSTALL] $<"
+ $(Q) $(INSTALL_PROGRAM) -D $< $(staticdir)/$(<F)
install_dmsetup_dynamic: dmsetup
- $(INSTALL_PROGRAM) -D $< $(sbindir)/$(<F)
- $(LN_S) -f $(<F) $(sbindir)/dmstats
+ @echo " [INSTALL] $<"
+ $(Q) $(INSTALL_PROGRAM) -D $< $(sbindir)/$(<F)
+ $(Q) $(LN_S) -f $(<F) $(sbindir)/dmstats
install_dmsetup_static: dmsetup.static
- $(INSTALL_PROGRAM) -D $< $(staticdir)/$(<F)
- $(LN_S) -f $(<F) $(staticdir)/dmstats
+ @echo " [INSTALL] $<"
+ $(Q) $(INSTALL_PROGRAM) -D $< $(staticdir)/$(<F)
+ $(Q) $(LN_S) -f $(<F) $(staticdir)/dmstats
install_device-mapper: $(INSTALL_DMSETUP_TARGETS)
5 years, 12 months
master - [lib/device/bcache] Tweaks after Kabi's review
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=da7e13ef88541c4ca4b...
Commit: da7e13ef88541c4ca4b067f4f47ad7b43d346501
Parent: acb42ec4652450f7cd73440929fd57f1487282bf
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Tue Jan 30 12:13:48 2018 +0000
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 20 11:10:45 2018 -0500
[lib/device/bcache] Tweaks after Kabi's review
---
aclocal.m4 | 222 ++++++++++++++++++++++++++++++------------------
configure | 18 +++-
include/configure.h.in | 16 +++-
lib/Makefile.in | 1 +
lib/device/bcache.c | 108 ++++++++++++++----------
lib/device/bcache.h | 14 +++
6 files changed, 248 insertions(+), 131 deletions(-)
diff --git a/aclocal.m4 b/aclocal.m4
index 4ab64a8..07ea0b6 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -69,32 +69,63 @@ AC_DEFUN([AX_PYTHON_MODULE],[
fi
])
-# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
-# serial 1 (pkg-config-0.24)
-#
-# Copyright �� 2004 Scott James Remnant <scott(a)netsplit.com>.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# 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.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# PKG_PROG_PKG_CONFIG([MIN-VERSION])
-# ----------------------------------
+dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
+dnl serial 11 (pkg-config-0.29)
+dnl
+dnl Copyright �� 2004 Scott James Remnant <scott(a)netsplit.com>.
+dnl Copyright �� 2012-2015 Dan Nicholson <dbn.lists(a)gmail.com>
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+dnl 02111-1307, USA.
+dnl
+dnl As a special exception to the GNU General Public License, if you
+dnl distribute this file as part of a program that contains a
+dnl configuration script generated by Autoconf, you may include it under
+dnl the same distribution terms that you use for the rest of that
+dnl program.
+
+dnl PKG_PREREQ(MIN-VERSION)
+dnl -----------------------
+dnl Since: 0.29
+dnl
+dnl Verify that the version of the pkg-config macros are at least
+dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
+dnl installed version of pkg-config, this checks the developer's version
+dnl of pkg.m4 when generating configure.
+dnl
+dnl To ensure that this macro is defined, also add:
+dnl m4_ifndef([PKG_PREREQ],
+dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
+dnl
+dnl See the "Since" comment for each macro you use to see what version
+dnl of the macros you require.
+m4_defun([PKG_PREREQ],
+[m4_define([PKG_MACROS_VERSION], [0.29])
+m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
+ [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
+])dnl PKG_PREREQ
+
+dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
+dnl ----------------------------------
+dnl Since: 0.16
+dnl
+dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
+dnl first found in the path. Checks that the version of pkg-config found
+dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
+dnl used since that's the first version where most current features of
+dnl pkg-config existed.
AC_DEFUN([PKG_PROG_PKG_CONFIG],
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
@@ -116,18 +147,19 @@ if test -n "$PKG_CONFIG"; then
PKG_CONFIG=""
fi
fi[]dnl
-])# PKG_PROG_PKG_CONFIG
-
-# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-#
-# Check to see whether a particular set of modules exists. Similar
-# to PKG_CHECK_MODULES(), but does not set variables or print errors.
-#
-# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
-# only at the first occurence in configure.ac, so if the first place
-# it's called might be skipped (such as if it is within an "if", you
-# have to call PKG_CHECK_EXISTS manually
-# --------------------------------------------------------------
+])dnl PKG_PROG_PKG_CONFIG
+
+dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------------------------------
+dnl Since: 0.18
+dnl
+dnl Check to see whether a particular set of modules exists. Similar to
+dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
+dnl
+dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+dnl only at the first occurence in configure.ac, so if the first place
+dnl it's called might be skipped (such as if it is within an "if", you
+dnl have to call PKG_CHECK_EXISTS manually
AC_DEFUN([PKG_CHECK_EXISTS],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
if test -n "$PKG_CONFIG" && \
@@ -137,8 +169,10 @@ m4_ifvaln([$3], [else
$3])dnl
fi])
-# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
-# ---------------------------------------------
+dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+dnl ---------------------------------------------
+dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
+dnl pkg_failed based on the result.
m4_define([_PKG_CONFIG],
[if test -n "$$1"; then
pkg_cv_[]$1="$$1"
@@ -150,10 +184,11 @@ m4_define([_PKG_CONFIG],
else
pkg_failed=untried
fi[]dnl
-])# _PKG_CONFIG
+])dnl _PKG_CONFIG
-# _PKG_SHORT_ERRORS_SUPPORTED
-# -----------------------------
+dnl _PKG_SHORT_ERRORS_SUPPORTED
+dnl ---------------------------
+dnl Internal check to see if pkg-config supports short errors.
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
@@ -161,19 +196,17 @@ if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
else
_pkg_short_errors_supported=no
fi[]dnl
-])# _PKG_SHORT_ERRORS_SUPPORTED
+])dnl _PKG_SHORT_ERRORS_SUPPORTED
-# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
-# [ACTION-IF-NOT-FOUND])
-#
-#
-# Note that if there is a possibility the first call to
-# PKG_CHECK_MODULES might not happen, you should be sure to include an
-# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
-#
-#
-# --------------------------------------------------------------
+dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl [ACTION-IF-NOT-FOUND])
+dnl --------------------------------------------------------------
+dnl Since: 0.4.0
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
+dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
AC_DEFUN([PKG_CHECK_MODULES],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
@@ -227,16 +260,40 @@ else
AC_MSG_RESULT([yes])
$3
fi[]dnl
-])# PKG_CHECK_MODULES
-
-
-# PKG_INSTALLDIR(DIRECTORY)
-# -------------------------
-# Substitutes the variable pkgconfigdir as the location where a module
-# should install pkg-config .pc files. By default the directory is
-# $libdir/pkgconfig, but the default can be changed by passing
-# DIRECTORY. The user can override through the --with-pkgconfigdir
-# parameter.
+])dnl PKG_CHECK_MODULES
+
+
+dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl [ACTION-IF-NOT-FOUND])
+dnl ---------------------------------------------------------------------
+dnl Since: 0.29
+dnl
+dnl Checks for existence of MODULES and gathers its build flags with
+dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
+dnl and VARIABLE-PREFIX_LIBS from --libs.
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
+dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
+dnl configure.ac.
+AC_DEFUN([PKG_CHECK_MODULES_STATIC],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+_save_PKG_CONFIG=$PKG_CONFIG
+PKG_CONFIG="$PKG_CONFIG --static"
+PKG_CHECK_MODULES($@)
+PKG_CONFIG=$_save_PKG_CONFIG[]dnl
+])dnl PKG_CHECK_MODULES_STATIC
+
+
+dnl PKG_INSTALLDIR([DIRECTORY])
+dnl -------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable pkgconfigdir as the location where a module
+dnl should install pkg-config .pc files. By default the directory is
+dnl $libdir/pkgconfig, but the default can be changed by passing
+dnl DIRECTORY. The user can override through the --with-pkgconfigdir
+dnl parameter.
AC_DEFUN([PKG_INSTALLDIR],
[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
m4_pushdef([pkg_description],
@@ -247,16 +304,18 @@ AC_ARG_WITH([pkgconfigdir],
AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
m4_popdef([pkg_default])
m4_popdef([pkg_description])
-]) dnl PKG_INSTALLDIR
-
-
-# PKG_NOARCH_INSTALLDIR(DIRECTORY)
-# -------------------------
-# Substitutes the variable noarch_pkgconfigdir as the location where a
-# module should install arch-independent pkg-config .pc files. By
-# default the directory is $datadir/pkgconfig, but the default can be
-# changed by passing DIRECTORY. The user can override through the
-# --with-noarch-pkgconfigdir parameter.
+])dnl PKG_INSTALLDIR
+
+
+dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
+dnl --------------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable noarch_pkgconfigdir as the location where a
+dnl module should install arch-independent pkg-config .pc files. By
+dnl default the directory is $datadir/pkgconfig, but the default can be
+dnl changed by passing DIRECTORY. The user can override through the
+dnl --with-noarch-pkgconfigdir parameter.
AC_DEFUN([PKG_NOARCH_INSTALLDIR],
[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
m4_pushdef([pkg_description],
@@ -267,13 +326,15 @@ AC_ARG_WITH([noarch-pkgconfigdir],
AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
m4_popdef([pkg_default])
m4_popdef([pkg_description])
-]) dnl PKG_NOARCH_INSTALLDIR
+])dnl PKG_NOARCH_INSTALLDIR
-# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
-# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-# -------------------------------------------
-# Retrieves the value of the pkg-config variable for the given module.
+dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------
+dnl Since: 0.28
+dnl
+dnl Retrieves the value of the pkg-config variable for the given module.
AC_DEFUN([PKG_CHECK_VAR],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
@@ -282,7 +343,7 @@ _PKG_CONFIG([$1], [variable="][$3]["], [$2])
AS_VAR_COPY([$1], [pkg_cv_][$1])
AS_VAR_IF([$1], [""], [$5], [$4])dnl
-])# PKG_CHECK_VAR
+])dnl PKG_CHECK_VAR
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
#
@@ -536,5 +597,4 @@ AC_DEFUN([AM_RUN_LOG],
echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
(exit $ac_status); }])
-
m4_include([acinclude.m4])
diff --git a/configure b/configure
index 5409f68..7f41249 100755
--- a/configure
+++ b/configure
@@ -886,6 +886,7 @@ infodir
docdir
oldincludedir
includedir
+runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -1101,6 +1102,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE}'
@@ -1353,6 +1355,15 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
+ -runstatedir | --runstatedir | --runstatedi | --runstated \
+ | --runstate | --runstat | --runsta | --runst | --runs \
+ | --run | --ru | --r)
+ ac_prev=runstatedir ;;
+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+ | --run=* | --ru=* | --r=*)
+ runstatedir=$ac_optarg ;;
+
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1490,7 +1501,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir
+ libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1643,6 +1654,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -12967,7 +12979,7 @@ if ${am_cv_pathless_PYTHON+:} false; then :
$as_echo_n "(cached) " >&6
else
- for am_cv_pathless_PYTHON in python python2 python3 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do
+ for am_cv_pathless_PYTHON in python python2 python3 python3.3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do
test "$am_cv_pathless_PYTHON" = none && break
prog="import sys
# split strings by '.' and convert to numeric. Append some zeros
@@ -13535,7 +13547,7 @@ if ${am_cv_pathless_PYTHON+:} false; then :
$as_echo_n "(cached) " >&6
else
- for am_cv_pathless_PYTHON in python python2 python3 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do
+ for am_cv_pathless_PYTHON in python python2 python3 python3.3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do
test "$am_cv_pathless_PYTHON" = none && break
prog="import sys
# split strings by '.' and convert to numeric. Append some zeros
diff --git a/include/configure.h.in b/include/configure.h.in
index be2f660..a4c93d6 100644
--- a/include/configure.h.in
+++ b/include/configure.h.in
@@ -347,9 +347,6 @@
/* Define to 1 if the system has the type `ptrdiff_t'. */
#undef HAVE_PTRDIFF_T
-/* Define to 1 if the compiler has the `__builtin_clz` builtin. */
-#undef HAVE___BUILTIN_CLZ
-
/* Define to 1 if you have the <readline/history.h> header file. */
#undef HAVE_READLINE_HISTORY_H
@@ -478,9 +475,16 @@
/* Define to 1 if you have the `strtoull' function. */
#undef HAVE_STRTOULL
+/* Define to 1 if `st_blocks' is a member of `struct stat'. */
+#undef HAVE_STRUCT_STAT_ST_BLOCKS
+
/* Define to 1 if `st_rdev' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_RDEV
+/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use
+ `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */
+#undef HAVE_ST_BLOCKS
+
/* Define to 1 if you have the <syslog.h> header file. */
#undef HAVE_SYSLOG_H
@@ -552,6 +556,9 @@
/* Define to 1 if you have the <sys/utsname.h> header file. */
#undef HAVE_SYS_UTSNAME_H
+/* Define to 1 if you have the <sys/vfs.h> header file. */
+#undef HAVE_SYS_VFS_H
+
/* Define to 1 if you have the <sys/wait.h> header file. */
#undef HAVE_SYS_WAIT_H
@@ -591,6 +598,9 @@
/* Define to 1 if the system has the type `_Bool'. */
#undef HAVE__BOOL
+/* Define to 1 if the system has the `__builtin_clz' built-in function */
+#undef HAVE___BUILTIN_CLZ
+
/* Internalization package */
#undef INTL_PACKAGE
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 1fdaca8..bd68edc 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -55,6 +55,7 @@ SOURCES =\
config/config.c \
datastruct/btree.c \
datastruct/str_list.c \
+ device/bcache.c \
device/dev-cache.c \
device/dev-ext.c \
device/dev-io.c \
diff --git a/lib/device/bcache.c b/lib/device/bcache.c
index 1be626c..3b8cf78 100644
--- a/lib/device/bcache.c
+++ b/lib/device/bcache.c
@@ -1,3 +1,17 @@
+/*
+ * 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 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
+ */
+
#define _GNU_SOURCE
#include <errno.h>
@@ -22,6 +36,11 @@
//----------------------------------------------------------------
+static void log_sys_warn(const char *syscall)
+{
+ log_warn("%s failed: %s", syscall, strerror(errno));
+}
+
// Assumes the list is not empty.
static inline struct dm_list *_list_pop(struct dm_list *head)
{
@@ -49,14 +68,14 @@ struct cb_set {
static struct cb_set *_cb_set_create(unsigned nr)
{
int i;
- struct cb_set *cbs = malloc(sizeof(*cbs));
+ struct cb_set *cbs = dm_malloc(sizeof(*cbs));
if (!cbs)
return NULL;
- cbs->vec = malloc(nr * sizeof(*cbs->vec));
+ cbs->vec = dm_malloc(nr * sizeof(*cbs->vec));
if (!cbs->vec) {
- free(cbs);
+ dm_free(cbs);
return NULL;
}
@@ -69,17 +88,18 @@ static struct cb_set *_cb_set_create(unsigned nr)
return cbs;
}
-static bool _cb_set_destroy(struct cb_set *cbs)
+static void _cb_set_destroy(struct cb_set *cbs)
{
+ // We know this is always called after a wait_all. So there should
+ // never be in flight IO.
if (!dm_list_empty(&cbs->allocated)) {
- // FIXME: I think we should propogate this up.
+ // bail out
log_error("async io still in flight");
- return false;
+ return;
}
- free(cbs->vec);
- free(cbs);
- return 0;
+ dm_free(cbs->vec);
+ dm_free(cbs);
}
static struct control_block *_cb_alloc(struct cb_set *cbs, void *context)
@@ -123,7 +143,7 @@ struct io_engine {
static struct io_engine *_engine_create(unsigned max_io)
{
int r;
- struct io_engine *e = malloc(sizeof(*e));
+ struct io_engine *e = dm_malloc(sizeof(*e));
if (!e)
return NULL;
@@ -138,7 +158,7 @@ static struct io_engine *_engine_create(unsigned max_io)
e->cbs = _cb_set_create(max_io);
if (!e->cbs) {
log_warn("couldn't create control block set");
- free(e);
+ dm_free(e);
return NULL;
}
@@ -149,7 +169,7 @@ static void _engine_destroy(struct io_engine *e)
{
_cb_set_destroy(e->cbs);
io_destroy(e->aio_context);
- free(e);
+ dm_free(e);
}
static bool _engine_issue(struct io_engine *e, int fd, enum dir d,
@@ -160,13 +180,13 @@ static bool _engine_issue(struct io_engine *e, int fd, enum dir d,
struct control_block *cb;
if (((uint64_t) data) & (PAGE_SIZE - 1)) {
- log_err("misaligned data buffer");
+ log_warn("misaligned data buffer");
return false;
}
cb = _cb_alloc(e->cbs, context);
if (!cb) {
- log_err("couldn't allocate control block");
+ log_warn("couldn't allocate control block");
return false;
}
@@ -181,7 +201,7 @@ static bool _engine_issue(struct io_engine *e, int fd, enum dir d,
cb_array[0] = &cb->cb;
r = io_submit(e->aio_context, 1, cb_array);
if (r < 0) {
- log_sys_error("io_submit", "");
+ log_sys_warn("io_submit");
_cb_free(e->cbs, cb);
return false;
}
@@ -201,7 +221,7 @@ static bool _engine_wait(struct io_engine *e, complete_fn fn)
memset(&event, 0, sizeof(event));
r = io_getevents(e->aio_context, 1, MAX_IO, event, NULL);
if (r < 0) {
- log_sys_error("io_getevents", "");
+ log_sys_warn("io_getevents");
return false;
}
@@ -217,7 +237,7 @@ static bool _engine_wait(struct io_engine *e, complete_fn fn)
fn(cb->context, (int) ev->res);
else {
- log_err("short io");
+ log_warn("short io");
fn(cb->context, -ENODATA);
}
@@ -341,7 +361,7 @@ static void _hash_insert(struct block *b)
dm_list_add_h(b->cache->buckets + h, &b->hash);
}
-static void _hash_remove(struct block *b)
+static inline void _hash_remove(struct block *b)
{
dm_list_del(&b->hash);
}
@@ -363,30 +383,30 @@ static unsigned _calc_nr_buckets(unsigned nr_blocks)
return r;
}
-static int _hash_table_init(struct bcache *cache, unsigned nr_entries)
+static bool _hash_table_init(struct bcache *cache, unsigned nr_entries)
{
unsigned i;
cache->nr_buckets = _calc_nr_buckets(nr_entries);
cache->hash_mask = cache->nr_buckets - 1;
- cache->buckets = malloc(cache->nr_buckets * sizeof(*cache->buckets));
+ cache->buckets = dm_malloc(cache->nr_buckets * sizeof(*cache->buckets));
if (!cache->buckets)
- return -ENOMEM;
+ return false;
for (i = 0; i < cache->nr_buckets; i++)
dm_list_init(cache->buckets + i);
- return 0;
+ return true;
}
static void _hash_table_exit(struct bcache *cache)
{
- free(cache->buckets);
+ dm_free(cache->buckets);
}
//----------------------------------------------------------------
-static int _init_free_list(struct bcache *cache, unsigned count)
+static bool _init_free_list(struct bcache *cache, unsigned count)
{
unsigned i;
size_t block_size = cache->block_sectors << SECTOR_SHIFT;
@@ -395,13 +415,13 @@ static int _init_free_list(struct bcache *cache, unsigned count)
/* Allocate the data for each block. We page align the data. */
if (!data)
- return -ENOMEM;
+ return false;
cache->raw_data = data;
- cache->raw_blocks = malloc(count * sizeof(*cache->raw_blocks));
+ cache->raw_blocks = dm_malloc(count * sizeof(*cache->raw_blocks));
if (!cache->raw_blocks)
- free(cache->raw_data);
+ dm_free(cache->raw_data);
for (i = 0; i < count; i++) {
struct block *b = cache->raw_blocks + i;
@@ -410,13 +430,13 @@ static int _init_free_list(struct bcache *cache, unsigned count)
dm_list_add(&cache->free, &b->list);
}
- return 0;
+ return true;
}
static void _exit_free_list(struct bcache *cache)
{
- free(cache->raw_data);
- free(cache->raw_blocks);
+ dm_free(cache->raw_data);
+ dm_free(cache->raw_blocks);
}
static struct block *_alloc_block(struct bcache *cache)
@@ -519,7 +539,7 @@ static void _complete_io(void *context, int err)
}
}
-static int _wait_io(struct bcache *cache)
+static bool _wait_io(struct bcache *cache)
{
return _engine_wait(cache->engine, _complete_io);
}
@@ -646,7 +666,7 @@ static struct block *_lookup_or_read_block(struct bcache *cache,
// FIXME: this is insufficient. We need to also catch a read
// lock of a write locked block. Ref count needs to distinguish.
if (b->ref_count && (flags & (GF_DIRTY | GF_ZERO))) {
- log_err("concurrent write lock attempted");
+ log_warn("concurrent write lock attempted");
return NULL;
}
@@ -706,10 +726,9 @@ static void _preemptive_writeback(struct bcache *cache)
*--------------------------------------------------------------*/
struct bcache *bcache_create(sector_t block_sectors, unsigned nr_cache_blocks)
{
- int r;
struct bcache *cache;
- cache = malloc(sizeof(*cache));
+ cache = dm_malloc(sizeof(*cache));
if (!cache)
return NULL;
@@ -718,7 +737,7 @@ struct bcache *bcache_create(sector_t block_sectors, unsigned nr_cache_blocks)
cache->engine = _engine_create(nr_cache_blocks < 1024u ? nr_cache_blocks : 1024u);
if (!cache->engine) {
- free(cache);
+ dm_free(cache);
return NULL;
}
@@ -732,9 +751,10 @@ struct bcache *bcache_create(sector_t block_sectors, unsigned nr_cache_blocks)
dm_list_init(&cache->clean);
dm_list_init(&cache->io_pending);
- if (_hash_table_init(cache, nr_cache_blocks)) {
+ if (!_hash_table_init(cache, nr_cache_blocks)) {
_engine_destroy(cache->engine);
- free(cache);
+ dm_free(cache);
+ return NULL;
}
cache->read_hits = 0;
@@ -744,11 +764,11 @@ struct bcache *bcache_create(sector_t block_sectors, unsigned nr_cache_blocks)
cache->write_misses = 0;
cache->prefetches = 0;
- r = _init_free_list(cache, nr_cache_blocks);
- if (r) {
+ if (!_init_free_list(cache, nr_cache_blocks)) {
_engine_destroy(cache->engine);
_hash_table_exit(cache);
- free(cache);
+ dm_free(cache);
+ return NULL;
}
return cache;
@@ -757,14 +777,14 @@ struct bcache *bcache_create(sector_t block_sectors, unsigned nr_cache_blocks)
void bcache_destroy(struct bcache *cache)
{
if (cache->nr_locked)
- log_warn("some blocks are still locked\n");
+ log_warn("some blocks are still locked");
bcache_flush(cache);
_wait_all(cache);
_exit_free_list(cache);
_hash_table_exit(cache);
_engine_destroy(cache->engine);
- free(cache);
+ dm_free(cache);
}
void bcache_prefetch(struct bcache *cache, int fd, block_address index)
@@ -794,14 +814,14 @@ bool bcache_get(struct bcache *cache, int fd, block_address index,
}
*result = NULL;
- log_err("couldn't get block");
+ log_warn("couldn't get block");
return false;
}
void bcache_put(struct block *b)
{
if (!b->ref_count) {
- log_err("ref count on bcache block already zero");
+ log_warn("ref count on bcache block already zero");
return;
}
diff --git a/lib/device/bcache.h b/lib/device/bcache.h
index 1f4262e..3227744 100644
--- a/lib/device/bcache.h
+++ b/lib/device/bcache.h
@@ -1,3 +1,17 @@
+/*
+ * 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 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 BCACHE_H
#define BCACHE_H
5 years, 12 months
master - [io paths] Unpick agk's aio stuff
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=00f1b208a1bf44665ec...
Commit: 00f1b208a1bf44665ec97a791355b1fcf525a3a7
Parent: d51429254f4e9b17083af0c554aa7045e5ec08bb
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Fri Apr 20 10:43:50 2018 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 20 11:03:58 2018 -0500
[io paths] Unpick agk's aio stuff
---
conf/example.conf.in | 16 -
configure.in | 22 --
doc/aio_design.txt | 215 --------------
include/configure.h.in | 3 -
lib/cache/lvmcache.c | 51 +---
lib/cache/lvmcache.h | 2 +-
lib/cache/lvmetad.c | 2 +-
lib/commands/toolcontext.c | 16 +-
lib/commands/toolcontext.h | 1 -
lib/config/config.c | 154 ++++-------
lib/config/config.h | 8 +-
lib/config/config_settings.h | 10 -
lib/config/defaults.h | 3 -
lib/device/dev-cache.c | 12 -
lib/device/dev-cache.h | 8 +-
lib/device/dev-io.c | 600 ++++++---------------------------------
lib/device/dev-luks.c | 2 +-
lib/device/dev-md.c | 2 +-
lib/device/dev-swap.c | 3 +-
lib/device/dev-type.c | 2 +-
lib/device/device.h | 102 ++-----
lib/filters/filter-composite.c | 4 +-
lib/filters/filter-persistent.c | 8 +-
lib/filters/filter.h | 2 +-
lib/format1/disk-rep.c | 10 +-
lib/format1/format1.c | 2 +-
lib/format1/lvm1-label.c | 19 +-
lib/format_pool/disk_rep.c | 2 +-
lib/format_pool/format_pool.c | 2 +-
lib/format_pool/pool_label.c | 13 +-
lib/format_text/archive.c | 4 +-
lib/format_text/archiver.c | 2 +-
lib/format_text/export.c | 21 +-
lib/format_text/format-text.c | 541 ++++++++++-------------------------
lib/format_text/import-export.h | 8 +-
lib/format_text/import.c | 233 +++++-----------
lib/format_text/layout.h | 12 +-
lib/format_text/text_label.c | 197 +++----------
lib/label/label.c | 173 ++++--------
lib/label/label.h | 6 +-
lib/metadata/metadata-liblvm.c | 3 +-
lib/metadata/metadata.c | 8 +-
lib/metadata/metadata.h | 5 +-
make.tmpl.in | 3 +-
tools/command.c | 11 +-
tools/toollib.c | 1 -
46 files changed, 565 insertions(+), 1959 deletions(-)
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 3b0638f..aab274d 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -59,22 +59,6 @@ devices {
# This configuration option is advanced.
scan = [ "/dev" ]
- # Configuration option devices/use_aio.
- # Use linux asynchronous I/O for parallel device access where possible.
- # This configuration option has an automatic default value.
- # use_aio = 1
-
- # Configuration option devices/aio_max.
- # Maximum number of asynchronous I/Os to issue concurrently.
- # This configuration option has an automatic default value.
- # aio_max = 128
-
- # Configuration option devices/aio_memory.
- # Approximate maximum total amount of memory (in MB) used
- # for asynchronous I/O buffers.
- # This configuration option has an automatic default value.
- # aio_memory = 10
-
# Configuration option devices/obtain_device_list_from_udev.
# Obtain the list of available devices from udev.
# This avoids opening or using any inapplicable non-block devices or
diff --git a/configure.in b/configure.in
index 605b6b2..b8e1623 100644
--- a/configure.in
+++ b/configure.in
@@ -39,7 +39,6 @@ case "$host_os" in
LDDEPS="$LDDEPS .export.sym"
LIB_SUFFIX=so
DEVMAPPER=yes
- AIO=yes
BUILD_LVMETAD=no
BUILD_LVMPOLLD=no
LOCKDSANLOCK=no
@@ -59,7 +58,6 @@ case "$host_os" in
CLDNOWHOLEARCHIVE=
LIB_SUFFIX=dylib
DEVMAPPER=yes
- AIO=no
ODIRECT=no
DM_IOCTLS=no
SELINUX=no
@@ -1125,24 +1123,6 @@ if test "$DEVMAPPER" = yes; then
fi
################################################################################
-dnl -- Disable aio
-AC_MSG_CHECKING(whether to use asynchronous I/O)
-AC_ARG_ENABLE(aio,
- AC_HELP_STRING([--disable-aio],
- [disable asynchronous I/O]),
- AIO=$enableval)
-AC_MSG_RESULT($AIO)
-
-if test "$AIO" = yes; then
- AC_CHECK_LIB(aio, io_setup,
- [AC_DEFINE([AIO_SUPPORT], 1, [Define to 1 if aio is available.])
- AIO_LIBS="-laio"
- AIO_SUPPORT=yes],
- [AIO_LIBS=
- AIO_SUPPORT=no ])
-fi
-
-################################################################################
dnl -- Build lvmetad
AC_MSG_CHECKING(whether to build LVMetaD)
AC_ARG_ENABLE(lvmetad,
@@ -2081,11 +2061,9 @@ AC_SUBST(DEFAULT_USE_LVMETAD)
AC_SUBST(DEFAULT_USE_LVMPOLLD)
AC_SUBST(DEFAULT_USE_LVMLOCKD)
AC_SUBST(DEVMAPPER)
-AC_SUBST(AIO)
AC_SUBST(DLM_CFLAGS)
AC_SUBST(DLM_LIBS)
AC_SUBST(DL_LIBS)
-AC_SUBST(AIO_LIBS)
AC_SUBST(DMEVENTD_PATH)
AC_SUBST(DM_LIB_PATCHLEVEL)
AC_SUBST(ELDFLAGS)
diff --git a/doc/aio_design.txt b/doc/aio_design.txt
deleted file mode 100644
index c6eb443..0000000
--- a/doc/aio_design.txt
+++ /dev/null
@@ -1,215 +0,0 @@
-Introducing asynchronous I/O to LVM
-===================================
-
-Issuing I/O asynchronously means instructing the kernel to perform specific
-I/O and return immediately without waiting for it to complete. The data
-is collected from the kernel later.
-
-Advantages
-----------
-
-A1. While waiting for the I/O to happen, the program could perform other
-operations.
-
-A2. When LVM is searching for its Physical Volumes, it issues a small amount of
-I/O to a large number of disks. If this was issued in parallel the overall
-runtime might be shorter while there should be little effect on the cpu time.
-
-A3. If more than one timeout occurs when accessing any devices, these can be
-taken in parallel, again reducing the runtime. This applies globally,
-not just while the code is searching for Physical Volumes, so reading,
-writing and committing the metadata may occasionally benefit too to some
-extent and there are probably maintenance advantages in using the same
-method of I/O throughout the main body of the code.
-
-A4. By introducing a simple callback function mechanism, the conversion can be
-performed largely incrementally by first refactoring and continuing to
-use synchronous I/O with the callbacks performed immediately. This allows the
-callbacks to be introduced without changing the running sequence of the code
-initially. Future projects could refactor some of the calling sites to
-simplify the code structure and even eliminate some of the nesting.
-This allows each part of what might ultimately amount to a large change to be
-introduced and tested independently.
-
-
-Disadvantages
--------------
-
-D1. The resulting code may be more complex with more failure modes to
-handle. Mitigate by thorough auditing and testing, rolling out
-gradually, and offering a simple switch to revert to the old behaviour.
-
-D2. The linux asynchronous I/O implementation is less mature than
-its synchronous I/O implementation and might show up problems that
-depend on the version of the kernel or library used. Fixes or
-workarounds for some of these might require kernel changes. For
-example, there are suggestions that despite being supposedly async,
-there are still cases where system calls can block. There might be
-resource dependencies on other processes running on the system that make
-it unsuitable for use while any devices are suspended. Mitigation
-as for D1.
-
-D3. The error handling within callbacks becomes more complicated.
-However we know that existing call paths can already sometimes discard
-errors, sometimes deliberately, sometimes not, so this aspect is in need
-of a complete review anyway and the new approach will make the error
-handling more transparent. Aim initially for overall behaviour that is
-no worse than that of the existing code, then work on improving it
-later.
-
-D4. The work will take a few weeks to code and test. This leads to a
-significant opportunity cost when compared against other enhancements
-that could be achieved in that time. However, the proof-of-concept work
-performed while writing this design has satisfied me that the work could
-proceed and be committed incrementally as a background task.
-
-
-Observations regarding LVM's I/O Architecture
----------------------------------------------
-
-H1. All device, metadata and config file I/O is constrained to pass through a
-single route in lib/device.
-
-H2. The first step of the analysis was to instrument this code path with
-log_debug messages. I/O is split into the following categories:
-
- "dev signatures",
- "PV labels",
- "VG metadata header",
- "VG metadata content",
- "extra VG metadata header",
- "extra VG metadata content",
- "LVM1 metadata",
- "pool metadata",
- "LV content",
- "logging",
-
-H3. A bounce buffer is used for most I/O.
-
-H4. Most callers finish using the supplied data before any further I/O is
-issued. The few that don't could be converted trivially to do so.
-
-H5. There is one stream of I/O per metadata area on each device.
-
-H6. Some reads fall at offsets close to immediately preceding reads, so it's
-possible to avoid these by caching one "block" per metadata area I/O stream.
-
-H7. Simple analysis suggests a minimum aligned read size of 8k would deliver
-immediate gains from this caching. A larger size might perform worse because
-almost all the time the extra data read would not be used, but this can be
-re-examined and tuned after the code is in place.
-
-
-Proposal
---------
-
-P1. Retain the "single I/O path" but offer an asynchronous option.
-
-P2. Eliminate the bounce buffer in most cases by improving alignment.
-
-P3. Reduce the number of reads by always reading a minimum of an aligned
-8k block.
-
-P4. Eliminate repeated reads by caching the last block read and changing
-the lib/device interface to return a pointer to read-only data within
-this block.
-
-P5. Only perform these interface changes for code on the critical path
-for now by converting other code sites to use wrappers around the new
-interface.
-
-P6. Treat asynchronous I/O as the interface of choice and optimise only
-for this case.
-
-P7. Convert the callers on the critical path to pass callback functions
-to the device layer. These functions will be called later with the
-read-only data, a context pointer and a success/failure indicator.
-Where an existing function performs a sequence of I/O, this has the
-advantage of breaking up the large function into smaller ones and
-wrapping the parameters used into structures. While this might look
-rather messy and ad-hoc in the short-term, it's a first step towards
-breaking up confusingly long functions into component parts and wrapping
-the existing long parameter lists into more appropriate structures and
-refactoring these parts of the code.
-
-P8. Limit the resources used by the asynchronous I/O by using two
-tunable parameters, one limiting the number of outstanding I/Os issued
-and another limiting the total amount of memory used.
-
-P9. Provide a fallback option if asynchronous I/O is unavailable by
-sharing the code paths but issuing the I/O synchronously and calling the
-callback immediately.
-
-P10. Only allocate the buffer for the I/O at the point where the I/O is
-about to be issued.
-
-P11. If the thresholds are exceeded, add the request to a simple queue,
-and process it later after some I/O has completed.
-
-
-Future work
------------
-F1. Perform a complete review of the error tracking so that device
-failures are handled and reported more cleanly, extending the existing
-basic error counting mechanism.
-
-F2. Consider whether some of the nested callbacks can be eliminated,
-which would allow for additional simplifications.
-
-F3. Adjust the contents of the adhoc context structs into more logical
-arrangements and use them more widely.
-
-F4. Perform wider refactoring of these areas of code.
-
-
-Testing considerations
-----------------------
-T1. The changes touch code on the device path, so a thorough re-test of
-the device layer is required. The new code needs a full audit down
-through the library layer into the kernel to check that all the error
-conditions that are currently implemented (such as EAGAIN) are handled
-sensibly. (LVM's I/O layer needs to remain as solid as we can make it.)
-
-T2. The current test suite provides a reasonably broad range of coverage
-of this area but is far from comprehensive.
-
-
-Acceptance criteria
--------------------
-A1. The current test suite should pass to the same extent as before the
-changes.
-
-A2. When all debugging and logging is disabled, strace -c must show
-improvements e.g. the expected fewer number of reads.
-
-A3. Running a range of commands under valgrind must not reveal any
-new leaks due to the changes.
-
-A4. All new coverity reports from the change must be addressed.
-
-A5. CPU time should be similar to that before, as the same work
-is being done overall, just in a different order.
-
-A6. Tests need to show improved behaviour in targetted areas. For example,
-if several devices are slow and time out, the delays should occur
-in parallel and the elapsed time should be less than before.
-
-
-Release considerations
-----------------------
-R1. Async I/O should be widely available and largely reliable on linux
-nowadays (even though parts of its interface and implementation remain a
-matter of controversy) so we should try to make its use the default
-whereever it is supported. If certain types of systems have problems we
-should try to detect those cases and disable it automatically there.
-
-R2. Because the implications of an unexpected problem in the new code
-could be severe for the people affected, the roll out needs to be gentle
-without a deadline to allow us plenty of time to gain confidence in the
-new code. Our own testing will only be able to cover a tiny fraction of
-the different setups our users have, so we need to look out for problems
-caused by this proactively and encourage people to test it on their own
-systems and report back. It must go into the tree near the start of a
-release cycle rather than at the end to provide time for our confidence
-in it to grow.
-
diff --git a/include/configure.h.in b/include/configure.h.in
index a491807..be2f660 100644
--- a/include/configure.h.in
+++ b/include/configure.h.in
@@ -1,8 +1,5 @@
/* include/configure.h.in. Generated from configure.in by autoheader. */
-/* Define to 1 if aio is available. */
-#undef AIO_SUPPORT
-
/* Define to 1 to use libblkid detection of signatures when wiping. */
#undef BLKID_WIPING_SUPPORT
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 5ff2827..fb81002 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -141,8 +141,6 @@ void lvmcache_seed_infos_from_lvmetad(struct cmd_context *cmd)
/* Volume Group metadata cache functions */
static void _free_cached_vgmetadata(struct lvmcache_vginfo *vginfo)
{
- struct lvmcache_info *info;
-
if (!vginfo || !vginfo->vgmetadata)
return;
@@ -156,10 +154,6 @@ static void _free_cached_vgmetadata(struct lvmcache_vginfo *vginfo)
vginfo->cft = NULL;
}
- /* Invalidate any cached device buffers */
- dm_list_iterate_items(info, &vginfo->infos)
- devbufs_release(info->dev);
-
log_debug_cache("lvmcache: VG %s wiped.", vginfo->vgname);
release_vg(vginfo->cached_vg);
@@ -548,6 +542,7 @@ const struct format_type *lvmcache_fmt_from_vgname(struct cmd_context *cmd,
{
struct lvmcache_vginfo *vginfo;
struct lvmcache_info *info;
+ struct label *label;
struct dm_list *devh, *tmp;
struct dm_list devs;
struct device_list *devl;
@@ -592,7 +587,7 @@ const struct format_type *lvmcache_fmt_from_vgname(struct cmd_context *cmd,
dm_list_iterate_safe(devh, tmp, &devs) {
devl = dm_list_item(devh, struct device_list);
- (void) label_read(devl->dev, NULL, UINT64_C(0));
+ (void) label_read(devl->dev, &label, UINT64_C(0));
dm_list_del(&devl->list);
dm_free(devl);
}
@@ -773,8 +768,10 @@ char *lvmcache_vgname_from_pvid(struct cmd_context *cmd, const char *pvid)
static void _rescan_entry(struct lvmcache_info *info)
{
+ struct label *label;
+
if (info->status & CACHE_INVALID)
- (void) label_read(info->dev, NULL, UINT64_C(0));
+ (void) label_read(info->dev, &label, UINT64_C(0));
}
static int _scan_invalid(void)
@@ -1096,31 +1093,17 @@ next:
goto next;
}
-/* Track the number of outstanding label reads */
-/* FIXME Switch to struct and also track failed */
-static void _process_label_data(int failed, unsigned ioflags, void *context, const void *data)
-{
- int *nr_labels_outstanding = context;
-
- if (!*nr_labels_outstanding) {
- log_error(INTERNAL_ERROR "_process_label_data called too many times");
- return;
- }
-
- (*nr_labels_outstanding)--;
-}
-
int lvmcache_label_scan(struct cmd_context *cmd)
{
struct dm_list del_cache_devs;
struct dm_list add_cache_devs;
struct lvmcache_info *info;
struct device_list *devl;
+ struct label *label;
struct dev_iter *iter;
struct device *dev;
struct format_type *fmt;
int dev_count = 0;
- int nr_labels_outstanding = 0;
int r = 0;
@@ -1159,22 +1142,13 @@ int lvmcache_label_scan(struct cmd_context *cmd)
_destroy_duplicate_device_list(&_found_duplicate_devs);
while ((dev = dev_iter_get(iter))) {
- log_debug_io("Scanning device %s", dev_name(dev));
- nr_labels_outstanding++;
- if (!label_read_callback(dev, UINT64_C(0), AIO_SUPPORTED_CODE_PATH, _process_label_data, &nr_labels_outstanding))
- nr_labels_outstanding--;
+ (void) label_read(dev, &label, UINT64_C(0));
dev_count++;
}
dev_iter_destroy(iter);
- while (nr_labels_outstanding) {
- log_very_verbose("Scanned %d device labels (%d outstanding)", dev_count, nr_labels_outstanding);
- if (!dev_async_getevents())
- return_0;
- }
-
- log_very_verbose("Scanned %d device labels (%d outstanding)", dev_count, nr_labels_outstanding);
+ log_very_verbose("Scanned %d device labels", dev_count);
/*
* _choose_preferred_devs() returns:
@@ -1208,7 +1182,7 @@ int lvmcache_label_scan(struct cmd_context *cmd)
dm_list_iterate_items(devl, &add_cache_devs) {
log_debug_cache("Rescan preferred device %s for lvmcache", dev_name(devl->dev));
- (void) label_read(devl->dev, NULL, UINT64_C(0));
+ (void) label_read(devl->dev, &label, UINT64_C(0));
}
dm_list_splice(&_unused_duplicate_devs, &del_cache_devs);
@@ -1228,7 +1202,7 @@ int lvmcache_label_scan(struct cmd_context *cmd)
*/
if (_force_label_scan && cmd->is_long_lived &&
cmd->dump_filter && cmd->full_filter && cmd->full_filter->dump &&
- !cmd->full_filter->dump(cmd->full_filter, cmd->mem, 0))
+ !cmd->full_filter->dump(cmd->full_filter, 0))
stack;
r = 1;
@@ -1529,6 +1503,7 @@ const char *lvmcache_pvid_from_devname(struct cmd_context *cmd,
const char *devname)
{
struct device *dev;
+ struct label *label;
if (!(dev = dev_cache_get(devname, cmd->filter))) {
log_error("%s: Couldn't find device. Check your filters?",
@@ -1536,7 +1511,7 @@ const char *lvmcache_pvid_from_devname(struct cmd_context *cmd,
return NULL;
}
- if (!(label_read(dev, NULL, UINT64_C(0))))
+ if (!(label_read(dev, &label, UINT64_C(0))))
return NULL;
return dev->pvid;
@@ -2001,7 +1976,7 @@ int lvmcache_add_orphan_vginfo(const char *vgname, struct format_type *fmt)
return _lvmcache_update_vgname(NULL, vgname, vgname, 0, "", fmt);
}
-int lvmcache_update_vgname_and_id(struct lvmcache_info *info, const struct lvmcache_vgsummary *vgsummary)
+int lvmcache_update_vgname_and_id(struct lvmcache_info *info, struct lvmcache_vgsummary *vgsummary)
{
const char *vgname = vgsummary->vgname;
const char *vgid = (char *)&vgsummary->vgid;
diff --git a/lib/cache/lvmcache.h b/lib/cache/lvmcache.h
index 3c76b78..847c208 100644
--- a/lib/cache/lvmcache.h
+++ b/lib/cache/lvmcache.h
@@ -85,7 +85,7 @@ void lvmcache_del(struct lvmcache_info *info);
/* Update things */
int lvmcache_update_vgname_and_id(struct lvmcache_info *info,
- const struct lvmcache_vgsummary *vgsummary);
+ struct lvmcache_vgsummary *vgsummary);
int lvmcache_update_vg(struct volume_group *vg, unsigned precommitted);
void lvmcache_lock_vgname(const char *vgname, int read_only);
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 589b48e..4b7410c 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -1771,7 +1771,7 @@ static int _lvmetad_pvscan_single(struct metadata_area *mda, void *baton)
struct volume_group *vg;
if (mda_is_ignored(mda) ||
- !(vg = mda->ops->vg_read(b->fid, "", mda, NULL, NULL, 1, 0)))
+ !(vg = mda->ops->vg_read(b->fid, "", mda, NULL, NULL, 1)))
return 1;
/* FIXME Also ensure contents match etc. */
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index b613b8f..c998495 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -636,16 +636,6 @@ static int _process_config(struct cmd_context *cmd)
*/
cmd->default_settings.udev_fallback = udev_disabled ? 1 : -1;
-#ifdef AIO_SUPPORT
- cmd->use_aio = find_config_tree_bool(cmd, devices_use_aio_CFG, NULL);
-#else
- cmd->use_aio = 0;
-#endif
- if (cmd->use_aio && !dev_async_setup(cmd))
- cmd->use_aio = 0;
-
- log_debug_io("%ssing asynchronous I/O.", cmd->use_aio ? "U" : "Not u");
-
init_retry_deactivation(find_config_tree_bool(cmd, activation_retry_deactivation_CFG, NULL));
init_activation_checks(find_config_tree_bool(cmd, activation_checks_CFG, NULL));
@@ -1298,7 +1288,7 @@ int init_filters(struct cmd_context *cmd, unsigned load_persistent_cache)
lvm_stat_ctim(&ts, &st);
cts = config_file_timestamp(cmd->cft);
if (timespeccmp(&ts, &cts, >) &&
- !persistent_filter_load(cmd->mem, cmd->filter, NULL))
+ !persistent_filter_load(cmd->filter, NULL))
log_verbose("Failed to load existing device cache from %s",
dev_cache);
}
@@ -2160,8 +2150,6 @@ int refresh_toolcontext(struct cmd_context *cmd)
cmd->lib_dir = NULL;
- label_init();
-
if (!_init_lvm_conf(cmd))
return_0;
@@ -2249,7 +2237,7 @@ void destroy_toolcontext(struct cmd_context *cmd)
int flags;
if (cmd->dump_filter && cmd->filter && cmd->filter->dump &&
- !cmd->filter->dump(cmd->filter, cmd->mem, 1))
+ !cmd->filter->dump(cmd->filter, 1))
stack;
archive_exit(cmd);
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 89d1088..f04afec 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -165,7 +165,6 @@ struct cmd_context {
unsigned vg_notify:1;
unsigned lv_notify:1;
unsigned pv_notify:1;
- unsigned use_aio:1;
unsigned activate_component:1; /* command activates component LV */
unsigned process_component_lvs:1; /* command processes also component LVs */
diff --git a/lib/config/config.c b/lib/config/config.c
index 97c5db8..8fca372 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2018 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -279,7 +279,7 @@ struct dm_config_tree *config_file_open_and_read(const char *config_file,
}
log_very_verbose("Loading config file: %s", config_file);
- if (!config_file_read(cmd->mem, cft)) {
+ if (!config_file_read(cft)) {
log_error("Failed to load config file %s", config_file);
goto bad;
}
@@ -489,102 +489,32 @@ int override_config_tree_from_profile(struct cmd_context *cmd,
return 0;
}
-struct process_config_file_params {
- 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 checksum_only;
- int no_dup_node_check;
- lvm_callback_fn_t config_file_read_fd_callback;
- void *config_file_read_fd_context;
- int ret;
-};
-
-static void _process_config_file_buffer(int failed, unsigned ioflags, void *context, const void *data)
-{
- struct process_config_file_params *pcfp = context;
- const char *fb = data, *fe;
-
- if (failed) {
- pcfp->ret = 0;
- goto_out;
- }
-
- if (pcfp->checksum_fn && pcfp->checksum !=
- (pcfp->checksum_fn(pcfp->checksum_fn(INITIAL_CRC, (const uint8_t *)fb, pcfp->size),
- (const uint8_t *)(fb + pcfp->size), pcfp->size2))) {
- log_error("%s: Checksum error at offset %" PRIu64, dev_name(pcfp->dev), (uint64_t) pcfp->offset);
- pcfp->ret = 0;
- goto out;
- }
-
- if (!pcfp->checksum_only) {
- fe = fb + pcfp->size + pcfp->size2;
- if (pcfp->no_dup_node_check) {
- if (!dm_config_parse_without_dup_node_check(pcfp->cft, fb, fe))
- pcfp->ret = 0;
- } else if (!dm_config_parse(pcfp->cft, fb, fe))
- pcfp->ret = 0;
- }
-
-out:
- if (pcfp->config_file_read_fd_callback)
- pcfp->config_file_read_fd_callback(!pcfp->ret, ioflags, pcfp->config_file_read_fd_context, NULL);
-}
-
/*
* When checksum_only is set, the checksum of buffer is only matched
* and function avoids parsing of mda into config tree which
* remains unmodified and should not be used.
*/
-int config_file_read_fd(struct dm_pool *mem, struct dm_config_tree *cft, struct device *dev, dev_io_reason_t reason,
+int config_file_read_fd(struct dm_config_tree *cft, struct device *dev, dev_io_reason_t reason,
off_t offset, size_t size, off_t offset2, size_t size2,
checksum_fn_t checksum_fn, uint32_t checksum,
- int checksum_only, int no_dup_node_check, unsigned ioflags,
- lvm_callback_fn_t config_file_read_fd_callback, void *config_file_read_fd_context)
+ int checksum_only, int no_dup_node_check)
{
- char *fb;
+ char *fb, *fe;
int r = 0;
- off_t mmap_offset = 0;
int use_mmap = 1;
- const char *buf = NULL;
- unsigned circular = size2 ? 1 : 0; /* Wrapped around end of disk metadata buffer? */
+ off_t mmap_offset = 0;
+ char *buf = NULL;
struct config_source *cs = dm_config_get_custom(cft);
- struct process_config_file_params *pcfp;
if (!_is_file_based_config_source(cs->type)) {
log_error(INTERNAL_ERROR "config_file_read_fd: expected file, special file "
"or profile config source, found %s config source.",
_config_source_names[cs->type]);
- goto bad;
- }
-
- if (!(pcfp = dm_pool_zalloc(mem, sizeof(*pcfp)))) {
- log_debug("config_file_read_fd: process_config_file_params struct allocation failed");
- goto bad;
+ return 0;
}
- pcfp->cft = cft;
- pcfp->dev = dev;
- pcfp->offset = offset;
- pcfp->size = size;
- pcfp->offset2 = offset2;
- pcfp->size2 = size2;
- pcfp->checksum_fn = checksum_fn;
- pcfp->checksum = checksum;
- pcfp->checksum_only = checksum_only;
- pcfp->no_dup_node_check = no_dup_node_check;
- pcfp->config_file_read_fd_callback = config_file_read_fd_callback;
- pcfp->config_file_read_fd_context = config_file_read_fd_context;
- pcfp->ret = 1;
-
/* Only use mmap with regular files */
- if (!(dev->flags & DEV_REGULAR) || circular)
+ if (!(dev->flags & DEV_REGULAR) || size2)
use_mmap = 0;
if (use_mmap) {
@@ -594,40 +524,56 @@ int config_file_read_fd(struct dm_pool *mem, struct dm_config_tree *cft, struct
MAP_PRIVATE, dev_fd(dev), offset - mmap_offset);
if (fb == (caddr_t) (-1)) {
log_sys_error("mmap", dev_name(dev));
- goto bad;
- }
- _process_config_file_buffer(0, ioflags, pcfp, fb + mmap_offset);
- r = pcfp->ret;
- /* unmap the file */
- if (munmap(fb, size + mmap_offset)) {
- log_sys_error("munmap", dev_name(dev));
- r = 0;
+ goto out;
}
+ fb = fb + mmap_offset;
} else {
- if (circular) {
- if (!(buf = dev_read_circular(dev, (uint64_t) offset, size, (uint64_t) offset2, size2, reason)))
+ if (!(buf = dm_malloc(size + size2))) {
+ log_error("Failed to allocate circular buffer.");
+ return 0;
+ }
+ if (!dev_read_circular(dev, (uint64_t) offset, size,
+ (uint64_t) offset2, size2, reason, buf)) {
+ goto out;
+ }
+ fb = buf;
+ }
+
+ if (checksum_fn && checksum !=
+ (checksum_fn(checksum_fn(INITIAL_CRC, (const uint8_t *)fb, size),
+ (const uint8_t *)(fb + size), size2))) {
+ log_error("%s: Checksum error at offset %" PRIu64, dev_name(dev), (uint64_t) offset);
+ goto out;
+ }
+
+ if (!checksum_only) {
+ fe = fb + size + size2;
+ if (no_dup_node_check) {
+ if (!dm_config_parse_without_dup_node_check(cft, fb, fe))
goto_out;
- _process_config_file_buffer(0, ioflags, pcfp, buf);
- dm_free((void *)buf);
} else {
- dev_read_callback(dev, (uint64_t) offset, size, reason, ioflags, _process_config_file_buffer, pcfp);
- if (config_file_read_fd_callback)
- return 1;
+ if (!dm_config_parse(cft, fb, fe))
+ goto_out;
}
- r = pcfp->ret;
}
-out:
- return r;
+ r = 1;
-bad:
- if (config_file_read_fd_callback)
- config_file_read_fd_callback(1, ioflags, config_file_read_fd_context, NULL);
+ out:
+ if (!use_mmap)
+ dm_free(buf);
+ else {
+ /* unmap the file */
+ if (munmap(fb - mmap_offset, size + mmap_offset)) {
+ log_sys_error("munmap", dev_name(dev));
+ r = 0;
+ }
+ }
- return 0;
+ return r;
}
-int config_file_read(struct dm_pool *mem, struct dm_config_tree *cft)
+int config_file_read(struct dm_config_tree *cft)
{
const char *filename = NULL;
struct config_source *cs = dm_config_get_custom(cft);
@@ -655,8 +601,8 @@ int config_file_read(struct dm_pool *mem, struct dm_config_tree *cft)
}
}
- r = config_file_read_fd(mem, cft, cf->dev, DEV_IO_MDA_CONTENT, 0, (size_t) info.st_size, 0, 0,
- (checksum_fn_t) NULL, 0, 0, 0, 0, NULL, NULL);
+ r = config_file_read_fd(cft, cf->dev, DEV_IO_MDA_CONTENT, 0, (size_t) info.st_size, 0, 0,
+ (checksum_fn_t) NULL, 0, 0, 0);
if (!cf->keep_open) {
if (!dev_close(cf->dev))
diff --git a/lib/config/config.h b/lib/config/config.h
index 4517cb7..d01306b 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -239,13 +239,11 @@ config_source_t config_get_source_type(struct dm_config_tree *cft);
typedef uint32_t (*checksum_fn_t) (uint32_t initial, const uint8_t *buf, uint32_t size);
struct dm_config_tree *config_open(config_source_t source, const char *filename, int keep_open);
-int config_file_read_fd(struct dm_pool *mem, struct dm_config_tree *cft, struct device *dev, dev_io_reason_t reason,
+int config_file_read_fd(struct dm_config_tree *cft, struct device *dev, dev_io_reason_t reason,
off_t offset, size_t size, off_t offset2, size_t size2,
checksum_fn_t checksum_fn, uint32_t checksum,
- int skip_parse, int no_dup_node_check, unsigned ioflags,
- lvm_callback_fn_t config_file_read_fd_callback, void *config_file_read_fd_context);
-
-int config_file_read(struct dm_pool *mem, struct dm_config_tree *cft);
+ int skip_parse, int no_dup_node_check);
+int config_file_read(struct dm_config_tree *cft);
struct dm_config_tree *config_file_open_and_read(const char *config_file, config_source_t source,
struct cmd_context *cmd);
int config_write(struct dm_config_tree *cft, struct config_def_tree_spec *tree_spec,
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index f1db797..077fb15 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -226,16 +226,6 @@ cfg(devices_dir_CFG, "dir", devices_CFG_SECTION, CFG_ADVANCED, CFG_TYPE_STRING,
cfg_array(devices_scan_CFG, "scan", devices_CFG_SECTION, CFG_ADVANCED, CFG_TYPE_STRING, "#S/dev", vsn(1, 0, 0), NULL, 0, NULL,
"Directories containing device nodes to use with LVM.\n")
-cfg(devices_use_aio_CFG, "use_aio", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_USE_AIO, vsn(2, 2, 178), NULL, 0, NULL,
- "Use linux asynchronous I/O for parallel device access where possible.\n")
-
-cfg(devices_aio_max_CFG, "aio_max", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_AIO_MAX, vsn(2, 2, 178), NULL, 0, NULL,
- "Maximum number of asynchronous I/Os to issue concurrently.\n")
-
-cfg(devices_aio_memory_CFG, "aio_memory", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_AIO_MEMORY, vsn(2, 2, 178), NULL, 0, NULL,
- "Approximate maximum total amount of memory (in MB) used\n"
- "for asynchronous I/O buffers.\n")
-
cfg_array(devices_loopfiles_CFG, "loopfiles", devices_CFG_SECTION, CFG_DEFAULT_UNDEFINED | CFG_UNSUPPORTED, CFG_TYPE_STRING, NULL, vsn(1, 2, 0), NULL, 0, NULL, NULL)
cfg(devices_obtain_device_list_from_udev_CFG, "obtain_device_list_from_udev", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_OBTAIN_DEVICE_LIST_FROM_UDEV, vsn(2, 2, 85), NULL, 0, NULL,
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 1c730a9..d9e19d9 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -32,9 +32,6 @@
#define DEFAULT_SYSTEM_ID_SOURCE "none"
#define DEFAULT_OBTAIN_DEVICE_LIST_FROM_UDEV 1
#define DEFAULT_EXTERNAL_DEVICE_INFO_SOURCE "none"
-#define DEFAULT_USE_AIO 1
-#define DEFAULT_AIO_MAX 128
-#define DEFAULT_AIO_MEMORY 10
#define DEFAULT_SYSFS_SCAN 1
#define DEFAULT_MD_COMPONENT_DETECTION 1
#define DEFAULT_FW_RAID_COMPONENT_DETECTION 0
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 711c2d8..e72ffd6 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -1245,24 +1245,12 @@ int dev_cache_check_for_open_devices(void)
int dev_cache_exit(void)
{
- struct btree_iter *b;
int num_open = 0;
- dev_async_exit();
-
if (_cache.names)
if ((num_open = _check_for_open_devices(1)) > 0)
log_error(INTERNAL_ERROR "%d device(s) were left open and have been closed.", num_open);
- if (_cache.devices) {
- /* FIXME Replace with structured devbuf cache */
- b = btree_first(_cache.devices);
- while (b) {
- devbufs_release(btree_get_data(b));
- b = btree_next(b);
- }
- }
-
if (_cache.mem)
dm_pool_destroy(_cache.mem);
diff --git a/lib/device/dev-cache.h b/lib/device/dev-cache.h
index 5603553..546b1fe 100644
--- a/lib/device/dev-cache.h
+++ b/lib/device/dev-cache.h
@@ -23,10 +23,10 @@
* predicate for devices.
*/
struct dev_filter {
- int (*passes_filter) (struct dev_filter *f, struct device *dev);
- void (*destroy) (struct dev_filter *f);
- void (*wipe) (struct dev_filter *f);
- int (*dump) (struct dev_filter *f, struct dm_pool *mem, int merge_existing);
+ int (*passes_filter) (struct dev_filter * f, struct device * dev);
+ void (*destroy) (struct dev_filter * f);
+ void (*wipe) (struct dev_filter * f);
+ int (*dump) (struct dev_filter * f, int merge_existing);
void *private;
unsigned use_count;
};
diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c
index d631b86..c321e61 100644
--- a/lib/device/dev-io.c
+++ b/lib/device/dev-io.c
@@ -53,12 +53,6 @@
# endif
#endif
-/*
- * Always read at least 8k from disk.
- * This seems to be a good compromise for the existing LVM2 metadata layout.
- */
-#define MIN_READ_SIZE (8 * 1024)
-
static DM_LIST_INIT(_open_devices);
static unsigned _dev_size_seqno = 1;
@@ -80,319 +74,38 @@ static const char *_reason_text(dev_io_reason_t reason)
return _reasons[(unsigned) reason];
}
-/*
- * Release the memory holding the last data we read
- */
-static void _release_devbuf(struct device_buffer *devbuf)
-{
- dm_free(devbuf->malloc_address);
- devbuf->malloc_address = NULL;
-}
-
-void devbufs_release(struct device *dev)
-{
- if ((dev->flags & DEV_REGULAR))
- return;
-
- _release_devbuf(&dev->last_devbuf);
- _release_devbuf(&dev->last_extra_devbuf);
-}
-
-#ifdef AIO_SUPPORT
-
-# include <libaio.h>
-
-static io_context_t _aio_ctx = 0;
-static struct io_event *_aio_events = NULL;
-static int _aio_max = 0;
-static int64_t _aio_memory_max = 0;
-static int _aio_must_queue = 0; /* Have we reached AIO capacity? */
-
-static DM_LIST_INIT(_aio_queue);
-
-#define DEFAULT_AIO_COLLECTION_EVENTS 32
-
-int dev_async_setup(struct cmd_context *cmd)
+/*-----------------------------------------------------------------
+ * The standard io loop that keeps submitting an io until it's
+ * all gone.
+ *---------------------------------------------------------------*/
+static int _io(struct device_area *where, char *buffer, int should_write, dev_io_reason_t reason)
{
- int r;
-
- _aio_max = find_config_tree_int(cmd, devices_aio_max_CFG, NULL);
- _aio_memory_max = find_config_tree_int(cmd, devices_aio_memory_CFG, NULL) * INT64_C(1024 * 1024);
-
- /* Threshold is zero? */
- if (!_aio_max || !_aio_memory_max) {
- if (_aio_ctx)
- dev_async_exit();
- return 1;
- }
-
- /* Already set up? */
- if (_aio_ctx)
- return 1;
-
- log_debug_io("Setting up aio context for up to %" PRId64 " MB across %d events.", _aio_memory_max, _aio_max);
-
- if (!_aio_events && !(_aio_events = dm_zalloc(sizeof(*_aio_events) * DEFAULT_AIO_COLLECTION_EVENTS))) {
- log_error("Failed to allocate io_event array for asynchronous I/O.");
- return 0;
- }
+ int fd = dev_fd(where->dev);
+ ssize_t n = 0;
+ size_t total = 0;
- if ((r = io_setup(_aio_max, &_aio_ctx)) < 0) {
- /*
- * Possible errors:
- * ENOSYS - aio not available in current kernel
- * EAGAIN - _aio_max is too big
- * EFAULT - invalid pointer
- * EINVAL - _aio_ctx != 0 or kernel aio limits exceeded
- * ENOMEM
- */
- log_warn("WARNING: Asynchronous I/O setup for %d events failed: %s", _aio_max, strerror(-r));
- log_warn("WARNING: Using only synchronous I/O.");
- dm_free(_aio_events);
- _aio_events = NULL;
- _aio_ctx = 0;
+ if (fd < 0) {
+ log_error("Attempt to read an unopened device (%s).",
+ dev_name(where->dev));
return 0;
}
- return 1;
-}
-
-/* Reset aio context after fork */
-int dev_async_reset(struct cmd_context *cmd)
-{
- log_debug_io("Resetting asynchronous I/O context.");
- _aio_ctx = 0;
- dm_free(_aio_events);
- _aio_events = NULL;
-
- return dev_async_setup(cmd);
-}
-
-/*
- * Track the amount of in-flight async I/O.
- * If it exceeds the defined threshold set _aio_must_queue.
- */
-static void _update_aio_counters(int nr, ssize_t bytes)
-{
- static int64_t aio_bytes = 0;
- static int aio_count = 0;
-
- aio_bytes += bytes;
- aio_count += nr;
-
- if (aio_count >= _aio_max || aio_bytes > _aio_memory_max)
- _aio_must_queue = 1;
- else
- _aio_must_queue = 0;
-}
-
-static int _io(struct device_buffer *devbuf, unsigned ioflags);
+ log_debug_io("%s %s:%8" PRIu64 " bytes (sync) at %" PRIu64 "%s (for %s)",
+ should_write ? "Write" : "Read ", dev_name(where->dev),
+ where->size, (uint64_t) where->start,
+ (should_write && test_mode()) ? " (test mode - suppressed)" : "", _reason_text(reason));
-int dev_async_getevents(void)
-{
- struct device_buffer *devbuf, *tmp;
- lvm_callback_fn_t dev_read_callback_fn;
- void *dev_read_callback_context;
- int r, event_nr;
-
- if (!_aio_ctx)
+ /*
+ * Skip all writes in test mode.
+ */
+ if (should_write && test_mode())
return 1;
- do {
- /* FIXME Add timeout - currently NULL - waits for ever for at least 1 item */
- r = io_getevents(_aio_ctx, 1, DEFAULT_AIO_COLLECTION_EVENTS, _aio_events, NULL);
- if (r > 0)
- break;
- if (!r)
- return 1; /* Timeout elapsed */
- if (r == -EINTR)
- continue;
- if (r == -EAGAIN) {
- usleep(100);
- return 1; /* Give the caller the opportunity to do other work before repeating */
- }
- /*
- * ENOSYS - not supported by kernel
- * EFAULT - memory invalid
- * EINVAL - _aio_ctx invalid or min_nr/nr/timeout out of range
- */
- log_error("Asynchronous event collection failed: %s", strerror(-r));
- return 0;
- } while (1);
-
- for (event_nr = 0; event_nr < r; event_nr++) {
- devbuf = _aio_events[event_nr].obj->data;
- dm_free(_aio_events[event_nr].obj);
-
- _update_aio_counters(-1, -devbuf->where.size);
-
- dev_read_callback_fn = devbuf->dev_read_callback_fn;
- dev_read_callback_context = devbuf->dev_read_callback_context;
-
- /* Clear the callbacks as a precaution */
- devbuf->dev_read_callback_context = NULL;
- devbuf->dev_read_callback_fn = NULL;
-
- if (_aio_events[event_nr].res == devbuf->where.size) {
- if (dev_read_callback_fn)
- dev_read_callback_fn(0, AIO_SUPPORTED_CODE_PATH, dev_read_callback_context, (char *)devbuf->buf + devbuf->data_offset);
- } else {
- /* FIXME If partial read is possible, resubmit remainder */
- log_error("%s: asynchronous read only I/O failed (" FMTd64 ") of " FMTu64 " bytes at " FMTu64 " (for %s): %s",
- dev_name(devbuf->where.dev), _aio_events[event_nr].res,
- (uint64_t) devbuf->where.size, (uint64_t) devbuf->where.start,
- _reason_text(devbuf->reason),
- (((int64_t)_aio_events[event_nr].res) < 0) ? strerror(-(int64_t)_aio_events[event_nr].res) : 0);
- _release_devbuf(devbuf);
- if (dev_read_callback_fn)
- dev_read_callback_fn(1, AIO_SUPPORTED_CODE_PATH, dev_read_callback_context, NULL);
- else
- r = 0;
- }
- }
-
- /* Submit further queued events if we can */
- dm_list_iterate_items_gen_safe(devbuf, tmp, &_aio_queue, aio_queued) {
- if (_aio_must_queue)
- break;
- dm_list_del(&devbuf->aio_queued);
- _io(devbuf, 1);
- }
-
- return 1;
-}
-
-static int _io_async(struct device_buffer *devbuf)
-{
- struct device_area *where = &devbuf->where;
- struct iocb *iocb;
- int r;
-
- _update_aio_counters(1, devbuf->where.size);
-
- if (!(iocb = dm_malloc(sizeof(*iocb)))) {
- log_error("Failed to allocate I/O control block array for asynchronous I/O.");
+ if (where->size > SSIZE_MAX) {
+ log_error("Read size too large: %" PRIu64, where->size);
return 0;
}
- io_prep_pread(iocb, dev_fd(where->dev), devbuf->buf, where->size, where->start);
- iocb->data = devbuf;
-
- do {
- r = io_submit(_aio_ctx, 1L, &iocb);
- if (r ==1)
- break; /* Success */
- if (r == -EAGAIN) {
- /* Try to release some resources then retry */
- usleep(100);
- if (dev_async_getevents())
- return_0;
- /* FIXME Add counter/timeout so we can't get stuck here for ever */
- continue;
- }
- /*
- * Possible errors:
- * EFAULT - invalid data
- * ENOSYS - no aio support in kernel
- * EBADF - bad file descriptor in iocb
- * EINVAL - invalid _aio_ctx / iocb not initialised / invalid operation for this fd
- */
- log_error("Asynchronous event submission failed: %s", strerror(-r));
- return 0;
- } while (1);
-
- return 1;
-}
-
-void dev_async_exit(void)
-{
- struct device_buffer *devbuf, *tmp;
- lvm_callback_fn_t dev_read_callback_fn;
- void *dev_read_callback_context;
- int r;
-
- if (!_aio_ctx)
- return;
-
- /* Discard any queued requests */
- dm_list_iterate_items_gen_safe(devbuf, tmp, &_aio_queue, aio_queued) {
- dm_list_del(&devbuf->aio_queued);
-
- _update_aio_counters(-1, -devbuf->where.size);
-
- dev_read_callback_fn = devbuf->dev_read_callback_fn;
- dev_read_callback_context = devbuf->dev_read_callback_context;
-
- _release_devbuf(devbuf);
-
- if (dev_read_callback_fn)
- dev_read_callback_fn(1, AIO_SUPPORTED_CODE_PATH, dev_read_callback_context, NULL);
- }
-
- log_debug_io("Destroying aio context.");
- if ((r = io_destroy(_aio_ctx)) < 0)
- /* Returns -ENOSYS if aio not in kernel or -EINVAL if _aio_ctx invalid */
- log_error("Failed to destroy asynchronous I/O context: %s", strerror(-r));
-
- dm_free(_aio_events);
- _aio_events = NULL;
-
- _aio_ctx = 0;
-}
-
-static void _queue_aio(struct device_buffer *devbuf)
-{
- dm_list_add(&_aio_queue, &devbuf->aio_queued);
- log_debug_io("Queueing aio.");
-}
-
-#else
-
-static int _aio_ctx = 0;
-static int _aio_must_queue = 0;
-
-int dev_async_setup(struct cmd_context *cmd)
-{
- return 1;
-}
-
-int dev_async_reset(struct cmd_context *cmd)
-{
- return 1;
-}
-
-int dev_async_getevents(void)
-{
- return 1;
-}
-
-void dev_async_exit(void)
-{
-}
-
-static int _io_async(struct device_buffer *devbuf)
-{
- return 0;
-}
-
-static void _queue_aio(struct device_buffer *devbuf)
-{
-}
-
-#endif /* AIO_SUPPORT */
-
-/*-----------------------------------------------------------------
- * The standard io loop that keeps submitting an io until it's
- * all gone.
- *---------------------------------------------------------------*/
-static int _io_sync(struct device_buffer *devbuf)
-{
- struct device_area *where = &devbuf->where;
- int fd = dev_fd(where->dev);
- char *buffer = devbuf->buf;
- ssize_t n = 0;
- size_t total = 0;
-
if (lseek(fd, (off_t) where->start, SEEK_SET) == (off_t) -1) {
log_error("%s: lseek %" PRIu64 " failed: %s",
dev_name(where->dev), (uint64_t) where->start,
@@ -402,19 +115,18 @@ static int _io_sync(struct device_buffer *devbuf)
while (total < (size_t) where->size) {
do
- n = devbuf->write ?
+ n = should_write ?
write(fd, buffer, (size_t) where->size - total) :
read(fd, buffer, (size_t) where->size - total);
while ((n < 0) && ((errno == EINTR) || (errno == EAGAIN)));
if (n < 0)
- log_error("%s: synchronous %s failed after %" PRIu64 " of %" PRIu64
- " at %" PRIu64 " (for %s): %s", dev_name(where->dev),
- devbuf->write ? "write" : "read",
- (uint64_t) total,
- (uint64_t) where->size, (uint64_t) where->start,
- _reason_text(devbuf->reason),
- strerror(errno));
+ log_error_once("%s: %s failed after %" PRIu64 " of %" PRIu64
+ " at %" PRIu64 ": %s", dev_name(where->dev),
+ should_write ? "write" : "read",
+ (uint64_t) total,
+ (uint64_t) where->size,
+ (uint64_t) where->start, strerror(errno));
if (n <= 0)
break;
@@ -426,42 +138,6 @@ static int _io_sync(struct device_buffer *devbuf)
return (total == (size_t) where->size);
}
-static int _io(struct device_buffer *devbuf, unsigned ioflags)
-{
- struct device_area *where = &devbuf->where;
- int fd = dev_fd(where->dev);
- int async = (!devbuf->write && _aio_ctx && aio_supported_code_path(ioflags) && devbuf->dev_read_callback_fn) ? 1 : 0;
-
- if (fd < 0) {
- log_error("Attempt to read an unopened device (%s).",
- dev_name(where->dev));
- return 0;
- }
-
- if (!devbuf->buf && !(devbuf->malloc_address = devbuf->buf = dm_malloc_aligned((size_t) devbuf->where.size, 0))) {
- log_error("I/O buffer malloc failed");
- return 0;
- }
-
- log_debug_io("%s %s(fd %d):%8" PRIu64 " bytes (%ssync) at %" PRIu64 "%s (for %s)",
- devbuf->write ? "Write" : "Read ", dev_name(where->dev), fd,
- where->size, async ? "a" : "", (uint64_t) where->start,
- (devbuf->write && test_mode()) ? " (test mode - suppressed)" : "", _reason_text(devbuf->reason));
-
- /*
- * Skip all writes in test mode.
- */
- if (devbuf->write && test_mode())
- return 1;
-
- if (where->size > SSIZE_MAX) {
- log_error("Read size too large: %" PRIu64, where->size);
- return 0;
- }
-
- return async ? _io_async(devbuf) : _io_sync(devbuf);
-}
-
/*-----------------------------------------------------------------
* LVM2 uses O_DIRECT when performing metadata io, which requires
* block size aligned accesses. If any io is not aligned we have
@@ -551,16 +227,15 @@ static void _widen_region(unsigned int block_size, struct device_area *region,
result->size += block_size - delta;
}
-static int _aligned_io(struct device_area *where, char *write_buffer,
- int should_write, dev_io_reason_t reason,
- unsigned ioflags, lvm_callback_fn_t dev_read_callback_fn, void *dev_read_callback_context)
+static int _aligned_io(struct device_area *where, char *buffer,
+ int should_write, dev_io_reason_t reason)
{
+ char *bounce, *bounce_buf;
unsigned int physical_block_size = 0;
unsigned int block_size = 0;
unsigned buffer_was_widened = 0;
uintptr_t mask;
struct device_area widened;
- struct device_buffer *devbuf;
int r = 0;
if (!(where->dev->flags & DEV_REGULAR) &&
@@ -569,11 +244,6 @@ static int _aligned_io(struct device_area *where, char *write_buffer,
if (!block_size)
block_size = lvm_getpagesize();
-
- /* Apply minimum read size */
- if (!should_write && block_size < MIN_READ_SIZE)
- block_size = MIN_READ_SIZE;
-
mask = block_size - 1;
_widen_region(block_size, where, &widened);
@@ -583,75 +253,50 @@ static int _aligned_io(struct device_area *where, char *write_buffer,
buffer_was_widened = 1;
log_debug_io("Widening request for %" PRIu64 " bytes at %" PRIu64 " to %" PRIu64 " bytes at %" PRIu64 " on %s (for %s)",
where->size, (uint64_t) where->start, widened.size, (uint64_t) widened.start, dev_name(where->dev), _reason_text(reason));
- }
-
- devbuf = DEV_DEVBUF(where->dev, reason);
- _release_devbuf(devbuf);
- devbuf->where.dev = where->dev;
- devbuf->where.start = widened.start;
- devbuf->where.size = widened.size;
- devbuf->write = should_write;
- devbuf->reason = reason;
- devbuf->dev_read_callback_fn = dev_read_callback_fn;
- devbuf->dev_read_callback_context = dev_read_callback_context;
-
- /* Store location of requested data relative to start of buf */
- devbuf->data_offset = where->start - devbuf->where.start;
-
- if (should_write && !buffer_was_widened && !((uintptr_t) write_buffer & mask))
+ } else if (!((uintptr_t) buffer & mask))
/* Perform the I/O directly. */
- devbuf->buf = write_buffer;
- else if (!should_write)
- /* Postpone buffer allocation until we're about to issue the I/O */
- devbuf->buf = NULL;
- else {
- /* Allocate a bounce buffer with an extra block */
- if (!(devbuf->malloc_address = devbuf->buf = dm_malloc((size_t) devbuf->where.size + block_size))) {
- log_error("Bounce buffer malloc failed");
- return 0;
- }
-
- /*
- * Realign start of bounce buffer (using the extra sector)
- */
- if (((uintptr_t) devbuf->buf) & mask)
- devbuf->buf = (char *) ((((uintptr_t) devbuf->buf) + mask) & ~mask);
- }
+ return _io(where, buffer, should_write, reason);
- /* If we've reached our concurrent AIO limit, add this request to the queue */
- if (!devbuf->write && _aio_ctx && aio_supported_code_path(ioflags) && dev_read_callback_fn && _aio_must_queue) {
- _queue_aio(devbuf);
- return 1;
+ /* Allocate a bounce buffer with an extra block */
+ if (!(bounce_buf = bounce = dm_malloc((size_t) widened.size + block_size))) {
+ log_error("Bounce buffer malloc failed");
+ return 0;
}
- devbuf->write = 0;
+ /*
+ * Realign start of bounce buffer (using the extra sector)
+ */
+ if (((uintptr_t) bounce) & mask)
+ bounce = (char *) ((((uintptr_t) bounce) + mask) & ~mask);
/* Do we need to read into the bounce buffer? */
- if ((!should_write || buffer_was_widened) && !_io(devbuf, ioflags)) {
+ if ((!should_write || buffer_was_widened) &&
+ !_io(&widened, bounce, 0, reason)) {
if (!should_write)
- goto_bad;
+ goto_out;
/* FIXME Handle errors properly! */
/* FIXME pre-extend the file */
- memset(devbuf->buf, '\n', devbuf->where.size);
+ memset(bounce, '\n', widened.size);
}
- if (!should_write)
- return 1;
-
- /* writes */
+ if (should_write) {
+ memcpy(bounce + (where->start - widened.start), buffer,
+ (size_t) where->size);
- if (devbuf->malloc_address) {
- memcpy((char *) devbuf->buf + devbuf->data_offset, write_buffer, (size_t) where->size);
- log_debug_io("Overwriting %" PRIu64 " bytes at %" PRIu64 " (for %s)", where->size,
- (uint64_t) where->start, _reason_text(devbuf->reason));
+ /* ... then we write */
+ if (!(r = _io(&widened, bounce, 1, reason)))
+ stack;
+
+ goto out;
}
- /* ... then we write */
- devbuf->write = 1;
- if (!(r = _io(devbuf, 0)))
- stack;
-bad:
- _release_devbuf(devbuf);
+ memcpy(buffer, bounce + (where->start - widened.start),
+ (size_t) where->size);
+
+ r = 1;
+
+out:
+ dm_free(bounce_buf);
return r;
}
@@ -1005,7 +650,6 @@ static void _close(struct device *dev)
dev->phys_block_size = -1;
dev->block_size = -1;
dm_list_del(&dev->open_list);
- devbufs_release(dev);
log_debug_devs("Closed %s", dev_name(dev));
@@ -1078,121 +722,55 @@ static void _dev_inc_error_count(struct device *dev)
dev->max_error_count, dev_name(dev));
}
-/*
- * Data is returned (read-only) at DEV_DEVBUF_DATA(dev, reason).
- * If dev_read_callback_fn is supplied, we always return 1 and take
- * responsibility for calling it exactly once. This might happen before the
- * function returns (if there's an error or the I/O is synchronous) or after.
- * Any error is passed to that function, which must track it if required.
- */
-static int _dev_read_callback(struct device *dev, uint64_t offset, size_t len, dev_io_reason_t reason,
- unsigned ioflags, lvm_callback_fn_t dev_read_callback_fn, void *callback_context)
+int dev_read(struct device *dev, uint64_t offset, size_t len, dev_io_reason_t reason, void *buffer)
{
struct device_area where;
- struct device_buffer *devbuf;
- uint64_t buf_end;
- int cached = 0;
- int ret = 0;
+ int ret;
- if (!dev->open_count) {
- log_error(INTERNAL_ERROR "Attempt to access device %s while closed.", dev_name(dev));
- goto out;
- }
+ if (!dev->open_count)
+ return_0;
if (!_dev_is_valid(dev))
- goto_out;
-
- /*
- * Can we satisfy this from data we stored last time we read?
- */
- if ((devbuf = DEV_DEVBUF(dev, reason)) && devbuf->malloc_address) {
- buf_end = devbuf->where.start + devbuf->where.size - 1;
- if (offset >= devbuf->where.start && offset <= buf_end && offset + len - 1 <= buf_end) {
- /* Reuse this buffer */
- cached = 1;
- devbuf->data_offset = offset - devbuf->where.start;
- log_debug_io("Cached read for %" PRIu64 " bytes at %" PRIu64 " on %s (for %s)",
- (uint64_t) len, (uint64_t) offset, dev_name(dev), _reason_text(reason));
- ret = 1;
- goto out;
- }
- }
+ return 0;
where.dev = dev;
where.start = offset;
where.size = len;
- ret = _aligned_io(&where, NULL, 0, reason, ioflags, dev_read_callback_fn, callback_context);
- if (!ret) {
- log_debug("Read from %s failed (for %s).", dev_name(dev), _reason_text(reason));
+ ret = _aligned_io(&where, buffer, 0, reason);
+ if (!ret)
_dev_inc_error_count(dev);
- }
-
-out:
- /* If we had an error or this was sync I/O, pass the result to any callback fn */
- if ((!ret || !_aio_ctx || !aio_supported_code_path(ioflags) || cached) && dev_read_callback_fn) {
- dev_read_callback_fn(!ret, ioflags, callback_context, DEV_DEVBUF_DATA(dev, reason));
- return 1;
- }
return ret;
}
-void dev_read_callback(struct device *dev, uint64_t offset, size_t len, dev_io_reason_t reason,
- unsigned ioflags, lvm_callback_fn_t dev_read_callback_fn, void *callback_context)
-{
- /* Always returns 1 if callback fn is supplied */
- if (!_dev_read_callback(dev, offset, len, reason, ioflags, dev_read_callback_fn, callback_context))
- log_error(INTERNAL_ERROR "_dev_read_callback failed");
-}
-
-/* Returns pointer to read-only buffer. Caller does not free it. */
-const char *dev_read(struct device *dev, uint64_t offset, size_t len, dev_io_reason_t reason)
-{
- if (!_dev_read_callback(dev, offset, len, reason, 0, NULL, NULL))
- return_NULL;
-
- return DEV_DEVBUF_DATA(dev, reason);
-}
-
-/* Read into supplied retbuf owned by the caller. */
-int dev_read_buf(struct device *dev, uint64_t offset, size_t len, dev_io_reason_t reason, void *retbuf)
-{
- if (!_dev_read_callback(dev, offset, len, reason, 0, NULL, NULL))
- return_0;
-
- memcpy(retbuf, DEV_DEVBUF_DATA(dev, reason), len);
-
- return 1;
-}
-
/*
- * Read from 'dev' in 2 distinct regions, denoted by (offset,len) and (offset2,len2).
- * Caller is responsible for dm_free().
+ * Read from 'dev' into 'buf', possibly in 2 distinct regions, denoted
+ * by (offset,len) and (offset2,len2). Thus, the total size of
+ * 'buf' should be len+len2.
*/
-const char *dev_read_circular(struct device *dev, uint64_t offset, size_t len,
- uint64_t offset2, size_t len2, dev_io_reason_t reason)
+int dev_read_circular(struct device *dev, uint64_t offset, size_t len,
+ uint64_t offset2, size_t len2, dev_io_reason_t reason, char *buf)
{
- char *buf = NULL;
-
- if (!(buf = dm_malloc(len + len2))) {
- log_error("Buffer allocation failed for split metadata.");
- return NULL;
+ if (!dev_read(dev, offset, len, reason, buf)) {
+ log_error("Read from %s failed", dev_name(dev));
+ return 0;
}
- if (!dev_read_buf(dev, offset, len, reason, buf)) {
- log_error("Read from %s failed.", dev_name(dev));
- dm_free(buf);
- return NULL;
- }
+ /*
+ * The second region is optional, and allows for
+ * a circular buffer on the device.
+ */
+ if (!len2)
+ return 1;
- if (!dev_read_buf(dev, offset2, len2, reason, buf + len)) {
- log_error("Circular read from %s failed.", dev_name(dev));
- dm_free(buf);
- return NULL;
+ if (!dev_read(dev, offset2, len2, reason, buf + len)) {
+ log_error("Circular read from %s failed",
+ dev_name(dev));
+ return 0;
}
- return buf;
+ return 1;
}
/* FIXME If O_DIRECT can't extend file, dev_extend first; dev_truncate after.
@@ -1238,7 +816,7 @@ int dev_write(struct device *dev, uint64_t offset, size_t len, dev_io_reason_t r
dev->flags |= DEV_ACCESSED_W;
- ret = _aligned_io(&where, buffer, 1, reason, 0, NULL, NULL);
+ ret = _aligned_io(&where, buffer, 1, reason);
if (!ret)
_dev_inc_error_count(dev);
@@ -1248,7 +826,7 @@ int dev_write(struct device *dev, uint64_t offset, size_t len, dev_io_reason_t r
int dev_set(struct device *dev, uint64_t offset, size_t len, dev_io_reason_t reason, int value)
{
size_t s;
- char buffer[4096] __attribute__((aligned(4096)));
+ char buffer[4096] __attribute__((aligned(8)));
if (!dev_open(dev))
return_0;
diff --git a/lib/device/dev-luks.c b/lib/device/dev-luks.c
index f291615..8513e14 100644
--- a/lib/device/dev-luks.c
+++ b/lib/device/dev-luks.c
@@ -31,7 +31,7 @@ int dev_is_luks(struct device *dev, uint64_t *offset_found)
if (offset_found)
*offset_found = 0;
- if (!dev_read_buf(dev, 0, LUKS_SIGNATURE_SIZE, DEV_IO_SIGNATURES, buf))
+ if (!dev_read(dev, 0, LUKS_SIGNATURE_SIZE, DEV_IO_SIGNATURES, buf))
goto_out;
ret = memcmp(buf, LUKS_SIGNATURE, LUKS_SIGNATURE_SIZE) ? 0 : 1;
diff --git a/lib/device/dev-md.c b/lib/device/dev-md.c
index 1a5d470..92ee214 100644
--- a/lib/device/dev-md.c
+++ b/lib/device/dev-md.c
@@ -37,7 +37,7 @@ static int _dev_has_md_magic(struct device *dev, uint64_t sb_offset)
uint32_t md_magic;
/* Version 1 is little endian; version 0.90.0 is machine endian */
- if (dev_read_buf(dev, sb_offset, sizeof(uint32_t), DEV_IO_SIGNATURES, &md_magic) &&
+ if (dev_read(dev, sb_offset, sizeof(uint32_t), DEV_IO_SIGNATURES, &md_magic) &&
((md_magic == MD_SB_MAGIC) ||
((MD_SB_MAGIC != xlate32(MD_SB_MAGIC)) && (md_magic == xlate32(MD_SB_MAGIC)))))
return 1;
diff --git a/lib/device/dev-swap.c b/lib/device/dev-swap.c
index 094eb05..a7ff10b 100644
--- a/lib/device/dev-swap.c
+++ b/lib/device/dev-swap.c
@@ -60,7 +60,8 @@ int dev_is_swap(struct device *dev, uint64_t *offset_found)
continue;
if (size < (page >> SECTOR_SHIFT))
break;
- if (!dev_read_buf(dev, page - SIGNATURE_SIZE, SIGNATURE_SIZE, DEV_IO_SIGNATURES, buf)) {
+ if (!dev_read(dev, page - SIGNATURE_SIZE,
+ SIGNATURE_SIZE, DEV_IO_SIGNATURES, buf)) {
ret = -1;
break;
}
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index b9e77f8..9608146 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -363,7 +363,7 @@ static int _has_partition_table(struct device *dev)
uint16_t magic;
} __attribute__((packed)) buf; /* sizeof() == SECTOR_SIZE */
- if (!dev_read_buf(dev, UINT64_C(0), sizeof(buf), DEV_IO_SIGNATURES, &buf))
+ if (!dev_read(dev, UINT64_C(0), sizeof(buf), DEV_IO_SIGNATURES, &buf))
return_0;
/* FIXME Check for other types of partition table too */
diff --git a/lib/device/device.h b/lib/device/device.h
index ea71d00..503373f 100644
--- a/lib/device/device.h
+++ b/lib/device/device.h
@@ -32,18 +32,6 @@
#define DEV_ASSUMED_FOR_LV 0x00000200 /* Is device assumed for an LV */
#define DEV_NOT_O_NOATIME 0x00000400 /* Don't use O_NOATIME */
-/* ioflags */
-#define AIO_SUPPORTED_CODE_PATH 0x00000001 /* Set if the code path supports AIO */
-
-#define aio_supported_code_path(ioflags) (((ioflags) & AIO_SUPPORTED_CODE_PATH) ? 1 : 0)
-
-/*
- * Standard format for callback functions.
- * When provided, callback functions are called exactly once.
- * If failed is set, data cannot be accessed.
- */
-typedef void (*lvm_callback_fn_t)(int failed, unsigned ioflags, void *context, const void *data);
-
/*
* Support for external device info.
* Any new external device info source needs to be
@@ -62,48 +50,6 @@ struct dev_ext {
};
/*
- * All I/O is annotated with the reason it is performed.
- */
-typedef enum dev_io_reason {
- DEV_IO_SIGNATURES = 0, /* Scanning device signatures */
- DEV_IO_LABEL, /* LVM PV disk label */
- DEV_IO_MDA_HEADER, /* Text format metadata area header */
- DEV_IO_MDA_CONTENT, /* Text format metadata area content */
- DEV_IO_MDA_EXTRA_HEADER, /* Header of any extra metadata areas on device */
- DEV_IO_MDA_EXTRA_CONTENT, /* Content of any extra metadata areas on device */
- DEV_IO_FMT1, /* Original LVM1 metadata format */
- DEV_IO_POOL, /* Pool metadata format */
- DEV_IO_LV, /* Content written to an LV */
- DEV_IO_LOG /* Logging messages */
-} dev_io_reason_t;
-
-/*
- * Is this I/O for a device's extra metadata area?
- */
-#define EXTRA_IO(reason) ((reason) == DEV_IO_MDA_EXTRA_HEADER || (reason) == DEV_IO_MDA_EXTRA_CONTENT)
-#define DEV_DEVBUF(dev, reason) (EXTRA_IO((reason)) ? &(dev)->last_extra_devbuf : &(dev)->last_devbuf)
-#define DEV_DEVBUF_DATA(dev, reason) ((char *) DEV_DEVBUF((dev), (reason))->buf + DEV_DEVBUF((dev), (reason))->data_offset)
-
-struct device_area {
- struct device *dev;
- uint64_t start; /* Bytes */
- uint64_t size; /* Bytes */
-};
-
-struct device_buffer {
- uint64_t data_offset; /* Offset to start of requested data within buf */
- void *malloc_address; /* Start of allocated memory */
- void *buf; /* Aligned buffer that contains data within it */
- struct device_area where; /* Location of buf */
- dev_io_reason_t reason;
- unsigned write:1; /* 1 if write; 0 if read */
-
- lvm_callback_fn_t dev_read_callback_fn;
- void *dev_read_callback_context;
- struct dm_list aio_queued; /* Queue of async I/O waiting to be issued */
-};
-
-/*
* All devices in LVM will be represented by one of these.
* pointer comparisons are valid.
*/
@@ -125,8 +71,6 @@ struct device {
uint64_t end;
struct dm_list open_list;
struct dev_ext ext;
- struct device_buffer last_devbuf; /* Last data buffer read from the device */
- struct device_buffer last_extra_devbuf; /* Last data buffer read from the device for extra metadata area */
const char *vgid; /* if device is an LV */
const char *lvid; /* if device is an LV */
@@ -135,11 +79,33 @@ struct device {
char _padding[7];
};
+/*
+ * All I/O is annotated with the reason it is performed.
+ */
+typedef enum dev_io_reason {
+ DEV_IO_SIGNATURES = 0, /* Scanning device signatures */
+ DEV_IO_LABEL, /* LVM PV disk label */
+ DEV_IO_MDA_HEADER, /* Text format metadata area header */
+ DEV_IO_MDA_CONTENT, /* Text format metadata area content */
+ DEV_IO_MDA_EXTRA_HEADER, /* Header of any extra metadata areas on device */
+ DEV_IO_MDA_EXTRA_CONTENT, /* Content of any extra metadata areas on device */
+ DEV_IO_FMT1, /* Original LVM1 metadata format */
+ DEV_IO_POOL, /* Pool metadata format */
+ DEV_IO_LV, /* Content written to an LV */
+ DEV_IO_LOG /* Logging messages */
+} dev_io_reason_t;
+
struct device_list {
struct dm_list list;
struct device *dev;
};
+struct device_area {
+ struct device *dev;
+ uint64_t start; /* Bytes */
+ uint64_t size; /* Bytes */
+};
+
/*
* Support for external device info.
*/
@@ -179,19 +145,9 @@ int dev_test_excl(struct device *dev);
int dev_fd(struct device *dev);
const char *dev_name(const struct device *dev);
-/* Returns a read-only buffer */
-const char *dev_read(struct device *dev, uint64_t offset, size_t len, dev_io_reason_t reason);
-const char *dev_read_circular(struct device *dev, uint64_t offset, size_t len,
- uint64_t offset2, size_t len2, dev_io_reason_t reason);
-
-/* Passes the data (or error) to dev_read_callback_fn */
-void dev_read_callback(struct device *dev, uint64_t offset, size_t len, dev_io_reason_t reason,
- unsigned ioflags, lvm_callback_fn_t dev_read_callback_fn, void *callback_context);
-
-/* Read data and copy it into a supplied private buffer. */
-/* Only use for tiny reads or on unimportant code paths. */
-int dev_read_buf(struct device *dev, uint64_t offset, size_t len, dev_io_reason_t reason, void *retbuf);
-
+int dev_read(struct device *dev, uint64_t offset, size_t len, dev_io_reason_t reason, void *buffer);
+int dev_read_circular(struct device *dev, uint64_t offset, size_t len,
+ uint64_t offset2, size_t len2, dev_io_reason_t reason, char *buf);
int dev_write(struct device *dev, uint64_t offset, size_t len, dev_io_reason_t reason, void *buffer);
int dev_append(struct device *dev, size_t len, dev_io_reason_t reason, char *buffer);
int dev_set(struct device *dev, uint64_t offset, size_t len, dev_io_reason_t reason, int value);
@@ -201,15 +157,7 @@ struct device *dev_create_file(const char *filename, struct device *dev,
struct dm_str_list *alias, int use_malloc);
void dev_destroy_file(struct device *dev);
-void devbufs_release(struct device *dev);
-
/* Return a valid device name from the alias list; NULL otherwise */
const char *dev_name_confirmed(struct device *dev, int quiet);
-struct cmd_context;
-int dev_async_getevents(void);
-int dev_async_setup(struct cmd_context *cmd);
-void dev_async_exit(void);
-int dev_async_reset(struct cmd_context *cmd);
-
#endif
diff --git a/lib/filters/filter-composite.c b/lib/filters/filter-composite.c
index 83a0f02..c635896 100644
--- a/lib/filters/filter-composite.c
+++ b/lib/filters/filter-composite.c
@@ -52,13 +52,13 @@ static void _composite_destroy(struct dev_filter *f)
dm_free(f);
}
-static int _dump(struct dev_filter *f, struct dm_pool *mem, int merge_existing)
+static int _dump(struct dev_filter *f, int merge_existing)
{
struct dev_filter **filters;
for (filters = (struct dev_filter **) f->private; *filters; ++filters)
if ((*filters)->dump &&
- !(*filters)->dump(*filters, mem, merge_existing))
+ !(*filters)->dump(*filters, merge_existing))
return_0;
return 1;
diff --git a/lib/filters/filter-persistent.c b/lib/filters/filter-persistent.c
index 7542e02..5bc0861 100644
--- a/lib/filters/filter-persistent.c
+++ b/lib/filters/filter-persistent.c
@@ -87,7 +87,7 @@ static int _read_array(struct pfilter *pf, struct dm_config_tree *cft,
return 1;
}
-int persistent_filter_load(struct dm_pool *mem, struct dev_filter *f, struct dm_config_tree **cft_out)
+int persistent_filter_load(struct dev_filter *f, struct dm_config_tree **cft_out)
{
struct pfilter *pf = (struct pfilter *) f->private;
struct dm_config_tree *cft;
@@ -116,7 +116,7 @@ int persistent_filter_load(struct dm_pool *mem, struct dev_filter *f, struct dm_
if (!(cft = config_open(CONFIG_FILE_SPECIAL, pf->file, 1)))
return_0;
- if (!config_file_read(mem, cft))
+ if (!config_file_read(cft))
goto_out;
log_debug_devs("Loading persistent filter cache from %s", pf->file);
@@ -175,7 +175,7 @@ static void _write_array(struct pfilter *pf, FILE *fp, const char *path,
fprintf(fp, "\n\t]\n");
}
-static int _persistent_filter_dump(struct dev_filter *f, struct dm_pool *mem, int merge_existing)
+static int _persistent_filter_dump(struct dev_filter *f, int merge_existing)
{
struct pfilter *pf;
char *tmp_file;
@@ -234,7 +234,7 @@ static int _persistent_filter_dump(struct dev_filter *f, struct dm_pool *mem, in
lvm_stat_ctim(&ts, &info);
if (merge_existing && timespeccmp(&ts, &pf->ctime, !=))
/* Keep cft open to avoid losing lock */
- persistent_filter_load(mem, f, &cft);
+ persistent_filter_load(f, &cft);
tmp_file = alloca(strlen(pf->file) + 5);
sprintf(tmp_file, "%s.tmp", pf->file);
diff --git a/lib/filters/filter.h b/lib/filters/filter.h
index 5dbf0b4..d75f6e1 100644
--- a/lib/filters/filter.h
+++ b/lib/filters/filter.h
@@ -53,6 +53,6 @@ typedef enum {
} filter_mode_t;
struct dev_filter *usable_filter_create(struct dev_types *dt, filter_mode_t mode);
-int persistent_filter_load(struct dm_pool *mem, struct dev_filter *f, struct dm_config_tree **cft_out);
+int persistent_filter_load(struct dev_filter *f, struct dm_config_tree **cft_out);
#endif /* _LVM_FILTER_H */
diff --git a/lib/format1/disk-rep.c b/lib/format1/disk-rep.c
index cf34e91..41955af 100644
--- a/lib/format1/disk-rep.c
+++ b/lib/format1/disk-rep.c
@@ -205,7 +205,7 @@ int munge_pvd(struct device *dev, struct pv_disk *pvd)
static int _read_pvd(struct device *dev, struct pv_disk *pvd)
{
- if (!dev_read_buf(dev, UINT64_C(0), sizeof(*pvd), DEV_IO_FMT1, pvd)) {
+ if (!dev_read(dev, UINT64_C(0), sizeof(*pvd), DEV_IO_FMT1, pvd)) {
log_very_verbose("Failed to read PV data from %s",
dev_name(dev));
return 0;
@@ -216,7 +216,7 @@ static int _read_pvd(struct device *dev, struct pv_disk *pvd)
static int _read_lvd(struct device *dev, uint64_t pos, struct lv_disk *disk)
{
- if (!dev_read_buf(dev, pos, sizeof(*disk), DEV_IO_FMT1, disk))
+ if (!dev_read(dev, pos, sizeof(*disk), DEV_IO_FMT1, disk))
return_0;
_xlate_lvd(disk);
@@ -228,7 +228,7 @@ int read_vgd(struct device *dev, struct vg_disk *vgd, struct pv_disk *pvd)
{
uint64_t pos = pvd->vg_on_disk.base;
- if (!dev_read_buf(dev, pos, sizeof(*vgd), DEV_IO_FMT1, vgd))
+ if (!dev_read(dev, pos, sizeof(*vgd), DEV_IO_FMT1, vgd))
return_0;
_xlate_vgd(vgd);
@@ -252,7 +252,7 @@ static int _read_uuids(struct disk_list *data)
uint64_t end = pos + data->pvd.pv_uuidlist_on_disk.size;
while (pos < end && num_read < data->vgd.pv_cur) {
- if (!dev_read_buf(data->dev, pos, sizeof(buffer), DEV_IO_FMT1, buffer))
+ if (!dev_read(data->dev, pos, sizeof(buffer), DEV_IO_FMT1, buffer))
return_0;
if (!(ul = dm_pool_alloc(data->mem, sizeof(*ul))))
@@ -311,7 +311,7 @@ static int _read_extents(struct disk_list *data)
if (!extents)
return_0;
- if (!dev_read_buf(data->dev, pos, len, DEV_IO_FMT1, extents))
+ if (!dev_read(data->dev, pos, len, DEV_IO_FMT1, extents))
return_0;
_xlate_extents(extents, data->pvd.pe_total);
diff --git a/lib/format1/format1.c b/lib/format1/format1.c
index 7d84e69..b3569e0 100644
--- a/lib/format1/format1.c
+++ b/lib/format1/format1.c
@@ -182,7 +182,7 @@ static struct volume_group *_format1_vg_read(struct format_instance *fid,
struct metadata_area *mda __attribute__((unused)),
struct cached_vg_fmtdata **vg_fmtdata __attribute__((unused)),
unsigned *use_previous_vg __attribute__((unused)),
- int single_device __attribute__((unused)), unsigned ioflags)
+ int single_device __attribute__((unused)))
{
struct volume_group *vg;
struct disk_list *dl;
diff --git a/lib/format1/lvm1-label.c b/lib/format1/lvm1-label.c
index d334fdc..3b8a655 100644
--- a/lib/format1/lvm1-label.c
+++ b/lib/format1/lvm1-label.c
@@ -54,17 +54,15 @@ static int _lvm1_write(struct label *label __attribute__((unused)), void *buf __
return 0;
}
-static int _lvm1_read(struct labeller *l, struct device *dev, void *buf, unsigned ioflags,
- lvm_callback_fn_t read_label_callback_fn, void *read_label_callback_context)
+static int _lvm1_read(struct labeller *l, struct device *dev, void *buf,
+ struct label **label)
{
struct pv_disk *pvd = (struct pv_disk *) buf;
struct vg_disk vgd;
struct lvmcache_info *info;
- struct label *label = NULL;
const char *vgid = FMT_LVM1_ORPHAN_VG_NAME;
const char *vgname = FMT_LVM1_ORPHAN_VG_NAME;
unsigned exported = 0;
- int r = 0;
munge_pvd(dev, pvd);
@@ -78,9 +76,8 @@ static int _lvm1_read(struct labeller *l, struct device *dev, void *buf, unsigne
if (!(info = lvmcache_add(l, (char *)pvd->pv_uuid, dev, vgname, vgid,
exported)))
- goto_out;
-
- label = lvmcache_get_label(info);
+ return_0;
+ *label = lvmcache_get_label(info);
lvmcache_set_device_size(info, ((uint64_t)xlate32(pvd->pv_size)) << SECTOR_SHIFT);
lvmcache_set_ext_version(info, 0);
@@ -89,13 +86,7 @@ static int _lvm1_read(struct labeller *l, struct device *dev, void *buf, unsigne
lvmcache_del_bas(info);
lvmcache_make_valid(info);
- r = 1;
-
-out:
- if (read_label_callback_fn)
- read_label_callback_fn(!r, 0, read_label_callback_context, label);
-
- return r;
+ return 1;
}
static int _lvm1_initialise_label(struct labeller *l __attribute__((unused)), struct label *label)
diff --git a/lib/format_pool/disk_rep.c b/lib/format_pool/disk_rep.c
index 4b2e7fb..374ff44 100644
--- a/lib/format_pool/disk_rep.c
+++ b/lib/format_pool/disk_rep.c
@@ -40,7 +40,7 @@ static int __read_pool_disk(const struct format_type *fmt, struct device *dev,
char buf[512] __attribute__((aligned(8)));
/* FIXME: Need to check the cache here first */
- if (!dev_read_buf(dev, UINT64_C(0), 512, DEV_IO_POOL, buf)) {
+ if (!dev_read(dev, UINT64_C(0), 512, DEV_IO_POOL, buf)) {
log_very_verbose("Failed to read PV data from %s",
dev_name(dev));
return 0;
diff --git a/lib/format_pool/format_pool.c b/lib/format_pool/format_pool.c
index c699058..f6e5e01 100644
--- a/lib/format_pool/format_pool.c
+++ b/lib/format_pool/format_pool.c
@@ -103,7 +103,7 @@ static struct volume_group *_pool_vg_read(struct format_instance *fid,
struct metadata_area *mda __attribute__((unused)),
struct cached_vg_fmtdata **vg_fmtdata __attribute__((unused)),
unsigned *use_previous_vg __attribute__((unused)),
- int single_device __attribute__((unused)), unsigned ioflags)
+ int single_device __attribute__((unused)))
{
struct volume_group *vg;
struct user_subpool *usp;
diff --git a/lib/format_pool/pool_label.c b/lib/format_pool/pool_label.c
index 888a2eb..2e30a7b 100644
--- a/lib/format_pool/pool_label.c
+++ b/lib/format_pool/pool_label.c
@@ -55,19 +55,12 @@ static int _pool_write(struct label *label __attribute__((unused)), void *buf __
return 0;
}
-static int _pool_read(struct labeller *l, struct device *dev, void *buf, unsigned ioflags,
- lvm_callback_fn_t read_label_callback_fn, void *read_label_callback_context)
+static int _pool_read(struct labeller *l, struct device *dev, void *buf,
+ struct label **label)
{
struct pool_list pl;
- struct label *label;
- int r;
- r = read_pool_label(&pl, l, dev, buf, &label);
-
- if (read_label_callback_fn)
- read_label_callback_fn(!r, 0, read_label_callback_context, label);
-
- return r;
+ return read_pool_label(&pl, l, dev, buf, label);
}
static int _pool_initialise_label(struct labeller *l __attribute__((unused)), struct label *label)
diff --git a/lib/format_text/archive.c b/lib/format_text/archive.c
index 2186de8..72ec40b 100644
--- a/lib/format_text/archive.c
+++ b/lib/format_text/archive.c
@@ -135,8 +135,8 @@ static struct dm_list *_scan_archive(struct dm_pool *mem,
dm_list_init(results);
- /* Use versionsort to handle numbers beyond 5 digits */
- if ((count = scandir(dir, &dirent, NULL, versionsort)) < 0) {
+ /* Sort fails beyond 5-digit indexes */
+ if ((count = scandir(dir, &dirent, NULL, alphasort)) < 0) {
log_error("Couldn't scan the archive directory (%s).", dir);
return 0;
}
diff --git a/lib/format_text/archiver.c b/lib/format_text/archiver.c
index 2c8e751..1eb6654 100644
--- a/lib/format_text/archiver.c
+++ b/lib/format_text/archiver.c
@@ -320,7 +320,7 @@ struct volume_group *backup_read_vg(struct cmd_context *cmd,
}
dm_list_iterate_items(mda, &tf->metadata_areas_in_use) {
- if (!(vg = mda->ops->vg_read(tf, vg_name, mda, NULL, NULL, 0, 0)))
+ if (!(vg = mda->ops->vg_read(tf, vg_name, mda, NULL, NULL, 0)))
stack;
break;
}
diff --git a/lib/format_text/export.c b/lib/format_text/export.c
index 08e1cda..e535237 100644
--- a/lib/format_text/export.c
+++ b/lib/format_text/export.c
@@ -23,7 +23,6 @@
#include "lvm-version.h"
#include "toolcontext.h"
#include "config-util.h"
-#include "layout.h"
#include <stdarg.h>
#include <time.h>
@@ -124,12 +123,11 @@ static int _extend_buffer(struct formatter *f)
log_debug_metadata("Doubling metadata output buffer to " FMTu32,
f->data.buf.size * 2);
- if (!(newbuf = dm_malloc_aligned(f->data.buf.size * 2, 0)))
- return_0;
-
- memcpy(newbuf, f->data.buf.start, f->data.buf.size);
- free(f->data.buf.start);
-
+ if (!(newbuf = dm_realloc(f->data.buf.start,
+ f->data.buf.size * 2))) {
+ log_error("Buffer reallocation failed.");
+ return 0;
+ }
f->data.buf.start = newbuf;
f->data.buf.size *= 2;
@@ -1066,7 +1064,7 @@ size_t text_vg_export_raw(struct volume_group *vg, const char *desc, char **buf)
return_0;
f->data.buf.size = 65536; /* Initial metadata limit */
- if (!(f->data.buf.start = dm_malloc_aligned(f->data.buf.size, 0))) {
+ if (!(f->data.buf.start = dm_malloc(f->data.buf.size))) {
log_error("text_export buffer allocation failed");
goto out;
}
@@ -1081,12 +1079,7 @@ size_t text_vg_export_raw(struct volume_group *vg, const char *desc, char **buf)
goto_out;
}
- f->data.buf.used += 1; /* Terminating NUL */
-
- /* Zero fill up to next alignment boundary */
- memset(f->data.buf.start + f->data.buf.used, 0, MDA_ALIGNMENT - f->data.buf.used % MDA_ALIGNMENT);
-
- r = f->data.buf.used;
+ r = f->data.buf.used + 1;
*buf = f->data.buf.start;
out:
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 2e7e2b8..be9a8b9 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2018 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -37,12 +37,6 @@
#include <dirent.h>
#include <ctype.h>
-/*
- * Round up offset within buffer to next location that is an exact multiple of alignment.
- * (We shouldn't assume the start of the metadata area was aligned the same way when it was created.)
- */
-#define ALIGN_ABSOLUTE(offset, buffer_start, alignment) ((offset) + (alignment) - UINT64_C(1) - ((buffer_start) + (offset) + (alignment) - UINT64_C(1)) % (alignment))
-
static struct format_instance *_text_create_text_instance(const struct format_type *fmt,
const struct format_instance_ctx *fic);
@@ -182,10 +176,9 @@ static int _pv_analyze_mda_raw (const struct format_type * fmt,
uint64_t offset2;
size_t size;
size_t size2;
- const char *buf = NULL;
+ char *buf=NULL;
struct device_area *area;
struct mda_context *mdac;
- unsigned circular = 0;
int r=0;
mdac = (struct mda_context *) mda->metadata_locn;
@@ -197,7 +190,7 @@ static int _pv_analyze_mda_raw (const struct format_type * fmt,
if (!dev_open_readonly(area->dev))
return_0;
- if (!(mdah = raw_read_mda_header(fmt->cmd->mem, area, mda_is_primary(mda))))
+ if (!(mdah = raw_read_mda_header(fmt, area, mda_is_primary(mda))))
goto_out;
rlocn = mdah->raw_locns;
@@ -226,7 +219,6 @@ static int _pv_analyze_mda_raw (const struct format_type * fmt,
prev_sector);
if (prev_sector > prev_sector2)
goto_out;
-
/*
* FIXME: for some reason, the whole metadata region from
* area->start to area->start+area->size is not used.
@@ -235,13 +227,10 @@ static int _pv_analyze_mda_raw (const struct format_type * fmt,
* "dm_config_maybe_section" returning true when there's no valid
* metadata in a sector (sectors with all nulls).
*/
+ if (!(buf = dm_malloc(size + size2)))
+ goto_out;
- circular = size2 ? 1 : 0;
-
- if (circular) {
- if (!(buf = dev_read_circular(area->dev, offset, size, offset2, size2, MDA_CONTENT_REASON(mda_is_primary(mda)))))
- goto_out;
- } else if (!(buf = dev_read(area->dev, offset, size, MDA_CONTENT_REASON(mda_is_primary(mda)))))
+ if (!dev_read_circular(area->dev, offset, size, offset2, size2, MDA_CONTENT_REASON(mda_is_primary(mda)), buf))
goto_out;
/*
@@ -272,20 +261,20 @@ static int _pv_analyze_mda_raw (const struct format_type * fmt,
size += SECTOR_SIZE;
}
}
- if (circular)
- dm_free((void *)buf);
+ dm_free(buf);
buf = NULL;
}
r = 1;
out:
- if (circular)
- dm_free((void *)buf);
+ dm_free(buf);
if (!dev_close(area->dev))
stack;
return r;
}
+
+
static int _text_lv_setup(struct format_instance *fid __attribute__((unused)),
struct logical_volume *lv)
{
@@ -326,27 +315,19 @@ static void _xlate_mdah(struct mda_header *mdah)
}
}
-struct process_raw_mda_header_params {
- struct mda_header *mdah;
- struct device_area dev_area;
- lvm_callback_fn_t mdah_callback_fn;
- void *mdah_callback_context;
- int ret;
-};
-
-static void _process_raw_mda_header(int failed, unsigned ioflags, void *context, const void *data)
+static int _raw_read_mda_header(struct mda_header *mdah, struct device_area *dev_area, int primary_mda)
{
- struct process_raw_mda_header_params *prmp = context;
- struct mda_header *mdah = prmp->mdah;
- struct device_area *dev_area = &prmp->dev_area;
-
- if (!dev_close(dev_area->dev))
- goto_bad;
+ if (!dev_open_readonly(dev_area->dev))
+ return_0;
- if (failed)
- goto_bad;
+ if (!dev_read(dev_area->dev, dev_area->start, MDA_HEADER_SIZE, MDA_HEADER_REASON(primary_mda), mdah)) {
+ if (!dev_close(dev_area->dev))
+ stack;
+ return_0;
+ }
- memcpy(mdah, data, MDA_HEADER_SIZE);
+ if (!dev_close(dev_area->dev))
+ return_0;
if (mdah->checksum_xl != xlate32(calc_crc(INITIAL_CRC, (uint8_t *)mdah->magic,
MDA_HEADER_SIZE -
@@ -354,7 +335,7 @@ static void _process_raw_mda_header(int failed, unsigned ioflags, void *context,
log_error("Incorrect metadata area header checksum on %s"
" at offset " FMTu64, dev_name(dev_area->dev),
dev_area->start);
- goto bad;
+ return 0;
}
_xlate_mdah(mdah);
@@ -363,83 +344,42 @@ static void _process_raw_mda_header(int failed, unsigned ioflags, void *context,
log_error("Wrong magic number in metadata area header on %s"
" at offset " FMTu64, dev_name(dev_area->dev),
dev_area->start);
- goto bad;
+ return 0;
}
if (mdah->version != FMTT_VERSION) {
log_error("Incompatible metadata area header version: %d on %s"
" at offset " FMTu64, mdah->version,
dev_name(dev_area->dev), dev_area->start);
- goto bad;
+ return 0;
}
if (mdah->start != dev_area->start) {
log_error("Incorrect start sector in metadata area header: "
FMTu64 " on %s at offset " FMTu64, mdah->start,
dev_name(dev_area->dev), dev_area->start);
- goto bad;
+ return 0;
}
- goto out;
-
-bad:
- prmp->ret = 0;
-out:
- if (prmp->mdah_callback_fn)
- prmp->mdah_callback_fn(!prmp->ret, ioflags, prmp->mdah_callback_context, mdah);
+ return 1;
}
-static struct mda_header *_raw_read_mda_header(struct dm_pool *mem, struct device_area *dev_area, int primary_mda,
- unsigned ioflags, lvm_callback_fn_t mdah_callback_fn, void *mdah_callback_context)
+struct mda_header *raw_read_mda_header(const struct format_type *fmt,
+ struct device_area *dev_area, int primary_mda)
{
struct mda_header *mdah;
- struct process_raw_mda_header_params *prmp;
- if (!(mdah = dm_pool_alloc(mem, MDA_HEADER_SIZE))) {
+ if (!(mdah = dm_pool_alloc(fmt->cmd->mem, MDA_HEADER_SIZE))) {
log_error("struct mda_header allocation failed");
return NULL;
}
- if (!(prmp = dm_pool_zalloc(mem, sizeof (*prmp)))) {
- log_error("struct process_raw_mda_header_params allocation failed");
- dm_pool_free(mem, mdah);
+ if (!_raw_read_mda_header(mdah, dev_area, primary_mda)) {
+ dm_pool_free(fmt->cmd->mem, mdah);
return NULL;
}
- if (!dev_open_readonly(dev_area->dev)) {
- dm_pool_free(mem, mdah);
- return_NULL;
- }
-
- prmp->mdah = mdah;
- prmp->dev_area = *dev_area;
- prmp->mdah_callback_fn = mdah_callback_fn;
- prmp->mdah_callback_context = mdah_callback_context;
- prmp->ret = 1;
-
- dev_read_callback(dev_area->dev, dev_area->start, MDA_HEADER_SIZE, MDA_HEADER_REASON(primary_mda),
- ioflags, _process_raw_mda_header, prmp);
- if (mdah_callback_fn)
- return mdah;
-
- if (!prmp->ret)
- return_NULL;
- else
- return mdah;
-}
-
-struct mda_header *raw_read_mda_header(struct dm_pool *mem, struct device_area *dev_area, int primary_mda)
-{
- return _raw_read_mda_header(mem, dev_area, primary_mda, 0, NULL, NULL);
-}
-
-int raw_read_mda_header_callback(struct dm_pool *mem, struct device_area *dev_area, int primary_mda,
- unsigned ioflags, lvm_callback_fn_t mdah_callback_fn, void *mdah_callback_context)
-{
- if (!_raw_read_mda_header(mem, dev_area, primary_mda, ioflags, mdah_callback_fn, mdah_callback_context))
- return_0;
-
- return 1;
+ return mdah;
}
static int _raw_write_mda_header(const struct format_type *fmt,
@@ -467,13 +407,13 @@ static struct raw_locn *_find_vg_rlocn(struct device_area *dev_area,
int *precommitted)
{
size_t len;
+ char vgnamebuf[NAME_LEN + 2] __attribute__((aligned(8)));
struct raw_locn *rlocn, *rlocn_precommitted;
struct lvmcache_info *info;
struct lvmcache_vgsummary vgsummary_orphan = {
.vgname = FMT_TEXT_ORPHAN_VG_NAME,
};
int rlocn_was_ignored;
- const char *buf;
memcpy(&vgsummary_orphan.vgid, FMT_TEXT_ORPHAN_VG_NAME, sizeof(FMT_TEXT_ORPHAN_VG_NAME));
@@ -508,12 +448,12 @@ static struct raw_locn *_find_vg_rlocn(struct device_area *dev_area,
/* FIXME Loop through rlocns two-at-a-time. List null-terminated. */
/* FIXME Ignore if checksum incorrect!!! */
- if (!(buf = dev_read(dev_area->dev, dev_area->start + rlocn->offset,
- NAME_LEN + 2, MDA_CONTENT_REASON(primary_mda))))
+ if (!dev_read(dev_area->dev, dev_area->start + rlocn->offset,
+ sizeof(vgnamebuf), MDA_CONTENT_REASON(primary_mda), vgnamebuf))
goto_bad;
- if (!strncmp(buf, vgname, len = strlen(vgname)) &&
- (isspace(*(buf + len)) || *(buf + len) == '{'))
+ if (!strncmp(vgnamebuf, vgname, len = strlen(vgname)) &&
+ (isspace(vgnamebuf[len]) || vgnamebuf[len] == '{'))
return rlocn;
log_debug_metadata("Volume group name found in %smetadata on %s at " FMTu64 " does "
@@ -530,46 +470,25 @@ static struct raw_locn *_find_vg_rlocn(struct device_area *dev_area,
}
/*
- * Find first aligned offset after end of existing metadata.
- * Based on the alignment provided, this is the exact offset to use for the new metadata.
- * The caller is responsible for validating the result.
+ * Determine offset for uncommitted metadata
*/
static uint64_t _next_rlocn_offset(struct raw_locn *rlocn, struct mda_header *mdah, uint64_t mdac_area_start, uint64_t alignment)
{
- uint64_t old_end, new_start_offset;
- int old_wrapped = 0; /* Does the old metadata wrap around? */
+ uint64_t new_start_offset;
if (!rlocn)
/* Find an empty slot */
- /* FIXME Assumes only one VG per mdah for now */
- return ALIGN_ABSOLUTE(MDA_HEADER_SIZE, mdac_area_start, alignment);
+ /* FIXME Assume only one VG per mdah for now */
+ return alignment;
- /* First find the end of the old metadata */
- old_end = rlocn->offset + rlocn->size;
-
- if (old_end > mdah->size) {
- old_wrapped = 1;
- old_end -= (mdah->size - MDA_HEADER_SIZE);
- }
+ /* Calculate new start position within buffer rounded up to absolute alignment */
+ new_start_offset = rlocn->offset + rlocn->size +
+ (alignment - (mdac_area_start + rlocn->offset + rlocn->size) % alignment);
- /* Calculate new start position relative to start of buffer rounded up to absolute alignment */
- new_start_offset = ALIGN_ABSOLUTE(old_end, mdac_area_start, alignment);
-
- /* If new location is beyond the end of the buffer, return to start of circular buffer and realign */
- if (new_start_offset >= mdah->size) {
- /* If the start of the buffer is occupied, move past it */
- if (old_wrapped || rlocn->offset == MDA_HEADER_SIZE)
- new_start_offset = old_end;
- else
- new_start_offset = MDA_HEADER_SIZE;
-
- new_start_offset = ALIGN_ABSOLUTE(new_start_offset, mdac_area_start, alignment);
- }
+ /* If new location is beyond the end of the buffer, wrap around back to start of circular buffer */
+ if (new_start_offset > mdah->size - MDA_HEADER_SIZE)
+ new_start_offset -= (mdah->size - MDA_HEADER_SIZE);
- /*
- * Note that we don't check here that this location isn't inside the existing metadata.
- * If it is, then it means this value of alignment cannot be used.
- */
return new_start_offset;
}
@@ -583,7 +502,7 @@ static int _raw_holds_vgname(struct format_instance *fid,
if (!dev_open_readonly(dev_area->dev))
return_0;
- if (!(mdah = raw_read_mda_header(fid->fmt->cmd->mem, dev_area, 0)))
+ if (!(mdah = raw_read_mda_header(fid->fmt, dev_area, 0)))
return_0;
if (_find_vg_rlocn(dev_area, mdah, 0, vgname, &noprecommit))
@@ -600,7 +519,7 @@ static struct volume_group *_vg_read_raw_area(struct format_instance *fid,
struct device_area *area,
struct cached_vg_fmtdata **vg_fmtdata,
unsigned *use_previous_vg,
- int precommitted, unsigned ioflags,
+ int precommitted,
int single_device, int primary_mda)
{
struct volume_group *vg = NULL;
@@ -610,7 +529,7 @@ static struct volume_group *_vg_read_raw_area(struct format_instance *fid,
char *desc;
uint32_t wrap = 0;
- if (!(mdah = raw_read_mda_header(fid->fmt->cmd->mem, area, primary_mda)))
+ if (!(mdah = raw_read_mda_header(fid->fmt, area, primary_mda)))
goto_out;
if (!(rlocn = _find_vg_rlocn(area, mdah, primary_mda, vgname, &precommitted))) {
@@ -633,7 +552,7 @@ static struct volume_group *_vg_read_raw_area(struct format_instance *fid,
(off_t) (area->start + rlocn->offset),
(uint32_t) (rlocn->size - wrap),
(off_t) (area->start + MDA_HEADER_SIZE),
- wrap, calc_crc, rlocn->checksum, ioflags, &when,
+ wrap, calc_crc, rlocn->checksum, &when,
&desc)) && (!use_previous_vg || !*use_previous_vg))
goto_out;
@@ -660,7 +579,7 @@ static struct volume_group *_vg_read_raw(struct format_instance *fid,
struct metadata_area *mda,
struct cached_vg_fmtdata **vg_fmtdata,
unsigned *use_previous_vg,
- int single_device, unsigned ioflags)
+ int single_device)
{
struct mda_context *mdac = (struct mda_context *) mda->metadata_locn;
struct volume_group *vg;
@@ -668,7 +587,7 @@ static struct volume_group *_vg_read_raw(struct format_instance *fid,
if (!dev_open_readonly(mdac->area.dev))
return_NULL;
- vg = _vg_read_raw_area(fid, vgname, &mdac->area, vg_fmtdata, use_previous_vg, 0, ioflags, single_device, mda_is_primary(mda));
+ vg = _vg_read_raw_area(fid, vgname, &mdac->area, vg_fmtdata, use_previous_vg, 0, single_device, mda_is_primary(mda));
if (!dev_close(mdac->area.dev))
stack;
@@ -680,7 +599,7 @@ static struct volume_group *_vg_read_precommit_raw(struct format_instance *fid,
const char *vgname,
struct metadata_area *mda,
struct cached_vg_fmtdata **vg_fmtdata,
- unsigned *use_previous_vg, unsigned ioflags)
+ unsigned *use_previous_vg)
{
struct mda_context *mdac = (struct mda_context *) mda->metadata_locn;
struct volume_group *vg;
@@ -688,7 +607,7 @@ static struct volume_group *_vg_read_precommit_raw(struct format_instance *fid,
if (!dev_open_readonly(mdac->area.dev))
return_NULL;
- vg = _vg_read_raw_area(fid, vgname, &mdac->area, vg_fmtdata, use_previous_vg, 1, ioflags, 0, mda_is_primary(mda));
+ vg = _vg_read_raw_area(fid, vgname, &mdac->area, vg_fmtdata, use_previous_vg, 1, 0, mda_is_primary(mda));
if (!dev_close(mdac->area.dev))
stack;
@@ -696,59 +615,6 @@ static struct volume_group *_vg_read_precommit_raw(struct format_instance *fid,
return vg;
}
-static int _metadata_fits_into_buffer(struct mda_context *mdac, struct mda_header *mdah,
- struct raw_locn *rlocn, uint64_t new_wrap)
-{
- uint64_t old_wrap = 0; /* Amount of wrap around in existing metadata */
- uint64_t old_end = 0; /* The (byte after the) end of the existing metadata */
- uint64_t new_end; /* The (byte after the) end of the new metadata */
- uint64_t old_start = 0; /* The start of the existing metadata */
- uint64_t new_start = mdac->rlocn.offset; /* The proposed start of the new metadata */
-
- /*
- * If the (aligned) start of the new metadata is already beyond the end
- * of the buffer this means it didn't fit with the given alignment.
- * (The caller has already tried to wrap it back to the start
- * of the buffer but the alignment pushed it back outside.)
- */
- if (new_start >= mdah->size)
- return_0;
-
- /* Does the total amount of metadata, old and new, fit inside the buffer? */
- if (MDA_HEADER_SIZE + (rlocn ? rlocn->size : 0) + mdac->rlocn.size >= mdah->size)
- return_0;
-
- /* If there's existing metadata, set old_start, old_end and old_wrap. */
- if (rlocn) {
- old_start = rlocn->offset;
- old_end = old_start + rlocn->size;
-
- /* Does the existing metadata wrap around the end of the buffer? */
- if (old_end > mdah->size)
- old_wrap = old_end - mdah->size;
- }
-
- new_end = new_wrap ? new_wrap + MDA_HEADER_SIZE : new_start + mdac->rlocn.size;
-
- /* If both wrap around, there's necessarily overlap */
- if (new_wrap && old_wrap)
- return_0;
-
- /* If there's no existing metadata, we're OK */
- if (!rlocn)
- return 1;
-
- /* If either wraps around, there's overlap if the new end falls beyond the old start */
- if ((new_wrap || old_wrap) && (new_end > old_start))
- return_0;
-
- /* If there's no wrap, check there's no overlap */
- if (!new_wrap && !old_wrap && (old_end > new_start) && (old_start < new_end))
- return_0;
-
- return 1;
-}
-
static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
struct metadata_area *mda)
{
@@ -758,12 +624,10 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
struct mda_header *mdah;
struct pv_list *pvl;
int r = 0;
- uint64_t new_wrap = 0; /* Number of bytes of new metadata that wrap around to start of buffer */
- uint64_t alignment = MDA_ALIGNMENT;
+ uint64_t new_wrap = 0, old_wrap = 0, new_end;
int found = 0;
int noprecommit = 0;
const char *old_vg_name = NULL;
- uint64_t new_size_rounded = 0;
/* Ignore any mda on a PV outside the VG. vgsplit relies on this */
dm_list_iterate_items(pvl, &vg->pvs) {
@@ -778,19 +642,12 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
if (!found)
return 1;
- /*
- * This is paired with the following closes:
- * - at the end of this fn if returning 0
- * - in _vg_commit_raw_rlocn regardless of return code
- * which handles commit (but not pre-commit) and revert.
- */
if (!dev_open(mdac->area.dev))
return_0;
- if (!(mdah = raw_read_mda_header(fid->fmt->cmd->mem, &mdac->area, mda_is_primary(mda))))
+ if (!(mdah = raw_read_mda_header(fid->fmt, &mdac->area, mda_is_primary(mda))))
goto_out;
- /* Following space is zero-filled up to the next MDA_ALIGNMENT boundary */
if (!fidtc->raw_metadata_buf &&
!(fidtc->raw_metadata_buf_size =
text_vg_export_raw(vg, "", &fidtc->raw_metadata_buf))) {
@@ -800,64 +657,37 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
rlocn = _find_vg_rlocn(&mdac->area, mdah, mda_is_primary(mda), old_vg_name ? : vg->name, &noprecommit);
+ mdac->rlocn.offset = _next_rlocn_offset(rlocn, mdah, mdac->area.start, MDA_ORIGINAL_ALIGNMENT);
mdac->rlocn.size = fidtc->raw_metadata_buf_size;
- /* Find where the new metadata would be written with our preferred alignment */
- mdac->rlocn.offset = _next_rlocn_offset(rlocn, mdah, mdac->area.start, alignment);
-
- /* If metadata extends beyond the buffer, return to the start instead of wrapping it */
if (mdac->rlocn.offset + mdac->rlocn.size > mdah->size)
- mdac->rlocn.offset = ALIGN_ABSOLUTE(MDA_HEADER_SIZE, mdac->area.start, alignment);
+ new_wrap = (mdac->rlocn.offset + mdac->rlocn.size) - mdah->size;
- /*
- * If the metadata doesn't fit into the buffer correctly with these
- * settings, fall back to the 512-byte alignment used by the original
- * LVM2 code and allow the metadata to be split into two parts,
- * wrapping around from the end of the circular buffer back to the
- * beginning.
- */
- if (!_metadata_fits_into_buffer(mdac, mdah, rlocn, 0)) {
- alignment = MDA_ORIGINAL_ALIGNMENT;
- mdac->rlocn.offset = _next_rlocn_offset(rlocn, mdah, mdac->area.start, alignment);
+ if (rlocn && (rlocn->offset + rlocn->size > mdah->size))
+ old_wrap = (rlocn->offset + rlocn->size) - mdah->size;
- /* Does the new metadata wrap around? */
- if (mdac->rlocn.offset + mdac->rlocn.size > mdah->size)
- new_wrap = (mdac->rlocn.offset + mdac->rlocn.size) - mdah->size;
- else
- new_wrap = 0;
-
- if (!_metadata_fits_into_buffer(mdac, mdah, rlocn, new_wrap)) {
- log_error("VG %s metadata on %s (" FMTu64 " bytes) too large for circular buffer (" FMTu64 " bytes with " FMTu64 " used)",
- vg->name, dev_name(mdac->area.dev), mdac->rlocn.size, mdah->size - MDA_HEADER_SIZE, rlocn ? rlocn->size : 0);
- goto out;
- }
+ new_end = new_wrap ? new_wrap + MDA_HEADER_SIZE :
+ mdac->rlocn.offset + mdac->rlocn.size;
- new_size_rounded = mdac->rlocn.size;
- } else {
- /* Round up to a multiple of the new alignment */
- if (mdac->rlocn.offset + new_size_rounded < mdah->size)
- new_size_rounded = (mdac->rlocn.size | (alignment - 1)) + 1;
- else
- new_size_rounded = mdac->rlocn.size;
+ if ((new_wrap && old_wrap) ||
+ (rlocn && (new_wrap || old_wrap) && (new_end > rlocn->offset)) ||
+ (MDA_HEADER_SIZE + (rlocn ? rlocn->size : 0) + mdac->rlocn.size >= mdah->size)) {
+ log_error("VG %s metadata on %s (" FMTu64 " bytes) too large for circular buffer (" FMTu64 " bytes with " FMTu64 " used)",
+ vg->name, dev_name(mdac->area.dev), mdac->rlocn.size, mdah->size - MDA_HEADER_SIZE, rlocn ? rlocn->size : 0);
+ goto out;
}
- log_debug_metadata("Writing %s metadata to %s at " FMTu64 " len " FMTu64 " (rounded to " FMTu64 ") of " FMTu64 " aligned to " FMTu64,
+ log_debug_metadata("Writing %s metadata to %s at " FMTu64 " len " FMTu64 " of " FMTu64,
vg->name, dev_name(mdac->area.dev), mdac->area.start +
- mdac->rlocn.offset, mdac->rlocn.size - new_wrap, new_size_rounded, mdac->rlocn.size, alignment);
+ mdac->rlocn.offset, mdac->rlocn.size - new_wrap, mdac->rlocn.size);
- if (!new_wrap) {
- /* Write text out, in alignment-sized blocks */
- if (!dev_write(mdac->area.dev, mdac->area.start + mdac->rlocn.offset,
- (size_t) new_size_rounded, MDA_CONTENT_REASON(mda_is_primary(mda)),
- fidtc->raw_metadata_buf))
- goto_out;
- } else {
- /* Write text out, circularly */
- if (!dev_write(mdac->area.dev, mdac->area.start + mdac->rlocn.offset,
- (size_t) (mdac->rlocn.size - new_wrap), MDA_CONTENT_REASON(mda_is_primary(mda)),
- fidtc->raw_metadata_buf))
- goto_out;
+ /* Write text out, circularly */
+ if (!dev_write(mdac->area.dev, mdac->area.start + mdac->rlocn.offset,
+ (size_t) (mdac->rlocn.size - new_wrap), MDA_CONTENT_REASON(mda_is_primary(mda)),
+ fidtc->raw_metadata_buf))
+ goto_out;
+ if (new_wrap) {
log_debug_metadata("Writing wrapped metadata to %s at " FMTu64 " len " FMTu64 " of " FMTu64,
dev_name(mdac->area.dev), mdac->area.start +
MDA_HEADER_SIZE, new_wrap, mdac->rlocn.size);
@@ -919,7 +749,7 @@ static int _vg_commit_raw_rlocn(struct format_instance *fid,
if (!found)
return 1;
- if (!(mdah = raw_read_mda_header(fid->fmt->cmd->mem, &mdac->area, mda_is_primary(mda))))
+ if (!(mdah = raw_read_mda_header(fid->fmt, &mdac->area, mda_is_primary(mda))))
goto_out;
if (!(rlocn = _find_vg_rlocn(&mdac->area, mdah, mda_is_primary(mda), old_vg_name ? : vg->name, &noprecommit))) {
@@ -957,9 +787,10 @@ static int _vg_commit_raw_rlocn(struct format_instance *fid,
rlocn->offset = mdac->rlocn.offset;
rlocn->size = mdac->rlocn.size;
rlocn->checksum = mdac->rlocn.checksum;
- log_debug_metadata("%sCommitting %s %smetadata (%u) to %s header at " FMTu64 " (offset " FMTu64 ", size " FMTu64 ")",
- precommit ? "Pre-" : "", vg->name, mda_is_ignored(mda) ? "(ignored) " : "", vg->seqno,
- dev_name(mdac->area.dev), mdac->area.start, mdac->rlocn.offset, mdac->rlocn.size);
+ log_debug_metadata("%sCommitting %s %smetadata (%u) to %s header at "
+ FMTu64, precommit ? "Pre-" : "", vg->name,
+ mda_is_ignored(mda) ? "(ignored) " : "", vg->seqno,
+ dev_name(mdac->area.dev), mdac->area.start);
} else
log_debug_metadata("Wiping pre-committed %s %smetadata from %s "
"header at " FMTu64, vg->name,
@@ -979,7 +810,6 @@ static int _vg_commit_raw_rlocn(struct format_instance *fid,
out:
if (!precommit) {
- /* This is an paired with the open at the start of _vg_write_raw */
if (!dev_close(mdac->area.dev))
stack;
@@ -1039,7 +869,7 @@ static int _vg_remove_raw(struct format_instance *fid, struct volume_group *vg,
if (!dev_open(mdac->area.dev))
return_0;
- if (!(mdah = raw_read_mda_header(fid->fmt->cmd->mem, &mdac->area, mda_is_primary(mda))))
+ if (!(mdah = raw_read_mda_header(fid->fmt, &mdac->area, mda_is_primary(mda))))
goto_out;
if (!(rlocn = _find_vg_rlocn(&mdac->area, mdah, mda_is_primary(mda), vg->name, &noprecommit))) {
@@ -1102,8 +932,7 @@ static struct volume_group *_vg_read_file(struct format_instance *fid,
struct metadata_area *mda,
struct cached_vg_fmtdata **vg_fmtdata,
unsigned *use_previous_vg __attribute__((unused)),
- int single_device __attribute__((unused)),
- unsigned ioflags __attribute__((unused)))
+ int single_device __attribute__((unused)))
{
struct text_context *tc = (struct text_context *) mda->metadata_locn;
@@ -1114,8 +943,7 @@ static struct volume_group *_vg_read_precommit_file(struct format_instance *fid,
const char *vgname,
struct metadata_area *mda,
struct cached_vg_fmtdata **vg_fmtdata,
- unsigned *use_previous_vg __attribute__((unused)),
- unsigned ioflags __attribute__((unused)))
+ unsigned *use_previous_vg __attribute__((unused)))
{
struct text_context *tc = (struct text_context *) mda->metadata_locn;
struct volume_group *vg;
@@ -1347,83 +1175,41 @@ static int _scan_file(const struct format_type *fmt, const char *vgname)
return 1;
}
-struct vgname_from_mda_params{
- const struct format_type *fmt;
- const struct mda_header *mdah;
- struct device_area *dev_area;
- int primary_mda;
- struct lvmcache_vgsummary *vgsummary;
- uint64_t *mda_free_sectors;
- lvm_callback_fn_t update_vgsummary_fn;
- void *update_vgsummary_context;
- uint32_t wrap;
- unsigned used_cached_metadata;
- int ret;
-};
-
-static void _vgname_from_mda_process(int failed, unsigned ioflags, void *context, const void *data)
+int vgname_from_mda(const struct format_type *fmt,
+ struct mda_header *mdah, int primary_mda, struct device_area *dev_area,
+ struct lvmcache_vgsummary *vgsummary, uint64_t *mda_free_sectors)
{
- struct vgname_from_mda_params *vfmp = context;
- const struct mda_header *mdah = vfmp->mdah;
- struct device_area *dev_area = vfmp->dev_area;
- struct lvmcache_vgsummary *vgsummary = vfmp->vgsummary;
- uint64_t *mda_free_sectors = vfmp->mda_free_sectors;
- const struct raw_locn *rlocn = mdah->raw_locns;
+ struct raw_locn *rlocn;
+ uint32_t wrap = 0;
+ unsigned int len = 0;
+ char buf[NAME_LEN + 1] __attribute__((aligned(8)));
uint64_t buffer_size, current_usage;
+ unsigned used_cached_metadata = 0;
- if (failed) {
- vfmp->ret = 0;
- goto_out;
- }
-
- /* Ignore this entry if the characters aren't permissible */
- if (!validate_name(vgsummary->vgname)) {
- vfmp->ret = 0;
- goto_out;
- }
-
- log_debug_metadata("%s: %s metadata at " FMTu64 " size " FMTu64 " with wrap " FMTu32
- " (in area at " FMTu64 " size " FMTu64
- ") for %s (" FMTVGID ")",
- dev_name(dev_area->dev),
- vfmp->used_cached_metadata ? "Using cached" : "Found",
- dev_area->start + rlocn->offset,
- rlocn->size, vfmp->wrap, dev_area->start, dev_area->size, vgsummary->vgname,
- (char *)&vgsummary->vgid);
-
- if (mda_free_sectors) {
- current_usage = ALIGN_ABSOLUTE(rlocn->size, dev_area->start + rlocn->offset, MDA_ALIGNMENT);
-
- buffer_size = mdah->size - MDA_HEADER_SIZE;
+ if (mda_free_sectors)
+ *mda_free_sectors = ((dev_area->size - MDA_HEADER_SIZE) / 2) >> SECTOR_SHIFT;
- if (current_usage * 2 >= buffer_size)
- *mda_free_sectors = UINT64_C(0);
- else
- *mda_free_sectors = ((buffer_size - 2 * current_usage) / 2) >> SECTOR_SHIFT;
+ if (!mdah) {
+ log_error(INTERNAL_ERROR "vgname_from_mda called with NULL pointer for mda_header");
+ return 0;
}
-out:
- vfmp->update_vgsummary_fn(!vfmp->ret, ioflags, vfmp->update_vgsummary_context, vfmp->vgsummary);
-}
-
-static void _vgname_from_mda_validate(int failed, unsigned ioflags, void *context, const void *data)
-{
- struct vgname_from_mda_params *vfmp = context;
- const char *buffer = data;
- const struct format_type *fmt = vfmp->fmt;
- const struct mda_header *mdah = vfmp->mdah;
- struct device_area *dev_area = vfmp->dev_area;
- struct lvmcache_vgsummary *vgsummary = vfmp->vgsummary;
- const struct raw_locn *rlocn = mdah->raw_locns;
- unsigned len = 0;
- char buf[NAME_LEN + 1] __attribute__((aligned(8)));
+ /* FIXME Cope with returning a list */
+ rlocn = mdah->raw_locns;
- if (failed) {
- vfmp->ret = 0;
- goto_out;
+ /*
+ * If no valid offset, do not try to search for vgname
+ */
+ if (!rlocn->offset) {
+ log_debug("%s: found metadata with offset 0.",
+ dev_name(dev_area->dev));
+ return 0;
}
- memcpy(buf, buffer, NAME_LEN);
+ /* Do quick check for a vgname */
+ if (!dev_read(dev_area->dev, dev_area->start + rlocn->offset,
+ NAME_LEN, MDA_CONTENT_REASON(primary_mda), buf))
+ return_0;
while (buf[len] && !isspace(buf[len]) && buf[len] != '{' &&
len < (NAME_LEN - 1))
@@ -1432,20 +1218,17 @@ static void _vgname_from_mda_validate(int failed, unsigned ioflags, void *contex
buf[len] = '\0';
/* Ignore this entry if the characters aren't permissible */
- if (!validate_name(buf)) {
- vfmp->ret = 0;
- goto_out;
- }
+ if (!validate_name(buf))
+ return_0;
/* We found a VG - now check the metadata */
if (rlocn->offset + rlocn->size > mdah->size)
- vfmp->wrap = (uint32_t) ((rlocn->offset + rlocn->size) - mdah->size);
+ wrap = (uint32_t) ((rlocn->offset + rlocn->size) - mdah->size);
- if (vfmp->wrap > rlocn->offset) {
+ if (wrap > rlocn->offset) {
log_error("%s: metadata (" FMTu64 " bytes) too large for circular buffer (" FMTu64 " bytes)",
dev_name(dev_area->dev), rlocn->size, mdah->size - MDA_HEADER_SIZE);
- vfmp->ret = 0;
- goto out;
+ return 0;
}
/* Did we see this metadata before? */
@@ -1453,75 +1236,42 @@ static void _vgname_from_mda_validate(int failed, unsigned ioflags, void *contex
vgsummary->mda_size = rlocn->size;
if (lvmcache_lookup_mda(vgsummary))
- vfmp->used_cached_metadata = 1;
+ used_cached_metadata = 1;
/* FIXME 64-bit */
- if (!text_vgsummary_import(fmt, dev_area->dev, MDA_CONTENT_REASON(vfmp->primary_mda),
+ if (!text_vgsummary_import(fmt, dev_area->dev, MDA_CONTENT_REASON(primary_mda),
(off_t) (dev_area->start + rlocn->offset),
- (uint32_t) (rlocn->size - vfmp->wrap),
+ (uint32_t) (rlocn->size - wrap),
(off_t) (dev_area->start + MDA_HEADER_SIZE),
- vfmp->wrap, calc_crc, vgsummary->vgname ? 1 : 0, ioflags,
- vgsummary, _vgname_from_mda_process, vfmp)) {
- vfmp->ret = 0;
- goto_out;
- }
-
-out:
- if (!vfmp->ret && vfmp->update_vgsummary_fn)
- vfmp->update_vgsummary_fn(1, ioflags, vfmp->update_vgsummary_context, vfmp->vgsummary);
-}
-
-int vgname_from_mda(const struct format_type *fmt,
- const struct mda_header *mdah, int primary_mda, struct device_area *dev_area,
- struct lvmcache_vgsummary *vgsummary, uint64_t *mda_free_sectors, unsigned ioflags,
- lvm_callback_fn_t update_vgsummary_fn, void *update_vgsummary_context)
-{
- const struct raw_locn *rlocn;
- struct vgname_from_mda_params *vfmp;
-
- if (mda_free_sectors)
- *mda_free_sectors = ((dev_area->size - MDA_HEADER_SIZE) / 2) >> SECTOR_SHIFT;
+ wrap, calc_crc, vgsummary->vgname ? 1 : 0,
+ vgsummary))
+ return_0;
- if (!mdah) {
- log_error(INTERNAL_ERROR "vgname_from_mda called with NULL pointer for mda_header");
- return 0;
- }
+ /* Ignore this entry if the characters aren't permissible */
+ if (!validate_name(vgsummary->vgname))
+ return_0;
- /* FIXME Cope with returning a list */
- rlocn = mdah->raw_locns;
+ log_debug_metadata("%s: %s metadata at " FMTu64 " size " FMTu64
+ " (in area at " FMTu64 " size " FMTu64
+ ") for %s (" FMTVGID ")",
+ dev_name(dev_area->dev),
+ used_cached_metadata ? "Using cached" : "Found",
+ dev_area->start + rlocn->offset,
+ rlocn->size, dev_area->start, dev_area->size, vgsummary->vgname,
+ (char *)&vgsummary->vgid);
- /*
- * If no valid offset, do not try to search for vgname
- */
- if (!rlocn->offset) {
- log_debug("%s: found metadata with offset 0.",
- dev_name(dev_area->dev));
- return 0;
- }
+ if (mda_free_sectors) {
+ current_usage = (rlocn->size + SECTOR_SIZE - UINT64_C(1)) -
+ (rlocn->size + SECTOR_SIZE - UINT64_C(1)) % SECTOR_SIZE;
+ buffer_size = mdah->size - MDA_HEADER_SIZE;
- if (!(vfmp = dm_pool_zalloc(fmt->cmd->mem, sizeof(*vfmp)))) {
- log_error("vgname_from_mda_params allocation failed");
- return 0;
+ if (current_usage * 2 >= buffer_size)
+ *mda_free_sectors = UINT64_C(0);
+ else
+ *mda_free_sectors = ((buffer_size - 2 * current_usage) / 2) >> SECTOR_SHIFT;
}
- vfmp->fmt = fmt;
- vfmp->mdah = mdah;
- vfmp->dev_area = dev_area;
- vfmp->vgsummary = vgsummary;
- vfmp->primary_mda = primary_mda;
- vfmp->mda_free_sectors = mda_free_sectors;
- vfmp->update_vgsummary_fn = update_vgsummary_fn;
- vfmp->update_vgsummary_context = update_vgsummary_context;
- vfmp->ret = 1;
-
- /* Do quick check for a vgname */
- /* We cannot read the full metadata here because the name has to be validated before we use the size field */
- dev_read_callback(dev_area->dev, dev_area->start + rlocn->offset, NAME_LEN, MDA_CONTENT_REASON(primary_mda),
- ioflags, _vgname_from_mda_validate, vfmp);
- if (update_vgsummary_fn)
- return 1;
- else
- return vfmp->ret;
+ return 1;
}
static int _scan_raw(const struct format_type *fmt, const char *vgname __attribute__((unused)))
@@ -1546,14 +1296,14 @@ static int _scan_raw(const struct format_type *fmt, const char *vgname __attribu
continue;
}
- if (!(mdah = raw_read_mda_header(fmt->cmd->mem, &rl->dev_area, 0))) {
+ if (!(mdah = raw_read_mda_header(fmt, &rl->dev_area, 0))) {
stack;
goto close_dev;
}
/* TODO: caching as in vgname_from_mda() (trigger this code?) */
- if (vgname_from_mda(fmt, mdah, 0, &rl->dev_area, &vgsummary, NULL, 0, NULL, NULL)) {
- vg = _vg_read_raw_area(&fid, vgsummary.vgname, &rl->dev_area, NULL, NULL, 0, 0, 0, 0);
+ if (vgname_from_mda(fmt, mdah, 0, &rl->dev_area, &vgsummary, NULL)) {
+ vg = _vg_read_raw_area(&fid, vgsummary.vgname, &rl->dev_area, NULL, NULL, 0, 0, 0);
if (vg)
lvmcache_update_vg(vg, 0);
}
@@ -2024,8 +1774,9 @@ static int _mda_export_text_raw(struct metadata_area *mda,
struct dm_config_node *parent)
{
struct mda_context *mdc = (struct mda_context *) mda->metadata_locn;
+ char mdah[MDA_HEADER_SIZE]; /* temporary */
- if (!mdc || !_raw_read_mda_header(cft->mem, &mdc->area, mda_is_primary(mda), 0, NULL, NULL))
+ if (!mdc || !_raw_read_mda_header((struct mda_header *)mdah, &mdc->area, mda_is_primary(mda)))
return 1; /* pretend the MDA does not exist */
return config_make_nodes(cft, parent, NULL,
diff --git a/lib/format_text/import-export.h b/lib/format_text/import-export.h
index 2c329d0..894d881 100644
--- a/lib/format_text/import-export.h
+++ b/lib/format_text/import-export.h
@@ -80,7 +80,7 @@ struct volume_group *text_vg_import_fd(struct format_instance *fid,
off_t offset, uint32_t size,
off_t offset2, uint32_t size2,
checksum_fn_t checksum_fn,
- uint32_t checksum, unsigned ioflags,
+ uint32_t checksum,
time_t *when, char **desc);
int text_vgsummary_import(const struct format_type *fmt,
@@ -88,9 +88,7 @@ int text_vgsummary_import(const struct format_type *fmt,
off_t offset, uint32_t size,
off_t offset2, uint32_t size2,
checksum_fn_t checksum_fn,
- int checksum_only, unsigned ioflags,
- struct lvmcache_vgsummary *vgsummary,
- lvm_callback_fn_t process_vgsummary_fn,
- void *process_vgsummary_context);
+ int checksum_only,
+ struct lvmcache_vgsummary *vgsummary);
#endif
diff --git a/lib/format_text/import.c b/lib/format_text/import.c
index 0138ddd..da4cefd 100644
--- a/lib/format_text/import.c
+++ b/lib/format_text/import.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2018 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -16,7 +16,6 @@
#include "lib.h"
#include "metadata.h"
#include "import-export.h"
-#include "toolcontext.h"
/* FIXME Use tidier inclusion method */
static struct text_vg_version_ops *(_text_vsn_list[2]);
@@ -33,55 +32,6 @@ static void _init_text_import(void)
_text_import_initialised = 1;
}
-struct import_vgsummary_params {
- const struct format_type *fmt;
- struct dm_config_tree *cft;
- int checksum_only;
- struct lvmcache_vgsummary *vgsummary;
- lvm_callback_fn_t process_vgsummary_fn;
- void *process_vgsummary_context;
- int ret;
-};
-
-static void _import_vgsummary(int failed, unsigned ioflags, void *context, const void *data)
-{
- struct import_vgsummary_params *ivsp = context;
- struct text_vg_version_ops **vsn;
-
- if (failed) {
- ivsp->ret = 0;
- goto_out;
- }
-
- if (ivsp->checksum_only)
- /* Checksum matches already-cached content - no need to reparse. */
- goto out;
-
- /*
- * Find a set of version functions that can read this file
- */
- for (vsn = &_text_vsn_list[0]; *vsn; vsn++) {
- if (!(*vsn)->check_version(ivsp->cft))
- continue;
-
- if (!(*vsn)->read_vgsummary(ivsp->fmt, ivsp->cft, ivsp->vgsummary)) {
- ivsp->ret = 0;
- goto_out;
- }
-
- goto out;
- }
-
- /* Nothing found */
- ivsp->ret = 0;
-
-out:
- config_destroy(ivsp->cft);
-
- if (ivsp->process_vgsummary_fn)
- ivsp->process_vgsummary_fn(!ivsp->ret, ioflags, ivsp->process_vgsummary_context, NULL);
-}
-
/*
* Find out vgname on a given device.
*/
@@ -90,76 +40,30 @@ int text_vgsummary_import(const struct format_type *fmt,
off_t offset, uint32_t size,
off_t offset2, uint32_t size2,
checksum_fn_t checksum_fn,
- int checksum_only, unsigned ioflags,
- struct lvmcache_vgsummary *vgsummary,
- lvm_callback_fn_t process_vgsummary_fn,
- void *process_vgsummary_context)
+ int checksum_only,
+ struct lvmcache_vgsummary *vgsummary)
{
- struct import_vgsummary_params *ivsp;
+ struct dm_config_tree *cft;
+ struct text_vg_version_ops **vsn;
+ int r = 0;
_init_text_import();
- if (!(ivsp = dm_pool_zalloc(fmt->cmd->mem, sizeof(*ivsp)))) {
- log_error("Failed to allocate import_vgsummary_params struct.");
- return 0;
- }
-
- if (!(ivsp->cft = config_open(CONFIG_FILE_SPECIAL, NULL, 0)))
+ if (!(cft = config_open(CONFIG_FILE_SPECIAL, NULL, 0)))
return_0;
- ivsp->fmt = fmt;
- ivsp->checksum_only = checksum_only;
- ivsp->vgsummary = vgsummary;
- ivsp->process_vgsummary_fn = process_vgsummary_fn;
- ivsp->process_vgsummary_context = process_vgsummary_context;
- ivsp->ret = 1;
-
- if (!dev) {
- if (!config_file_read(fmt->cmd->mem, ivsp->cft)) {
- log_error("Couldn't read volume group metadata.");
- ivsp->ret = 0;
- }
- _import_vgsummary(!ivsp->ret, ioflags, ivsp, NULL);
- } else if (!config_file_read_fd(fmt->cmd->mem, ivsp->cft, dev, reason, offset, size,
- offset2, size2, checksum_fn,
- vgsummary->mda_checksum,
- checksum_only, 1, ioflags, &_import_vgsummary, ivsp)) {
+ if ((!dev && !config_file_read(cft)) ||
+ (dev && !config_file_read_fd(cft, dev, reason, offset, size,
+ offset2, size2, checksum_fn,
+ vgsummary->mda_checksum,
+ checksum_only, 1))) {
log_error("Couldn't read volume group metadata.");
- return 0;
+ goto out;
}
- return ivsp->ret;
-}
-
-struct cached_vg_fmtdata {
- uint32_t cached_mda_checksum;
- size_t cached_mda_size;
-};
-
-struct import_vg_params {
- struct format_instance *fid;
- struct dm_config_tree *cft;
- int single_device;
- int skip_parse;
- unsigned *use_previous_vg;
- struct volume_group *vg;
- uint32_t checksum;
- uint32_t total_size;
- time_t *when;
- struct cached_vg_fmtdata **vg_fmtdata;
- char **desc;
-};
-
-static void _import_vg(int failed, unsigned ioflags, void *context, const void *data)
-{
- struct import_vg_params *ivp = context;
- struct text_vg_version_ops **vsn;
-
- ivp->vg = NULL;
-
- if (ivp->skip_parse) {
- if (ivp->use_previous_vg)
- *ivp->use_previous_vg = 1;
+ if (checksum_only) {
+ /* Checksum matches already-cached content - no need to reparse. */
+ r = 1;
goto out;
}
@@ -167,28 +71,26 @@ static void _import_vg(int failed, unsigned ioflags, void *context, const void *
* Find a set of version functions that can read this file
*/
for (vsn = &_text_vsn_list[0]; *vsn; vsn++) {
- if (!(*vsn)->check_version(ivp->cft))
+ if (!(*vsn)->check_version(cft))
continue;
- if (!(ivp->vg = (*vsn)->read_vg(ivp->fid, ivp->cft, ivp->single_device, 0)))
+ if (!(*vsn)->read_vgsummary(fmt, cft, vgsummary))
goto_out;
- (*vsn)->read_desc(ivp->vg->vgmem, ivp->cft, ivp->when, ivp->desc);
+ r = 1;
break;
}
- if (ivp->vg && ivp->vg_fmtdata && *ivp->vg_fmtdata) {
- (*ivp->vg_fmtdata)->cached_mda_size = ivp->total_size;
- (*ivp->vg_fmtdata)->cached_mda_checksum = ivp->checksum;
- }
-
- if (ivp->use_previous_vg)
- *ivp->use_previous_vg = 0;
-
-out:
- config_destroy(ivp->cft);
+ out:
+ config_destroy(cft);
+ return r;
}
+struct cached_vg_fmtdata {
+ uint32_t cached_mda_checksum;
+ size_t cached_mda_size;
+};
+
struct volume_group *text_vg_import_fd(struct format_instance *fid,
const char *file,
struct cached_vg_fmtdata **vg_fmtdata,
@@ -198,10 +100,13 @@ struct volume_group *text_vg_import_fd(struct format_instance *fid,
off_t offset, uint32_t size,
off_t offset2, uint32_t size2,
checksum_fn_t checksum_fn,
- uint32_t checksum, unsigned ioflags,
+ uint32_t checksum,
time_t *when, char **desc)
{
- struct import_vg_params *ivp;
+ struct volume_group *vg = NULL;
+ struct dm_config_tree *cft;
+ struct text_vg_version_ops **vsn;
+ int skip_parse;
if (vg_fmtdata && !*vg_fmtdata &&
!(*vg_fmtdata = dm_pool_zalloc(fid->mem, sizeof(**vg_fmtdata)))) {
@@ -209,48 +114,56 @@ struct volume_group *text_vg_import_fd(struct format_instance *fid,
return NULL;
}
- if (!(ivp = dm_pool_zalloc(fid->fmt->cmd->mem, sizeof(*ivp)))) {
- log_error("Failed to allocate import_vgsummary_params struct.");
- return NULL;
- }
-
_init_text_import();
- ivp->fid = fid;
- ivp->when = when;
- *ivp->when = 0;
- ivp->desc = desc;
- *ivp->desc = NULL;
- ivp->single_device = single_device;
- ivp->use_previous_vg = use_previous_vg;
- ivp->checksum = checksum;
- ivp->total_size = size + size2;
- ivp->vg_fmtdata = vg_fmtdata;
-
- if (!(ivp->cft = config_open(CONFIG_FILE_SPECIAL, file, 0)))
+ *desc = NULL;
+ *when = 0;
+
+ if (!(cft = config_open(CONFIG_FILE_SPECIAL, file, 0)))
return_NULL;
/* Does the metadata match the already-cached VG? */
- ivp->skip_parse = vg_fmtdata &&
- ((*vg_fmtdata)->cached_mda_checksum == checksum) &&
- ((*vg_fmtdata)->cached_mda_size == ivp->total_size);
+ skip_parse = vg_fmtdata &&
+ ((*vg_fmtdata)->cached_mda_checksum == checksum) &&
+ ((*vg_fmtdata)->cached_mda_size == (size + size2));
+
+ if ((!dev && !config_file_read(cft)) ||
+ (dev && !config_file_read_fd(cft, dev, MDA_CONTENT_REASON(primary_mda), offset, size,
+ offset2, size2, checksum_fn, checksum,
+ skip_parse, 1)))
+ goto_out;
- if (!dev && !config_file_read(fid->mem, ivp->cft)) {
- config_destroy(ivp->cft);
- return_NULL;
+ if (skip_parse) {
+ if (use_previous_vg)
+ *use_previous_vg = 1;
+ goto out;
}
- if (dev) {
- if (!config_file_read_fd(fid->mem, ivp->cft, dev, MDA_CONTENT_REASON(primary_mda), offset, size,
- offset2, size2, checksum_fn, checksum,
- ivp->skip_parse, 1, ioflags, &_import_vg, ivp)) {
- config_destroy(ivp->cft);
- return_NULL;
- }
- } else
- _import_vg(0, 0, ivp, NULL);
+ /*
+ * Find a set of version functions that can read this file
+ */
+ for (vsn = &_text_vsn_list[0]; *vsn; vsn++) {
+ if (!(*vsn)->check_version(cft))
+ continue;
+
+ if (!(vg = (*vsn)->read_vg(fid, cft, single_device, 0)))
+ goto_out;
+
+ (*vsn)->read_desc(vg->vgmem, cft, when, desc);
+ break;
+ }
+
+ if (vg && vg_fmtdata && *vg_fmtdata) {
+ (*vg_fmtdata)->cached_mda_size = (size + size2);
+ (*vg_fmtdata)->cached_mda_checksum = checksum;
+ }
- return ivp->vg;
+ if (use_previous_vg)
+ *use_previous_vg = 0;
+
+ out:
+ config_destroy(cft);
+ return vg;
}
struct volume_group *text_vg_import_file(struct format_instance *fid,
@@ -258,7 +171,7 @@ struct volume_group *text_vg_import_file(struct format_instance *fid,
time_t *when, char **desc)
{
return text_vg_import_fd(fid, file, NULL, NULL, 0, NULL, 0, (off_t)0, 0, (off_t)0, 0, NULL, 0,
- 0, when, desc);
+ when, desc);
}
static struct volume_group *_import_vg_from_config_tree(const struct dm_config_tree *cft,
diff --git a/lib/format_text/layout.h b/lib/format_text/layout.h
index 98a0b36..1746b9c 100644
--- a/lib/format_text/layout.h
+++ b/lib/format_text/layout.h
@@ -17,7 +17,6 @@
#define _LVM_TEXT_LAYOUT_H
#include "config.h"
-#include "format-text.h"
#include "metadata.h"
#include "lvmcache.h"
#include "uuid.h"
@@ -81,9 +80,8 @@ struct mda_header {
struct raw_locn raw_locns[0]; /* NULL-terminated list */
} __attribute__ ((packed));
-struct mda_header *raw_read_mda_header(struct dm_pool *mem, struct device_area *dev_area, int primary_mda);
-int raw_read_mda_header_callback(struct dm_pool *mem, struct device_area *dev_area, int primary_mda,
- unsigned ioflags, lvm_callback_fn_t mdah_callback_fn, void *mdah_callback_context);
+struct mda_header *raw_read_mda_header(const struct format_type *fmt,
+ struct device_area *dev_area, int primary_mda);
struct mda_lists {
struct dm_list dirs;
@@ -105,11 +103,9 @@ struct mda_context {
#define LVM2_LABEL "LVM2 001"
#define MDA_SIZE_MIN (8 * (unsigned) lvm_getpagesize())
#define MDA_ORIGINAL_ALIGNMENT 512 /* Original alignment used for start of VG metadata content */
-#define MDA_ALIGNMENT 4096 /* Default alignment in bytes since 2.02.177 for start of VG metadata content. */
-int vgname_from_mda(const struct format_type *fmt, const struct mda_header *mdah, int primary_mda,
+int vgname_from_mda(const struct format_type *fmt, struct mda_header *mdah, int primary_mda,
struct device_area *dev_area, struct lvmcache_vgsummary *vgsummary,
- uint64_t *mda_free_sectors, unsigned ioflags,
- lvm_callback_fn_t update_vgsummary_callback_fn, void *update_vgsummary_callback_context);
+ uint64_t *mda_free_sectors);
#endif
diff --git a/lib/format_text/text_label.c b/lib/format_text/text_label.c
index 45136e9..7058f70 100644
--- a/lib/format_text/text_label.c
+++ b/lib/format_text/text_label.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2018 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -19,7 +19,6 @@
#include "label.h"
#include "xlate.h"
#include "lvmcache.h"
-#include "toolcontext.h"
#include <sys/stat.h>
#include <fcntl.h>
@@ -36,14 +35,14 @@ static int _text_can_handle(struct labeller *l __attribute__((unused)),
return 0;
}
-struct dl_setup_baton {
+struct _dl_setup_baton {
struct disk_locn *pvh_dlocn_xl;
struct device *dev;
};
static int _da_setup(struct disk_locn *da, void *baton)
{
- struct dl_setup_baton *p = baton;
+ struct _dl_setup_baton *p = baton;
p->pvh_dlocn_xl->offset = xlate64(da->offset);
p->pvh_dlocn_xl->size = xlate64(da->size);
p->pvh_dlocn_xl++;
@@ -57,7 +56,7 @@ static int _ba_setup(struct disk_locn *ba, void *baton)
static int _mda_setup(struct metadata_area *mda, void *baton)
{
- struct dl_setup_baton *p = baton;
+ struct _dl_setup_baton *p = baton;
struct mda_context *mdac = (struct mda_context *) mda->metadata_locn;
if (mdac->area.dev != p->dev)
@@ -72,7 +71,7 @@ static int _mda_setup(struct metadata_area *mda, void *baton)
static int _dl_null_termination(void *baton)
{
- struct dl_setup_baton *p = baton;
+ struct _dl_setup_baton *p = baton;
p->pvh_dlocn_xl->offset = xlate64(UINT64_C(0));
p->pvh_dlocn_xl->size = xlate64(UINT64_C(0));
@@ -87,7 +86,7 @@ static int _text_write(struct label *label, void *buf)
struct pv_header *pvhdr;
struct pv_header_extension *pvhdr_ext;
struct lvmcache_info *info;
- struct dl_setup_baton baton;
+ struct _dl_setup_baton baton;
char buffer[64] __attribute__((aligned(8)));
int ba1, da1, mda1, mda2;
@@ -319,106 +318,18 @@ static int _text_initialise_label(struct labeller *l __attribute__((unused)),
return 1;
}
-struct update_mda_baton {
+struct _update_mda_baton {
struct lvmcache_info *info;
struct label *label;
- int nr_outstanding_mdas;
- unsigned ioflags;
- lvm_callback_fn_t read_label_callback_fn;
- void *read_label_callback_context;
- int ret;
};
-struct process_mda_header_params {
- struct update_mda_baton *umb;
- struct metadata_area *mda;
- struct device *dev;
- struct lvmcache_vgsummary vgsummary;
- int ret;
-};
-
-static void _process_vgsummary(int failed, unsigned ioflags, void *context, const void *data)
-{
- struct process_mda_header_params *pmp = context;
- const struct lvmcache_vgsummary *vgsummary = data;
-
- --pmp->umb->nr_outstanding_mdas;
-
- /* FIXME Need to distinguish genuine errors here */
- if (failed)
- goto_out;
-
- if (!lvmcache_update_vgname_and_id(pmp->umb->info, vgsummary)) {
- pmp->umb->ret = 0;
- pmp->ret = 0;
- }
-
-out:
- if (!pmp->umb->nr_outstanding_mdas && pmp->umb->ret)
- lvmcache_make_valid(pmp->umb->info);
-
- if (!dev_close(pmp->dev))
- stack;
-
- if (!pmp->umb->nr_outstanding_mdas && pmp->umb->read_label_callback_fn)
- pmp->umb->read_label_callback_fn(!pmp->umb->ret, ioflags, pmp->umb->read_label_callback_context, pmp->umb->label);
-}
-
-static void _process_mda_header(int failed, unsigned ioflags, void *context, const void *data)
-{
- struct process_mda_header_params *pmp = context;
- const struct mda_header *mdah = data;
- struct update_mda_baton *umb = pmp->umb;
- const struct format_type *fmt = umb->label->labeller->fmt;
- struct metadata_area *mda = pmp->mda;
- struct mda_context *mdac = (struct mda_context *) mda->metadata_locn;
-
- if (failed)
- goto_bad;
-
- mda_set_ignored(mda, rlocn_is_ignored(mdah->raw_locns));
-
- if (mda_is_ignored(mda)) {
- log_debug_metadata("Ignoring mda on device %s at offset " FMTu64,
- dev_name(mdac->area.dev),
- mdac->area.start);
- goto bad;
- }
-
- if (!vgname_from_mda(fmt, mdah, mda_is_primary(mda), &mdac->area, &pmp->vgsummary, &mdac->free_sectors, ioflags, _process_vgsummary, pmp)) {
- /* FIXME Separate fatal and non-fatal error cases? */
- goto_bad;
- }
-
- return;
-
-bad:
- _process_vgsummary(1, ioflags, pmp, NULL);
- return;
-}
-
-static int _count_mda(struct metadata_area *mda, void *baton)
-{
- struct update_mda_baton *umb = baton;
-
- umb->nr_outstanding_mdas++;
-
- return 1;
-}
-
static int _update_mda(struct metadata_area *mda, void *baton)
{
- struct process_mda_header_params *pmp;
- struct update_mda_baton *umb = baton;
- const struct format_type *fmt = umb->label->labeller->fmt;
- struct dm_pool *mem = umb->label->labeller->fmt->cmd->mem;
+ struct _update_mda_baton *p = baton;
+ const struct format_type *fmt = p->label->labeller->fmt;
struct mda_context *mdac = (struct mda_context *) mda->metadata_locn;
- unsigned ioflags = umb->ioflags;
-
- if (!(pmp = dm_pool_zalloc(mem, sizeof(*pmp)))) {
- log_error("struct process_mda_header_params allocation failed");
- return 0;
- }
+ struct mda_header *mdah;
+ struct lvmcache_vgsummary vgsummary = { 0 };
/*
* Using the labeller struct to preserve info about
@@ -427,34 +338,45 @@ static int _update_mda(struct metadata_area *mda, void *baton)
* TODO: make lvmcache smarter and move this cache logic there
*/
- pmp->dev = mdac->area.dev;
- pmp->umb = umb;
- pmp->mda = mda;
-
if (!dev_open_readonly(mdac->area.dev)) {
mda_set_ignored(mda, 1);
stack;
- if (!--umb->nr_outstanding_mdas && umb->read_label_callback_fn)
- umb->read_label_callback_fn(!umb->ret, ioflags, umb->read_label_callback_context, umb->label);
return 1;
}
- pmp->ret = 1;
-
- if (!raw_read_mda_header_callback(fmt->cmd->mem, &mdac->area, mda_is_primary(mda), ioflags, _process_mda_header, pmp)) {
- _process_vgsummary(1, ioflags, pmp, NULL);
+ if (!(mdah = raw_read_mda_header(fmt, &mdac->area, mda_is_primary(mda)))) {
stack;
- return 1;
+ goto close_dev;
}
- if (umb->read_label_callback_fn)
+ mda_set_ignored(mda, rlocn_is_ignored(mdah->raw_locns));
+
+ if (mda_is_ignored(mda)) {
+ log_debug_metadata("Ignoring mda on device %s at offset " FMTu64,
+ dev_name(mdac->area.dev),
+ mdac->area.start);
+ if (!dev_close(mdac->area.dev))
+ stack;
return 1;
- else
- return pmp->ret;
+ }
+
+ if (vgname_from_mda(fmt, mdah, mda_is_primary(mda), &mdac->area, &vgsummary,
+ &mdac->free_sectors) &&
+ !lvmcache_update_vgname_and_id(p->info, &vgsummary)) {
+ if (!dev_close(mdac->area.dev))
+ stack;
+ return_0;
+ }
+
+close_dev:
+ if (!dev_close(mdac->area.dev))
+ stack;
+
+ return 1;
}
-static int _text_read(struct labeller *l, struct device *dev, void *buf, unsigned ioflags,
- lvm_callback_fn_t read_label_callback_fn, void *read_label_callback_context)
+static int _text_read(struct labeller *l, struct device *dev, void *buf,
+ struct label **label)
{
struct label_header *lh = (struct label_header *) buf;
struct pv_header *pvhdr;
@@ -463,9 +385,7 @@ static int _text_read(struct labeller *l, struct device *dev, void *buf, unsigne
struct disk_locn *dlocn_xl;
uint64_t offset;
uint32_t ext_version;
- struct dm_pool *mem = l->fmt->cmd->mem;
- struct update_mda_baton *umb;
- struct label *label;
+ struct _update_mda_baton baton;
/*
* PV header base
@@ -475,9 +395,9 @@ static int _text_read(struct labeller *l, struct device *dev, void *buf, unsigne
if (!(info = lvmcache_add(l, (char *)pvhdr->pv_uuid, dev,
FMT_TEXT_ORPHAN_VG_NAME,
FMT_TEXT_ORPHAN_VG_NAME, 0)))
- goto_bad;
+ return_0;
- label = lvmcache_get_label(info);
+ *label = lvmcache_get_label(info);
lvmcache_set_device_size(info, xlate64(pvhdr->device_size_xl));
@@ -523,41 +443,16 @@ static int _text_read(struct labeller *l, struct device *dev, void *buf, unsigne
lvmcache_add_ba(info, offset, xlate64(dlocn_xl->size));
dlocn_xl++;
}
-
out:
- if (!(umb = dm_pool_zalloc(mem, sizeof(*umb)))) {
- log_error("baton allocation failed");
- goto_bad;
- }
+ baton.info = info;
+ baton.label = *label;
- umb->info = info;
- umb->label = label;
- umb->ioflags = ioflags;
- umb->read_label_callback_fn = read_label_callback_fn;
- umb->read_label_callback_context = read_label_callback_context;
+ if (!lvmcache_foreach_mda(info, _update_mda, &baton))
+ return_0;
- umb->ret = 1;
-
- if (!lvmcache_foreach_mda(info, _count_mda, umb))
- goto_bad;
-
- if (!umb->nr_outstanding_mdas) {
- lvmcache_make_valid(info);
- if (read_label_callback_fn)
- read_label_callback_fn(0, ioflags, read_label_callback_context, label);
- return 1;
- }
-
- if (!lvmcache_foreach_mda(info, _update_mda, umb))
- goto_bad;
+ lvmcache_make_valid(info);
return 1;
-
-bad:
- if (read_label_callback_fn)
- read_label_callback_fn(1, ioflags, read_label_callback_context, NULL);
-
- return 0;
}
static void _text_destroy_label(struct labeller *l __attribute__((unused)),
diff --git a/lib/label/label.c b/lib/label/label.c
index 32fad82..46dd667 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2018 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -25,8 +25,6 @@
/* FIXME Allow for larger labels? Restricted to single sector currently */
-static struct dm_pool *_labeller_mem;
-
/*
* Internal labeller struct.
*/
@@ -59,13 +57,7 @@ static struct labeller_i *_alloc_li(const char *name, struct labeller *l)
int label_init(void)
{
- if (!(_labeller_mem = dm_pool_create("label scan", 128))) {
- log_error("Labeller pool creation failed.");
- return 0;
- }
-
dm_list_init(&_labellers);
-
return 1;
}
@@ -80,8 +72,6 @@ void label_exit(void)
}
dm_list_init(&_labellers);
-
- dm_pool_destroy(_labeller_mem);
}
int label_register_handler(struct labeller *handler)
@@ -118,74 +108,32 @@ static void _update_lvmcache_orphan(struct lvmcache_info *info)
stack;
}
-struct find_labeller_params {
- struct device *dev;
- uint64_t scan_sector; /* Sector to be scanned */
- uint64_t label_sector; /* Sector where label found */
- lvm_callback_fn_t process_label_data_fn;
- void *process_label_data_context;
-
- struct label **result;
-
- int ret;
-};
-
-static void _set_label_read_result(int failed, unsigned ioflags, void *context, const void *data)
+static struct labeller *_find_labeller(struct device *dev, char *buf,
+ uint64_t *label_sector,
+ uint64_t scan_sector)
{
- struct find_labeller_params *flp = context;
- struct label **result = flp->result;
- struct label *label = (struct label *) data;
-
- if (failed) {
- flp->ret = 0;
- goto_out;
- }
-
- /* Fix up device and label sector which the low-level code doesn't set */
- if (label) {
- label->dev = flp->dev;
- label->sector = flp->label_sector;
- }
-
- if (result)
- *result = (struct label *) label;
-
-out:
- if (!dev_close(flp->dev))
- stack;
-
- if (flp->process_label_data_fn) {
- log_debug_io("Completed label reading for %s", dev_name(flp->dev));
- flp->process_label_data_fn(!flp->ret, ioflags, flp->process_label_data_context, NULL);
- }
-}
-
-static void _find_labeller(int failed, unsigned ioflags, void *context, const void *data)
-{
- struct find_labeller_params *flp = context;
- const char *readbuf = data;
- struct device *dev = flp->dev;
- uint64_t scan_sector = flp->scan_sector;
- char labelbuf[LABEL_SIZE] __attribute__((aligned(8)));
struct labeller_i *li;
- struct labeller *l = NULL; /* Set when a labeller claims the label */
- const struct label_header *lh;
+ struct labeller *r = NULL;
+ struct label_header *lh;
struct lvmcache_info *info;
uint64_t sector;
+ int found = 0;
+ char readbuf[LABEL_SCAN_SIZE] __attribute__((aligned(8)));
- if (failed) {
+ if (!dev_read(dev, scan_sector << SECTOR_SHIFT,
+ LABEL_SCAN_SIZE, DEV_IO_LABEL, readbuf)) {
log_debug_devs("%s: Failed to read label area", dev_name(dev));
- _set_label_read_result(1, ioflags, flp, NULL);
- return;
+ goto out;
}
/* Scan a few sectors for a valid label */
for (sector = 0; sector < LABEL_SCAN_SECTORS;
sector += LABEL_SIZE >> SECTOR_SHIFT) {
- lh = (struct label_header *) (readbuf + (sector << SECTOR_SHIFT));
+ lh = (struct label_header *) (readbuf +
+ (sector << SECTOR_SHIFT));
if (!strncmp((char *)lh->id, LABEL_ID, sizeof(lh->id))) {
- if (l) {
+ if (found) {
log_error("Ignoring additional label on %s at "
"sector %" PRIu64, dev_name(dev),
sector + scan_sector);
@@ -205,7 +153,7 @@ static void _find_labeller(int failed, unsigned ioflags, void *context, const vo
"ignoring", dev_name(dev));
continue;
}
- if (l)
+ if (found)
continue;
}
@@ -216,44 +164,46 @@ static void _find_labeller(int failed, unsigned ioflags, void *context, const vo
"sector %" PRIu64,
dev_name(dev), li->name,
sector + scan_sector);
- if (l) {
+ if (found) {
log_error("Ignoring additional label "
"on %s at sector %" PRIu64,
dev_name(dev),
sector + scan_sector);
continue;
}
- memcpy(labelbuf, lh, LABEL_SIZE);
- flp->label_sector = sector + scan_sector;
- l = li->l;
+ r = li->l;
+ memcpy(buf, lh, LABEL_SIZE);
+ if (label_sector)
+ *label_sector = sector + scan_sector;
+ found = 1;
break;
}
}
}
- if (!l) {
+ out:
+ if (!found) {
if ((info = lvmcache_info_from_pvid(dev->pvid, dev, 0)))
_update_lvmcache_orphan(info);
log_very_verbose("%s: No label detected", dev_name(dev));
- flp->ret = 0;
- _set_label_read_result(1, ioflags, flp, NULL);
- } else
- (void) (l->ops->read)(l, dev, labelbuf, ioflags, &_set_label_read_result, flp);
+ }
+
+ return r;
}
/* FIXME Also wipe associated metadata area headers? */
int label_remove(struct device *dev)
{
- char labelbuf[LABEL_SIZE] __attribute__((aligned(8)));
+ char buf[LABEL_SIZE] __attribute__((aligned(8)));
+ char readbuf[LABEL_SCAN_SIZE] __attribute__((aligned(8)));
int r = 1;
uint64_t sector;
int wipe;
struct labeller_i *li;
struct label_header *lh;
struct lvmcache_info *info;
- const char *readbuf = NULL;
- memset(labelbuf, 0, LABEL_SIZE);
+ memset(buf, 0, LABEL_SIZE);
log_very_verbose("Scanning for labels to wipe from %s", dev_name(dev));
@@ -266,7 +216,7 @@ int label_remove(struct device *dev)
*/
dev_flush(dev);
- if (!(readbuf = dev_read(dev, UINT64_C(0), LABEL_SCAN_SIZE, DEV_IO_LABEL))) {
+ if (!dev_read(dev, UINT64_C(0), LABEL_SCAN_SIZE, DEV_IO_LABEL, readbuf)) {
log_debug_devs("%s: Failed to read label area", dev_name(dev));
goto out;
}
@@ -274,7 +224,8 @@ int label_remove(struct device *dev)
/* Scan first few sectors for anything looking like a label */
for (sector = 0; sector < LABEL_SCAN_SECTORS;
sector += LABEL_SIZE >> SECTOR_SHIFT) {
- lh = (struct label_header *) (readbuf + (sector << SECTOR_SHIFT));
+ lh = (struct label_header *) (readbuf +
+ (sector << SECTOR_SHIFT));
wipe = 0;
@@ -294,7 +245,8 @@ int label_remove(struct device *dev)
if (wipe) {
log_very_verbose("%s: Wiping label at sector %" PRIu64,
dev_name(dev), sector);
- if (dev_write(dev, sector << SECTOR_SHIFT, LABEL_SIZE, DEV_IO_LABEL, labelbuf)) {
+ if (dev_write(dev, sector << SECTOR_SHIFT, LABEL_SIZE, DEV_IO_LABEL,
+ buf)) {
/* Also remove the PV record from cache. */
info = lvmcache_info_from_pvid(dev->pvid, dev, 0);
if (info)
@@ -315,39 +267,21 @@ int label_remove(struct device *dev)
return r;
}
-static int _label_read(struct device *dev, uint64_t scan_sector, struct label **result,
- unsigned ioflags, lvm_callback_fn_t process_label_data_fn, void *process_label_data_context)
+int label_read(struct device *dev, struct label **result,
+ uint64_t scan_sector)
{
+ char buf[LABEL_SIZE] __attribute__((aligned(8)));
+ struct labeller *l;
+ uint64_t sector;
struct lvmcache_info *info;
- struct find_labeller_params *flp;
+ int r = 0;
if ((info = lvmcache_info_from_pvid(dev->pvid, dev, 1))) {
log_debug_devs("Reading label from lvmcache for %s", dev_name(dev));
- if (result)
- *result = lvmcache_get_label(info);
- if (process_label_data_fn) {
- log_debug_io("Completed label reading for %s", dev_name(dev));
- process_label_data_fn(0, ioflags, process_label_data_context, NULL);
- }
+ *result = lvmcache_get_label(info);
return 1;
}
- if (!(flp = dm_pool_zalloc(_labeller_mem, sizeof *flp))) {
- log_error("find_labeller_params allocation failed.");
- return 0;
- }
-
- flp->dev = dev;
- flp->scan_sector = scan_sector;
- flp->result = result;
- flp->process_label_data_fn = process_label_data_fn;
- flp->process_label_data_context = process_label_data_context;
- flp->ret = 1;
-
- /* Ensure result is always wiped as a precaution */
- if (result)
- *result = NULL;
-
log_debug_devs("Reading label from device %s", dev_name(dev));
if (!dev_open_readonly(dev)) {
@@ -356,26 +290,19 @@ static int _label_read(struct device *dev, uint64_t scan_sector, struct label **
if ((info = lvmcache_info_from_pvid(dev->pvid, dev, 0)))
_update_lvmcache_orphan(info);
- return 0;
+ return r;
}
- dev_read_callback(dev, scan_sector << SECTOR_SHIFT, LABEL_SCAN_SIZE, DEV_IO_LABEL, ioflags, _find_labeller, flp);
- if (process_label_data_fn)
- return 1;
- else
- return flp->ret;
-}
+ if ((l = _find_labeller(dev, buf, §or, scan_sector)))
+ if ((r = (l->ops->read)(l, dev, buf, result)) && result && *result) {
+ (*result)->dev = dev;
+ (*result)->sector = sector;
+ }
-/* result may be NULL if caller doesn't need it */
-int label_read(struct device *dev, struct label **result, uint64_t scan_sector)
-{
- return _label_read(dev, scan_sector, result, 0, NULL, NULL);
-}
+ if (!dev_close(dev))
+ stack;
-int label_read_callback(struct device *dev, uint64_t scan_sector, unsigned ioflags,
- lvm_callback_fn_t process_label_data_fn, void *process_label_data_context)
-{
- return _label_read(dev, scan_sector, NULL, ioflags, process_label_data_fn, process_label_data_context);
+ return r;
}
/* Caller may need to use label_get_handler to create label struct! */
diff --git a/lib/label/label.h b/lib/label/label.h
index 6d31eb0..ea11290 100644
--- a/lib/label/label.h
+++ b/lib/label/label.h
@@ -62,8 +62,8 @@ struct label_ops {
/*
* Read a label from a volume.
*/
- int (*read) (struct labeller *l, struct device *dev, void *buf,
- unsigned ioflags, lvm_callback_fn_t label_read_callback_fn, void *label_read_callback_context);
+ int (*read) (struct labeller * l, struct device * dev,
+ void *buf, struct label ** label);
/*
* Populate label_type etc.
@@ -96,8 +96,6 @@ struct labeller *label_get_handler(const char *name);
int label_remove(struct device *dev);
int label_read(struct device *dev, struct label **result,
uint64_t scan_sector);
-int label_read_callback(struct device *dev, uint64_t scan_sector,
- unsigned ioflags, lvm_callback_fn_t process_label_data_fn, void *process_label_data_context);
int label_write(struct device *dev, struct label *label);
struct label *label_create(struct labeller *labeller);
void label_destroy(struct label *label);
diff --git a/lib/metadata/metadata-liblvm.c b/lib/metadata/metadata-liblvm.c
index d192b15..a4284bc 100644
--- a/lib/metadata/metadata-liblvm.c
+++ b/lib/metadata/metadata-liblvm.c
@@ -491,6 +491,7 @@ static int _pvremove_check(struct cmd_context *cmd, const char *name,
{
static const char really_wipe_msg[] = "Really WIPE LABELS from physical volume";
struct device *dev;
+ struct label *label;
struct pv_list *pvl;
struct physical_volume *pv = NULL;
int used;
@@ -505,7 +506,7 @@ static int _pvremove_check(struct cmd_context *cmd, const char *name,
/* Is there a pv here already? */
/* If not, this is an error unless you used -f. */
- if (!label_read(dev, NULL, 0)) {
+ if (!label_read(dev, &label, 0)) {
if (force_count)
return 1;
log_error("No PV label found on %s.", name);
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index b5b97c2..2249d2f 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -3912,9 +3912,9 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
use_previous_vg = 0;
if ((use_precommitted &&
- !(vg = mda->ops->vg_read_precommit(fid, vgname, mda, &vg_fmtdata, &use_previous_vg, 0)) && !use_previous_vg) ||
+ !(vg = mda->ops->vg_read_precommit(fid, vgname, mda, &vg_fmtdata, &use_previous_vg)) && !use_previous_vg) ||
(!use_precommitted &&
- !(vg = mda->ops->vg_read(fid, vgname, mda, &vg_fmtdata, &use_previous_vg, 0, 0)) && !use_previous_vg)) {
+ !(vg = mda->ops->vg_read(fid, vgname, mda, &vg_fmtdata, &use_previous_vg, 0)) && !use_previous_vg)) {
inconsistent = 1;
vg_fmtdata = NULL;
continue;
@@ -4104,9 +4104,9 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
use_previous_vg = 0;
if ((use_precommitted &&
- !(vg = mda->ops->vg_read_precommit(fid, vgname, mda, &vg_fmtdata, &use_previous_vg, 0)) && !use_previous_vg) ||
+ !(vg = mda->ops->vg_read_precommit(fid, vgname, mda, &vg_fmtdata, &use_previous_vg)) && !use_previous_vg) ||
(!use_precommitted &&
- !(vg = mda->ops->vg_read(fid, vgname, mda, &vg_fmtdata, &use_previous_vg, 0, 0)) && !use_previous_vg)) {
+ !(vg = mda->ops->vg_read(fid, vgname, mda, &vg_fmtdata, &use_previous_vg, 0)) && !use_previous_vg)) {
inconsistent = 1;
vg_fmtdata = NULL;
continue;
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index f6b19f4..1fa14e8 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -48,6 +48,7 @@
*/
#define dm_round_up(n, sz) (dm_div_up((n), (sz)) * (sz))
+
/* Various flags */
/* See metadata-exported.h for the complete list. */
/* Note that the bits no longer necessarily correspond to LVM1 disk format */
@@ -80,12 +81,12 @@ struct metadata_area_ops {
struct metadata_area * mda,
struct cached_vg_fmtdata **vg_fmtdata,
unsigned *use_previous_vg,
- int single_device, unsigned ioflags);
+ int single_device);
struct volume_group *(*vg_read_precommit) (struct format_instance * fi,
const char *vg_name,
struct metadata_area * mda,
struct cached_vg_fmtdata **vg_fmtdata,
- unsigned *use_previous_vg, unsigned ioflags);
+ unsigned *use_previous_vg);
/*
* Write out complete VG metadata. You must ensure internal
* consistency before calling. eg. PEs can't refer to PVs not
diff --git a/make.tmpl.in b/make.tmpl.in
index 414b1dd..bdf2349 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -62,8 +62,7 @@ CLDFLAGS += @CLDFLAGS@
ELDFLAGS += @ELDFLAGS@
LDDEPS += @LDDEPS@
LIB_SUFFIX = @LIB_SUFFIX@
-LVMINTERNAL_LIBS = -llvm-internal $(DMEVENT_LIBS) $(DAEMON_LIBS) $(SYSTEMD_LIBS) $(UDEV_LIBS) $(DL_LIBS) $(BLKID_LIBS) $(AIO_LIBS)
-AIO_LIBS = @AIO_LIBS@
+LVMINTERNAL_LIBS = -llvm-internal $(DMEVENT_LIBS) $(DAEMON_LIBS) $(SYSTEMD_LIBS) $(UDEV_LIBS) $(DL_LIBS) $(BLKID_LIBS)
DL_LIBS = @DL_LIBS@
RT_LIBS = @RT_LIBS@
M_LIBS = @M_LIBS@
diff --git a/tools/command.c b/tools/command.c
index a40b327..8944399 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -1357,11 +1357,13 @@ static void _create_opt_names_alpha(void)
qsort(opt_names_alpha, ARG_COUNT, sizeof(long), _long_name_compare);
}
-static int _copy_line(char *line, int max_line, int *position, int *len)
+static int _copy_line(char *line, int max_line, int *position)
{
int p = *position;
int i = 0;
+ memset(line, 0, max_line);
+
while (1) {
line[i] = _command_input[p];
i++;
@@ -1375,9 +1377,7 @@ static int _copy_line(char *line, int max_line, int *position, int *len)
if (i == (max_line - 1))
break;
}
- line[i] = '\0';
*position = p;
- *len = i + 1;
return 1;
}
@@ -1395,7 +1395,6 @@ int define_commands(struct cmd_context *cmdtool, const char *run_name)
int prev_was_oo = 0;
int prev_was_op = 0;
int copy_pos = 0;
- int copy_len = 0;
int skip = 0;
int i;
@@ -1406,14 +1405,14 @@ int define_commands(struct cmd_context *cmdtool, const char *run_name)
/* Process each line of command-lines-input.h (from command-lines.in) */
- while (_copy_line(line, MAX_LINE, ©_pos, ©_len)) {
+ while (_copy_line(line, MAX_LINE, ©_pos)) {
if (line[0] == '\n')
break;
if ((n = strchr(line, '\n')))
*n = '\0';
- memcpy(line_orig, line, copy_len);
+ memcpy(line_orig, line, sizeof(line));
_split_line(line, &line_argc, line_argv, ' ');
if (!line_argc)
diff --git a/tools/toollib.c b/tools/toollib.c
index 3f27a7a..451f24d 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -116,7 +116,6 @@ int become_daemon(struct cmd_context *cmd, int skip_lvm)
/* FIXME Clean up properly here */
_exit(ECMD_FAILED);
}
- dev_async_reset(cmd);
dev_close_all();
return 1;
5 years, 12 months