summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--VERSION2
-rw-r--r--WHATS_NEW4
-rw-r--r--doc/example.conf12
-rw-r--r--include/.symlinks1
-rw-r--r--lib/Makefile.in1
-rw-r--r--lib/commands/toolcontext.c28
-rw-r--r--lib/config/defaults.h1
-rw-r--r--lib/filters/filter-md.c98
-rw-r--r--lib/filters/filter-md.h23
9 files changed, 159 insertions, 11 deletions
diff --git a/VERSION b/VERSION
index be07568df..501373df0 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.00.12-cvs (2004-04-14)
+2.00.13-cvs (2004-04-16)
diff --git a/WHATS_NEW b/WHATS_NEW
index dd2a16f33..64d0975b1 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -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.
Version 2.00.12 - 14 Apr 2004
diff --git a/doc/example.conf b/doc/example.conf
index 057239699..81c00de38 100644
--- a/doc/example.conf
+++ b/doc/example.conf
@@ -27,9 +27,6 @@ devices {
# the device will be accepted or rejected (ignored). Devices that
# 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
# 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.
write_cache_state = 1
- # An advanced setting.
+ # Advanced settings.
+
# List of pairs of additional acceptable block device types found
# in /proc/devices with maximum (non-zero) number of partitions.
# types = [ "fd", 16 ]
# If sysfs is mounted (2.6 kernels) restrict device scanning to
# the block devices it believes are valid.
+ # 1 enables; 0 disables.
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
diff --git a/include/.symlinks b/include/.symlinks
index a79ec97ea..955007c28 100644
--- a/include/.symlinks
+++ b/include/.symlinks
@@ -14,6 +14,7 @@
../lib/device/device.h
../lib/display/display.h
../lib/filters/filter-composite.h
+../lib/filters/filter-md.h
../lib/filters/filter-persistent.h
../lib/filters/filter-regex.h
../lib/filters/filter-sysfs.h
diff --git a/lib/Makefile.in b/lib/Makefile.in
index f9ceb114c..fa640597d 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -37,6 +37,7 @@ SOURCES =\
filters/filter-persistent.c \
filters/filter-regex.c \
filters/filter-sysfs.c \
+ filters/filter-md.c \
filters/filter.c \
format_text/archive.c \
format_text/export.c \
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index ba837b5fd..6b69c8850 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -23,6 +23,7 @@
#include "activate.h"
#include "filter.h"
#include "filter-composite.h"
+#include "filter-md.h"
#include "filter-persistent.h"
#include "filter-regex.h"
#include "filter-sysfs.h"
@@ -275,7 +276,7 @@ static int _init_dev_cache(struct cmd_context *cmd)
return 1;
}
-#define MAX_FILTERS 3
+#define MAX_FILTERS 4
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));
- /* 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",
DEFAULT_SYSFS_SCAN)) {
if ((filters[nr_filt] = sysfs_filter_create(cmd->proc_dir)))
nr_filt++;
}
- /* regex filter */
+ /* regex filter. Optional. */
if (!(cn = find_config_node(cmd->cft->root, "devices/filter")))
log_debug("devices/filter not found in config file: no regex "
"filter installed");
@@ -302,14 +313,21 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
return NULL;
}
- /* device type filter */
+ /* device type filter. Required. */
cn = find_config_node(cmd->cft->root, "devices/types");
if (!(filters[nr_filt++] = lvm_type_filter_create(cmd->proc_dir, cn))) {
log_error("Failed to create lvm type filter");
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) ?
filters[0] : composite_filter_create(nr_filt, filters);
}
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index d1e6d2908..76d905564 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -29,6 +29,7 @@
#define DEFAULT_DEV_DIR "/dev"
#define DEFAULT_PROC_DIR "/proc"
#define DEFAULT_SYSFS_SCAN 1
+#define DEFAULT_MD_COMPONENT_DETECTION 1
#define DEFAULT_LOCK_DIR "/var/lock/lvm"
#define DEFAULT_LOCKING_LIB "lvm2_locking.so"
diff --git a/lib/filters/filter-md.c b/lib/filters/filter-md.c
new file mode 100644
index 000000000..ea99abeb2
--- /dev/null
+++ b/lib/filters/filter-md.c
@@ -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
diff --git a/lib/filters/filter-md.h b/lib/filters/filter-md.h
new file mode 100644
index 000000000..6a98f0b0d
--- /dev/null
+++ b/lib/filters/filter-md.h
@@ -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
+