* [PATCH] raid autodetect for sun disk labels
@ 2002-09-26 4:30 Alex Williamson
2002-09-26 4:47 ` David S. Miller
0 siblings, 1 reply; 2+ messages in thread
From: Alex Williamson @ 2002-09-26 4:30 UTC (permalink / raw)
To: sparclinux, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 521 bytes --]
I wasn't terribly fond of the idea of needing an initrd or weird
boot options to support root raid on a sparc, so I hacked on the sun
disk label support a bit to pass "Linux raid autodetect" partitions
up to md. The extra breakout of the disk label struct is from the fdisk
source, hopefully it's not obsolete. With this I can boot to a root
raid0 on a sparc 10, but it should of course work on any set of disks w/
proper magic. Patch attached for 2.4.20-pre7/8. Please CC on followup.
Thanks,
Alex Williamson
[-- Attachment #2: sun_autoraid.patch --]
[-- Type: text/plain, Size: 1658 bytes --]
--- linux-2.4.19/fs/partitions/sun.c~ Tue Sep 24 23:02:49 2002
+++ linux-2.4.19/fs/partitions/sun.c Wed Sep 25 20:45:05 2002
@@ -19,6 +19,10 @@
#include "check.h"
#include "sun.h"
+#if CONFIG_BLK_DEV_MD
+extern void md_autodetect_dev(kdev_t dev);
+#endif
+
int sun_partition(struct gendisk *hd, struct block_device *bdev, unsigned long first_sector, int first_part_minor)
{
int i, csum;
@@ -27,7 +31,14 @@
kdev_t dev = to_kdev_t(bdev->bd_dev);
struct sun_disklabel {
unsigned char info[128]; /* Informative text string */
- unsigned char spare[292]; /* Boot information etc. */
+ unsigned char spare0[14];
+ struct sun_info {
+ unsigned char spare1;
+ unsigned char id;
+ unsigned char spare2;
+ unsigned char flags;
+ } infos[8];
+ unsigned char spare[246]; /* Boot information etc. */
unsigned short rspeed; /* Disk rotational speed */
unsigned short pcylcount; /* Physical cylinder count */
unsigned short sparecyl; /* extra sects per cylinder */
@@ -69,6 +80,7 @@
put_dev_sector(sect);
return 0;
}
+
/* All Sun disks have 8 partition entries */
spc = be16_to_cpu(label->ntrks) * be16_to_cpu(label->nsect);
for(i=0; i < 8; i++, p++) {
@@ -77,8 +89,14 @@
st_sector = first_sector + be32_to_cpu(p->start_cylinder) * spc;
num_sectors = be32_to_cpu(p->num_sectors);
- if (num_sectors)
+ if (num_sectors) {
add_gd_partition(hd, first_part_minor, st_sector, num_sectors);
+#if CONFIG_BLK_DEV_MD
+ if (label->infos[i].id == 0xfd) { /* "Linux raid autodetect" */
+ md_autodetect_dev(MKDEV(hd->major, first_part_minor));
+ }
+#endif
+ }
first_part_minor++;
}
printk("\n");
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] raid autodetect for sun disk labels
2002-09-26 4:30 [PATCH] raid autodetect for sun disk labels Alex Williamson
@ 2002-09-26 4:47 ` David S. Miller
0 siblings, 0 replies; 2+ messages in thread
From: David S. Miller @ 2002-09-26 4:47 UTC (permalink / raw)
To: alex_williamson; +Cc: sparclinux, linux-kernel
Nice work, I put this into my tree and I will pass it on
to Marcelo and Linus.
The only changes I made were:
1) Include linux/config.h
2) Use LINUX_RAID_PARTITION instead of magic constant
Thanks again.
--- fs/partitions/sun.c.~1~ Wed Sep 25 21:41:22 2002
+++ fs/partitions/sun.c Wed Sep 25 21:45:34 2002
@@ -7,6 +7,7 @@
* Re-organised Feb 1998 Russell King
*/
+#include <linux/config.h>
#include <linux/fs.h>
#include <linux/genhd.h>
#include <linux/kernel.h>
@@ -19,6 +20,10 @@
#include "check.h"
#include "sun.h"
+#ifdef CONFIG_BLK_DEV_MD
+extern void md_autodetect_dev(kdev_t dev);
+#endif
+
int sun_partition(struct gendisk *hd, struct block_device *bdev, unsigned long first_sector, int first_part_minor)
{
int i, csum;
@@ -27,7 +32,14 @@
kdev_t dev = to_kdev_t(bdev->bd_dev);
struct sun_disklabel {
unsigned char info[128]; /* Informative text string */
- unsigned char spare[292]; /* Boot information etc. */
+ unsigned char sparc0[14];
+ struct sun_info {
+ unsigned char spare1;
+ unsigned char id;
+ unsigned char spare2;
+ unsigned char flags;
+ } infos[8];
+ unsigned char spare[246]; /* Boot information etc. */
unsigned short rspeed; /* Disk rotational speed */
unsigned short pcylcount; /* Physical cylinder count */
unsigned short sparecyl; /* extra sects per cylinder */
@@ -63,22 +75,30 @@
ush = ((unsigned short *) (label+1)) - 1;
for (csum = 0; ush >= ((unsigned short *) label);)
csum ^= *ush--;
- if(csum) {
+ if (csum) {
printk("Dev %s Sun disklabel: Csum bad, label corrupted\n",
bdevname(dev));
put_dev_sector(sect);
return 0;
}
+
/* All Sun disks have 8 partition entries */
spc = be16_to_cpu(label->ntrks) * be16_to_cpu(label->nsect);
- for(i=0; i < 8; i++, p++) {
+ for (i = 0; i < 8; i++, p++) {
unsigned long st_sector;
int num_sectors;
st_sector = first_sector + be32_to_cpu(p->start_cylinder) * spc;
num_sectors = be32_to_cpu(p->num_sectors);
- if (num_sectors)
- add_gd_partition(hd, first_part_minor, st_sector, num_sectors);
+ if (num_sectors) {
+ add_gd_partition(hd, first_part_minor,
+ st_sector, num_sectors);
+#ifdef CONFIG_BLK_DEV_MD
+ if (label->infos[i].id == LINUX_RAID_PARTITION)
+ md_autodetect_dev(MKDEV(hd->major,
+ first_part_minor));
+#endif
+ }
first_part_minor++;
}
printk("\n");
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-09-26 4:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-26 4:30 [PATCH] raid autodetect for sun disk labels Alex Williamson
2002-09-26 4:47 ` David S. Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).