svn commit: r222120 - head/sbin/hastd
Author: pjd Date: Fri May 20 11:16:25 2011 New Revision: 222120 URL: http://svn.freebsd.org/changeset/base/222120 Log: If no listen address is specified, bind by default to: tcp4://0.0.0.0:8457 tcp6://[::]:8457 MFC after:3 weeks Modified: head/sbin/hastd/parse.y Modified: head/sbin/hastd/parse.y == --- head/sbin/hastd/parse.y Fri May 20 11:15:27 2011(r222119) +++ head/sbin/hastd/parse.y Fri May 20 11:16:25 2011(r222120) @@ -257,7 +257,6 @@ yy_config_parse(const char *config, bool pjdlog_debug(1, "No IPv4 support in the kernel, not listening on IPv4 address."); } -#ifdef notyet if (family_supported(AF_INET6)) { lst = calloc(1, sizeof(*lst)); if (lst == NULL) { @@ -274,7 +273,6 @@ yy_config_parse(const char *config, bool pjdlog_debug(1, "No IPv6 support in the kernel, not listening on IPv6 address."); } -#endif if (TAILQ_EMPTY(&lconfig->hc_listen)) { pjdlog_error("No address to listen on."); yy_config_free(lconfig); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r222119 - head/sbin/hastd
Author: pjd Date: Fri May 20 11:15:27 2011 New Revision: 222119 URL: http://svn.freebsd.org/changeset/base/222119 Log: Rename ipv4/ipv6 to tcp4/tcp6. MFC after:3 weeks Modified: head/sbin/hastd/hast.h head/sbin/hastd/parse.y Modified: head/sbin/hastd/hast.h == --- head/sbin/hastd/hast.h Fri May 20 11:14:05 2011(r222118) +++ head/sbin/hastd/hast.h Fri May 20 11:15:27 2011(r222119) @@ -86,8 +86,8 @@ #defineHAST_TIMEOUT20 #defineHAST_CONFIG "/etc/hast.conf" #defineHAST_CONTROL"/var/run/hastctl" -#defineHASTD_LISTEN_IPV4 "tcp4://0.0.0.0:8457" -#defineHASTD_LISTEN_IPV6 "tcp6://[::]:8457" +#defineHASTD_LISTEN_TCP4 "tcp4://0.0.0.0:8457" +#defineHASTD_LISTEN_TCP6 "tcp6://[::]:8457" #defineHASTD_PIDFILE "/var/run/hastd.pid" /* Default extent size. */ Modified: head/sbin/hastd/parse.y == --- head/sbin/hastd/parse.y Fri May 20 11:14:05 2011(r222118) +++ head/sbin/hastd/parse.y Fri May 20 11:15:27 2011(r222119) @@ -61,8 +61,8 @@ static struct hast_resource *curres; static bool mynode, hadmynode; static char depth0_control[HAST_ADDRSIZE]; -static char depth0_listen_ipv4[HAST_ADDRSIZE]; -static char depth0_listen_ipv6[HAST_ADDRSIZE]; +static char depth0_listen_tcp4[HAST_ADDRSIZE]; +static char depth0_listen_tcp6[HAST_ADDRSIZE]; static TAILQ_HEAD(, hastd_listen) depth0_listen; static int depth0_replication; static int depth0_checksum; @@ -193,10 +193,10 @@ yy_config_parse(const char *config, bool depth0_compression = HAST_COMPRESSION_HOLE; strlcpy(depth0_control, HAST_CONTROL, sizeof(depth0_control)); TAILQ_INIT(&depth0_listen); - strlcpy(depth0_listen_ipv4, HASTD_LISTEN_IPV4, - sizeof(depth0_listen_ipv4)); - strlcpy(depth0_listen_ipv6, HASTD_LISTEN_IPV6, - sizeof(depth0_listen_ipv6)); + strlcpy(depth0_listen_tcp4, HASTD_LISTEN_TCP4, + sizeof(depth0_listen_tcp4)); + strlcpy(depth0_listen_tcp6, HASTD_LISTEN_TCP6, + sizeof(depth0_listen_tcp6)); depth0_exec[0] = '\0'; lconfig = calloc(1, sizeof(*lconfig)); @@ -250,7 +250,7 @@ yy_config_parse(const char *config, bool exit(EX_TEMPFAIL); return (NULL); } - (void)strlcpy(lst->hl_addr, depth0_listen_ipv4, + (void)strlcpy(lst->hl_addr, depth0_listen_tcp4, sizeof(lst->hl_addr)); TAILQ_INSERT_TAIL(&lconfig->hc_listen, lst, hl_next); } else { @@ -267,7 +267,7 @@ yy_config_parse(const char *config, bool exit(EX_TEMPFAIL); return (NULL); } - (void)strlcpy(lst->hl_addr, depth0_listen_ipv6, + (void)strlcpy(lst->hl_addr, depth0_listen_tcp6, sizeof(lst->hl_addr)); TAILQ_INSERT_TAIL(&lconfig->hc_listen, lst, hl_next); } else { ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r222118 - head/sbin/hastd
Author: pjd Date: Fri May 20 11:14:05 2011 New Revision: 222118 URL: http://svn.freebsd.org/changeset/base/222118 Log: Now that hell is fully frozen it is good time to add IPv6 support to HAST. MFC after:3 weeks Modified: head/sbin/hastd/proto_tcp.c Modified: head/sbin/hastd/proto_tcp.c == --- head/sbin/hastd/proto_tcp.c Fri May 20 11:10:39 2011(r222117) +++ head/sbin/hastd/proto_tcp.c Fri May 20 11:14:05 2011(r222118) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2009-2010 The FreeBSD Foundation + * Copyright (c) 2011 Pawel Jakub Dawidek * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from @@ -51,10 +52,10 @@ __FBSDID("$FreeBSD$"); #include "proto_impl.h" #include "subr.h" -#defineTCP_CTX_MAGIC 0x7c441c +#defineTCP_CTX_MAGIC 0x7c41c struct tcp_ctx { int tc_magic; - struct sockaddr_in tc_sin; + struct sockaddr_storage tc_sa; int tc_fd; int tc_side; #defineTCP_SIDE_CLIENT 0 @@ -65,24 +66,6 @@ struct tcp_ctx { static int tcp_connect_wait(void *ctx, int timeout); static void tcp_close(void *ctx); -static in_addr_t -str2ip(const char *str) -{ - struct hostent *hp; - in_addr_t ip; - - ip = inet_addr(str); - if (ip != INADDR_NONE) { - /* It is a valid IP address. */ - return (ip); - } - /* Check if it is a valid host name. */ - hp = gethostbyname(str); - if (hp == NULL) - return (INADDR_NONE); - return (((struct in_addr *)(void *)hp->h_addr)->s_addr); -} - /* * Function converts the given string to unsigned number. */ @@ -114,57 +97,93 @@ invalid: } static int -tcp_addr(const char *addr, int defport, struct sockaddr_in *sinp) +tcp_addr(const char *addr, int defport, struct sockaddr_storage *sap) { - char iporhost[MAXHOSTNAMELEN]; + char iporhost[MAXHOSTNAMELEN], portstr[6]; + struct addrinfo hints; + struct addrinfo *res; const char *pp; + intmax_t port; size_t size; - in_addr_t ip; + int error; if (addr == NULL) return (-1); - if (strncasecmp(addr, "tcp://", 7) == 0) + bzero(&hints, sizeof(hints)); + hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV; + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_TCP; + + if (strncasecmp(addr, "tcp4://", 7) == 0) { + addr += 7; + hints.ai_family = PF_INET; + } else if (strncasecmp(addr, "tcp6://", 7) == 0) { addr += 7; - else if (strncasecmp(addr, "tcp://", 6) == 0) + hints.ai_family = PF_INET6; + } else if (strncasecmp(addr, "tcp://", 6) == 0) { addr += 6; - else { + } else { /* * Because TCP is the default assume IP or host is given without * prefix. */ } - sinp->sin_family = AF_INET; - sinp->sin_len = sizeof(*sinp); - /* Extract optional port. */ - pp = strrchr(addr, ':'); + /* +* Extract optional port. +* There are three cases to consider. +* 1. hostname with port, eg. freefall.freebsd.org:8457 +* 2. IPv4 address with port, eg. 192.168.0.101:8457 +* 3. IPv6 address with port, eg. [fe80::1]:8457 +* We discover IPv6 address by checking for two colons and if port is +* given, the address has to start with [. +*/ + pp = NULL; + if (strchr(addr, ':') != strrchr(addr, ':')) { + if (addr[0] == '[') + pp = strrchr(addr, ':'); + } else { + pp = strrchr(addr, ':'); + } if (pp == NULL) { /* Port not given, use the default. */ - sinp->sin_port = htons(defport); + port = defport; } else { - intmax_t port; - if (numfromstr(pp + 1, 1, 65535, &port) < 0) return (errno); - sinp->sin_port = htons(port); } + (void)snprintf(portstr, sizeof(portstr), "%jd", (intmax_t)port); /* Extract host name or IP address. */ if (pp == NULL) { size = sizeof(iporhost); if (strlcpy(iporhost, addr, size) >= size) return (ENAMETOOLONG); + } else if (addr[0] == '[' && pp[-1] == ']') { + size = (size_t)(pp - addr - 2 + 1); + if (size > sizeof(
svn commit: r222117 - head/sbin/hastd
Author: pjd Date: Fri May 20 11:10:39 2011 New Revision: 222117 URL: http://svn.freebsd.org/changeset/base/222117 Log: Allow [ ] characters in strings. They might be used in IPv6 addresses. MFC after:3 weeks Modified: head/sbin/hastd/token.l Modified: head/sbin/hastd/token.l == --- head/sbin/hastd/token.l Fri May 20 11:09:02 2011(r222116) +++ head/sbin/hastd/token.l Fri May 20 11:10:39 2011(r222117) @@ -68,7 +68,7 @@ sha256{ DP; return SHA256; } hole { DP; return HOLE; } lzf{ DP; return LZF; } [0-9]+ { DP; yylval.num = atoi(yytext); return NUM; } -[a-zA-Z0-9\.\-_/\:]+ { DP; yylval.str = strdup(yytext); return STR; } +[a-zA-Z0-9\.\-_/\:\[\]]+ { DP; yylval.str = strdup(yytext); return STR; } \{ { DP; depth++; return OB; } \} { DP; depth--; return CB; } #.*$ /* ignore comments */; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r222116 - head/sbin/hastd
Author: pjd Date: Fri May 20 11:09:02 2011 New Revision: 222116 URL: http://svn.freebsd.org/changeset/base/222116 Log: Rename tcp4 to tcp in preparation for IPv6 support. MFC after:3 weeks Modified: head/sbin/hastd/Makefile head/sbin/hastd/proto_tcp.c Modified: head/sbin/hastd/Makefile == --- head/sbin/hastd/MakefileFri May 20 11:06:17 2011(r222115) +++ head/sbin/hastd/MakefileFri May 20 11:09:02 2011(r222116) @@ -20,7 +20,7 @@ SRCS+=y.tab.h MAN= hastd.8 hast.conf.5 NO_WFORMAT= -CFLAGS+=-DPROTO_TCP4_DEFAULT_PORT=8457 +CFLAGS+=-DPROTO_TCP_DEFAULT_PORT=8457 CFLAGS+=-I${.CURDIR} CFLAGS+=-DINET .if ${MK_INET6_SUPPORT} != "no" Modified: head/sbin/hastd/proto_tcp.c == --- head/sbin/hastd/proto_tcp.c Fri May 20 11:06:17 2011(r222115) +++ head/sbin/hastd/proto_tcp.c Fri May 20 11:09:02 2011(r222116) @@ -51,19 +51,19 @@ __FBSDID("$FreeBSD$"); #include "proto_impl.h" #include "subr.h" -#defineTCP4_CTX_MAGIC 0x7c441c -struct tcp4_ctx { +#defineTCP_CTX_MAGIC 0x7c441c +struct tcp_ctx { int tc_magic; struct sockaddr_in tc_sin; int tc_fd; int tc_side; -#defineTCP4_SIDE_CLIENT0 -#defineTCP4_SIDE_SERVER_LISTEN 1 -#defineTCP4_SIDE_SERVER_WORK 2 +#defineTCP_SIDE_CLIENT 0 +#defineTCP_SIDE_SERVER_LISTEN 1 +#defineTCP_SIDE_SERVER_WORK2 }; -static int tcp4_connect_wait(void *ctx, int timeout); -static void tcp4_close(void *ctx); +static int tcp_connect_wait(void *ctx, int timeout); +static void tcp_close(void *ctx); static in_addr_t str2ip(const char *str) @@ -114,7 +114,7 @@ invalid: } static int -tcp4_addr(const char *addr, int defport, struct sockaddr_in *sinp) +tcp_addr(const char *addr, int defport, struct sockaddr_in *sinp) { char iporhost[MAXHOSTNAMELEN]; const char *pp; @@ -124,13 +124,13 @@ tcp4_addr(const char *addr, int defport, if (addr == NULL) return (-1); - if (strncasecmp(addr, "tcp4://", 7) == 0) + if (strncasecmp(addr, "tcp://", 7) == 0) addr += 7; else if (strncasecmp(addr, "tcp://", 6) == 0) addr += 6; else { /* -* Because TCP4 is the default assume IP or host is given without +* Because TCP is the default assume IP or host is given without * prefix. */ } @@ -170,14 +170,14 @@ tcp4_addr(const char *addr, int defport, } static int -tcp4_setup_new(const char *addr, int side, void **ctxp) +tcp_setup_new(const char *addr, int side, void **ctxp) { - struct tcp4_ctx *tctx; + struct tcp_ctx *tctx; int ret, nodelay; PJDLOG_ASSERT(addr != NULL); - PJDLOG_ASSERT(side == TCP4_SIDE_CLIENT || - side == TCP4_SIDE_SERVER_LISTEN); + PJDLOG_ASSERT(side == TCP_SIDE_CLIENT || + side == TCP_SIDE_SERVER_LISTEN); PJDLOG_ASSERT(ctxp != NULL); tctx = malloc(sizeof(*tctx)); @@ -185,7 +185,7 @@ tcp4_setup_new(const char *addr, int sid return (errno); /* Parse given address. */ - if ((ret = tcp4_addr(addr, PROTO_TCP4_DEFAULT_PORT, + if ((ret = tcp_addr(addr, PROTO_TCP_DEFAULT_PORT, &tctx->tc_sin)) != 0) { free(tctx); return (ret); @@ -210,20 +210,20 @@ tcp4_setup_new(const char *addr, int sid } tctx->tc_side = side; - tctx->tc_magic = TCP4_CTX_MAGIC; + tctx->tc_magic = TCP_CTX_MAGIC; *ctxp = tctx; return (0); } static int -tcp4_setup_wrap(int fd, int side, void **ctxp) +tcp_setup_wrap(int fd, int side, void **ctxp) { - struct tcp4_ctx *tctx; + struct tcp_ctx *tctx; PJDLOG_ASSERT(fd >= 0); - PJDLOG_ASSERT(side == TCP4_SIDE_CLIENT || - side == TCP4_SIDE_SERVER_WORK); + PJDLOG_ASSERT(side == TCP_SIDE_CLIENT || + side == TCP_SIDE_SERVER_WORK); PJDLOG_ASSERT(ctxp != NULL); tctx = malloc(sizeof(*tctx)); @@ -233,47 +233,47 @@ tcp4_setup_wrap(int fd, int side, void * tctx->tc_fd = fd; tctx->tc_sin.sin_family = AF_UNSPEC; tctx->tc_side = side; - tctx->tc_magic = TCP4_CTX_MAGIC; + tctx->tc_magic = TCP_CTX_MAGIC; *ctxp = tctx; return (0); } static int -tcp4_client(const char *srcaddr, const char *dstaddr, void **ctxp) +tcp_client(const char *srcaddr, const char *dstaddr, void **ctxp) { - struct tcp4_ctx *tctx; + struct tcp_ctx *tctx; struct sockaddr_in sin; int ret; - ret = tcp4_setup_new(dstaddr, TCP4_SIDE_CLIENT, ctxp); + ret = tcp_setup_new(dstad
svn commit: r222115 - head/sbin/hastd
Author: pjd Date: Fri May 20 11:06:17 2011 New Revision: 222115 URL: http://svn.freebsd.org/changeset/base/222115 Log: Rename proto_tcp4.c to proto_tcp.c in preparation for IPv6 support. MFC after:2 weeks Added: head/sbin/hastd/proto_tcp.c - copied unchanged from r222085, head/sbin/hastd/proto_tcp4.c Deleted: head/sbin/hastd/proto_tcp4.c Modified: head/sbin/hastd/Makefile Modified: head/sbin/hastd/Makefile == --- head/sbin/hastd/MakefileFri May 20 07:51:46 2011(r222114) +++ head/sbin/hastd/MakefileFri May 20 11:06:17 2011(r222115) @@ -12,7 +12,7 @@ SRCS+=metadata.c SRCS+= nv.c SRCS+= secondary.c SRCS+= parse.y pjdlog.c primary.c -SRCS+= proto.c proto_common.c proto_socketpair.c proto_tcp4.c proto_uds.c +SRCS+= proto.c proto_common.c proto_socketpair.c proto_tcp.c proto_uds.c SRCS+= rangelock.c SRCS+= subr.c SRCS+= token.l Copied: head/sbin/hastd/proto_tcp.c (from r222085, head/sbin/hastd/proto_tcp4.c) == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sbin/hastd/proto_tcp.c Fri May 20 11:06:17 2011(r222115, copy of r222085, head/sbin/hastd/proto_tcp4.c) @@ -0,0 +1,597 @@ +/*- + * Copyright (c) 2009-2010 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Pawel Jakub Dawidek under sponsorship from + * the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include /* MAXHOSTNAMELEN */ +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pjdlog.h" +#include "proto_impl.h" +#include "subr.h" + +#defineTCP4_CTX_MAGIC 0x7c441c +struct tcp4_ctx { + int tc_magic; + struct sockaddr_in tc_sin; + int tc_fd; + int tc_side; +#defineTCP4_SIDE_CLIENT0 +#defineTCP4_SIDE_SERVER_LISTEN 1 +#defineTCP4_SIDE_SERVER_WORK 2 +}; + +static int tcp4_connect_wait(void *ctx, int timeout); +static void tcp4_close(void *ctx); + +static in_addr_t +str2ip(const char *str) +{ + struct hostent *hp; + in_addr_t ip; + + ip = inet_addr(str); + if (ip != INADDR_NONE) { + /* It is a valid IP address. */ + return (ip); + } + /* Check if it is a valid host name. */ + hp = gethostbyname(str); + if (hp == NULL) + return (INADDR_NONE); + return (((struct in_addr *)(void *)hp->h_addr)->s_addr); +} + +/* + * Function converts the given string to unsigned number. + */ +static int +numfromstr(const char *str, intmax_t minnum, intmax_t maxnum, intmax_t *nump) +{ + intmax_t digit, num; + + if (str[0] == '\0') + goto invalid; /* Empty string. */ + num = 0; + for (; *str != '\0'; str++) { + if (*str < '0' || *str > '9') + goto invalid; /* Non-digit character. */ + digit = *str - '0'; + if (num > num * 10 + digit) + goto invalid; /* Overflow. */ + num = num * 10 + digit; + if (num > maxnum) + goto invalid; /* Too big. */ + } + if (num < minnum) + goto invalid; /* Too small. */ + *nump = num; + return (0); +invalid: +
svn commit: r222108 - head/sbin/hastd
Author: pjd Date: Thu May 19 23:18:42 2011 New Revision: 222108 URL: http://svn.freebsd.org/changeset/base/222108 Log: In preparation for IPv6 support allow to specify multiple addresses to listen on. MFC after:3 weeks Modified: head/sbin/hastd/hast.conf.5 head/sbin/hastd/hast.h head/sbin/hastd/hastd.c head/sbin/hastd/parse.y Modified: head/sbin/hastd/hast.conf.5 == --- head/sbin/hastd/hast.conf.5 Thu May 19 23:13:08 2011(r222107) +++ head/sbin/hastd/hast.conf.5 Thu May 19 23:18:42 2011(r222108) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 2, 2011 +.Dd May 20, 2011 .Dt HAST.CONF 5 .Os .Sh NAME @@ -159,6 +159,7 @@ tcp4://0.0.0.0 tcp4://0.0.0.0:8457 .Ed .Pp +Multiple listen addresses can be specified. The default value is .Pa tcp4://0.0.0.0:8457 . .It Ic replication Aq mode Modified: head/sbin/hastd/hast.h == --- head/sbin/hastd/hast.h Thu May 19 23:13:08 2011(r222107) +++ head/sbin/hastd/hast.h Thu May 19 23:18:42 2011(r222108) @@ -82,12 +82,13 @@ #defineHIO_FLUSH 4 #defineHIO_KEEPALIVE 5 -#defineHAST_USER "hast" -#defineHAST_TIMEOUT20 -#defineHAST_CONFIG "/etc/hast.conf" -#defineHAST_CONTROL"/var/run/hastctl" -#defineHASTD_LISTEN"tcp4://0.0.0.0:8457" -#defineHASTD_PIDFILE "/var/run/hastd.pid" +#defineHAST_USER "hast" +#defineHAST_TIMEOUT20 +#defineHAST_CONFIG "/etc/hast.conf" +#defineHAST_CONTROL"/var/run/hastctl" +#defineHASTD_LISTEN_IPV4 "tcp4://0.0.0.0:8457" +#defineHASTD_LISTEN_IPV6 "tcp6://[::]:8457" +#defineHASTD_PIDFILE "/var/run/hastd.pid" /* Default extent size. */ #defineHAST_EXTENTSIZE 2097152 @@ -100,6 +101,14 @@ /* Number of seconds to sleep between reconnect retries or keepalive packets. */ #defineHAST_KEEPALIVE 10 +struct hastd_listen { + /* Address to listen on. */ + char hl_addr[HAST_ADDRSIZE]; + /* Protocol-specific data. */ + struct proto_conn *hl_conn; + TAILQ_ENTRY(hastd_listen) hl_next; +}; + struct hastd_config { /* Address to communicate with hastctl(8). */ char hc_controladdr[HAST_ADDRSIZE]; @@ -107,10 +116,8 @@ struct hastd_config { struct proto_conn *hc_controlconn; /* Incoming control connection. */ struct proto_conn *hc_controlin; - /* Address to listen on. */ - char hc_listenaddr[HAST_ADDRSIZE]; - /* Protocol-specific data. */ - struct proto_conn *hc_listenconn; + /* List of addresses to listen on. */ + TAILQ_HEAD(, hastd_listen) hc_listen; /* List of resources. */ TAILQ_HEAD(, hast_resource) hc_resources; }; Modified: head/sbin/hastd/hastd.c == --- head/sbin/hastd/hastd.c Thu May 19 23:13:08 2011(r222107) +++ head/sbin/hastd/hastd.c Thu May 19 23:18:42 2011(r222108) @@ -98,6 +98,7 @@ void descriptors_cleanup(struct hast_resource *res) { struct hast_resource *tres; + struct hastd_listen *lst; TAILQ_FOREACH(tres, &cfg->hc_resources, hr_next) { if (tres == res) { @@ -120,7 +121,10 @@ descriptors_cleanup(struct hast_resource if (cfg->hc_controlin != NULL) proto_close(cfg->hc_controlin); proto_close(cfg->hc_controlconn); - proto_close(cfg->hc_listenconn); + TAILQ_FOREACH(lst, &cfg->hc_listen, hl_next) { + if (lst->hl_conn != NULL) + proto_close(lst->hl_conn); + } (void)pidfile_close(pfh); hook_fini(); pjdlog_fini(); @@ -462,6 +466,8 @@ hastd_reload(void) { struct hastd_config *newcfg; struct hast_resource *nres, *cres, *tres; + struct hastd_listen *nlst, *clst; + unsigned int nlisten; uint8_t role; pjdlog_info("Reloading configuration..."); @@ -483,19 +489,37 @@ hastd_reload(void) } } /* -* Check if listen address has changed. +* Check if any listen address has changed. */ - if (strcmp(cfg->hc_listenaddr, newcfg->hc_listenaddr) != 0) { - if (proto_server(newcfg->hc_listenaddr, - &newcfg->hc_listenconn) < 0) { - pjdlog_errno(LOG_ERR, "Unable to listen on address %s", - newcfg->hc_listenaddr); - goto failed; + nlisten = 0; + TAILQ_FOREACH(nlst, &newcfg->hc_listen, hl_next) { + TAILQ_FOREACH(clst, &cfg->hc_listen, hl_next) { + if (strcmp(nlst->hl_add
svn commit: r222087 - head/sbin/hastd
Author: pjd Date: Wed May 18 22:43:56 2011 New Revision: 222087 URL: http://svn.freebsd.org/changeset/base/222087 Log: - Add support for AF_INET6 sockets for %S format character. - Use inet_ntop(3) instead of reimplementing it. - Use %hhu for unsigned char instead of casting it to unsigned int and using %u. MFC after:1 week Modified: head/sbin/hastd/pjdlog.c Modified: head/sbin/hastd/pjdlog.c == --- head/sbin/hastd/pjdlog.cWed May 18 22:36:58 2011(r222086) +++ head/sbin/hastd/pjdlog.cWed May 18 22:43:56 2011(r222087) @@ -31,8 +31,10 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include +#include #include #include @@ -103,22 +105,39 @@ pjdlog_printf_render_sockaddr(struct __p switch (ss->ss_family) { case AF_INET: { + char addr[INET_ADDRSTRLEN]; const struct sockaddr_in *sin; - in_addr_t ip; unsigned int port; sin = (const struct sockaddr_in *)ss; - ip = ntohl(sin->sin_addr.s_addr); port = ntohs(sin->sin_port); + if (inet_ntop(ss->ss_family, &sin->sin_addr, addr, + sizeof(addr)) == NULL) { + PJDLOG_ABORT("inet_ntop(AF_INET) failed: %s.", + strerror(errno)); + } + snprintf(buf, sizeof(buf), "%s:%u", addr, port); + break; + } + case AF_INET6: + { + char addr[INET6_ADDRSTRLEN]; + const struct sockaddr_in6 *sin; + unsigned int port; - snprintf(buf, sizeof(buf), "%u.%u.%u.%u:%u", - ((ip >> 24) & 0xff), ((ip >> 16) & 0xff), - ((ip >> 8) & 0xff), (ip & 0xff), port); + sin = (const struct sockaddr_in6 *)ss; + port = ntohs(sin->sin6_port); + if (inet_ntop(ss->ss_family, &sin->sin6_addr, addr, + sizeof(addr)) == NULL) { + PJDLOG_ABORT("inet_ntop(AF_INET6) failed: %s.", + strerror(errno)); + } + snprintf(buf, sizeof(buf), "[%s]:%u", addr, port); break; } default: - snprintf(buf, sizeof(buf), "[unsupported family %u]", - (unsigned int)ss->ss_family); + snprintf(buf, sizeof(buf), "[unsupported family %hhu]", + ss->ss_family); break; } ret = __printf_out(io, pi, buf, strlen(buf)); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r222084 - head/contrib/gperf/src
On Wed, May 18, 2011 at 09:06:20PM +, Ben Laurie wrote: > Author: benl > Date: Wed May 18 21:06:20 2011 > New Revision: 222084 > URL: http://svn.freebsd.org/changeset/base/222084 > > Log: > Fix clang warnings. > > Approved by:philip (mentor) [...] > -fprintf (stderr, " by changing asso_value['%c'] (char #%d) to > %d\n", > +fprintf (stderr, " by changing asso_value['%c'] (char #%zd) to > %d\n", > *p, p - union_set + 1, asso_values[(unsigned > char)(*p)]); Hmm, both 'p' and 'union_set' are 'char *' and %zd is for ssize_t. It is a bit strange that it fixes the warning. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpqtfHcv0ouD.pgp Description: PGP signature
Re: svn commit: r222079 - head/usr.sbin/pc-sysinstall/backend
On Wed, May 18, 2011 at 08:38:29PM +, Josh Paetzel wrote: > Author: jpaetzel > Date: Wed May 18 20:38:28 2011 > New Revision: 222079 > URL: http://svn.freebsd.org/changeset/base/222079 > > Log: > Wipeout the end of disks, home to things like gmirror metadata, backup GPT > tables, > and other potential evil. If geom_mirror.ko is loaded it won't work, as gmirror keeps its components open for writing. But if this is GENERIC and geom_mirror.ko is not loaded, you should be fine. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpTslP35BbIm.pgp Description: PGP signature
Re: svn commit: r221993 - in head/sys: kern sys
On Mon, May 16, 2011 at 04:18:40PM +, Poul-Henning Kamp wrote: > Author: phk > Date: Mon May 16 16:18:40 2011 > New Revision: 221993 > URL: http://svn.freebsd.org/changeset/base/221993 > > Log: > Change the length quantities of sbufs to be ssize_t rather than int. > > Constify a couple of arguments. > > Modified: > head/sys/kern/subr_sbuf.c > head/sys/sys/sbuf.h > > Modified: head/sys/kern/subr_sbuf.c > == > --- head/sys/kern/subr_sbuf.c Mon May 16 15:59:50 2011(r221992) > +++ head/sys/kern/subr_sbuf.c Mon May 16 16:18:40 2011(r221993) > @@ -94,7 +94,8 @@ _assert_sbuf_integrity(const char *fun, > KASSERT(s->s_buf != NULL, > ("%s called with uninitialized or corrupt sbuf", fun)); > KASSERT(s->s_len < s->s_size, > - ("wrote past end of sbuf (%d >= %d)", s->s_len, s->s_size)); > + ("wrote past end of sbuf (%jd >= %jd)", > + (intmax_t)s->s_len, (intmax_t)s->s_size)); For ssize_t we have %zd. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpMl1w9hZERA.pgp Description: PGP signature
svn commit: r221899 - in head/sbin: hastctl hastd
Author: pjd Date: Sat May 14 17:02:03 2011 New Revision: 221899 URL: http://svn.freebsd.org/changeset/base/221899 Log: Currently we are unable to use capsicum for the primary worker process, because we need to do ioctl(2)s, which are not permitted in the capability mode. What we do now is to chroot(2) to /var/empty, which restricts access to file system name space and we drop privileges to hast user and hast group. This still allows to access to other name spaces, like list of processes, network and sysvipc. To address that, use jail(2) instead of chroot(2). Using jail(2) will restrict access to process table, network (we use ip-less jails) and sysvipc (if security.jail.sysvipc_allowed is turned off). This provides much better separation. MFC after:1 week Modified: head/sbin/hastctl/hastctl.c head/sbin/hastd/primary.c head/sbin/hastd/secondary.c head/sbin/hastd/subr.c head/sbin/hastd/subr.h Modified: head/sbin/hastctl/hastctl.c == --- head/sbin/hastctl/hastctl.c Sat May 14 16:55:24 2011(r221898) +++ head/sbin/hastctl/hastctl.c Sat May 14 17:02:03 2011(r221899) @@ -480,7 +480,7 @@ main(int argc, char *argv[]) cfg->hc_controladdr); } - if (drop_privs(true) != 0) + if (drop_privs(NULL) != 0) exit(EX_CONFIG); /* Send the command to the server... */ Modified: head/sbin/hastd/primary.c == --- head/sbin/hastd/primary.c Sat May 14 16:55:24 2011(r221898) +++ head/sbin/hastd/primary.c Sat May 14 17:02:03 2011(r221899) @@ -904,7 +904,7 @@ hastd_primary(struct hast_resource *res) init_ggate(res); init_environment(res); - if (drop_privs(true) != 0) { + if (drop_privs(res) != 0) { cleanup(res); exit(EX_CONFIG); } Modified: head/sbin/hastd/secondary.c == --- head/sbin/hastd/secondary.c Sat May 14 16:55:24 2011(r221898) +++ head/sbin/hastd/secondary.c Sat May 14 17:02:03 2011(r221899) @@ -436,7 +436,7 @@ hastd_secondary(struct hast_resource *re init_local(res); init_environment(); - if (drop_privs(true) != 0) + if (drop_privs(res) != 0) exit(EX_CONFIG); pjdlog_info("Privileges successfully dropped."); Modified: head/sbin/hastd/subr.c == --- head/sbin/hastd/subr.c Sat May 14 16:55:24 2011(r221898) +++ head/sbin/hastd/subr.c Sat May 14 17:02:03 2011(r221899) @@ -32,9 +32,10 @@ __FBSDID("$FreeBSD$"); #include -#include +#include #include #include +#include #include #include @@ -147,13 +148,15 @@ role2str(int role) } int -drop_privs(bool usecapsicum) +drop_privs(struct hast_resource *res) { + char jailhost[sizeof(res->hr_name) * 2]; + struct jail jailst; struct passwd *pw; uid_t ruid, euid, suid; gid_t rgid, egid, sgid; gid_t gidset[1]; - bool capsicum; + bool capsicum, jailed; /* * According to getpwnam(3) we have to clear errno before calling the @@ -173,10 +176,34 @@ drop_privs(bool usecapsicum) return (-1); } } - if (chroot(pw->pw_dir) == -1) { - KEEP_ERRNO(pjdlog_errno(LOG_ERR, - "Unable to change root directory to %s", pw->pw_dir)); - return (-1); + + bzero(&jailst, sizeof(jailst)); + jailst.version = JAIL_API_VERSION; + jailst.path = pw->pw_dir; + if (res == NULL) { + (void)snprintf(jailhost, sizeof(jailhost), "hastctl"); + } else { + (void)snprintf(jailhost, sizeof(jailhost), "hastd: %s (%s)", + res->hr_name, role2str(res->hr_role)); + } + jailst.hostname = jailhost; + jailst.jailname = NULL; + jailst.ip4s = 0; + jailst.ip4 = NULL; + jailst.ip6s = 0; + jailst.ip6 = NULL; + if (jail(&jailst) >= 0) { + jailed = true; + } else { + jailed = false; + pjdlog_errno(LOG_WARNING, + "Unable to jail to directory to %s", pw->pw_dir); + if (chroot(pw->pw_dir) == -1) { + KEEP_ERRNO(pjdlog_errno(LOG_ERR, + "Unable to change root directory to %s", + pw->pw_dir)); + return (-1); + } } PJDLOG_VERIFY(chdir("/") == 0); gidset[0] = pw->pw_gid; @@ -197,15 +224,10 @@ drop_privs(bool usecapsicum) return (-1); } - capsicum = false; - if (usecapsicum) { -
svn commit: r221898 - head/sbin/hastd
Author: pjd Date: Sat May 14 16:55:24 2011 New Revision: 221898 URL: http://svn.freebsd.org/changeset/base/221898 Log: When using capsicum to sanbox, still use other methods first, just in case one of them have some problems. Modified: head/sbin/hastd/subr.c Modified: head/sbin/hastd/subr.c == --- head/sbin/hastd/subr.c Sat May 14 15:24:15 2011(r221897) +++ head/sbin/hastd/subr.c Sat May 14 16:55:24 2011(r221898) @@ -153,15 +153,7 @@ drop_privs(bool usecapsicum) uid_t ruid, euid, suid; gid_t rgid, egid, sgid; gid_t gidset[1]; - - if (usecapsicum) { - if (cap_enter() == 0) { - pjdlog_debug(1, - "Privileges successfully dropped using capsicum."); - return (0); - } - pjdlog_errno(LOG_WARNING, "Unable to sandbox using capsicum"); - } + bool capsicum; /* * According to getpwnam(3) we have to clear errno before calling the @@ -205,6 +197,16 @@ drop_privs(bool usecapsicum) return (-1); } + capsicum = false; + if (usecapsicum) { + if (cap_enter() == 0) { + capsicum = true; + } else { + pjdlog_errno(LOG_WARNING, + "Unable to sandbox using capsicum"); + } + } + /* * Better be sure that everything succeeded. */ @@ -221,7 +223,8 @@ drop_privs(bool usecapsicum) PJDLOG_VERIFY(gidset[0] == pw->pw_gid); pjdlog_debug(1, - "Privileges successfully dropped using chroot+setgid+setuid."); + "Privileges successfully dropped using %schroot+setgid+setuid.", + capsicum ? "capsicum+" : ""); return (0); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r221816 - head/usr.bin/fstat
On Thu, May 12, 2011 at 11:57:03AM -0700, Stanislav Sedov wrote: > On Thu, 12 May 2011 17:02:56 + (UTC) > Warner Losh mentioned: > > > Author: imp > > Date: Thu May 12 17:02:56 2011 > > New Revision: 221816 > > URL: http://svn.freebsd.org/changeset/base/221816 > > > > Log: > > Fix printf int mismatch on 32-bit architectures... > > > > Thanks a lot! > Apparently I did `make universe` in the wrong tree... Sure... :) -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpvRPQg7mArr.pgp Description: PGP signature
svn commit: r221643 - head/sbin/hastd
Author: pjd Date: Sun May 8 11:10:56 2011 New Revision: 221643 URL: http://svn.freebsd.org/changeset/base/221643 Log: Allow to specify remote as 'none' again which was broken by r219351, where 'none' was defined as a value for checksum. Reported by: trasz MFC after:1 week Modified: head/sbin/hastd/parse.y Modified: head/sbin/hastd/parse.y == --- head/sbin/hastd/parse.y Sun May 8 11:05:03 2011(r221642) +++ head/sbin/hastd/parse.y Sun May 8 11:10:56 2011(r221643) @@ -289,6 +289,7 @@ yy_config_free(struct hastd_config *conf %token FULLSYNC MEMSYNC ASYNC NONE CRC32 SHA256 HOLE LZF %token NUM STR OB CB +%type remote_str %type replication_type %type checksum_type %type compression_type @@ -796,7 +797,7 @@ resource_node_entry: source_statement ; -remote_statement: REMOTE STR +remote_statement: REMOTE remote_str { assert(depth == 2); if (mynode) { @@ -813,6 +814,12 @@ remote_statement: REMOTE STR } ; +remote_str: + NONE{ $$ = strdup("none"); } + | + STR { } + ; + source_statement: SOURCE STR { assert(depth == 2); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r221633 - head/sbin/geom/class/eli
Author: pjd Date: Sun May 8 09:46:09 2011 New Revision: 221633 URL: http://svn.freebsd.org/changeset/base/221633 Log: Document the following sysctls: kern.geom.eli.version kern.geom.eli.key_cache_limit kern.geom.eli.key_cache_hits kern.geom.eli.key_cache_misses MFC after:1 week Modified: head/sbin/geom/class/eli/geli.8 Modified: head/sbin/geom/class/eli/geli.8 == --- head/sbin/geom/class/eli/geli.8 Sun May 8 09:31:17 2011 (r221632) +++ head/sbin/geom/class/eli/geli.8 Sun May 8 09:46:09 2011 (r221633) @@ -1,4 +1,4 @@ -.\" Copyright (c) 2005-2010 Pawel Jakub Dawidek +.\" Copyright (c) 2005-2011 Pawel Jakub Dawidek .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -627,9 +627,13 @@ variables can be used to control the beh .Nm ELI GEOM class. The default value is shown next to each variable. -All variables can also be set in +Some variables can also be set in .Pa /boot/loader.conf . .Bl -tag -width indent +.It Va kern.geom.eli.version +Version number of the +.Nm ELI +GEOM class. .It Va kern.geom.eli.debug : No 0 Debug level of the .Nm ELI @@ -668,6 +672,22 @@ When set to 1, can speed-up crypto opera Batching allows to reduce number of interrupts by responding on a group of crypto requests with one interrupt. The crypto card and the driver has to support this feature. +.It Va kern.geom.eli.key_cache_limit : No 8192 +Specifies how many encryption keys to cache. +The default limit +.No ( 8192 +keys) will allow to cache all keys for 4TB provider with 512 bytes sectors and +will take around 1MB of memory. +.It Va kern.geom.eli.key_cache_hits +Reports how many times we were looking up a key and it was already in cache. +This sysctl is not updated for providers that need less keys than the limit +specified in +.Va kern.geom.eli.key_cache_limit . +.It Va kern.geom.eli.key_cache_misses +Reports how many times we were looking up a key and it was not in cache. +This sysctl is not updated for providers that need less keys than the limit +specified in +.Va kern.geom.eli.key_cache_limit . .El .Sh EXIT STATUS Exit status is 0 on success, and 1 if the command fails. ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r221631 - head/sys/geom/eli
Author: pjd Date: Sun May 8 09:29:21 2011 New Revision: 221631 URL: http://svn.freebsd.org/changeset/base/221631 Log: Export GELI class version via sysctl kern.geom.eli.version. MFC after:1 week Modified: head/sys/geom/eli/g_eli.c Modified: head/sys/geom/eli/g_eli.c == --- head/sys/geom/eli/g_eli.c Sun May 8 09:25:54 2011(r221630) +++ head/sys/geom/eli/g_eli.c Sun May 8 09:29:21 2011(r221631) @@ -57,6 +57,9 @@ MALLOC_DEFINE(M_ELI, "eli data", "GEOM_E SYSCTL_DECL(_kern_geom); SYSCTL_NODE(_kern_geom, OID_AUTO, eli, CTLFLAG_RW, 0, "GEOM_ELI stuff"); +static int g_eli_version = G_ELI_VERSION; +SYSCTL_INT(_kern_geom_eli, OID_AUTO, version, CTLFLAG_RD, &g_eli_version, 0, +"GELI version"); int g_eli_debug = 0; TUNABLE_INT("kern.geom.eli.debug", &g_eli_debug); SYSCTL_INT(_kern_geom_eli, OID_AUTO, debug, CTLFLAG_RW, &g_eli_debug, 0, ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r221630 - head/sys/geom/eli
Author: pjd Date: Sun May 8 09:25:54 2011 New Revision: 221630 URL: http://svn.freebsd.org/changeset/base/221630 Log: Version 6 is compatible with version 5 when it comes to control commands. MFC after:1 week Modified: head/sys/geom/eli/g_eli_ctl.c Modified: head/sys/geom/eli/g_eli_ctl.c == --- head/sys/geom/eli/g_eli_ctl.c Sun May 8 09:25:16 2011 (r221629) +++ head/sys/geom/eli/g_eli_ctl.c Sun May 8 09:25:54 2011 (r221630) @@ -1014,7 +1014,12 @@ g_eli_config(struct gctl_req *req, struc gctl_error(req, "No '%s' argument.", "version"); return; } - if (*version != G_ELI_VERSION) { + while (*version != G_ELI_VERSION) { + if (G_ELI_VERSION == G_ELI_VERSION_06 && + *version == G_ELI_VERSION_05) { + /* Compatible. */ + break; + } gctl_error(req, "Userland and kernel parts are out of sync."); return; } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r221629 - head/sys/geom/eli
Author: pjd Date: Sun May 8 09:25:16 2011 New Revision: 221629 URL: http://svn.freebsd.org/changeset/base/221629 Log: Detect and handle metadata of version 6. MFC after:1 week Modified: head/sys/geom/eli/g_eli.h Modified: head/sys/geom/eli/g_eli.h == --- head/sys/geom/eli/g_eli.h Sun May 8 09:17:56 2011(r221628) +++ head/sys/geom/eli/g_eli.h Sun May 8 09:25:16 2011(r221629) @@ -265,7 +265,7 @@ eli_metadata_decode_v0(const u_char *dat } static __inline int -eli_metadata_decode_v1v2v3v4v5(const u_char *data, struct g_eli_metadata *md) +eli_metadata_decode_v1v2v3v4v5v6(const u_char *data, struct g_eli_metadata *md) { MD5_CTX ctx; const u_char *p; @@ -296,15 +296,16 @@ eli_metadata_decode(const u_char *data, bcopy(data, md->md_magic, sizeof(md->md_magic)); md->md_version = le32dec(data + sizeof(md->md_magic)); switch (md->md_version) { - case 0: + case G_ELI_VERSION_00: error = eli_metadata_decode_v0(data, md); break; - case 1: - case 2: - case 3: - case 4: - case 5: - error = eli_metadata_decode_v1v2v3v4v5(data, md); + case G_ELI_VERSION_01: + case G_ELI_VERSION_02: + case G_ELI_VERSION_03: + case G_ELI_VERSION_04: + case G_ELI_VERSION_05: + case G_ELI_VERSION_06: + error = eli_metadata_decode_v1v2v3v4v5v6(data, md); break; default: error = EINVAL; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r221628 - head/sys/geom/eli
Author: pjd Date: Sun May 8 09:17:56 2011 New Revision: 221628 URL: http://svn.freebsd.org/changeset/base/221628 Log: When support for multiple encryption keys was committed, GELI integrity mode was not updated to pass CRD_F_KEY_EXPLICIT flag to opencrypto. This resulted in always using first key. We need to support providers created with this bug, so set special G_ELI_FLAG_FIRST_KEY flag for GELI provider in integrity mode with version smaller than 6 and pass the CRD_F_KEY_EXPLICIT flag to opencrypto only if G_ELI_FLAG_FIRST_KEY doesn't exist. Reported by: Anton Yuzhaninov MFC after:1 week Modified: head/sys/geom/eli/g_eli.c head/sys/geom/eli/g_eli.h head/sys/geom/eli/g_eli_integrity.c Modified: head/sys/geom/eli/g_eli.c == --- head/sys/geom/eli/g_eli.c Sun May 8 09:11:59 2011(r221627) +++ head/sys/geom/eli/g_eli.c Sun May 8 09:17:56 2011(r221628) @@ -329,7 +329,12 @@ g_eli_newsession(struct g_eli_worker *wr crie.cri_klen = sc->sc_ekeylen; if (sc->sc_ealgo == CRYPTO_AES_XTS) crie.cri_klen <<= 1; - crie.cri_key = sc->sc_ekey; + if ((sc->sc_flags & G_ELI_FLAG_FIRST_KEY) != 0) { + crie.cri_key = g_eli_key_hold(sc, 0, + LIST_FIRST(&sc->sc_geom->consumer)->provider->sectorsize); + } else { + crie.cri_key = sc->sc_ekey; + } if (sc->sc_flags & G_ELI_FLAG_AUTH) { bzero(&cria, sizeof(cria)); cria.cri_alg = sc->sc_aalgo; @@ -368,6 +373,9 @@ g_eli_newsession(struct g_eli_worker *wr panic("%s: invalid condition", __func__); } + if ((sc->sc_flags & G_ELI_FLAG_FIRST_KEY) != 0) + g_eli_key_drop(sc, crie.cri_key); + return (error); } @@ -708,6 +716,8 @@ g_eli_create(struct gctl_req *req, struc sc->sc_flags |= G_ELI_FLAG_NATIVE_BYTE_ORDER; if (md->md_version < 5) sc->sc_flags |= G_ELI_FLAG_SINGLE_KEY; + if (md->md_version < 6 && (sc->sc_flags & G_ELI_FLAG_AUTH) != 0) + sc->sc_flags |= G_ELI_FLAG_FIRST_KEY; sc->sc_ealgo = md->md_ealgo; sc->sc_nkey = nkey; Modified: head/sys/geom/eli/g_eli.h == --- head/sys/geom/eli/g_eli.h Sun May 8 09:11:59 2011(r221627) +++ head/sys/geom/eli/g_eli.h Sun May 8 09:17:56 2011(r221628) @@ -63,10 +63,19 @@ * 2 - Added G_ELI_FLAG_READONLY. * 3 - Added 'configure' subcommand. * 4 - IV is generated from offset converted to little-endian - * (flag G_ELI_FLAG_NATIVE_BYTE_ORDER will be set for older versions). + * (the G_ELI_FLAG_NATIVE_BYTE_ORDER flag will be set for older versions). * 5 - Added multiple encrypton keys and AES-XTS support. + * 6 - Fixed usage of multiple keys for authenticated providers (the + * G_ELI_FLAG_FIRST_KEY flag will be set for older versions). */ -#defineG_ELI_VERSION 5 +#defineG_ELI_VERSION_000 +#defineG_ELI_VERSION_011 +#defineG_ELI_VERSION_022 +#defineG_ELI_VERSION_033 +#defineG_ELI_VERSION_044 +#defineG_ELI_VERSION_055 +#defineG_ELI_VERSION_066 +#defineG_ELI_VERSION G_ELI_VERSION_06 /* ON DISK FLAGS. */ /* Use random, onetime keys. */ @@ -92,6 +101,8 @@ #defineG_ELI_FLAG_SINGLE_KEY 0x0008 /* Device suspended. */ #defineG_ELI_FLAG_SUSPEND 0x0010 +/* Provider uses first encryption key. */ +#defineG_ELI_FLAG_FIRST_KEY0x0020 #defineG_ELI_NEW_BIO 255 Modified: head/sys/geom/eli/g_eli_integrity.c == --- head/sys/geom/eli/g_eli_integrity.c Sun May 8 09:11:59 2011 (r221627) +++ head/sys/geom/eli/g_eli_integrity.c Sun May 8 09:17:56 2011 (r221628) @@ -513,6 +513,8 @@ g_eli_auth_run(struct g_eli_worker *wr, crde->crd_skip = sc->sc_alen; crde->crd_len = data_secsize; crde->crd_flags = CRD_F_IV_EXPLICIT | CRD_F_IV_PRESENT; + if ((sc->sc_flags & G_ELI_FLAG_FIRST_KEY) == 0) + crde->crd_flags |= CRD_F_KEY_EXPLICIT; if (bp->bio_cmd == BIO_WRITE) crde->crd_flags |= CRD_F_ENCRYPT; crde->crd_alg = sc->sc_ealgo; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r221626 - head/sys/geom/eli
Author: pjd Date: Sun May 8 09:11:04 2011 New Revision: 221626 URL: http://svn.freebsd.org/changeset/base/221626 Log: Remove prototype for a function that no longer exist. MFC after:1 week Modified: head/sys/geom/eli/g_eli.h Modified: head/sys/geom/eli/g_eli.h == --- head/sys/geom/eli/g_eli.h Sun May 8 09:09:49 2011(r221625) +++ head/sys/geom/eli/g_eli.h Sun May 8 09:11:04 2011(r221626) @@ -509,8 +509,6 @@ void g_eli_config(struct gctl_req *req, void g_eli_read_done(struct bio *bp); void g_eli_write_done(struct bio *bp); int g_eli_crypto_rerun(struct cryptop *crp); -uint8_t *g_eli_crypto_key(struct g_eli_softc *sc, off_t offset, -size_t blocksize); void g_eli_crypto_ivgen(struct g_eli_softc *sc, off_t offset, u_char *iv, size_t size); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r221625 - head/sys/geom/eli
Author: pjd Date: Sun May 8 09:09:49 2011 New Revision: 221625 URL: http://svn.freebsd.org/changeset/base/221625 Log: Drop proper key. MFC after:1 week Modified: head/sys/geom/eli/g_eli_integrity.c Modified: head/sys/geom/eli/g_eli_integrity.c == --- head/sys/geom/eli/g_eli_integrity.c Sun May 8 09:08:50 2011 (r221624) +++ head/sys/geom/eli/g_eli_integrity.c Sun May 8 09:09:49 2011 (r221625) @@ -149,7 +149,7 @@ g_eli_auth_read_done(struct cryptop *crp bp->bio_error = crp->crp_etype; } sc = bp->bio_to->geom->softc; - g_eli_key_drop(sc, crp->crp_desc->crd_key); + g_eli_key_drop(sc, crp->crp_desc->crd_next->crd_key); /* * Do we have all sectors already? */ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r221624 - head/sys/geom/eli
Author: pjd Date: Sun May 8 09:08:50 2011 New Revision: 221624 URL: http://svn.freebsd.org/changeset/base/221624 Log: Add magic field to the g_eli_key structure to detect if we are really operating on proper structures. MFC after:1 week Modified: head/sys/geom/eli/g_eli_key_cache.c Modified: head/sys/geom/eli/g_eli_key_cache.c == --- head/sys/geom/eli/g_eli_key_cache.c Sun May 8 08:22:11 2011 (r221623) +++ head/sys/geom/eli/g_eli_key_cache.c Sun May 8 09:08:50 2011 (r221624) @@ -57,9 +57,13 @@ static uint64_t g_eli_key_cache_misses; SYSCTL_UQUAD(_kern_geom_eli, OID_AUTO, key_cache_misses, CTLFLAG_RW, &g_eli_key_cache_misses, 0, "Key cache misses"); +#defineG_ELI_KEY_MAGIC 0xe11341c + struct g_eli_key { /* Key value, must be first in the structure. */ uint8_t gek_key[G_ELI_DATAKEYLEN]; + /* Magic. */ + int gek_magic; /* Key number. */ uint64_tgek_keyno; /* Reference counter. */ @@ -98,6 +102,7 @@ g_eli_key_fill(struct g_eli_softc *sc, s sizeof(hmacdata), key->gek_key, 0); key->gek_keyno = keyno; key->gek_count = 0; + key->gek_magic = G_ELI_KEY_MAGIC; } static struct g_eli_key * @@ -150,6 +155,7 @@ g_eli_key_replace(struct g_eli_softc *sc { mtx_assert(&sc->sc_ekeys_lock, MA_OWNED); + KASSERT(key->gek_magic == G_ELI_KEY_MAGIC, ("Invalid magic.")); RB_REMOVE(g_eli_key_tree, &sc->sc_ekeys_tree, key); TAILQ_REMOVE(&sc->sc_ekeys_queue, key, gek_next); @@ -167,7 +173,7 @@ g_eli_key_remove(struct g_eli_softc *sc, { mtx_assert(&sc->sc_ekeys_lock, MA_OWNED); - + KASSERT(key->gek_magic == G_ELI_KEY_MAGIC, ("Invalid magic.")); KASSERT(key->gek_count == 0, ("gek_count=%d", key->gek_count)); RB_REMOVE(g_eli_key_tree, &sc->sc_ekeys_tree, key); @@ -276,6 +282,8 @@ g_eli_key_hold(struct g_eli_softc *sc, o /* We have all the keys, so avoid some overhead. */ key = RB_FIND(g_eli_key_tree, &sc->sc_ekeys_tree, &keysearch); KASSERT(key != NULL, ("No key %ju found.", (uintmax_t)keyno)); + KASSERT(key->gek_magic == G_ELI_KEY_MAGIC, + ("Invalid key magic.")); return (key->gek_key); } @@ -306,6 +314,8 @@ g_eli_key_hold(struct g_eli_softc *sc, o key->gek_count++; mtx_unlock(&sc->sc_ekeys_lock); + KASSERT(key->gek_magic == G_ELI_KEY_MAGIC, ("Invalid key magic.")); + return (key->gek_key); } @@ -317,6 +327,8 @@ g_eli_key_drop(struct g_eli_softc *sc, u if ((sc->sc_flags & G_ELI_FLAG_SINGLE_KEY) != 0) return; + KASSERT(key->gek_magic == G_ELI_KEY_MAGIC, ("Invalid key magic.")); + if (sc->sc_ekeys_total == sc->sc_ekeys_allocated) return; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r221124 - in head: . sbin/mount sbin/mount_nfs sys/amd64/conf sys/fs/nfsclient sys/i386/conf sys/ia64/conf sys/nfsclient sys/pc98/conf sys/powerpc/conf sys/sparc64/conf sys/sun4v/conf
On Fri, May 06, 2011 at 07:54:25AM -0400, Rick Macklem wrote: > > On Thu, May 05, 2011 at 07:06:46PM -0400, Rick Macklem wrote: > > > Also, except for the SYSCTL() naming issue they don't comflict. At > > > the > > > moment it is perfectly ok to use both for mounts concurrently. > > > For example, you could have the following 2 lines in your > > > /etc/fstab: > > > > > > nfs-server:/sub1 /mnt nfs rw 0 0 > > > nfs-server:/sub2 /mnt2 oldnfs rw 0 0 > > > > > > I don't know why you would actually choose to do this, unless you > > > found > > > that the old NFS client did something that worked better for "/sub2" > > > for > > > your purposes, but it will work fine. > > > > My personal opinion is that supporting such configuration is not worth > > the efforts and actually I'd prefer to use the same sysctl tree > > (vfs.nfs.*) and the same fstype (nfs) in both clients. User would > > decide > > which to use by loading one kernel module or the other. > > > Well, first off, I think there are problems if you have two modules > using the same "fstype" name. For example, the old mount syscall > which is still used by amd, does an unconditional > kern_kldload(.., "fstype",...); > > I'm not sure what happens when there are two modules both with the > same "fstype"? > > Also, there could be a script in /etc/rc.d that runs before any mount is > attempted (I don't know how to do this, but I assume rc@ will) and it > could load one or the other based on an rc.conf variable, but what > about doing a mount from single user? > > And I also don't know how to tell the system to allow kernels to be > built with one of NFSCLIENT, NFSCL, but not both of them? (It would > fail for both of them, since there would be 2 VFS_SET()s with the > same "fstype", I think?) > > I also think there might be situations where running both concurrently > could still be useful (that's the way things have been for 8.n). > Here's a not too hypothetical example: > - an 8.n system mounts 3 file servers > server1 - a FreeBSD server with NFSv4 enabled > server2 - Solaris8 > server3 - some Linux distro > and the /etc/fstab entries look like: > > server1:/vol1 /vol1 nfs rw,nfsv40 0 > server2:/vol2 /vol2 nfs rw 0 0 > server3:/vol3 /vol3 nfs rw 0 0 > > (The part w.r.t. server1 using NFSv4 isn't too hypothetical, since I > recently got email from a guy who is using NFSv4 on 8.2 because it > fixed a file locking problem for him. Related to openoffice, if I > recall correctly.) > > The above is using both NFS clients concurrently, although whoever > set it up might not realize that, since server1 using "newnfs" because > that's needed for NFSv4. > > Ok, now this system is upgraded to 9.0 and then /vol3 goes wonky. > If both clients can still run concurrently, /etc/fstab could be changed > to: > > server1:/vol1 /vol1 nfs rw,nfsv40 0 > server2:/vol2 /vol2 nfs rw 0 0 > server3:/vol3 /vol3 oldnfs rw0 0 > > to seee if the problem is caused by the switchover to the new NFS > client. If the wonkyness goes away, I have some work to do. If not, > I'm off the hook because something else is causing the wonkyness. > > If the two stacks can't run concurrently, the above change couldn't > be done, because "nfsv4" isn't supported by the old NFS client. > > In summary, at this point, changing the vfs.nfs.xxx to be shared > by the two clients is, to me, easier than trying to change things > so the two clients use the same "fstype" and can't run concurrently > and I also think there may be cases where running them concurrently > in 9.0 would be useful. If you don't share my preference then it would be good to make new NFS just 'nfs' everywhere (sysctls, fstype, etc.), so that we won't end up with 'newnfs' in random places in five years from now. What you do with old NFS is less important to me:) -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpBLcdbFNGSn.pgp Description: PGP signature
Re: svn commit: r221124 - in head: . sbin/mount sbin/mount_nfs sys/amd64/conf sys/fs/nfsclient sys/i386/conf sys/ia64/conf sys/nfsclient sys/pc98/conf sys/powerpc/conf sys/sparc64/conf sys/sun4v/conf
On Thu, May 05, 2011 at 07:06:46PM -0400, Rick Macklem wrote: > Also, except for the SYSCTL() naming issue they don't comflict. At the > moment it is perfectly ok to use both for mounts concurrently. > For example, you could have the following 2 lines in your /etc/fstab: > > nfs-server:/sub1/mntnfsrw 00 > nfs-server:/sub2/mnt2 oldnfs rw 00 > > I don't know why you would actually choose to do this, unless you found > that the old NFS client did something that worked better for "/sub2" for > your purposes, but it will work fine. My personal opinion is that supporting such configuration is not worth the efforts and actually I'd prefer to use the same sysctl tree (vfs.nfs.*) and the same fstype (nfs) in both clients. User would decide which to use by loading one kernel module or the other. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpvKMQMMwzuD.pgp Description: PGP signature
Re: svn commit: r221449 - head/sys/geom/journal
On Wed, May 04, 2011 at 06:06:40PM +, Andrey V. Elsukov wrote: > Author: ae > Date: Wed May 4 18:06:40 2011 > New Revision: 221449 > URL: http://svn.freebsd.org/changeset/base/221449 > > Log: > Removed KASSERT, g_new_providerf() can not fail. Well, the assertion was there to prepare us for times when g_new_providerf() will be able to fail. I was suspecting we might want to make g_new_providerf() to fail when the given name is already in use. In such case we use to create two identical entries in /dev/, not sure what we do now (panic?). > Modified: > head/sys/geom/journal/g_journal.c > > Modified: head/sys/geom/journal/g_journal.c > == > --- head/sys/geom/journal/g_journal.c Wed May 4 17:58:15 2011 > (r221448) > +++ head/sys/geom/journal/g_journal.c Wed May 4 18:06:40 2011 > (r221449) > @@ -2097,7 +2097,6 @@ g_journal_worker(void *arg) > gp = sc->sc_geom; > g_topology_lock(); > pp = g_new_providerf(gp, "%s.journal", sc->sc_name); > - KASSERT(pp != NULL, ("Cannot create %s.journal.", sc->sc_name)); > pp->mediasize = sc->sc_mediasize; > /* >* There could be a problem when data provider and journal providers -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgp0VnxRUbAas.pgp Description: PGP signature
Re: svn commit: r221398 - head/share/man/man9
On Tue, May 03, 2011 at 06:55:16PM +, Andrey V. Elsukov wrote: > Author: ae > Date: Tue May 3 18:55:16 2011 > New Revision: 221398 > URL: http://svn.freebsd.org/changeset/base/221398 > > Log: > Document make_dev_alias_p(). You should also add it to MLINKS in share/man/man9/Makefile. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpFgkEQ7CmhQ.pgp Description: PGP signature
Re: svn commit: r221242 - stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
On Sat, Apr 30, 2011 at 05:28:55AM +, Marcel Moolenaar wrote: > Author: marcel > Date: Sat Apr 30 05:28:54 2011 > New Revision: 221242 > URL: http://svn.freebsd.org/changeset/base/221242 > > Log: > Unbreak non-x86 and in particular ia64, The default stack size > on ia64 is 32KB. Unconditionally hardcoding a 16KB stack for > reasons of increasing the stack size on i386 is just wrong. If > the size was indeed expressed in terms of pages, as the commit > log suggested, then it would happen to be just right for ia64, > though only accidentally. > > Pointy hat: avg, pjd Marcel, you already know my opinion that I don't agree with this change. I don't think you are going to update the code once new architecture arrive. This change also reduces thread stack size for already existing architectures (arm and mips). I'd prefer to either commit my patch that protects against passing stack size smaller than the default on given architecture or commit what we have in HEAD. > --- stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c Sat Apr > 30 02:44:15 2011(r221241) > +++ stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c Sat Apr > 30 05:28:54 2011(r221242) > @@ -129,6 +129,7 @@ void > txg_sync_start(dsl_pool_t *dp) > { > tx_state_t *tx = &dp->dp_tx; > + size_t stksize = 0; > > mutex_enter(&tx->tx_sync_lock); > > @@ -146,7 +147,10 @@ txg_sync_start(dsl_pool_t *dp) >* 32-bit x86. This is due in part to nested pools and >* scrub_visitbp() recursion. >*/ > - tx->tx_sync_thread = thread_create(NULL, 16<<10, txg_sync_thread, > +#ifdef __i386__ > + stksize = 16 << 10; > +#endif > + tx->tx_sync_thread = thread_create(NULL, stksize, txg_sync_thread, > dp, 0, &p0, TS_RUN, minclsyspri); > > mutex_exit(&tx->tx_sync_lock); -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpVDcyxzBUcS.pgp Description: PGP signature
Re: svn commit: r220983 - head
On Tue, Apr 26, 2011 at 09:17:04PM -0600, Warner Losh wrote: > > It's not difficult to add -- the issue is that the mechanism is unreliable. > > It doesn't work for all partition types supporting labels, it's hard to > > figure out what the name of the label provider is in a generic way, and the > > label providers have a nasty habit of disappearing periodically when you > > use the underlying provider for anything. Also, retastes don't always work. > > For example, if I change the label of a GPT partition, the label provider > > does not reflect the change until a disk reattach (e.g. a reboot). > > I know that for ufs, it works well, except for the root partition which > requires some dancing to retrofit. But if you relabel a partition, it shows > up right away in /dev/ufs/newlbl. Guess not all of them are that reliable. > > The new names, and slightly non-deterministic probe order make it more > important that we shake out the bugs from this as best we can. I think that > names/uuid are critical to the future, and we need to fix any remaining > issues. Labels are kinda tricky and they differ. For example UFS labels or IDs don't play with tasting well (they were never designed to play well with such mechanism). You can create file system that is smaller than underlying provider (newfs -s). How do we know that label is assigned to the provider we are tasing and not to some other provider? Currently we check that based on recorded file system size and provider size, so we won't create label/id on ad0s1 instead of ad0s1a, but because of this we won't create label/id at all if file system was created with the -s option. GPT labels and IDs should be implemented as part of GPART class and not GLABEL. Currently if you modify GPT label for a partition in ad0 there is no write to, eg. ad0p1, so there is no taste event which allows glabel to detect the change, so the label is not updated in /dev/gpt/. There is a patch on freebsd-geom@ to move GPT labels/IDs to GPART. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpODQRCVUyob.pgp Description: PGP signature
Re: svn commit: r220982 - in head: . sys/amd64/conf sys/arm/conf sys/conf sys/i386/conf sys/ia64/conf sys/mips/conf sys/mips/malta sys/pc98/conf sys/powerpc/conf sys/sparc64/conf sys/sun4v/conf
On Tue, Apr 26, 2011 at 11:45:37AM +0300, Alexander Motin wrote: > On 26.04.2011 11:34, Pawel Jakub Dawidek wrote: > >On Tue, Apr 26, 2011 at 11:18:06AM +0300, Alexander Motin wrote: > >>What do you think about this: > >>http://docs.freebsd.org/cgi/mid.cgi?4DB54BA9.5050901 > >>? I've found that zpool utility don't likes symbolic links, but > >>except this and together with fixing hardcoding problem IMHO it > >>looks not bad. > > > >It does look good, indeed. > > > >What's the problem with zpool? > > make_dev_alias() creates symlink to the original device. After that, > attempt to do `zpool create test /dev/ad12 /dev/ad13` fails. May be > because it doesn't resolve symlink and can't find geom with name > ad12. IIRC zpool go straight to GEOM providers and doesn't even look into /dev/. Feel free to ignore this issue. Actually I think it is even better as people will notice that they should not use legacy names. > >It should operate on GEOM providers only. > > OK. If `zpool create` is the only possible problem there, then I > think we can live with it. I agree. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpBFGfj8XmKq.pgp Description: PGP signature
Re: svn commit: r220982 - in head: . sys/amd64/conf sys/arm/conf sys/conf sys/i386/conf sys/ia64/conf sys/mips/conf sys/mips/malta sys/pc98/conf sys/powerpc/conf sys/sparc64/conf sys/sun4v/conf
On Tue, Apr 26, 2011 at 11:18:06AM +0300, Alexander Motin wrote: > What do you think about this: > http://docs.freebsd.org/cgi/mid.cgi?4DB54BA9.5050901 > ? I've found that zpool utility don't likes symbolic links, but > except this and together with fixing hardcoding problem IMHO it > looks not bad. It does look good, indeed. What's the problem with zpool? It should operate on GEOM providers only. Also, ZFS should not be affected by providers name changes. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgp8kYcbwmlOq.pgp Description: PGP signature
Re: svn commit: r220982 - in head: . sys/amd64/conf sys/arm/conf sys/conf sys/i386/conf sys/ia64/conf sys/mips/conf sys/mips/malta sys/pc98/conf sys/powerpc/conf sys/sparc64/conf sys/sun4v/conf
On Tue, Apr 26, 2011 at 10:50:17AM +0300, Alexander Motin wrote: > On 26.04.2011 10:35, Pawel Jakub Dawidek wrote: > >On Tue, Apr 26, 2011 at 10:19:55AM +0300, Alexander Motin wrote: > >>On 26.04.2011 10:00, Pawel Jakub Dawidek wrote: > >>>On Mon, Apr 25, 2011 at 08:34:33PM +0300, Alexander Motin wrote: > >>>>I've thought about the process of fixing hardcoded provider names there, > >>>>and it is absolutely not trivial. If we take the "symlinking" way (patch > >>>>is already posted to current@), I think it will be much easier for > >>>>everybody, and especially users, if I hack all mentioned above GEOM > >>>>classes to ignore adX/adaY difference in provider names. And it should > >>>>perfectly fit into remaining time window. > >>> > >>>Could you be more specific what the hack would do exactly? > >> > >>I would write some comparison function, which would search both > >>names for adX/adaY prefixes, if they found on both arguments, > >>trimmed them and compared remaining parts. > >> > >>I think for usual purpose of name hardcoding device name part is > >>less important. Comparing partition names part should be enough. The > >>tricky part there is to properly identify device part, so I was > >>thinking about specific hack for adX/adaY. > > > >I was wondering how would you match X and Y, but this is indeed not > >important. So on taste we could do (totally untested): > > > >static bool > >provider_name_matches(const char *ppname, const char *hcname) > >{ > > > > if (strcmp(ppname, hcname) == 0) > > return (true); > > if (strncmp(hcname, "ad", 2) != 0 || > > hcname[2]< '0' || hcname[2]> '9') { > > return (false); > > } > > if (strncmp(ppname, "ada", 3) != 0 || > > ppname[3]< '0' || ppname[3]> '9') { > > return (false); > > } > > /* Skip 'ad[0-9]+'. */ > > hcname += 3; > > while (hcname[0]>= '0'&& hcname[0]<= '9') > > hcname++; > > /* Skip 'ada[0-9]+'. > > ppname += 4; > > while (ppname[0]>= '0'&& ppname[0]<= '9') > > ppname++; > > > > return (strcmp(ppname, hcname) == 0); > >} > > > >That could work. > > Yes, I was thinking about something like that. May be just > symmetric, so it could handle some cases of downgrade. Ok, so this will handle hardcoded provider names. I think this is good enough. Now, what about fstab? There is a problem to figure out which disk we booted from once we enter the kernel. I was wondering if we could detect that someone is trying to mount root which from 'ad[0-9]+' and then we could scan all ada[0-9]+ looking for UFS file system and /etc/fstab in there and / entry which matches vfs.root.mountfrom variable. This should cover 99% of cases. 1% is for cases where another disk have identical partitioning scheme and /etc/fstab file. There also might be cases where someone defines vfs.root.mountfrom in /boot/loader.conf and doesn't really use /etc/fstab. > >Another possibility I was thinking of was to create GEOM providers for > >both names and orphan the other name once one of them is opened for > >writing. > > I've even implemented patch (posted on current@) with close idea (I > was creating extra geom with legacy name), and it will have the same > problem: if somebody open any partition on the device with the new > name, all legacy names will become inaccessible (busy), and vice > versa. It could be not a big problem if it would only be user's > choice -- we could say just: "use one or another, not both". But > provider could be chosen blindly by some GEOM class, such as glabel, > and then it turns into pure lottery. Good point. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpbM2D7HFR36.pgp Description: PGP signature
Re: svn commit: r220982 - in head: . sys/amd64/conf sys/arm/conf sys/conf sys/i386/conf sys/ia64/conf sys/mips/conf sys/mips/malta sys/pc98/conf sys/powerpc/conf sys/sparc64/conf sys/sun4v/conf
On Tue, Apr 26, 2011 at 10:19:55AM +0300, Alexander Motin wrote: > On 26.04.2011 10:00, Pawel Jakub Dawidek wrote: > >On Mon, Apr 25, 2011 at 08:34:33PM +0300, Alexander Motin wrote: > >>I've thought about the process of fixing hardcoded provider names there, > >>and it is absolutely not trivial. If we take the "symlinking" way (patch > >>is already posted to current@), I think it will be much easier for > >>everybody, and especially users, if I hack all mentioned above GEOM > >>classes to ignore adX/adaY difference in provider names. And it should > >>perfectly fit into remaining time window. > > > >Could you be more specific what the hack would do exactly? > > I would write some comparison function, which would search both > names for adX/adaY prefixes, if they found on both arguments, > trimmed them and compared remaining parts. > > I think for usual purpose of name hardcoding device name part is > less important. Comparing partition names part should be enough. The > tricky part there is to properly identify device part, so I was > thinking about specific hack for adX/adaY. I was wondering how would you match X and Y, but this is indeed not important. So on taste we could do (totally untested): static bool provider_name_matches(const char *ppname, const char *hcname) { if (strcmp(ppname, hcname) == 0) return (true); if (strncmp(hcname, "ad", 2) != 0 || hcname[2] < '0' || hcname[2] > '9') { return (false); } if (strncmp(ppname, "ada", 3) != 0 || ppname[3] < '0' || ppname[3] > '9') { return (false); } /* Skip 'ad[0-9]+'. */ hcname += 3; while (hcname[0] >= '0' && hcname[0] <= '9') hcname++; /* Skip 'ada[0-9]+'. ppname += 4; while (ppname[0] >= '0' && ppname[0] <= '9') ppname++; return (strcmp(ppname, hcname) == 0); } That could work. Another possibility I was thinking of was to create GEOM providers for both names and orphan the other name once one of them is opened for writing. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgp0hHvc9o0AW.pgp Description: PGP signature
Re: svn commit: r220982 - in head: . sys/amd64/conf sys/arm/conf sys/conf sys/i386/conf sys/ia64/conf sys/mips/conf sys/mips/malta sys/pc98/conf sys/powerpc/conf sys/sparc64/conf sys/sun4v/conf
On Mon, Apr 25, 2011 at 12:16:22PM -0700, Garrett Cooper wrote: > I'd prefer having an UPDATING note with all of the affected areas so that > people can understand what needs to change and adjust their systems > accordingly. As far as geom based hardcoding is concerned: maybe this can > serve as a good lesson of what shouldn't be done and what should be > fixed/have a translation layer added for this item? Hardcoding provider names in metadata is not mistake. It was added to protect against hacks like the 'c' partition. In the system there might be serval providers representing exactly same data and hardcoding provider name allows to choose the proper one. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpYmjKQaLxPU.pgp Description: PGP signature
Re: svn commit: r220982 - in head: . sys/amd64/conf sys/arm/conf sys/conf sys/i386/conf sys/ia64/conf sys/mips/conf sys/mips/malta sys/pc98/conf sys/powerpc/conf sys/sparc64/conf sys/sun4v/conf
On Mon, Apr 25, 2011 at 08:34:33PM +0300, Alexander Motin wrote: > I've thought about the process of fixing hardcoded provider names there, > and it is absolutely not trivial. If we take the "symlinking" way (patch > is already posted to current@), I think it will be much easier for > everybody, and especially users, if I hack all mentioned above GEOM > classes to ignore adX/adaY difference in provider names. And it should > perfectly fit into remaining time window. Could you be more specific what the hack would do exactly? -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgppYnWTQh2id.pgp Description: PGP signature
Re: svn commit: r220982 - in head: . sys/amd64/conf sys/arm/conf sys/conf sys/i386/conf sys/ia64/conf sys/mips/conf sys/mips/malta sys/pc98/conf sys/powerpc/conf sys/sparc64/conf sys/sun4v/conf
On Sun, Apr 24, 2011 at 06:59:40PM +, Bjoern A. Zeeb wrote: > I had been pondering devfs "link"s myself, the problem is that from the rc > framework they come too late. If you can add a simple .ko that does it > programmatically on 9 that would be great. The problem is that after booting > the new kernel you don't know whether people had ATA_STATIC on or not, so > we'd have to go with the defaults, that were in 8.x (and an extra tunable to > flip the logic maybe)? We do know that people have ATA_STATIC_ID, because if they don't, this means they have their custom kernel config which doesn't contain ATA_CAM and when they will use it next time they recompile their kernel they will still have /dev/adX entries. Also, as Alexander already noted, because of all the problems with ATA naming over the years and for other reasons too, people often hardcode provider name in various GEOM classes metadata, so symlink won't help. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgphYasTLOfQ1.pgp Description: PGP signature
Re: svn commit: r220983 - head
On Sun, Apr 24, 2011 at 05:25:00AM -0500, Dan Mack wrote: > For those of us using a ZFS root pool built out of /dev/gpt/ > devices, will these automagically pick up the new names? Even if you use adX devices in your ZFS pool and they will suddenly change to adaY, ZFS should detect this properly and no manual intervention should be needed. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpjNffXu8RSN.pgp Description: PGP signature
svn commit: r220984 - head/sys/geom/eli
Author: pjd Date: Sun Apr 24 10:41:13 2011 New Revision: 220984 URL: http://svn.freebsd.org/changeset/base/220984 Log: One key is expected from providers smaller than or equal to (2^20)*sectorsize bytes. Remove bogus assertion and while here remove another too obvious assertion. Reported by: Fabian Keil MFC after:2 weeks Modified: head/sys/geom/eli/g_eli_key_cache.c Modified: head/sys/geom/eli/g_eli_key_cache.c == --- head/sys/geom/eli/g_eli_key_cache.c Sun Apr 24 09:23:08 2011 (r220983) +++ head/sys/geom/eli/g_eli_key_cache.c Sun Apr 24 10:41:13 2011 (r220984) @@ -263,12 +263,6 @@ g_eli_key_hold(struct g_eli_softc *sc, o if ((sc->sc_flags & G_ELI_FLAG_SINGLE_KEY) != 0) return (sc->sc_ekey); - KASSERT(sc->sc_ekeys_total > 1, ("%s: sc_ekeys_total=%ju", __func__, - (uintmax_t)sc->sc_ekeys_total)); - KASSERT((sc->sc_flags & G_ELI_FLAG_SINGLE_KEY) == 0, - ("%s: SINGLE_KEY flag set, but sc_ekeys_total=%ju", __func__, - (uintmax_t)sc->sc_ekeys_total)); - /* We switch key every 2^G_ELI_KEY_SHIFT blocks. */ keyno = (offset >> G_ELI_KEY_SHIFT) / blocksize; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r220930 - head/sys/conf
Author: pjd Date: Thu Apr 21 21:15:11 2011 New Revision: 220930 URL: http://svn.freebsd.org/changeset/base/220930 Log: Add g_eli_key_cache.c to GELI. MFC after:2 weeks Modified: head/sys/conf/files Modified: head/sys/conf/files == --- head/sys/conf/files Thu Apr 21 20:56:34 2011(r220929) +++ head/sys/conf/files Thu Apr 21 21:15:11 2011(r220930) @@ -2101,6 +2101,7 @@ geom/eli/g_eli_crypto.c optional geom_e geom/eli/g_eli_ctl.c optional geom_eli geom/eli/g_eli_integrity.c optional geom_eli geom/eli/g_eli_key.c optional geom_eli +geom/eli/g_eli_key_cache.c optional geom_eli geom/eli/g_eli_privacy.c optional geom_eli geom/eli/pkcs5v2.c optional geom_eli geom/gate/g_gate.c optional geom_gate ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r220923 - head/sys/geom/eli
Author: pjd Date: Thu Apr 21 13:35:20 2011 New Revision: 220923 URL: http://svn.freebsd.org/changeset/base/220923 Log: If number of keys for the given provider doesn't exceed the limit, allocate all of them at attach time. This allows to avoid moving keys around in the most-recently-used queue and needs no mutex synchronization nor refcounting. MFC after:2 weeks Modified: head/sys/geom/eli/g_eli_key_cache.c Modified: head/sys/geom/eli/g_eli_key_cache.c == --- head/sys/geom/eli/g_eli_key_cache.c Thu Apr 21 13:31:43 2011 (r220922) +++ head/sys/geom/eli/g_eli_key_cache.c Thu Apr 21 13:35:20 2011 (r220923) @@ -217,6 +217,16 @@ g_eli_key_init(struct g_eli_softc *sc) sc->sc_ekeys_allocated = 0; TAILQ_INIT(&sc->sc_ekeys_queue); RB_INIT(&sc->sc_ekeys_tree); + if (sc->sc_ekeys_total <= g_eli_key_cache_limit) { + uint64_t keyno; + + for (keyno = 0; keyno < sc->sc_ekeys_total; keyno++) + (void)g_eli_key_allocate(sc, keyno); + KASSERT(sc->sc_ekeys_total == sc->sc_ekeys_allocated, + ("sc_ekeys_total=%ju != sc_ekeys_allocated=%ju", + (uintmax_t)sc->sc_ekeys_total, + (uintmax_t)sc->sc_ekeys_allocated)); + } } mtx_unlock(&sc->sc_ekeys_lock); } @@ -268,6 +278,13 @@ g_eli_key_hold(struct g_eli_softc *sc, o keysearch.gek_keyno = keyno; + if (sc->sc_ekeys_total == sc->sc_ekeys_allocated) { + /* We have all the keys, so avoid some overhead. */ + key = RB_FIND(g_eli_key_tree, &sc->sc_ekeys_tree, &keysearch); + KASSERT(key != NULL, ("No key %ju found.", (uintmax_t)keyno)); + return (key->gek_key); + } + mtx_lock(&sc->sc_ekeys_lock); key = RB_FIND(g_eli_key_tree, &sc->sc_ekeys_tree, &keysearch); if (key != NULL) { @@ -306,6 +323,9 @@ g_eli_key_drop(struct g_eli_softc *sc, u if ((sc->sc_flags & G_ELI_FLAG_SINGLE_KEY) != 0) return; + if (sc->sc_ekeys_total == sc->sc_ekeys_allocated) + return; + mtx_lock(&sc->sc_ekeys_lock); KASSERT(key->gek_count > 0, ("key->gek_count=%d", key->gek_count)); key->gek_count--; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r220922 - in head/sys: geom/eli modules/geom/geom_eli
Author: pjd Date: Thu Apr 21 13:31:43 2011 New Revision: 220922 URL: http://svn.freebsd.org/changeset/base/220922 Log: Instead of allocating memory for all the keys at device attach, create reasonably large cache for the keys that is filled when needed. The previous version was problematic for very large providers (hundreds of terabytes or serval petabytes). Every terabyte of data needs around 256kB for keys. Make the default cache limit big enough to fit all the keys needed for 4TB providers, which will eat at most 1MB of memory. MFC after:2 weeks Added: head/sys/geom/eli/g_eli_key_cache.c (contents, props changed) Modified: head/sys/geom/eli/g_eli.c head/sys/geom/eli/g_eli.h head/sys/geom/eli/g_eli_ctl.c head/sys/geom/eli/g_eli_integrity.c head/sys/geom/eli/g_eli_key.c head/sys/geom/eli/g_eli_privacy.c head/sys/modules/geom/geom_eli/Makefile Modified: head/sys/geom/eli/g_eli.c == --- head/sys/geom/eli/g_eli.c Thu Apr 21 12:38:12 2011(r220921) +++ head/sys/geom/eli/g_eli.c Thu Apr 21 13:31:43 2011(r220922) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2005-2010 Pawel Jakub Dawidek + * Copyright (c) 2005-2011 Pawel Jakub Dawidek * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -329,7 +329,7 @@ g_eli_newsession(struct g_eli_worker *wr crie.cri_klen = sc->sc_ekeylen; if (sc->sc_ealgo == CRYPTO_AES_XTS) crie.cri_klen <<= 1; - crie.cri_key = sc->sc_ekeys[0]; + crie.cri_key = sc->sc_ekey; if (sc->sc_flags & G_ELI_FLAG_AUTH) { bzero(&cria, sizeof(cria)); cria.cri_alg = sc->sc_aalgo; @@ -522,34 +522,6 @@ again: } /* - * Select encryption key. If G_ELI_FLAG_SINGLE_KEY is present we only have one - * key available for all the data. If the flag is not present select the key - * based on data offset. - */ -uint8_t * -g_eli_crypto_key(struct g_eli_softc *sc, off_t offset, size_t blocksize) -{ - u_int nkey; - - if (sc->sc_nekeys == 1) - return (sc->sc_ekeys[0]); - - KASSERT(sc->sc_nekeys > 1, ("%s: sc_nekeys=%u", __func__, - sc->sc_nekeys)); - KASSERT((sc->sc_flags & G_ELI_FLAG_SINGLE_KEY) == 0, - ("%s: SINGLE_KEY flag set, but sc_nekeys=%u", __func__, - sc->sc_nekeys)); - - /* We switch key every 2^G_ELI_KEY_SHIFT blocks. */ - nkey = (offset >> G_ELI_KEY_SHIFT) / blocksize; - - KASSERT(nkey < sc->sc_nekeys, ("%s: nkey=%u >= sc_nekeys=%u", __func__, - nkey, sc->sc_nekeys)); - - return (sc->sc_ekeys[nkey]); -} - -/* * Here we generate IV. It is unique for every sector. */ void @@ -766,6 +738,7 @@ g_eli_create(struct gctl_req *req, struc bioq_init(&sc->sc_queue); mtx_init(&sc->sc_queue_mtx, "geli:queue", NULL, MTX_DEF); + mtx_init(&sc->sc_ekeys_lock, "geli:ekeys", NULL, MTX_DEF); pp = NULL; cp = g_new_consumer(gp); @@ -909,11 +882,7 @@ failed: } g_destroy_consumer(cp); g_destroy_geom(gp); - if (sc->sc_ekeys != NULL) { - bzero(sc->sc_ekeys, - sc->sc_nekeys * (sizeof(uint8_t *) + G_ELI_DATAKEYLEN)); - free(sc->sc_ekeys, M_ELI); - } + g_eli_key_destroy(sc); bzero(sc, sizeof(*sc)); free(sc, M_ELI); return (NULL); @@ -953,12 +922,7 @@ g_eli_destroy(struct g_eli_softc *sc, bo } mtx_destroy(&sc->sc_queue_mtx); gp->softc = NULL; - if (sc->sc_ekeys != NULL) { - /* The sc_ekeys field can be NULL is device is suspended. */ - bzero(sc->sc_ekeys, - sc->sc_nekeys * (sizeof(uint8_t *) + G_ELI_DATAKEYLEN)); - free(sc->sc_ekeys, M_ELI); - } + g_eli_key_destroy(sc); bzero(sc, sizeof(*sc)); free(sc, M_ELI); @@ -1191,6 +1155,11 @@ g_eli_dumpconf(struct sbuf *sb, const ch return; if (pp != NULL || cp != NULL) return; /* Nothing here. */ + + sbuf_printf(sb, "%s%ju", indent, + (uintmax_t)sc->sc_ekeys_total); + sbuf_printf(sb, "%s%ju", indent, + (uintmax_t)sc->sc_ekeys_allocated); sbuf_printf(sb, "%s", indent); if (sc->sc_flags == 0) sbuf_printf(sb, "NONE"); Modified: head/sys/geom/eli/g_eli.h ========== --- head/sys/geom/eli/g_eli.h Thu Apr 21 12:38:12 2011(r220921) +++ head/sys/geom/eli/g_eli.h Thu Apr 21 13:31:43 2011(r220922) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 200
svn commit: r220899 - head/sbin/hastd
Author: pjd Date: Wed Apr 20 18:49:12 2011 New Revision: 220899 URL: http://svn.freebsd.org/changeset/base/220899 Log: Correct comment. MFC after:1 week Modified: head/sbin/hastd/hastd.c Modified: head/sbin/hastd/hastd.c == --- head/sbin/hastd/hastd.c Wed Apr 20 18:43:28 2011(r220898) +++ head/sbin/hastd/hastd.c Wed Apr 20 18:49:12 2011(r220899) @@ -739,7 +739,7 @@ listen_accept(void) if (res->hr_role == HAST_ROLE_PRIMARY) { /* * If we act as primary request the other side to wait -* for us for a bit, as may might be finishing cleanups. +* for us a bit, as we might be finishing cleanups. */ nv_add_uint8(nverr, 1, "wait"); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r220898 - head/sbin/hastd
Author: pjd Date: Wed Apr 20 18:43:28 2011 New Revision: 220898 URL: http://svn.freebsd.org/changeset/base/220898 Log: When we become primary, we connect to the remote and expect it to be in secondary role. It is possible that the remote node is primary, but only because there was a role change and it didn't finish cleaning up (unmounting file systems, etc.). If we detect such situation, wait for the remote node to switch the role to secondary before accepting I/Os. If we don't wait for it in that case, we will most likely cause split-brain. MFC after:1 week Modified: head/sbin/hastd/hastd.c head/sbin/hastd/primary.c Modified: head/sbin/hastd/hastd.c == --- head/sbin/hastd/hastd.c Wed Apr 20 18:04:34 2011(r220897) +++ head/sbin/hastd/hastd.c Wed Apr 20 18:43:28 2011(r220898) @@ -736,6 +736,13 @@ listen_accept(void) nv_add_stringf(nverr, "errmsg", "Remote node acts as %s for the resource and not as %s.", role2str(res->hr_role), role2str(HAST_ROLE_SECONDARY)); + if (res->hr_role == HAST_ROLE_PRIMARY) { + /* +* If we act as primary request the other side to wait +* for us for a bit, as may might be finishing cleanups. +*/ + nv_add_uint8(nverr, 1, "wait"); + } goto fail; } /* Does token (if exists) match? */ Modified: head/sbin/hastd/primary.c == --- head/sbin/hastd/primary.c Wed Apr 20 18:04:34 2011(r220897) +++ head/sbin/hastd/primary.c Wed Apr 20 18:43:28 2011(r220898) @@ -219,6 +219,7 @@ static pthread_cond_t range_regular_cond static struct rangelocks *range_sync; static bool range_sync_wait; static pthread_cond_t range_sync_cond; +static bool fullystarted; static void *ggate_recv_thread(void *arg); static void *local_send_thread(void *arg); @@ -524,7 +525,7 @@ primary_connect(struct hast_resource *re return (0); } -static bool +static int init_remote(struct hast_resource *res, struct proto_conn **inp, struct proto_conn **outp) { @@ -537,6 +538,7 @@ init_remote(struct hast_resource *res, s int64_t datasize; uint32_t mapsize; size_t size; + int error; PJDLOG_ASSERT((inp == NULL && outp == NULL) || (inp != NULL && outp != NULL)); PJDLOG_ASSERT(real_remote(res)); @@ -545,7 +547,9 @@ init_remote(struct hast_resource *res, s errmsg = NULL; if (primary_connect(res, &out) == -1) - return (false); + return (ECONNREFUSED); + + error = ECONNABORTED; /* * First handshake step. @@ -577,6 +581,8 @@ init_remote(struct hast_resource *res, s errmsg = nv_get_string(nvin, "errmsg"); if (errmsg != NULL) { pjdlog_warning("%s", errmsg); + if (nv_exists(nvin, "wait")) + error = EBUSY; nv_free(nvin); goto close; } @@ -734,14 +740,14 @@ init_remote(struct hast_resource *res, s res->hr_remoteout = out; } event_send(res, EVENT_CONNECT); - return (true); + return (0); close: if (errmsg != NULL && strcmp(errmsg, "Split-brain condition!") == 0) event_send(res, EVENT_SPLITBRAIN); proto_close(out); if (in != NULL) proto_close(in); - return (false); + return (error); } static void @@ -920,8 +926,30 @@ hastd_primary(struct hast_resource *res) */ error = pthread_create(&td, NULL, ctrl_thread, res); PJDLOG_ASSERT(error == 0); - if (real_remote(res) && init_remote(res, NULL, NULL)) - sync_start(); + if (real_remote(res)) { + error = init_remote(res, NULL, NULL); + if (error == 0) { + sync_start(); + } else if (error == EBUSY) { + time_t start = time(NULL); + + pjdlog_warning("Waiting for remote node to become %s for %ds.", + role2str(HAST_ROLE_SECONDARY), + res->hr_timeout); + for (;;) { + sleep(1); + error = init_remote(res, NULL, NULL); + if (error != EBUSY) + break; + if (time(NULL) > start + res->hr_timeout) + break; + } + if (error == EBUSY) { + pjdlog_warning("Remote node is still %s, starting anyway.", +
svn commit: r220890 - head/sbin/hastd
Author: pjd Date: Wed Apr 20 16:38:05 2011 New Revision: 220890 URL: http://svn.freebsd.org/changeset/base/220890 Log: If we act in different role than requested by the remote node, log it as a warning and not an error. MFC after:1 week Modified: head/sbin/hastd/hastd.c Modified: head/sbin/hastd/hastd.c == --- head/sbin/hastd/hastd.c Wed Apr 20 16:36:59 2011(r220889) +++ head/sbin/hastd/hastd.c Wed Apr 20 16:38:05 2011(r220890) @@ -730,7 +730,7 @@ listen_accept(void) } /* Is the resource marked as secondary? */ if (res->hr_role != HAST_ROLE_SECONDARY) { - pjdlog_error("We act as %s for the resource and not as %s as requested by %s.", + pjdlog_warning("We act as %s for the resource and not as %s as requested by %s.", role2str(res->hr_role), role2str(HAST_ROLE_SECONDARY), raddr); nv_add_stringf(nverr, "errmsg", ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r220889 - head/sbin/hastd
Author: pjd Date: Wed Apr 20 16:36:59 2011 New Revision: 220889 URL: http://svn.freebsd.org/changeset/base/220889 Log: Timeout must be positive. MFC after:1 week Modified: head/sbin/hastd/parse.y Modified: head/sbin/hastd/parse.y == --- head/sbin/hastd/parse.y Wed Apr 20 14:19:34 2011(r220888) +++ head/sbin/hastd/parse.y Wed Apr 20 16:36:59 2011(r220889) @@ -461,6 +461,10 @@ compression_type: timeout_statement: TIMEOUT NUM { + if ($2 <= 0) { + pjdlog_error("Negative or zero timeout."); + return (1); + } switch (depth) { case 0: depth0_timeout = $2; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r220877 - head/sys/fs/nfsclient
On Wed, Apr 20, 2011 at 08:09:32AM -0400, Rick Macklem wrote: > > > + tmp_off = uio->uio_offset + uio->uio_resid; > > > + mtx_lock(&nmp->nm_mtx); > > > + if (tmp_off > nmp->nm_maxfilesize || tmp_off < uio->uio_offset) { > > > + mtx_unlock(&nmp->nm_mtx); > > > return (EFBIG); > > > + } > > > + mtx_unlock(&nmp->nm_mtx); > > > > I don't think you need the lock to protect nm_maxfilesize. Can it > > change > > from under us? My guess is that it is set on mount time and is not > > modified afterwards. > > > Good question. > For NFSv3 - it is only modified by the first fsinfo RPC and that normally > happens at mount time, as you guessed above. (This is consistent with > RFC1813, which defines the fsinfo RPC as getting non-volatile > information.) > For NFSv4 - it gets it each time VFS_STATFS() happens. I am not sure that > this is correct, but I don't know of anywhere in RFC3530 where it states > that this attribute will not change. In practice, I suspect that servers > seldom, if ever, change it. > > So, it is unlikely to change and I'd be comfortable taking the mutex lock > off the check for it, if others are? (As you might be aware, I started a > thread on hackers-freebsd@ where my question was basically "do you need to > mutex lock when you read a global variable". My main concern there was a > case that I'm working on w.r.t. forced dismounts. jhb@ suggested that he > thinks it is good practice to always lock, to play it safe. At least that > was my interpretation?) This is not that easy, I'm afraid. You need to ask yourself a question what you are trying to protect from. Here, the mutex only guarantees to have consistent view of the nm_maxfilesize field. For example if this field modification wouldn't be atomic you would need the mutex to ensure that the value is correct. Imagine a situation where it is modifed not by simple 'a = b', but by something like this: mtx_lock(&nmp->nm_mtx); nmp->nm_maxfilesize = some_32bit_array[0]; nmp->nm_maxfilesize |= some_32bit_array[1] << 32; mtx_unlock(&nmp->nm_mtx); To read that properly you need a mutex to ensure you won't read the value between those two operations. If it is not the case - its modification is atomic and reading it is atomic then you don't need mutex to read the value as it will always be consistent. The question is what will happen if it changes after you read it. thread0 thread1 --- --- mtx_lock(&nmp->nm_mtx); nmp->nm_maxfilesize = 8192; mtx_unlock(&nmp->nm_mtx); mtx_lock(&nmp->nm_mtx); if (tmp_off > nmp->nm_maxfilesize) { mtx_unlock(&nmp->nm_mtx); return (EFBIG); } mtx_unlock(&nmp->nm_mtx); mtx_lock(&nmp->nm_mtx); nmp->nm_maxfilesize = 2048; mtx_unlock(&nmp->nm_mtx); Now, if tmp_off is 4096 what will happen if you have a race like the above? Is it critical? Then you need to protect with this mutex as well. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpgonzRkKE9U.pgp Description: PGP signature
Re: svn commit: r220877 - head/sys/fs/nfsclient
On Wed, Apr 20, 2011 at 01:15:22AM +, Rick Macklem wrote: > Author: rmacklem > Date: Wed Apr 20 01:15:22 2011 > New Revision: 220877 > URL: http://svn.freebsd.org/changeset/base/220877 > > Log: > Modify the offset + size checks for read and write in the > experimental NFS client to take care of overflows for the calls > above the buffer cache layer in a manner similar to r220876. > Thanks go to dillon at apollo.backplane.com for providing the > snippet of code that does this. [...] > + tmp_off = uio->uio_offset + uio->uio_resid; > + mtx_lock(&nmp->nm_mtx); > + if (tmp_off > nmp->nm_maxfilesize || tmp_off < uio->uio_offset) { > + mtx_unlock(&nmp->nm_mtx); > return (EFBIG); > + } > + mtx_unlock(&nmp->nm_mtx); I don't think you need the lock to protect nm_maxfilesize. Can it change from under us? My guess is that it is set on mount time and is not modified afterwards. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgppFrhLwoiAo.pgp Description: PGP signature
svn commit: r220865 - head/sbin/hastd
Author: pjd Date: Tue Apr 19 19:26:27 2011 New Revision: 220865 URL: http://svn.freebsd.org/changeset/base/220865 Log: Scenario: - We have two nodes connected and synchronized (local counters on both sides are 0). - We take secondary down and recreate it. - Primary connects to it and starts synchronization (but local counters are still 0). - We switch the roles. - Synchronization restarts but data is synchronized now from new primary (because local counters are 0) that doesn't have new data yet. This fix this issue we bump local counter on primary when we discover that connected secondary was recreated and has no data yet. Reported by: trociny Discussed with: trociny Tested by:trociny MFC after:1 week Modified: head/sbin/hastd/primary.c head/sbin/hastd/secondary.c Modified: head/sbin/hastd/primary.c == --- head/sbin/hastd/primary.c Tue Apr 19 18:18:02 2011(r220864) +++ head/sbin/hastd/primary.c Tue Apr 19 19:26:27 2011(r220865) @@ -667,6 +667,25 @@ init_remote(struct hast_resource *res, s res->hr_secondary_localcnt = nv_get_uint64(nvin, "localcnt"); res->hr_secondary_remotecnt = nv_get_uint64(nvin, "remotecnt"); res->hr_syncsrc = nv_get_uint8(nvin, "syncsrc"); + if (nv_exists(nvin, "virgin")) { + /* +* Secondary was reinitialized, bump localcnt if it is 0 as +* only we have the data. +*/ + PJDLOG_ASSERT(res->hr_syncsrc == HAST_SYNCSRC_PRIMARY); + PJDLOG_ASSERT(res->hr_secondary_localcnt == 0); + + if (res->hr_primary_localcnt == 0) { + PJDLOG_ASSERT(res->hr_secondary_remotecnt == 0); + + mtx_lock(&metadata_lock); + res->hr_primary_localcnt++; + pjdlog_debug(1, "Increasing localcnt to %ju.", + (uintmax_t)res->hr_primary_localcnt); + (void)metadata_write(res); + mtx_unlock(&metadata_lock); + } + } map = NULL; mapsize = nv_get_uint32(nvin, "mapsize"); if (mapsize > 0) { Modified: head/sbin/hastd/secondary.c == --- head/sbin/hastd/secondary.c Tue Apr 19 18:18:02 2011(r220864) +++ head/sbin/hastd/secondary.c Tue Apr 19 19:26:27 2011(r220865) @@ -261,6 +261,7 @@ init_remote(struct hast_resource *res, s } else { memset(map, 0xff, mapsize); } + nv_add_int8(nvout, 1, "virgin"); nv_add_uint8(nvout, HAST_SYNCSRC_PRIMARY, "syncsrc"); } else if (res->hr_resuid != resuid) { char errmsg[256]; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r220791 - in head: lib/libc/sys sys/compat/freebsd32 sys/kern sys/sys
On Mon, Apr 18, 2011 at 11:13:02PM +0300, Kostik Belousov wrote: > > The need is, as commented, to return EFBIG when the new file size will > > be larger than the FS supports. Without this code, passing in > > something like posix_fallocate(fd, 0, OFF_MAX) will run the filesystem > > out of space. > Handling max file size and not overflowing the fs are different things. > VOP_WRITE() will handle file size on its own too. I see no problem with > exhausting free space if this is what user asked for. This makes me wonder that current implementation isn't atomic. If we get out of space error, we won't shrink the file back. Even if we could shirk it at the end, we won't be able to put holes in the middle of it. Not sure if this is a big issue, but one doesn't expect from rename(2) to create new link and not remove old one. All in all, making it atomic would be impossible currently for various reasons (we can't put holes back and we can crash in the middle). -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpaERe1jUaAu.pgp Description: PGP signature
Re: svn commit: r220791 - in head: lib/libc/sys sys/compat/freebsd32 sys/kern sys/sys
On Mon, Apr 18, 2011 at 10:28:10PM +0300, Kostik Belousov wrote: > > + if (offset + len > vap->va_size) { > > + VATTR_NULL(vap); > > + vap->va_size = offset + len; > > + error = VOP_SETATTR(vp, vap, td->td_ucred); > > + if (error != 0) > > + goto out; > > + } > I still do not see a reason to do VOP_SETATTR() there. VOP_WRITE() will > do auto-extend as needed. Also, see below. Yeah, also when we extend file size we could skip reading zeros. > > + if (offset < vap->va_size) { [...] > > + } else { > > + bzero(buf, cur); > > + } > Wouldn't VOP_SETATTR() at the start of the function mostly prevent > this bzero from executing ? Once we drop the vnode lock, the file size can change under us, no? > I estimated what it would take to do the optimized implementation for UFS, > and I think that the following change would allow to lessen the code > duplication much. > > What if the vnode lock drop and looping be handled by the syscall, instead > of the vop implementation ? In other words, allow the VOP_ALLOCATE() > to allocate less then requested, and return the allocated amount to > the caller. The loop would be centralized then, freeing fs from doing > the dance. Also, if fs considers that suitable, it would do a whole > allocation in one run. I'd still go with SEEK_DATA/SEEK_HOLE loop as I suggested on arch@. If you would like to spend time on it, having SEEK_DATA/SEEK_HOLE support in UFS would be beneficial for other purposes too. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgp1qSb3OEnrS.pgp Description: PGP signature
Re: svn commit: r220755 - in head: . contrib/gcc/doc contrib/gcc/objc contrib/libobjc etc/mtree gnu/lib gnu/lib/libobjc gnu/usr.bin/cc gnu/usr.bin/cc/cc1obj gnu/usr.bin/cc/cc_tools gnu/usr.bin/cc/doc
On Mon, Apr 18, 2011 at 11:06:42AM -0600, Warner Losh wrote: > > On Apr 18, 2011, at 1:01 AM, Roman Divacky wrote: > > > please mark this in src/UPDATING, maybe bump freebsd_version too? > > Please do not bump freebsd_version just for this. Ports wishing to know can > go off the last bump, if there are any. > > Every freebsd_version bump forces rebuilding all modules and such and is a > pita. I agree that this is a PITA, but there also should be a way to force module load even on version bump. This is PITA especially for developers. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpurWxPsKu5d.pgp Description: PGP signature
Re: svn commit: r220559 - in head/sys: conf geom
e_int_value("map", i, "offset", &off); > + ret = resource_int_value("map", i, "readonly", &readonly); > + ret = resource_string_value("map", i, "name", &name); > + /* No name or error read name */ > + if (ret) > + continue; First and second 'ret' is not checked. > + if (off > size) > + printf("%s: off(%d) > size(%d) for \"%s\"\n", > + __func__, off, size, name); Is this a leftover debug printf? > + error = g_slice_config(gp, i, G_SLICE_CONFIG_SET, start + off, > + size - off, sectorsize, "map/%s", name); Four spaces. > + printf("MAP: %08x-%08x, offset=%08x \"map/%s\"\n", > +(uint32_t) start, > +(uint32_t) size, > +(uint32_t) off, > +name > +); Four spaces. Not need to separate cast and variable with space. > + if (error) > + printf("%s g_slice_config returns %d for \"%s\"\n", > + __func__, error, name); Leftover debug printf? > + sc->entry[i] = off; > + sc->dsize[i] = size - off; > + sc->readonly[i] = readonly ? 1 : 0; > + } > + > + > + if (i == 0) > + return (NULL); Redundant empty line before 'if'. > +static void > +g_map_config(struct gctl_req *req, struct g_class *mp, const char *verb) > +{ > + struct g_geom *gp; > + > + g_topology_assert(); > + gp = gctl_get_geom(req, mp, "geom"); > + if (gp == NULL) > + return; > + gctl_error(req, "Unknown verb"); > +} Seems to be a no-op. GEOM can cope if this method is not specified. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpUjqhWplxsh.pgp Description: PGP signature
svn commit: r220575 - head/cddl/contrib/opensolaris/lib/libzfs/common
Author: pjd Date: Tue Apr 12 20:31:33 2011 New Revision: 220575 URL: http://svn.freebsd.org/changeset/base/220575 Log: Fix 'zfs list ' handling. If the path was found, the 'ret' variable was uninitialized. PR: kern/155940 Submitted by: KOIE Hidetaka MFC after:1 week Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c == --- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Tue Apr 12 20:10:15 2011(r220574) +++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Tue Apr 12 20:31:33 2011(r220575) @@ -734,12 +734,13 @@ zfs_path_to_zhandle(libzfs_handle_t *hdl { struct statfs sfs; - if (statfs(path, &sfs) != 0) { + ret = statfs(path, &sfs); + if (ret == 0) + statfs2mnttab(&sfs, &entry); + else { (void) fprintf(stderr, "%s: %s\n", path, strerror(errno)); - ret = -1; } - statfs2mnttab(&sfs, &entry); } #endif /* sun */ if (ret != 0) { ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r220573 - head/sbin/hastd
Author: pjd Date: Tue Apr 12 19:13:10 2011 New Revision: 220573 URL: http://svn.freebsd.org/changeset/base/220573 Log: The replication mode that is currently support is fullsync, not memsync. Correct this and print a warning if different replication mode is configured. MFC after:1 week Modified: head/sbin/hastd/parse.y Modified: head/sbin/hastd/parse.y == --- head/sbin/hastd/parse.y Tue Apr 12 17:02:40 2011(r220572) +++ head/sbin/hastd/parse.y Tue Apr 12 19:13:10 2011(r220573) @@ -169,7 +169,7 @@ yy_config_parse(const char *config, bool lineno = 0; depth0_timeout = HAST_TIMEOUT; - depth0_replication = HAST_REPLICATION_MEMSYNC; + depth0_replication = HAST_REPLICATION_FULLSYNC; depth0_checksum = HAST_CHECKSUM_NONE; depth0_compression = HAST_COMPRESSION_HOLE; strlcpy(depth0_control, HAST_CONTROL, sizeof(depth0_control)); @@ -228,6 +228,13 @@ yy_config_parse(const char *config, bool */ curres->hr_replication = depth0_replication; } + if (curres->hr_replication == HAST_REPLICATION_MEMSYNC || + curres->hr_replication == HAST_REPLICATION_ASYNC) { + pjdlog_warning("Replication mode \"%s\" is not implemented, falling back to \"%s\".", + curres->hr_replication == HAST_REPLICATION_MEMSYNC ? + "memsync" : "async", "fullsync"); + curres->hr_replication = HAST_REPLICATION_FULLSYNC; + } if (curres->hr_checksum == -1) { /* * Checksum is not set at resource-level. ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r220274 - head/sbin/hastd
Author: pjd Date: Sat Apr 2 09:34:33 2011 New Revision: 220274 URL: http://svn.freebsd.org/changeset/base/220274 Log: Increase default timeout from 5 seconds to 20 seconds. 5 seconds is definitely to short under heavy load and I was experiencing those timeouts in my recent tests. MFC after:1 week Modified: head/sbin/hastd/hast.conf.5 head/sbin/hastd/hast.h Modified: head/sbin/hastd/hast.conf.5 == --- head/sbin/hastd/hast.conf.5 Sat Apr 2 09:31:02 2011(r220273) +++ head/sbin/hastd/hast.conf.5 Sat Apr 2 09:34:33 2011(r220274) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 20, 2011 +.Dd April 2, 2011 .Dt HAST.CONF 5 .Os .Sh NAME @@ -241,7 +241,7 @@ LZF is very fast, general purpose compre .Pp Connection timeout in seconds. The default value is -.Va 5 . +.Va 20 . .It Ic exec Aq path .Pp Execute the given program on various HAST events. Modified: head/sbin/hastd/hast.h == --- head/sbin/hastd/hast.h Sat Apr 2 09:31:02 2011(r220273) +++ head/sbin/hastd/hast.h Sat Apr 2 09:34:33 2011(r220274) @@ -83,7 +83,7 @@ #defineHIO_KEEPALIVE 5 #defineHAST_USER "hast" -#defineHAST_TIMEOUT5 +#defineHAST_TIMEOUT20 #defineHAST_CONFIG "/etc/hast.conf" #defineHAST_CONTROL"/var/run/hastctl" #defineHASTD_LISTEN"tcp4://0.0.0.0:8457" ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r220270 - head/sbin/hastd
On Sat, Apr 02, 2011 at 09:22:06AM +, Pawel Jakub Dawidek wrote: > Author: pjd > Date: Sat Apr 2 09:22:06 2011 > New Revision: 220270 > URL: http://svn.freebsd.org/changeset/base/220270 > > Log: > Allow to disable sends or receives on a socket using shutdown(2) by > interpreting NULL 'data' argument passed to proto_common_send() or > proto_common_recv() as a will to do so. > > MFC after: 1 month This should've been 1 week here in the next two commits. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpYIudbJw3gq.pgp Description: PGP signature
svn commit: r220273 - head/sbin/hastd
Author: pjd Date: Sat Apr 2 09:31:02 2011 New Revision: 220273 URL: http://svn.freebsd.org/changeset/base/220273 Log: Handle ENOBUFS on send(2) by retrying for a while and logging the problem. MFC after:1 week Modified: head/sbin/hastd/proto_common.c Modified: head/sbin/hastd/proto_common.c == --- head/sbin/hastd/proto_common.c Sat Apr 2 09:29:53 2011 (r220272) +++ head/sbin/hastd/proto_common.c Sat Apr 2 09:31:02 2011 (r220273) @@ -94,6 +94,7 @@ proto_common_send(int sock, const unsign { ssize_t done; size_t sendsize; + int errcount = 0; PJDLOG_ASSERT(sock >= 0); @@ -118,6 +119,23 @@ proto_common_send(int sock, const unsign } else if (done < 0) { if (errno == EINTR) continue; + if (errno == ENOBUFS) { + /* +* If there are no buffers we retry. +* After each try we increase delay before the +* next one and we give up after fifteen times. +* This gives 11s of total wait time. +*/ + if (errcount == 15) { + pjdlog_warning("Getting ENOBUFS errors for 11s on send(), giving up."); + } else { + if (errcount == 0) + pjdlog_warning("Got ENOBUFS error on send(), retrying for a bit."); + errcount++; + usleep(10 * errcount); + continue; + } + } /* * If this is blocking socket and we got EAGAIN, this * means the request timed out. Translate errno to @@ -131,6 +149,10 @@ proto_common_send(int sock, const unsign data += done; size -= done; } while (size > 0); + if (errcount > 0) { + pjdlog_info("Data sent successfully after %d ENOBUFS error%s.", + errcount, errcount == 1 ? "" : "s"); + } if (fd == -1) return (0); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r220272 - head/sbin/hastd
Author: pjd Date: Sat Apr 2 09:29:53 2011 New Revision: 220272 URL: http://svn.freebsd.org/changeset/base/220272 Log: When we are operating on blocking socket and get EAGAIN on send(2) or recv(2) this means that request timed out. Translate the meaningless EAGAIN to ETIMEDOUT to give administrator a hint that he might need to increase timeout in configuration file. MFC after:1 month Modified: head/sbin/hastd/proto_common.c Modified: head/sbin/hastd/proto_common.c == --- head/sbin/hastd/proto_common.c Sat Apr 2 09:25:13 2011 (r220271) +++ head/sbin/hastd/proto_common.c Sat Apr 2 09:29:53 2011 (r220272) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2009-2010 The FreeBSD Foundation + * Copyright (c) 2011 Pawel Jakub Dawidek * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from @@ -34,8 +35,11 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include #include #include +#include #include "pjdlog.h" #include "proto_impl.h" @@ -45,6 +49,16 @@ __FBSDID("$FreeBSD$"); #defineMAX_SEND_SIZE 32768 #endif +static bool +blocking_socket(int sock) +{ + int flags; + + flags = fcntl(sock, F_GETFL); + PJDLOG_ASSERT(flags >= 0); + return ((flags & O_NONBLOCK) == 0); +} + static int proto_descriptor_send(int sock, int fd) { @@ -99,11 +113,19 @@ proto_common_send(int sock, const unsign do { sendsize = size < MAX_SEND_SIZE ? size : MAX_SEND_SIZE; done = send(sock, data, sendsize, MSG_NOSIGNAL); - if (done == 0) + if (done == 0) { return (ENOTCONN); - else if (done < 0) { + } else if (done < 0) { if (errno == EINTR) continue; + /* +* If this is blocking socket and we got EAGAIN, this +* means the request timed out. Translate errno to +* ETIMEDOUT, to give administrator a hint to +* eventually increase timeout. +*/ + if (errno == EAGAIN && blocking_socket(sock)) + errno = ETIMEDOUT; return (errno); } data += done; @@ -169,10 +191,19 @@ proto_common_recv(int sock, unsigned cha do { done = recv(sock, data, size, MSG_WAITALL); } while (done == -1 && errno == EINTR); - if (done == 0) + if (done == 0) { return (ENOTCONN); - else if (done < 0) + } else if (done < 0) { + /* +* If this is blocking socket and we got EAGAIN, this +* means the request timed out. Translate errno to +* ETIMEDOUT, to give administrator a hint to +* eventually increase timeout. +*/ + if (errno == EAGAIN && blocking_socket(sock)) + errno = ETIMEDOUT; return (errno); + } if (fdp == NULL) return (0); return (proto_descriptor_recv(sock, fdp)); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r220271 - head/sbin/hastd
Author: pjd Date: Sat Apr 2 09:25:13 2011 New Revision: 220271 URL: http://svn.freebsd.org/changeset/base/220271 Log: Declare directions for sockets between primary and secondary. In HAST we use two sockets - one for only sending the data and one for only receiving the data. MFC after:1 month Modified: head/sbin/hastd/primary.c head/sbin/hastd/secondary.c Modified: head/sbin/hastd/primary.c == --- head/sbin/hastd/primary.c Sat Apr 2 09:22:06 2011(r220270) +++ head/sbin/hastd/primary.c Sat Apr 2 09:25:13 2011(r220271) @@ -701,6 +701,11 @@ init_remote(struct hast_resource *res, s (void)hast_activemap_flush(res); } nv_free(nvin); + /* Setup directions. */ + if (proto_send(out, NULL, 0) == -1) + pjdlog_errno(LOG_WARNING, "Unable to set connection direction"); + if (proto_recv(in, NULL, 0) == -1) + pjdlog_errno(LOG_WARNING, "Unable to set connection direction"); pjdlog_info("Connected to %s.", res->hr_remoteaddr); if (inp != NULL && outp != NULL) { *inp = in; Modified: head/sbin/hastd/secondary.c == --- head/sbin/hastd/secondary.c Sat Apr 2 09:22:06 2011(r220270) +++ head/sbin/hastd/secondary.c Sat Apr 2 09:25:13 2011(r220271) @@ -183,6 +183,10 @@ init_remote(struct hast_resource *res, s unsigned char *map; size_t mapsize; + /* Setup direction. */ + if (proto_send(res->hr_remoteout, NULL, 0) == -1) + pjdlog_errno(LOG_WARNING, "Unable to set connection direction"); + map = NULL; mapsize = 0; nvout = nv_alloc(); @@ -346,6 +350,9 @@ init_remote(struct hast_resource *res, s if (map != NULL) free(map); nv_free(nvout); + /* Setup direction. */ + if (proto_recv(res->hr_remotein, NULL, 0) == -1) + pjdlog_errno(LOG_WARNING, "Unable to set connection direction"); if (res->hr_secondary_localcnt > res->hr_primary_remotecnt && res->hr_primary_localcnt > res->hr_secondary_remotecnt) { /* Exit on split-brain. */ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r220270 - head/sbin/hastd
Author: pjd Date: Sat Apr 2 09:22:06 2011 New Revision: 220270 URL: http://svn.freebsd.org/changeset/base/220270 Log: Allow to disable sends or receives on a socket using shutdown(2) by interpreting NULL 'data' argument passed to proto_common_send() or proto_common_recv() as a will to do so. MFC after:1 month Modified: head/sbin/hastd/proto_common.c Modified: head/sbin/hastd/proto_common.c == --- head/sbin/hastd/proto_common.c Sat Apr 2 08:45:13 2011 (r220269) +++ head/sbin/hastd/proto_common.c Sat Apr 2 09:22:06 2011 (r220270) @@ -82,6 +82,17 @@ proto_common_send(int sock, const unsign size_t sendsize; PJDLOG_ASSERT(sock >= 0); + + if (data == NULL) { + /* The caller is just trying to decide about direction. */ + + PJDLOG_ASSERT(size == 0); + + if (shutdown(sock, SHUT_RD) == -1) + return (errno); + return (0); + } + PJDLOG_ASSERT(data != NULL); PJDLOG_ASSERT(size > 0); @@ -141,6 +152,17 @@ proto_common_recv(int sock, unsigned cha ssize_t done; PJDLOG_ASSERT(sock >= 0); + + if (data == NULL) { + /* The caller is just trying to decide about direction. */ + + PJDLOG_ASSERT(size == 0); + + if (shutdown(sock, SHUT_WR) == -1) + return (errno); + return (0); + } + PJDLOG_ASSERT(data != NULL); PJDLOG_ASSERT(size > 0); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r220266 - head/sbin/hastd
Author: pjd Date: Sat Apr 2 07:01:09 2011 New Revision: 220266 URL: http://svn.freebsd.org/changeset/base/220266 Log: Handle the problem described in r220264 by using GEOM GATE queue of unlimited length. This should fix deadlocks reported by HAST users. MFC after:1 week Modified: head/sbin/hastd/primary.c Modified: head/sbin/hastd/primary.c == --- head/sbin/hastd/primary.c Sat Apr 2 06:59:05 2011(r220265) +++ head/sbin/hastd/primary.c Sat Apr 2 07:01:09 2011(r220266) @@ -761,7 +761,7 @@ init_ggate(struct hast_resource *res) ggiocreate.gctl_mediasize = res->hr_datasize; ggiocreate.gctl_sectorsize = res->hr_local_sectorsize; ggiocreate.gctl_flags = 0; - ggiocreate.gctl_maxcount = G_GATE_MAX_QUEUE_SIZE; + ggiocreate.gctl_maxcount = 0; ggiocreate.gctl_timeout = 0; ggiocreate.gctl_unit = G_GATE_NAME_GIVEN; snprintf(ggiocreate.gctl_name, sizeof(ggiocreate.gctl_name), "hast/%s", ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r220265 - head/sbin/ggate/ggatel
Author: pjd Date: Sat Apr 2 06:59:05 2011 New Revision: 220265 URL: http://svn.freebsd.org/changeset/base/220265 Log: Because ggatel(8) operates on local GEOM providers, use unlimited queue size in GEOM GATE to fix the issue described in r220264. This also means that we no longer need -q option, remove it. Don't bother to leaving it as a no-op, as ggatel(8) is just an example utility. Modified: head/sbin/ggate/ggatel/ggatel.8 head/sbin/ggate/ggatel/ggatel.c Modified: head/sbin/ggate/ggatel/ggatel.8 == --- head/sbin/ggate/ggatel/ggatel.8 Sat Apr 2 06:56:06 2011 (r220264) +++ head/sbin/ggate/ggatel/ggatel.8 Sat Apr 2 06:59:05 2011 (r220265) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 26, 2004 +.Dd April 2, 2011 .Dt GGATEL 8 .Os .Sh NAME @@ -35,7 +35,6 @@ .Cm create .Op Fl v .Op Fl o Cm ro | wo | rw -.Op Fl q Ar queue_size .Op Fl s Ar sectorsize .Op Fl t Ar timeout .Op Fl u Ar unit @@ -100,10 +99,6 @@ or read-write .Pq Cm rw . Default is .Cm rw . -.It Fl q Ar queue_size -Number of pending I/O requests that can be queued before they will -start to be canceled. -Default is 1024. .It Fl s Ar sectorsize Sector size for .Nm ggate Modified: head/sbin/ggate/ggatel/ggatel.c == --- head/sbin/ggate/ggatel/ggatel.c Sat Apr 2 06:56:06 2011 (r220264) +++ head/sbin/ggate/ggatel/ggatel.c Sat Apr 2 06:59:05 2011 (r220265) @@ -53,7 +53,6 @@ static const char *path = NULL; static int unit = G_GATE_UNIT_AUTO; static unsigned flags = 0; static int force = 0; -static unsigned queue_size = G_GATE_QUEUE_SIZE; static unsigned sectorsize = 0; static unsigned timeout = G_GATE_TIMEOUT; @@ -61,7 +60,7 @@ static void usage(void) { - fprintf(stderr, "usage: %s create [-v] [-o ] [-q queue_size] " + fprintf(stderr, "usage: %s create [-v] [-o ] " "[-s sectorsize] [-t timeout] [-u unit] \n", getprogname()); fprintf(stderr, " %s rescue [-v] [-o ] <-u unit> " "\n", getprogname()); @@ -182,7 +181,7 @@ g_gatel_create(void) ggioc.gctl_sectorsize = sectorsize; ggioc.gctl_timeout = timeout; ggioc.gctl_flags = flags; - ggioc.gctl_maxcount = queue_size; + ggioc.gctl_maxcount = 0; strlcpy(ggioc.gctl_info, path, sizeof(ggioc.gctl_info)); g_gate_ioctl(G_GATE_CMD_CREATE, &ggioc); if (unit == -1) @@ -230,7 +229,7 @@ main(int argc, char *argv[]) for (;;) { int ch; - ch = getopt(argc, argv, "fo:q:s:t:u:v"); + ch = getopt(argc, argv, "fo:s:t:u:v"); if (ch == -1) break; switch (ch) { @@ -253,14 +252,6 @@ main(int argc, char *argv[]) "Invalid argument for '-o' option."); } break; - case 'q': - if (action != CREATE) - usage(); - errno = 0; - queue_size = strtoul(optarg, NULL, 10); - if (queue_size == 0 && errno != 0) - errx(EXIT_FAILURE, "Invalid queue_size."); - break; case 's': if (action != CREATE) usage(); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r220264 - head/sys/geom/gate
Author: pjd Date: Sat Apr 2 06:56:06 2011 New Revision: 220264 URL: http://svn.freebsd.org/changeset/base/220264 Log: GEOM has an internal mechanism to deal with ENOMEM errors returned via g_io_deliver(). In such case it increases 'pace' counter on each ENOMEM and reschedules the request. The 'pace' counter is decreased for each request going down, but until 'pace' is greater than zero, GEOM will handle at most 10 requests per second. For GEOM GATE users that are proxy to local GEOM providers (like ggatel(8) and HAST) we can end up with almost permanent slow down of GEOM down queue. This is because once we reach GEOM GATE queue limit, we return ENOMEM to the GEOM. This means that we have, eg. 1024 I/O requests in the GEOM GATE queue. To make room in the queue and stop returning ENOMEM we need to proceed the requests of course, but those requests are handled by userland daemons that handle them by reading/writing also from/to local GEOM providers. For example with HAST, a new requests comes to /dev/hast/data, which is GEOM GATE provider. GEOM GATE passes the request to hastd(8) and hastd(8) reads/writes from/to /dev/da0. Once we reach GEOM GATE queue limit, to free up a slot in GEOM GATE queue, hastd(8) has to read/write from/to /dev/da0, but this request will also be very slow, because GEOM now slows down all the requests. We end up with full queue that we can unload at the speed of 10 requests per second. This simply looks like a deadlock. Fix it by allowing userland daemons that work with both GEOM GATE and local GEOM providers to specify unlimited queue size, so GEOM GATE will never return ENOMEM to the GEOM. MFC after:1 week Modified: head/sys/geom/gate/g_gate.c Modified: head/sys/geom/gate/g_gate.c == --- head/sys/geom/gate/g_gate.c Sat Apr 2 06:25:13 2011(r220263) +++ head/sys/geom/gate/g_gate.c Sat Apr 2 06:56:06 2011(r220264) @@ -194,7 +194,7 @@ g_gate_start(struct bio *bp) } mtx_lock(&sc->sc_queue_mtx); - if (sc->sc_queue_count > sc->sc_queue_size) { + if (sc->sc_queue_size > 0 && sc->sc_queue_count > sc->sc_queue_size) { mtx_unlock(&sc->sc_queue_mtx); G_GATE_LOGREQ(1, bp, "Queue full, request canceled."); g_io_deliver(bp, ENOMEM); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r220024 - head/lib/libc/gen
Author: pjd Date: Sat Mar 26 07:17:24 2011 New Revision: 220024 URL: http://svn.freebsd.org/changeset/base/220024 Log: Don't calculate len too early. Modified: head/lib/libc/gen/directory.3 Modified: head/lib/libc/gen/directory.3 == --- head/lib/libc/gen/directory.3 Sat Mar 26 07:15:57 2011 (r220023) +++ head/lib/libc/gen/directory.3 Sat Mar 26 07:17:24 2011 (r220024) @@ -207,10 +207,10 @@ see .Pp Sample code which searches a directory for entry ``name'' is: .Bd -literal -offset indent -len = strlen(name); dirp = opendir("."); if (dirp == NULL) return (ERROR); +len = strlen(name); while ((dp = readdir(dirp)) != NULL) { if (dp->d_namlen == len && strcmp(dp->d_name, name) == 0) { (void)closedir(dirp); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r220023 - head/lib/libc/gen
Author: pjd Date: Sat Mar 26 07:15:57 2011 New Revision: 220023 URL: http://svn.freebsd.org/changeset/base/220023 Log: Follow style(9) in example code and handle opendir(3) error. Modified: head/lib/libc/gen/directory.3 Modified: head/lib/libc/gen/directory.3 == --- head/lib/libc/gen/directory.3 Sat Mar 26 07:15:35 2011 (r220022) +++ head/lib/libc/gen/directory.3 Sat Mar 26 07:15:57 2011 (r220023) @@ -209,13 +209,16 @@ Sample code which searches a directory f .Bd -literal -offset indent len = strlen(name); dirp = opendir("."); -while ((dp = readdir(dirp)) != NULL) - if (dp->d_namlen == len && !strcmp(dp->d_name, name)) { +if (dirp == NULL) + return (ERROR); +while ((dp = readdir(dirp)) != NULL) { + if (dp->d_namlen == len && strcmp(dp->d_name, name) == 0) { (void)closedir(dirp); - return FOUND; + return (FOUND); } +} (void)closedir(dirp); -return NOT_FOUND; +return (NOT_FOUND); .Ed .Sh SEE ALSO .Xr close 2 , ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r220007 - head/sbin/hastd
Author: pjd Date: Fri Mar 25 20:19:15 2011 New Revision: 220007 URL: http://svn.freebsd.org/changeset/base/220007 Log: Add mapsize to the header just before sending the packet. Before it could change later and we were sending invalid mapsize. Some time ago I added optimization where when nodes are connected for the first time and there were no writes to them yet, there is no initial full synchronization. This bug prevented it from working. MFC after:1 week Modified: head/sbin/hastd/secondary.c Modified: head/sbin/hastd/secondary.c == --- head/sbin/hastd/secondary.c Fri Mar 25 20:15:16 2011(r220006) +++ head/sbin/hastd/secondary.c Fri Mar 25 20:19:15 2011(r220007) @@ -201,7 +201,6 @@ init_remote(struct hast_resource *res, s "Unable to allocate memory (%zu bytes) for activemap.", mapsize); } - nv_add_uint32(nvout, (uint32_t)mapsize, "mapsize"); /* * When we work as primary and secondary is missing we will increase * localcnt in our metadata. When secondary is connected and synced @@ -339,6 +338,7 @@ init_remote(struct hast_resource *res, s (uintmax_t)res->hr_secondary_localcnt, (uintmax_t)res->hr_secondary_remotecnt); } + nv_add_uint32(nvout, (uint32_t)mapsize, "mapsize"); if (hast_proto_send(res, res->hr_remotein, nvout, map, mapsize) < 0) { pjdlog_exit(EX_TEMPFAIL, "Unable to send activemap to %s", res->hr_remoteaddr); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r220006 - head/sbin/hastd
Author: pjd Date: Fri Mar 25 20:15:16 2011 New Revision: 220006 URL: http://svn.freebsd.org/changeset/base/220006 Log: Use timeout from configuration file not only when sending and receiving, but also when establishing connection. MFC after:1 week Modified: head/sbin/hastd/primary.c Modified: head/sbin/hastd/primary.c == --- head/sbin/hastd/primary.c Fri Mar 25 20:13:38 2011(r220005) +++ head/sbin/hastd/primary.c Fri Mar 25 20:15:16 2011(r220006) @@ -509,7 +509,7 @@ primary_connect(struct hast_resource *re primary_exit(EX_TEMPFAIL, "Unable to receive connection from parent"); } - if (proto_connect_wait(conn, HAST_TIMEOUT) < 0) { + if (proto_connect_wait(conn, res->hr_timeout) < 0) { pjdlog_errno(LOG_WARNING, "Unable to connect to %s", res->hr_remoteaddr); proto_close(conn); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r220005 - head/sbin/hastd
Author: pjd Date: Fri Mar 25 20:13:38 2011 New Revision: 220005 URL: http://svn.freebsd.org/changeset/base/220005 Log: Use role2str() when setting process title. MFC after:1 week Modified: head/sbin/hastd/primary.c head/sbin/hastd/secondary.c Modified: head/sbin/hastd/primary.c == --- head/sbin/hastd/primary.c Fri Mar 25 18:23:10 2011(r220004) +++ head/sbin/hastd/primary.c Fri Mar 25 20:13:38 2011(r220005) @@ -868,7 +868,7 @@ hastd_primary(struct hast_resource *res) pjdlog_init(mode); pjdlog_debug_set(debuglevel); pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role)); - setproctitle("%s (primary)", res->hr_name); + setproctitle("%s (%s)", res->hr_name, role2str(res->hr_role)); init_local(res); init_ggate(res); Modified: head/sbin/hastd/secondary.c == --- head/sbin/hastd/secondary.c Fri Mar 25 18:23:10 2011(r220004) +++ head/sbin/hastd/secondary.c Fri Mar 25 20:13:38 2011(r220005) @@ -414,7 +414,7 @@ hastd_secondary(struct hast_resource *re pjdlog_init(mode); pjdlog_debug_set(debuglevel); pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role)); - setproctitle("%s (secondary)", res->hr_name); + setproctitle("%s (%s)", res->hr_name, role2str(res->hr_role)); PJDLOG_VERIFY(sigemptyset(&mask) == 0); PJDLOG_VERIFY(sigprocmask(SIG_SETMASK, &mask, NULL) == 0); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219973 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Author: pjd Date: Thu Mar 24 20:28:09 2011 New Revision: 219973 URL: http://svn.freebsd.org/changeset/base/219973 Log: Checking file access on size change is bogus. The checks are done earlier by VFS where we know if this is truncate(2) or ftruncate(2). If this is the latter we should depend on the mode the file was opened and not on the current permission. PR: standards/154873 Reported by: Mark Martinec Discussed with: Eric Schrock Discussed with: Mark Maybee MFC after:1 month Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c == --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Thu Mar 24 20:15:42 2011(r219972) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Thu Mar 24 20:28:09 2011(r219973) @@ -2962,11 +2962,6 @@ top: */ if (mask & AT_SIZE) { - err = zfs_zaccess(zp, ACE_WRITE_DATA, 0, skipaclchk, cr); - if (err) { - ZFS_EXIT(zfsvfs); - return (err); - } /* * XXX - Note, we are not providing any open * mode flags here (like FNDELAY), so we may ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219959 - head/cddl/contrib/opensolaris/lib/libzfs/common
Author: pjd Date: Thu Mar 24 14:12:41 2011 New Revision: 219959 URL: http://svn.freebsd.org/changeset/base/219959 Log: Properly print characters larger than 127. Submitted by: noordsij Reviewed by: Eric Schrock MFC after:1 month Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c == --- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c Thu Mar 24 13:52:59 2011(r219958) +++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c Thu Mar 24 14:12:41 2011(r219959) @@ -138,8 +138,10 @@ stream_bytes(FILE *fp, const char *strin while (*string) { if (*string > ' ' && *string != '\\' && *string < '\177') (void) fprintf(fp, "%c", *string++); - else - (void) fprintf(fp, "\\%03o", *string++); + else { + (void) fprintf(fp, "\\%03hho", + (unsigned char)*string++); + } } } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219900 - head/sbin/hastd
Author: pjd Date: Wed Mar 23 11:09:04 2011 New Revision: 219900 URL: http://svn.freebsd.org/changeset/base/219900 Log: Don't create socketpair for connection forwarding between parent and secondary. Secondary doesn't need to connect anywhere. MFC after:1 week Modified: head/sbin/hastd/hastd.c head/sbin/hastd/secondary.c Modified: head/sbin/hastd/hastd.c == --- head/sbin/hastd/hastd.c Wed Mar 23 08:33:12 2011(r219899) +++ head/sbin/hastd/hastd.c Wed Mar 23 11:09:04 2011(r219900) @@ -224,7 +224,8 @@ descriptors_assert(const struct hast_res fd, dtype2str(mode), dtype2str(S_IFSOCK)); break; } - } else if (fd == proto_descriptor(res->hr_conn)) { + } else if (res->hr_role == HAST_ROLE_PRIMARY && + fd == proto_descriptor(res->hr_conn)) { if (!isopen) { (void)snprintf(msg, sizeof(msg), "Descriptor %d (conn) is closed, but should be open.", @@ -238,6 +239,15 @@ descriptors_assert(const struct hast_res break; } } else if (res->hr_role == HAST_ROLE_SECONDARY && + res->hr_conn != NULL && + fd == proto_descriptor(res->hr_conn)) { + if (isopen) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (conn) is open, but should be closed.", + fd); + break; + } + } else if (res->hr_role == HAST_ROLE_SECONDARY && fd == proto_descriptor(res->hr_remotein)) { if (!isopen) { (void)snprintf(msg, sizeof(msg), @@ -851,6 +861,8 @@ connection_migrate(struct hast_resource pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role)); + PJDLOG_ASSERT(res->hr_role == HAST_ROLE_PRIMARY); + if (proto_recv(res->hr_conn, &val, sizeof(val)) < 0) { pjdlog_errno(LOG_WARNING, "Unable to receive connection command"); @@ -951,17 +963,19 @@ main_loop(void) TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) { if (res->hr_event == NULL) continue; - PJDLOG_ASSERT(res->hr_conn != NULL); fd = proto_descriptor(res->hr_event); PJDLOG_ASSERT(fd >= 0); FD_SET(fd, &rfds); maxfd = fd > maxfd ? fd : maxfd; if (res->hr_role == HAST_ROLE_PRIMARY) { /* Only primary workers asks for connections. */ + PJDLOG_ASSERT(res->hr_conn != NULL); fd = proto_descriptor(res->hr_conn); PJDLOG_ASSERT(fd >= 0); FD_SET(fd, &rfds); maxfd = fd > maxfd ? fd : maxfd; + } else { + PJDLOG_ASSERT(res->hr_conn == NULL); } } @@ -998,20 +1012,26 @@ main_loop(void) TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) { if (res->hr_event == NULL) continue; - PJDLOG_ASSERT(res->hr_conn != NULL); if (FD_ISSET(proto_descriptor(res->hr_event), &rfds)) { if (event_recv(res) == 0) continue; /* The worker process exited? */ proto_close(res->hr_event); res->hr_event = NULL; - proto_close(res->hr_conn); - res->hr_conn = NULL; + if (res->hr_conn != NULL) { + proto_close(res->hr_conn); + res->hr_conn = NULL; + } continue; } - if (res->hr_role == HAST_ROLE_PRIMARY && - FD_ISSET(proto_descriptor(res->hr_conn), &rfds)) { - connection_migrate(res); + if (res->hr_role == HAST_ROLE_PRIMARY) { + PJDLOG_ASSERT(res->hr_conn != NULL); + if (FD_ISSET(proto_descriptor(res->hr_conn), + &rfds)) { + con
svn commit: r219887 - head/sbin/hastd
Author: pjd Date: Tue Mar 22 21:19:51 2011 New Revision: 219887 URL: http://svn.freebsd.org/changeset/base/219887 Log: Add my copyright. MFC after:1 week Modified: head/sbin/hastd/subr.c head/sbin/hastd/subr.h Modified: head/sbin/hastd/subr.c == --- head/sbin/hastd/subr.c Tue Mar 22 21:16:14 2011(r219886) +++ head/sbin/hastd/subr.c Tue Mar 22 21:19:51 2011(r219887) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2010 The FreeBSD Foundation + * Copyright (c) 2011 Pawel Jakub Dawidek * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from Modified: head/sbin/hastd/subr.h == --- head/sbin/hastd/subr.h Tue Mar 22 21:16:14 2011(r219886) +++ head/sbin/hastd/subr.h Tue Mar 22 21:19:51 2011(r219887) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2010 The FreeBSD Foundation + * Copyright (c) 2011 Pawel Jakub Dawidek * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219884 - head/sbin/hastctl
Author: pjd Date: Tue Mar 22 21:11:36 2011 New Revision: 219884 URL: http://svn.freebsd.org/changeset/base/219884 Log: Forgot to commit this as part of r219873. MFC after:1 week Modified: head/sbin/hastctl/Makefile Modified: head/sbin/hastctl/Makefile == --- head/sbin/hastctl/Makefile Tue Mar 22 21:05:56 2011(r219883) +++ head/sbin/hastctl/Makefile Tue Mar 22 21:11:36 2011(r219884) @@ -13,7 +13,7 @@ SRCS+=lzf.c SRCS+= metadata.c SRCS+= nv.c SRCS+= parse.y pjdlog.c -SRCS+= proto.c proto_common.c proto_tcp4.c proto_uds.c +SRCS+= proto.c proto_common.c proto_uds.c SRCS+= token.l SRCS+= subr.c SRCS+= y.tab.h ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219873 - head/sbin/hastd
Author: pjd Date: Tue Mar 22 16:21:11 2011 New Revision: 219873 URL: http://svn.freebsd.org/changeset/base/219873 Log: The proto API is a general purpose API, so don't use 'hast' in structures or function names. It can now be used outside of HAST. MFC after:1 week Modified: head/sbin/hastd/Makefile head/sbin/hastd/hast.h head/sbin/hastd/proto.c head/sbin/hastd/proto_impl.h head/sbin/hastd/proto_socketpair.c head/sbin/hastd/proto_tcp4.c head/sbin/hastd/proto_uds.c Modified: head/sbin/hastd/Makefile == --- head/sbin/hastd/MakefileTue Mar 22 14:55:31 2011(r219872) +++ head/sbin/hastd/MakefileTue Mar 22 16:21:11 2011(r219873) @@ -20,6 +20,7 @@ SRCS+=y.tab.h MAN= hastd.8 hast.conf.5 NO_WFORMAT= +CFLAGS+=-DPROTO_TCP4_DEFAULT_PORT=8457 CFLAGS+=-I${.CURDIR} CFLAGS+=-DINET .if ${MK_INET6_SUPPORT} != "no" Modified: head/sbin/hastd/hast.h == --- head/sbin/hastd/hast.h Tue Mar 22 14:55:31 2011(r219872) +++ head/sbin/hastd/hast.h Tue Mar 22 16:21:11 2011(r219873) @@ -86,7 +86,6 @@ #defineHAST_TIMEOUT5 #defineHAST_CONFIG "/etc/hast.conf" #defineHAST_CONTROL"/var/run/hastctl" -#defineHASTD_PORT 8457 #defineHASTD_LISTEN"tcp4://0.0.0.0:8457" #defineHASTD_PIDFILE "/var/run/hastd.pid" Modified: head/sbin/hastd/proto.c == --- head/sbin/hastd/proto.c Tue Mar 22 14:55:31 2011(r219872) +++ head/sbin/hastd/proto.c Tue Mar 22 16:21:11 2011(r219873) @@ -45,33 +45,33 @@ __FBSDID("$FreeBSD$"); #definePROTO_CONN_MAGIC0x907041c struct proto_conn { - int pc_magic; - struct hast_proto *pc_proto; - void*pc_ctx; - int pc_side; + int pc_magic; + struct proto*pc_proto; + void*pc_ctx; + int pc_side; #definePROTO_SIDE_CLIENT 0 #definePROTO_SIDE_SERVER_LISTEN1 #definePROTO_SIDE_SERVER_WORK 2 }; -static TAILQ_HEAD(, hast_proto) protos = TAILQ_HEAD_INITIALIZER(protos); +static TAILQ_HEAD(, proto) protos = TAILQ_HEAD_INITIALIZER(protos); void -proto_register(struct hast_proto *proto, bool isdefault) +proto_register(struct proto *proto, bool isdefault) { static bool seen_default = false; if (!isdefault) - TAILQ_INSERT_HEAD(&protos, proto, hp_next); + TAILQ_INSERT_HEAD(&protos, proto, prt_next); else { PJDLOG_ASSERT(!seen_default); seen_default = true; - TAILQ_INSERT_TAIL(&protos, proto, hp_next); + TAILQ_INSERT_TAIL(&protos, proto, prt_next); } } static struct proto_conn * -proto_alloc(struct hast_proto *proto, int side) +proto_alloc(struct proto *proto, int side) { struct proto_conn *conn; @@ -108,7 +108,7 @@ static int proto_common_setup(const char *srcaddr, const char *dstaddr, struct proto_conn **connp, int side) { - struct hast_proto *proto; + struct proto *proto; struct proto_conn *conn; void *ctx; int ret; @@ -116,17 +116,17 @@ proto_common_setup(const char *srcaddr, PJDLOG_ASSERT(side == PROTO_SIDE_CLIENT || side == PROTO_SIDE_SERVER_LISTEN); - TAILQ_FOREACH(proto, &protos, hp_next) { + TAILQ_FOREACH(proto, &protos, prt_next) { if (side == PROTO_SIDE_CLIENT) { - if (proto->hp_client == NULL) + if (proto->prt_client == NULL) ret = -1; else - ret = proto->hp_client(srcaddr, dstaddr, &ctx); + ret = proto->prt_client(srcaddr, dstaddr, &ctx); } else /* if (side == PROTO_SIDE_SERVER_LISTEN) */ { - if (proto->hp_server == NULL) + if (proto->prt_server == NULL) ret = -1; else - ret = proto->hp_server(dstaddr, &ctx); + ret = proto->prt_server(dstaddr, &ctx); } /* * ret == 0 - success @@ -148,8 +148,8 @@ proto_common_setup(const char *srcaddr, } conn = proto_alloc(proto, side); if (conn == NULL) { - if (proto->hp_close != NULL) - proto->hp_close(ctx); + if (proto->prt_close != NULL) + proto->prt_close(ctx); errno = ENOMEM; return (-1); } @@ -176,10 +17
svn commit: r219864 - head/sbin/hastd
Author: pjd Date: Tue Mar 22 10:39:34 2011 New Revision: 219864 URL: http://svn.freebsd.org/changeset/base/219864 Log: White space cleanups. MFC after:1 week Modified: head/sbin/hastd/activemap.c head/sbin/hastd/hastd.8 head/sbin/hastd/hastd.c head/sbin/hastd/primary.c head/sbin/hastd/proto_tcp4.c head/sbin/hastd/secondary.c head/sbin/hastd/subr.c Modified: head/sbin/hastd/activemap.c == --- head/sbin/hastd/activemap.c Tue Mar 22 10:29:36 2011(r219863) +++ head/sbin/hastd/activemap.c Tue Mar 22 10:39:34 2011(r219864) @@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$"); #defineACTIVEMAP_MAGIC 0xac71e4 struct activemap { int am_magic; /* Magic value. */ - off_tam_mediasize; /* Media size in bytes. */ + off_tam_mediasize; /* Media size in bytes. */ uint32_t am_extentsize; /* Extent size in bytes, must be power of 2. */ uint8_t am_extentshift;/* 2 ^ extentbits == extentsize */ Modified: head/sbin/hastd/hastd.8 == --- head/sbin/hastd/hastd.8 Tue Mar 22 10:29:36 2011(r219863) +++ head/sbin/hastd/hastd.8 Tue Mar 22 10:39:34 2011(r219864) @@ -95,7 +95,7 @@ following option: .Bd -ragged -offset indent .Cd "options GEOM_GATE" .Ed -.Pp +.Pp The connection between two .Nm daemons is always initiated from the one running as primary to the one Modified: head/sbin/hastd/hastd.c == --- head/sbin/hastd/hastd.c Tue Mar 22 10:29:36 2011(r219863) +++ head/sbin/hastd/hastd.c Tue Mar 22 10:39:34 2011(r219864) @@ -132,19 +132,19 @@ dtype2str(mode_t mode) if (S_ISBLK(mode)) return ("block device"); - else if (S_ISCHR(mode)) + else if (S_ISCHR(mode)) return ("character device"); - else if (S_ISDIR(mode)) + else if (S_ISDIR(mode)) return ("directory"); else if (S_ISFIFO(mode)) return ("pipe or FIFO"); - else if (S_ISLNK(mode)) + else if (S_ISLNK(mode)) return ("symbolic link"); - else if (S_ISREG(mode)) + else if (S_ISREG(mode)) return ("regular file"); else if (S_ISSOCK(mode)) return ("socket"); - else if (S_ISWHT(mode)) + else if (S_ISWHT(mode)) return ("whiteout"); else return ("unknown"); @@ -929,7 +929,7 @@ main_loop(void) time_t lastcheck, now; fd_set rfds; - lastcheck = time(NULL); + lastcheck = time(NULL); seltimeout.tv_sec = REPORT_INTERVAL; seltimeout.tv_usec = 0; Modified: head/sbin/hastd/primary.c == --- head/sbin/hastd/primary.c Tue Mar 22 10:29:36 2011(r219863) +++ head/sbin/hastd/primary.c Tue Mar 22 10:39:34 2011(r219864) @@ -183,7 +183,7 @@ static pthread_mutex_t metadata_lock; while (((hio) = TAILQ_FIRST(&hio_##name##_list[(ncomp)])) == NULL && !_last) { \ cv_timedwait(&hio_##name##_list_cond[(ncomp)], \ &hio_##name##_list_lock[(ncomp)], (timeout)); \ - if ((timeout) != 0) \ + if ((timeout) != 0) \ _last = true; \ } \ if (hio != NULL) { \ @@ -1268,7 +1268,7 @@ keepalive_send(struct hast_resource *res rw_unlock(&hio_remote_lock[ncomp]); return; } - + PJDLOG_ASSERT(res->hr_remotein != NULL); PJDLOG_ASSERT(res->hr_remoteout != NULL); @@ -1314,7 +1314,7 @@ remote_send_thread(void *arg) /* Remote component is 1 for now. */ ncomp = 1; - lastcheck = time(NULL); + lastcheck = time(NULL); for (;;) { pjdlog_debug(2, "remote_send: Taking request."); Modified: head/sbin/hastd/proto_tcp4.c == --- head/sbin/hastd/proto_tcp4.cTue Mar 22 10:29:36 2011 (r219863) +++ head/sbin/hastd/proto_tcp4.cTue Mar 22 10:39:34 2011 (r219864) @@ -337,7 +337,7 @@ tcp4_connect_wait(void *ctx, int timeout tv.tv_usec = 0; again: FD_ZERO(&fdset); - FD_SET(tctx->tc_fd, &fdset); + FD_SET(tctx->tc_fd, &fdset); ret = select(tctx->tc_fd + 1, NULL, &fdset, NULL, &tv); if (ret == 0) { error = ETI
svn commit: r219847 - in head/sbin: hastctl hastd
Author: pjd Date: Mon Mar 21 21:31:50 2011 New Revision: 219847 URL: http://svn.freebsd.org/changeset/base/219847 Log: When dropping privileges prefer capsicum over chroot+setgid+setuid. We can use capsicum for secondary worker processes and hastctl. When working as primary we drop privileges using chroot+setgid+setuid still as we need to send ioctl(2)s to ggate device, for which capsicum doesn't allow (yet). X-MFC after: capsicum is merged to stable/8 Modified: head/sbin/hastctl/hastctl.c head/sbin/hastd/primary.c head/sbin/hastd/secondary.c head/sbin/hastd/subr.c head/sbin/hastd/subr.h Modified: head/sbin/hastctl/hastctl.c == --- head/sbin/hastctl/hastctl.c Mon Mar 21 21:16:40 2011(r219846) +++ head/sbin/hastctl/hastctl.c Mon Mar 21 21:31:50 2011(r219847) @@ -480,9 +480,8 @@ main(int argc, char *argv[]) cfg->hc_controladdr); } - if (drop_privs() != 0) + if (drop_privs(true) != 0) exit(EX_CONFIG); - pjdlog_debug(1, "Privileges successfully dropped."); /* Send the command to the server... */ if (hast_proto_send(NULL, controlconn, nv, NULL, 0) < 0) { Modified: head/sbin/hastd/primary.c == --- head/sbin/hastd/primary.c Mon Mar 21 21:16:40 2011(r219846) +++ head/sbin/hastd/primary.c Mon Mar 21 21:31:50 2011(r219847) @@ -874,7 +874,7 @@ hastd_primary(struct hast_resource *res) init_ggate(res); init_environment(res); - if (drop_privs() != 0) { + if (drop_privs(true) != 0) { cleanup(res); exit(EX_CONFIG); } Modified: head/sbin/hastd/secondary.c == --- head/sbin/hastd/secondary.c Mon Mar 21 21:16:40 2011(r219846) +++ head/sbin/hastd/secondary.c Mon Mar 21 21:31:50 2011(r219847) @@ -440,7 +440,7 @@ hastd_secondary(struct hast_resource *re init_local(res); init_environment(); - if (drop_privs() != 0) + if (drop_privs(true) != 0) exit(EX_CONFIG); pjdlog_info("Privileges successfully dropped."); Modified: head/sbin/hastd/subr.c == --- head/sbin/hastd/subr.c Mon Mar 21 21:16:40 2011(r219846) +++ head/sbin/hastd/subr.c Mon Mar 21 21:31:50 2011(r219847) @@ -30,6 +30,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include @@ -39,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -144,13 +146,22 @@ role2str(int role) } int -drop_privs(void) +drop_privs(bool usecapsicum) { struct passwd *pw; uid_t ruid, euid, suid; gid_t rgid, egid, sgid; gid_t gidset[1]; + if (usecapsicum) { + if (cap_enter() == 0) { + pjdlog_debug(1, + "Privileges successfully dropped using capsicum."); + return (0); + } + pjdlog_errno(LOG_WARNING, "Unable to sandbox using capsicum"); + } + /* * According to getpwnam(3) we have to clear errno before calling the * function to be able to distinguish between an error and missing @@ -208,5 +219,8 @@ drop_privs(void) PJDLOG_VERIFY(getgroups(1, gidset) == 1); PJDLOG_VERIFY(gidset[0] == pw->pw_gid); + pjdlog_debug(1, + "Privileges successfully dropped using chroot+setgid+setuid."); + return (0); } Modified: head/sbin/hastd/subr.h == --- head/sbin/hastd/subr.h Mon Mar 21 21:16:40 2011(r219846) +++ head/sbin/hastd/subr.h Mon Mar 21 21:31:50 2011(r219847) @@ -50,6 +50,6 @@ int snprlcat(char *str, size_t size, con int provinfo(struct hast_resource *res, bool dowrite); const char *role2str(int role); -int drop_privs(void); +int drop_privs(bool usecapsicum); #endif /* !_SUBR_H_ */ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219844 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 21:16:12 2011 New Revision: 219844 URL: http://svn.freebsd.org/changeset/base/219844 Log: Initialize localcnt on first write. This fixes assertion when we create resource, set role to primary, do no writes, then sent it to secondary and accept connection from primary. MFC after:1 week Modified: head/sbin/hastd/primary.c Modified: head/sbin/hastd/primary.c == --- head/sbin/hastd/primary.c Mon Mar 21 21:14:07 2011(r219843) +++ head/sbin/hastd/primary.c Mon Mar 21 21:16:12 2011(r219844) @@ -478,7 +478,7 @@ init_local(struct hast_resource *res) * that there were no writes yet, so there is no need to synchronize * anything. */ - res->hr_primary_localcnt = 1; + res->hr_primary_localcnt = 0; res->hr_primary_remotecnt = 0; if (metadata_write(res) < 0) exit(EX_NOINPUT); @@ -1093,7 +1093,11 @@ ggate_recv_thread(void *arg) break; case BIO_WRITE: if (res->hr_resuid == 0) { - /* This is first write, initialize resuid. */ + /* +* This is first write, initialize localcnt and +* resuid. +*/ + res->hr_primary_localcnt = 1; (void)init_resuid(res); } for (;;) { ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219843 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 21:14:07 2011 New Revision: 219843 URL: http://svn.freebsd.org/changeset/base/219843 Log: Fix typo. MFC after:1 week Modified: head/sbin/hastd/secondary.c Modified: head/sbin/hastd/secondary.c == --- head/sbin/hastd/secondary.c Mon Mar 21 18:39:42 2011(r219842) +++ head/sbin/hastd/secondary.c Mon Mar 21 21:14:07 2011(r219843) @@ -277,7 +277,7 @@ init_remote(struct hast_resource *res, s /* Is primary is out-of-date? */ (res->hr_secondary_localcnt > res->hr_primary_remotecnt && res->hr_secondary_remotecnt == res->hr_primary_localcnt) || - /* Node are more or less in sync? */ + /* Nodes are more or less in sync? */ (res->hr_secondary_localcnt == res->hr_primary_remotecnt && res->hr_secondary_remotecnt == res->hr_primary_localcnt) || /* Is secondary is out-of-date? */ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219837 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 15:29:20 2011 New Revision: 219837 URL: http://svn.freebsd.org/changeset/base/219837 Log: Before handling any events on descriptors check signals so we can update our info about worker processes if any of them was terminated in the meantime. This fixes the problem with 'hastctl status' running from a hook called on split-brain: 1. Secondary calls a hooks and terminates. 2. Hook asks for resource status via 'hastctl status'. 3. The main hastd handles the status request by sending it to the secondary worker who is already dead, but because signals weren't checked yet he doesn't know that and we get EPIPE. MFC after:1 week Modified: head/sbin/hastd/hastd.c Modified: head/sbin/hastd/hastd.c == --- head/sbin/hastd/hastd.c Mon Mar 21 15:23:10 2011(r219836) +++ head/sbin/hastd/hastd.c Mon Mar 21 15:29:20 2011(r219837) @@ -884,19 +884,12 @@ out: } static void -main_loop(void) +check_signals(void) { - struct hast_resource *res; - struct timeval seltimeout; struct timespec sigtimeout; - int fd, maxfd, ret, signo; - time_t lastcheck, now; sigset_t mask; - fd_set rfds; + int signo; - lastcheck = time(NULL); - seltimeout.tv_sec = REPORT_INTERVAL; - seltimeout.tv_usec = 0; sigtimeout.tv_sec = 0; sigtimeout.tv_nsec = 0; @@ -906,29 +899,45 @@ main_loop(void) PJDLOG_VERIFY(sigaddset(&mask, SIGTERM) == 0); PJDLOG_VERIFY(sigaddset(&mask, SIGCHLD) == 0); + while ((signo = sigtimedwait(&mask, NULL, &sigtimeout)) != -1) { + switch (signo) { + case SIGINT: + case SIGTERM: + sigexit_received = true; + terminate_workers(); + proto_close(cfg->hc_controlconn); + exit(EX_OK); + break; + case SIGCHLD: + child_exit(); + break; + case SIGHUP: + hastd_reload(); + break; + default: + PJDLOG_ABORT("Unexpected signal (%d).", signo); + } + } +} + +static void +main_loop(void) +{ + struct hast_resource *res; + struct timeval seltimeout; + int fd, maxfd, ret; + time_t lastcheck, now; + fd_set rfds; + + lastcheck = time(NULL); + seltimeout.tv_sec = REPORT_INTERVAL; + seltimeout.tv_usec = 0; + pjdlog_info("Started successfully, running protocol version %d.", HAST_PROTO_VERSION); for (;;) { - while ((signo = sigtimedwait(&mask, NULL, &sigtimeout)) != -1) { - switch (signo) { - case SIGINT: - case SIGTERM: - sigexit_received = true; - terminate_workers(); - proto_close(cfg->hc_controlconn); - exit(EX_OK); - break; - case SIGCHLD: - child_exit(); - break; - case SIGHUP: - hastd_reload(); - break; - default: - PJDLOG_ABORT("Unexpected signal (%d).", signo); - } - } + check_signals(); /* Setup descriptors for select(2). */ FD_ZERO(&rfds); @@ -976,6 +985,12 @@ main_loop(void) pjdlog_exit(EX_OSERR, "select() failed"); } + /* +* Check for signals before we do anything to update our +* info about terminated workers in the meantime. +*/ + check_signals(); + if (FD_ISSET(proto_descriptor(cfg->hc_controlconn), &rfds)) control_handle(cfg); if (FD_ISSET(proto_descriptor(cfg->hc_listenconn), &rfds)) ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219833 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 15:08:10 2011 New Revision: 219833 URL: http://svn.freebsd.org/changeset/base/219833 Log: Remove stale comment. Yes, it is valid to set role back to init. MFC after:1 week Modified: head/sbin/hastd/control.c Modified: head/sbin/hastd/control.c == --- head/sbin/hastd/control.c Mon Mar 21 14:53:27 2011(r219832) +++ head/sbin/hastd/control.c Mon Mar 21 15:08:10 2011(r219833) @@ -327,7 +327,7 @@ control_handle(struct hastd_config *cfg) if (cmd == HASTCTL_SET_ROLE) { role = nv_get_uint8(nvin, "role"); switch (role) { - case HAST_ROLE_INIT:/* Is that valid to set, hmm? */ + case HAST_ROLE_INIT: case HAST_ROLE_PRIMARY: case HAST_ROLE_SECONDARY: break; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219832 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 14:53:27 2011 New Revision: 219832 URL: http://svn.freebsd.org/changeset/base/219832 Log: Increase debug level of "Checking hooks." message. MFC after:1 week Modified: head/sbin/hastd/hooks.c Modified: head/sbin/hastd/hooks.c == --- head/sbin/hastd/hooks.c Mon Mar 21 14:51:16 2011(r219831) +++ head/sbin/hastd/hooks.c Mon Mar 21 14:53:27 2011(r219832) @@ -288,7 +288,7 @@ hook_check(void) assert(hooks_initialized); - pjdlog_debug(1, "Checking hooks."); + pjdlog_debug(2, "Checking hooks."); /* * Report about processes that are running for a long time. ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219831 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 14:51:16 2011 New Revision: 219831 URL: http://svn.freebsd.org/changeset/base/219831 Log: Be pedantic and free nvout before exiting. MFC after:1 week Modified: head/sbin/hastd/secondary.c Modified: head/sbin/hastd/secondary.c == --- head/sbin/hastd/secondary.c Mon Mar 21 14:50:12 2011(r219830) +++ head/sbin/hastd/secondary.c Mon Mar 21 14:51:16 2011(r219831) @@ -271,6 +271,7 @@ init_remote(struct hast_resource *res, s pjdlog_exit(EX_TEMPFAIL, "Unable to send response to %s", res->hr_remoteaddr); } + nv_free(nvout); exit(EX_CONFIG); } else if ( /* Is primary is out-of-date? */ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219830 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 14:50:12 2011 New Revision: 219830 URL: http://svn.freebsd.org/changeset/base/219830 Log: Detect situation where resource internal identifier differs. This means that both nodes have separately managed resources that don't have the same data. MFC after:1 week Modified: head/sbin/hastd/secondary.c Modified: head/sbin/hastd/secondary.c == --- head/sbin/hastd/secondary.c Mon Mar 21 14:29:35 2011(r219829) +++ head/sbin/hastd/secondary.c Mon Mar 21 14:50:12 2011(r219830) @@ -259,6 +259,19 @@ init_remote(struct hast_resource *res, s memset(map, 0xff, mapsize); } nv_add_uint8(nvout, HAST_SYNCSRC_PRIMARY, "syncsrc"); + } else if (res->hr_resuid != resuid) { + char errmsg[256]; + + (void)snprintf(errmsg, sizeof(errmsg), + "Resource unique ID mismatch (primary=%ju, secondary=%ju).", + (uintmax_t)resuid, (uintmax_t)res->hr_resuid); + pjdlog_error("%s", errmsg); + nv_add_string(nvout, errmsg, "errmsg"); + if (hast_proto_send(res, res->hr_remotein, nvout, NULL, 0) < 0) { + pjdlog_exit(EX_TEMPFAIL, "Unable to send response to %s", + res->hr_remoteaddr); + } + exit(EX_CONFIG); } else if ( /* Is primary is out-of-date? */ (res->hr_secondary_localcnt > res->hr_primary_remotecnt && ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219821 - head/sbin/hastctl
Author: pjd Date: Mon Mar 21 11:52:00 2011 New Revision: 219821 URL: http://svn.freebsd.org/changeset/base/219821 Log: Forgot to commit this as a part of r219818. MFC after:1 week Modified: head/sbin/hastctl/hastctl.c Modified: head/sbin/hastctl/hastctl.c == --- head/sbin/hastctl/hastctl.c Mon Mar 21 09:58:24 2011(r219820) +++ head/sbin/hastctl/hastctl.c Mon Mar 21 11:52:00 2011(r219821) @@ -330,6 +330,9 @@ control_status(struct nv *nv) (unsigned int)nv_get_uint32(nv, "keepdirty%u", ii)); printf(" remoteaddr: %s\n", nv_get_string(nv, "remoteaddr%u", ii)); + str = nv_get_string(nv, "sourceaddr%u", ii); + if (str != NULL) + printf(" sourceaddr: %s\n", str); printf(" replication: %s\n", nv_get_string(nv, "replication%u", ii)); str = nv_get_string(nv, "status%u", ii); @@ -466,7 +469,7 @@ main(int argc, char *argv[]) } /* Setup control connection... */ - if (proto_client(cfg->hc_controladdr, &controlconn) < 0) { + if (proto_client(NULL, cfg->hc_controladdr, &controlconn) < 0) { pjdlog_exit(EX_OSERR, "Unable to setup control connection to %s", cfg->hc_controladdr); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219818 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 08:54:59 2011 New Revision: 219818 URL: http://svn.freebsd.org/changeset/base/219818 Log: In hast.conf we define the other node's address in 'remote' variable. This way we know how to connect to secondary node when we are primary. The same variable is used by the secondary node - it only accepts connections from the address stored in 'remote' variable. In cluster configurations it is common that each node has its individual IP address and there is one addtional shared IP address which is assigned to primary node. It seems it is possible that if the shared IP address is from the same network as the individual IP address it might be choosen by the kernel as a source address for connection with the secondary node. Such connection will be rejected by secondary, as it doesn't come from primary node individual IP. Add 'source' variable that allows to specify source IP address we want to bind to before connecting to the secondary node. MFC after:1 week Modified: head/sbin/hastd/control.c head/sbin/hastd/hast.conf.5 head/sbin/hastd/hast.h head/sbin/hastd/hastd.c head/sbin/hastd/parse.y head/sbin/hastd/primary.c head/sbin/hastd/proto.c head/sbin/hastd/proto.h head/sbin/hastd/proto_impl.h head/sbin/hastd/proto_socketpair.c head/sbin/hastd/proto_tcp4.c head/sbin/hastd/proto_uds.c head/sbin/hastd/secondary.c head/sbin/hastd/token.l Modified: head/sbin/hastd/control.c == --- head/sbin/hastd/control.c Mon Mar 21 08:38:24 2011(r219817) +++ head/sbin/hastd/control.c Mon Mar 21 08:54:59 2011(r219818) @@ -234,6 +234,8 @@ control_status(struct hastd_config *cfg, nv_add_string(nvout, res->hr_provname, "provname%u", no); nv_add_string(nvout, res->hr_localpath, "localpath%u", no); nv_add_string(nvout, res->hr_remoteaddr, "remoteaddr%u", no); + if (res->hr_sourceaddr[0] != '\0') + nv_add_string(nvout, res->hr_sourceaddr, "sourceaddr%u", no); switch (res->hr_replication) { case HAST_REPLICATION_FULLSYNC: nv_add_string(nvout, "fullsync", "replication%u", no); Modified: head/sbin/hastd/hast.conf.5 == --- head/sbin/hastd/hast.conf.5 Mon Mar 21 08:38:24 2011(r219817) +++ head/sbin/hastd/hast.conf.5 Mon Mar 21 08:54:59 2011(r219818) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 30, 2010 +.Dd March 20, 2011 .Dt HAST.CONF 5 .Os .Sh NAME @@ -93,6 +93,7 @@ resource { local # Required remote + source } on { # Resource-node section @@ -101,6 +102,7 @@ resource { local # Required remote + source } } .Ed @@ -337,6 +339,14 @@ A special value of .Va none can be used when the remote address is not yet known (eg. the other node is not set up yet). +.It Ic source Aq addr +.Pp +Local address to bind to before connecting to the remote +.Nm hastd +daemon. +Format is the same as for the +.Ic listen +statement. .El .Sh FILES .Bl -tag -width ".Pa /var/run/hastctl" -compact @@ -367,10 +377,12 @@ resource shared { resource tank { on hasta { local /dev/mirror/tanka + source tcp4://10.0.0.1 remote tcp4://10.0.0.2 } on hastb { local /dev/mirror/tankb + source tcp4://10.0.0.2 remote tcp4://10.0.0.1 } } Modified: head/sbin/hastd/hast.h == --- head/sbin/hastd/hast.h Mon Mar 21 08:38:24 2011(r219817) +++ head/sbin/hastd/hast.h Mon Mar 21 08:54:59 2011(r219818) @@ -169,6 +169,8 @@ struct hast_resource { /* Address of the remote component. */ charhr_remoteaddr[HAST_ADDRSIZE]; + /* Local address to bind to for outgoing connections. */ + charhr_sourceaddr[HAST_ADDRSIZE]; /* Connection for incoming data. */ struct proto_conn *hr_remotein; /* Connection for outgoing data. */ Modified: head/sbin/hastd/hastd.c == --- head/sbin/hastd/hastd.c Mon Mar 21 08:38:24 2011(r219817) +++ head/sbin/hastd/hastd.c Mon Mar 21 08:54:59 2011(r219818) @@ -360,6 +360,8 @@ resource_needs_restart(const struct hast res0->hr_role == HAST_ROLE_SECONDARY) { if (strcmp(res0->hr_remoteaddr, res1->hr_remoteaddr) != 0) return (true); + if (strcmp(res0->hr_sourceaddr, res1->hr_sourceaddr) != 0) + return (true); if (res0->hr_replication != res1->hr_replication)
svn commit: r219817 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 08:38:24 2011 New Revision: 219817 URL: http://svn.freebsd.org/changeset/base/219817 Log: Log when we start hooks checking and when we execute a hook. MFC after:1 week Modified: head/sbin/hastd/hooks.c Modified: head/sbin/hastd/hooks.c == --- head/sbin/hastd/hooks.c Mon Mar 21 08:37:50 2011(r219816) +++ head/sbin/hastd/hooks.c Mon Mar 21 08:38:24 2011(r219817) @@ -288,6 +288,8 @@ hook_check(void) assert(hooks_initialized); + pjdlog_debug(1, "Checking hooks."); + /* * Report about processes that are running for a long time. */ @@ -363,6 +365,8 @@ hook_execv(const char *path, va_list ap) if (hp == NULL) return; + pjdlog_debug(1, "Executing hook: %s", hp->hp_comm); + pid = fork(); switch (pid) { case -1:/* Error. */ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219816 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 08:37:50 2011 New Revision: 219816 URL: http://svn.freebsd.org/changeset/base/219816 Log: Use snprlcat() instead of two strlcat(3)s. MFC after:1 week Modified: head/sbin/hastd/hooks.c Modified: head/sbin/hastd/hooks.c == --- head/sbin/hastd/hooks.c Mon Mar 21 08:36:50 2011(r219815) +++ head/sbin/hastd/hooks.c Mon Mar 21 08:37:50 2011(r219816) @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include "hooks.h" +#include "subr.h" #include "synch.h" /* Report processes that are running for too long not often than this value. */ @@ -184,8 +185,8 @@ hook_alloc(const char *path, char **args (void)strlcpy(hp->hp_comm, path, sizeof(hp->hp_comm)); /* We start at 2nd argument as we don't want to have exec name twice. */ for (ii = 1; args[ii] != NULL; ii++) { - (void)strlcat(hp->hp_comm, " ", sizeof(hp->hp_comm)); - (void)strlcat(hp->hp_comm, args[ii], sizeof(hp->hp_comm)); + (void)snprlcat(hp->hp_comm, sizeof(hp->hp_comm), " %s", + args[ii]); } if (strlen(hp->hp_comm) >= sizeof(hp->hp_comm) - 1) { pjdlog_error("Exec path too long, correct configuration file."); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219815 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 08:36:50 2011 New Revision: 219815 URL: http://svn.freebsd.org/changeset/base/219815 Log: Add snprlcat() and vsnprlcat() - the functions I'm always missing. They work as a combination of snprintf(3) and strlcat(3) - the caller can append a string build based on the given format. MFC after:1 week Modified: head/sbin/hastd/subr.c head/sbin/hastd/subr.h Modified: head/sbin/hastd/subr.c == --- head/sbin/hastd/subr.c Mon Mar 21 08:33:58 2011(r219814) +++ head/sbin/hastd/subr.c Mon Mar 21 08:36:50 2011(r219815) @@ -38,6 +38,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include +#include #include #include @@ -46,6 +49,27 @@ __FBSDID("$FreeBSD$"); #include "subr.h" int +vsnprlcat(char *str, size_t size, const char *fmt, va_list ap) +{ + size_t len; + + len = strlen(str); + return (vsnprintf(str + len, size - len, fmt, ap)); +} + +int +snprlcat(char *str, size_t size, const char *fmt, ...) +{ + va_list ap; + int result; + + va_start(ap, fmt); + result = vsnprlcat(str, size, fmt, ap); + va_end(ap); + return (result); +} + +int provinfo(struct hast_resource *res, bool dowrite) { struct stat sb; Modified: head/sbin/hastd/subr.h == --- head/sbin/hastd/subr.h Mon Mar 21 08:33:58 2011(r219814) +++ head/sbin/hastd/subr.h Mon Mar 21 08:36:50 2011(r219815) @@ -45,6 +45,9 @@ errno = _rerrno;\ } while (0) +int vsnprlcat(char *str, size_t size, const char *fmt, va_list ap); +int snprlcat(char *str, size_t size, const char *fmt, ...); + int provinfo(struct hast_resource *res, bool dowrite); const char *role2str(int role); int drop_privs(void); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219814 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 08:33:58 2011 New Revision: 219814 URL: http://svn.freebsd.org/changeset/base/219814 Log: When creating connection on behalf of primary worker, set pjdlog prefix to resource name and role, so that any logs related to that can be identified properly. MFC after:1 week Modified: head/sbin/hastd/hastd.c Modified: head/sbin/hastd/hastd.c == --- head/sbin/hastd/hastd.c Mon Mar 21 08:31:35 2011(r219813) +++ head/sbin/hastd/hastd.c Mon Mar 21 08:33:58 2011(r219814) @@ -842,6 +842,8 @@ connection_migrate(struct hast_resource struct proto_conn *conn; int16_t val = 0; + pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role)); + if (proto_recv(res->hr_conn, &val, sizeof(val)) < 0) { pjdlog_errno(LOG_WARNING, "Unable to receive connection command"); @@ -869,6 +871,8 @@ out: } if (val == 0 && proto_connection_send(res->hr_conn, conn) < 0) pjdlog_errno(LOG_WARNING, "Unable to send connection"); + + pjdlog_prefix_set("%s", ""); } static void ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219813 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 08:31:35 2011 New Revision: 219813 URL: http://svn.freebsd.org/changeset/base/219813 Log: If there is any traffic on one of out descriptors, we were not checking for long running hooks. Fix it by not using select(2) timeout to decide if we want to check hooks or not. MFC after:1 week Modified: head/sbin/hastd/hastd.c Modified: head/sbin/hastd/hastd.c == --- head/sbin/hastd/hastd.c Mon Mar 21 06:18:26 2011(r219812) +++ head/sbin/hastd/hastd.c Mon Mar 21 08:31:35 2011(r219813) @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -877,9 +878,11 @@ main_loop(void) struct timeval seltimeout; struct timespec sigtimeout; int fd, maxfd, ret, signo; + time_t lastcheck, now; sigset_t mask; fd_set rfds; + lastcheck = time(NULL); seltimeout.tv_sec = REPORT_INTERVAL; seltimeout.tv_usec = 0; sigtimeout.tv_sec = 0; @@ -943,9 +946,18 @@ main_loop(void) PJDLOG_ASSERT(maxfd + 1 <= (int)FD_SETSIZE); ret = select(maxfd + 1, &rfds, NULL, NULL, &seltimeout); - if (ret == 0) + now = time(NULL); + if (lastcheck + REPORT_INTERVAL <= now) { hook_check(); - else if (ret == -1) { + lastcheck = now; + } + if (ret == 0) { + /* +* select(2) timed out, so there should be no +* descriptors to check. +*/ + continue; + } else if (ret == -1) { if (errno == EINTR) continue; KEEP_ERRNO((void)pidfile_remove(pfh)); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219696 - head/lib/libc/gen
Author: pjd Date: Wed Mar 16 08:58:09 2011 New Revision: 219696 URL: http://svn.freebsd.org/changeset/base/219696 Log: From fts.c comment: The "FTS_NOSTAT" option can avoid a lot of calls to stat(2) if it knows that a directory could not possibly have subdirectories. This is decided by looking at the link count: a subdirectory would increment its parent's link count by virtue of its own ".." entry. This assumption only holds for UFS-like filesystems that implement links and directories this way, so we must punt for others. It looks like ZFS is a UFS-like file system, as the above also holds for ZFS. Add ZFS to the list of file systems that allow for such optimization. MFC after:1 month Modified: head/lib/libc/gen/fts-compat.c head/lib/libc/gen/fts.c Modified: head/lib/libc/gen/fts-compat.c == --- head/lib/libc/gen/fts-compat.c Wed Mar 16 08:56:22 2011 (r219695) +++ head/lib/libc/gen/fts-compat.c Wed Mar 16 08:58:09 2011 (r219696) @@ -110,6 +110,7 @@ struct _fts_private { static const char *ufslike_filesystems[] = { "ufs", + "zfs", "nfs", "nfs4", "ext2fs", Modified: head/lib/libc/gen/fts.c == --- head/lib/libc/gen/fts.c Wed Mar 16 08:56:22 2011(r219695) +++ head/lib/libc/gen/fts.c Wed Mar 16 08:58:09 2011(r219696) @@ -100,6 +100,7 @@ struct _fts_private { static const char *ufslike_filesystems[] = { "ufs", + "zfs", "nfs", "nfs4", "ext2fs", ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219669 - head/sbin/hastd
Author: pjd Date: Tue Mar 15 13:53:39 2011 New Revision: 219669 URL: http://svn.freebsd.org/changeset/base/219669 Log: Remove #include needed for debugging. MFC after:1 week Modified: head/sbin/hastd/proto_common.c Modified: head/sbin/hastd/proto_common.c == --- head/sbin/hastd/proto_common.c Tue Mar 15 13:40:47 2011 (r219668) +++ head/sbin/hastd/proto_common.c Tue Mar 15 13:53:39 2011 (r219669) @@ -104,7 +104,6 @@ proto_common_send(int sock, const unsign return (proto_descriptor_send(sock, fd)); } -#include static int proto_descriptor_recv(int sock, int *fdp) { ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r219641 - in head: etc release
On Mon, Mar 14, 2011 at 01:47:17PM +, Nathan Whitehorn wrote: > Author: nwhitehorn > Date: Mon Mar 14 13:47:17 2011 > New Revision: 219641 > URL: http://svn.freebsd.org/changeset/base/219641 > > Log: > Thanks to sysinstall for its 15 years of service. And now to sleep, > perchance to dream... And yes, I just heard, it is snowing in hell. This is for you, Nathan: http://www.youtube.com/watch?v=4m8ltkjO7Pg -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpUmDN9UFGgm.pgp Description: PGP signature
svn commit: r219636 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Author: pjd Date: Mon Mar 14 11:07:12 2011 New Revision: 219636 URL: http://svn.freebsd.org/changeset/base/219636 Log: Fix potential panic in dbuf_sync_list() relate to spill blocks handling. Obtained from:IllumOS MFC after:1 month Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c == --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Mon Mar 14 10:51:24 2011(r219635) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Mon Mar 14 11:07:12 2011(r219636) @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. */ #include @@ -1300,13 +1301,17 @@ dbuf_undirty(dmu_buf_impl_t *db, dmu_tx_ * it, since one of the current holders may be in the * middle of an update. Note that users of dbuf_undirty() * should not place a hold on the dbuf before the call. +* Also note: we can get here with a spill block, so +* test for that similar to how dbuf_dirty does. */ if (refcount_count(&db->db_holds) > db->db_dirtycnt) { mutex_exit(&db->db_mtx); /* Make sure we don't toss this buffer at sync phase */ - mutex_enter(&dn->dn_mtx); - dnode_clear_range(dn, db->db_blkid, 1, tx); - mutex_exit(&dn->dn_mtx); + if (db->db_blkid != DMU_SPILL_BLKID) { + mutex_enter(&dn->dn_mtx); + dnode_clear_range(dn, db->db_blkid, 1, tx); + mutex_exit(&dn->dn_mtx); + } DB_DNODE_EXIT(db); return (0); } @@ -1319,11 +1324,18 @@ dbuf_undirty(dmu_buf_impl_t *db, dmu_tx_ *drp = dr->dr_next; + /* +* Note that there are three places in dbuf_dirty() +* where this dirty record may be put on a list. +* Make sure to do a list_remove corresponding to +* every one of those list_insert calls. +*/ if (dr->dr_parent) { mutex_enter(&dr->dr_parent->dt.di.dr_mtx); list_remove(&dr->dr_parent->dt.di.dr_children, dr); mutex_exit(&dr->dr_parent->dt.di.dr_mtx); - } else if (db->db_level+1 == dn->dn_nlevels) { + } else if (db->db_blkid == DMU_SPILL_BLKID || + db->db_level+1 == dn->dn_nlevels) { ASSERT(db->db_blkptr == NULL || db->db_parent == dn->dn_dbuf); mutex_enter(&dn->dn_mtx); list_remove(&dn->dn_dirty_records[txg & TXG_MASK], dr); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219621 - head/tools/regression/pjdfstest/tests/open
Author: pjd Date: Sun Mar 13 19:35:13 2011 New Revision: 219621 URL: http://svn.freebsd.org/changeset/base/219621 Log: POSIX accepts only ELOOP if O_NOFOLLOW is specified and target is a symlink. Modified: head/tools/regression/pjdfstest/tests/open/16.t Modified: head/tools/regression/pjdfstest/tests/open/16.t == --- head/tools/regression/pjdfstest/tests/open/16.t Sun Mar 13 19:23:32 2011(r219620) +++ head/tools/regression/pjdfstest/tests/open/16.t Sun Mar 13 19:35:13 2011(r219621) @@ -1,7 +1,7 @@ #!/bin/sh # $FreeBSD$ -desc="open returns EMLINK/ELOOP when O_NOFOLLOW was specified and the target is a symbolic link" +desc="open returns ELOOP when O_NOFOLLOW was specified and the target is a symbolic link" dir=`dirname $0` . ${dir}/../misc.sh @@ -12,8 +12,8 @@ n0=`namegen` n1=`namegen` expect 0 symlink ${n0} ${n1} -expect "EMLINK|ELOOP" open ${n1} O_RDONLY,O_CREAT,O_NOFOLLOW 0644 -expect "EMLINK|ELOOP" open ${n1} O_RDONLY,O_NOFOLLOW -expect "EMLINK|ELOOP" open ${n1} O_WRONLY,O_NOFOLLOW -expect "EMLINK|ELOOP" open ${n1} O_RDWR,O_NOFOLLOW +expect ELOOP open ${n1} O_RDONLY,O_CREAT,O_NOFOLLOW 0644 +expect ELOOP open ${n1} O_RDONLY,O_NOFOLLOW +expect ELOOP open ${n1} O_WRONLY,O_NOFOLLOW +expect ELOOP open ${n1} O_RDWR,O_NOFOLLOW expect 0 unlink ${n1} ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219566 - head/tools/regression/pjdfstest
Author: pjd Date: Sat Mar 12 14:09:43 2011 New Revision: 219566 URL: http://svn.freebsd.org/changeset/base/219566 Log: Add some missing consts. Modified: head/tools/regression/pjdfstest/pjdfstest.c Modified: head/tools/regression/pjdfstest/pjdfstest.c == --- head/tools/regression/pjdfstest/pjdfstest.c Sat Mar 12 12:10:17 2011 (r219565) +++ head/tools/regression/pjdfstest/pjdfstest.c Sat Mar 12 14:09:43 2011 (r219566) @@ -129,7 +129,7 @@ enum action { #defineMAX_ARGS8 struct syscall_desc { - char*sd_name; + const char *sd_name; enum action sd_action; int sd_args[MAX_ARGS]; }; @@ -193,7 +193,7 @@ static struct syscall_desc syscalls[] = struct flag { long longf_flag; - char*f_str; + const char *f_str; }; static struct flag open_flags[] = { @@ -310,8 +310,8 @@ static struct flag fstatat_flags[] = { }; struct name { - int n_name; - char*n_str; + int n_name; + const char *n_str; }; static struct name pathconf_names[] = { ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r219483 - head/sys/boot/i386/gptboot
On Fri, Mar 11, 2011 at 01:11:15PM +, John Baldwin wrote: > Author: jhb > Date: Fri Mar 11 13:11:15 2011 > New Revision: 219483 > URL: http://svn.freebsd.org/changeset/base/219483 > > Log: > Remove all object files during 'make clean'. Oops, I think that was me. Thank you, John. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpN4jOfBqEnJ.pgp Description: PGP signature
svn commit: r219464 - head/tools/regression/pjdfstest
Author: pjd Date: Thu Mar 10 21:00:30 2011 New Revision: 219464 URL: http://svn.freebsd.org/changeset/base/219464 Log: Add support for *at syscalls: - openat(2) - unlinkat(2) - mkdirat(2) - linkat(2) - symlinkat(2) - renameat(2) - mkfifoat(2) - mknodat(2) - fchmodat(2) - fchownat(2) - fstatat(2) Modified: head/tools/regression/pjdfstest/pjdfstest.c Modified: head/tools/regression/pjdfstest/pjdfstest.c == --- head/tools/regression/pjdfstest/pjdfstest.c Thu Mar 10 20:59:02 2011 (r219463) +++ head/tools/regression/pjdfstest/pjdfstest.c Thu Mar 10 21:00:30 2011 (r219464) @@ -64,15 +64,23 @@ enum action { ACTION_OPEN, + ACTION_OPENAT, ACTION_CREATE, ACTION_UNLINK, + ACTION_UNLINKAT, ACTION_MKDIR, + ACTION_MKDIRAT, ACTION_RMDIR, ACTION_LINK, + ACTION_LINKAT, ACTION_SYMLINK, + ACTION_SYMLINKAT, ACTION_RENAME, + ACTION_RENAMEAT, ACTION_MKFIFO, + ACTION_MKFIFOAT, ACTION_MKNOD, + ACTION_MKNODAT, ACTION_BIND, ACTION_CONNECT, ACTION_CHMOD, @@ -80,9 +88,11 @@ enum action { #ifdef HAS_LCHMOD ACTION_LCHMOD, #endif + ACTION_FCHMODAT, ACTION_CHOWN, ACTION_FCHOWN, ACTION_LCHOWN, + ACTION_FCHOWNAT, #ifdef HAS_CHFLAGS ACTION_CHFLAGS, #endif @@ -97,6 +107,7 @@ enum action { ACTION_STAT, ACTION_FSTAT, ACTION_LSTAT, + ACTION_FSTATAT, ACTION_PATHCONF, ACTION_FPATHCONF, ACTION_LPATHCONF, @@ -110,6 +121,8 @@ enum action { #defineTYPE_NONE 0x #defineTYPE_STRING 0x0001 #defineTYPE_NUMBER 0x0002 +#defineTYPE_DESCRIPTOR 0x0003 +#defineTYPE_MASK 0x000f #defineTYPE_OPTIONAL 0x0100 @@ -123,47 +136,58 @@ struct syscall_desc { static struct syscall_desc syscalls[] = { { "open", ACTION_OPEN, { TYPE_STRING, TYPE_STRING, TYPE_NUMBER | TYPE_OPTIONAL, TYPE_NONE } }, + { "openat", ACTION_OPENAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_STRING, TYPE_NUMBER | TYPE_OPTIONAL, TYPE_NONE } }, { "create", ACTION_CREATE, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, { "unlink", ACTION_UNLINK, { TYPE_STRING, TYPE_NONE } }, + { "unlinkat", ACTION_UNLINKAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_STRING, TYPE_NONE } }, { "mkdir", ACTION_MKDIR, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, + { "mkdirat", ACTION_MKDIRAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, { "rmdir", ACTION_RMDIR, { TYPE_STRING, TYPE_NONE } }, { "link", ACTION_LINK, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, + { "linkat", ACTION_LINKAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_DESCRIPTOR, TYPE_STRING, TYPE_STRING, TYPE_NONE } }, { "symlink", ACTION_SYMLINK, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, + { "symlinkat", ACTION_SYMLINKAT, { TYPE_STRING, TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NONE } }, { "rename", ACTION_RENAME, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, + { "renameat", ACTION_RENAMEAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NONE } }, { "mkfifo", ACTION_MKFIFO, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, + { "mkfifoat", ACTION_MKFIFOAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, { "mknod", ACTION_MKNOD, { TYPE_STRING, TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE} }, + { "mknodat", ACTION_MKNODAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE} }, { "bind", ACTION_BIND, { TYPE_STRING, TYPE_NONE } }, { "connect", ACTION_CONNECT, { TYPE_STRING, TYPE_NONE } }, { "chmod", ACTION_CHMOD, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, - { "fchmod", ACTION_FCHMOD, { TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } }, + { "fchmod", ACTION_FCHMOD, { TYPE_DESCRIPTOR, TYPE_NUMBER, TYPE_NONE } }, #ifdef HAS_LCHMOD { "lchmod", ACTION_LCHMOD, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, #endif + { "fchmodat", ACTION_FCHMODAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NUMBER, TYPE_STRING, TYPE_NONE } }, { "chown", ACTION_CHOWN, { TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } }, - { "fchown", ACTION_FCHOWN, { TYPE_NUMBER, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } }, + { "fchown", ACTION_FCHOWN, { TYPE_DESCRIPTOR, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } }, { "lchown", ACTION_LCHOWN, { TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } }, + { "fchownat", ACTION_FCHOWNAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_STRING, TYPE_NONE } }, #ifdef HAS_CHFLAGS { "chflags", ACTION_CHFLAGS, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, #endif #ifdef HAS_FCHFLAGS - { "fchflags", ACTION_FCHFLAGS, { TYPE
svn commit: r219463 - head/tools/regression/pjdfstest/tests/chmod
Author: pjd Date: Thu Mar 10 20:59:02 2011 New Revision: 219463 URL: http://svn.freebsd.org/changeset/base/219463 Log: Improve test a bit, now that we have fstat(2) support. The test was support to check if SUID/SGID bits are removed on first write, but actually we were checking if they were removed after close. Now we can check if SUID/SGID bits are gone after first write. While here add checks to see if when both SUID and SGID bits are set they are both cleared on first write. Modified: head/tools/regression/pjdfstest/tests/chmod/12.t Modified: head/tools/regression/pjdfstest/tests/chmod/12.t == --- head/tools/regression/pjdfstest/tests/chmod/12.tThu Mar 10 20:37:54 2011(r219462) +++ head/tools/regression/pjdfstest/tests/chmod/12.tThu Mar 10 20:59:02 2011(r219463) @@ -6,7 +6,7 @@ desc="verify SUID/SGID bit behaviour" dir=`dirname $0` . ${dir}/../misc.sh -echo "1..10" +echo "1..14" n0=`namegen` n1=`namegen` @@ -18,13 +18,19 @@ cd ${n2} # Check whether writing to the file by non-owner clears the SUID. expect 0 create ${n0} 04777 -expect 0 -u 65534 -g 65534 open ${n0} O_WRONLY : write 0 x +expect 0777 -u 65534 -g 65534 open ${n0} O_WRONLY : write 0 x : fstat 0 mode expect 0777 stat ${n0} mode expect 0 unlink ${n0} # Check whether writing to the file by non-owner clears the SGID. expect 0 create ${n0} 02777 -expect 0 -u 65534 -g 65534 open ${n0} O_RDWR : write 0 x +expect 0777 -u 65534 -g 65534 open ${n0} O_RDWR : write 0 x : fstat 0 mode +expect 0777 stat ${n0} mode +expect 0 unlink ${n0} + +# Check whether writing to the file by non-owner clears the SUID+SGID. +expect 0 create ${n0} 06777 +expect 0777 -u 65534 -g 65534 open ${n0} O_RDWR : write 0 x : fstat 0 mode expect 0777 stat ${n0} mode expect 0 unlink ${n0} ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r219462 - svnadmin/conf
Author: pjd Date: Thu Mar 10 20:37:54 2011 New Revision: 219462 URL: http://svn.freebsd.org/changeset/base/219462 Log: Please welcome Mikolaj Golub as a new src committer. Mikolaj will be working on HAST and I'm sure lots of other stuff. I'll be his mentor and kib@ will help me. Approved by: core Modified: svnadmin/conf/access svnadmin/conf/mentors Modified: svnadmin/conf/access == --- svnadmin/conf/accessThu Mar 10 20:02:58 2011(r219461) +++ svnadmin/conf/accessThu Mar 10 20:37:54 2011(r219462) @@ -227,6 +227,7 @@ thompsa ticso tijl trasz +trociny trhodes truckman tuexen Modified: svnadmin/conf/mentors == --- svnadmin/conf/mentors Thu Mar 10 20:02:58 2011(r219461) +++ svnadmin/conf/mentors Thu Mar 10 20:37:54 2011(r219462) @@ -30,6 +30,7 @@ sbrunoscottl snbdwmalone sson gnn tijl kib +trocinypjd Co-mentor: kib versus gavin Co-mentor: fjoe will ken zack zml ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"