summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amd64/stand/libsa/softraid.c11
-rw-r--r--sys/arch/i386/stand/libsa/softraid.c11
-rw-r--r--sys/arch/sparc64/stand/ofwboot/softraid.c21
-rw-r--r--sys/dev/softraid.c58
-rw-r--r--sys/dev/softraid_crypto.c6
5 files changed, 56 insertions, 51 deletions
diff --git a/sys/arch/amd64/stand/libsa/softraid.c b/sys/arch/amd64/stand/libsa/softraid.c
index 16582514cd4..89fea751496 100644
--- a/sys/arch/amd64/stand/libsa/softraid.c
+++ b/sys/arch/amd64/stand/libsa/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.9 2015/05/29 13:54:26 krw Exp $ */
+/* $OpenBSD: softraid.c,v 1.10 2015/07/19 16:12:10 krw Exp $ */
/*
* Copyright (c) 2012 Joel Sing <jsing@openbsd.org>
@@ -150,7 +150,7 @@ srprobe(void)
SLIST_INIT(&sr_volumes);
SLIST_INIT(&sr_keydisks);
- md = alloc(SR_META_SIZE * 512);
+ md = alloc(SR_META_SIZE * DEV_BSIZE);
TAILQ_FOREACH(dip, &disklist, list) {
@@ -170,8 +170,9 @@ srprobe(void)
continue;
/* Read softraid metadata. */
- bzero(md, SR_META_SIZE * 512);
- off = DL_GETPOFFSET(pp) + SR_META_OFFSET;
+ bzero(md, SR_META_SIZE * DEV_BSIZE);
+ off = DL_SECTOBLK(&dip->disklabel, DL_GETPOFFSET(pp));
+ off += SR_META_OFFSET;
error = biosd_io(F_READ, &dip->bios_info, off,
SR_META_SIZE, md);
if (error)
@@ -314,7 +315,7 @@ srprobe(void)
bv->sbv_flags & BIOC_SCBOOTABLE ? "*" : "");
}
- explicit_bzero(md, SR_META_SIZE * 512);
+ explicit_bzero(md, SR_META_SIZE * DEV_BSIZE);
free(md, 0);
}
diff --git a/sys/arch/i386/stand/libsa/softraid.c b/sys/arch/i386/stand/libsa/softraid.c
index 16582514cd4..89fea751496 100644
--- a/sys/arch/i386/stand/libsa/softraid.c
+++ b/sys/arch/i386/stand/libsa/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.9 2015/05/29 13:54:26 krw Exp $ */
+/* $OpenBSD: softraid.c,v 1.10 2015/07/19 16:12:10 krw Exp $ */
/*
* Copyright (c) 2012 Joel Sing <jsing@openbsd.org>
@@ -150,7 +150,7 @@ srprobe(void)
SLIST_INIT(&sr_volumes);
SLIST_INIT(&sr_keydisks);
- md = alloc(SR_META_SIZE * 512);
+ md = alloc(SR_META_SIZE * DEV_BSIZE);
TAILQ_FOREACH(dip, &disklist, list) {
@@ -170,8 +170,9 @@ srprobe(void)
continue;
/* Read softraid metadata. */
- bzero(md, SR_META_SIZE * 512);
- off = DL_GETPOFFSET(pp) + SR_META_OFFSET;
+ bzero(md, SR_META_SIZE * DEV_BSIZE);
+ off = DL_SECTOBLK(&dip->disklabel, DL_GETPOFFSET(pp));
+ off += SR_META_OFFSET;
error = biosd_io(F_READ, &dip->bios_info, off,
SR_META_SIZE, md);
if (error)
@@ -314,7 +315,7 @@ srprobe(void)
bv->sbv_flags & BIOC_SCBOOTABLE ? "*" : "");
}
- explicit_bzero(md, SR_META_SIZE * 512);
+ explicit_bzero(md, SR_META_SIZE * DEV_BSIZE);
free(md, 0);
}
diff --git a/sys/arch/sparc64/stand/ofwboot/softraid.c b/sys/arch/sparc64/stand/ofwboot/softraid.c
index 9308a8475ef..296c1016dc9 100644
--- a/sys/arch/sparc64/stand/ofwboot/softraid.c
+++ b/sys/arch/sparc64/stand/ofwboot/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.1 2014/11/26 19:50:03 stsp Exp $ */
+/* $OpenBSD: softraid.c,v 1.2 2015/07/19 16:12:10 krw Exp $ */
/*
* Copyright (c) 2012 Joel Sing <jsing@openbsd.org>
@@ -151,7 +151,7 @@ srprobe(void)
SLIST_INIT(&sr_volumes);
SLIST_INIT(&sr_keydisks);
- md = alloc(SR_META_SIZE * 512);
+ md = alloc(SR_META_SIZE * DEV_BSIZE);
diskno = 0;
ihandle = -1;
TAILQ_FOREACH(dip, &disklist, list) {
@@ -168,13 +168,14 @@ srprobe(void)
continue;
/* Read softraid metadata. */
- bzero(md, SR_META_SIZE * 512);
- ofdev.partoff = DL_GETPOFFSET(pp);
+ bzero(md, SR_META_SIZE * DEV_BSIZE);
+ ofdev.partoff = DL_SECTOBLK(&dip->disklabel,
+ DL_GETPOFFSET(pp));
error = strategy(&ofdev, F_READ, SR_META_OFFSET,
- SR_META_SIZE * 512, md, &read);
- if (error || read != SR_META_SIZE * 512)
+ SR_META_SIZE * DEV_BSIZE, md, &read);
+ if (error || read != SR_META_SIZE * DEV_BSIZE)
continue;
-
+
/* Is this valid softraid metadata? */
if (md->ssdi.ssd_magic != SR_MAGIC)
continue;
@@ -315,8 +316,8 @@ srprobe(void)
bv->sbv_flags & BIOC_SCBOOTABLE ? "*" : "");
}
- explicit_bzero(md, SR_META_SIZE * 512);
- free(md, SR_META_SIZE * 512);
+ explicit_bzero(md, SR_META_SIZE * DEV_BSIZE);
+ free(md, SR_META_SIZE * DEV_BSIZE);
}
int
@@ -334,7 +335,7 @@ sr_strategy(struct sr_boot_volume *bv, int rw, daddr32_t blk, size_t size,
u_char *bp;
int err;
int ihandle;
-
+
/* We only support read-only softraid. */
if (rw != F_READ)
return ENOTSUP;
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index c46c7d9f73c..21d56c17c58 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.354 2015/05/29 13:48:45 krw Exp $ */
+/* $OpenBSD: softraid.c,v 1.355 2015/07/19 16:12:10 krw Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -215,7 +215,7 @@ struct sr_meta_driver {
int (*smd_validate)(struct sr_discipline *,
struct sr_metadata *, void *);
} smd[] = {
- { SR_META_OFFSET, SR_META_SIZE * 512,
+ { SR_META_OFFSET, SR_META_SIZE * DEV_BSIZE,
sr_meta_native_probe, sr_meta_native_attach, NULL,
sr_meta_native_read, sr_meta_native_write, NULL },
{ 0, 0, NULL, NULL, NULL, NULL }
@@ -232,7 +232,8 @@ sr_meta_attach(struct sr_discipline *sd, int chunk_no, int force)
DNPRINTF(SR_D_META, "%s: sr_meta_attach(%d)\n", DEVNAME(sc), chunk_no);
/* in memory copy of metadata */
- sd->sd_meta = malloc(SR_META_SIZE * 512, M_DEVBUF, M_ZERO | M_NOWAIT);
+ sd->sd_meta = malloc(SR_META_SIZE * DEV_BSIZE, M_DEVBUF,
+ M_ZERO | M_NOWAIT);
if (!sd->sd_meta) {
sr_error(sc, "could not allocate memory for metadata");
goto bad;
@@ -509,7 +510,7 @@ sr_meta_clear(struct sr_discipline *sd)
goto done;
}
- m = malloc(SR_META_SIZE * 512, M_DEVBUF, M_WAITOK | M_ZERO);
+ m = malloc(SR_META_SIZE * DEV_BSIZE, M_DEVBUF, M_WAITOK | M_ZERO);
SLIST_FOREACH(ch_entry, cl, src_link) {
if (sr_meta_native_write(sd, ch_entry->src_dev_mm, m, NULL)) {
/* XXX mark disk offline */
@@ -521,9 +522,9 @@ sr_meta_clear(struct sr_discipline *sd)
bzero(&ch_entry->src_meta, sizeof(ch_entry->src_meta));
}
- bzero(sd->sd_meta, SR_META_SIZE * 512);
+ bzero(sd->sd_meta, SR_META_SIZE * DEV_BSIZE);
- free(m, M_DEVBUF, SR_META_SIZE * 512);
+ free(m, M_DEVBUF, SR_META_SIZE * DEV_BSIZE);
rv = 0;
done:
return (rv);
@@ -649,7 +650,7 @@ sr_meta_save(struct sr_discipline *sd, u_int32_t flags)
/* meta scratchpad */
s = &smd[sd->sd_meta_type];
- m = malloc(SR_META_SIZE * 512, M_DEVBUF, M_ZERO | M_NOWAIT);
+ m = malloc(SR_META_SIZE * DEV_BSIZE, M_DEVBUF, M_ZERO | M_NOWAIT);
if (!m) {
printf("%s: could not allocate metadata scratch area\n",
DEVNAME(sc));
@@ -726,7 +727,7 @@ restart:
wu.swu_dis = sd;
sd->sd_scsi_sync(&wu);
}
- free(m, M_DEVBUF, SR_META_SIZE * 512);
+ free(m, M_DEVBUF, SR_META_SIZE * DEV_BSIZE);
return (0);
bad:
return (1);
@@ -746,7 +747,7 @@ sr_meta_read(struct sr_discipline *sd)
DNPRINTF(SR_D_META, "%s: sr_meta_read\n", DEVNAME(sc));
- sm = malloc(SR_META_SIZE * 512, M_DEVBUF, M_WAITOK | M_ZERO);
+ sm = malloc(SR_META_SIZE * DEV_BSIZE, M_DEVBUF, M_WAITOK | M_ZERO);
s = &smd[sd->sd_meta_type];
if (sd->sd_meta_type != SR_META_F_NATIVE)
fm = malloc(s->smd_size, M_DEVBUF, M_WAITOK | M_ZERO);
@@ -797,7 +798,7 @@ sr_meta_read(struct sr_discipline *sd)
cp++;
}
- free(sm, M_DEVBUF, SR_META_SIZE * 512);
+ free(sm, M_DEVBUF, SR_META_SIZE * DEV_BSIZE);
free(fm, M_DEVBUF, s->smd_size);
done:
@@ -1050,14 +1051,14 @@ sr_meta_native_bootprobe(struct sr_softc *sc, dev_t devno,
}
vput(vn);
- /* Make sure this is a 512-byte/sector device. */
+ /* Make sure this is a DEV_BSIZE byte/sector device. */
if (label.d_secsize != DEV_BSIZE) {
DNPRINTF(SR_D_META, "%s: %s has unsupported sector size (%d)",
DEVNAME(sc), devname, label.d_secsize);
goto done;
}
- md = malloc(SR_META_SIZE * 512, M_DEVBUF, M_ZERO | M_NOWAIT);
+ md = malloc(SR_META_SIZE * DEV_BSIZE, M_DEVBUF, M_ZERO | M_NOWAIT);
if (md == NULL) {
sr_error(sc, "not enough memory for metadata buffer");
goto done;
@@ -1128,7 +1129,7 @@ sr_meta_native_bootprobe(struct sr_softc *sc, dev_t devno,
done:
free(fake_sd, M_DEVBUF, sizeof(struct sr_discipline));
- free(md, M_DEVBUF, SR_META_SIZE * 512);
+ free(md, M_DEVBUF, SR_META_SIZE * DEV_BSIZE);
return (rv);
}
@@ -1566,7 +1567,7 @@ sr_meta_native_probe(struct sr_softc *sc, struct sr_chunk *ch_entry)
}
memcpy(ch_entry->src_duid, label.d_uid, sizeof(ch_entry->src_duid));
- /* Make sure this is a 512-byte/sector device. */
+ /* Make sure this is a DEV_BSIZE byte/sector device. */
if (label.d_secsize != DEV_BSIZE) {
sr_error(sc, "%s has unsupported sector size (%u)",
devname, label.d_secsize);
@@ -1614,7 +1615,7 @@ sr_meta_native_attach(struct sr_discipline *sd, int force)
DNPRINTF(SR_D_META, "%s: sr_meta_native_attach\n", DEVNAME(sc));
- md = malloc(SR_META_SIZE * 512, M_DEVBUF, M_ZERO | M_NOWAIT);
+ md = malloc(SR_META_SIZE * DEV_BSIZE, M_DEVBUF, M_ZERO | M_NOWAIT);
if (md == NULL) {
sr_error(sc, "not enough memory for metadata buffer");
goto bad;
@@ -1687,7 +1688,7 @@ sr_meta_native_attach(struct sr_discipline *sd, int force)
rv = 0;
bad:
- free(md, M_DEVBUF, SR_META_SIZE * 512);
+ free(md, M_DEVBUF, SR_META_SIZE * DEV_BSIZE);
return (rv);
}
@@ -1701,8 +1702,8 @@ sr_meta_native_read(struct sr_discipline *sd, dev_t dev,
DNPRINTF(SR_D_META, "%s: sr_meta_native_read(0x%x, %p)\n",
DEVNAME(sc), dev, md);
- return (sr_meta_rw(sd, dev, md, SR_META_SIZE * 512, SR_META_OFFSET,
- B_READ));
+ return (sr_meta_rw(sd, dev, md, SR_META_SIZE * DEV_BSIZE,
+ SR_META_OFFSET, B_READ));
}
int
@@ -1715,8 +1716,8 @@ sr_meta_native_write(struct sr_discipline *sd, dev_t dev,
DNPRINTF(SR_D_META, "%s: sr_meta_native_write(0x%x, %p)\n",
DEVNAME(sc), dev, md);
- return (sr_meta_rw(sd, dev, md, SR_META_SIZE * 512, SR_META_OFFSET,
- B_WRITE));
+ return (sr_meta_rw(sd, dev, md, SR_META_SIZE * DEV_BSIZE,
+ SR_META_OFFSET, B_WRITE));
}
void
@@ -3682,10 +3683,10 @@ sr_ioctl_installboot(struct sr_softc *sc, struct sr_discipline *sd,
goto done;
}
- if (bb->bb_bootblk_size > SR_BOOT_BLOCKS_SIZE * 512)
+ if (bb->bb_bootblk_size > SR_BOOT_BLOCKS_SIZE * DEV_BSIZE)
goto done;
- if (bb->bb_bootldr_size > SR_BOOT_LOADER_SIZE * 512)
+ if (bb->bb_bootldr_size > SR_BOOT_LOADER_SIZE * DEV_BSIZE)
goto done;
/* Copy in boot block. */
@@ -4031,13 +4032,13 @@ sr_raid_read_cap(struct sr_workunit *wu)
_lto4b(0xffffffff, rcd.addr);
else
_lto4b(addr, rcd.addr);
- _lto4b(512, rcd.length);
+ _lto4b(DEV_BSIZE, rcd.length);
sr_copy_internal_data(xs, &rcd, sizeof(rcd));
rv = 0;
} else if (xs->cmd->opcode == READ_CAPACITY_16) {
bzero(&rcd16, sizeof(rcd16));
_lto8b(addr, rcd16.addr);
- _lto4b(512, rcd16.length);
+ _lto4b(DEV_BSIZE, rcd16.length);
sr_copy_internal_data(xs, &rcd16, sizeof(rcd16));
rv = 0;
}
@@ -4491,7 +4492,7 @@ sr_validate_stripsize(u_int32_t b)
{
int s = 0;
- if (b % 512)
+ if (b % DEV_BSIZE)
return (-1);
while ((b & 1) == 0) {
@@ -5020,6 +5021,7 @@ sr_hibernate_io(dev_t dev, daddr_t blkno, vaddr_t addr, size_t size, int op, voi
daddr_t key_blkno;
uint32_t sub_raidoff; /* ofs of sr part in underlying dev */
struct disklabel dl;
+ struct partition *pp;
size_t i, j;
u_char iv[8];
@@ -5065,13 +5067,13 @@ sr_hibernate_io(dev_t dev, daddr_t blkno, vaddr_t addr, size_t size, int op, voi
return (ENOTSUP);
}
- if (dl.d_partitions[DISKPART(my->subdev)].p_fstype != FS_RAID ||
- DL_GETPSIZE(&dl.d_partitions[DISKPART(my->subdev)]) == 0)
+ pp = &dl.d_partitions[DISKPART(my->subdev)];
+ if (pp->p_fstype != FS_RAID || DL_GETPSIZE(pp) == 0)
return (ENOTSUP);
/* Find the offset of the SR part in the underlying device */
sub_raidoff = my->srd->sd_meta->ssd_data_offset +
- DL_GETPOFFSET(&dl.d_partitions[DISKPART(my->subdev)]);
+ DL_SECTOBLK(&dl, DL_GETPOFFSET(pp));
DNPRINTF(SR_D_MISC,"sr_hibernate_io: blk trans ofs: %d blks\n",
sub_raidoff);
diff --git a/sys/dev/softraid_crypto.c b/sys/dev/softraid_crypto.c
index 0f27f9731cc..cdd094b42e2 100644
--- a/sys/dev/softraid_crypto.c
+++ b/sys/dev/softraid_crypto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_crypto.c,v 1.118 2015/07/05 20:51:33 mlarkin Exp $ */
+/* $OpenBSD: softraid_crypto.c,v 1.119 2015/07/19 16:12:10 krw Exp $ */
/*
* Copyright (c) 2007 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Hans-Joerg Hoexer <hshoexer@openbsd.org>
@@ -833,7 +833,7 @@ sr_crypto_read_key_disk(struct sr_discipline *sd, dev_t dev)
/*
* Read and validate key disk metadata.
*/
- sm = malloc(SR_META_SIZE * 512, M_DEVBUF, M_WAITOK | M_ZERO);
+ sm = malloc(SR_META_SIZE * DEV_BSIZE, M_DEVBUF, M_WAITOK | M_ZERO);
if (sr_meta_native_read(sd, dev, sm, NULL)) {
sr_error(sc, "native bootprobe could not read native metadata");
goto done;
@@ -886,7 +886,7 @@ done:
free(omi, M_DEVBUF, 0);
}
- free(sm, M_DEVBUF, SR_META_SIZE * 512);
+ free(sm, M_DEVBUF, SR_META_SIZE * DEV_BSIZE);
if (vn && open) {
VOP_CLOSE(vn, FREAD, NOCRED, curproc);