1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-22 06:50:52 +03:00

scan: enable full md filter when md 1.0 devices are present

The previous commit de2863739f2ea17d89d0e442379109f967b5919d
    scan: use full md filter when md 1.0 devices are present

needs the use_full_md_check flag in the md filter, but
the cmd struct is not available when the filter is run,
so that commit wasn't working.  Fix this by setting the
flag in a global variable.

(This was fixed in the master branch with commit 8eab37593
in which the cmd struct was passed to the filters, but it
was an intrusive change, so this commit is using the less
intrusive global variable.)
This commit is contained in:
David Teigland 2018-10-18 11:32:32 -05:00
parent de2863739f
commit e7bb508809
2 changed files with 19 additions and 27 deletions

View File

@ -16,6 +16,9 @@
#include "lib.h"
#include "filter.h"
/* See label.c comment about this hack. */
extern int use_full_md_check;
#ifdef __linux__
#define MSG_SKIPPING "%s: Skipping md component device"
@ -80,7 +83,7 @@
* that will not pass.
*/
static int _passes_md_filter(struct device *dev, int full)
static int _passes_md_filter(struct dev_filter *f, struct device *dev)
{
int ret;
@ -91,7 +94,7 @@ static int _passes_md_filter(struct device *dev, int full)
if (!md_filtering())
return 1;
ret = dev_is_md(dev, NULL, full);
ret = dev_is_md(dev, NULL, use_full_md_check);
if (ret == -EAGAIN) {
/* let pass, call again after scan */
@ -104,6 +107,7 @@ static int _passes_md_filter(struct device *dev, int full)
return 1;
if (ret == 1) {
log_debug_devs("md filter full %d excluding md component %s", use_full_md_check, dev_name(dev));
if (dev->ext.src == DEV_EXT_NONE)
log_debug_devs(MSG_SKIPPING, dev_name(dev));
else
@ -121,18 +125,6 @@ static int _passes_md_filter(struct device *dev, int full)
return 1;
}
static int _passes_md_filter_lite(struct dev_filter *f __attribute__((unused)),
struct device *dev)
{
return _passes_md_filter(dev, 0);
}
static int _passes_md_filter_full(struct dev_filter *f __attribute__((unused)),
struct device *dev)
{
return _passes_md_filter(dev, 1);
}
static void _destroy(struct dev_filter *f)
{
if (f->use_count)
@ -150,18 +142,7 @@ struct dev_filter *md_filter_create(struct cmd_context *cmd, struct dev_types *d
return NULL;
}
/*
* FIXME: for commands that want a full md check (pvcreate, vgcreate,
* vgextend), we do an extra read at the end of every device that the
* filter looks at. This isn't necessary; we only need to do the full
* md check on the PVs that these commands are trying to use.
*/
if (cmd->use_full_md_check)
f->passes_filter = _passes_md_filter_full;
else
f->passes_filter = _passes_md_filter_lite;
f->passes_filter = _passes_md_filter;
f->destroy = _destroy;
f->use_count = 0;
f->private = dt;

View File

@ -27,6 +27,7 @@
#include <unistd.h>
#include <sys/time.h>
int use_full_md_check;
/* FIXME Allow for larger labels? Restricted to single sector currently */
@ -868,8 +869,18 @@ int label_scan(struct cmd_context *cmd)
* devs in 'pvs', which is a pretty harmless effect from a
* pretty uncommon situation.
*/
if (dev_is_md_with_end_superblock(cmd->dev_types, dev))
if (dev_is_md_with_end_superblock(cmd->dev_types, dev)) {
cmd->use_full_md_check = 1;
/* This is a hack because 'cmd' is not passed
into the filters so we can't check the flag
in the cmd struct. The master branch has
changed the filters in commit 8eab37593eccb
to accept cmd, but it's a complex change
that I'm trying to avoid in the stable branch. */
use_full_md_check = 1;
}
};
dev_iter_destroy(iter);