diff options
author | 2010-03-26 11:20:34 +0000 | |
---|---|---|
committer | 2010-03-26 11:20:34 +0000 | |
commit | f6e5141f756d7432a6514212017fd86d5d02ed1f (patch) | |
tree | e8263bdccbeae1abdea519776e474a7db1f51f88 | |
parent | tweak previous; (diff) | |
download | wireguard-openbsd-f6e5141f756d7432a6514212017fd86d5d02ed1f.tar.xz wireguard-openbsd-f6e5141f756d7432a6514212017fd86d5d02ed1f.zip |
Add storage for the boot block and boot loader to the softraid metadata.
Also add a new optional metadata type for boot data. This is the first
step (of many) towards being able to boot from softraid volumes.
WARNING: This version of the softraid metadata is not compatible with
previous versions. As a result, any softraid volumes created with older
kernels will not assemble. Data on existing softraid volumes should be
backed up before upgrading. The volume should then be recreated and the
data restored.
ok marco@
-rw-r--r-- | sys/dev/softraid.c | 11 | ||||
-rw-r--r-- | sys/dev/softraid_crypto.c | 4 | ||||
-rw-r--r-- | sys/dev/softraid_raid0.c | 5 | ||||
-rw-r--r-- | sys/dev/softraid_raid1.c | 4 | ||||
-rw-r--r-- | sys/dev/softraid_raid6.c | 6 | ||||
-rw-r--r-- | sys/dev/softraid_raidp.c | 6 | ||||
-rw-r--r-- | sys/dev/softraidvar.h | 41 |
7 files changed, 46 insertions, 31 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c index e0a57d5e918..b83bfc495be 100644 --- a/sys/dev/softraid.c +++ b/sys/dev/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.195 2010/03/23 01:57:19 krw Exp $ */ +/* $OpenBSD: softraid.c,v 1.196 2010/03/26 11:20:34 jsing Exp $ */ /* * Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org> @@ -1341,8 +1341,7 @@ sr_meta_native_probe(struct sr_softc *sc, struct sr_chunk *ch_entry) goto unwind; } - size = DL_GETPSIZE(&label.d_partitions[part]) - - SR_META_SIZE - SR_META_OFFSET; + size = DL_GETPSIZE(&label.d_partitions[part]) - SR_DATA_OFFSET; if (size <= 0) { DNPRINTF(SR_D_META, "%s: %s partition too small\n", DEVNAME(sc), devname); @@ -2351,8 +2350,7 @@ sr_hotspare(struct sr_softc *sc, dev_t dev) } /* Calculate partition size. */ - size = DL_GETPSIZE(&label.d_partitions[part]) - - SR_META_SIZE - SR_META_OFFSET; + size = DL_GETPSIZE(&label.d_partitions[part]) - SR_DATA_OFFSET; /* * Create and populate chunk metadata. @@ -2646,8 +2644,7 @@ sr_rebuild_init(struct sr_discipline *sd, dev_t dev, int hotspare) } /* is partition large enough? */ - size = DL_GETPSIZE(&label.d_partitions[part]) - - SR_META_SIZE - SR_META_OFFSET; + size = DL_GETPSIZE(&label.d_partitions[part]) - SR_DATA_OFFSET; if (size < csize) { printf("%s: partition too small, at least %llu B required\n", DEVNAME(sc), csize << DEV_BSHIFT); diff --git a/sys/dev/softraid_crypto.c b/sys/dev/softraid_crypto.c index 7d7b9285a61..2dcf873874d 100644 --- a/sys/dev/softraid_crypto.c +++ b/sys/dev/softraid_crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_crypto.c,v 1.47 2010/01/09 23:15:06 krw Exp $ */ +/* $OpenBSD: softraid_crypto.c,v 1.48 2010/03/26 11:20:34 jsing Exp $ */ /* * Copyright (c) 2007 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Hans-Joerg Hoexer <hshoexer@openbsd.org> @@ -1144,7 +1144,7 @@ sr_crypto_rw2(struct sr_workunit *wu, struct cryptop *crp) if (sr_validate_io(wu, &blk, "sr_crypto_rw2")) goto bad; - blk += SR_META_SIZE + SR_META_OFFSET; + blk += SR_DATA_OFFSET; wu->swu_io_count = 1; diff --git a/sys/dev/softraid_raid0.c b/sys/dev/softraid_raid0.c index 9fe048f3b63..c0c7e9d218b 100644 --- a/sys/dev/softraid_raid0.c +++ b/sys/dev/softraid_raid0.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_raid0.c,v 1.19 2010/01/09 23:15:06 krw Exp $ */ +/* $OpenBSD: softraid_raid0.c,v 1.20 2010/03/26 11:20:34 jsing Exp $ */ /* * Copyright (c) 2008 Marco Peereboom <marco@peereboom.us> * @@ -300,8 +300,7 @@ sr_raid0_rw(struct sr_workunit *wu) chunk = strip_no % no_chunk; stripoffs = lbaoffs & (strip_size - 1); chunkoffs = (strip_no / no_chunk) << strip_bits; - physoffs = chunkoffs + stripoffs + - ((SR_META_OFFSET + SR_META_SIZE) << DEV_BSHIFT); + physoffs = chunkoffs + stripoffs + (SR_DATA_OFFSET << DEV_BSHIFT); length = MIN(xs->datalen, strip_size - stripoffs); leftover = xs->datalen; data = xs->data; diff --git a/sys/dev/softraid_raid1.c b/sys/dev/softraid_raid1.c index 343e390a027..916defebe94 100644 --- a/sys/dev/softraid_raid1.c +++ b/sys/dev/softraid_raid1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_raid1.c,v 1.22 2010/01/09 23:15:06 krw Exp $ */ +/* $OpenBSD: softraid_raid1.c,v 1.23 2010/03/26 11:20:34 jsing Exp $ */ /* * Copyright (c) 2007 Marco Peereboom <marco@peereboom.us> * @@ -381,7 +381,7 @@ sr_raid1_rw(struct sr_workunit *wu) goto bad; /* calculate physical block */ - blk += SR_META_SIZE + SR_META_OFFSET; + blk += SR_DATA_OFFSET; if (xs->flags & SCSI_DATA_IN) ios = 1; diff --git a/sys/dev/softraid_raid6.c b/sys/dev/softraid_raid6.c index bcfa69f8d6a..a6e68c21a78 100644 --- a/sys/dev/softraid_raid6.c +++ b/sys/dev/softraid_raid6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_raid6.c,v 1.15 2010/02/09 01:18:05 jordan Exp $ */ +/* $OpenBSD: softraid_raid6.c,v 1.16 2010/03/26 11:20:34 jsing Exp $ */ /* * Copyright (c) 2009 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2009 Jordan Hargrave <jordan@openbsd.org> @@ -490,8 +490,8 @@ sr_raid6_rw(struct sr_workunit *wu) strip_no = lbaoffs >> strip_bits; strip_offs = lbaoffs & (strip_size - 1); chunk_offs = (strip_no / no_chunk) << strip_bits; - phys_offs = chunk_offs + strip_offs + - ((SR_META_OFFSET + SR_META_SIZE) << DEV_BSHIFT); + phys_offs = chunk_offs + strip_offs + + (SR_DATA_OFFSET << DEV_BSHIFT); /* get size remaining in this stripe */ length = MIN(strip_size - strip_offs, datalen); diff --git a/sys/dev/softraid_raidp.c b/sys/dev/softraid_raidp.c index 594a9b72764..1afc73ae068 100644 --- a/sys/dev/softraid_raidp.c +++ b/sys/dev/softraid_raidp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_raidp.c,v 1.15 2010/01/20 19:55:15 jordan Exp $ */ +/* $OpenBSD: softraid_raidp.c,v 1.16 2010/03/26 11:20:34 jsing Exp $ */ /* * Copyright (c) 2009 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2009 Jordan Hargrave <jordan@openbsd.org> @@ -406,8 +406,8 @@ sr_raidp_rw(struct sr_workunit *wu) strip_no = lbaoffs >> strip_bits; strip_offs = lbaoffs & (strip_size - 1); chunk_offs = (strip_no / no_chunk) << strip_bits; - phys_offs = chunk_offs + strip_offs + - ((SR_META_OFFSET + SR_META_SIZE) << DEV_BSHIFT); + phys_offs = chunk_offs + strip_offs + + (SR_DATA_OFFSET << DEV_BSHIFT); /* get size remaining in this stripe */ length = MIN(strip_size - strip_offs, datalen); diff --git a/sys/dev/softraidvar.h b/sys/dev/softraidvar.h index e581e75cf64..fdc5e0cb0c9 100644 --- a/sys/dev/softraidvar.h +++ b/sys/dev/softraidvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: softraidvar.h,v 1.89 2010/02/13 21:19:26 jsing Exp $ */ +/* $OpenBSD: softraidvar.h,v 1.90 2010/03/26 11:20:34 jsing Exp $ */ /* * Copyright (c) 2006 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org> @@ -22,22 +22,32 @@ #include <crypto/md5.h> #include <sys/vnode.h> -#define SR_UUID_MAX 16 -struct sr_uuid { - u_int8_t sui_id[SR_UUID_MAX]; -} __packed; +#define SR_META_VERSION 4 /* bump when sr_metadata changes */ +#define SR_META_SIZE 64 /* save space at chunk beginning */ +#define SR_META_OFFSET 16 /* skip 8192 bytes at chunk beginning */ + +#define SR_META_F_NATIVE 0 /* Native metadata format. */ +#define SR_META_F_INVALID -1 + +#define SR_BOOT_OFFSET (SR_META_OFFSET + SR_META_SIZE) +#define SR_BOOT_LOADER_SIZE 320 /* Size of boot loader storage. */ +#define SR_BOOT_LOADER_OFFSET SR_BOOT_OFFSET +#define SR_BOOT_BLOCKS_SIZE 128 /* Size of boot block storage. */ +#define SR_BOOT_BLOCKS_OFFSET (SR_BOOT_LOADER_OFFSET + SR_BOOT_LOADER_SIZE) +#define SR_BOOT_SIZE (SR_BOOT_LOADER_SIZE + SR_BOOT_BLOCKS_SIZE) + +#define SR_HEADER_SIZE (SR_META_SIZE + SR_BOOT_SIZE) +#define SR_DATA_OFFSET (SR_META_OFFSET + SR_HEADER_SIZE) #define SR_HOTSPARE_LEVEL 0xffffffff #define SR_HOTSPARE_VOLID 0xffffffff #define SR_KEYDISK_LEVEL 0xfffffffe #define SR_KEYDISK_VOLID 0xfffffffe -#define SR_META_SIZE 64 /* save space at chunk beginning */ -#define SR_META_OFFSET 16 /* skip 8192 bytes at chunk beginning */ -#define SR_META_VERSION 3 /* bump when sr_metadata changes */ - -#define SR_META_F_NATIVE 0 /* Native metadata format. */ -#define SR_META_F_INVALID -1 +#define SR_UUID_MAX 16 +struct sr_uuid { + u_int8_t sui_id[SR_UUID_MAX]; +} __packed; struct sr_metadata { struct sr_meta_invariant { @@ -136,18 +146,27 @@ struct sr_meta_crypto { #define chk_hmac_sha1 _scm_chk.chk_hmac_sha1 } __packed; +struct sr_meta_boot { + u_int64_t sbm_root_uid; + u_int32_t sbm_bootblk_size; + u_int32_t sbm_bootldr_size; +} __packed; + struct sr_meta_opt { struct sr_meta_opt_invariant { u_int32_t som_type; /* optional type */ #define SR_OPT_INVALID 0x00 #define SR_OPT_CRYPTO 0x01 +#define SR_OPT_BOOT 0x02 u_int32_t som_pad; union { struct sr_meta_crypto smm_crypto; + struct sr_meta_boot smm_boot; } som_meta; } _som_invariant; #define somi _som_invariant #define somi_crypto _som_invariant.smm_crypto +#define somi_boot _som_invariant.smm_boot /* MD5 of invariant optional metadata */ u_int8_t som_checksum[MD5_DIGEST_LENGTH]; } __packed; |