summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Peereboom <marco@cvs.openbsd.org>2008-01-24 17:50:18 +0000
committerMarco Peereboom <marco@cvs.openbsd.org>2008-01-24 17:50:18 +0000
commit09bf642dedeb502a88e5e3dc119257a18a1167c6 (patch)
treeee35d14117384b9215a6bc82b4993a1d6b633bfd
parentfa0d145b74edd2ec5341babcd7eab0f0424e4808 (diff)
Bring softraid into the world of 16 byte commands; this allows for > 2TB disks
Fix bioctl size output which was off by *512; diagnosed by otto
-rw-r--r--sys/dev/softraid.c39
-rw-r--r--sys/dev/softraid_crypto.c4
-rw-r--r--sys/dev/softraid_raid0.c4
-rw-r--r--sys/dev/softraid_raid1.c4
4 files changed, 37 insertions, 14 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index 689e1e7a7c5..6bdbecf4e25 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.94 2008/01/24 13:54:47 marco Exp $ */
+/* $OpenBSD: softraid.c,v 1.95 2008/01/24 17:50:17 marco Exp $ */
/*
* Copyright (c) 2007 Marco Peereboom <marco@peereboom.us>
*
@@ -433,8 +433,10 @@ sr_scsi_cmd(struct scsi_xfer *xs)
switch (xs->cmd->opcode) {
case READ_COMMAND:
case READ_BIG:
+ case READ_16:
case WRITE_COMMAND:
case WRITE_BIG:
+ case WRITE_16:
DNPRINTF(SR_D_CMD, "%s: sr_scsi_cmd: READ/WRITE %02x\n",
DEVNAME(sc), xs->cmd->opcode);
if (sd->sd_scsi_rw(wu))
@@ -470,8 +472,9 @@ sr_scsi_cmd(struct scsi_xfer *xs)
goto complete;
case READ_CAPACITY:
- DNPRINTF(SR_D_CMD, "%s: sr_scsi_cmd READ CAPACITY\n",
- DEVNAME(sc));
+ case READ_CAPACITY_16:
+ DNPRINTF(SR_D_CMD, "%s: sr_scsi_cmd READ CAPACITY 0x%02x\n",
+ DEVNAME(sc), xs->cmd->opcode);
if (sd->sd_scsi_read_cap(wu))
goto stuffup;
goto complete;
@@ -608,7 +611,7 @@ sr_ioctl_vol(struct sr_softc *sc, struct bioc_vol *bv)
sv = &sc->sc_dis[i]->sd_vol;
bv->bv_status = sv->sv_meta.svm_status;
- bv->bv_size = sv->sv_meta.svm_size;
+ bv->bv_size = sv->sv_meta.svm_size << DEV_BSHIFT;
bv->bv_level = sv->sv_meta.svm_level;
bv->bv_nodisk = sv->sv_meta.svm_no_chunk;
strlcpy(bv->bv_dev, sv->sv_meta.svm_devname,
@@ -641,7 +644,7 @@ sr_ioctl_disk(struct sr_softc *sc, struct bioc_disk *bd)
src = sc->sc_dis[i]->sd_vol.sv_chunks[id];
bd->bd_status = src->src_meta.scm_status;
- bd->bd_size = src->src_meta.scm_size;
+ bd->bd_size = src->src_meta.scm_size << DEV_BSHIFT;
bd->bd_channel = vol;
bd->bd_target = id;
strlcpy(bd->bd_vendor, src->src_meta.scm_devname,
@@ -712,7 +715,7 @@ sr_ioctl_createraid(struct sr_softc *sc, struct bioc_createraid *bc, int user)
dev_t *dt;
int i, s, no_chunk, rv = EINVAL, vol;
int no_meta, updatemeta = 0;
- int64_t vol_size;
+ u_int64_t vol_size;
int32_t strip_size = 0;
struct sr_chunk_head *cl;
struct sr_discipline *sd = NULL;
@@ -1395,15 +1398,29 @@ sr_raid_read_cap(struct sr_workunit *wu)
struct sr_discipline *sd = wu->swu_dis;
struct scsi_xfer *xs = wu->swu_xs;
struct scsi_read_cap_data rcd;
+ struct scsi_read_cap_data_16 rcd16;
+ int rv = 1;
DNPRINTF(SR_D_DIS, "%s: sr_raid_read_cap\n", DEVNAME(sd->sd_sc));
- bzero(&rcd, sizeof(rcd));
- _lto4b(sd->sd_vol.sv_meta.svm_size, rcd.addr);
- _lto4b(512, rcd.length);
- sr_copy_internal_data(xs, &rcd, sizeof(rcd));
+ if (xs->cmd->opcode == READ_CAPACITY) {
+ bzero(&rcd, sizeof(rcd));
+ if (sd->sd_vol.sv_meta.svm_size > 0xffffffffllu)
+ _lto4b(0xffffffff, rcd.addr);
+ else
+ _lto4b(sd->sd_vol.sv_meta.svm_size, rcd.addr);
+ _lto4b(512, 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(sd->sd_vol.sv_meta.svm_size, rcd16.addr);
+ _lto4b(512, rcd16.length);
+ sr_copy_internal_data(xs, &rcd16, sizeof(rcd16));
+ rv = 0;
+ }
- return (0);
+ return (rv);
}
int
diff --git a/sys/dev/softraid_crypto.c b/sys/dev/softraid_crypto.c
index 008bc3cf0a5..98b399ac679 100644
--- a/sys/dev/softraid_crypto.c
+++ b/sys/dev/softraid_crypto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_crypto.c,v 1.1 2007/11/27 16:37:05 tedu Exp $ */
+/* $OpenBSD: softraid_crypto.c,v 1.2 2008/01/24 17:50:17 marco Exp $ */
/*
* Copyright (c) 2007 Ted Unangst <tedu@openbsd.org>
*
@@ -77,6 +77,8 @@ sr_crypto_getcryptop(struct sr_workunit *wu, int encrypt)
if (xs->cmdlen == 10)
blk = _4btol(((struct scsi_rw_big *)xs->cmd)->addr);
+ else if (xs->cmdlen == 16)
+ blk = _8btol(((struct scsi_rw_16 *)xs->cmd)->addr);
else if (xs->cmdlen == 6)
blk = _3btol(((struct scsi_rw *)xs->cmd)->addr);
diff --git a/sys/dev/softraid_raid0.c b/sys/dev/softraid_raid0.c
index 2719b1c708f..2e2f7dbe6f6 100644
--- a/sys/dev/softraid_raid0.c
+++ b/sys/dev/softraid_raid0.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_raid0.c,v 1.3 2008/01/24 14:01:06 marco Exp $ */
+/* $OpenBSD: softraid_raid0.c,v 1.4 2008/01/24 17:50:17 marco Exp $ */
/*
* Copyright (c) 2008 Marco Peereboom <marco@peereboom.us>
*
@@ -123,6 +123,8 @@ sr_raid0_rw(struct sr_workunit *wu)
if (xs->cmdlen == 10)
blk = _4btol(((struct scsi_rw_big *)xs->cmd)->addr);
+ else if (xs->cmdlen == 16)
+ blk = _8btol(((struct scsi_rw_16 *)xs->cmd)->addr);
else if (xs->cmdlen == 6)
blk = _3btol(((struct scsi_rw *)xs->cmd)->addr);
else {
diff --git a/sys/dev/softraid_raid1.c b/sys/dev/softraid_raid1.c
index 94dd8be3823..6e20c959802 100644
--- a/sys/dev/softraid_raid1.c
+++ b/sys/dev/softraid_raid1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_raid1.c,v 1.1 2007/11/27 17:21:52 tedu Exp $ */
+/* $OpenBSD: softraid_raid1.c,v 1.2 2008/01/24 17:50:17 marco Exp $ */
/*
* Copyright (c) 2007 Marco Peereboom <marco@peereboom.us>
*
@@ -114,6 +114,8 @@ sr_raid1_rw(struct sr_workunit *wu)
if (xs->cmdlen == 10)
blk = _4btol(((struct scsi_rw_big *)xs->cmd)->addr);
+ else if (xs->cmdlen == 16)
+ blk = _8btol(((struct scsi_rw_16 *)xs->cmd)->addr);
else if (xs->cmdlen == 6)
blk = _3btol(((struct scsi_rw *)xs->cmd)->addr);
else {