svn commit: r268149 - stable/10/sys/cam/ctl
Alexander Motin
mav at FreeBSD.org
Wed Jul 2 10:42:44 UTC 2014
Author: mav
Date: Wed Jul 2 10:42:43 2014
New Revision: 268149
URL: http://svnweb.freebsd.org/changeset/base/268149
Log:
MFC r267515:
Remove memcpy() from ctl_private[] accesses.
That union is aligned enough to access data directly.
Modified:
stable/10/sys/cam/ctl/ctl.c
stable/10/sys/cam/ctl/ctl_backend_block.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/cam/ctl/ctl.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl.c Wed Jul 2 10:41:11 2014 (r268148)
+++ stable/10/sys/cam/ctl/ctl.c Wed Jul 2 10:42:43 2014 (r268149)
@@ -5779,7 +5779,7 @@ int
ctl_write_same(struct ctl_scsiio *ctsio)
{
struct ctl_lun *lun;
- struct ctl_lba_len_flags lbalen;
+ struct ctl_lba_len_flags *lbalen;
uint64_t lba;
uint32_t num_blocks;
int len, retval;
@@ -5872,11 +5872,10 @@ ctl_write_same(struct ctl_scsiio *ctsio)
return (CTL_RETVAL_COMPLETE);
}
- lbalen.lba = lba;
- lbalen.len = num_blocks;
- lbalen.flags = byte2;
- memcpy(ctsio->io_hdr.ctl_private[CTL_PRIV_LBA_LEN].bytes, &lbalen,
- sizeof(lbalen));
+ lbalen = (struct ctl_lba_len_flags *)&ctsio->io_hdr.ctl_private[CTL_PRIV_LBA_LEN];
+ lbalen->lba = lba;
+ lbalen->len = num_blocks;
+ lbalen->flags = byte2;
retval = lun->backend->config_write((union ctl_io *)ctsio);
return (retval);
@@ -5887,7 +5886,7 @@ ctl_unmap(struct ctl_scsiio *ctsio)
{
struct ctl_lun *lun;
struct scsi_unmap *cdb;
- struct ctl_ptr_len_flags ptrlen;
+ struct ctl_ptr_len_flags *ptrlen;
struct scsi_unmap_header *hdr;
struct scsi_unmap_desc *buf, *end;
uint64_t lba;
@@ -5942,11 +5941,10 @@ ctl_unmap(struct ctl_scsiio *ctsio)
buf = (struct scsi_unmap_desc *)(hdr + 1);
end = buf + len / sizeof(*buf);
- ptrlen.ptr = (void *)buf;
- ptrlen.len = len;
- ptrlen.flags = byte2;
- memcpy(ctsio->io_hdr.ctl_private[CTL_PRIV_LBA_LEN].bytes, &ptrlen,
- sizeof(ptrlen));
+ ptrlen = (struct ctl_ptr_len_flags *)&ctsio->io_hdr.ctl_private[CTL_PRIV_LBA_LEN];
+ ptrlen->ptr = (void *)buf;
+ ptrlen->len = len;
+ ptrlen->flags = byte2;
for (; buf < end; buf++) {
lba = scsi_8btou64(buf->lba);
@@ -12755,7 +12753,7 @@ ctl_process_done(union ctl_io *io, int h
switch (io->io_hdr.io_type) {
case CTL_IO_SCSI: {
int isread;
- struct ctl_lba_len lbalen;
+ struct ctl_lba_len *lbalen;
isread = 0;
switch (io->scsiio.cdb[0]) {
@@ -12772,12 +12770,12 @@ ctl_process_done(union ctl_io *io, int h
case WRITE_VERIFY_10:
case WRITE_VERIFY_12:
case WRITE_VERIFY_16:
- memcpy(&lbalen, io->io_hdr.ctl_private[
- CTL_PRIV_LBA_LEN].bytes, sizeof(lbalen));
+ lbalen = (struct ctl_lba_len *)
+ &io->io_hdr.ctl_private[CTL_PRIV_LBA_LEN];
if (isread) {
lun->stats.ports[targ_port].bytes[CTL_STATS_READ] +=
- lbalen.len * blocksize;
+ lbalen->len * blocksize;
lun->stats.ports[targ_port].operations[CTL_STATS_READ]++;
#ifdef CTL_TIME_IO
@@ -12807,7 +12805,7 @@ ctl_process_done(union ctl_io *io, int h
#endif /* CTL_TIME_IO */
} else {
lun->stats.ports[targ_port].bytes[CTL_STATS_WRITE] +=
- lbalen.len * blocksize;
+ lbalen->len * blocksize;
lun->stats.ports[targ_port].operations[
CTL_STATS_WRITE]++;
Modified: stable/10/sys/cam/ctl/ctl_backend_block.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl_backend_block.c Wed Jul 2 10:41:11 2014 (r268148)
+++ stable/10/sys/cam/ctl/ctl_backend_block.c Wed Jul 2 10:42:43 2014 (r268149)
@@ -788,7 +788,7 @@ ctl_be_block_unmap_dev(struct ctl_be_blo
{
union ctl_io *io;
struct ctl_be_block_devdata *dev_data;
- struct ctl_ptr_len_flags ptrlen;
+ struct ctl_ptr_len_flags *ptrlen;
struct scsi_unmap_desc *buf, *end;
uint64_t len;
@@ -802,10 +802,9 @@ ctl_be_block_unmap_dev(struct ctl_be_blo
if (beio->io_offset == -1) {
beio->io_len = 0;
- memcpy(&ptrlen, io->io_hdr.ctl_private[CTL_PRIV_LBA_LEN].bytes,
- sizeof(ptrlen));
- buf = (struct scsi_unmap_desc *)ptrlen.ptr;
- end = buf + ptrlen.len / sizeof(*buf);
+ ptrlen = (struct ctl_ptr_len_flags *)&io->io_hdr.ctl_private[CTL_PRIV_LBA_LEN];
+ buf = (struct scsi_unmap_desc *)ptrlen->ptr;
+ end = buf + ptrlen->len / sizeof(*buf);
for (; buf < end; buf++) {
len = (uint64_t)scsi_4btoul(buf->length) *
be_lun->blocksize;
@@ -928,7 +927,7 @@ ctl_be_block_cw_dispatch_ws(struct ctl_b
{
struct ctl_be_block_io *beio;
struct ctl_be_block_softc *softc;
- struct ctl_lba_len_flags lbalen;
+ struct ctl_lba_len_flags *lbalen;
uint64_t len_left, lba;
int i, seglen;
uint8_t *buf, *end;
@@ -937,11 +936,10 @@ ctl_be_block_cw_dispatch_ws(struct ctl_b
beio = io->io_hdr.ctl_private[CTL_PRIV_BACKEND].ptr;
softc = be_lun->softc;
- memcpy(&lbalen, io->io_hdr.ctl_private[CTL_PRIV_LBA_LEN].bytes,
- sizeof(lbalen));
+ lbalen = (struct ctl_lba_len_flags *)&io->io_hdr.ctl_private[CTL_PRIV_LBA_LEN];
- if (lbalen.flags & ~(SWS_LBDATA | SWS_UNMAP) ||
- (lbalen.flags & SWS_UNMAP && be_lun->unmap == NULL)) {
+ if (lbalen->flags & ~(SWS_LBDATA | SWS_UNMAP) ||
+ (lbalen->flags & SWS_UNMAP && be_lun->unmap == NULL)) {
ctl_free_beio(beio);
ctl_set_invalid_field(&io->scsiio,
/*sks_valid*/ 1,
@@ -977,9 +975,9 @@ ctl_be_block_cw_dispatch_ws(struct ctl_b
break;
}
- if (lbalen.flags & SWS_UNMAP) {
- beio->io_offset = lbalen.lba * be_lun->blocksize;
- beio->io_len = (uint64_t)lbalen.len * be_lun->blocksize;
+ if (lbalen->flags & SWS_UNMAP) {
+ beio->io_offset = lbalen->lba * be_lun->blocksize;
+ beio->io_len = (uint64_t)lbalen->len * be_lun->blocksize;
beio->bio_cmd = BIO_DELETE;
beio->ds_trans_type = DEVSTAT_FREE;
@@ -991,9 +989,9 @@ ctl_be_block_cw_dispatch_ws(struct ctl_b
beio->ds_trans_type = DEVSTAT_WRITE;
DPRINTF("WRITE SAME at LBA %jx len %u\n",
- (uintmax_t)lbalen.lba, lbalen.len);
+ (uintmax_t)lbalen->lba, lbalen->len);
- len_left = (uint64_t)lbalen.len * be_lun->blocksize;
+ len_left = (uint64_t)lbalen->len * be_lun->blocksize;
for (i = 0, lba = 0; i < CTLBLK_MAX_SEGS && len_left > 0; i++) {
/*
@@ -1014,21 +1012,19 @@ ctl_be_block_cw_dispatch_ws(struct ctl_b
end = buf + seglen;
for (; buf < end; buf += be_lun->blocksize) {
memcpy(buf, io->scsiio.kern_data_ptr, be_lun->blocksize);
- if (lbalen.flags & SWS_LBDATA)
- scsi_ulto4b(lbalen.lba + lba, buf);
+ if (lbalen->flags & SWS_LBDATA)
+ scsi_ulto4b(lbalen->lba + lba, buf);
lba++;
}
}
- beio->io_offset = lbalen.lba * be_lun->blocksize;
+ beio->io_offset = lbalen->lba * be_lun->blocksize;
beio->io_len = lba * be_lun->blocksize;
/* We can not do all in one run. Correct and schedule rerun. */
if (len_left > 0) {
- lbalen.lba += lba;
- lbalen.len -= lba;
- memcpy(io->io_hdr.ctl_private[CTL_PRIV_LBA_LEN].bytes, &lbalen,
- sizeof(lbalen));
+ lbalen->lba += lba;
+ lbalen->len -= lba;
beio->beio_cont = ctl_be_block_cw_done_ws;
}
@@ -1041,16 +1037,15 @@ ctl_be_block_cw_dispatch_unmap(struct ct
{
struct ctl_be_block_io *beio;
struct ctl_be_block_softc *softc;
- struct ctl_ptr_len_flags ptrlen;
+ struct ctl_ptr_len_flags *ptrlen;
DPRINTF("entered\n");
beio = io->io_hdr.ctl_private[CTL_PRIV_BACKEND].ptr;
softc = be_lun->softc;
- memcpy(&ptrlen, io->io_hdr.ctl_private[CTL_PRIV_LBA_LEN].bytes,
- sizeof(ptrlen));
+ ptrlen = (struct ctl_ptr_len_flags *)&io->io_hdr.ctl_private[CTL_PRIV_LBA_LEN];
- if (ptrlen.flags != 0 || be_lun->unmap == NULL) {
+ if (ptrlen->flags != 0 || be_lun->unmap == NULL) {
ctl_free_beio(beio);
ctl_set_invalid_field(&io->scsiio,
/*sks_valid*/ 0,
@@ -1092,8 +1087,7 @@ ctl_be_block_cw_dispatch_unmap(struct ct
beio->bio_cmd = BIO_DELETE;
beio->ds_trans_type = DEVSTAT_FREE;
- DPRINTF("WRITE SAME at LBA %jx len %u\n",
- (uintmax_t)lbalen.lba, lbalen.len);
+ DPRINTF("UNMAP\n");
be_lun->unmap(be_lun, beio);
}
@@ -1188,7 +1182,7 @@ ctl_be_block_dispatch(struct ctl_be_bloc
{
struct ctl_be_block_io *beio;
struct ctl_be_block_softc *softc;
- struct ctl_lba_len lbalen;
+ struct ctl_lba_len *lbalen;
uint64_t len_left, lbaoff;
int i;
@@ -1248,14 +1242,13 @@ ctl_be_block_dispatch(struct ctl_be_bloc
beio->ds_trans_type = DEVSTAT_WRITE;
}
- memcpy(&lbalen, io->io_hdr.ctl_private[CTL_PRIV_LBA_LEN].bytes,
- sizeof(lbalen));
+ lbalen = (struct ctl_lba_len *)&io->io_hdr.ctl_private[CTL_PRIV_LBA_LEN];
DPRINTF("%s at LBA %jx len %u @%ju\n",
(beio->bio_cmd == BIO_READ) ? "READ" : "WRITE",
- (uintmax_t)lbalen.lba, lbalen.len, lbaoff);
+ (uintmax_t)lbalen->lba, lbalen->len, lbaoff);
lbaoff = io->scsiio.kern_rel_offset / be_lun->blocksize;
- beio->io_offset = (lbalen.lba + lbaoff) * be_lun->blocksize;
- beio->io_len = MIN((lbalen.len - lbaoff) * be_lun->blocksize,
+ beio->io_offset = (lbalen->lba + lbaoff) * be_lun->blocksize;
+ beio->io_len = MIN((lbalen->len - lbaoff) * be_lun->blocksize,
CTLBLK_MAX_IO_SIZE);
beio->io_len -= beio->io_len % be_lun->blocksize;
More information about the svn-src-stable
mailing list