]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2008-07-04 Robert Millan <rmh@aybabtu.com>
authorrobertmh <robertmh@localhost>
Thu, 3 Jul 2008 22:56:43 +0000 (22:56 +0000)
committerrobertmh <robertmh@localhost>
Thu, 3 Jul 2008 22:56:43 +0000 (22:56 +0000)
        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).

        Some callers relied on previous buggy behaviour, since they would
        rise an error when their own hooks caused early abortion of its
        iteration.

        * kern/device.c (grub_device_open): Improve error message.
        * disk/lvm.c (grub_lvm_open): Likewise.
        * disk/raid.c (grub_raid_open): Likewise.

        * 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().

        * kern/partition.c (grub_partition_iterate): Abort parent iteration
        when hook requests it, independently of grub_errno.  Do not fail when
        part_map_iterate_hook() caused early abortion of p->iterate().

        * util/biosdisk.c (grub_util_biosdisk_get_grub_dev): Do not fail
        when grub_partition_iterate() returned with non-zero.

ChangeLog
disk/lvm.c
disk/raid.c
kern/device.c
kern/partition.c
partmap/gpt.c
partmap/pc.c
util/biosdisk.c

index 21925bc00f4b552eff0f5be28750dd70a6a5c60d..799a2e2d4228c4e3f54b17d57ec40487abd930e8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2008-07-04  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).
+
+       Some callers relied on previous buggy behaviour, since they would
+       rise an error when their own hooks caused early abortion of its
+       iteration.
+
+       * kern/device.c (grub_device_open): Improve error message.
+       * disk/lvm.c (grub_lvm_open): Likewise.
+       * disk/raid.c (grub_raid_open): Likewise.
+
+       * 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().
+
+       * kern/partition.c (grub_partition_iterate): Abort parent iteration
+       when hook requests it, independently of grub_errno.  Do not fail when
+       part_map_iterate_hook() caused early abortion of p->iterate().
+
+       * util/biosdisk.c (grub_util_biosdisk_get_grub_dev): Do not fail
+       when grub_partition_iterate() returned with non-zero.
+
 2008-07-03  Pavel Roskin  <proski@gnu.org>
 
        * disk/ata.c (grub_ata_pio_write): Check status before writing,
index 997d15cd5ea05e8977968474db6b9539c61b110d..6a05caa752807cc9bd064f36ac7e0c5a9081c473 100644 (file)
@@ -95,7 +95,7 @@ grub_lvm_open (const char *name, grub_disk_t disk)
     }
 
   if (! lv)
-    return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown device");
+    return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown LVM device %s", name);
 
   disk->has_partitions = 0;
   disk->id = lv->number;
index b8a5e12103df386d51985ab94b47b9541ebcf929..a484fcf89635607264c48bb3a878e832b68bb7e0 100644 (file)
@@ -100,7 +100,7 @@ grub_raid_open (const char *name, grub_disk_t disk)
     }
 
   if (!array)
-    return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown device");
+    return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown RAID device %s", name);
 
   disk->has_partitions = 1;
   disk->id = array->number;
index a39fdcecb0a8879df9a5ab4fc9add334e714119f..1b5a77c00af04f017ccc5fd1cdb07b6dcf587a7a 100644 (file)
@@ -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;
     }
 
index b9a04577582e4ec69b81fcf73cc755f3c1c62df3..cb0e4f7b8fef6cf7848d8b2ccb91ac7c5fa401f4 100644 (file)
@@ -103,12 +103,10 @@ grub_partition_iterate (struct grub_disk *disk,
   
   int part_map_iterate (const grub_partition_map_t p)
     {
-      grub_err_t err;
-
       grub_dprintf ("partition", "Detecting %s...\n", p->name);
-      err = p->iterate (disk, part_map_iterate_hook);
+      p->iterate (disk, part_map_iterate_hook);
 
-      if (err != GRUB_ERR_NONE)
+      if (grub_errno != GRUB_ERR_NONE)
        {
          /* Continue to next partition map type.  */
          grub_dprintf ("partition", "%s detection failed.\n", p->name);
index ddfde2ec99e0b3c76f66a573b6657939fd63a13a..683fcbacee793df3848e96c04b11372b3420af48 100644 (file)
@@ -103,7 +103,7 @@ gpt_partition_map_iterate (grub_disk_t disk,
                        (unsigned long long) part.len);
 
          if (hook (disk, &part))
-           return grub_errno;
+           return 1;
        }
 
       last_offset += grub_le_to_cpu32 (gpt.partentry_size);
@@ -151,7 +151,8 @@ gpt_partition_map_probe (grub_disk_t disk, const char *str)
       return 0;
     }
 
-  if (gpt_partition_map_iterate (disk, find_func))
+  gpt_partition_map_iterate (disk, find_func);
+  if (grub_errno)
     goto fail;
 
   return p;
index 2fba45dbb723d593ae0bf1e431047261a5db0a05..0aa1482a89f975afe5ae30ba97604e88f20228de 100644 (file)
@@ -153,7 +153,7 @@ pc_partition_map_iterate (grub_disk_t disk,
              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))
@@ -192,7 +192,7 @@ pc_partition_map_iterate (grub_disk_t disk,
                      
                      if (be->fs_type != GRUB_PC_PARTITION_BSD_TYPE_UNUSED)
                        if (hook (disk, &p))
-                         goto finish;
+                         return 1;
                    }
                }
            }
@@ -257,7 +257,8 @@ pc_partition_map_probe (grub_disk_t disk, const char *str)
     return 0;
   
   pcdata = p->data;
-  if (pc_partition_map_iterate (disk, find_func))
+  pc_partition_map_iterate (disk, find_func);
+  if (grub_errno)
     goto fail;
 
   if (p->index < 0)
index 65e5af0ad574846483d1f734001fcd21afa44468..1137e98fea7564620114e91c631867bcea7e11e5 100644 (file)
@@ -863,7 +863,8 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
     if (! disk)
       return 0;
     
-    if (grub_partition_iterate (disk, find_partition) != GRUB_ERR_NONE)
+    grub_partition_iterate (disk, find_partition);
+    if (grub_errno != GRUB_ERR_NONE)
       {
        grub_disk_close (disk);
        return 0;