-2.00.12-cvs (2004-04-14)
+2.00.13-cvs (2004-04-16)
-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
# 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).
# 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
../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
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 \
#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"
return 1;
}
-#define MAX_FILTERS 3
+#define MAX_FILTERS 4
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");
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);
}
#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"
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
+