aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/ctl/ctl_tpc.c
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2017-02-18 06:03:16 +0000
committerAlexander Motin <mav@FreeBSD.org>2017-02-18 06:03:16 +0000
commit46511441fb85ac756388f25bb627ea956c11df92 (patch)
treeaaed2bedd0addbcde138bae14b1d3f2f5a55d968 /sys/cam/ctl/ctl_tpc.c
parent8e31b510b050a60e0efc2cf0f63e08cfd9263ac4 (diff)
downloadsrc-46511441fb85ac756388f25bb627ea956c11df92.tar.gz
src-46511441fb85ac756388f25bb627ea956c11df92.zip
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. MFC after: 1 week
Notes
Notes: svn path=/head/; revision=313910
Diffstat (limited to 'sys/cam/ctl/ctl_tpc.c')
-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 c8d60cad0194..39d4f2440af9 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,