grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Revision 2136 breaks two-disk configuarion


From: Pavel Roskin
Subject: Re: Revision 2136 breaks two-disk configuarion
Date: Mon, 27 Apr 2009 18:26:11 -0400

On Sun, 2009-04-26 at 22:57 -0700, David Miller wrote:

> grub_disk_open() isn't used, but a grub_device_open() does occur
> during the iterator that has us find the FS_UUID device.  This
> happens search_fs_uuid().
> 
> If we don't do this, we leave a device reference open and dangling.

Then we should be using grub_device_close().  I've made a patch that
keeps dev, not disk in the data field.  Unfortunately, the problem
persists.  I could easily reproduce it on another machine by using a
flash drive and qemu.

It's entirely possible that the problem is elsewhere.  But I have no
experience debugging memory problems in GRUB, so it will take time
before I find out.

Here's the patch.  It doesn't make the memory problem go away, but it
makes the code nicer by using the same abstraction to open and close the
disk.

diff --git a/disk/fs_uuid.c b/disk/fs_uuid.c
index 9d83bb8..f590ad2 100644
--- a/disk/fs_uuid.c
+++ b/disk/fs_uuid.c
@@ -89,7 +89,7 @@ grub_fs_uuid_open (const char *name, grub_disk_t disk)
   disk->total_sectors = dev->disk->total_sectors;
   disk->has_partitions = 0;
   disk->partition = dev->disk->partition;
-  disk->data = dev->disk;
+  disk->data = dev;
 
   return GRUB_ERR_NONE;
 }
@@ -97,24 +97,24 @@ grub_fs_uuid_open (const char *name, grub_disk_t disk)
 static void
 grub_fs_uuid_close (grub_disk_t disk __attribute((unused)))
 {
-  grub_disk_t parent = disk->data;
-  grub_disk_close (parent);
+  grub_device_t parent = disk->data;
+  grub_device_close (parent);
 }
 
 static grub_err_t
 grub_fs_uuid_read (grub_disk_t disk, grub_disk_addr_t sector,
                   grub_size_t size, char *buf)
 {
-  grub_disk_t parent = disk->data;
-  return parent->dev->read (parent, sector, size, buf);
+  grub_device_t parent = disk->data;
+  return parent->disk->dev->read (parent->disk, sector, size, buf);
 }
 
 static grub_err_t
 grub_fs_uuid_write (grub_disk_t disk, grub_disk_addr_t sector,
                    grub_size_t size, const char *buf)
 {
-  grub_disk_t parent = disk->data;
-  return parent->dev->write (parent, sector, size, buf);
+  grub_device_t parent = disk->data;
+  return parent->disk->dev->write (parent->disk, sector, size, buf);
 }
 
 static struct grub_disk_dev grub_fs_uuid_dev =

-- 
Regards,
Pavel Roskin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]