mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
filters: check for mpath before opening devs
Split out the partitioned device filter that needs to open the device and move the multipath filter in front of it. When a device is multipathed, sending I/O to the underlying paths may cause problems, the most obvious being I/O errors visible to lvm if a path is down. Revert the incorrect <backtrace> messages added when a device doesn't pass a filter. Log each filter initialisation to show sequence. Avoid duplicate 'Using $device' debug messages.
This commit is contained in:
parent
0da72743ca
commit
80bcdb93ff
@ -1,5 +1,8 @@
|
|||||||
Version 2.02.101 -
|
Version 2.02.101 -
|
||||||
===================================
|
===================================
|
||||||
|
Move mpath device filter before partitioned filter (which opens devices).
|
||||||
|
Split partitioned filter out of lvm_type filter.
|
||||||
|
Merge filter*.h into a single filter.h.
|
||||||
Require confirmation for vgchange -c when no VGs listed explicitly.
|
Require confirmation for vgchange -c when no VGs listed explicitly.
|
||||||
Also skip /var and /var/log by default in blkdeactivate when unmounting.
|
Also skip /var and /var/log by default in blkdeactivate when unmounting.
|
||||||
Add support for bind mounts in blkdeactivate.
|
Add support for bind mounts in blkdeactivate.
|
||||||
|
@ -17,12 +17,6 @@
|
|||||||
@top_srcdir@/lib/device/dev-type.h
|
@top_srcdir@/lib/device/dev-type.h
|
||||||
@top_srcdir@/lib/device/device.h
|
@top_srcdir@/lib/device/device.h
|
||||||
@top_srcdir@/lib/display/display.h
|
@top_srcdir@/lib/display/display.h
|
||||||
@top_srcdir@/lib/filters/filter-composite.h
|
|
||||||
@top_srcdir@/lib/filters/filter-md.h
|
|
||||||
@top_srcdir@/lib/filters/filter-mpath.h
|
|
||||||
@top_srcdir@/lib/filters/filter-persistent.h
|
|
||||||
@top_srcdir@/lib/filters/filter-regex.h
|
|
||||||
@top_srcdir@/lib/filters/filter-sysfs.h
|
|
||||||
@top_srcdir@/lib/filters/filter.h
|
@top_srcdir@/lib/filters/filter.h
|
||||||
@top_srcdir@/lib/format1/format1.h
|
@top_srcdir@/lib/format1/format1.h
|
||||||
@top_srcdir@/lib/format_pool/format_pool.h
|
@top_srcdir@/lib/format_pool/format_pool.h
|
||||||
|
@ -66,7 +66,8 @@ SOURCES =\
|
|||||||
filters/filter-sysfs.c \
|
filters/filter-sysfs.c \
|
||||||
filters/filter-md.c \
|
filters/filter-md.c \
|
||||||
filters/filter-mpath.c \
|
filters/filter-mpath.c \
|
||||||
filters/filter.c \
|
filters/filter-partitioned.c \
|
||||||
|
filters/filter-type.c \
|
||||||
format_text/archive.c \
|
format_text/archive.c \
|
||||||
format_text/archiver.c \
|
format_text/archiver.c \
|
||||||
format_text/export.c \
|
format_text/export.c \
|
||||||
|
@ -20,12 +20,6 @@
|
|||||||
#include "lvm-string.h"
|
#include "lvm-string.h"
|
||||||
#include "activate.h"
|
#include "activate.h"
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "filter-composite.h"
|
|
||||||
#include "filter-md.h"
|
|
||||||
#include "filter-mpath.h"
|
|
||||||
#include "filter-persistent.h"
|
|
||||||
#include "filter-regex.h"
|
|
||||||
#include "filter-sysfs.h"
|
|
||||||
#include "label.h"
|
#include "label.h"
|
||||||
#include "lvm-file.h"
|
#include "lvm-file.h"
|
||||||
#include "format-text.h"
|
#include "format-text.h"
|
||||||
@ -35,7 +29,6 @@
|
|||||||
#include "segtype.h"
|
#include "segtype.h"
|
||||||
#include "lvmcache.h"
|
#include "lvmcache.h"
|
||||||
#include "lvmetad.h"
|
#include "lvmetad.h"
|
||||||
#include "dev-cache.h"
|
|
||||||
#include "archiver.h"
|
#include "archiver.h"
|
||||||
|
|
||||||
#ifdef HAVE_LIBDL
|
#ifdef HAVE_LIBDL
|
||||||
@ -824,7 +817,7 @@ static int _init_dev_cache(struct cmd_context *cmd)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_FILTERS 5
|
#define MAX_FILTERS 6
|
||||||
|
|
||||||
static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
|
static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
|
||||||
{
|
{
|
||||||
@ -853,7 +846,6 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
|
|||||||
if (!(cn = find_config_tree_node(cmd, devices_filter_CFG, NULL)))
|
if (!(cn = find_config_tree_node(cmd, devices_filter_CFG, NULL)))
|
||||||
log_very_verbose("devices/filter not found in config file: "
|
log_very_verbose("devices/filter not found in config file: "
|
||||||
"no regex filter installed");
|
"no regex filter installed");
|
||||||
|
|
||||||
else if (!(filters[nr_filt] = regex_filter_create(cn->v))) {
|
else if (!(filters[nr_filt] = regex_filter_create(cn->v))) {
|
||||||
log_error("Failed to create regex device filter");
|
log_error("Failed to create regex device filter");
|
||||||
goto bad;
|
goto bad;
|
||||||
@ -867,6 +859,19 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
|
|||||||
}
|
}
|
||||||
nr_filt++;
|
nr_filt++;
|
||||||
|
|
||||||
|
/* mpath component filter. Optional, non-critical. */
|
||||||
|
if (find_config_tree_bool(cmd, devices_multipath_component_detection_CFG, NULL)) {
|
||||||
|
if ((filters[nr_filt] = mpath_filter_create(cmd->dev_types)))
|
||||||
|
nr_filt++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* partitioned device filter. Required. */
|
||||||
|
if (!(filters[nr_filt] = partitioned_filter_create(cmd->dev_types))) {
|
||||||
|
log_error("Failed to create partitioned device filter");
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
nr_filt++;
|
||||||
|
|
||||||
/* md component filter. Optional, non-critical. */
|
/* md component filter. Optional, non-critical. */
|
||||||
if (find_config_tree_bool(cmd, devices_md_component_detection_CFG, NULL)) {
|
if (find_config_tree_bool(cmd, devices_md_component_detection_CFG, NULL)) {
|
||||||
init_md_filtering(1);
|
init_md_filtering(1);
|
||||||
@ -874,12 +879,6 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
|
|||||||
nr_filt++;
|
nr_filt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mpath component filter. Optional, non-critical. */
|
|
||||||
if (find_config_tree_bool(cmd, devices_multipath_component_detection_CFG, NULL)) {
|
|
||||||
if ((filters[nr_filt] = mpath_filter_create(cmd->dev_types)))
|
|
||||||
nr_filt++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Only build a composite filter if we really need it. */
|
/* Only build a composite filter if we really need it. */
|
||||||
if (nr_filt == 1)
|
if (nr_filt == 1)
|
||||||
return filters[0];
|
return filters[0];
|
||||||
@ -888,6 +887,7 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
|
|||||||
goto_bad;
|
goto_bad;
|
||||||
|
|
||||||
return composite;
|
return composite;
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
while (--nr_filt >= 0)
|
while (--nr_filt >= 0)
|
||||||
filters[nr_filt]->destroy(filters[nr_filt]);
|
filters[nr_filt]->destroy(filters[nr_filt]);
|
||||||
|
@ -14,10 +14,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
#include "dev-cache.h"
|
|
||||||
#include "lvm-types.h"
|
#include "lvm-types.h"
|
||||||
#include "btree.h"
|
#include "btree.h"
|
||||||
#include "filter.h"
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "toolcontext.h"
|
#include "toolcontext.h"
|
||||||
|
|
||||||
@ -923,8 +921,11 @@ struct device *dev_cache_get(const char *name, struct dev_filter *f)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (d && (!f || (d->flags & DEV_REGULAR) ||
|
if (!d || (f && !(d->flags & DEV_REGULAR) && !(f->passes_filter(f, d))))
|
||||||
f->passes_filter(f, d))) ? d : NULL;
|
return NULL;
|
||||||
|
|
||||||
|
log_debug_devs("Using %s", dev_name(d));
|
||||||
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct device *_dev_cache_seek_devt(dev_t dev)
|
static struct device *_dev_cache_seek_devt(dev_t dev)
|
||||||
@ -1007,8 +1008,10 @@ struct device *dev_iter_get(struct dev_iter *iter)
|
|||||||
while (iter->current) {
|
while (iter->current) {
|
||||||
struct device *d = _iter_next(iter);
|
struct device *d = _iter_next(iter);
|
||||||
if (!iter->filter || (d->flags & DEV_REGULAR) ||
|
if (!iter->filter || (d->flags & DEV_REGULAR) ||
|
||||||
iter->filter->passes_filter(iter->filter, d))
|
iter->filter->passes_filter(iter->filter, d)) {
|
||||||
|
log_debug_devs("Using %s", dev_name(d));
|
||||||
return d;
|
return d;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
#include "filter-composite.h"
|
#include "filter.h"
|
||||||
|
|
||||||
static int _and_p(struct dev_filter *f, struct device *dev)
|
static int _and_p(struct dev_filter *f, struct device *dev)
|
||||||
{
|
{
|
||||||
@ -22,9 +22,7 @@ static int _and_p(struct dev_filter *f, struct device *dev)
|
|||||||
|
|
||||||
for (filters = (struct dev_filter **) f->private; *filters; ++filters)
|
for (filters = (struct dev_filter **) f->private; *filters; ++filters)
|
||||||
if (!(*filters)->passes_filter(*filters, dev))
|
if (!(*filters)->passes_filter(*filters, dev))
|
||||||
return_0;
|
return 0; /* No 'stack': a filter, not an error. */
|
||||||
|
|
||||||
log_debug_devs("Using %s", dev_name(dev));
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -92,5 +90,7 @@ struct dev_filter *composite_filter_create(int n, struct dev_filter **filters)
|
|||||||
cft->use_count = 0;
|
cft->use_count = 0;
|
||||||
cft->private = filters_copy;
|
cft->private = filters_copy;
|
||||||
|
|
||||||
|
log_debug_devs("Composite filter initialised.");
|
||||||
|
|
||||||
return cft;
|
return cft;
|
||||||
}
|
}
|
||||||
|
@ -1,23 +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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LVM_FILTER_COMPOSITE_H
|
|
||||||
#define _LVM_FILTER_COMPOSITE_H
|
|
||||||
|
|
||||||
#include "dev-cache.h"
|
|
||||||
|
|
||||||
struct dev_filter *composite_filter_create(int n, struct dev_filter **filters);
|
|
||||||
|
|
||||||
#endif
|
|
@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
#include "filter-md.h"
|
#include "filter.h"
|
||||||
|
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
|
|
||||||
@ -64,6 +64,8 @@ struct dev_filter *md_filter_create(struct dev_types *dt)
|
|||||||
f->use_count = 0;
|
f->use_count = 0;
|
||||||
f->private = dt;
|
f->private = dt;
|
||||||
|
|
||||||
|
log_debug_devs("MD filter initialised.");
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2004 Luca Berra
|
|
||||||
*
|
|
||||||
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LVM_FILTER_MD_H
|
|
||||||
#define _LVM_FILTER_MD_H
|
|
||||||
|
|
||||||
#include "dev-cache.h"
|
|
||||||
#include "dev-type.h"
|
|
||||||
|
|
||||||
struct dev_filter *md_filter_create(struct dev_types *dt);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
#include "filter-mpath.h"
|
#include "filter.h"
|
||||||
#include "activate.h"
|
#include "activate.h"
|
||||||
|
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
@ -228,6 +228,8 @@ struct dev_filter *mpath_filter_create(struct dev_types *dt)
|
|||||||
f->use_count = 0;
|
f->use_count = 0;
|
||||||
f->private = dt;
|
f->private = dt;
|
||||||
|
|
||||||
|
log_debug_devs("mpath filter initialised.");
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LVM_FILTER_MPATH_H
|
|
||||||
#define _LVM_FILTER_MPATH_H
|
|
||||||
|
|
||||||
#include "dev-cache.h"
|
|
||||||
#include "dev-type.h"
|
|
||||||
|
|
||||||
struct dev_filter *mpath_filter_create(struct dev_types *dt);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
83
lib/filters/filter-partitioned.c
Normal file
83
lib/filters/filter-partitioned.c
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||||
|
* Copyright (C) 2004-2012 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "lib.h"
|
||||||
|
#include "filter.h"
|
||||||
|
|
||||||
|
static int _passes_partitioned_filter(struct dev_filter *f, struct device *dev)
|
||||||
|
{
|
||||||
|
struct dev_types *dt = (struct dev_types *) f->private;
|
||||||
|
const char *name = dev_name(dev);
|
||||||
|
int ret = 0;
|
||||||
|
uint64_t size;
|
||||||
|
|
||||||
|
/* Check it's accessible */
|
||||||
|
if (!dev_open_readonly_quiet(dev)) {
|
||||||
|
log_debug_devs("%s: Skipping: open failed", name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check it's not too small */
|
||||||
|
if (!dev_get_size(dev, &size)) {
|
||||||
|
log_debug_devs("%s: Skipping: dev_get_size failed", name);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size < pv_min_size()) {
|
||||||
|
log_debug_devs("%s: Skipping: Too small to hold a PV", name);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dev_is_partitioned(dt, dev)) {
|
||||||
|
log_debug_devs("%s: Skipping: Partition table signature found",
|
||||||
|
name);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = 1;
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (!dev_close(dev))
|
||||||
|
stack;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _partitioned_filter_destroy(struct dev_filter *f)
|
||||||
|
{
|
||||||
|
if (f->use_count)
|
||||||
|
log_error(INTERNAL_ERROR "Destroying partitioned filter while in use %u times.", f->use_count);
|
||||||
|
|
||||||
|
dm_free(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct dev_filter *partitioned_filter_create(struct dev_types *dt)
|
||||||
|
{
|
||||||
|
struct dev_filter *f;
|
||||||
|
|
||||||
|
if (!(f = dm_zalloc(sizeof(struct dev_filter)))) {
|
||||||
|
log_error("Partitioned filter allocation failed");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
f->passes_filter = _passes_partitioned_filter;
|
||||||
|
f->destroy = _partitioned_filter_destroy;
|
||||||
|
f->use_count = 0;
|
||||||
|
f->private = dt;
|
||||||
|
|
||||||
|
log_debug_devs("Partitioned filter initialised.");
|
||||||
|
|
||||||
|
return f;
|
||||||
|
}
|
@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
#include "filter-persistent.h"
|
#include "filter.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "lvm-file.h"
|
#include "lvm-file.h"
|
||||||
#include "activate.h"
|
#include "activate.h"
|
||||||
@ -366,6 +366,8 @@ struct dev_filter *persistent_filter_create(struct dev_types *dt,
|
|||||||
f->wipe = _persistent_filter_wipe;
|
f->wipe = _persistent_filter_wipe;
|
||||||
f->dump = _persistent_filter_dump;
|
f->dump = _persistent_filter_dump;
|
||||||
|
|
||||||
|
log_debug_devs("Persistent filter initialised.");
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
|
||||||
* Copyright (C) 2004-2006 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LVM_FILTER_PERSISTENT_H
|
|
||||||
#define _LVM_FILTER_PERSISTENT_H
|
|
||||||
|
|
||||||
#include "dev-cache.h"
|
|
||||||
#include "dev-type.h"
|
|
||||||
|
|
||||||
struct dev_filter *persistent_filter_create(struct dev_types *dt,
|
|
||||||
struct dev_filter *f,
|
|
||||||
const char *file);
|
|
||||||
|
|
||||||
int persistent_filter_load(struct dev_filter *f, struct dm_config_tree **cft_out);
|
|
||||||
|
|
||||||
#endif
|
|
@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
#include "filter-regex.h"
|
#include "filter.h"
|
||||||
|
|
||||||
struct rfilter {
|
struct rfilter {
|
||||||
struct dm_pool *mem;
|
struct dm_pool *mem;
|
||||||
@ -212,6 +212,9 @@ struct dev_filter *regex_filter_create(const struct dm_config_value *patterns)
|
|||||||
f->destroy = _regex_destroy;
|
f->destroy = _regex_destroy;
|
||||||
f->use_count = 0;
|
f->use_count = 0;
|
||||||
f->private = rf;
|
f->private = rf;
|
||||||
|
|
||||||
|
log_debug_devs("Regex filter initialised.");
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
|
@ -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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LVM_FILTER_REGEX_H
|
|
||||||
#define _LVM_FILTER_REGEX_H
|
|
||||||
|
|
||||||
#include "dev-cache.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* patterns must be an array of strings of the form:
|
|
||||||
* [ra]<sep><regex><sep>, eg,
|
|
||||||
* r/cdrom/ - reject cdroms
|
|
||||||
* a|loop/[0-4]| - accept loops 0 to 4
|
|
||||||
* r|.*| - reject everything else
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct dev_filter *regex_filter_create(const struct dm_config_value *patterns);
|
|
||||||
|
|
||||||
#endif
|
|
@ -13,7 +13,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
#include "filter-sysfs.h"
|
#include "filter.h"
|
||||||
|
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
|
|
||||||
@ -324,6 +324,9 @@ struct dev_filter *sysfs_filter_create(void)
|
|||||||
f->destroy = _destroy;
|
f->destroy = _destroy;
|
||||||
f->use_count = 0;
|
f->use_count = 0;
|
||||||
f->private = ds;
|
f->private = ds;
|
||||||
|
|
||||||
|
log_debug_devs("Sysfs filter initialised.");
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LVM_FILTER_SYSFS_H
|
|
||||||
#define _LVM_FILTER_SYSFS_H
|
|
||||||
|
|
||||||
#include "dev-cache.h"
|
|
||||||
|
|
||||||
struct dev_filter *sysfs_filter_create(void);
|
|
||||||
|
|
||||||
#endif
|
|
@ -20,8 +20,6 @@ static int _passes_lvm_type_device_filter(struct dev_filter *f, struct device *d
|
|||||||
{
|
{
|
||||||
struct dev_types *dt = (struct dev_types *) f->private;
|
struct dev_types *dt = (struct dev_types *) f->private;
|
||||||
const char *name = dev_name(dev);
|
const char *name = dev_name(dev);
|
||||||
int ret = 0;
|
|
||||||
uint64_t size;
|
|
||||||
|
|
||||||
/* Is this a recognised device type? */
|
/* Is this a recognised device type? */
|
||||||
if (!dt->dev_type_array[MAJOR(dev->dev)].max_partitions) {
|
if (!dt->dev_type_array[MAJOR(dev->dev)].max_partitions) {
|
||||||
@ -30,36 +28,7 @@ static int _passes_lvm_type_device_filter(struct dev_filter *f, struct device *d
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check it's accessible */
|
return 1;
|
||||||
if (!dev_open_readonly_quiet(dev)) {
|
|
||||||
log_debug_devs("%s: Skipping: open failed", name);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check it's not too small */
|
|
||||||
if (!dev_get_size(dev, &size)) {
|
|
||||||
log_debug_devs("%s: Skipping: dev_get_size failed", name);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (size < pv_min_size()) {
|
|
||||||
log_debug_devs("%s: Skipping: Too small to hold a PV", name);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dev_is_partitioned(dt, dev)) {
|
|
||||||
log_debug_devs("%s: Skipping: Partition table signature found",
|
|
||||||
name);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = 1;
|
|
||||||
|
|
||||||
out:
|
|
||||||
if (!dev_close(dev))
|
|
||||||
stack;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _lvm_type_filter_destroy(struct dev_filter *f)
|
static void _lvm_type_filter_destroy(struct dev_filter *f)
|
||||||
@ -84,5 +53,7 @@ struct dev_filter *lvm_type_filter_create(struct dev_types *dt)
|
|||||||
f->use_count = 0;
|
f->use_count = 0;
|
||||||
f->private = dt;
|
f->private = dt;
|
||||||
|
|
||||||
|
log_debug_devs("LVM type filter initialised.");
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||||
* Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
|
* Copyright (C) 2004 Luca Berra
|
||||||
|
* Copyright (C) 2004-2013 Red Hat, Inc. All rights reserved.
|
||||||
*
|
*
|
||||||
* This file is part of LVM2.
|
* This file is part of LVM2.
|
||||||
*
|
*
|
||||||
@ -19,6 +20,26 @@
|
|||||||
#include "dev-cache.h"
|
#include "dev-cache.h"
|
||||||
#include "dev-type.h"
|
#include "dev-type.h"
|
||||||
|
|
||||||
|
struct dev_filter *composite_filter_create(int n, struct dev_filter **filters);
|
||||||
struct dev_filter *lvm_type_filter_create(struct dev_types *dt);
|
struct dev_filter *lvm_type_filter_create(struct dev_types *dt);
|
||||||
|
struct dev_filter *md_filter_create(struct dev_types *dt);
|
||||||
|
struct dev_filter *mpath_filter_create(struct dev_types *dt);
|
||||||
|
struct dev_filter *partitioned_filter_create(struct dev_types *dt);
|
||||||
|
struct dev_filter *persistent_filter_create(struct dev_types *dt,
|
||||||
|
struct dev_filter *f,
|
||||||
|
const char *file);
|
||||||
|
struct dev_filter *sysfs_filter_create(void);
|
||||||
|
|
||||||
#endif
|
/*
|
||||||
|
* patterns must be an array of strings of the form:
|
||||||
|
* [ra]<sep><regex><sep>, eg,
|
||||||
|
* r/cdrom/ - reject cdroms
|
||||||
|
* a|loop/[0-4]| - accept loops 0 to 4
|
||||||
|
* r|.*| - reject everything else
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct dev_filter *regex_filter_create(const struct dm_config_value *patterns);
|
||||||
|
|
||||||
|
int persistent_filter_load(struct dev_filter *f, struct dm_config_tree **cft_out);
|
||||||
|
|
||||||
|
#endif /* _LVM_FILTER_H */
|
||||||
|
@ -36,10 +36,6 @@
|
|||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
#include "filter.h"
|
|
||||||
#include "filter-composite.h"
|
|
||||||
#include "filter-persistent.h"
|
|
||||||
#include "filter-regex.h"
|
|
||||||
#include "metadata-exported.h"
|
#include "metadata-exported.h"
|
||||||
#include "locking.h"
|
#include "locking.h"
|
||||||
#include "lvm-exec.h"
|
#include "lvm-exec.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user