All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] Fix lvm on top of dmraid
@ 2009-07-14 20:24 Hans de Goede
       [not found] ` <1247603083-3513-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Hans de Goede @ 2009-07-14 20:24 UTC (permalink / raw)
  To: Discussion of Development and Customization of the Red Hat Linux Installer,
	initramfs
  Cc: Harald Hoyer, Hans de Goede

The lvm rules were failing to identify PV's on mdraid because
blkid/vol_id has not been run on md raidsets by previous rules.
---
 modules.d/90lvm/64-lvm-vol_id.rules |    1 +
 modules.d/90lvm/64-lvm.rules        |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/modules.d/90lvm/64-lvm-vol_id.rules b/modules.d/90lvm/64-lvm-vol_id.rules
index d3a07c1..f5f3a6f 100644
--- a/modules.d/90lvm/64-lvm-vol_id.rules
+++ b/modules.d/90lvm/64-lvm-vol_id.rules
@@ -8,6 +8,7 @@ SUBSYSTEM!="block", GOTO="lvm_end"
 ACTION!="add|change", GOTO="lvm_end"
 
 KERNEL=="dm-*", IMPORT{program}="vol_id --export $tempnode"
+KERNEL=="md*", IMPORT{program}="/sbin/blkid -o udev -p $tempnode"
 
 ENV{ID_FS_TYPE}=="LVM2_member", \
     TEST!="/tmp/.lvm_scan-%k", \
diff --git a/modules.d/90lvm/64-lvm.rules b/modules.d/90lvm/64-lvm.rules
index 3403020..a1c2d1f 100644
--- a/modules.d/90lvm/64-lvm.rules
+++ b/modules.d/90lvm/64-lvm.rules
@@ -8,6 +8,7 @@ SUBSYSTEM!="block", GOTO="lvm_end"
 ACTION!="add|change", GOTO="lvm_end"
 
 KERNEL=="dm-*", IMPORT{program}="/sbin/blkid -o udev -p $tempnode"
+KERNEL=="md*", IMPORT{program}="/sbin/blkid -o udev -p $tempnode"
 
 ENV{ID_FS_TYPE}=="LVM2_member", \
     TEST!="/tmp/.lvm_scan-%k", \
-- 
1.6.2.2

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] Make Intel BIOS raid use mdraid instead of dmraid when mdadm 3.0 is available
       [not found] ` <1247603083-3513-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2009-07-14 20:24   ` Hans de Goede
       [not found]     ` <1247603083-3513-2-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Hans de Goede @ 2009-07-14 20:24 UTC (permalink / raw)
  To: Discussion of Development and Customization of the Red Hat Linux Installer,
	initramfs
  Cc: Harald Hoyer, Hans de Goede

Intel BIOS raid is being shifted from dmraid to mdraid because mdraid offers
more features. So if an imsm metadata capable mdadm is present use mdraid
instead of dmraid for isw_raid_member's

This patch also adds code to mdraid_start.sh so that the raidsets
inside the imsm containers get started once udev is done probing
(doing this earlier leads to potentially degraded use of the sets and
 an unwanted resync).
---
 modules.d/90dmraid/61-dmraid-imsm.rules         |   15 +++++++++++++++
 modules.d/90dmraid/install                      |    6 +++++-
 modules.d/90mdraid/65-md-incremental-imsm.rules |   10 ++++++++++
 modules.d/90mdraid/install                      |    8 ++++++--
 modules.d/90mdraid/mdraid_start.sh              |   11 ++++++++++-
 5 files changed, 46 insertions(+), 4 deletions(-)
 create mode 100644 modules.d/90dmraid/61-dmraid-imsm.rules
 create mode 100644 modules.d/90mdraid/65-md-incremental-imsm.rules

diff --git a/modules.d/90dmraid/61-dmraid-imsm.rules b/modules.d/90dmraid/61-dmraid-imsm.rules
new file mode 100644
index 0000000..e06ea3f
--- /dev/null
+++ b/modules.d/90dmraid/61-dmraid-imsm.rules
@@ -0,0 +1,15 @@
+# This file causes block devices with Linux RAID (mdadm) signatures to
+# automatically cause mdadm to be run.
+# See udev(8) for syntax
+
+SUBSYSTEM!="block", GOTO="dm_end"
+ACTION!="add|change", GOTO="dm_end"
+
+ENV{ID_FS_TYPE}=="linux_raid_member", GOTO="dm_end"
+ENV{ID_FS_TYPE}=="isw_raid_member", GOTO="dm_end"
+
+ENV{ID_FS_TYPE}=="*_raid_member", \
+    TEST!="/tmp/.dmraid_scan-%k", \
+    RUN+="/bin/sh -c '>/tmp/.dmraid_scan-%k; /bin/ln -fs /sbin/dmraid_scan /initqueue/dmraid_scan.sh'"
+
+LABEL="dm_end"
diff --git a/modules.d/90dmraid/install b/modules.d/90dmraid/install
index fadaf0f..d8aca57 100755
--- a/modules.d/90dmraid/install
+++ b/modules.d/90dmraid/install
@@ -2,4 +2,8 @@
 dracut_install dmraid
 inst "$moddir/dmraid.sh" /sbin/dmraid_scan
 inst_rules 64-md-raid.rules
-inst_rules "$moddir/61-dmraid.rules"
+if [ ! -x /lib/udev/vol_id ] && mdadm -Q -e imsm /dev/null &> /dev/null; then
+    inst_rules "$moddir/61-dmraid-imsm.rules"
+else
+    inst_rules "$moddir/61-dmraid.rules"
+fi
diff --git a/modules.d/90mdraid/65-md-incremental-imsm.rules b/modules.d/90mdraid/65-md-incremental-imsm.rules
new file mode 100644
index 0000000..7dcdf33
--- /dev/null
+++ b/modules.d/90mdraid/65-md-incremental-imsm.rules
@@ -0,0 +1,10 @@
+# This file causes block devices with Linux RAID (mdadm) signatures to
+# automatically cause mdadm to be run.
+# See udev(8) for syntax
+
+SUBSYSTEM=="block", ACTION=="add", \
+        ENV{ID_FS_TYPE}=="linux_raid_member|isw_raid_member", \
+        TEST!="/tmp/.mdraid_start-%k", \
+	IMPORT{program}="/sbin/mdadm --examine --export $tempnode", \
+	RUN+="/sbin/mdadm -I --no-degraded $env{DEVNAME}", \
+	RUN+="/bin/sh -c '>/tmp/.mdraid_start-%k; /bin/ln -s /sbin/mdraid_start /initqueue/mdraid_start.sh'"
diff --git a/modules.d/90mdraid/install b/modules.d/90mdraid/install
index eef6567..0391957 100755
--- a/modules.d/90mdraid/install
+++ b/modules.d/90mdraid/install
@@ -12,7 +12,11 @@ instmods =drivers/md
 if [ -x /lib/udev/vol_id ]; then
     inst_rules "$moddir/61-mdadm.rules"
 else
-    inst_rules "$moddir/65-md-incremental.rules"
+    if mdadm -Q -e imsm /dev/null &> /dev/null; then
+        inst_rules "$moddir/65-md-incremental-imsm.rules"
+    else
+        inst_rules "$moddir/65-md-incremental.rules"
+    fi
     inst_rules 64-md-raid.rules
 fi
 
@@ -24,4 +28,4 @@ if [ -x  /sbin/mdmon ] ; then
 fi 
 
 inst "$moddir/mdraid_start.sh" /sbin/mdraid_start
-
+inst grep
diff --git a/modules.d/90mdraid/mdraid_start.sh b/modules.d/90mdraid/mdraid_start.sh
index 3475b7e..7293ded 100755
--- a/modules.d/90mdraid/mdraid_start.sh
+++ b/modules.d/90mdraid/mdraid_start.sh
@@ -4,5 +4,14 @@ if $UDEV_QUEUE_EMPTY >/dev/null 2>&1; then
     [ -h "$job" ] && rm -f "$job"
     # run mdadm if udev has settled
     mdadm -IRs
+    # and activate any containers
+    for md in /dev/md?*; do
+        case $md in
+            /dev/md*p*) ;;
+            *)
+                if mdadm --export --detail $md | grep -q container; then
+                    mdadm -IR $md
+                fi
+        esac
+    done
 fi
-
-- 
1.6.2.2

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] Tell the kernel to forget about partitions found on raw imsm raid disks
       [not found]     ` <1247603083-3513-2-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2009-07-14 20:24       ` Hans de Goede
       [not found]         ` <1247603083-3513-3-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Hans de Goede @ 2009-07-14 20:24 UTC (permalink / raw)
  To: Discussion of Development and Customization of the Red Hat Linux Installer,
	initramfs
  Cc: Harald Hoyer, Hans de Goede

When using a simple raid mirror, the kernel will find a valid partition
table on the raw disks, so partitions of the set can not only be
accessed through the mdraid subsystem but also through /dev/rawdisk#,
this is very undesirable.

This patch call a new rm_partitions utility on the raw disks of
an imsm raidset when using mdraid for it, for dmraid we have
the -Z option to dmraid, although this assumes that nothing touches
the raw partitions between the initial disk add event and dmraid running
(once udev is done probing) so it might be better to switch to
the same mechanism for dmraid too.

This patch currently assumes this new utility (code included) will become
part of udev and will live in /lib/udev, for now it is probably a good idea
to include this utility with dracut as we are doing with switch_root
---
 modules.d/90mdraid/65-md-incremental-imsm.rules |    1 +
 modules.d/90mdraid/install                      |    1 +
 rm_partitions.c                                 |   78 +++++++++++++++++++++++
 3 files changed, 80 insertions(+), 0 deletions(-)
 create mode 100644 rm_partitions.c

diff --git a/modules.d/90mdraid/65-md-incremental-imsm.rules b/modules.d/90mdraid/65-md-incremental-imsm.rules
index 7dcdf33..9617d6d 100644
--- a/modules.d/90mdraid/65-md-incremental-imsm.rules
+++ b/modules.d/90mdraid/65-md-incremental-imsm.rules
@@ -6,5 +6,6 @@ SUBSYSTEM=="block", ACTION=="add", \
         ENV{ID_FS_TYPE}=="linux_raid_member|isw_raid_member", \
         TEST!="/tmp/.mdraid_start-%k", \
 	IMPORT{program}="/sbin/mdadm --examine --export $tempnode", \
+	RUN+="/lib/udev/rm_partitions $env{DEVNAME}", \
 	RUN+="/sbin/mdadm -I --no-degraded $env{DEVNAME}", \
 	RUN+="/bin/sh -c '>/tmp/.mdraid_start-%k; /bin/ln -s /sbin/mdraid_start /initqueue/mdraid_start.sh'"
diff --git a/modules.d/90mdraid/install b/modules.d/90mdraid/install
index 0391957..ec31e3f 100755
--- a/modules.d/90mdraid/install
+++ b/modules.d/90mdraid/install
@@ -13,6 +13,7 @@ if [ -x /lib/udev/vol_id ]; then
     inst_rules "$moddir/61-mdadm.rules"
 else
     if mdadm -Q -e imsm /dev/null &> /dev/null; then
+        dracut_install /lib/udev/rm_partitions
         inst_rules "$moddir/65-md-incremental-imsm.rules"
     else
         inst_rules "$moddir/65-md-incremental.rules"
diff --git a/rm_partitions.c b/rm_partitions.c
new file mode 100644
index 0000000..2cddda1
--- /dev/null
+++ b/rm_partitions.c
@@ -0,0 +1,78 @@
+/*
+
+# Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
+#
+# Copyright 2009 Red Hat, Inc.
+#
+# 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
+# General Public License v.2.  This program is distributed in the hope that it
+# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
+# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat
+# trademarks that are incorporated in the source code or documentation are not
+# subject to the GNU General Public License and may only be used or replicated
+# with the express permission of Red Hat, Inc. 
+
+*/
+#include <linux/blkpg.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+/* Remove the partition block devices (ie sda1) from block devices (ie sda)
+   the main purpose of this is to make things like lvm, hal and blkid
+   not try to access the partitions the kernel finds on disks which are
+   part of a BIOS-RAID set. */
+static int remove_partitions(const char *device_node)
+{
+	struct blkpg_partition part = { 0, };
+	struct blkpg_ioctl_arg io = {
+		.op = BLKPG_DEL_PARTITION,
+		.datalen = sizeof(part),
+		.data = &part,
+	};
+
+	int fd = open(device_node, O_RDWR);
+	if (fd < 0) {
+		fprintf(stderr, "Error opening %s: %s\n", device_node,
+			strerror(errno));
+		return -1;
+	}
+
+	/* There is no way to enumerate partitions */
+	for (part.pno = 1; part.pno <= 256; part.pno++) {
+		if (ioctl(fd, BLKPG, &io) < 0 && errno != ENXIO &&
+				(part.pno < 16 || errno != EINVAL)) {
+			fprintf(stderr,
+				"Error removing part %d from %s: %s\n",
+				part.pno, device_node,
+				strerror(errno));
+			return -1;
+		}
+	}
+	return 0;
+}
+
+int main (int argc, char *argv[])
+{
+	int i;
+
+	if (argc < 2) {
+		printf("Usage: %s <disk-device-node-path> [more-disks]\n",
+			argv[0]);
+		printf("Example: \"%s /dev/sda\"\n", argv[0]);
+		return 2;
+	}
+
+	for (i = 1; i < argc; i++)
+		if (remove_partitions(argv[i]))
+			return 1;
+
+	return 0;
+}
-- 
1.6.2.2

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] Tell the kernel to forget about partitions found on raw imsm raid disks
       [not found]         ` <1247603083-3513-3-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2009-07-14 23:02           ` Karel Zak
       [not found]             ` <20090714230219.GA5766-sHeGUpI7y9L/9pzu0YdTqQ@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Karel Zak @ 2009-07-14 23:02 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Discussion of Development and Customization of the Red Hat Linux Installer,
	initramfs, Harald Hoyer


 Hi Hans,

On Tue, Jul 14, 2009 at 10:24:43PM +0200, Hans de Goede wrote:
> This patch currently assumes this new utility (code included) will become
> part of udev and will live in /lib/udev, for now it is probably a good idea

 I hope not. The utility duplicate partx(8) / delpart(8) code.

> --- a/modules.d/90mdraid/65-md-incremental-imsm.rules
> +++ b/modules.d/90mdraid/65-md-incremental-imsm.rules
> @@ -6,5 +6,6 @@ SUBSYSTEM=="block", ACTION=="add", \
>         ENV{ID_FS_TYPE}=="linux_raid_member|isw_raid_member", \
>         TEST!="/tmp/.mdraid_start-%k", \
> 	IMPORT{program}="/sbin/mdadm --examine --export $tempnode", \
>+	RUN+="/lib/udev/rm_partitions $env{DEVNAME}", \

 + RUN+=/sbin/partx -d $env{DEVNAME}", \

> +static int remove_partitions(const char *device_node)
> +{
> +	struct blkpg_partition part = { 0, };
> +	struct blkpg_ioctl_arg io = {
> +		.op = BLKPG_DEL_PARTITION,
> +		.datalen = sizeof(part),
> +		.data = &part,
> +	};
> +
> +	int fd = open(device_node, O_RDWR);
> +	if (fd < 0) {
> +		fprintf(stderr, "Error opening %s: %s\n", device_node,
> +			strerror(errno));
> +		return -1;
> +	}
> +
> +	/* There is no way to enumerate partitions */

 /proc/partitions or /sys/block/<disk>/<disk>[N] or at least 
 use the limit from /sys/block/<disk>/range.

 Unfortunately, partx is also blind and does not use any precisely
 defined list/range of partitions.

> +	for (part.pno = 1; part.pno <= 256; part.pno++) {
> +		if (ioctl(fd, BLKPG, &io) < 0 && errno != ENXIO &&
> +				(part.pno < 16 || errno != EINVAL)) {
> +			fprintf(stderr,
> +				"Error removing part %d from %s: %s\n",
> +				part.pno, device_node,
> +				strerror(errno));
> +			return -1;
> +		}
> +	}


    Karel

-- 
 Karel Zak  <kzak-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] Tell the kernel to forget about partitions found on raw imsm raid disks
       [not found]             ` <20090714230219.GA5766-sHeGUpI7y9L/9pzu0YdTqQ@public.gmane.org>
@ 2009-07-15  8:03               ` Hans de Goede
  0 siblings, 0 replies; 5+ messages in thread
From: Hans de Goede @ 2009-07-15  8:03 UTC (permalink / raw)
  To: Karel Zak
  Cc: Discussion of Development and Customization of the Red Hat Linux Installer,
	initramfs, Harald Hoyer

Hi,

On 07/15/2009 01:02 AM, Karel Zak wrote:
>   Hi Hans,
>
> On Tue, Jul 14, 2009 at 10:24:43PM +0200, Hans de Goede wrote:
>> This patch currently assumes this new utility (code included) will become
>> part of udev and will live in /lib/udev, for now it is probably a good idea
>
>   I hope not. The utility duplicate partx(8) / delpart(8) code.
>
>> --- a/modules.d/90mdraid/65-md-incremental-imsm.rules
>> +++ b/modules.d/90mdraid/65-md-incremental-imsm.rules
>> @@ -6,5 +6,6 @@ SUBSYSTEM=="block", ACTION=="add", \
>>          ENV{ID_FS_TYPE}=="linux_raid_member|isw_raid_member", \
>>          TEST!="/tmp/.mdraid_start-%k", \
>> 	IMPORT{program}="/sbin/mdadm --examine --export $tempnode", \
>> +	RUN+="/lib/udev/rm_partitions $env{DEVNAME}", \
>
>   + RUN+=/sbin/partx -d $env{DEVNAME}", \
>

Ah, good one I only knew about kpartx not partx, yes partx is the way to
go (assumed it works I've not tested this yet), no need to invent a
new utility.

Regards,

Hans
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-07-15  8:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-14 20:24 [PATCH 1/3] Fix lvm on top of dmraid Hans de Goede
     [not found] ` <1247603083-3513-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-07-14 20:24   ` [PATCH 2/3] Make Intel BIOS raid use mdraid instead of dmraid when mdadm 3.0 is available Hans de Goede
     [not found]     ` <1247603083-3513-2-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-07-14 20:24       ` [PATCH 3/3] Tell the kernel to forget about partitions found on raw imsm raid disks Hans de Goede
     [not found]         ` <1247603083-3513-3-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-07-14 23:02           ` Karel Zak
     [not found]             ` <20090714230219.GA5766-sHeGUpI7y9L/9pzu0YdTqQ@public.gmane.org>
2009-07-15  8:03               ` Hans de Goede

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.