All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Millan <rmh@aybabtu.com>
To: grub-devel@gnu.org
Subject: [PATCH] pc & gpt partmap iterators don't abort when their hook requests it
Date: Tue, 1 Jul 2008 15:25:32 +0200	[thread overview]
Message-ID: <20080701132532.GA19736@thorin> (raw)

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


See ChangeLog for description.  I'd really like to receive some review on
this one, since the code it touches is so fragile (although I tested it on a
typical setup and it works).

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What good is a phone call… if you are unable to speak?
(as seen on /.)

[-- Attachment #2: partmap_iterator_abortion.diff --]
[-- Type: text/x-diff, Size: 2874 bytes --]

2008-07-01  Robert Millan  <rmh@aybabtu.com>

	This fixes a performance issue when pc & gpt partmap iterators
	didn't abort iteration even after our hook found what it was
	looking for (often causing expensive probes of non-existant drives).

	The probe functions relied on previous buggy behaviour, since they
	would rise an error when their own hook (find_func()) caused early
	abortion of its iteration.

	* kern/device.c (grub_device_open): Improve error message.

	* partmap/pc.c (pc_partition_map_iterate): Abort parent iteration
	when hook requests it, independently of grub_errno.
	(pc_partition_map_probe): Do not fail when find_func() caused
	early abortion of pc_partition_map_iterate().

	* partmap/gpt.c (gpt_partition_map_iterate): Abort parent iteration
	when hook requests it, independently of grub_errno.
	(gpt_partition_map_probe): Do not fail when find_func() caused
	early abortion of gpt_partition_map_iterate().

diff -x debian -x ChangeLog -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/kern/device.c ./kern/device.c
--- ../grub2/kern/device.c	2008-01-10 00:25:54.000000000 +0100
+++ ./kern/device.c	2008-06-30 14:15:19.000000000 +0200
@@ -50,7 +50,7 @@ grub_device_open (const char *name)
   disk = grub_disk_open (name);
   if (! disk)
     {
-      grub_error (GRUB_ERR_BAD_DEVICE, "unknown device");
+      grub_error (GRUB_ERR_BAD_DEVICE, "unknown device %s", name);
       goto fail;
     }
 
diff -x debian -x ChangeLog -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/partmap/gpt.c ./partmap/gpt.c
--- ../grub2/partmap/gpt.c	2008-02-23 21:33:32.000000000 +0100
+++ ./partmap/gpt.c	2008-07-01 15:06:31.000000000 +0200
@@ -102,7 +102,7 @@ gpt_partition_map_iterate (grub_disk_t d
 			i, part.start, part.len);
 
 	  if (hook (disk, &part))
-	    return grub_errno;
+	    return 1;
 	}
 
       last_offset += grub_le_to_cpu32 (gpt.partentry_size);
@@ -150,8 +150,7 @@ gpt_partition_map_probe (grub_disk_t dis
       return 0;
     }
 
-  if (gpt_partition_map_iterate (disk, find_func))
-    goto fail;
+  gpt_partition_map_iterate (disk, find_func);
 
   return p;
 
diff -x debian -x ChangeLog -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/partmap/pc.c ./partmap/pc.c
--- ../grub2/partmap/pc.c	2007-07-22 01:32:30.000000000 +0200
+++ ./partmap/pc.c	2008-07-01 15:06:03.000000000 +0200
@@ -151,7 +151,7 @@ pc_partition_map_iterate (grub_disk_t di
 	      pcdata.dos_part++;
 	      
 	      if (hook (disk, &p))
-		goto finish;
+		return 1;
 
 	      /* Check if this is a BSD partition.  */
 	      if (grub_pc_partition_is_bsd (e->type))
@@ -255,8 +255,7 @@ pc_partition_map_probe (grub_disk_t disk
     return 0;
   
   pcdata = p->data;
-  if (pc_partition_map_iterate (disk, find_func))
-    goto fail;
+  pc_partition_map_iterate (disk, find_func);
 
   if (p->index < 0)
     {

             reply	other threads:[~2008-07-01 13:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-01 13:25 Robert Millan [this message]
2008-07-01 15:33 ` [PATCH] pc & gpt partmap iterators don't abort when their hook requests it Robert Millan
2008-07-03 18:31   ` Marco Gerards
2008-07-03 22:57     ` Robert Millan

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=20080701132532.GA19736@thorin \
    --to=rmh@aybabtu.com \
    --cc=grub-devel@gnu.org \
    /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.