* disk/dmraid_nvidia.c (grub_dmraid_nv_detect): Add start_sector
parameter. Set its pointer target to 0. * disk/mdraid_linux.c (grub_mdraid_detect): Add start_sector parameter. Set its pointer target to 0 for 0.9 metadata, or to the `data_offset' value from the superblock for 1.x metadata. * disk/raid.c (grub_raid_read): Offset reads by the start sector of data on the device. (insert_array): Record the start sector of data on the device. (grub_raid_register): Pass start_sector parameters to grub_raid_list->detect and insert_array. * include/grub/raid.h (struct grub_raid_array): Add start_sector member. (struct grub_raid): Add start_sector parameter to `detect'.
This commit is contained in:
parent
139ab97dc3
commit
1c785436da
5 changed files with 40 additions and 8 deletions
|
@ -1,3 +1,19 @@
|
||||||
|
2010-07-18 Colin Watson <cjwatson@ubuntu.com>
|
||||||
|
|
||||||
|
* disk/dmraid_nvidia.c (grub_dmraid_nv_detect): Add start_sector
|
||||||
|
parameter. Set its pointer target to 0.
|
||||||
|
* disk/mdraid_linux.c (grub_mdraid_detect): Add start_sector
|
||||||
|
parameter. Set its pointer target to 0 for 0.9 metadata, or to the
|
||||||
|
`data_offset' value from the superblock for 1.x metadata.
|
||||||
|
* disk/raid.c (grub_raid_read): Offset reads by the start sector of
|
||||||
|
data on the device.
|
||||||
|
(insert_array): Record the start sector of data on the device.
|
||||||
|
(grub_raid_register): Pass start_sector parameters to
|
||||||
|
grub_raid_list->detect and insert_array.
|
||||||
|
* include/grub/raid.h (struct grub_raid_array): Add start_sector
|
||||||
|
member.
|
||||||
|
(struct grub_raid): Add start_sector parameter to `detect'.
|
||||||
|
|
||||||
2010-07-18 Colin Watson <cjwatson@ubuntu.com>
|
2010-07-18 Colin Watson <cjwatson@ubuntu.com>
|
||||||
|
|
||||||
* disk/raid.c (insert_array): Use md/%s to name mdadm 1.x devices,
|
* disk/raid.c (insert_array): Use md/%s to name mdadm 1.x devices,
|
||||||
|
|
|
@ -89,7 +89,8 @@ struct grub_nv_super
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_dmraid_nv_detect (grub_disk_t disk, struct grub_raid_array *array)
|
grub_dmraid_nv_detect (grub_disk_t disk, struct grub_raid_array *array,
|
||||||
|
grub_disk_addr_t *start_sector)
|
||||||
{
|
{
|
||||||
grub_disk_addr_t sector;
|
grub_disk_addr_t sector;
|
||||||
struct grub_nv_super sb;
|
struct grub_nv_super sb;
|
||||||
|
@ -145,6 +146,8 @@ grub_dmraid_nv_detect (grub_disk_t disk, struct grub_raid_array *array)
|
||||||
grub_memcpy (array->uuid, (char *) &sb.array.signature,
|
grub_memcpy (array->uuid, (char *) &sb.array.signature,
|
||||||
sizeof (sb.array.signature));
|
sizeof (sb.array.signature));
|
||||||
|
|
||||||
|
*start_sector = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -229,7 +229,8 @@ struct grub_raid_super_1x
|
||||||
#define WriteMostly1 1 /* Mask for writemostly flag in above devflags. */
|
#define WriteMostly1 1 /* Mask for writemostly flag in above devflags. */
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array)
|
grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array,
|
||||||
|
grub_disk_addr_t *start_sector)
|
||||||
{
|
{
|
||||||
grub_disk_addr_t sector;
|
grub_disk_addr_t sector;
|
||||||
grub_uint64_t size, sb_size;
|
grub_uint64_t size, sb_size;
|
||||||
|
@ -328,6 +329,8 @@ superblock_0_90:
|
||||||
uuid[2] = sb.set_uuid2;
|
uuid[2] = sb.set_uuid2;
|
||||||
uuid[3] = sb.set_uuid3;
|
uuid[3] = sb.set_uuid3;
|
||||||
|
|
||||||
|
*start_sector = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
superblock_1_x:
|
superblock_1_x:
|
||||||
|
@ -387,6 +390,8 @@ superblock_0_90:
|
||||||
|
|
||||||
grub_memcpy (array->uuid, sb_1x->set_uuid, 16);
|
grub_memcpy (array->uuid, sb_1x->set_uuid, 16);
|
||||||
|
|
||||||
|
*start_sector = sb_1x->data_offset;
|
||||||
|
|
||||||
grub_free (sb_1x);
|
grub_free (sb_1x);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
15
disk/raid.c
15
disk/raid.c
|
@ -254,7 +254,8 @@ grub_raid_read (grub_disk_t disk, grub_disk_addr_t sector,
|
||||||
grub_errno = GRUB_ERR_NONE;
|
grub_errno = GRUB_ERR_NONE;
|
||||||
|
|
||||||
err = grub_disk_read (array->device[k],
|
err = grub_disk_read (array->device[k],
|
||||||
read_sector + j * far_ofs + b,
|
array->start_sector[k] +
|
||||||
|
read_sector + j * far_ofs + b,
|
||||||
0,
|
0,
|
||||||
read_size << GRUB_DISK_SECTOR_BITS,
|
read_size << GRUB_DISK_SECTOR_BITS,
|
||||||
buf);
|
buf);
|
||||||
|
@ -366,7 +367,8 @@ grub_raid_read (grub_disk_t disk, grub_disk_addr_t sector,
|
||||||
grub_errno = GRUB_ERR_NONE;
|
grub_errno = GRUB_ERR_NONE;
|
||||||
|
|
||||||
err = grub_disk_read (array->device[disknr],
|
err = grub_disk_read (array->device[disknr],
|
||||||
read_sector + b, 0,
|
array->start_sector[disknr] +
|
||||||
|
read_sector + b, 0,
|
||||||
read_size << GRUB_DISK_SECTOR_BITS,
|
read_size << GRUB_DISK_SECTOR_BITS,
|
||||||
buf);
|
buf);
|
||||||
|
|
||||||
|
@ -475,7 +477,7 @@ grub_raid_write (grub_disk_t disk __attribute ((unused)),
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
insert_array (grub_disk_t disk, struct grub_raid_array *new_array,
|
insert_array (grub_disk_t disk, struct grub_raid_array *new_array,
|
||||||
const char *scanner_name)
|
grub_disk_addr_t start_sector, const char *scanner_name)
|
||||||
{
|
{
|
||||||
struct grub_raid_array *array = 0, *p;
|
struct grub_raid_array *array = 0, *p;
|
||||||
|
|
||||||
|
@ -524,6 +526,7 @@ insert_array (grub_disk_t disk, struct grub_raid_array *new_array,
|
||||||
*array = *new_array;
|
*array = *new_array;
|
||||||
array->nr_devs = 0;
|
array->nr_devs = 0;
|
||||||
grub_memset (&array->device, 0, sizeof (array->device));
|
grub_memset (&array->device, 0, sizeof (array->device));
|
||||||
|
grub_memset (&array->start_sector, 0, sizeof (array->start_sector));
|
||||||
|
|
||||||
if (array->name)
|
if (array->name)
|
||||||
goto skip_duplicate_check;
|
goto skip_duplicate_check;
|
||||||
|
@ -587,6 +590,7 @@ insert_array (grub_disk_t disk, struct grub_raid_array *new_array,
|
||||||
|
|
||||||
/* Add the device to the array. */
|
/* Add the device to the array. */
|
||||||
array->device[new_array->index] = disk;
|
array->device[new_array->index] = disk;
|
||||||
|
array->start_sector[new_array->index] = start_sector;
|
||||||
array->nr_devs++;
|
array->nr_devs++;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -628,6 +632,7 @@ grub_raid_register (grub_raid_t raid)
|
||||||
{
|
{
|
||||||
grub_disk_t disk;
|
grub_disk_t disk;
|
||||||
struct grub_raid_array array;
|
struct grub_raid_array array;
|
||||||
|
grub_disk_addr_t start_sector;
|
||||||
|
|
||||||
grub_dprintf ("raid", "Scanning for RAID devices on disk %s\n", name);
|
grub_dprintf ("raid", "Scanning for RAID devices on disk %s\n", name);
|
||||||
|
|
||||||
|
@ -636,8 +641,8 @@ grub_raid_register (grub_raid_t raid)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if ((disk->total_sectors != GRUB_ULONG_MAX) &&
|
if ((disk->total_sectors != GRUB_ULONG_MAX) &&
|
||||||
(! grub_raid_list->detect (disk, &array)) &&
|
(! grub_raid_list->detect (disk, &array, &start_sector)) &&
|
||||||
(! insert_array (disk, &array, grub_raid_list->name)))
|
(! insert_array (disk, &array, start_sector, grub_raid_list->name)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* This error usually means it's not raid, no need to display
|
/* This error usually means it's not raid, no need to display
|
||||||
|
|
|
@ -51,6 +51,8 @@ struct grub_raid_array
|
||||||
char *name; /* That will be "md<number>". */
|
char *name; /* That will be "md<number>". */
|
||||||
unsigned int nr_devs; /* The number of devices we've found so far. */
|
unsigned int nr_devs; /* The number of devices we've found so far. */
|
||||||
grub_disk_t device[GRUB_RAID_MAX_DEVICES]; /* Array of total_devs devices. */
|
grub_disk_t device[GRUB_RAID_MAX_DEVICES]; /* Array of total_devs devices. */
|
||||||
|
grub_disk_addr_t start_sector[GRUB_RAID_MAX_DEVICES];
|
||||||
|
/* Start of each device, in 512 byte sectors. */
|
||||||
struct grub_raid_array *next;
|
struct grub_raid_array *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -58,7 +60,8 @@ struct grub_raid
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
grub_err_t (*detect) (grub_disk_t disk, struct grub_raid_array *array);
|
grub_err_t (*detect) (grub_disk_t disk, struct grub_raid_array *array,
|
||||||
|
grub_disk_addr_t *start_sector);
|
||||||
|
|
||||||
struct grub_raid *next;
|
struct grub_raid *next;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue