[Dmraid-debian-commits] [SCM] Maintenance of the dmraid package branch, master, updated. debian/1.0.0.rc15-1.exp6-7-g4fce3ee
Giuseppe Iuculano
giuseppe at iuculano.it
Fri Feb 13 07:30:12 UTC 2009
The following commit has been merged in the master branch:
commit 4fce3ee208d079121cceaf082abf7d0ff837520b
Author: Giuseppe Iuculano <giuseppe at iuculano.it>
Date: Fri Feb 13 08:18:35 2009 +0100
debian/patches/13_rm_partitions.patch: patch adding --rm_partitions cmdline option and functionality
From bugzilla:
As discussed on irc, here is a patch adding a --rm_partitions cmdline
option,
which will make dmraid tell the kernel to forget about the (often
invalid)
partitions it *thinks* it has found on the disks used in a raid array.
This fixes:
1) Ugly IO error messages caused by probing of the invalid partitions,
see:
bug 475384
2) mount by UUID / LABEL sometimes trying to mount /dev/sda1 instead of
/dev/mapper/raidset-p1, which is really really bad!
diff --git a/debian/patches/13_rm_partitions.patch b/debian/patches/13_rm_partitions.patch
new file mode 100644
index 0000000..b4e4cbf
--- /dev/null
+++ b/debian/patches/13_rm_partitions.patch
@@ -0,0 +1,194 @@
+Author: Giuseppe Iuculano <giuseppe at iuculano.it>
+Description: Add patch adding --rm_partitions cmdline option and functionality
+ (Origin Fedora)
+--- a/1.0.0.rc15/include/dmraid/lib_context.h
++++ b/1.0.0.rc15/include/dmraid/lib_context.h
+@@ -169,6 +169,7 @@ enum action {
+ PARTCHAR = 0x20000000,
+
+ #endif
++ RMPARTITIONS = 0x40000000,
+ };
+
+ /* Arguments allowed ? */
+--- a/1.0.0.rc15/lib/Makefile.in
++++ b/1.0.0.rc15/lib/Makefile.in
+@@ -12,6 +12,7 @@ SOURCES=\
+ activate/activate.c \
+ activate/devmapper.c \
+ device/ata.c \
++ device/partition.c \
+ device/scan.c \
+ device/scsi.c \
+ display/display.c \
+--- a/1.0.0.rc15/lib/device/dev-io.h
++++ b/1.0.0.rc15/lib/device/dev-io.h
+@@ -19,5 +19,6 @@
+
+ int discover_devices(struct lib_context *lc, char **devnodes);
+ int removable_device(struct lib_context *lc, char *dev_path);
++int remove_device_partitions(struct lib_context *lc, void *rs, int dummy);
+
+ #endif
+--- /dev/null
++++ b/1.0.0.rc15/lib/device/partition.c
+@@ -0,0 +1,58 @@
++/*
++ * Copyright (C) 2009 Hans de Goede <hdegoede at redhat.com>, Red Hat Inc.
++ * All rights reserved.
++ *
++ * See file LICENSE at the top of this source tree for license information.
++ */
++#include <linux/blkpg.h>
++#include <sys/ioctl.h>
++#include <errno.h>
++#include <fcntl.h>
++#include "internal.h"
++
++static int
++_remove_subset_partitions(struct lib_context *lc, struct raid_set *rs)
++{
++ struct raid_dev *rd;
++ struct blkpg_partition part = { 0, };
++ struct blkpg_ioctl_arg io = {
++ .op = BLKPG_DEL_PARTITION,
++ .datalen = sizeof(part),
++ .data = &part,
++ };
++
++ list_for_each_entry(rd, &rs->devs, devs) {
++ int fd = open(rd->di->path, O_RDWR);
++ if (fd < 0)
++ LOG_ERR(lc, 0, "opening %s: %s\n", rd->di->path,
++ strerror(errno));
++
++ /* There is no way to enumerate partitions */
++ for (part.pno = 1; part.pno <= 256; part.pno++) {
++ if (ioctl(fd, BLKPG, &io) < 0 && errno != ENXIO)
++ LOG_ERR(lc, 0,
++ "removing part %d from %s: %s\n",
++ part.pno, rd->di->path,
++ strerror(errno));
++ }
++ }
++ return 1;
++}
++
++/* Remove the partition block devices (ie sda1) from block devices (ie sda)
++ used in the set, so that things like hal / blkid won't try to access the
++ disks directly */
++int
++remove_device_partitions(struct lib_context *lc, void *v, int dummy)
++{
++ struct raid_set *subset, *rs = v;
++
++ /* Recursively walk down the chain of stacked RAID sets */
++ list_for_each_entry(subset, &rs->sets, list) {
++ /* Remove partitions from devices of set below this one */
++ if (!T_GROUP(rs) && !remove_device_partitions(lc, subset, 0))
++ return 0;
++ }
++
++ return _remove_subset_partitions(lc, rs);
++}
+--- a/1.0.0.rc15/lib/metadata/metadata.c
++++ b/1.0.0.rc15/lib/metadata/metadata.c
+@@ -2147,6 +2147,9 @@ lib_perform(struct lib_context *lc, enum
+ if (get_metadata(lc, action, p, argv))
+ ret = p->post(lc, p->pre ? p->pre(p->arg) : p->arg);
+
++ if (ret && (RMPARTITIONS & action))
++ process_sets(lc, remove_device_partitions, 0, SETS);
++
+ if (LOCK == p->lock)
+ unlock_resource(lc, NULL);
+
+--- a/1.0.0.rc15/tools/commands.c
++++ b/1.0.0.rc15/tools/commands.c
+@@ -38,7 +38,7 @@ static char const *short_opts = "a:hipP:
+ #endif
+ "rR:s::tv"
+ #endif
+- "VC:S::";
++ "VC:S::Z";
+
+ #ifdef HAVE_GETOPTLONG
+ static struct option long_opts[] = {
+@@ -73,6 +73,7 @@ static struct option long_opts[] = {
+ {"version", no_argument, NULL, 'V'},
+ {"create", required_argument, NULL, 'C'},
+ {"spare", optional_argument, NULL, 'S'},
++ {"rm_partitions", no_argument, NULL, 'Z'},
+ {NULL, no_argument, NULL, 0}
+ };
+ #endif /* #ifdef HAVE_GETOPTLONG */
+@@ -209,6 +210,7 @@ help(struct lib_context *lc, int arg)
+ "\t[-f|--format FORMAT[,FORMAT...]]\n"
+ "\t[-P|--partchar CHAR]\n"
+ "\t[-p|--no_partitions]\n"
++ "\t[-Z|--rm_partitions]\n"
+ "\t[--separator SEPARATOR]\n" "\t[RAID-set...]\n", c);
+ log_print(lc, "%s\t{-h|--help}\n", c);
+ log_print(lc, "%s\t{-V/--version}\n", c);
+@@ -221,7 +223,7 @@ help(struct lib_context *lc, int arg)
+ "\t[-f|--format FORMAT[,FORMAT...]]\n"
+ "\t[-P|--partchar CHAR]\n" "\t[-p|--no_partitions]\n"
+ "\t[--separator SEPARATOR]\n" "\t[-t|--test]\n"
+- "\t[RAID-set...]\n", c);
++ "\t[-Z|--rm_partitions] [RAID-set...]\n", c);
+ log_print(lc,
+ "%s\t{-b|--block_devices} *\n"
+ "\t[-c|--display_columns][FIELD[,FIELD...]]...\n"
+@@ -274,7 +276,7 @@ static struct actions actions[] = {
+ UNDEF, /* Set in check_activate() by mandatory option argument. */
+ UNDEF,
+ ACTIVATE | DEACTIVATE | FORMAT | HELP | IGNORELOCKING | NOPARTITIONS |
+- SEPARATOR
++ SEPARATOR | RMPARTITIONS
+ #ifndef DMRAID_MINI
+ | DBG | TEST | VERBOSE
+ #endif
+@@ -293,7 +295,8 @@ static struct actions actions[] = {
+ # endif
+ | RAID_DEVICES | RAID_SETS,
+ ACTIVE | INACTIVE | COLUMN | DBG | DUMP | DMERASE | GROUP | HELP |
+- IGNORELOCKING | NOPARTITIONS | SEPARATOR | TEST | VERBOSE
++ IGNORELOCKING | NOPARTITIONS | SEPARATOR | TEST | VERBOSE |
++ RMPARTITIONS
+ #else
+ , UNDEF
+ #endif
+@@ -310,7 +313,7 @@ static struct actions actions[] = {
+ {'P',
+ PARTCHAR,
+ ACTIVATE | DEACTIVATE,
+- FORMAT | HELP | IGNORELOCKING | SEPARATOR
++ FORMAT | HELP | IGNORELOCKING | SEPARATOR | RMPARTITIONS
+ #ifndef DMRAID_MINI
+ | DBG | TEST | VERBOSE
+ #endif
+@@ -323,7 +326,7 @@ static struct actions actions[] = {
+ {'p',
+ NOPARTITIONS,
+ ACTIVATE | DEACTIVATE,
+- FORMAT | HELP | IGNORELOCKING | SEPARATOR
++ FORMAT | HELP | IGNORELOCKING | SEPARATOR | RMPARTITIONS
+ #ifndef DMRAID_MINI
+ | DBG | TEST | VERBOSE
+ #endif
+@@ -573,6 +576,15 @@ static struct actions actions[] = {
+ check_spare_argument,
+ LC_HOT_SPARE_SET,
+ },
++ {'Z',
++ RMPARTITIONS,
++ ACTIVATE, /* We cannot undo this on DEACTIVATE ! */
++ DBG | FORMAT | HELP | IGNORELOCKING | NOPARTITIONS | VERBOSE |
++ SEPARATOR,
++ ARGS,
++ NULL,
++ 0,
++ },
+ };
+
+ /*
diff --git a/debian/patches/series b/debian/patches/series
index 59e134e..b1ac6d3 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -9,3 +9,4 @@
10_exit_code.patch
11_isw-raid10.patch
12_support_virtio_devices.patch
+13_rm_partitions.patch
--
Maintenance of the dmraid package
More information about the Dmraid-debian-commits
mailing list