All of lore.kernel.org
 help / color / mirror / Atom feed
* Big Endian fix patch (was: Re: Couple more fixes for Linux raid metadata 1.x support)
@ 2010-07-27  1:00 Doug Nazar
  2010-07-27 15:26 ` Lennart Sorensen
  0 siblings, 1 reply; 26+ messages in thread
From: Doug Nazar @ 2010-07-27  1:00 UTC (permalink / raw)
  To: lsorense, grub-devel

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



On Mon, Jul 26, 2010 at 01:20:34PM -0400, Lennart Sorensen wrote:
>  On Mon, Jul 26, 2010 at 01:20:34PM -0400, Lennart Sorensen wrote:
>  >/  Now this is on a powerpc64 system, so it is big endian.  That number by/
>  >/  the way is FFFFFFFFFFFFFF00./
>  >
>  >/  I wonder if some part of the 1.x raid handling code has an endianess bug./
>  >
>  >/  Got any guesses I can try before I just go convert back to 0.9 raids?/
>  >/  I really hate giving up on things that ought to work and loose the/
>  >/  debugging opportunity./
>
>  Turns out it very much was endian issues.
>
>  Here is a patch that fixes it for me.
>
>  I am using your two recent patches as well.


I'd worried about endianess while testing. I've been spending the last 2 
days trying to setup a QEMU powerpc64 image to run some regression 
testing but it's taking forever (combination of old P4 computer and QEMU 
giving me random errors from the cdrom drive).

I'll run it through the grinder in a bit.

Doug


[-- Attachment #2: Type: text/html, Size: 1363 bytes --]

^ permalink raw reply	[flat|nested] 26+ messages in thread
* Couple more fixes for Linux raid metadata 1.x support
@ 2010-07-24 10:22 Doug Nazar
  2010-07-26 17:20 ` Lennart Sorensen
  0 siblings, 1 reply; 26+ messages in thread
From: Doug Nazar @ 2010-07-24 10:22 UTC (permalink / raw)
  To: grub-devel, Colin Watson, Felix Zielcke, Peter Henn

[-- 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)


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

end of thread, other threads:[~2010-09-13 19:55 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-27  1:00 Big Endian fix patch (was: Re: Couple more fixes for Linux raid metadata 1.x support) Doug Nazar
2010-07-27 15:26 ` Lennart Sorensen
2010-07-27 23:58   ` Big Endian fix patch Doug Nazar
2010-07-28 14:52     ` Lennart Sorensen
2010-07-28 15:29       ` Doug Nazar
2010-07-28  8:51   ` Doug Nazar
2010-07-28 15:00     ` Lennart Sorensen
2010-07-28 15:51       ` Lennart Sorensen
2010-07-28 16:30         ` Doug Nazar
2010-07-28 17:01           ` Lennart Sorensen
2010-07-28 17:12             ` Doug Nazar
2010-07-28 17:40               ` Lennart Sorensen
2010-07-28 17:42               ` Lennart Sorensen
2010-07-28 17:52                 ` Lennart Sorensen
2010-07-28 18:17                   ` Doug Nazar
2010-07-28 18:49                     ` Lennart Sorensen
2010-07-28 20:10                       ` Doug Nazar
2010-07-28 22:25                         ` Lennart Sorensen
2010-07-28 20:46                       ` Doug Nazar
2010-07-29 15:30                         ` Lennart Sorensen
2010-07-28 18:01                 ` Doug Nazar
2010-07-28 18:50                   ` Lennart Sorensen
2010-07-28 15:52       ` Doug Nazar
2010-07-28 15:55         ` Lennart Sorensen
2010-09-13 19:54     ` Vladimir 'φ-coder/phcoder' Serbinenko
  -- strict thread matches above, loose matches on Subject: below --
2010-07-24 10:22 Couple more fixes for Linux raid metadata 1.x support Doug Nazar
2010-07-26 17:20 ` 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

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.