summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorAndrew Stormont <astormont@racktopsystems.com>2020-05-22 16:50:12 +0100
committerAndrew Stormont <astormont@racktopsystems.com>2021-07-06 16:01:32 +0100
commit1a065e93eee983124652c3eb0cfdcb4776cd89ab (patch)
tree0e3155cdca158699844de794661fee7c5cb4bb0a /usr/src
parent3a18338393f3485e50eae6288b6a9ab89e9f715a (diff)
downloadillumos-joyent-1a065e93eee983124652c3eb0cfdcb4776cd89ab.tar.gz
12782 GRUB should pass pool and vdev GUIDs in $ZFS-BOOTFS
Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Igor Kozhukhov <igor@dilos.org> Approved by: Garrett D'Amore <garrett@damore.org>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/grub/capability3
-rw-r--r--usr/src/grub/grub-0.97/stage2/builtins.c3
-rw-r--r--usr/src/grub/grub-0.97/stage2/disk_io.c3
-rw-r--r--usr/src/grub/grub-0.97/stage2/expand.c18
-rw-r--r--usr/src/grub/grub-0.97/stage2/fsys_zfs.c19
-rw-r--r--usr/src/grub/grub-0.97/stage2/shared.h3
6 files changed, 40 insertions, 9 deletions
diff --git a/usr/src/grub/capability b/usr/src/grub/capability
index dd7c6018df..69b12a3b4e 100644
--- a/usr/src/grub/capability
+++ b/usr/src/grub/capability
@@ -22,6 +22,7 @@
# Copyright (c) 2013, 2015 by Delphix. All rights reserved.
# Copyright 2013 Saso Kiselkov. All rights reserved.
# Copyright 2016 Nexenta Systems, Inc.
+# Copyright 2021 RackTop Systems, Inc.
#
# This file defines the current capabilities of GRUB over and above that
# supported by the standard distribution
@@ -31,7 +32,7 @@
# GRUB necessitating that the boot blocks be reinstalled for that fix or
# enhancement to take effect.
#
-VERSION=28
+VERSION=29
dboot
xVM
zfs
diff --git a/usr/src/grub/grub-0.97/stage2/builtins.c b/usr/src/grub/grub-0.97/stage2/builtins.c
index 1c5d15ef2b..dfa2cb058e 100644
--- a/usr/src/grub/grub-0.97/stage2/builtins.c
+++ b/usr/src/grub/grub-0.97/stage2/builtins.c
@@ -2,6 +2,7 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
+ * Copyright 2021 RackTop Systems, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -121,6 +122,8 @@ init_config (void)
current_bootpath[0] = '\0';
current_bootfs_obj = 0;
current_devid[0] = '\0';
+ current_bootguid = 0;
+ current_bootvdev = 0;
is_zfs_mount = 0;
}
diff --git a/usr/src/grub/grub-0.97/stage2/disk_io.c b/usr/src/grub/grub-0.97/stage2/disk_io.c
index 1b07c23f7c..0b5bbf5f0e 100644
--- a/usr/src/grub/grub-0.97/stage2/disk_io.c
+++ b/usr/src/grub/grub-0.97/stage2/disk_io.c
@@ -2,6 +2,7 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
+ * Copyright 2021 RackTop Systems, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -130,6 +131,8 @@ char current_bootfs[MAXNAMELEN];
uint64_t current_bootfs_obj;
char current_bootpath[MAXPATHLEN];
char current_devid[MAXPATHLEN];
+uint64_t current_bootguid;
+uint64_t current_bootvdev;
int is_zfs_mount;
unsigned long best_drive;
unsigned long best_part;
diff --git a/usr/src/grub/grub-0.97/stage2/expand.c b/usr/src/grub/grub-0.97/stage2/expand.c
index ead71c6e6b..912ef78a16 100644
--- a/usr/src/grub/grub-0.97/stage2/expand.c
+++ b/usr/src/grub/grub-0.97/stage2/expand.c
@@ -2,6 +2,7 @@
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
* Copyright (c) 2013 Joyent, Inc. All rights reserved.
+ * Copyright 2021 RackTop Systems, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -388,6 +389,15 @@ expand_string(const char *s, char *d, unsigned int len)
if (current_devid[0] != '\0')
vlen += 13 + strlen(current_devid);
+ if (current_bootguid != 0) {
+ vlen += grub_sprintf(NULL,
+ ",zfs-bootpool=\"%llu\"", current_bootguid);
+ }
+ if (current_bootvdev != 0) {
+ vlen += grub_sprintf(NULL,
+ ",zfs-bootvdev=\"%llu\"", current_bootvdev);
+ }
+
if (q + vlen >= d + len)
return (ERR_WONT_FIT);
@@ -406,6 +416,14 @@ expand_string(const char *s, char *d, unsigned int len)
q += grub_sprintf(q, ",diskdevid=\"%s\"",
current_devid);
}
+ if (current_bootguid != 0) {
+ q += grub_sprintf(q, ",zfs-bootpool=\"%llu\"",
+ current_bootguid);
+ }
+ if (current_bootvdev != 0) {
+ q += grub_sprintf(q, ",zfs-bootvdev=\"%llu\"",
+ current_bootvdev);
+ }
p += 11; /* $ZFS-BOOTFS */
continue;
diff --git a/usr/src/grub/grub-0.97/stage2/fsys_zfs.c b/usr/src/grub/grub-0.97/stage2/fsys_zfs.c
index ead5947ab5..ef51e0b4bd 100644
--- a/usr/src/grub/grub-0.97/stage2/fsys_zfs.c
+++ b/usr/src/grub/grub-0.97/stage2/fsys_zfs.c
@@ -1,6 +1,7 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
+ * Copyright 2021 RackTop Systems, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1525,13 +1526,13 @@ vdev_get_bootpath(char *nv, uint64_t inguid, char *devid, char *bootpath,
* ERR_* - failure
*/
static int
-check_pool_label(uint64_t sector, char *stack, char *outdevid,
- char *outpath, uint64_t *outguid, uint64_t *outashift, uint64_t *outversion)
+check_pool_label(uint64_t sector, char *stack, char *outdevid, char *outpath,
+ uint64_t *outguid, uint64_t *outdiskguid, uint64_t *outashift,
+ uint64_t *outversion)
{
vdev_phys_t *vdev;
uint64_t pool_state, txg = 0;
char *nvlist, *nv, *features;
- uint64_t diskguid;
sector += (VDEV_SKIP_SIZE >> SPA_MINBLOCKSHIFT);
@@ -1572,13 +1573,13 @@ check_pool_label(uint64_t sector, char *stack, char *outdevid,
if (nvlist_lookup_value(nvlist, ZPOOL_CONFIG_VDEV_TREE, &nv,
DATA_TYPE_NVLIST, NULL))
return (ERR_FSYS_CORRUPT);
- if (nvlist_lookup_value(nvlist, ZPOOL_CONFIG_GUID, &diskguid,
+ if (nvlist_lookup_value(nvlist, ZPOOL_CONFIG_GUID, outdiskguid,
DATA_TYPE_UINT64, NULL))
return (ERR_FSYS_CORRUPT);
if (nvlist_lookup_value(nv, ZPOOL_CONFIG_ASHIFT, outashift,
DATA_TYPE_UINT64, NULL) != 0)
return (ERR_FSYS_CORRUPT);
- if (vdev_get_bootpath(nv, diskguid, outdevid, outpath, 0))
+ if (vdev_get_bootpath(nv, *outdiskguid, outdevid, outpath, 0))
return (ERR_NO_BOOTPATH);
if (nvlist_lookup_value(nvlist, ZPOOL_CONFIG_POOL_GUID, outguid,
DATA_TYPE_UINT64, NULL))
@@ -1627,7 +1628,7 @@ zfs_mount(void)
objset_phys_t *osp;
char tmp_bootpath[MAXNAMELEN];
char tmp_devid[MAXNAMELEN];
- uint64_t tmp_guid, ashift, version;
+ uint64_t tmp_guid, tmp_vdev, ashift, version;
uint64_t adjpl = (uint64_t)part_length << SPA_MINBLOCKSHIFT;
int err = errnum; /* preserve previous errnum state */
@@ -1669,8 +1670,8 @@ zfs_mount(void)
0, VDEV_UBERBLOCK_RING, ub_array) == 0)
continue;
- if (check_pool_label(sector, stack, tmp_devid,
- tmp_bootpath, &tmp_guid, &ashift, &version))
+ if (check_pool_label(sector, stack, tmp_devid, tmp_bootpath,
+ &tmp_guid, &tmp_vdev, &ashift, &version))
continue;
if (pool_guid == 0)
@@ -1695,6 +1696,8 @@ zfs_mount(void)
grub_memmove(&current_uberblock, ubbest, sizeof (uberblock_t));
grub_memmove(current_bootpath, tmp_bootpath, MAXNAMELEN);
grub_memmove(current_devid, tmp_devid, grub_strlen(tmp_devid));
+ current_bootguid = tmp_guid;
+ current_bootvdev = tmp_vdev;
is_zfs_mount = 1;
return (1);
}
diff --git a/usr/src/grub/grub-0.97/stage2/shared.h b/usr/src/grub/grub-0.97/stage2/shared.h
index 050e6335fe..74e74255c1 100644
--- a/usr/src/grub/grub-0.97/stage2/shared.h
+++ b/usr/src/grub/grub-0.97/stage2/shared.h
@@ -2,6 +2,7 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
+ * Copyright 2021 RackTop Systems, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -682,6 +683,8 @@ extern char current_bootfs[MAXNAMELEN];
extern unsigned long long current_bootfs_obj;
extern char current_bootpath[MAXPATHLEN];
extern char current_devid[MAXPATHLEN];
+extern unsigned long long current_bootguid;
+extern unsigned long long current_bootvdev;
extern int is_zfs_mount;
extern unsigned long best_drive;
extern unsigned long best_part;