diff options
author | Marco Peereboom <marco@cvs.openbsd.org> | 2008-02-05 16:15:36 +0000 |
---|---|---|
committer | Marco Peereboom <marco@cvs.openbsd.org> | 2008-02-05 16:15:36 +0000 |
commit | a4ddd3b46ca4cdebde5521654e727d8b6ce99b2b (patch) | |
tree | f2808adfbe2a11f3b701d0d3ed3b49f7f776c071 /sys/dev/softraid_raid1.c | |
parent | a9f52949554f7da6c2067224b8b2c12db1fd2b6a (diff) |
Create a generic function to validate IO instead of copying and pasting
same code in all disciplines. This shaves of a few bytes.
crypto 3185 -> 2690
raid 0 2843 -> 2378
raid 1 3474 -> 2689
Diffstat (limited to 'sys/dev/softraid_raid1.c')
-rw-r--r-- | sys/dev/softraid_raid1.c | 46 |
1 files changed, 3 insertions, 43 deletions
diff --git a/sys/dev/softraid_raid1.c b/sys/dev/softraid_raid1.c index 933c5d57a54..430c9ed033c 100644 --- a/sys/dev/softraid_raid1.c +++ b/sys/dev/softraid_raid1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_raid1.c,v 1.3 2008/01/24 19:58:08 marco Exp $ */ +/* $OpenBSD: softraid_raid1.c,v 1.4 2008/02/05 16:15:35 marco Exp $ */ /* * Copyright (c) 2007 Marco Peereboom <marco@peereboom.us> * @@ -293,49 +293,9 @@ sr_raid1_rw(struct sr_workunit *wu) int ios, x, i, s, rt; daddr64_t blk; - DNPRINTF(SR_D_DIS, "%s: sr_raid1_rw 0x%02x\n", DEVNAME(sd->sd_sc), - xs->cmd->opcode); - - if (sd->sd_vol.sv_meta.svm_status == BIOC_SVOFFLINE) { - DNPRINTF(SR_D_DIS, "%s: sr_raid1_rw device offline\n", - DEVNAME(sd->sd_sc)); - goto bad; - } - - if (xs->datalen == 0) { - printf("%s: %s: illegal block count\n", - DEVNAME(sd->sd_sc), sd->sd_vol.sv_meta.svm_devname); - goto bad; - } - - 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 { - printf("%s: %s: illegal cmdlen\n", DEVNAME(sd->sd_sc), - sd->sd_vol.sv_meta.svm_devname); + /* blk and scsi error will be handled by sr_validate_io */ + if (sr_validate_io(wu, &blk, "sr_raid1_rw")) goto bad; - } - - wu->swu_blk_start = blk; - wu->swu_blk_end = blk + (xs->datalen >> 9) - 1; - - if (wu->swu_blk_end > sd->sd_vol.sv_meta.svm_size) { - DNPRINTF(SR_D_DIS, "%s: sr_raid1_rw out of bounds start: %lld " - "end: %lld length: %d\n", wu->swu_blk_start, - wu->swu_blk_end, xs->datalen); - - sd->sd_scsi_sense.error_code = SSD_ERRCODE_CURRENT | - SSD_ERRCODE_VALID; - sd->sd_scsi_sense.flags = SKEY_ILLEGAL_REQUEST; - sd->sd_scsi_sense.add_sense_code = 0x21; - sd->sd_scsi_sense.add_sense_code_qual = 0x00; - sd->sd_scsi_sense.extra_len = 4; - goto bad; - } /* calculate physical block */ blk += SR_META_SIZE + SR_META_OFFSET; |