From d5a0114b8e81d299022a5c017cdf51389113b35e Mon Sep 17 00:00:00 2001 From: pjd Date: Fri, 29 Jul 2005 11:22:13 +0000 Subject: [PATCH 01/20] Update manual page after ggate rewrite. MFC after: 1 day --- ggatec/ggatec.8 | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ggatec/ggatec.8 b/ggatec/ggatec.8 index dd7d7cc..9f6bc00 100644 --- a/ggatec/ggatec.8 +++ b/ggatec/ggatec.8 @@ -46,7 +46,7 @@ .Ar host .Ar path .Nm -.Cm attach +.Cm rescue .Op Fl n .Op Fl v .Op Fl o Cm ro | wo | rw @@ -83,12 +83,11 @@ Connect to given daemon and create a .Nm ggate provider related to the given remote file or device. -.It Cm attach -Attach a worker process to an existing -.Nm ggate -provider (create a new connection to the +.It Cm rescue +If ggatec process died/has been killed, you can save situation with this +command, which creates new connection to the .Xr ggated 8 -daemon). +daemon and will handle pending and future requests. .It Cm destroy Destroy the given .Nm ggate @@ -139,7 +138,7 @@ If not specified, it is taken from device, or set to 512 bytes for files. .It Fl t Ar timeout Number of seconds to wait before an I/O request will be canceled. 0 means no timeout. -Default is 30. +Default is 0. .It Fl u Ar unit Unit number to use. .It Fl v From 7edf8f85ad6f0bbfd7e21792e471e3ddecf14755 Mon Sep 17 00:00:00 2001 From: ru Date: Fri, 18 Nov 2005 10:36:29 +0000 Subject: [PATCH 02/20] -mdoc sweep. --- ggatec/ggatec.8 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ggatec/ggatec.8 b/ggatec/ggatec.8 index 9f6bc00..a88e0cb 100644 --- a/ggatec/ggatec.8 +++ b/ggatec/ggatec.8 @@ -84,7 +84,9 @@ daemon and create a .Nm ggate provider related to the given remote file or device. .It Cm rescue -If ggatec process died/has been killed, you can save situation with this +If +.Nm +process died/has been killed, you can save situation with this command, which creates new connection to the .Xr ggated 8 daemon and will handle pending and future requests. From 954d6c9c0c8ca9e49703fb429ee210e29f777ee0 Mon Sep 17 00:00:00 2001 From: pjd Date: Sun, 12 Mar 2006 09:27:51 +0000 Subject: [PATCH 03/20] Flush stdout after printing name of created device, so it can be properly read when 'ggatec create' is used in backticks or its output is piped to another command. Submitted by: Paul Schenkeveld MFC after: 3 days --- ggatec/ggatec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ggatec/ggatec.c b/ggatec/ggatec.c index 70f667d..e421614 100644 --- a/ggatec/ggatec.c +++ b/ggatec/ggatec.c @@ -457,8 +457,10 @@ g_gatec_create(void) snprintf(ggioc.gctl_info, sizeof(ggioc.gctl_info), "%s:%u %s", host, port, path); g_gate_ioctl(G_GATE_CMD_CREATE, &ggioc); - if (unit == -1) + if (unit == -1) { printf("%s%u\n", G_GATE_PROVIDER_NAME, ggioc.gctl_unit); + fflush(stdout); + } unit = ggioc.gctl_unit; mydaemon(); From dc87143160a19af9832bcf4263c96f8872ba6172 Mon Sep 17 00:00:00 2001 From: ru Date: Fri, 17 Mar 2006 18:54:44 +0000 Subject: [PATCH 04/20] Reimplementation of world/kernel build options. For details, see: http://lists.freebsd.org/pipermail/freebsd-current/2006-March/061725.html The src.conf(5) manpage is to follow in a few days. Brought to you by: imp, jhb, kris, phk, ru (all bugs are mine) --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 97094d6..03ef1ba 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,12 @@ # $FreeBSD$ +.include + SUBDIR= ${_ggatec} \ ${_ggated} \ ggatel -.if !defined(NO_LIBPTHREAD) +.if ${MK_LIBPTHREAD} != "no" _ggatec= ggatec _ggated= ggated .endif From 02aa198c5ed57eeeb04c68a644b4e46d7aef6ef4 Mon Sep 17 00:00:00 2001 From: ru Date: Tue, 21 Mar 2006 11:00:54 +0000 Subject: [PATCH 05/20] Unbreak WITHOUT_LIBPHREAD/WITHOUT_LIBC_R option support, depending on platform. --- Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 03ef1ba..4dd5141 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,12 @@ SUBDIR= ${_ggatec} \ ${_ggated} \ ggatel -.if ${MK_LIBPTHREAD} != "no" +.if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "sparc64" +.if ${MK_LIBC_R} != "no" +_ggatec= ggatec +_ggated= ggated +.endif +.elif ${MK_LIBPTHREAD} != "no" _ggatec= ggatec _ggated= ggated .endif From 699bc8886ce026feef89f71de5cf70ae57bb57b4 Mon Sep 17 00:00:00 2001 From: ru Date: Wed, 12 Apr 2006 19:52:34 +0000 Subject: [PATCH 06/20] libc_r is no longer provided, and on alpha and sparc64, libthr is (sym)linked to libpthread. Account for this change and check for MK_LIBTHR instead of MK_LIBC_R where appropriate. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4dd5141..a089bf3 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ SUBDIR= ${_ggatec} \ ggatel .if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "sparc64" -.if ${MK_LIBC_R} != "no" +.if ${MK_LIBTHR} != "no" _ggatec= ggatec _ggated= ggated .endif From 730d0e1f1001cea8c06a028538d94d19855dc0fd Mon Sep 17 00:00:00 2001 From: trhodes Date: Sat, 10 Jun 2006 09:45:26 +0000 Subject: [PATCH 07/20] Fix a typo s/Made/Make. Use .Pp for a line break, it will quiet the mdoc(7) warning. --- ggatec/ggatec.8 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ggatec/ggatec.8 b/ggatec/ggatec.8 index a88e0cb..195f0b7 100644 --- a/ggatec/ggatec.8 +++ b/ggatec/ggatec.8 @@ -159,12 +159,12 @@ should be called with the .Fl v option. .Sh EXAMPLES -Made use of CD-ROM device from remote host. +Make use of CD-ROM device from remote host. .Bd -literal -offset indent server# cat /etc/gg.exports client RO /dev/acd0 server# ggated - +.Pp client# ggatec create -o ro server /dev/acd0 ggate0 client# mount_cd9660 /dev/ggate0 /cdrom From 84428198ee136960d043a84cbd39c0bcd66ad42a Mon Sep 17 00:00:00 2001 From: ru Date: Tue, 22 Aug 2006 08:03:01 +0000 Subject: [PATCH 08/20] Remove alpha left-overs. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a089bf3..73a8016 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ SUBDIR= ${_ggatec} \ ${_ggated} \ ggatel -.if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "sparc64" +.if ${MACHINE_ARCH} == "sparc64" .if ${MK_LIBTHR} != "no" _ggatec= ggatec _ggated= ggated From c3391f008afa2220bf646e1eceb8fbd82f9a89e7 Mon Sep 17 00:00:00 2001 From: ru Date: Mon, 18 Sep 2006 11:55:10 +0000 Subject: [PATCH 09/20] Markup fixes. --- ggatec/ggatec.8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ggatec/ggatec.8 b/ggatec/ggatec.8 index 195f0b7..09f0444 100644 --- a/ggatec/ggatec.8 +++ b/ggatec/ggatec.8 @@ -164,7 +164,7 @@ Make use of CD-ROM device from remote host. server# cat /etc/gg.exports client RO /dev/acd0 server# ggated -.Pp + client# ggatec create -o ro server /dev/acd0 ggate0 client# mount_cd9660 /dev/ggate0 /cdrom From 186e33abdcad74fc836ab9b71fd1687c73d0267f Mon Sep 17 00:00:00 2001 From: pjd Date: Mon, 30 Oct 2006 18:29:24 +0000 Subject: [PATCH 10/20] - Handle timeouts from recv(2) properly. - Increase timeout to 8 seconds (should be made configurable). Reported by: Ulrich Spoerlein Reported by: Christian Laursen PR: kern/104829 MFC after: 1 week --- shared/ggate.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/shared/ggate.c b/shared/ggate.c index c8428a6..5101092 100644 --- a/shared/ggate.c +++ b/shared/ggate.c @@ -250,8 +250,12 @@ g_gate_send(int s, const void *buf, size_t len, int flags) ssize_t g_gate_recv(int s, void *buf, size_t len, int flags) { + ssize_t done; - return (recv(s, buf, len, flags)); + do { + done = recv(s, buf, len, flags); + } while (done == -1 && errno == EAGAIN); + return (done); } int nagle = 1; @@ -280,7 +284,7 @@ g_gate_socket_settings(int sfd) bsize = sndbuf; if (setsockopt(sfd, SOL_SOCKET, SO_SNDBUF, &bsize, sizeof(bsize)) == -1) g_gate_xlog("setsockopt(SO_SNDBUF): %s.", strerror(errno)); - tv.tv_sec = 1; + tv.tv_sec = 8; tv.tv_usec = 0; if (setsockopt(sfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) == -1) { g_gate_log(LOG_ERR, "setsockopt(SO_SNDTIMEO) error: %s.", From 52e33d5e83bfc698c593ed846d226eb2881aff1e Mon Sep 17 00:00:00 2001 From: ru Date: Sun, 26 Nov 2006 14:36:34 +0000 Subject: [PATCH 11/20] - When building world WITHOUT_LIBPTHREAD, link libthr to libpthread. - Don't build ngctl(8) and cached(8) if threading libs aren't built. - Fix various issues in a cached(8) makefile. --- Makefile | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 73a8016..989589f 100644 --- a/Makefile +++ b/Makefile @@ -6,12 +6,8 @@ SUBDIR= ${_ggatec} \ ${_ggated} \ ggatel -.if ${MACHINE_ARCH} == "sparc64" -.if ${MK_LIBTHR} != "no" -_ggatec= ggatec -_ggated= ggated -.endif -.elif ${MK_LIBPTHREAD} != "no" +.if ${MK_LIBTHR} != "no" || \ + (${MACHINE_ARCH} != "sparc64" && ${MK_LIBPTHREAD} != "no") _ggatec= ggatec _ggated= ggated .endif From 45d7602d9061d452c2723f5f2af5cd6dedce2e20 Mon Sep 17 00:00:00 2001 From: pjd Date: Fri, 15 Dec 2006 18:16:47 +0000 Subject: [PATCH 12/20] Fix ggated for platforms with 64bit size_t. The DIOCGSECTORSIZE ioctl returns u_int. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported by: Javier Martín Rueda PR: amd64/91799 MFC after: 3 days --- ggated/ggated.c | 2 +- shared/ggate.c | 4 ++-- shared/ggate.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ggated/ggated.c b/ggated/ggated.c index 82d66e1..b0dd2d2 100644 --- a/ggated/ggated.c +++ b/ggated/ggated.c @@ -60,7 +60,7 @@ struct ggd_connection { off_t c_mediasize; - off_t c_sectorsize; + u_int c_sectorsize; unsigned c_flags; /* flags (RO/RW) */ int c_diskfd; int c_sendfd; diff --git a/shared/ggate.c b/shared/ggate.c index 5101092..ff72a27 100644 --- a/shared/ggate.c +++ b/shared/ggate.c @@ -149,10 +149,10 @@ g_gate_mediasize(int fd) return (mediasize); } -size_t +u_int g_gate_sectorsize(int fd) { - size_t secsize; + u_int secsize; struct stat sb; if (fstat(fd, &sb) == -1) diff --git a/shared/ggate.h b/shared/ggate.h index acbdaaa..9a81b0f 100644 --- a/shared/ggate.h +++ b/shared/ggate.h @@ -98,7 +98,7 @@ void g_gate_log(int priority, const char *message, ...); void g_gate_xvlog(const char *message, va_list ap); void g_gate_xlog(const char *message, ...); off_t g_gate_mediasize(int fd); -size_t g_gate_sectorsize(int fd); +u_int g_gate_sectorsize(int fd); void g_gate_open_device(void); void g_gate_close_device(void); void g_gate_ioctl(unsigned long req, void *data); From b31e210ebab7053a09a0682008d0ba1f3713fff8 Mon Sep 17 00:00:00 2001 From: pjd Date: Mon, 18 Dec 2006 11:12:00 +0000 Subject: [PATCH 13/20] For consistency use 'unsigned' instead of 'u_int'. --- ggated/ggated.c | 2 +- shared/ggate.c | 4 ++-- shared/ggate.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ggated/ggated.c b/ggated/ggated.c index b0dd2d2..b211ccc 100644 --- a/ggated/ggated.c +++ b/ggated/ggated.c @@ -60,7 +60,7 @@ struct ggd_connection { off_t c_mediasize; - u_int c_sectorsize; + unsigned c_sectorsize; unsigned c_flags; /* flags (RO/RW) */ int c_diskfd; int c_sendfd; diff --git a/shared/ggate.c b/shared/ggate.c index ff72a27..09e35d3 100644 --- a/shared/ggate.c +++ b/shared/ggate.c @@ -149,10 +149,10 @@ g_gate_mediasize(int fd) return (mediasize); } -u_int +unsigned g_gate_sectorsize(int fd) { - u_int secsize; + unsigned secsize; struct stat sb; if (fstat(fd, &sb) == -1) diff --git a/shared/ggate.h b/shared/ggate.h index 9a81b0f..3e26253 100644 --- a/shared/ggate.h +++ b/shared/ggate.h @@ -98,7 +98,7 @@ void g_gate_log(int priority, const char *message, ...); void g_gate_xvlog(const char *message, va_list ap); void g_gate_xlog(const char *message, ...); off_t g_gate_mediasize(int fd); -u_int g_gate_sectorsize(int fd); +unsigned g_gate_sectorsize(int fd); void g_gate_open_device(void); void g_gate_close_device(void); void g_gate_ioctl(unsigned long req, void *data); From 74db3a0a0deb9ff3f319466f3f0c9b7f5a107635 Mon Sep 17 00:00:00 2001 From: pjd Date: Fri, 6 Apr 2007 11:19:48 +0000 Subject: [PATCH 14/20] Implement a work-around for poor ggate write performance. --- ggatec/Makefile | 1 + shared/ggate.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ggatec/Makefile b/ggatec/Makefile index c49cfe8..4d8917f 100644 --- a/ggatec/Makefile +++ b/ggatec/Makefile @@ -6,6 +6,7 @@ PROG= ggatec MAN= ggatec.8 SRCS= ggatec.c ggate.c +CFLAGS+= -DMAX_SEND_SIZE=32768 CFLAGS+= -DLIBGEOM CFLAGS+= -I${.CURDIR}/../shared diff --git a/shared/ggate.c b/shared/ggate.c index 09e35d3..dd40790 100644 --- a/shared/ggate.c +++ b/shared/ggate.c @@ -222,6 +222,16 @@ g_gate_load_module(void) } } +/* + * When we send from ggatec packets larger than 32kB, performance drops + * significantly (eg. to 256kB/s over 1Gbit/s link). This is not a problem + * when data is send from ggated. I don't know why, so for now I limit + * size of packets send from ggatec to 32kB by defining MAX_SEND_SIZE + * in ggatec Makefile. + */ +#ifndef MAX_SEND_SIZE +#define MAX_SEND_SIZE MAXPHYS +#endif ssize_t g_gate_send(int s, const void *buf, size_t len, int flags) { @@ -229,7 +239,7 @@ g_gate_send(int s, const void *buf, size_t len, int flags) const unsigned char *p = buf; while (len > 0) { - done2 = send(s, p, len, flags); + done2 = send(s, p, MIN(len, MAX_SEND_SIZE), flags); if (done2 == 0) break; else if (done2 == -1) { From f12b1824a7856e1ee274121e11eb4236e11f00a1 Mon Sep 17 00:00:00 2001 From: ru Date: Mon, 1 Oct 2007 18:22:32 +0000 Subject: [PATCH 15/20] Always install libpthread.* symlinks if at least one of the threading libraries is built. This simplifies the logic in makefiles that need to check if the pthreads support is present. It also fixes a bug where we would build a threading library that we shouldn't have built: for example, building with WITHOUT_LIBTHR and the default value of DEFAULT_THREADING_LIB (libthr) would mistakenly build the libthr library, but not install it. Approved by: re (kensmith) --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 989589f..7ab5ccb 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,7 @@ SUBDIR= ${_ggatec} \ ${_ggated} \ ggatel -.if ${MK_LIBTHR} != "no" || \ - (${MACHINE_ARCH} != "sparc64" && ${MK_LIBPTHREAD} != "no") +.if ${MK_LIBTHR} != "no" || ${MK_LIBPTHREAD} != "no" _ggatec= ggatec _ggated= ggated .endif From baa2e1e0e90429804fdc6b9a0b2be82b4a79a9e2 Mon Sep 17 00:00:00 2001 From: obrien Date: Tue, 9 Oct 2007 13:42:34 +0000 Subject: [PATCH 16/20] Repo copy libpthreads to libkse. This introduces the WITHOUT_LIBKSE nob, and changes WITHOUT_LIBPTHREADS to mean with neither threading libs. Approved by: re(kensmith) --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7ab5ccb..e889f2f 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ SUBDIR= ${_ggatec} \ ${_ggated} \ ggatel -.if ${MK_LIBTHR} != "no" || ${MK_LIBPTHREAD} != "no" +.if ${MK_LIBPTHREAD} != "no" && (${MK_LIBTHR} != "no" || ${MK_LIBKSE} != "no") _ggatec= ggatec _ggated= ggated .endif From ff12a9e0c997d74271c1b54c0b1837ef77f8782d Mon Sep 17 00:00:00 2001 From: obrien Date: Tue, 9 Oct 2007 23:31:11 +0000 Subject: [PATCH 17/20] Tweak the handling of "WITHOUT_LIBPTHREAD". Also remove the accidental treatment of 'LIBKSE' as an "old style" knob. Submitted by: ru Approved by: re(kensmith) --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e889f2f..38ca2f2 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ SUBDIR= ${_ggatec} \ ${_ggated} \ ggatel -.if ${MK_LIBPTHREAD} != "no" && (${MK_LIBTHR} != "no" || ${MK_LIBKSE} != "no") +.if ${MK_LIBTHR} != "no" || ${MK_LIBKSE} != "no" _ggatec= ggatec _ggated= ggated .endif From 8075905bc86fa242071128d0d2d7a582cc7c4907 Mon Sep 17 00:00:00 2001 From: ru Date: Sat, 29 Mar 2008 17:44:40 +0000 Subject: [PATCH 18/20] Remove options MK_LIBKSE and DEFAULT_THREAD_LIB now that we no longer build libkse. This should fix WITHOUT_LIBTHR builds as a side effect. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 38ca2f2..8f889f1 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ SUBDIR= ${_ggatec} \ ${_ggated} \ ggatel -.if ${MK_LIBTHR} != "no" || ${MK_LIBKSE} != "no" +.if ${MK_LIBTHR} != "no" _ggatec= ggatec _ggated= ggated .endif From a87d6e404d765e5106c3a956125bd34adc9d42c3 Mon Sep 17 00:00:00 2001 From: gonzo Date: Fri, 20 Jun 2008 21:41:44 +0000 Subject: [PATCH 19/20] Fix spelling PR: kern/124723 Event: Bugathon#5 --- ggated/ggated.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ggated/ggated.c b/ggated/ggated.c index b211ccc..74784e7 100644 --- a/ggated/ggated.c +++ b/ggated/ggated.c @@ -211,10 +211,10 @@ line_parse(char *line, unsigned lineno) ex = malloc(sizeof(*ex)); if (ex == NULL) - g_gate_xlog("No enough memory."); + g_gate_xlog("Not enough memory."); ex->e_path = strdup(path); if (ex->e_path == NULL) - g_gate_xlog("No enough memory."); + g_gate_xlog("Not enough memory."); /* Made 'and' here. */ ex->e_ip = (ip & mask); From b93805e89673bf86eefe81dc1b59b54312385c2e Mon Sep 17 00:00:00 2001 From: mtm Date: Thu, 26 Jun 2008 07:05:35 +0000 Subject: [PATCH 20/20] The signature for a pthread function requires that it return a pointer to a void. The send_thread() and disk_thread() funtions; however, do not have a return value because they run for the duration of the daemon's lifetime. This causes gcc to barf when running with -O3. Make these functions return a null pointer to quiet it. PR: bin/124342 Submitted by: Garrett Cooper (minus his comments) MFC after: 1 week --- ggated/ggated.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ggated/ggated.c b/ggated/ggated.c index 74784e7..52d2428 100644 --- a/ggated/ggated.c +++ b/ggated/ggated.c @@ -756,6 +756,9 @@ disk_thread(void *arg) error = pthread_mutex_unlock(&outqueue_mtx); assert(error == 0); } + + /* NOTREACHED */ + return (NULL); } static void * @@ -810,6 +813,9 @@ send_thread(void *arg) } free(req); } + + /* NOTREACHED */ + return (NULL); } static void