]> sourceware.org Git - lvm2.git/commitdiff
Set devices/md_component_detection = 1 to ignore devices containing md
authorAlasdair Kergon <agk@redhat.com>
Fri, 16 Apr 2004 16:12:04 +0000 (16:12 +0000)
committerAlasdair Kergon <agk@redhat.com>
Fri, 16 Apr 2004 16:12:04 +0000 (16:12 +0000)
superblocks. [Luca Berra]

VERSION
WHATS_NEW
doc/example.conf
include/.symlinks
lib/Makefile.in
lib/commands/toolcontext.c
lib/config/defaults.h
lib/filters/filter-md.c [new file with mode: 0644]
lib/filters/filter-md.h [new file with mode: 0644]

diff --git a/VERSION b/VERSION
index be07568df8d8e35daea608b22c2c87169037bc21..501373df0c1a45b1a7b7a741f188afd55a86e0b2 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.00.12-cvs (2004-04-14)
+2.00.13-cvs (2004-04-16)
index dd2a16f3359245bf218082027c55646dbbb1de08..64d0975b149abc04901b960cc2b853ba6f4ee179 100644 (file)
--- 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
index 057239699cbb74bdc3e7c541bab8c26b6024d8d1..81c00de389d81ee65a53452e4dc27db7f527feef 100644 (file)
@@ -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
index a79ec97eacefae0dcafb9fa754108a9c74ac6744..955007c28c9cf89f1745f6de07947e56e7679ec3 100644 (file)
@@ -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
index f9ceb114c9647f26b5d8f5aa1b6cc09809f4e4aa..fa640597dd864318f09ec32cf00bcd00038580d1 100644 (file)
@@ -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 \
index ba837b5fdd6871012f2f3d9f403c70be08bfd5a2..6b69c885029d49830d23dd80c2a9a94ff27f9a37 100644 (file)
@@ -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);
 }
index d1e6d2908e213be2d675b8e5511932d1cda04837..76d90556421a6cde1beac2b90c74eafca343ea84 100644 (file)
@@ -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 (file)
index 0000000..ea99abe
--- /dev/null
@@ -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 (file)
index 0000000..6a98f0b
--- /dev/null
@@ -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
+
This page took 0.049479 seconds and 5 git commands to generate.