summaryrefslogtreecommitdiffstats
path: root/sys/cam
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2017-02-25 01:53:45 +0000
committermav <mav@FreeBSD.org>2017-02-25 01:53:45 +0000
commit51c89b98e6d1180067ad03454d5303e098ca812e (patch)
treefae51ea1243c9326d6517f0161564f3a06c3f6d4 /sys/cam
parente13dc0131627347529a3e93e6da9f0ab619d080c (diff)
downloadFreeBSD-src-51c89b98e6d1180067ad03454d5303e098ca812e.zip
FreeBSD-src-51c89b98e6d1180067ad03454d5303e098ca812e.tar.gz
MFC r313910: Change XCOPY memory allocations.
Before this change XCOPY code could allocate memory in chunks up to 16-32MB (VMware does XCOPY in 4MB chunks by default), that could be difficult for VM subsystem to do due to KVA fragmentation, that sometimes created huge allocation delays, blocking any I/O for respective LU for that time. This change limits allocations down to TPC_MAX_IO_SIZE, which is 1MB now. 1MB is also not a cookie, but ZFS also can do that for large blocks, so it should be less dramatic. As drawback this increases CPU overhead, but it still look acceptable comparing to time consumed by ZFS read/write.
Diffstat (limited to 'sys/cam')
-rw-r--r--sys/cam/ctl/ctl_tpc.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/sys/cam/ctl/ctl_tpc.c b/sys/cam/ctl/ctl_tpc.c
index c8d60ca..39d4f24 100644
--- a/sys/cam/ctl/ctl_tpc.c
+++ b/sys/cam/ctl/ctl_tpc.c
@@ -85,6 +85,7 @@ struct tpc_io {
uint8_t target;
uint32_t cscd;
uint64_t lun;
+ uint8_t *buf;
struct tpc_list *list;
struct runl run;
TAILQ_ENTRY(tpc_io) rlinks;
@@ -127,7 +128,6 @@ struct tpc_list {
off_t curbytes;
int curops;
int stage;
- uint8_t *buf;
off_t segsectors;
off_t segbytes;
int tbdio;
@@ -813,9 +813,9 @@ tpc_process_b2b(struct tpc_list *list)
while ((tior = TAILQ_FIRST(&list->allio)) != NULL) {
TAILQ_REMOVE(&list->allio, tior, links);
ctl_free_io(tior->io);
+ free(tior->buf, M_CTL);
free(tior, M_CTL);
}
- free(list->buf, M_CTL);
if (list->abort) {
ctl_set_task_aborted(list->ctsio);
return (CTL_RETVAL_ERROR);
@@ -874,7 +874,6 @@ tpc_process_b2b(struct tpc_list *list)
return (CTL_RETVAL_ERROR);
}
- list->buf = malloc(numbytes, M_CTL, M_WAITOK);
list->segbytes = numbytes;
list->segsectors = numbytes / dstblock;
donebytes = 0;
@@ -894,11 +893,12 @@ tpc_process_b2b(struct tpc_list *list)
tior = malloc(sizeof(*tior), M_CTL, M_WAITOK | M_ZERO);
TAILQ_INIT(&tior->run);
+ tior->buf = malloc(roundbytes, M_CTL, M_WAITOK);
tior->list = list;
TAILQ_INSERT_TAIL(&list->allio, tior, links);
tior->io = tpcl_alloc_io();
ctl_scsi_read_write(tior->io,
- /*data_ptr*/ &list->buf[donebytes],
+ /*data_ptr*/ tior->buf,
/*data_len*/ roundbytes,
/*read_op*/ 1,
/*byte2*/ 0,
@@ -919,7 +919,7 @@ tpc_process_b2b(struct tpc_list *list)
TAILQ_INSERT_TAIL(&list->allio, tiow, links);
tiow->io = tpcl_alloc_io();
ctl_scsi_read_write(tiow->io,
- /*data_ptr*/ &list->buf[donebytes],
+ /*data_ptr*/ tior->buf,
/*data_len*/ roundbytes,
/*read_op*/ 0,
/*byte2*/ 0,
@@ -1029,9 +1029,9 @@ tpc_process_register_key(struct tpc_list *list)
while ((tio = TAILQ_FIRST(&list->allio)) != NULL) {
TAILQ_REMOVE(&list->allio, tio, links);
ctl_free_io(tio->io);
+ free(tio->buf, M_CTL);
free(tio, M_CTL);
}
- free(list->buf, M_CTL);
if (list->abort) {
ctl_set_task_aborted(list->ctsio);
return (CTL_RETVAL_ERROR);
@@ -1064,9 +1064,9 @@ tpc_process_register_key(struct tpc_list *list)
TAILQ_INSERT_TAIL(&list->allio, tio, links);
tio->io = tpcl_alloc_io();
datalen = sizeof(struct scsi_per_res_out_parms);
- list->buf = malloc(datalen, M_CTL, M_WAITOK);
+ tio->buf = malloc(datalen, M_CTL, M_WAITOK);
ctl_scsi_persistent_res_out(tio->io,
- list->buf, datalen, SPRO_REGISTER, -1,
+ tio->buf, datalen, SPRO_REGISTER, -1,
scsi_8btou64(seg->res_key), scsi_8btou64(seg->sa_res_key),
/*tag_type*/ CTL_TAG_SIMPLE, /*control*/ 0);
tio->io->io_hdr.retries = 3;
@@ -1166,9 +1166,9 @@ tpc_process_wut(struct tpc_list *list)
while ((tio = TAILQ_FIRST(&list->allio)) != NULL) {
TAILQ_REMOVE(&list->allio, tio, links);
ctl_free_io(tio->io);
+ free(tio->buf, M_CTL);
free(tio, M_CTL);
}
- free(list->buf, M_CTL);
if (list->abort) {
ctl_set_task_aborted(list->ctsio);
return (CTL_RETVAL_ERROR);
@@ -1233,8 +1233,6 @@ tpc_process_wut(struct tpc_list *list)
return (CTL_RETVAL_ERROR);
}
- list->buf = malloc(numbytes, M_CTL, M_WAITOK |
- (list->token == NULL ? M_ZERO : 0));
list->segbytes = numbytes;
list->segsectors = numbytes / dstblock;
//printf("Copy chunk of %ju sectors from %ju to %ju\n", list->segsectors,
@@ -1257,11 +1255,12 @@ tpc_process_wut(struct tpc_list *list)
tior = malloc(sizeof(*tior), M_CTL, M_WAITOK | M_ZERO);
TAILQ_INIT(&tior->run);
+ tior->buf = malloc(roundbytes, M_CTL, M_WAITOK);
tior->list = list;
TAILQ_INSERT_TAIL(&list->allio, tior, links);
tior->io = tpcl_alloc_io();
ctl_scsi_read_write(tior->io,
- /*data_ptr*/ &list->buf[donebytes],
+ /*data_ptr*/ tior->buf,
/*data_len*/ roundbytes,
/*read_op*/ 1,
/*byte2*/ 0,
@@ -1280,7 +1279,7 @@ tpc_process_wut(struct tpc_list *list)
TAILQ_INSERT_TAIL(&list->allio, tiow, links);
tiow->io = tpcl_alloc_io();
ctl_scsi_read_write(tiow->io,
- /*data_ptr*/ &list->buf[donebytes],
+ /*data_ptr*/ tior->buf,
/*data_len*/ roundbytes,
/*read_op*/ 0,
/*byte2*/ 0,
OpenPOWER on IntegriCloud