From: Pavel Roskin <proski@gnu.org>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: Revision 2136 breaks two-disk configuarion
Date: Mon, 27 Apr 2009 18:26:11 -0400 [thread overview]
Message-ID: <1240871171.11406.106.camel@mj> (raw)
In-Reply-To: <20090426.225757.05232059.davem@davemloft.net>
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
next prev parent reply other threads:[~2009-04-27 22:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-27 5:25 Revision 2136 breaks two-disk configuarion Pavel Roskin
2009-04-27 5:57 ` David Miller
2009-04-27 22:26 ` Pavel Roskin [this message]
2009-04-28 1:37 ` [PATCH] " Pavel Roskin
2009-04-28 1:45 ` David Miller
2009-04-28 3:50 ` Pavel Roskin
2009-04-28 8:59 ` David Miller
2009-04-28 13:26 ` Pavel Roskin
2009-04-28 8:59 ` David Miller
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=1240871171.11406.106.camel@mj \
--to=proski@gnu.org \
--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.