* [PATCH] Support up to 256 SCSI disks on Linux
@ 2009-03-04 16:35 Colin Watson
2009-03-04 21:16 ` Robert Millan
0 siblings, 1 reply; 5+ messages in thread
From: Colin Watson @ 2009-03-04 16:35 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1: Type: text/plain, Size: 643 bytes --]
Linux's Documentation/devices.txt file says that up to 256 SCSI disks
are supported. GRUB currently only supports the first 16. Wikimedia
filed an Ubuntu bug report about this
(https://bugs.launchpad.net/bugs/335174), so here's a patch to extend
this. (I really haven't been able to test this much at all beyond
compile-testing as I don't have a suitable system myself ...)
I suppose it might be nice to macroify the stuff in
grub_util_getdiskname, but TBH I'm not sure it would shorten it all that
much or make it much more readable, so I didn't bother.
Thanks,
--
Colin Watson [cjwatson@ubuntu.com]
[-- Attachment #2: grub2.more-scsi-disks.diff --]
[-- Type: text/x-diff, Size: 3759 bytes --]
Index: util/raid.c
===================================================================
--- util/raid.c (revision 2016)
+++ util/raid.c (working copy)
@@ -32,6 +32,16 @@
#include <linux/raid/md_p.h>
#include <linux/raid/md_u.h>
+static void
+grub_util_getdiskname_scsi (char *name, int scsi_major, int scsi_minor)
+{
+ int unit = scsi_major * 16 + scsi_minor;
+ if (unit < 26)
+ sprintf (name, "/dev/sd%c", 'a' + unit);
+ else
+ sprintf (name, "/dev/sd%c%c", 'a' + unit / 26 - 1, 'a' + unit % 26);
+}
+
static char *
grub_util_getdiskname (int major, int minor)
{
@@ -48,7 +58,37 @@ grub_util_getdiskname (int major, int minor)
else if (major == IDE3_MAJOR)
sprintf (name, "/dev/hd%c", 'g' + minor / 64);
else if (major == SCSI_DISK0_MAJOR)
- sprintf (name, "/dev/sd%c", 'a' + minor / 16);
+ grub_util_getdiskname_scsi (name, 0, minor / 16);
+ else if (major == SCSI_DISK1_MAJOR)
+ grub_util_getdiskname_scsi (name, 1, minor / 16);
+ else if (major == SCSI_DISK2_MAJOR)
+ grub_util_getdiskname_scsi (name, 2, minor / 16);
+ else if (major == SCSI_DISK3_MAJOR)
+ grub_util_getdiskname_scsi (name, 3, minor / 16);
+ else if (major == SCSI_DISK4_MAJOR)
+ grub_util_getdiskname_scsi (name, 4, minor / 16);
+ else if (major == SCSI_DISK5_MAJOR)
+ grub_util_getdiskname_scsi (name, 5, minor / 16);
+ else if (major == SCSI_DISK6_MAJOR)
+ grub_util_getdiskname_scsi (name, 6, minor / 16);
+ else if (major == SCSI_DISK7_MAJOR)
+ grub_util_getdiskname_scsi (name, 7, minor / 16);
+ else if (major == SCSI_DISK8_MAJOR)
+ grub_util_getdiskname_scsi (name, 8, minor / 16);
+ else if (major == SCSI_DISK9_MAJOR)
+ grub_util_getdiskname_scsi (name, 9, minor / 16);
+ else if (major == SCSI_DISK10_MAJOR)
+ grub_util_getdiskname_scsi (name, 10, minor / 16);
+ else if (major == SCSI_DISK11_MAJOR)
+ grub_util_getdiskname_scsi (name, 11, minor / 16);
+ else if (major == SCSI_DISK12_MAJOR)
+ grub_util_getdiskname_scsi (name, 12, minor / 16);
+ else if (major == SCSI_DISK13_MAJOR)
+ grub_util_getdiskname_scsi (name, 13, minor / 16);
+ else if (major == SCSI_DISK14_MAJOR)
+ grub_util_getdiskname_scsi (name, 14, minor / 16);
+ else if (major == SCSI_DISK15_MAJOR)
+ grub_util_getdiskname_scsi (name, 15, minor / 16);
else
grub_util_error ("Unknown device number: %d, %d", major, minor);
Index: util/grub-mkdevicemap.c
===================================================================
--- util/grub-mkdevicemap.c (revision 2016)
+++ util/grub-mkdevicemap.c (working copy)
@@ -231,7 +231,10 @@ get_scsi_disk_name (char *name, int unit)
{
#if defined(__linux__)
/* GNU/Linux */
- sprintf (name, "/dev/sd%c", unit + 'a');
+ if (unit < 26)
+ sprintf (name, "/dev/sd%c", unit + 'a');
+ else
+ sprintf (name, "/dev/sd%c%c", unit / 26 - 1 + 'a', unit % 26 + 'a');
#elif defined(__GNU__)
/* GNU/Hurd */
sprintf (name, "/dev/sd%d", unit);
@@ -516,7 +519,11 @@ make_device_map (const char *device_map, int flopp
#endif /* __linux__ */
/* The rest is SCSI disks. */
+#ifdef __linux__
+ for (i = 0; i < 256; i++)
+#else
for (i = 0; i < 16; i++)
+#endif /* __linux__ */
{
char name[16];
Index: util/hostdisk.c
===================================================================
--- util/hostdisk.c (revision 2016)
+++ util/hostdisk.c (working copy)
@@ -709,8 +709,12 @@ convert_system_partition_to_system_disk (const cha
|| strncmp ("sd", p, 2) == 0)
&& p[2] >= 'a' && p[2] <= 'z')
{
- /* /dev/[hsv]d[a-z][0-9]* */
- p[3] = '\0';
+ if (p[3] >= 'a' && p[3] <= 'z')
+ /* /dev/[hsv]d[a-z][a-z][0-9]* */
+ p[4] = '\0';
+ else
+ /* /dev/[hsv]d[a-z][0-9]* */
+ p[3] = '\0';
return path;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Support up to 256 SCSI disks on Linux
2009-03-04 16:35 [PATCH] Support up to 256 SCSI disks on Linux Colin Watson
@ 2009-03-04 21:16 ` Robert Millan
2009-03-04 21:23 ` Robert Millan
0 siblings, 1 reply; 5+ messages in thread
From: Robert Millan @ 2009-03-04 21:16 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, Mar 04, 2009 at 04:35:09PM +0000, Colin Watson wrote:
> Linux's Documentation/devices.txt file says that up to 256 SCSI disks
> are supported. GRUB currently only supports the first 16. Wikimedia
> filed an Ubuntu bug report about this
> (https://bugs.launchpad.net/bugs/335174), so here's a patch to extend
> this. (I really haven't been able to test this much at all beyond
> compile-testing as I don't have a suitable system myself ...)
>
> I suppose it might be nice to macroify the stuff in
> grub_util_getdiskname, but TBH I'm not sure it would shorten it all that
> much or make it much more readable, so I didn't bother.
Hi Colin,
I feel some dejavu. I think this is not the first max disk limit you
find ;-)
> else if (major == SCSI_DISK0_MAJOR)
> - sprintf (name, "/dev/sd%c", 'a' + minor / 16);
> + grub_util_getdiskname_scsi (name, 0, minor / 16);
> + else if (major == SCSI_DISK1_MAJOR)
> + grub_util_getdiskname_scsi (name, 1, minor / 16);
> [...]
Can this be factorized somehow? Space in raid.mod is quite critical; when
used it usually ends up in core.img, which needs to fit in the embed area.
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Support up to 256 SCSI disks on Linux
2009-03-04 21:16 ` Robert Millan
@ 2009-03-04 21:23 ` Robert Millan
2009-04-10 23:05 ` phcoder
0 siblings, 1 reply; 5+ messages in thread
From: Robert Millan @ 2009-03-04 21:23 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, Mar 04, 2009 at 10:16:29PM +0100, Robert Millan wrote:
> > else if (major == SCSI_DISK0_MAJOR)
> > - sprintf (name, "/dev/sd%c", 'a' + minor / 16);
> > + grub_util_getdiskname_scsi (name, 0, minor / 16);
> > + else if (major == SCSI_DISK1_MAJOR)
> > + grub_util_getdiskname_scsi (name, 1, minor / 16);
> > [...]
>
> Can this be factorized somehow? Space in raid.mod is quite critical; when
> used it usually ends up in core.img, which needs to fit in the embed area.
Oh, I'm sorry. I thought you were editting disk/raid.c. util/raid.c has no
size issues. A macro would still be nice though.
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Support up to 256 SCSI disks on Linux
2009-03-04 21:23 ` Robert Millan
@ 2009-04-10 23:05 ` phcoder
2009-04-13 13:59 ` Robert Millan
0 siblings, 1 reply; 5+ messages in thread
From: phcoder @ 2009-04-10 23:05 UTC (permalink / raw)
To: The development of GRUB 2
Robert Millan wrote:
> On Wed, Mar 04, 2009 at 10:16:29PM +0100, Robert Millan wrote:
>>> else if (major == SCSI_DISK0_MAJOR)
>>> - sprintf (name, "/dev/sd%c", 'a' + minor / 16);
>>> + grub_util_getdiskname_scsi (name, 0, minor / 16);
>>> + else if (major == SCSI_DISK1_MAJOR)
>>> + grub_util_getdiskname_scsi (name, 1, minor / 16);
>>> [...]
>> Can this be factorized somehow? Space in raid.mod is quite critical; when
>> used it usually ends up in core.img, which needs to fit in the embed area.
>
> Oh, I'm sorry. I thought you were editting disk/raid.c. util/raid.c has no
> size issues. A macro would still be nice though.
>
What about making an array of SCSI_DISK?_MAJOR and then just go through it?
--
Regards
Vladimir 'phcoder' Serbinenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Support up to 256 SCSI disks on Linux
2009-04-10 23:05 ` phcoder
@ 2009-04-13 13:59 ` Robert Millan
0 siblings, 0 replies; 5+ messages in thread
From: Robert Millan @ 2009-04-13 13:59 UTC (permalink / raw)
To: The development of GRUB 2
On Sat, Apr 11, 2009 at 01:05:19AM +0200, phcoder wrote:
> Robert Millan wrote:
>> On Wed, Mar 04, 2009 at 10:16:29PM +0100, Robert Millan wrote:
>>>> else if (major == SCSI_DISK0_MAJOR)
>>>> - sprintf (name, "/dev/sd%c", 'a' + minor / 16);
>>>> + grub_util_getdiskname_scsi (name, 0, minor / 16);
>>>> + else if (major == SCSI_DISK1_MAJOR)
>>>> + grub_util_getdiskname_scsi (name, 1, minor / 16);
>>>> [...]
>>> Can this be factorized somehow? Space in raid.mod is quite critical; when
>>> used it usually ends up in core.img, which needs to fit in the embed area.
>>
>> Oh, I'm sorry. I thought you were editting disk/raid.c. util/raid.c has no
>> size issues. A macro would still be nice though.
>>
> What about making an array of SCSI_DISK?_MAJOR and then just go through it?
Sounds good.
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-04-13 13:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-04 16:35 [PATCH] Support up to 256 SCSI disks on Linux Colin Watson
2009-03-04 21:16 ` Robert Millan
2009-03-04 21:23 ` Robert Millan
2009-04-10 23:05 ` phcoder
2009-04-13 13:59 ` Robert Millan
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.