From cd8bc2a97a0fb56d9d768d3bd7ae8f1ae753a026 Mon Sep 17 00:00:00 2001 From: Doug Ledford Date: Wed, 27 Jul 2011 14:43:27 -0400 Subject: [PATCH] A couple minor bugfixes --- mdadm-3.2.2-readd.patch | 26 +++++++++++ mdadm-3.2.2-writemostly.patch | 87 +++++++++++++++++++++++++++++++++++ mdadm.spec | 10 +++- 3 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 mdadm-3.2.2-readd.patch create mode 100644 mdadm-3.2.2-writemostly.patch diff --git a/mdadm-3.2.2-readd.patch b/mdadm-3.2.2-readd.patch new file mode 100644 index 0000000..1aa3f43 --- /dev/null +++ b/mdadm-3.2.2-readd.patch @@ -0,0 +1,26 @@ +--- mdadm-3.2.2/util.c.readd 2011-06-17 01:15:50.000000000 -0400 ++++ mdadm-3.2.2/util.c 2011-07-18 14:43:40.776150946 -0400 +@@ -364,19 +364,21 @@ int enough_fd(int fd) + struct mdu_disk_info_s disk; + int avail_disks = 0; + int i; ++ int raid_disks; + char *avail; + + if (ioctl(fd, GET_ARRAY_INFO, &array) != 0 || + array.raid_disks <= 0) + return 0; + avail = calloc(array.raid_disks, 1); +- for (i=0; i < 1024 && array.nr_disks > 0; i++) { ++ raid_disks = array.raid_disks; ++ for (i=0; i < 1024 && raid_disks > 0; i++) { + disk.number = i; + if (ioctl(fd, GET_DISK_INFO, &disk) != 0) + continue; + if (disk.major == 0 && disk.minor == 0) + continue; +- array.nr_disks--; ++ raid_disks--; + + if (! (disk.state & (1<writemostly > 0) { + int rv = -1; + tfd = dev_open(dv->devname, O_RDWR); ++ if (tfd < 0) { ++ fprintf(stderr, Name ": failed to open %s for" ++ " superblock update during re-add\n", dv->devname); ++ return 1; ++ } + +- if (tfd >= 0) ++ if (dv->writemostly == 1) ++ rv = st->ss->update_super( ++ st, NULL, "writemostly", ++ devname, verbose, 0, NULL); ++ if (dv->writemostly == 2) ++ rv = st->ss->update_super( ++ st, NULL, "readwrite", ++ devname, verbose, 0, NULL); ++ if (update) + rv = st->ss->update_super( + st, NULL, update, + devname, verbose, 0, NULL); +diff -up mdadm-3.2.2/mdadm.h.writemostly mdadm-3.2.2/mdadm.h +--- mdadm-3.2.2/mdadm.h.writemostly 2011-07-27 14:12:28.800779575 -0400 ++++ mdadm-3.2.2/mdadm.h 2011-07-27 14:04:34.669932148 -0400 +@@ -646,6 +646,8 @@ extern struct superswitch { + * linear-grow-new - add a new device to a linear array, but don't + * change the size: so superblock still matches + * linear-grow-update - now change the size of the array. ++ * writemostly - set the WriteMostly1 bit in the superblock devflags ++ * readwrite - clear the WriteMostly1 bit in the superblock devflags + */ + int (*update_super)(struct supertype *st, struct mdinfo *info, + char *update, +diff -up mdadm-3.2.2/super0.c.writemostly mdadm-3.2.2/super0.c +--- mdadm-3.2.2/super0.c.writemostly 2011-06-17 01:15:50.000000000 -0400 ++++ mdadm-3.2.2/super0.c 2011-07-27 14:12:18.655889559 -0400 +@@ -570,6 +570,10 @@ static int update_super0(struct supertyp + sb->state &= ~(1<reshape_position = info->reshape_progress; ++ else if (strcmp(update, "writemostly")==0) ++ sb->state |= (1<state &= ~(1<minor = dinfo->minor; + dk->raid_disk = dinfo->raid_disk; + dk->state = dinfo->state; ++ /* In case our source disk was writemostly, don't copy that bit */ ++ dk->state &= ~(1<this_disk = sb->disks[dinfo->number]; + sb->sb_csum = calc_sb0_csum(sb); +diff -up mdadm-3.2.2/super1.c.writemostly mdadm-3.2.2/super1.c +--- mdadm-3.2.2/super1.c.writemostly 2011-06-17 01:15:50.000000000 -0400 ++++ mdadm-3.2.2/super1.c 2011-07-27 14:12:18.656889548 -0400 +@@ -803,6 +803,10 @@ static int update_super1(struct supertyp + __le64_to_cpu(sb->data_size)); + } else if (strcmp(update, "_reshape_progress")==0) + sb->reshape_position = __cpu_to_le64(info->reshape_progress); ++ else if (strcmp(update, "writemostly")==0) ++ sb->devflags |= WriteMostly1; ++ else if (strcmp(update, "readwrite")==0) ++ sb->devflags &= ~WriteMostly1; + else + rv = -1; + +@@ -923,6 +927,7 @@ static int add_to_super1(struct supertyp + sb->max_dev = __cpu_to_le32(dk->number+1); + + sb->dev_number = __cpu_to_le32(dk->number); ++ sb->devflags = 0; /* don't copy another disks flags */ + sb->sb_csum = calc_sb_1_csum(sb); + + dip = (struct devinfo **)&st->info; diff --git a/mdadm.spec b/mdadm.spec index 934e569..54935d4 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -1,7 +1,7 @@ Summary: The mdadm program controls Linux md devices (software RAID arrays) Name: mdadm Version: 3.2.2 -Release: 6%{?dist} +Release: 7%{?dist} Source: http://www.kernel.org/pub/linux/utils/raid/mdadm/mdadm-%{version}.tar.bz2 Source1: mdmonitor.init Source2: raid-check @@ -14,6 +14,8 @@ Source8: mdadm.conf Patch0: mdadm-3.2.2-man.patch Patch1: mdadm-3.2.1-version.patch Patch2: mdadm-3.2.2-fixbuild.patch +Patch3: mdadm-3.2.2-readd.patch +Patch4: mdadm-3.2.2-writemostly.patch Patch19: mdadm-3.1.3-udev.patch Patch20: mdadm-2.5.2-static.patch URL: http://www.kernel.org/pub/linux/utils/raid/mdadm/ @@ -51,6 +53,8 @@ is not used as the system init process. %patch0 -p1 -b .man %patch1 -p1 -b .version %patch2 -p1 -b .build +%patch3 -p1 -b .readd +%patch4 -p1 -b .writemostly %patch19 -p1 -b .udev %patch20 -p1 -b .static @@ -125,6 +129,10 @@ fi %{_initrddir}/* %changelog +* Wed Jul 27 2011 Doug Ledford - 3.2.2-7 +- Fix a bug with readding a device +- Fix a bug with writemostly flag handling + * Mon Jul 18 2011 Doug Ledford - 3.2.2-6 - Bump and rebuild again