mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Set devices/md_component_detection = 1 to ignore devices containing md
superblocks. [Luca Berra]
This commit is contained in:
parent
121c5c060b
commit
01c6121ba5
@ -1,5 +1,7 @@
|
|||||||
Version 2.00.13 - 64 Apr 2004
|
Version 2.00.13 - 16 Apr 2004
|
||||||
=============================
|
=============================
|
||||||
|
Set devices/md_component_detection = 1 to ignore devices containing md
|
||||||
|
superblocks. [Luca Berra]
|
||||||
Ignore error setting selinux file context if fs doesn't support it.
|
Ignore error setting selinux file context if fs doesn't support it.
|
||||||
|
|
||||||
Version 2.00.12 - 14 Apr 2004
|
Version 2.00.12 - 14 Apr 2004
|
||||||
|
@ -27,9 +27,6 @@ devices {
|
|||||||
# the device will be accepted or rejected (ignored). Devices that
|
# the device will be accepted or rejected (ignored). Devices that
|
||||||
# don't match any patterns are accepted.
|
# don't match any patterns are accepted.
|
||||||
|
|
||||||
# If using RAID md devices as physical volumes, you should
|
|
||||||
# set up a filter here to reject the constituent devices.
|
|
||||||
|
|
||||||
# Remember to run vgscan after you change this parameter to ensure
|
# Remember to run vgscan after you change this parameter to ensure
|
||||||
# that the cache file gets regenerated (see below).
|
# that the cache file gets regenerated (see below).
|
||||||
|
|
||||||
@ -57,14 +54,21 @@ devices {
|
|||||||
# You can turn off writing this cache file by setting this to 0.
|
# You can turn off writing this cache file by setting this to 0.
|
||||||
write_cache_state = 1
|
write_cache_state = 1
|
||||||
|
|
||||||
# An advanced setting.
|
# Advanced settings.
|
||||||
|
|
||||||
# List of pairs of additional acceptable block device types found
|
# List of pairs of additional acceptable block device types found
|
||||||
# in /proc/devices with maximum (non-zero) number of partitions.
|
# in /proc/devices with maximum (non-zero) number of partitions.
|
||||||
# types = [ "fd", 16 ]
|
# types = [ "fd", 16 ]
|
||||||
|
|
||||||
# If sysfs is mounted (2.6 kernels) restrict device scanning to
|
# If sysfs is mounted (2.6 kernels) restrict device scanning to
|
||||||
# the block devices it believes are valid.
|
# the block devices it believes are valid.
|
||||||
|
# 1 enables; 0 disables.
|
||||||
sysfs_scan = 1
|
sysfs_scan = 1
|
||||||
|
|
||||||
|
# By default, LVM2 will ignore devices used as components of
|
||||||
|
# software RAID (md) devices by looking for md superblocks.
|
||||||
|
# 1 enables; 0 disables.
|
||||||
|
md_component_detection = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# This section that allows you to configure the nature of the
|
# This section that allows you to configure the nature of the
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
../lib/device/device.h
|
../lib/device/device.h
|
||||||
../lib/display/display.h
|
../lib/display/display.h
|
||||||
../lib/filters/filter-composite.h
|
../lib/filters/filter-composite.h
|
||||||
|
../lib/filters/filter-md.h
|
||||||
../lib/filters/filter-persistent.h
|
../lib/filters/filter-persistent.h
|
||||||
../lib/filters/filter-regex.h
|
../lib/filters/filter-regex.h
|
||||||
../lib/filters/filter-sysfs.h
|
../lib/filters/filter-sysfs.h
|
||||||
|
@ -37,6 +37,7 @@ SOURCES =\
|
|||||||
filters/filter-persistent.c \
|
filters/filter-persistent.c \
|
||||||
filters/filter-regex.c \
|
filters/filter-regex.c \
|
||||||
filters/filter-sysfs.c \
|
filters/filter-sysfs.c \
|
||||||
|
filters/filter-md.c \
|
||||||
filters/filter.c \
|
filters/filter.c \
|
||||||
format_text/archive.c \
|
format_text/archive.c \
|
||||||
format_text/export.c \
|
format_text/export.c \
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "activate.h"
|
#include "activate.h"
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "filter-composite.h"
|
#include "filter-composite.h"
|
||||||
|
#include "filter-md.h"
|
||||||
#include "filter-persistent.h"
|
#include "filter-persistent.h"
|
||||||
#include "filter-regex.h"
|
#include "filter-regex.h"
|
||||||
#include "filter-sysfs.h"
|
#include "filter-sysfs.h"
|
||||||
@ -275,7 +276,7 @@ static int _init_dev_cache(struct cmd_context *cmd)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_FILTERS 3
|
#define MAX_FILTERS 4
|
||||||
|
|
||||||
static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
|
static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
|
||||||
{
|
{
|
||||||
@ -285,14 +286,24 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
|
|||||||
|
|
||||||
memset(filters, 0, sizeof(filters));
|
memset(filters, 0, sizeof(filters));
|
||||||
|
|
||||||
/* sysfs filter */
|
/*
|
||||||
|
* Filters listed in order: top one gets applied first.
|
||||||
|
* Failure to initialise some filters is not fatal.
|
||||||
|
* Update MAX_FILTERS definition above when adding new filters.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* sysfs filter. Only available on 2.6 kernels. Non-critical.
|
||||||
|
* Listed first because it's very efficient at eliminating
|
||||||
|
* unavailable devices.
|
||||||
|
*/
|
||||||
if (find_config_bool(cmd->cft->root, "devices/sysfs_scan",
|
if (find_config_bool(cmd->cft->root, "devices/sysfs_scan",
|
||||||
DEFAULT_SYSFS_SCAN)) {
|
DEFAULT_SYSFS_SCAN)) {
|
||||||
if ((filters[nr_filt] = sysfs_filter_create(cmd->proc_dir)))
|
if ((filters[nr_filt] = sysfs_filter_create(cmd->proc_dir)))
|
||||||
nr_filt++;
|
nr_filt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* regex filter */
|
/* regex filter. Optional. */
|
||||||
if (!(cn = find_config_node(cmd->cft->root, "devices/filter")))
|
if (!(cn = find_config_node(cmd->cft->root, "devices/filter")))
|
||||||
log_debug("devices/filter not found in config file: no regex "
|
log_debug("devices/filter not found in config file: no regex "
|
||||||
"filter installed");
|
"filter installed");
|
||||||
@ -302,14 +313,21 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* device type filter */
|
/* device type filter. Required. */
|
||||||
cn = find_config_node(cmd->cft->root, "devices/types");
|
cn = find_config_node(cmd->cft->root, "devices/types");
|
||||||
if (!(filters[nr_filt++] = lvm_type_filter_create(cmd->proc_dir, cn))) {
|
if (!(filters[nr_filt++] = lvm_type_filter_create(cmd->proc_dir, cn))) {
|
||||||
log_error("Failed to create lvm type filter");
|
log_error("Failed to create lvm type filter");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* only build a composite filter if we really need it */
|
/* md component filter. Optional, non-critical. */
|
||||||
|
if (find_config_bool(cmd->cft->root, "devices/md_component_detection",
|
||||||
|
DEFAULT_MD_COMPONENT_DETECTION)) {
|
||||||
|
if ((filters[nr_filt] = md_filter_create()))
|
||||||
|
nr_filt++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Only build a composite filter if we really need it. */
|
||||||
return (nr_filt == 1) ?
|
return (nr_filt == 1) ?
|
||||||
filters[0] : composite_filter_create(nr_filt, filters);
|
filters[0] : composite_filter_create(nr_filt, filters);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#define DEFAULT_DEV_DIR "/dev"
|
#define DEFAULT_DEV_DIR "/dev"
|
||||||
#define DEFAULT_PROC_DIR "/proc"
|
#define DEFAULT_PROC_DIR "/proc"
|
||||||
#define DEFAULT_SYSFS_SCAN 1
|
#define DEFAULT_SYSFS_SCAN 1
|
||||||
|
#define DEFAULT_MD_COMPONENT_DETECTION 1
|
||||||
|
|
||||||
#define DEFAULT_LOCK_DIR "/var/lock/lvm"
|
#define DEFAULT_LOCK_DIR "/var/lock/lvm"
|
||||||
#define DEFAULT_LOCKING_LIB "lvm2_locking.so"
|
#define DEFAULT_LOCKING_LIB "lvm2_locking.so"
|
||||||
|
98
lib/filters/filter-md.c
Normal file
98
lib/filters/filter-md.c
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "lib.h"
|
||||||
|
#include "filter-md.h"
|
||||||
|
#include "metadata.h"
|
||||||
|
|
||||||
|
#ifdef linux
|
||||||
|
|
||||||
|
/* Lifted from <linux/raid/md_p.h> because of difficulty including it */
|
||||||
|
|
||||||
|
#define MD_SB_MAGIC 0xa92b4efc
|
||||||
|
#define MD_RESERVED_BYTES (64 * 1024)
|
||||||
|
#define MD_RESERVED_SECTORS (MD_RESERVED_BYTES / 512)
|
||||||
|
#define MD_NEW_SIZE_SECTORS(x) ((x & ~(MD_RESERVED_SECTORS - 1)) \
|
||||||
|
- MD_RESERVED_SECTORS)
|
||||||
|
|
||||||
|
static int _ignore_md(struct dev_filter *f, struct device *dev)
|
||||||
|
{
|
||||||
|
uint64_t size, sector;
|
||||||
|
uint32_t md_magic;
|
||||||
|
|
||||||
|
if (!dev_get_size(dev, &size)) {
|
||||||
|
stack;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size < MD_RESERVED_SECTORS * 2)
|
||||||
|
/*
|
||||||
|
* We could ignore it since it is obviously too
|
||||||
|
* small, but that's not our job.
|
||||||
|
*/
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (!dev_open(dev)) {
|
||||||
|
stack;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sector = MD_NEW_SIZE_SECTORS(size);
|
||||||
|
|
||||||
|
/* Check if it is an md component device. */
|
||||||
|
if (dev_read(dev, sector << SECTOR_SHIFT, sizeof(uint32_t), &md_magic)) {
|
||||||
|
if (md_magic == MD_SB_MAGIC) {
|
||||||
|
log_debug("%s: Skipping md component device",
|
||||||
|
dev_name(dev));
|
||||||
|
if (!dev_close(dev))
|
||||||
|
stack;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dev_close(dev))
|
||||||
|
stack;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _destroy(struct dev_filter *f)
|
||||||
|
{
|
||||||
|
dbg_free(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct dev_filter *md_filter_create(void)
|
||||||
|
{
|
||||||
|
struct dev_filter *f;
|
||||||
|
|
||||||
|
if (!(f = dbg_malloc(sizeof(*f)))) {
|
||||||
|
log_error("md filter allocation failed");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
f->passes_filter = _ignore_md;
|
||||||
|
f->destroy = _destroy;
|
||||||
|
f->private = NULL;
|
||||||
|
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
struct dev_filter *md_filter_create(void)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
23
lib/filters/filter-md.h
Normal file
23
lib/filters/filter-md.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* 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"
|
||||||
|
|
||||||
|
struct dev_filter *md_filter_create(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user