From a69bdf412268f8baf777d8eeac3ffbff9352e57e Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Fri, 28 Apr 2017 22:46:35 +0200 Subject: [PATCH 312/325] ggate: Increase maximum BIO length to 1MB This is required for ggatec/ggated to work with ZFS pools with recordsize=1m. XXX: Incrementing the zeros buffer shouldn't be necessary and is unlikely to speed up the trimming. Obtained from: ElectroBSD --- sbin/ggate/ggatec/ggatec.c | 6 +++--- sbin/ggate/ggated/ggated.c | 17 ++++++++++------- sbin/ggate/shared/ggate.h | 2 ++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/sbin/ggate/ggatec/ggatec.c b/sbin/ggate/ggatec/ggatec.c index ee719aabf17c..37f03f4423ec 100644 --- a/sbin/ggate/ggatec/ggatec.c +++ b/sbin/ggate/ggatec/ggatec.c @@ -102,7 +102,7 @@ send_thread(void *arg __unused) { struct g_gate_ctl_io ggio; struct g_gate_hdr hdr; - char buf[MAXPHYS]; + char buf[GGATE_MAX_BIO_LENGTH]; ssize_t data; int error; @@ -170,7 +170,7 @@ send_thread(void *arg __unused) } /* Don't send requests for more data than we can handle the response for! */ - if (ggio.gctl_length > MAXPHYS) { + if (ggio.gctl_length > GGATE_MAX_BIO_LENGTH) { g_gate_log(LOG_ERR, "Request too big: %zd", ggio.gctl_length); ggio.gctl_error = EOPNOTSUPP; g_gate_ioctl(G_GATE_CMD_DONE, &ggio); @@ -222,7 +222,7 @@ recv_thread(void *arg __unused) { struct g_gate_ctl_io ggio; struct g_gate_hdr hdr; - char buf[MAXPHYS]; + char buf[GGATE_MAX_BIO_LENGTH]; ssize_t data; g_gate_log(LOG_NOTICE, "%s: started!", __func__); diff --git a/sbin/ggate/ggated/ggated.c b/sbin/ggate/ggated/ggated.c index 82df8a8aa391..132998bab152 100644 --- a/sbin/ggate/ggated/ggated.c +++ b/sbin/ggate/ggated/ggated.c @@ -707,12 +707,14 @@ recv_thread(void *arg) /* * Limit the amount of memory we allocate on behalf of - * the client. MAXPHYS is the hard limit in ggatec, - * values above it are thus pretty suspicious. + * the client. GGATE_MAX_BIO_LENGTH is the hard limit in + * ggatec, values above it are thus pretty suspicious. */ - if (req->r_length > MAXPHYS && req->r_cmd != GGATE_CMD_DELETE) { - g_gate_xlog("Request length above MAXPHYS: %u > %u", - (unsigned)req->r_length, MAXPHYS); + if (req->r_length > GGATE_MAX_BIO_LENGTH && + req->r_cmd != GGATE_CMD_DELETE) { + g_gate_xlog("Request length above " + "GGATE_MAX_BIO_LENGTH: %u > %u", + (unsigned)req->r_length, GGATE_MAX_BIO_LENGTH); } /* @@ -749,7 +751,7 @@ recv_thread(void *arg) static ssize_t delete_range(int fd, size_t length, off_t offset) { - static char zeros[MAXPHYS]; + static char zeros[GGATE_MAX_BIO_LENGTH]; size_t written; written = 0; @@ -761,7 +763,8 @@ delete_range(int fd, size_t length, off_t offset) size_t chunk_size; bytes_left = length - written; - chunk_size = bytes_left > MAXPHYS ? MAXPHYS : bytes_left; + chunk_size = bytes_left > sizeof(zeros) ? + sizeof(zeros) : bytes_left; ret = pwrite(fd, zeros, chunk_size, offset + written); if (ret == -1) return (written); diff --git a/sbin/ggate/shared/ggate.h b/sbin/ggate/shared/ggate.h index 5d3a9bd6025b..bb6ddc4ac8f8 100644 --- a/sbin/ggate/shared/ggate.h +++ b/sbin/ggate/shared/ggate.h @@ -60,6 +60,8 @@ #define GGATE_CMD_FLUSH 2 #define GGATE_CMD_DELETE 3 +#define GGATE_MAX_BIO_LENGTH 1048576 + extern int g_gate_devfd; extern int g_gate_verbose; -- 2.32.0