master - pvck: use bcache
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e7670d333855ecccb21...
Commit: e7670d333855ecccb21b30bc6b4525d6bafaa940
Parent: b504bb809efa8a3a4db0e494bb80d3720d82e6ff
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Feb 15 11:06:50 2018 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 20 11:22:47 2018 -0500
pvck: use bcache
---
lib/format_text/format-text.c | 24 +++++++++++++++++-------
tools/pvck.c | 2 ++
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 8a42213..ef59f07 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -187,9 +187,6 @@ static int _pv_analyze_mda_raw (const struct format_type * fmt,
FMTu64, mdac->area.start, mdac->area.size);
area = &mdac->area;
- if (!dev_open_readonly(area->dev))
- return_0;
-
if (!(mdah = raw_read_mda_header(fmt, area, mda_is_primary(mda))))
goto_out;
@@ -230,8 +227,23 @@ static int _pv_analyze_mda_raw (const struct format_type * fmt,
if (!(buf = dm_malloc(size + size2)))
goto_out;
- if (!dev_read_circular(area->dev, offset, size, offset2, size2, MDA_CONTENT_REASON(mda_is_primary(mda)), buf))
- goto_out;
+ if (!bcache_read_bytes(scan_bcache, area->dev->bcache_fd, offset, size, buf)) {
+ log_error("Failed to read dev %s offset %llu size %llu",
+ dev_name(area->dev),
+ (unsigned long long)offset,
+ (unsigned long long)size);
+ goto out;
+ }
+
+ if (size2) {
+ if (!bcache_read_bytes(scan_bcache, area->dev->bcache_fd, offset2, size2, buf + size)) {
+ log_error("Failed to read dev %s offset %llu size %llu",
+ dev_name(area->dev),
+ (unsigned long long)offset2,
+ (unsigned long long)size2);
+ goto out;
+ }
+ }
/*
* FIXME: We could add more sophisticated metadata detection
@@ -268,8 +280,6 @@ static int _pv_analyze_mda_raw (const struct format_type * fmt,
r = 1;
out:
dm_free(buf);
- if (!dev_close(area->dev))
- stack;
return r;
}
diff --git a/tools/pvck.c b/tools/pvck.c
index 0fedb4a..634b38d 100644
--- a/tools/pvck.c
+++ b/tools/pvck.c
@@ -23,6 +23,8 @@ int pvck(struct cmd_context *cmd, int argc, char **argv)
/* FIXME: validate cmdline options */
/* FIXME: what does the cmdline look like? */
+ label_scan_setup_bcache();
+
/*
* Use what's on the cmdline directly, and avoid calling into
* some of the other infrastructure functions, so as to avoid
5 years, 12 months
master - test: vgsplit-usage if LVM1 tests
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ae093df3f15f6d125bf...
Commit: ae093df3f15f6d125bf85ed921e5a971b170dc23
Parent: d75aa557845e37f5c4b90ca43c81943bd9b90094
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Feb 15 10:00:07 2018 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 20 11:22:46 2018 -0500
test: vgsplit-usage if LVM1 tests
---
test/shell/vgsplit-usage.sh | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/test/shell/vgsplit-usage.sh b/test/shell/vgsplit-usage.sh
index 98818ab..a112e86 100644
--- a/test/shell/vgsplit-usage.sh
+++ b/test/shell/vgsplit-usage.sh
@@ -184,6 +184,7 @@ check pvlv_counts $vg1 2 1 0
vgremove -f $vg1
# vgsplit rejects split because metadata types differ
+if test -n "$LVM_TEST_LVM1" ; then
pvcreate -ff -M1 "$dev3" "$dev4"
pvcreate -ff "$dev1" "$dev2"
vgcreate -M1 $vg1 "$dev3" "$dev4"
@@ -192,3 +193,4 @@ not vgsplit $vg1 $vg2 "$dev3" 2>err;
grep "Metadata types differ" err
vgremove -f $vg1 $vg2
fi
+fi
5 years, 12 months
master - disable LVM1 tests
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d75aa557845e37f5c4b...
Commit: d75aa557845e37f5c4b90ca43c81943bd9b90094
Parent: 96a61337b00a250f69e7a8e6ac390c47c36c2c0f
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Feb 15 09:54:12 2018 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 20 11:22:46 2018 -0500
disable LVM1 tests
---
test/lib/flavour-ndev-cluster.sh | 1 -
test/lib/flavour-ndev-vanilla.sh | 1 -
test/lib/flavour-udev-cluster.sh | 1 -
test/lib/flavour-udev-vanilla.sh | 1 -
4 files changed, 0 insertions(+), 4 deletions(-)
diff --git a/test/lib/flavour-ndev-cluster.sh b/test/lib/flavour-ndev-cluster.sh
index 3082b11..3629069 100644
--- a/test/lib/flavour-ndev-cluster.sh
+++ b/test/lib/flavour-ndev-cluster.sh
@@ -1,2 +1 @@
export LVM_TEST_LOCKING=3
-export LVM_TEST_LVM1=1
diff --git a/test/lib/flavour-ndev-vanilla.sh b/test/lib/flavour-ndev-vanilla.sh
index c106e61..1899c94 100644
--- a/test/lib/flavour-ndev-vanilla.sh
+++ b/test/lib/flavour-ndev-vanilla.sh
@@ -1,2 +1 @@
export LVM_TEST_LOCKING=1
-export LVM_TEST_LVM1=1
diff --git a/test/lib/flavour-udev-cluster.sh b/test/lib/flavour-udev-cluster.sh
index 1cab558..a9025a6 100644
--- a/test/lib/flavour-udev-cluster.sh
+++ b/test/lib/flavour-udev-cluster.sh
@@ -1,3 +1,2 @@
export LVM_TEST_LOCKING=3
export LVM_TEST_DEVDIR=/dev
-export LVM_TEST_LVM1=1
diff --git a/test/lib/flavour-udev-vanilla.sh b/test/lib/flavour-udev-vanilla.sh
index 6fbdafe..ca778a6 100644
--- a/test/lib/flavour-udev-vanilla.sh
+++ b/test/lib/flavour-udev-vanilla.sh
@@ -1,3 +1,2 @@
export LVM_TEST_LOCKING=1
export LVM_TEST_DEVDIR=/dev
-export LVM_TEST_LVM1=1
5 years, 12 months
master - lvmdiskscan: use the new label_scan
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=96a61337b00a250f69e...
Commit: 96a61337b00a250f69e7a8e6ac390c47c36c2c0f
Parent: 28255e3eeef13a0e73a40d533623b22dd9db89cb
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 14 16:43:26 2018 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 20 11:22:46 2018 -0500
lvmdiskscan: use the new label_scan
instead of doing it's own.
---
tools/lvmdiskscan.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/tools/lvmdiskscan.c b/tools/lvmdiskscan.c
index cb688b5..7e2fc88 100644
--- a/tools/lvmdiskscan.c
+++ b/tools/lvmdiskscan.c
@@ -87,7 +87,6 @@ int lvmdiskscan(struct cmd_context *cmd, int argc __attribute__((unused)),
uint64_t size;
struct dev_iter *iter;
struct device *dev;
- struct label *label;
/* initialise these here to avoid problems with the lvm shell */
disks_found = 0;
@@ -105,10 +104,10 @@ int lvmdiskscan(struct cmd_context *cmd, int argc __attribute__((unused)),
return ECMD_FAILED;
}
- /* Do scan */
+ label_scan(cmd);
+
for (dev = dev_iter_get(iter); dev; dev = dev_iter_get(iter)) {
- /* Try if it is a PV first */
- if ((label_read(dev, &label, UINT64_C(0)))) {
+ if (lvmcache_has_dev_info(dev)) {
if (!dev_get_size(dev, &size)) {
log_error("Couldn't get size of \"%s\"",
dev_name(dev));
5 years, 12 months
master - scan: always setup bcache for commands using lvmetad
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=28255e3eeef13a0e73a...
Commit: 28255e3eeef13a0e73a40d533623b22dd9db89cb
Parent: f328532f05877fc04e7f67c751ef95a844831b9b
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 14 16:21:27 2018 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 20 11:22:46 2018 -0500
scan: always setup bcache for commands using lvmetad
Do this at the start of the command so that it doesn't
need to be checked and set up in every function that
could need it.
---
lib/cache/lvmcache.c | 5 ++++-
lib/label/label.c | 29 +++++++++++++++++------------
lib/label/label.h | 1 +
3 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 87bcc37..53254f4 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -1241,8 +1241,11 @@ int lvmcache_label_scan(struct cmd_context *cmd)
int r = 0;
- if (lvmetad_used())
+ if (lvmetad_used()) {
+ if (!label_scan_setup_bcache())
+ return 0;
return 1;
+ }
/* Avoid recursion when a PVID can't be found! */
if (_scanning_in_progress)
diff --git a/lib/label/label.c b/lib/label/label.c
index 3359b4d..dc14beb 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -678,18 +678,6 @@ int label_scan_devs(struct cmd_context *cmd, struct dm_list *devs)
{
struct device_list *devl;
- if (!scan_bcache) {
- /*
- * This is only needed when commands are using lvmetad, in
- * which case they don't do an initial label_scan, but may
- * later need to rescan certain devs from disk and call this
- * function.
- * FIXME: is there some better number to choose here?
- */
- if (!_setup_bcache(32))
- return 0;
- }
-
dm_list_iterate_items(devl, devs) {
if (_in_bcache(devl->dev)) {
bcache_invalidate_fd(scan_bcache, devl->dev->bcache_fd);
@@ -841,3 +829,20 @@ void label_scan_confirm(struct device *dev)
label_read(dev, NULL, 0);
}
+/*
+ * This is only needed when commands are using lvmetad, in which case they
+ * don't do an initial label_scan, but may later need to rescan certain devs
+ * from disk and call this function. FIXME: is there some better number to
+ * choose here?
+ */
+
+int label_scan_setup_bcache(void)
+{
+ if (!scan_bcache) {
+ if (!_setup_bcache(32))
+ return 0;
+ }
+
+ return 1;
+}
+
diff --git a/lib/label/label.h b/lib/label/label.h
index e265a6b..107bd30 100644
--- a/lib/label/label.h
+++ b/lib/label/label.h
@@ -110,5 +110,6 @@ void label_scan_destroy(struct cmd_context *cmd);
int label_read(struct device *dev, struct label **labelp, uint64_t unused_sector);
int label_read_sector(struct device *dev, struct label **labelp, uint64_t scan_sector);
void label_scan_confirm(struct device *dev);
+int label_scan_setup_bcache(void);
#endif
5 years, 12 months
master - scan: leave the caller's dev list unchanged
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f328532f05877fc04e7...
Commit: f328532f05877fc04e7f67c751ef95a844831b9b
Parent: 7bce66c5e83296398e2eee99140b3d6e409236c9
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 14 16:15:30 2018 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 20 11:22:46 2018 -0500
scan: leave the caller's dev list unchanged
When scanning the list of devs from the caller
they are moved to another temporary list, but
were never returned to the original list.
---
lib/label/label.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/lib/label/label.c b/lib/label/label.c
index bf1070c..3359b4d 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -567,6 +567,8 @@ static int _scan_list(struct dm_list *devs, int *failed)
if (failed)
*failed = scan_failed_count;
+ dm_list_splice(devs, &done_devs);
+
return 1;
}
5 years, 12 months
master - scan: setup bcache for commands using lvmetad
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7bce66c5e83296398e2...
Commit: 7bce66c5e83296398e2eee99140b3d6e409236c9
Parent: 6e580465b50edcd5fef0eb95180a620cb785d835
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 14 15:45:31 2018 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 20 11:22:46 2018 -0500
scan: setup bcache for commands using lvmetad
Commands using lvmetad will not begin with a proper
label_scan which initializes bcache, but may later
decide they need to scan a set of devs, in which case
they'll need bcache set up at that point.
---
lib/label/label.c | 66 +++++++++++++++++++++++++++++++++++++---------------
1 files changed, 47 insertions(+), 19 deletions(-)
diff --git a/lib/label/label.c b/lib/label/label.c
index 19beecf..bf1070c 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -570,6 +570,38 @@ static int _scan_list(struct dm_list *devs, int *failed)
return 1;
}
+static int _setup_bcache(int cache_blocks)
+{
+ struct io_engine *ioe;
+
+ /* No devices can happen, just create bcache with any small number. */
+ if (!cache_blocks)
+ cache_blocks = 8;
+
+ /*
+ * 100 is arbitrary, it's the max number of concurrent aio's
+ * possible, i.e, the number of devices that can be read at
+ * once. Should this be configurable?
+ */
+ if (!(ioe = create_async_io_engine(100))) {
+ log_error("Failed to create bcache io engine.");
+ return 0;
+ }
+
+ /*
+ * Configure one cache block for each device on the system.
+ * We won't generally need to cache that many because some
+ * of the devs will not be lvm devices, and we don't need
+ * an entry for those. We might want to change this.
+ */
+ if (!(scan_bcache = bcache_create(BCACHE_BLOCK_SIZE_IN_SECTORS, cache_blocks, ioe))) {
+ log_error("Failed to create bcache with %d cache blocks.", cache_blocks);
+ return 0;
+ }
+
+ return 1;
+}
+
/*
* Scan and cache lvm data from all devices on the system.
* The cache should be empty/reset before calling this.
@@ -581,8 +613,6 @@ int label_scan(struct cmd_context *cmd)
struct dev_iter *iter;
struct device_list *devl;
struct device *dev;
- struct io_engine *ioe;
- int cache_blocks;
log_debug_devs("Finding devices to scan");
@@ -621,25 +651,11 @@ int label_scan(struct cmd_context *cmd)
dev_iter_destroy(iter);
if (!scan_bcache) {
- /* No devices can happen, just create bcache with any small number. */
- if (!(cache_blocks = dm_list_size(&all_devs)))
- cache_blocks = 8;
-
- /*
- * 100 is arbitrary, it's the max number of concurrent aio's
- * possible, i.e, the number of devices that can be read at
- * once. Should this be configurable?
- */
- if (!(ioe = create_async_io_engine(100)))
- return 0;
-
/*
- * Configure one cache block for each device on the system.
- * We won't generally need to cache that many because some
- * of the devs will not be lvm devices, and we don't need
- * an entry for those. We might want to change this.
+ * FIXME: there should probably be some max number of
+ * cache blocks we use when setting up bcache.
*/
- if (!(scan_bcache = bcache_create(BCACHE_BLOCK_SIZE_IN_SECTORS, cache_blocks, ioe)))
+ if (!_setup_bcache(dm_list_size(&all_devs)))
return 0;
}
@@ -660,6 +676,18 @@ int label_scan_devs(struct cmd_context *cmd, struct dm_list *devs)
{
struct device_list *devl;
+ if (!scan_bcache) {
+ /*
+ * This is only needed when commands are using lvmetad, in
+ * which case they don't do an initial label_scan, but may
+ * later need to rescan certain devs from disk and call this
+ * function.
+ * FIXME: is there some better number to choose here?
+ */
+ if (!_setup_bcache(32))
+ return 0;
+ }
+
dm_list_iterate_items(devl, devs) {
if (_in_bcache(devl->dev)) {
bcache_invalidate_fd(scan_bcache, devl->dev->bcache_fd);
5 years, 12 months
master - vgremove: fix force remove on devs with damaged metadata
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6e580465b50edcd5fef...
Commit: 6e580465b50edcd5fef0eb95180a620cb785d835
Parent: 37471bb4777f3f407d2cd942995b45c326ea221a
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 14 14:47:28 2018 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 20 11:22:46 2018 -0500
vgremove: fix force remove on devs with damaged metadata
The improved detection of bad metadata when scanning
(where errors were ignored before) means we now have to
override some errors when forcibly erasing damaged metadata.
---
lib/format_text/format-text.c | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index f33451f..8a42213 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -865,12 +865,28 @@ static int _vg_remove_raw(struct format_instance *fid, struct volume_group *vg,
int r = 0;
int noprecommit = 0;
- if (!(mdah = raw_read_mda_header(fid->fmt, &mdac->area, mda_is_primary(mda))))
- goto_out;
+ if (!(mdah = dm_pool_alloc(fid->fmt->cmd->mem, MDA_HEADER_SIZE))) {
+ log_error("struct mda_header allocation failed");
+ return 0;
+ }
- if (!(rlocn = _read_metadata_location_vg(&mdac->area, mdah, mda_is_primary(mda), vg->name, &noprecommit))) {
+ /*
+ * FIXME: what's the point of reading the mda_header and metadata,
+ * since we zero the rlocn fields whether we can read them or not.
+ */
+
+ if (!_raw_read_mda_header(mdah, &mdac->area, mda_is_primary(mda))) {
+ log_warn("WARNING: Removing metadata location on %s with bad mda header.",
+ dev_name(mdac->area.dev));
rlocn = &mdah->raw_locns[0];
mdah->raw_locns[1].offset = 0;
+ } else {
+ if (!(rlocn = _read_metadata_location_vg(&mdac->area, mdah, mda_is_primary(mda), vg->name, &noprecommit))) {
+ log_warn("WARNING: Removing metadata location on %s with bad metadata.",
+ dev_name(mdac->area.dev));
+ rlocn = &mdah->raw_locns[0];
+ mdah->raw_locns[1].offset = 0;
+ }
}
rlocn->offset = 0;
5 years, 12 months
master - scan: skip extra scan in vg_read
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=37471bb4777f3f407d2...
Commit: 37471bb4777f3f407d2cd942995b45c326ea221a
Parent: e4f478d86d6545f6cced7a8ba3bc0b79dccb7b6e
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 14 13:49:56 2018 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 20 11:22:46 2018 -0500
scan: skip extra scan in vg_read
Drop an extra label scan in the recovery part
of vg_read. This is a temporary improvement
until the pending replacement for the broken
recovery code burried in vg_read.
---
lib/metadata/metadata.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 5d3f835..b588a04 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -4080,8 +4080,6 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
/* Independent MDAs aren't supported under low memory */
if (!cmd->independent_metadata_areas && prioritized_section())
return_NULL;
- lvmcache_force_next_label_scan();
- lvmcache_label_scan(cmd);
if (!(fmt = lvmcache_fmt_from_vgname(cmd, vgname, vgid, 0)))
return_NULL;
5 years, 12 months
master - scan: handle request to scan missing dev
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e4f478d86d6545f6cce...
Commit: e4f478d86d6545f6cced7a8ba3bc0b79dccb7b6e
Parent: 89f54a5094981c827ca557cb1381e5f1a028912c
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Feb 13 16:17:02 2018 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 20 11:22:46 2018 -0500
scan: handle request to scan missing dev
---
lib/label/label.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/lib/label/label.c b/lib/label/label.c
index 1268498..19beecf 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -257,6 +257,8 @@ struct bcache *scan_bcache;
static bool _in_bcache(struct device *dev)
{
+ if (!dev)
+ return NULL;
return (dev->flags & DEV_IN_BCACHE) ? true : false;
}
@@ -402,6 +404,9 @@ static int _scan_dev_open(struct device *dev)
int flags = 0;
int fd;
+ if (!dev)
+ return 0;
+
if (dev->flags & DEV_IN_BCACHE) {
log_error("scan_dev_open %s DEV_IN_BCACHE already set", dev_name(dev));
dev->flags &= ~DEV_IN_BCACHE;
5 years, 12 months