All of lore.kernel.org
 help / color / mirror / Atom feed
From: Doug Nazar <nazard.michi@gmail.com>
To: grub-devel@gnu.org, Colin Watson <cjwatson@ubuntu.com>,
	 Felix Zielcke <fzielcke@z-51.de>, Peter Henn <peter.henn@web.de>
Subject: Couple more fixes for Linux raid metadata 1.x support
Date: Sat, 24 Jul 2010 06:22:02 -0400	[thread overview]
Message-ID: <4C4ABECA.2030008@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 442 bytes --]

  While doing some in-depth testing came across a few more issues. The 
second one really threw me for a loop. The LVM wouldn't come up because 
it couldn't find some of the raid arrays but when I hexdumped the raid 
arrays it showed the correct uuid. Applies on top of previous patch.

- Ignore spare and faulty drives
- Set a dynamic array->number. It's used for the disk->id and is important
   for the cache subsystem that it be unique.


[-- Attachment #2: grub-update-raid-metadata-1x-support-2.diff --]
[-- Type: text/plain, Size: 2931 bytes --]

=== modified file 'disk/mdraid_linux.c'
--- disk/mdraid_linux.c	2010-07-23 05:25:00 +0000
+++ disk/mdraid_linux.c	2010-07-24 05:53:53 +0000
@@ -363,6 +363,19 @@
     return grub_error (GRUB_ERR_OUT_OF_RANGE, "csum invalid");
   }
 
+  if (grub_le_to_cpu32 (real_sb->dev_number) <
+      grub_le_to_cpu32 (real_sb->max_dev))
+    array->index = grub_le_to_cpu16
+      (real_sb->dev_roles[grub_le_to_cpu32 (real_sb->dev_number)]);
+  else
+    array->index = 0xffff;  /* disk will be later not used! */
+    
+  if (array->index == 0xffff || array->index == 0xfffe)
+  {
+    grub_free (real_sb);
+    return grub_error (GRUB_ERR_OUT_OF_RANGE, "spare or faulty drive");
+  }
+    
   array->name = grub_strdup (real_sb->set_name);
   if (! array->name)
     {
@@ -375,14 +388,11 @@
   array->layout = grub_le_to_cpu32 (real_sb->layout);
   array->total_devs = grub_le_to_cpu32 (real_sb->raid_disks);
   array->disk_size = grub_le_to_cpu64 (real_sb->size);
+  if (!array->disk_size)
+    /* Level 0 doesn't seem to set sb->size */
+    array->disk_size = grub_le_to_cpu64 (real_sb->data_size);
   array->chunk_size = grub_le_to_cpu32 (real_sb->chunksize);
   array->freshness = grub_le_to_cpu32(real_sb->events);
-  if (grub_le_to_cpu32 (real_sb->dev_number) <
-      grub_le_to_cpu32 (real_sb->max_dev))
-    array->index = grub_le_to_cpu16
-      (real_sb->dev_roles[grub_le_to_cpu32 (real_sb->dev_number)]);
-  else
-    array->index = 0xffff;  /* disk will be later not used! */
   array->uuid_len = 16;
   array->uuid = grub_malloc (16);
   if (!array->uuid)

=== modified file 'disk/raid.c'
--- disk/raid.c	2010-07-23 05:25:00 +0000
+++ disk/raid.c	2010-07-24 09:57:05 +0000
@@ -555,25 +555,28 @@
       grub_memset (&array->device, 0, sizeof (array->device));
       grub_memset (&array->start_sector, 0, sizeof (array->start_sector));
 
+      /* mdraid 1.x superblocks don't have a number but we need a unique id
+         for the cache system. Start numbering down from the top. */
       if (array->name)
-	goto skip_duplicate_check;
+	array->number = -1;
+	
       /* Check whether we don't have multiple arrays with the same number.  */
       for (p = array_list; p != NULL; p = p->next)
         {
-          if (! p->name && p->number == array->number) 
+          if (p->number == array->number) 
 	    break;
         }
 
       if (p)
         {
           /* The number is already in use, so we need to find a new one.  */
-          int i = 0;
+	  int i = array->name ? -2 : 0;
 
 	  while (1)
 	    {
 	      for (p = array_list; p != NULL; p = p->next)
 		{
-		  if (! p->name && p->number == i)
+		  if (p->number == i)
 		    break;
 		}
 
@@ -584,10 +587,10 @@
 		  break;
 		}
 
-	      i++;
+	      i += array->name ? -1 : 1;
 	    }
 	}
-    skip_duplicate_check:
+	
       /* mdraid 1.x superblocks have only a name stored not a number.
 	 Use it directly as GRUB device.  */
       if (! array->name)


             reply	other threads:[~2010-07-25 13:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-24 10:22 Doug Nazar [this message]
2010-07-26 17:20 ` Couple more fixes for Linux raid metadata 1.x support Lennart Sorensen
2010-07-26 21:07   ` Big Endian fix patch (was: Re: Couple more fixes for Linux raid metadata 1.x support) Lennart Sorensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C4ABECA.2030008@gmail.com \
    --to=nazard.michi@gmail.com \
    --cc=cjwatson@ubuntu.com \
    --cc=fzielcke@z-51.de \
    --cc=grub-devel@gnu.org \
    --cc=peter.henn@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.