From owner-svn-src-stable-11@freebsd.org Sun Mar 19 07:34:20 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E91F5D13BA4; Sun, 19 Mar 2017 07:34:20 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B5EAA1FFC; Sun, 19 Mar 2017 07:34:20 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2J7YJiC095283; Sun, 19 Mar 2017 07:34:19 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2J7YJu0095279; Sun, 19 Mar 2017 07:34:19 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201703190734.v2J7YJu0095279@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Sun, 19 Mar 2017 07:34:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315532 - stable/11/sys/netpfil/ipfw X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 07:34:21 -0000 Author: ae Date: Sun Mar 19 07:34:19 2017 New Revision: 315532 URL: https://svnweb.freebsd.org/changeset/base/315532 Log: MFC r314716: Add IPv6 support to O_IP_DST_LOOKUP opcode. o check the size of O_IP_SRC_LOOKUP opcode, it can not exceed the size of ipfw_insn_u32; o rename ipfw_lookup_table_extended() function into ipfw_lookup_table() and remove old ipfw_lookup_table(); o use args->f_id.flow_id6 that is in host byte order to get DSCP value; o add SCTP ports support to 'lookup src/dst-port' opcode; o add IPv6 support to 'lookup src/dst-ip' opcode. PR: 217292 Sponsored by: Yandex LLC Differential Revision: https://reviews.freebsd.org/D9873 Modified: stable/11/sys/netpfil/ipfw/ip_fw2.c stable/11/sys/netpfil/ipfw/ip_fw_private.h stable/11/sys/netpfil/ipfw/ip_fw_sockopt.c stable/11/sys/netpfil/ipfw/ip_fw_table.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netpfil/ipfw/ip_fw2.c ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw2.c Sun Mar 19 05:00:14 2017 (r315531) +++ stable/11/sys/netpfil/ipfw/ip_fw2.c Sun Mar 19 07:34:19 2017 (r315532) @@ -382,8 +382,8 @@ iface_match(struct ifnet *ifp, ipfw_insn /* Check by name or by IP address */ if (cmd->name[0] != '\0') { /* match by name */ if (cmd->name[0] == '\1') /* use tablearg to match */ - return ipfw_lookup_table_extended(chain, cmd->p.kidx, 0, - &ifp->if_index, tablearg); + return ipfw_lookup_table(chain, cmd->p.kidx, 0, + &ifp->if_index, tablearg); /* Check name */ if (cmd->p.glob) { if (fnmatch(cmd->name, ifp->if_xname, 0) == 0) @@ -1454,86 +1454,130 @@ do { \ src_ip.s_addr); break; - case O_IP_SRC_LOOKUP: case O_IP_DST_LOOKUP: - if (is_ipv4) { - uint32_t key = - (cmd->opcode == O_IP_DST_LOOKUP) ? - dst_ip.s_addr : src_ip.s_addr; - uint32_t v = 0; - - if (cmdlen > F_INSN_SIZE(ipfw_insn_u32)) { - /* generic lookup. The key must be - * in 32bit big-endian format. - */ - v = ((ipfw_insn_u32 *)cmd)->d[1]; - if (v == 0) - key = dst_ip.s_addr; - else if (v == 1) - key = src_ip.s_addr; - else if (v == 6) /* dscp */ - key = (ip->ip_tos >> 2) & 0x3f; - else if (offset != 0) - break; - else if (proto != IPPROTO_TCP && - proto != IPPROTO_UDP) - break; - else if (v == 2) - key = dst_port; - else if (v == 3) - key = src_port; + { + void *pkey; + uint32_t vidx, key; + uint16_t keylen; + + if (cmdlen > F_INSN_SIZE(ipfw_insn_u32)) { + /* Determine lookup key type */ + vidx = ((ipfw_insn_u32 *)cmd)->d[1]; + if (vidx != 4 /* uid */ && + vidx != 5 /* jail */ && + is_ipv6 == 0 && is_ipv4 == 0) + break; + /* Determine key length */ + if (vidx == 0 /* dst-ip */ || + vidx == 1 /* src-ip */) + keylen = is_ipv6 ? + sizeof(struct in6_addr): + sizeof(in_addr_t); + else { + keylen = sizeof(key); + pkey = &key; + } + if (vidx == 0 /* dst-ip */) + pkey = is_ipv4 ? (void *)&dst_ip: + (void *)&args->f_id.dst_ip6; + else if (vidx == 1 /* src-ip */) + pkey = is_ipv4 ? (void *)&src_ip: + (void *)&args->f_id.src_ip6; + else if (vidx == 6 /* dscp */) { + if (is_ipv4) + key = ip->ip_tos >> 2; + else { + key = args->f_id.flow_id6; + key = (key & 0x0f) << 2 | + (key & 0xf000) >> 14; + } + key &= 0x3f; + } else if (vidx == 2 /* dst-port */ || + vidx == 3 /* src-port */) { + /* Skip fragments */ + if (offset != 0) + break; + /* Skip proto without ports */ + if (proto != IPPROTO_TCP && + proto != IPPROTO_UDP && + proto != IPPROTO_SCTP) + break; + if (vidx == 2 /* dst-port */) + key = dst_port; + else + key = src_port; + } #ifndef USERSPACE - else if (v == 4 || v == 5) { - check_uidgid( - (ipfw_insn_u32 *)cmd, - args, &ucred_lookup, + else if (vidx == 4 /* uid */ || + vidx == 5 /* jail */) { + check_uidgid( + (ipfw_insn_u32 *)cmd, + args, &ucred_lookup, #ifdef __FreeBSD__ - &ucred_cache); - if (v == 4 /* O_UID */) - key = ucred_cache->cr_uid; - else if (v == 5 /* O_JAIL */) - key = ucred_cache->cr_prison->pr_id; + &ucred_cache); + if (vidx == 4 /* uid */) + key = ucred_cache->cr_uid; + else if (vidx == 5 /* jail */) + key = ucred_cache->cr_prison->pr_id; #else /* !__FreeBSD__ */ - (void *)&ucred_cache); - if (v ==4 /* O_UID */) - key = ucred_cache.uid; - else if (v == 5 /* O_JAIL */) - key = ucred_cache.xid; + (void *)&ucred_cache); + if (vidx == 4 /* uid */) + key = ucred_cache.uid; + else if (vidx == 5 /* jail */) + key = ucred_cache.xid; #endif /* !__FreeBSD__ */ } #endif /* !USERSPACE */ else - break; - } - match = ipfw_lookup_table(chain, - cmd->arg1, key, &v); - if (!match) + break; + match = ipfw_lookup_table(chain, + cmd->arg1, keylen, pkey, &vidx); + if (!match) + break; + tablearg = vidx; break; - if (cmdlen == F_INSN_SIZE(ipfw_insn_u32)) - match = ((ipfw_insn_u32 *)cmd)->d[0] == - TARG_VAL(chain, v, tag); - else - tablearg = v; + } + /* cmdlen =< F_INSN_SIZE(ipfw_insn_u32) */ + /* FALLTHROUGH */ + } + case O_IP_SRC_LOOKUP: + { + void *pkey; + uint32_t vidx; + uint16_t keylen; + + if (is_ipv4) { + keylen = sizeof(in_addr_t); + if (cmd->opcode == O_IP_DST_LOOKUP) + pkey = &dst_ip; + else + pkey = &src_ip; } else if (is_ipv6) { - uint32_t v = 0; - void *pkey = (cmd->opcode == O_IP_DST_LOOKUP) ? - &args->f_id.dst_ip6: &args->f_id.src_ip6; - match = ipfw_lookup_table_extended(chain, - cmd->arg1, - sizeof(struct in6_addr), - pkey, &v); - if (cmdlen == F_INSN_SIZE(ipfw_insn_u32)) - match = ((ipfw_insn_u32 *)cmd)->d[0] == - TARG_VAL(chain, v, tag); - if (match) - tablearg = v; + keylen = sizeof(struct in6_addr); + if (cmd->opcode == O_IP_DST_LOOKUP) + pkey = &args->f_id.dst_ip6; + else + pkey = &args->f_id.src_ip6; + } else + break; + match = ipfw_lookup_table(chain, cmd->arg1, + keylen, pkey, &vidx); + if (!match) + break; + if (cmdlen == F_INSN_SIZE(ipfw_insn_u32)) { + match = ((ipfw_insn_u32 *)cmd)->d[0] == + TARG_VAL(chain, vidx, tag); + if (!match) + break; } + tablearg = vidx; break; + } case O_IP_FLOW_LOOKUP: { uint32_t v = 0; - match = ipfw_lookup_table_extended(chain, + match = ipfw_lookup_table(chain, cmd->arg1, 0, &args->f_id, &v); if (cmdlen == F_INSN_SIZE(ipfw_insn_u32)) match = ((ipfw_insn_u32 *)cmd)->d[0] == Modified: stable/11/sys/netpfil/ipfw/ip_fw_private.h ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw_private.h Sun Mar 19 05:00:14 2017 (r315531) +++ stable/11/sys/netpfil/ipfw/ip_fw_private.h Sun Mar 19 07:34:19 2017 (r315532) @@ -739,9 +739,7 @@ struct table_info; typedef int (table_lookup_t)(struct table_info *ti, void *key, uint32_t keylen, uint32_t *val); -int ipfw_lookup_table(struct ip_fw_chain *ch, uint16_t tbl, in_addr_t addr, - uint32_t *val); -int ipfw_lookup_table_extended(struct ip_fw_chain *ch, uint16_t tbl, uint16_t plen, +int ipfw_lookup_table(struct ip_fw_chain *ch, uint16_t tbl, uint16_t plen, void *paddr, uint32_t *val); int ipfw_init_tables(struct ip_fw_chain *ch, int first); int ipfw_resize_tables(struct ip_fw_chain *ch, unsigned int ntables); Modified: stable/11/sys/netpfil/ipfw/ip_fw_sockopt.c ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw_sockopt.c Sun Mar 19 05:00:14 2017 (r315531) +++ stable/11/sys/netpfil/ipfw/ip_fw_sockopt.c Sun Mar 19 07:34:19 2017 (r315532) @@ -1821,6 +1821,8 @@ check_ipfw_rule_body(ipfw_insn *cmd, int break; case O_IP_SRC_LOOKUP: + if (cmdlen > F_INSN_SIZE(ipfw_insn_u32)) + goto bad_size; case O_IP_DST_LOOKUP: if (cmd->arg1 >= V_fw_tables_max) { printf("ipfw: invalid table number %d\n", Modified: stable/11/sys/netpfil/ipfw/ip_fw_table.c ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw_table.c Sun Mar 19 05:00:14 2017 (r315531) +++ stable/11/sys/netpfil/ipfw/ip_fw_table.c Sun Mar 19 07:34:19 2017 (r315532) @@ -1606,30 +1606,13 @@ ipfw_resize_tables(struct ip_fw_chain *c } /* - * Lookup an IP @addr in table @tbl. - * Stores found value in @val. - * - * Returns 1 if @addr was found. - */ -int -ipfw_lookup_table(struct ip_fw_chain *ch, uint16_t tbl, in_addr_t addr, - uint32_t *val) -{ - struct table_info *ti; - - ti = KIDX_TO_TI(ch, tbl); - - return (ti->lookup(ti, &addr, sizeof(in_addr_t), val)); -} - -/* * Lookup an arbtrary key @paddr of legth @plen in table @tbl. * Stores found value in @val. * * Returns 1 if key was found. */ int -ipfw_lookup_table_extended(struct ip_fw_chain *ch, uint16_t tbl, uint16_t plen, +ipfw_lookup_table(struct ip_fw_chain *ch, uint16_t tbl, uint16_t plen, void *paddr, uint32_t *val) { struct table_info *ti; From owner-svn-src-stable-11@freebsd.org Sun Mar 19 10:26:01 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B026ED11F4B; Sun, 19 Mar 2017 10:26:01 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 626ECC40; Sun, 19 Mar 2017 10:26:01 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JAQ04N064606; Sun, 19 Mar 2017 10:26:00 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JAQ02c064604; Sun, 19 Mar 2017 10:26:00 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191026.v2JAQ02c064604@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 10:26:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315535 - stable/11/usr.bin/iscsictl X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 10:26:01 -0000 Author: trasz Date: Sun Mar 19 10:26:00 2017 New Revision: 315535 URL: https://svnweb.freebsd.org/changeset/base/315535 Log: MFC r312539 (by mav@): Remove some unused code. Modified: stable/11/usr.bin/iscsictl/iscsictl.c stable/11/usr.bin/iscsictl/iscsictl.h Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/iscsictl/iscsictl.c ============================================================================== --- stable/11/usr.bin/iscsictl/iscsictl.c Sun Mar 19 09:36:43 2017 (r315534) +++ stable/11/usr.bin/iscsictl/iscsictl.c Sun Mar 19 10:26:00 2017 (r315535) @@ -700,17 +700,6 @@ usage(void) exit(1); } -char * -checked_strdup(const char *s) -{ - char *c; - - c = strdup(s); - if (c == NULL) - xo_err(1, "strdup"); - return (c); -} - int main(int argc, char **argv) { Modified: stable/11/usr.bin/iscsictl/iscsictl.h ============================================================================== --- stable/11/usr.bin/iscsictl/iscsictl.h Sun Mar 19 09:36:43 2017 (r315534) +++ stable/11/usr.bin/iscsictl/iscsictl.h Sun Mar 19 10:26:00 2017 (r315535) @@ -40,7 +40,6 @@ #define DEFAULT_IQN "iqn.1994-09.org.freebsd:" #define MAX_NAME_LEN 223 -#define MAX_DATA_SEGMENT_LENGTH 65536 #define AUTH_METHOD_UNSPECIFIED 0 #define AUTH_METHOD_NONE 1 @@ -88,23 +87,6 @@ struct conf { TAILQ_HEAD(, target) conf_targets; }; -#define CONN_SESSION_TYPE_NONE 0 -#define CONN_SESSION_TYPE_DISCOVERY 1 -#define CONN_SESSION_TYPE_NORMAL 2 - -struct connection { - struct target *conn_target; - int conn_socket; - int conn_session_type; - uint32_t conn_cmdsn; - uint32_t conn_statsn; - size_t conn_max_data_segment_length; - size_t conn_max_burst_length; - size_t conn_max_outstanding_r2t; - int conn_header_digest; - int conn_data_digest; -}; - struct conf *conf_new(void); struct conf *conf_new_from_file(const char *path); void conf_delete(struct conf *conf); @@ -116,7 +98,6 @@ void target_delete(struct target *ic); void print_periphs(int session_id); -char *checked_strdup(const char *); bool valid_iscsi_name(const char *name); int parse_enable(const char *enable); From owner-svn-src-stable-11@freebsd.org Sun Mar 19 10:28:52 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7222FD12098; Sun, 19 Mar 2017 10:28:52 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 413D0F33; Sun, 19 Mar 2017 10:28:52 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JASpej064809; Sun, 19 Mar 2017 10:28:51 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JASpPQ064808; Sun, 19 Mar 2017 10:28:51 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191028.v2JASpPQ064808@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 10:28:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315537 - stable/11/sys/compat/linux X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 10:28:52 -0000 Author: trasz Date: Sun Mar 19 10:28:51 2017 New Revision: 315537 URL: https://svnweb.freebsd.org/changeset/base/315537 Log: MFC r313017: Fix linux_getppid() to debug the actual parent, even it was reparented by debugger. Modified: stable/11/sys/compat/linux/linux_misc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linux/linux_misc.c ============================================================================== --- stable/11/sys/compat/linux/linux_misc.c Sun Mar 19 10:28:04 2017 (r315536) +++ stable/11/sys/compat/linux/linux_misc.c Sun Mar 19 10:28:51 2017 (r315537) @@ -1726,9 +1726,7 @@ linux_getppid(struct thread *td, struct printf(ARGS(getppid, "")); #endif - PROC_LOCK(td->td_proc); - td->td_retval[0] = td->td_proc->p_pptr->p_pid; - PROC_UNLOCK(td->td_proc); + td->td_retval[0] = kern_getppid(td); return (0); } From owner-svn-src-stable-11@freebsd.org Sun Mar 19 10:32:41 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3B1CDD1230B; Sun, 19 Mar 2017 10:32:41 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 09FF113D1; Sun, 19 Mar 2017 10:32:40 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JAWeqK068679; Sun, 19 Mar 2017 10:32:40 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JAWeKq068678; Sun, 19 Mar 2017 10:32:40 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191032.v2JAWeKq068678@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 10:32:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315538 - stable/11/sys/compat/linux X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 10:32:41 -0000 Author: trasz Date: Sun Mar 19 10:32:39 2017 New Revision: 315538 URL: https://svnweb.freebsd.org/changeset/base/315538 Log: MFC r313283: Fix linux_pipe() and linux_pipe2() to close file descriptors on copyout error. Modified: stable/11/sys/compat/linux/linux_file.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linux/linux_file.c ============================================================================== --- stable/11/sys/compat/linux/linux_file.c Sun Mar 19 10:28:51 2017 (r315537) +++ stable/11/sys/compat/linux/linux_file.c Sun Mar 19 10:32:39 2017 (r315538) @@ -1629,11 +1629,16 @@ linux_pipe(struct thread *td, struct lin #endif error = kern_pipe(td, fildes, 0, NULL, NULL); - if (error) + if (error != 0) return (error); - /* XXX: Close descriptors on error. */ - return (copyout(fildes, args->pipefds, sizeof(fildes))); + error = copyout(fildes, args->pipefds, sizeof(fildes)); + if (error != 0) { + (void)kern_close(td, fildes[0]); + (void)kern_close(td, fildes[1]); + } + + return (error); } int @@ -1656,11 +1661,16 @@ linux_pipe2(struct thread *td, struct li if ((args->flags & LINUX_O_CLOEXEC) != 0) flags |= O_CLOEXEC; error = kern_pipe(td, fildes, flags, NULL, NULL); - if (error) + if (error != 0) return (error); - /* XXX: Close descriptors on error. */ - return (copyout(fildes, args->pipefds, sizeof(fildes))); + error = copyout(fildes, args->pipefds, sizeof(fildes)); + if (error != 0) { + (void)kern_close(td, fildes[0]); + (void)kern_close(td, fildes[1]); + } + + return (error); } int From owner-svn-src-stable-11@freebsd.org Sun Mar 19 10:34:28 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4A806D123E0; Sun, 19 Mar 2017 10:34:28 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F3EBF159E; Sun, 19 Mar 2017 10:34:27 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JAYRLd068815; Sun, 19 Mar 2017 10:34:27 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JAYRb8068814; Sun, 19 Mar 2017 10:34:27 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191034.v2JAYRb8068814@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 10:34:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315539 - stable/11/sys/kern X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 10:34:28 -0000 Author: trasz Date: Sun Mar 19 10:34:26 2017 New Revision: 315539 URL: https://svnweb.freebsd.org/changeset/base/315539 Log: MFC r313350: In r290196 the root mount hold mechanism was changed to make it not wait for mount hold release if the root device already exists. So, unless your rootdev is not on USB - ie in the usual case - the root mount won't wait for USB. However, the old behaviour was sometimes used as "wait until USB is fully enumerated", and r290196 broke that. This commit adds vfs.root_mount_always_wait tunable, to force the kernel to always wait for root mount holds, even if the root is already there. Relnotes: yes Modified: stable/11/sys/kern/vfs_mountroot.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/vfs_mountroot.c ============================================================================== --- stable/11/sys/kern/vfs_mountroot.c Sun Mar 19 10:32:39 2017 (r315538) +++ stable/11/sys/kern/vfs_mountroot.c Sun Mar 19 10:34:26 2017 (r315539) @@ -132,6 +132,11 @@ static int root_mount_complete; static int root_mount_timeout = 3; TUNABLE_INT("vfs.mountroot.timeout", &root_mount_timeout); +static int root_mount_always_wait = 0; +SYSCTL_INT(_vfs, OID_AUTO, root_mount_always_wait, CTLFLAG_RDTUN, + &root_mount_always_wait, 0, + "Wait for root mount holds even if the root device already exists"); + SYSCTL_PROC(_vfs, OID_AUTO, root_mount_hold, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, sysctl_vfs_root_mount_hold, "A", @@ -961,10 +966,11 @@ vfs_mountroot_wait_if_neccessary(const c /* * In case of ZFS and NFS we don't have a way to wait for - * specific device. + * specific device. Also do the wait if the user forced that + * behaviour by setting vfs.root_mount_always_wait=1. */ if (strcmp(fs, "zfs") == 0 || strstr(fs, "nfs") != NULL || - dev[0] == '\0') { + dev[0] == '\0' || root_mount_always_wait != 0) { vfs_mountroot_wait(); return (0); } From owner-svn-src-stable-11@freebsd.org Sun Mar 19 10:35:58 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4021AD12478; Sun, 19 Mar 2017 10:35:58 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0CA5C16DC; Sun, 19 Mar 2017 10:35:57 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JAZv12068930; Sun, 19 Mar 2017 10:35:57 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JAZvNv068929; Sun, 19 Mar 2017 10:35:57 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191035.v2JAZvNv068929@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 10:35:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315540 - stable/11/sys/kern X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 10:35:58 -0000 Author: trasz Date: Sun Mar 19 10:35:56 2017 New Revision: 315540 URL: https://svnweb.freebsd.org/changeset/base/315540 Log: MFC r313351: Make root_mount_hold() work after boot. This is important for two reasons. First is rerooting into USB-mounted device that happens to be not yet enumerated. The second is when mounting with (non-root) filesystem on USB device on a hub that's enumerated later than the root mount: the rc scripts explicitly mount for the root mount holds to be released, but each USB bus takes the hold asynchronously, and if that happens after root mount, it would just get ignored. Modified: stable/11/sys/kern/vfs_mountroot.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/vfs_mountroot.c ============================================================================== --- stable/11/sys/kern/vfs_mountroot.c Sun Mar 19 10:34:26 2017 (r315539) +++ stable/11/sys/kern/vfs_mountroot.c Sun Mar 19 10:35:56 2017 (r315540) @@ -171,9 +171,6 @@ root_mount_hold(const char *identifier) { struct root_hold_token *h; - if (root_mounted()) - return (NULL); - h = malloc(sizeof *h, M_DEVBUF, M_ZERO | M_WAITOK); h->who = identifier; mtx_lock(&root_holds_mtx); @@ -186,8 +183,8 @@ void root_mount_rel(struct root_hold_token *h) { - if (h == NULL) - return; + KASSERT(h != NULL, ("%s: NULL token", __func__)); + mtx_lock(&root_holds_mtx); LIST_REMOVE(h, list); wakeup(&root_holds); From owner-svn-src-stable-11@freebsd.org Sun Mar 19 10:37:04 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7AAD8D12511; Sun, 19 Mar 2017 10:37:04 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 499501840; Sun, 19 Mar 2017 10:37:04 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JAb31g069029; Sun, 19 Mar 2017 10:37:03 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JAb3AR069028; Sun, 19 Mar 2017 10:37:03 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191037.v2JAb3AR069028@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 10:37:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315541 - stable/11/sys/compat/linux X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 10:37:04 -0000 Author: trasz Date: Sun Mar 19 10:37:03 2017 New Revision: 315541 URL: https://svnweb.freebsd.org/changeset/base/315541 Log: MFC r313804: Improve debugging output. Modified: stable/11/sys/compat/linux/linux.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linux/linux.c ============================================================================== --- stable/11/sys/compat/linux/linux.c Sun Mar 19 10:35:56 2017 (r315540) +++ stable/11/sys/compat/linux/linux.c Sun Mar 19 10:37:03 2017 (r315541) @@ -128,7 +128,7 @@ int linux_to_bsd_signal(int sig) { - KASSERT(sig > 0 && sig <= LINUX_SIGRTMAX, ("Invalid Linux signal\n")); + KASSERT(sig > 0 && sig <= LINUX_SIGRTMAX, ("invalid Linux signal %d\n", sig)); if (sig < LINUX_SIGRTMIN) return (linux_to_bsd_sigtbl[_SIG_IDX(sig)]); From owner-svn-src-stable-11@freebsd.org Sun Mar 19 10:38:29 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 483B6D12592; Sun, 19 Mar 2017 10:38:29 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 144B31993; Sun, 19 Mar 2017 10:38:29 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JAcSwE069136; Sun, 19 Mar 2017 10:38:28 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JAcSms069135; Sun, 19 Mar 2017 10:38:28 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191038.v2JAcSms069135@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 10:38:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315542 - stable/11/sys/compat/linprocfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 10:38:29 -0000 Author: trasz Date: Sun Mar 19 10:38:27 2017 New Revision: 315542 URL: https://svnweb.freebsd.org/changeset/base/315542 Log: MFC r313995: Add /proc/self/mounts to linprocfs; some linux binaries need it. Modified: stable/11/sys/compat/linprocfs/linprocfs.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linprocfs/linprocfs.c ============================================================================== --- stable/11/sys/compat/linprocfs/linprocfs.c Sun Mar 19 10:37:03 2017 (r315541) +++ stable/11/sys/compat/linprocfs/linprocfs.c Sun Mar 19 10:38:27 2017 (r315542) @@ -1543,6 +1543,8 @@ linprocfs_init(PFS_INIT_ARGS) NULL, NULL, NULL, PFS_RD); pfs_create_file(dir, "mem", &procfs_doprocmem, &procfs_attr, &procfs_candebug, NULL, PFS_RDWR|PFS_RAW); + pfs_create_file(dir, "mounts", &linprocfs_domtab, + NULL, NULL, NULL, PFS_RD); pfs_create_link(dir, "root", &linprocfs_doprocroot, NULL, NULL, NULL, 0); pfs_create_file(dir, "stat", &linprocfs_doprocstat, From owner-svn-src-stable-11@freebsd.org Sun Mar 19 10:40:01 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 241ABD12610; Sun, 19 Mar 2017 10:40:01 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D917D1AF2; Sun, 19 Mar 2017 10:40:00 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JAdxT2069248; Sun, 19 Mar 2017 10:39:59 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JAdxO1069245; Sun, 19 Mar 2017 10:39:59 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191039.v2JAdxO1069245@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 10:39:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315543 - in stable/11/sys: amd64/linux32 compat/linux i386/linux X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 10:40:01 -0000 Author: trasz Date: Sun Mar 19 10:39:59 2017 New Revision: 315543 URL: https://svnweb.freebsd.org/changeset/base/315543 Log: MFC r314282: Fix linux_fstatfs() to return proper value for f_frsize. Without it, linux df(1) binary from Xenial shows garbage. Modified: stable/11/sys/amd64/linux32/linux.h stable/11/sys/compat/linux/linux_stats.c stable/11/sys/i386/linux/linux.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/linux32/linux.h ============================================================================== --- stable/11/sys/amd64/linux32/linux.h Sun Mar 19 10:38:27 2017 (r315542) +++ stable/11/sys/amd64/linux32/linux.h Sun Mar 19 10:39:59 2017 (r315543) @@ -250,7 +250,9 @@ struct l_statfs64 { uint64_t f_ffree; l_fsid_t f_fsid; l_int f_namelen; - l_int f_spare[6]; + l_int f_frsize; + l_int f_flags; + l_int f_spare[4]; } __packed; /* sigaction flags */ Modified: stable/11/sys/compat/linux/linux_stats.c ============================================================================== --- stable/11/sys/compat/linux/linux_stats.c Sun Mar 19 10:38:27 2017 (r315542) +++ stable/11/sys/compat/linux/linux_stats.c Sun Mar 19 10:39:59 2017 (r315543) @@ -339,7 +339,9 @@ struct l_statfs { l_long f_ffree; l_fsid_t f_fsid; l_long f_namelen; - l_long f_spare[6]; + l_long f_frsize; + l_long f_flags; + l_long f_spare[4]; }; #define LINUX_CODA_SUPER_MAGIC 0x73757245L @@ -407,6 +409,9 @@ bsd_to_linux_statfs(struct statfs *bsd_s linux_statfs->f_fsid.val[0] = bsd_statfs->f_fsid.val[0]; linux_statfs->f_fsid.val[1] = bsd_statfs->f_fsid.val[1]; linux_statfs->f_namelen = MAXNAMLEN; + linux_statfs->f_frsize = bsd_statfs->f_bsize; + linux_statfs->f_flags = 0; + memset(linux_statfs->f_spare, 0, sizeof(linux_statfs->f_spare)); return (0); } @@ -451,6 +456,9 @@ bsd_to_linux_statfs64(struct statfs *bsd linux_statfs->f_fsid.val[0] = bsd_statfs->f_fsid.val[0]; linux_statfs->f_fsid.val[1] = bsd_statfs->f_fsid.val[1]; linux_statfs->f_namelen = MAXNAMLEN; + linux_statfs->f_frsize = bsd_statfs->f_bsize; + linux_statfs->f_flags = 0; + memset(linux_statfs->f_spare, 0, sizeof(linux_statfs->f_spare)); } int Modified: stable/11/sys/i386/linux/linux.h ============================================================================== --- stable/11/sys/i386/linux/linux.h Sun Mar 19 10:38:27 2017 (r315542) +++ stable/11/sys/i386/linux/linux.h Sun Mar 19 10:39:59 2017 (r315543) @@ -225,7 +225,9 @@ struct l_statfs64 { uint64_t f_ffree; l_fsid_t f_fsid; l_int f_namelen; - l_int f_spare[6]; + l_int f_frsize; + l_int f_flags; + l_int f_spare[4]; }; #define LINUX_NSIG_WORDS 2 From owner-svn-src-stable-11@freebsd.org Sun Mar 19 10:41:38 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 54294D1283C; Sun, 19 Mar 2017 10:41:38 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0161E1D26; Sun, 19 Mar 2017 10:41:37 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JAfbfj070218; Sun, 19 Mar 2017 10:41:37 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JAfboA070217; Sun, 19 Mar 2017 10:41:37 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191041.v2JAfboA070217@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 10:41:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315544 - stable/11/sys/amd64/linux X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 10:41:38 -0000 Author: trasz Date: Sun Mar 19 10:41:36 2017 New Revision: 315544 URL: https://svnweb.freebsd.org/changeset/base/315544 Log: MFC r313993: Reimplement linux_arch_prctl() as a wrapper around sysarch(2). This also adds support for LINUX_ARCH_SET_GS. Modified: stable/11/sys/amd64/linux/linux_machdep.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/linux/linux_machdep.c ============================================================================== --- stable/11/sys/amd64/linux/linux_machdep.c Sun Mar 19 10:39:59 2017 (r315543) +++ stable/11/sys/amd64/linux/linux_machdep.c Sun Mar 19 10:41:36 2017 (r315544) @@ -88,6 +88,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include int linux_execve(struct thread *td, struct linux_execve_args *args) @@ -226,28 +227,34 @@ int linux_arch_prctl(struct thread *td, struct linux_arch_prctl_args *args) { int error; - struct pcb *pcb; + struct sysarch_args bsd_args; LINUX_CTR2(arch_prctl, "0x%x, %p", args->code, args->addr); - error = ENOTSUP; - pcb = td->td_pcb; - switch (args->code) { - case LINUX_ARCH_GET_GS: - error = copyout(&pcb->pcb_gsbase, (unsigned long *)args->addr, - sizeof(args->addr)); - break; case LINUX_ARCH_SET_GS: - if (args->addr >= VM_MAXUSER_ADDRESS) - return(EPERM); + bsd_args.op = AMD64_SET_GSBASE; + bsd_args.parms = (void *)args->addr; + error = sysarch(td, &bsd_args); + if (error == EINVAL) + error = EPERM; + break; + case LINUX_ARCH_SET_FS: + bsd_args.op = AMD64_SET_FSBASE; + bsd_args.parms = (void *)args->addr; + error = sysarch(td, &bsd_args); + if (error == EINVAL) + error = EPERM; break; case LINUX_ARCH_GET_FS: - error = copyout(&pcb->pcb_fsbase, (unsigned long *)args->addr, - sizeof(args->addr)); + bsd_args.op = AMD64_GET_FSBASE; + bsd_args.parms = (void *)args->addr; + error = sysarch(td, &bsd_args); break; - case LINUX_ARCH_SET_FS: - error = linux_set_cloned_tls(td, (void *)args->addr); + case LINUX_ARCH_GET_GS: + bsd_args.op = AMD64_GET_GSBASE; + bsd_args.parms = (void *)args->addr; + error = sysarch(td, &bsd_args); break; default: error = EINVAL; From owner-svn-src-stable-11@freebsd.org Sun Mar 19 14:05:57 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 85F75D133CB; Sun, 19 Mar 2017 14:05:57 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 550BDFC5; Sun, 19 Mar 2017 14:05:57 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JE5u4E056596; Sun, 19 Mar 2017 14:05:56 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JE5uoD056595; Sun, 19 Mar 2017 14:05:56 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191405.v2JE5uoD056595@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 14:05:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315546 - stable/11/sbin/fsck X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 14:05:57 -0000 Author: trasz Date: Sun Mar 19 14:05:56 2017 New Revision: 315546 URL: https://svnweb.freebsd.org/changeset/base/315546 Log: MFC r313915: Make fsck(8) default to "ufs", like eg mount(8) does. Modified: stable/11/sbin/fsck/fsck.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/fsck/fsck.c ============================================================================== --- stable/11/sbin/fsck/fsck.c Sun Mar 19 13:46:11 2017 (r315545) +++ stable/11/sbin/fsck/fsck.c Sun Mar 19 14:05:56 2017 (r315546) @@ -215,7 +215,7 @@ main(int argc, char *argv[]) if (vfstype == NULL) vfstype = getfstype(spec); if (vfstype == NULL) - errx(1, "Could not determine filesystem type"); + vfstype = "ufs"; type = vfstype; devcheck(spec); } else { From owner-svn-src-stable-11@freebsd.org Sun Mar 19 14:09:03 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 94954D1350B; Sun, 19 Mar 2017 14:09:03 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6399512EF; Sun, 19 Mar 2017 14:09:03 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JE92kk056991; Sun, 19 Mar 2017 14:09:02 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JE92kD056990; Sun, 19 Mar 2017 14:09:02 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191409.v2JE92kD056990@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 14:09:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315547 - stable/11/sbin/savecore X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 14:09:03 -0000 Author: trasz Date: Sun Mar 19 14:09:02 2017 New Revision: 315547 URL: https://svnweb.freebsd.org/changeset/base/315547 Log: MFC r313946: Make savecore(8) output nicer by specifying the maximum field width instead of minimum one (precision instead of width). Modified: stable/11/sbin/savecore/savecore.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/savecore/savecore.c ============================================================================== --- stable/11/sbin/savecore/savecore.c Sun Mar 19 14:05:56 2017 (r315546) +++ stable/11/sbin/savecore/savecore.c Sun Mar 19 14:09:02 2017 (r315547) @@ -620,7 +620,7 @@ DoFile(const char *savedir, const char * } if (kdhl.panicstring[0] != '\0') - syslog(LOG_ALERT, "reboot after panic: %*s", + syslog(LOG_ALERT, "reboot after panic: %.*s", (int)sizeof(kdhl.panicstring), kdhl.panicstring); else syslog(LOG_ALERT, "reboot"); From owner-svn-src-stable-11@freebsd.org Sun Mar 19 14:12:57 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3C01CD1370D; Sun, 19 Mar 2017 14:12:57 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1695917A0; Sun, 19 Mar 2017 14:12:57 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JECunl060812; Sun, 19 Mar 2017 14:12:56 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JECtGN060806; Sun, 19 Mar 2017 14:12:55 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191412.v2JECtGN060806@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 14:12:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315548 - in stable/11/sys: amd64/linux32 compat/freebsd32 compat/linux i386/linux kern X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 14:12:57 -0000 Author: trasz Date: Sun Mar 19 14:12:55 2017 New Revision: 315548 URL: https://svnweb.freebsd.org/changeset/base/315548 Log: MFC r312986: Replace sys_ftruncate() with kern_ftruncate() in various compats. Sponsored by: DARPA, AFRL Modified: stable/11/sys/amd64/linux32/linux32_machdep.c stable/11/sys/compat/freebsd32/freebsd32_misc.c stable/11/sys/compat/linux/linux_file.c stable/11/sys/i386/linux/linux_machdep.c stable/11/sys/kern/vfs_syscalls.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/linux32/linux32_machdep.c ============================================================================== --- stable/11/sys/amd64/linux32/linux32_machdep.c Sun Mar 19 14:09:02 2017 (r315547) +++ stable/11/sys/amd64/linux32/linux32_machdep.c Sun Mar 19 14:12:55 2017 (r315548) @@ -645,7 +645,6 @@ linux_sigaltstack(struct thread *td, str int linux_ftruncate64(struct thread *td, struct linux_ftruncate64_args *args) { - struct ftruncate_args sa; #ifdef DEBUG if (ldebug(ftruncate64)) @@ -653,9 +652,7 @@ linux_ftruncate64(struct thread *td, str (intmax_t)args->length); #endif - sa.fd = args->fd; - sa.length = args->length; - return sys_ftruncate(td, &sa); + return (kern_ftruncate(td, args->fd, args->length)); } int Modified: stable/11/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- stable/11/sys/compat/freebsd32/freebsd32_misc.c Sun Mar 19 14:09:02 2017 (r315547) +++ stable/11/sys/compat/freebsd32/freebsd32_misc.c Sun Mar 19 14:12:55 2017 (r315548) @@ -1507,11 +1507,8 @@ freebsd32_truncate(struct thread *td, st int freebsd32_ftruncate(struct thread *td, struct freebsd32_ftruncate_args *uap) { - struct ftruncate_args ap; - ap.fd = uap->fd; - ap.length = PAIR32TO64(off_t,uap->length); - return (sys_ftruncate(td, &ap)); + return (kern_ftruncate(td, uap->fd, PAIR32TO64(off_t, uap->length))); } #ifdef COMPAT_43 @@ -1613,11 +1610,8 @@ freebsd6_freebsd32_truncate(struct threa int freebsd6_freebsd32_ftruncate(struct thread *td, struct freebsd6_freebsd32_ftruncate_args *uap) { - struct ftruncate_args ap; - ap.fd = uap->fd; - ap.length = PAIR32TO64(off_t,uap->length); - return (sys_ftruncate(td, &ap)); + return (kern_ftruncate(td, uap->fd, PAIR32TO64(off_t, uap->length))); } #endif /* COMPAT_FREEBSD6 */ Modified: stable/11/sys/compat/linux/linux_file.c ============================================================================== --- stable/11/sys/compat/linux/linux_file.c Sun Mar 19 14:09:02 2017 (r315547) +++ stable/11/sys/compat/linux/linux_file.c Sun Mar 19 14:12:55 2017 (r315548) @@ -940,15 +940,8 @@ linux_truncate64(struct thread *td, stru int linux_ftruncate(struct thread *td, struct linux_ftruncate_args *args) { - struct ftruncate_args /* { - int fd; - int pad; - off_t length; - } */ nuap; - - nuap.fd = args->fd; - nuap.length = args->length; - return (sys_ftruncate(td, &nuap)); + + return (kern_ftruncate(td, args->fd, args->length)); } int Modified: stable/11/sys/i386/linux/linux_machdep.c ============================================================================== --- stable/11/sys/i386/linux/linux_machdep.c Sun Mar 19 14:09:02 2017 (r315547) +++ stable/11/sys/i386/linux/linux_machdep.c Sun Mar 19 14:12:55 2017 (r315548) @@ -611,7 +611,6 @@ linux_sigaltstack(struct thread *td, str int linux_ftruncate64(struct thread *td, struct linux_ftruncate64_args *args) { - struct ftruncate_args sa; #ifdef DEBUG if (ldebug(ftruncate64)) @@ -619,9 +618,7 @@ linux_ftruncate64(struct thread *td, str (intmax_t)args->length); #endif - sa.fd = args->fd; - sa.length = args->length; - return sys_ftruncate(td, &sa); + return (kern_ftruncate(td, args->fd, args->length)); } int Modified: stable/11/sys/kern/vfs_syscalls.c ============================================================================== --- stable/11/sys/kern/vfs_syscalls.c Sun Mar 19 14:09:02 2017 (r315547) +++ stable/11/sys/kern/vfs_syscalls.c Sun Mar 19 14:12:55 2017 (r315548) @@ -3363,11 +3363,8 @@ freebsd6_truncate(struct thread *td, str int freebsd6_ftruncate(struct thread *td, struct freebsd6_ftruncate_args *uap) { - struct ftruncate_args ouap; - ouap.fd = uap->fd; - ouap.length = uap->length; - return (sys_ftruncate(td, &ouap)); + return (kern_ftruncate(td, uap->fd, uap->length)); } #endif From owner-svn-src-stable-11@freebsd.org Sun Mar 19 14:25:25 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 65918D13B04; Sun, 19 Mar 2017 14:25:25 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 23AB6114; Sun, 19 Mar 2017 14:25:25 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JEPOu4065053; Sun, 19 Mar 2017 14:25:24 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JEPNuA065048; Sun, 19 Mar 2017 14:25:23 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191425.v2JEPNuA065048@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 14:25:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315549 - in stable/11/sys: compat/cloudabi compat/linux kern sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 14:25:25 -0000 Author: trasz Date: Sun Mar 19 14:25:23 2017 New Revision: 315549 URL: https://svnweb.freebsd.org/changeset/base/315549 Log: MFC r312988: Add kern_listen(), kern_shutdown(), and kern_socket(), and use them instead of their sys_*() counterparts in various compats. The svr4 is left untouched, because there's no point. Sponsored by: DARPA, AFRL Modified: stable/11/sys/compat/cloudabi/cloudabi_fd.c stable/11/sys/compat/cloudabi/cloudabi_sock.c stable/11/sys/compat/linux/linux_socket.c stable/11/sys/kern/uipc_syscalls.c stable/11/sys/sys/syscallsubr.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/cloudabi/cloudabi_fd.c ============================================================================== --- stable/11/sys/compat/cloudabi/cloudabi_fd.c Sun Mar 19 14:12:55 2017 (r315548) +++ stable/11/sys/compat/cloudabi/cloudabi_fd.c Sun Mar 19 14:25:23 2017 (r315549) @@ -100,9 +100,6 @@ cloudabi_sys_fd_create1(struct thread *t struct cloudabi_sys_fd_create1_args *uap) { struct filecaps fcaps = {}; - struct socket_args socket_args = { - .domain = AF_UNIX, - }; switch (uap->type) { case CLOUDABI_FILETYPE_POLL: @@ -113,14 +110,11 @@ cloudabi_sys_fd_create1(struct thread *t CAP_MMAP_RWX); return (kern_shm_open(td, SHM_ANON, O_RDWR, 0, &fcaps)); case CLOUDABI_FILETYPE_SOCKET_DGRAM: - socket_args.type = SOCK_DGRAM; - return (sys_socket(td, &socket_args)); + return (kern_socket(td, AF_UNIX, SOCK_DGRAM, 0)); case CLOUDABI_FILETYPE_SOCKET_SEQPACKET: - socket_args.type = SOCK_SEQPACKET; - return (sys_socket(td, &socket_args)); + return (kern_socket(td, AF_UNIX, SOCK_SEQPACKET, 0)); case CLOUDABI_FILETYPE_SOCKET_STREAM: - socket_args.type = SOCK_STREAM; - return (sys_socket(td, &socket_args)); + return (kern_socket(td, AF_UNIX, SOCK_STREAM, 0)); default: return (EINVAL); } Modified: stable/11/sys/compat/cloudabi/cloudabi_sock.c ============================================================================== --- stable/11/sys/compat/cloudabi/cloudabi_sock.c Sun Mar 19 14:12:55 2017 (r315548) +++ stable/11/sys/compat/cloudabi/cloudabi_sock.c Sun Mar 19 14:25:23 2017 (r315549) @@ -35,7 +35,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -165,37 +164,31 @@ int cloudabi_sys_sock_listen(struct thread *td, struct cloudabi_sys_sock_listen_args *uap) { - struct listen_args listen_args = { - .s = uap->sock, - .backlog = uap->backlog, - }; - return (sys_listen(td, &listen_args)); + return (kern_listen(td, uap->sock, uap->backlog)); } int cloudabi_sys_sock_shutdown(struct thread *td, struct cloudabi_sys_sock_shutdown_args *uap) { - struct shutdown_args shutdown_args = { - .s = uap->sock, - }; + int how; switch (uap->how) { case CLOUDABI_SHUT_RD: - shutdown_args.how = SHUT_RD; + how = SHUT_RD; break; case CLOUDABI_SHUT_WR: - shutdown_args.how = SHUT_WR; + how = SHUT_WR; break; case CLOUDABI_SHUT_RD | CLOUDABI_SHUT_WR: - shutdown_args.how = SHUT_RDWR; + how = SHUT_RDWR; break; default: return (EINVAL); } - return (sys_shutdown(td, &shutdown_args)); + return (kern_shutdown(td, uap->sock, how)); } int Modified: stable/11/sys/compat/linux/linux_socket.c ============================================================================== --- stable/11/sys/compat/linux/linux_socket.c Sun Mar 19 14:12:55 2017 (r315548) +++ stable/11/sys/compat/linux/linux_socket.c Sun Mar 19 14:25:23 2017 (r315549) @@ -697,32 +697,26 @@ goout: int linux_socket(struct thread *td, struct linux_socket_args *args) { - struct socket_args /* { - int domain; - int type; - int protocol; - } */ bsd_args; - int retval_socket; + int domain, retval_socket, type; - bsd_args.protocol = args->protocol; - bsd_args.type = args->type & LINUX_SOCK_TYPE_MASK; - if (bsd_args.type < 0 || bsd_args.type > LINUX_SOCK_MAX) + type = args->type & LINUX_SOCK_TYPE_MASK; + if (type < 0 || type > LINUX_SOCK_MAX) return (EINVAL); retval_socket = linux_set_socket_flags(args->type & ~LINUX_SOCK_TYPE_MASK, - &bsd_args.type); + &type); if (retval_socket != 0) return (retval_socket); - bsd_args.domain = linux_to_bsd_domain(args->domain); - if (bsd_args.domain == -1) + domain = linux_to_bsd_domain(args->domain); + if (domain == -1) return (EAFNOSUPPORT); - retval_socket = sys_socket(td, &bsd_args); + retval_socket = kern_socket(td, domain, type, args->protocol); if (retval_socket) return (retval_socket); - if (bsd_args.type == SOCK_RAW - && (bsd_args.protocol == IPPROTO_RAW || bsd_args.protocol == 0) - && bsd_args.domain == PF_INET) { + if (type == SOCK_RAW + && (args->protocol == IPPROTO_RAW || args->protocol == 0) + && domain == PF_INET) { /* It's a raw IP socket: set the IP_HDRINCL option. */ int hdrincl; @@ -738,7 +732,7 @@ linux_socket(struct thread *td, struct l * For simplicity we do this unconditionally of the net.inet6.ip6.v6only * sysctl value. */ - if (bsd_args.domain == PF_INET6) { + if (domain == PF_INET6) { int v6only; v6only = 0; @@ -816,14 +810,8 @@ linux_connect(struct thread *td, struct int linux_listen(struct thread *td, struct linux_listen_args *args) { - struct listen_args /* { - int s; - int backlog; - } */ bsd_args; - bsd_args.s = args->s; - bsd_args.backlog = args->backlog; - return (sys_listen(td, &bsd_args)); + return (kern_listen(td, args->s, args->backlog)); } static int @@ -1523,14 +1511,8 @@ linux_recvmmsg(struct thread *td, struct int linux_shutdown(struct thread *td, struct linux_shutdown_args *args) { - struct shutdown_args /* { - int s; - int how; - } */ bsd_args; - bsd_args.s = args->s; - bsd_args.how = args->how; - return (sys_shutdown(td, &bsd_args)); + return (kern_shutdown(td, args->s, args->how)); } int Modified: stable/11/sys/kern/uipc_syscalls.c ============================================================================== --- stable/11/sys/kern/uipc_syscalls.c Sun Mar 19 14:12:55 2017 (r315548) +++ stable/11/sys/kern/uipc_syscalls.c Sun Mar 19 14:25:23 2017 (r315549) @@ -130,13 +130,19 @@ sys_socket(td, uap) int protocol; } */ *uap; { + + return (kern_socket(td, uap->domain, uap->type, uap->protocol)); +} + +int +kern_socket(struct thread *td, int domain, int type, int protocol) +{ struct socket *so; struct file *fp; - int fd, error, type, oflag, fflag; + int fd, error, oflag, fflag; - AUDIT_ARG_SOCKET(uap->domain, uap->type, uap->protocol); + AUDIT_ARG_SOCKET(domain, type, protocol); - type = uap->type; oflag = 0; fflag = 0; if ((type & SOCK_CLOEXEC) != 0) { @@ -149,8 +155,7 @@ sys_socket(td, uap) } #ifdef MAC - error = mac_socket_check_create(td->td_ucred, uap->domain, type, - uap->protocol); + error = mac_socket_check_create(td->td_ucred, domain, type, protocol); if (error != 0) return (error); #endif @@ -158,8 +163,7 @@ sys_socket(td, uap) if (error != 0) return (error); /* An extra reference on `fp' has been held for us by falloc(). */ - error = socreate(uap->domain, &so, type, uap->protocol, - td->td_ucred, td); + error = socreate(domain, &so, type, protocol, td->td_ucred, td); if (error != 0) { fdclose(td, fp, fd); } else { @@ -258,13 +262,20 @@ sys_listen(td, uap) int backlog; } */ *uap; { + + return (kern_listen(td, uap->s, uap->backlog)); +} + +int +kern_listen(struct thread *td, int s, int backlog) +{ struct socket *so; struct file *fp; cap_rights_t rights; int error; - AUDIT_ARG_FD(uap->s); - error = getsock_cap(td, uap->s, cap_rights_init(&rights, CAP_LISTEN), + AUDIT_ARG_FD(s); + error = getsock_cap(td, s, cap_rights_init(&rights, CAP_LISTEN), &fp, NULL, NULL); if (error == 0) { so = fp->f_data; @@ -272,10 +283,10 @@ sys_listen(td, uap) error = mac_socket_check_listen(td->td_ucred, so); if (error == 0) #endif - error = solisten(so, uap->backlog, td); + error = solisten(so, backlog, td); fdrop(fp, td); } - return(error); + return (error); } /* @@ -1328,17 +1339,24 @@ sys_shutdown(td, uap) int how; } */ *uap; { + + return (kern_shutdown(td, uap->s, uap->how)); +} + +int +kern_shutdown(struct thread *td, int s, int how) +{ struct socket *so; struct file *fp; cap_rights_t rights; int error; - AUDIT_ARG_FD(uap->s); - error = getsock_cap(td, uap->s, cap_rights_init(&rights, CAP_SHUTDOWN), + AUDIT_ARG_FD(s); + error = getsock_cap(td, s, cap_rights_init(&rights, CAP_SHUTDOWN), &fp, NULL, NULL); if (error == 0) { so = fp->f_data; - error = soshutdown(so, uap->how); + error = soshutdown(so, how); /* * Previous versions did not return ENOTCONN, but 0 in * case the socket was not connected. Some important Modified: stable/11/sys/sys/syscallsubr.h ============================================================================== --- stable/11/sys/sys/syscallsubr.h Sun Mar 19 14:12:55 2017 (r315548) +++ stable/11/sys/sys/syscallsubr.h Sun Mar 19 14:25:23 2017 (r315549) @@ -136,6 +136,8 @@ int kern_kldstat(struct thread *td, int int kern_kldunload(struct thread *td, int fileid, int flags); int kern_linkat(struct thread *td, int fd1, int fd2, char *path1, char *path2, enum uio_seg segflg, int follow); +int kern_listen(struct thread *td, int s, int backlog); +int kern_lseek(struct thread *td, int fd, off_t offset, int whence); int kern_lutimes(struct thread *td, char *path, enum uio_seg pathseg, struct timeval *tptr, enum uio_seg tptrseg); int kern_madvise(struct thread *td, uintptr_t addr, size_t len, int behav); @@ -224,6 +226,7 @@ int kern_shmat(struct thread *td, int sh int shmflg); int kern_shmctl(struct thread *td, int shmid, int cmd, void *buf, size_t *bufsz); +int kern_shutdown(struct thread *td, int s, int how); int kern_sigaction(struct thread *td, int sig, const struct sigaction *act, struct sigaction *oact, int flags); int kern_sigaltstack(struct thread *td, stack_t *ss, stack_t *oss); @@ -232,6 +235,7 @@ int kern_sigprocmask(struct thread *td, int kern_sigsuspend(struct thread *td, sigset_t mask); int kern_sigtimedwait(struct thread *td, sigset_t waitset, struct ksiginfo *ksi, struct timespec *timeout); +int kern_socket(struct thread *td, int domain, int type, int protocol); int kern_statat(struct thread *td, int flag, int fd, char *path, enum uio_seg pathseg, struct stat *sbp, void (*hook)(struct vnode *vp, struct stat *sbp)); From owner-svn-src-stable-11@freebsd.org Sun Mar 19 14:36:20 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 99DC2D13E08; Sun, 19 Mar 2017 14:36:20 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 744CB9C9; Sun, 19 Mar 2017 14:36:20 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JEaJNY069626; Sun, 19 Mar 2017 14:36:19 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JEaJAQ069620; Sun, 19 Mar 2017 14:36:19 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191436.v2JEaJAQ069620@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 14:36:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315550 - in stable/11/sys: compat/cloudabi compat/freebsd32 compat/linux kern X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 14:36:20 -0000 Author: trasz Date: Sun Mar 19 14:36:19 2017 New Revision: 315550 URL: https://svnweb.freebsd.org/changeset/base/315550 Log: MFC r312987: Add kern_lseek() and use it instead of sys_lseek() in various compats. I didn't touch svr4/, there's no point. Sponsored by: DARPA, AFRL Modified: stable/11/sys/compat/cloudabi/cloudabi_fd.c stable/11/sys/compat/freebsd32/freebsd32_misc.c stable/11/sys/compat/linux/linux_file.c stable/11/sys/kern/vfs_syscalls.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/cloudabi/cloudabi_fd.c ============================================================================== --- stable/11/sys/compat/cloudabi/cloudabi_fd.c Sun Mar 19 14:25:23 2017 (r315549) +++ stable/11/sys/compat/cloudabi/cloudabi_fd.c Sun Mar 19 14:36:19 2017 (r315550) @@ -203,26 +203,23 @@ cloudabi_sys_fd_replace(struct thread *t int cloudabi_sys_fd_seek(struct thread *td, struct cloudabi_sys_fd_seek_args *uap) { - struct lseek_args lseek_args = { - .fd = uap->fd, - .offset = uap->offset - }; + int whence; switch (uap->whence) { case CLOUDABI_WHENCE_CUR: - lseek_args.whence = SEEK_CUR; + whence = SEEK_CUR; break; case CLOUDABI_WHENCE_END: - lseek_args.whence = SEEK_END; + whence = SEEK_END; break; case CLOUDABI_WHENCE_SET: - lseek_args.whence = SEEK_SET; + whence = SEEK_SET; break; default: return (EINVAL); } - return (sys_lseek(td, &lseek_args)); + return (kern_lseek(td, uap->fd, uap->offset, whence)); } /* Converts a file descriptor to a CloudABI file descriptor type. */ Modified: stable/11/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- stable/11/sys/compat/freebsd32/freebsd32_misc.c Sun Mar 19 14:25:23 2017 (r315549) +++ stable/11/sys/compat/freebsd32/freebsd32_misc.c Sun Mar 19 14:36:19 2017 (r315550) @@ -1467,12 +1467,8 @@ freebsd32_pwrite(struct thread *td, stru int ofreebsd32_lseek(struct thread *td, struct ofreebsd32_lseek_args *uap) { - struct lseek_args nuap; - nuap.fd = uap->fd; - nuap.offset = uap->offset; - nuap.whence = uap->whence; - return (sys_lseek(td, &nuap)); + return (kern_lseek(td, uap->fd, uap->offset, uap->whence)); } #endif @@ -1480,13 +1476,10 @@ int freebsd32_lseek(struct thread *td, struct freebsd32_lseek_args *uap) { int error; - struct lseek_args ap; off_t pos; - ap.fd = uap->fd; - ap.offset = PAIR32TO64(off_t,uap->offset); - ap.whence = uap->whence; - error = sys_lseek(td, &ap); + error = kern_lseek(td, uap->fd, PAIR32TO64(off_t, uap->offset), + uap->whence); /* Expand the quad return into two parts for eax and edx */ pos = td->td_uretoff.tdu_off; td->td_retval[RETVAL_LO] = pos & 0xffffffff; /* %eax */ @@ -1583,13 +1576,10 @@ int freebsd6_freebsd32_lseek(struct thread *td, struct freebsd6_freebsd32_lseek_args *uap) { int error; - struct lseek_args ap; off_t pos; - ap.fd = uap->fd; - ap.offset = PAIR32TO64(off_t,uap->offset); - ap.whence = uap->whence; - error = sys_lseek(td, &ap); + error = kern_lseek(td, uap->fd, PAIR32TO64(off_t, uap->offset), + uap->whence); /* Expand the quad return into two parts for eax and edx */ pos = *(off_t *)(td->td_retval); td->td_retval[RETVAL_LO] = pos & 0xffffffff; /* %eax */ Modified: stable/11/sys/compat/linux/linux_file.c ============================================================================== --- stable/11/sys/compat/linux/linux_file.c Sun Mar 19 14:25:23 2017 (r315549) +++ stable/11/sys/compat/linux/linux_file.c Sun Mar 19 14:36:19 2017 (r315550) @@ -212,31 +212,19 @@ linux_open(struct thread *td, struct lin int linux_lseek(struct thread *td, struct linux_lseek_args *args) { - struct lseek_args /* { - int fd; - int pad; - off_t offset; - int whence; - } */ tmp_args; - int error; #ifdef DEBUG if (ldebug(lseek)) printf(ARGS(lseek, "%d, %ld, %d"), args->fdes, (long)args->off, args->whence); #endif - tmp_args.fd = args->fdes; - tmp_args.offset = (off_t)args->off; - tmp_args.whence = args->whence; - error = sys_lseek(td, &tmp_args); - return (error); + return (kern_lseek(td, args->fdes, args->off, args->whence)); } #if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) int linux_llseek(struct thread *td, struct linux_llseek_args *args) { - struct lseek_args bsd_args; int error; off_t off; @@ -247,14 +235,12 @@ linux_llseek(struct thread *td, struct l #endif off = (args->olow) | (((off_t) args->ohigh) << 32); - bsd_args.fd = args->fd; - bsd_args.offset = off; - bsd_args.whence = args->whence; - - if ((error = sys_lseek(td, &bsd_args))) + error = kern_lseek(td, args->fd, off, args->whence); + if (error != 0) return (error); - if ((error = copyout(td->td_retval, args->res, sizeof (off_t)))) + error = copyout(td->td_retval, args->res, sizeof(off_t)); + if (error != 0) return (error); td->td_retval[0] = 0; Modified: stable/11/sys/kern/vfs_syscalls.c ============================================================================== --- stable/11/sys/kern/vfs_syscalls.c Sun Mar 19 14:25:23 2017 (r315549) +++ stable/11/sys/kern/vfs_syscalls.c Sun Mar 19 14:36:19 2017 (r315550) @@ -1804,25 +1804,25 @@ struct lseek_args { }; #endif int -sys_lseek(td, uap) - struct thread *td; - register struct lseek_args /* { - int fd; - int pad; - off_t offset; - int whence; - } */ *uap; +sys_lseek(struct thread *td, struct lseek_args *uap) +{ + + return (kern_lseek(td, uap->fd, uap->offset, uap->whence)); +} + +int +kern_lseek(struct thread *td, int fd, off_t offset, int whence) { struct file *fp; cap_rights_t rights; int error; - AUDIT_ARG_FD(uap->fd); - error = fget(td, uap->fd, cap_rights_init(&rights, CAP_SEEK), &fp); + AUDIT_ARG_FD(fd); + error = fget(td, fd, cap_rights_init(&rights, CAP_SEEK), &fp); if (error != 0) return (error); error = (fp->f_ops->fo_flags & DFLAG_SEEKABLE) != 0 ? - fo_seek(fp, uap->offset, uap->whence, td) : ESPIPE; + fo_seek(fp, offset, whence, td) : ESPIPE; fdrop(fp, td); return (error); } @@ -1839,41 +1839,20 @@ struct olseek_args { }; #endif int -olseek(td, uap) - struct thread *td; - register struct olseek_args /* { - int fd; - long offset; - int whence; - } */ *uap; +olseek(struct thread *td, struct olseek_args *uap) { - struct lseek_args /* { - int fd; - int pad; - off_t offset; - int whence; - } */ nuap; - nuap.fd = uap->fd; - nuap.offset = uap->offset; - nuap.whence = uap->whence; - return (sys_lseek(td, &nuap)); + return (kern_lseek(td, uap->fd, uap->offset, uap->whence)); } #endif /* COMPAT_43 */ #if defined(COMPAT_FREEBSD6) /* Version with the 'pad' argument */ int -freebsd6_lseek(td, uap) - struct thread *td; - register struct freebsd6_lseek_args *uap; +freebsd6_lseek(struct thread *td, struct freebsd6_lseek_args *uap) { - struct lseek_args ouap; - ouap.fd = uap->fd; - ouap.offset = uap->offset; - ouap.whence = uap->whence; - return (sys_lseek(td, &ouap)); + return (kern_lseek(td, uap->fd, uap->offset, uap->whence)); } #endif From owner-svn-src-stable-11@freebsd.org Sun Mar 19 14:40:03 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2204AD13E88; Sun, 19 Mar 2017 14:40:03 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CB2C3B20; Sun, 19 Mar 2017 14:40:02 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JEe1ib069839; Sun, 19 Mar 2017 14:40:01 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JEe15w069837; Sun, 19 Mar 2017 14:40:01 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191440.v2JEe15w069837@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 14:40:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315551 - in stable/11/sys: compat/freebsd32 kern X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 14:40:03 -0000 Author: trasz Date: Sun Mar 19 14:40:01 2017 New Revision: 315551 URL: https://svnweb.freebsd.org/changeset/base/315551 Log: MFC r313016: Replace calls to sys_truncate() with kern_truncate(). Sponsored by: DARPA, AFRL Modified: stable/11/sys/compat/freebsd32/freebsd32_misc.c stable/11/sys/kern/vfs_syscalls.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- stable/11/sys/compat/freebsd32/freebsd32_misc.c Sun Mar 19 14:36:19 2017 (r315550) +++ stable/11/sys/compat/freebsd32/freebsd32_misc.c Sun Mar 19 14:40:01 2017 (r315551) @@ -1490,11 +1490,9 @@ freebsd32_lseek(struct thread *td, struc int freebsd32_truncate(struct thread *td, struct freebsd32_truncate_args *uap) { - struct truncate_args ap; - ap.path = uap->path; - ap.length = PAIR32TO64(off_t,uap->length); - return (sys_truncate(td, &ap)); + return (kern_truncate(td, uap->path, UIO_USERSPACE, + PAIR32TO64(off_t, uap->length))); } int @@ -1590,11 +1588,9 @@ freebsd6_freebsd32_lseek(struct thread * int freebsd6_freebsd32_truncate(struct thread *td, struct freebsd6_freebsd32_truncate_args *uap) { - struct truncate_args ap; - ap.path = uap->path; - ap.length = PAIR32TO64(off_t,uap->length); - return (sys_truncate(td, &ap)); + return (kern_truncate(td, uap->path, UIO_USERSPACE, + PAIR32TO64(off_t, uap->length))); } int Modified: stable/11/sys/kern/vfs_syscalls.c ============================================================================== --- stable/11/sys/kern/vfs_syscalls.c Sun Mar 19 14:36:19 2017 (r315550) +++ stable/11/sys/kern/vfs_syscalls.c Sun Mar 19 14:40:01 2017 (r315551) @@ -3308,22 +3308,10 @@ struct otruncate_args { }; #endif int -otruncate(td, uap) - struct thread *td; - register struct otruncate_args /* { - char *path; - long length; - } */ *uap; +otruncate(struct thread *td, struct otruncate_args *uap) { - struct truncate_args /* { - char *path; - int pad; - off_t length; - } */ nuap; - - nuap.path = uap->path; - nuap.length = uap->length; - return (sys_truncate(td, &nuap)); + + return (kern_truncate(td, uap->path, UIO_USERSPACE, uap->length)); } #endif /* COMPAT_43 */ @@ -3332,11 +3320,8 @@ otruncate(td, uap) int freebsd6_truncate(struct thread *td, struct freebsd6_truncate_args *uap) { - struct truncate_args ouap; - ouap.path = uap->path; - ouap.length = uap->length; - return (sys_truncate(td, &ouap)); + return (kern_truncate(td, uap->path, UIO_USERSPACE, uap->length)); } int From owner-svn-src-stable-11@freebsd.org Sun Mar 19 14:46:42 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 72D03D12489; Sun, 19 Mar 2017 14:46:42 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 322E813C6; Sun, 19 Mar 2017 14:46:42 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JEkfDJ073686; Sun, 19 Mar 2017 14:46:41 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JEkeLS073682; Sun, 19 Mar 2017 14:46:40 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191446.v2JEkeLS073682@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 14:46:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315553 - in stable/11/sys: compat/freebsd32 compat/linux kern sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 14:46:42 -0000 Author: trasz Date: Sun Mar 19 14:46:40 2017 New Revision: 315553 URL: https://svnweb.freebsd.org/changeset/base/315553 Log: MFC r313018: Add kern_pread() and kern_pwrite(), and use it in compats instead of their sys_*() counterparts. The svr4 is left unchanged. Sponsored by: DARPA, AFRL Modified: stable/11/sys/compat/freebsd32/freebsd32_misc.c stable/11/sys/compat/linux/linux_file.c stable/11/sys/kern/sys_generic.c stable/11/sys/sys/syscallsubr.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- stable/11/sys/compat/freebsd32/freebsd32_misc.c Sun Mar 19 14:42:16 2017 (r315552) +++ stable/11/sys/compat/freebsd32/freebsd32_misc.c Sun Mar 19 14:46:40 2017 (r315553) @@ -1442,25 +1442,17 @@ freebsd4_freebsd32_fhstatfs(struct threa int freebsd32_pread(struct thread *td, struct freebsd32_pread_args *uap) { - struct pread_args ap; - ap.fd = uap->fd; - ap.buf = uap->buf; - ap.nbyte = uap->nbyte; - ap.offset = PAIR32TO64(off_t,uap->offset); - return (sys_pread(td, &ap)); + return (kern_pread(td, uap->fd, uap->buf, uap->nbyte, + PAIR32TO64(off_t, uap->offset))); } int freebsd32_pwrite(struct thread *td, struct freebsd32_pwrite_args *uap) { - struct pwrite_args ap; - ap.fd = uap->fd; - ap.buf = uap->buf; - ap.nbyte = uap->nbyte; - ap.offset = PAIR32TO64(off_t,uap->offset); - return (sys_pwrite(td, &ap)); + return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte, + PAIR32TO64(off_t, uap->offset))); } #ifdef COMPAT_43 @@ -1549,25 +1541,17 @@ freebsd32_getdirentries(struct thread *t int freebsd6_freebsd32_pread(struct thread *td, struct freebsd6_freebsd32_pread_args *uap) { - struct pread_args ap; - ap.fd = uap->fd; - ap.buf = uap->buf; - ap.nbyte = uap->nbyte; - ap.offset = PAIR32TO64(off_t,uap->offset); - return (sys_pread(td, &ap)); + return (kern_pread(td, uap->fd, uap->buf, uap->nbyte, + PAIR32TO64(off_t, uap->offset))); } int freebsd6_freebsd32_pwrite(struct thread *td, struct freebsd6_freebsd32_pwrite_args *uap) { - struct pwrite_args ap; - ap.fd = uap->fd; - ap.buf = uap->buf; - ap.nbyte = uap->nbyte; - ap.offset = PAIR32TO64(off_t,uap->offset); - return (sys_pwrite(td, &ap)); + return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte, + PAIR32TO64(off_t, uap->offset))); } int Modified: stable/11/sys/compat/linux/linux_file.c ============================================================================== --- stable/11/sys/compat/linux/linux_file.c Sun Mar 19 14:42:16 2017 (r315552) +++ stable/11/sys/compat/linux/linux_file.c Sun Mar 19 14:46:40 2017 (r315553) @@ -998,20 +998,13 @@ linux_fdatasync(td, uap) } int -linux_pread(td, uap) - struct thread *td; - struct linux_pread_args *uap; +linux_pread(struct thread *td, struct linux_pread_args *uap) { - struct pread_args bsd; cap_rights_t rights; struct vnode *vp; int error; - bsd.fd = uap->fd; - bsd.buf = uap->buf; - bsd.nbyte = uap->nbyte; - bsd.offset = uap->offset; - error = sys_pread(td, &bsd); + error = kern_pread(td, uap->fd, uap->buf, uap->nbyte, uap->offset); if (error == 0) { /* This seems to violate POSIX but linux does it */ error = fgetvp(td, uap->fd, @@ -1028,17 +1021,10 @@ linux_pread(td, uap) } int -linux_pwrite(td, uap) - struct thread *td; - struct linux_pwrite_args *uap; -{ - struct pwrite_args bsd; - - bsd.fd = uap->fd; - bsd.buf = uap->buf; - bsd.nbyte = uap->nbyte; - bsd.offset = uap->offset; - return (sys_pwrite(td, &bsd)); +linux_pwrite(struct thread *td, struct linux_pwrite_args *uap) +{ + + return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte, uap->offset)); } int Modified: stable/11/sys/kern/sys_generic.c ============================================================================== --- stable/11/sys/kern/sys_generic.c Sun Mar 19 14:42:16 2017 (r315552) +++ stable/11/sys/kern/sys_generic.c Sun Mar 19 14:46:40 2017 (r315553) @@ -220,39 +220,37 @@ struct pread_args { }; #endif int -sys_pread(td, uap) - struct thread *td; - struct pread_args *uap; +sys_pread(struct thread *td, struct pread_args *uap) +{ + + return (kern_pread(td, uap->fd, uap->buf, uap->nbyte, uap->offset)); +} + +int +kern_pread(struct thread *td, int fd, void *buf, size_t nbyte, off_t offset) { struct uio auio; struct iovec aiov; int error; - if (uap->nbyte > IOSIZE_MAX) + if (nbyte > IOSIZE_MAX) return (EINVAL); - aiov.iov_base = uap->buf; - aiov.iov_len = uap->nbyte; + aiov.iov_base = buf; + aiov.iov_len = nbyte; auio.uio_iov = &aiov; auio.uio_iovcnt = 1; - auio.uio_resid = uap->nbyte; + auio.uio_resid = nbyte; auio.uio_segflg = UIO_USERSPACE; - error = kern_preadv(td, uap->fd, &auio, uap->offset); - return(error); + error = kern_preadv(td, fd, &auio, offset); + return (error); } #if defined(COMPAT_FREEBSD6) int -freebsd6_pread(td, uap) - struct thread *td; - struct freebsd6_pread_args *uap; +freebsd6_pread(struct thread *td, struct freebsd6_pread_args *uap) { - struct pread_args oargs; - oargs.fd = uap->fd; - oargs.buf = uap->buf; - oargs.nbyte = uap->nbyte; - oargs.offset = uap->offset; - return (sys_pread(td, &oargs)); + return (kern_pread(td, uap->fd, uap->buf, uap->nbyte, uap->offset)); } #endif @@ -436,39 +434,38 @@ struct pwrite_args { }; #endif int -sys_pwrite(td, uap) - struct thread *td; - struct pwrite_args *uap; +sys_pwrite(struct thread *td, struct pwrite_args *uap) +{ + + return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte, uap->offset)); +} + +int +kern_pwrite(struct thread *td, int fd, const void *buf, size_t nbyte, + off_t offset) { struct uio auio; struct iovec aiov; int error; - if (uap->nbyte > IOSIZE_MAX) + if (nbyte > IOSIZE_MAX) return (EINVAL); - aiov.iov_base = (void *)(uintptr_t)uap->buf; - aiov.iov_len = uap->nbyte; + aiov.iov_base = (void *)(uintptr_t)buf; + aiov.iov_len = nbyte; auio.uio_iov = &aiov; auio.uio_iovcnt = 1; - auio.uio_resid = uap->nbyte; + auio.uio_resid = nbyte; auio.uio_segflg = UIO_USERSPACE; - error = kern_pwritev(td, uap->fd, &auio, uap->offset); + error = kern_pwritev(td, fd, &auio, offset); return(error); } #if defined(COMPAT_FREEBSD6) int -freebsd6_pwrite(td, uap) - struct thread *td; - struct freebsd6_pwrite_args *uap; +freebsd6_pwrite(struct thread *td, struct freebsd6_pwrite_args *uap) { - struct pwrite_args oargs; - oargs.fd = uap->fd; - oargs.buf = uap->buf; - oargs.nbyte = uap->nbyte; - oargs.offset = uap->offset; - return (sys_pwrite(td, &oargs)); + return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte, uap->offset)); } #endif Modified: stable/11/sys/sys/syscallsubr.h ============================================================================== --- stable/11/sys/sys/syscallsubr.h Sun Mar 19 14:42:16 2017 (r315552) +++ stable/11/sys/sys/syscallsubr.h Sun Mar 19 14:46:40 2017 (r315553) @@ -177,11 +177,15 @@ int kern_posix_fallocate(struct thread * off_t len); int kern_procctl(struct thread *td, enum idtype idtype, id_t id, int com, void *data); +int kern_pread(struct thread *td, int fd, void *buf, size_t nbyte, + off_t offset); int kern_preadv(struct thread *td, int fd, struct uio *auio, off_t offset); int kern_pselect(struct thread *td, int nd, fd_set *in, fd_set *ou, fd_set *ex, struct timeval *tvp, sigset_t *uset, int abi_nfdbits); int kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data); +int kern_pwrite(struct thread *td, int fd, const void *buf, size_t nbyte, + off_t offset); int kern_pwritev(struct thread *td, int fd, struct uio *auio, off_t offset); int kern_readlinkat(struct thread *td, int fd, char *path, enum uio_seg pathseg, char *buf, enum uio_seg bufseg, size_t count); From owner-svn-src-stable-11@freebsd.org Sun Mar 19 15:07:31 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CBE5AD1297D; Sun, 19 Mar 2017 15:07:31 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8D77E1D43; Sun, 19 Mar 2017 15:07:31 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JF7U1Y081945; Sun, 19 Mar 2017 15:07:30 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JF7UIk081942; Sun, 19 Mar 2017 15:07:30 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191507.v2JF7UIk081942@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 15:07:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315554 - in stable/11/sys: compat/freebsd32 kern sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 15:07:31 -0000 Author: trasz Date: Sun Mar 19 15:07:30 2017 New Revision: 315554 URL: https://svnweb.freebsd.org/changeset/base/315554 Log: MFC r313015: Add kern_cpuset_getid() and kern_cpuset_setid(), and use them in compat32 instead of their sub_*() counterparts. Sponsored by: DARPA, AFRL Modified: stable/11/sys/compat/freebsd32/freebsd32_misc.c stable/11/sys/kern/kern_cpuset.c stable/11/sys/sys/syscallsubr.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- stable/11/sys/compat/freebsd32/freebsd32_misc.c Sun Mar 19 14:46:40 2017 (r315553) +++ stable/11/sys/compat/freebsd32/freebsd32_misc.c Sun Mar 19 15:07:30 2017 (r315554) @@ -2526,27 +2526,18 @@ int freebsd32_cpuset_setid(struct thread *td, struct freebsd32_cpuset_setid_args *uap) { - struct cpuset_setid_args ap; - ap.which = uap->which; - ap.id = PAIR32TO64(id_t,uap->id); - ap.setid = uap->setid; - - return (sys_cpuset_setid(td, &ap)); + return (kern_cpuset_setid(td, uap->which, + PAIR32TO64(id_t, uap->id), uap->setid)); } int freebsd32_cpuset_getid(struct thread *td, struct freebsd32_cpuset_getid_args *uap) { - struct cpuset_getid_args ap; - - ap.level = uap->level; - ap.which = uap->which; - ap.id = PAIR32TO64(id_t,uap->id); - ap.setid = uap->setid; - return (sys_cpuset_getid(td, &ap)); + return (kern_cpuset_getid(td, uap->level, uap->which, + PAIR32TO64(id_t, uap->id), uap->setid)); } int Modified: stable/11/sys/kern/kern_cpuset.c ============================================================================== --- stable/11/sys/kern/kern_cpuset.c Sun Mar 19 14:46:40 2017 (r315553) +++ stable/11/sys/kern/kern_cpuset.c Sun Mar 19 15:07:30 2017 (r315554) @@ -976,18 +976,26 @@ struct cpuset_setid_args { int sys_cpuset_setid(struct thread *td, struct cpuset_setid_args *uap) { + + return (kern_cpuset_setid(td, uap->which, uap->id, uap->setid)); +} + +int +kern_cpuset_setid(struct thread *td, cpuwhich_t which, + id_t id, cpusetid_t setid) +{ struct cpuset *set; int error; /* * Presently we only support per-process sets. */ - if (uap->which != CPU_WHICH_PID) + if (which != CPU_WHICH_PID) return (EINVAL); - set = cpuset_lookup(uap->setid, td); + set = cpuset_lookup(setid, td); if (set == NULL) return (ESRCH); - error = cpuset_setproc(uap->id, set, NULL); + error = cpuset_setproc(id, set, NULL); cpuset_rel(set); return (error); } @@ -1003,19 +1011,28 @@ struct cpuset_getid_args { int sys_cpuset_getid(struct thread *td, struct cpuset_getid_args *uap) { + + return (kern_cpuset_getid(td, uap->level, uap->which, uap->id, + uap->setid)); +} + +int +kern_cpuset_getid(struct thread *td, cpulevel_t level, cpuwhich_t which, + id_t id, cpusetid_t *setid) +{ struct cpuset *nset; struct cpuset *set; struct thread *ttd; struct proc *p; - cpusetid_t id; + cpusetid_t tmpid; int error; - if (uap->level == CPU_LEVEL_WHICH && uap->which != CPU_WHICH_CPUSET) + if (level == CPU_LEVEL_WHICH && which != CPU_WHICH_CPUSET) return (EINVAL); - error = cpuset_which(uap->which, uap->id, &p, &ttd, &set); + error = cpuset_which(which, id, &p, &ttd, &set); if (error) return (error); - switch (uap->which) { + switch (which) { case CPU_WHICH_TID: case CPU_WHICH_PID: thread_lock(ttd); @@ -1030,7 +1047,7 @@ sys_cpuset_getid(struct thread *td, stru case CPU_WHICH_DOMAIN: return (EINVAL); } - switch (uap->level) { + switch (level) { case CPU_LEVEL_ROOT: nset = cpuset_refroot(set); cpuset_rel(set); @@ -1041,10 +1058,10 @@ sys_cpuset_getid(struct thread *td, stru case CPU_LEVEL_WHICH: break; } - id = set->cs_id; + tmpid = set->cs_id; cpuset_rel(set); if (error == 0) - error = copyout(&id, uap->setid, sizeof(id)); + error = copyout(&tmpid, setid, sizeof(id)); return (error); } Modified: stable/11/sys/sys/syscallsubr.h ============================================================================== --- stable/11/sys/sys/syscallsubr.h Sun Mar 19 14:46:40 2017 (r315553) +++ stable/11/sys/sys/syscallsubr.h Sun Mar 19 15:07:30 2017 (r315554) @@ -87,6 +87,10 @@ int kern_clock_settime(struct thread *td int kern_close(struct thread *td, int fd); int kern_connectat(struct thread *td, int dirfd, int fd, struct sockaddr *sa); +int kern_cpuset_getid(struct thread *td, cpulevel_t level, + cpuwhich_t which, id_t id, cpusetid_t *setid); +int kern_cpuset_setid(struct thread *td, cpuwhich_t which, + id_t id, cpusetid_t setid); int kern_dup(struct thread *td, u_int mode, int flags, int old, int new); int kern_execve(struct thread *td, struct image_args *args, struct mac *mac_p); From owner-svn-src-stable-11@freebsd.org Sun Mar 19 15:15:35 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E4393D12EFA; Sun, 19 Mar 2017 15:15:35 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BEA9268E; Sun, 19 Mar 2017 15:15:35 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JFFYTt086029; Sun, 19 Mar 2017 15:15:34 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JFFYWN086025; Sun, 19 Mar 2017 15:15:34 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191515.v2JFFYWN086025@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 15:15:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315555 - in stable/11/sys: compat/freebsd32 compat/linux kern sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 15:15:36 -0000 Author: trasz Date: Sun Mar 19 15:15:34 2017 New Revision: 315555 URL: https://svnweb.freebsd.org/changeset/base/315555 Log: MFC r313281: Add kern_cpuset_getaffinity() and kern_cpuset_getaffinity(), and use it in compats instead of their sys_*() counterparts. Sponsored by: DARPA, AFRL Modified: stable/11/sys/compat/freebsd32/freebsd32_misc.c stable/11/sys/compat/linux/linux_misc.c stable/11/sys/kern/kern_cpuset.c stable/11/sys/sys/syscallsubr.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- stable/11/sys/compat/freebsd32/freebsd32_misc.c Sun Mar 19 15:07:30 2017 (r315554) +++ stable/11/sys/compat/freebsd32/freebsd32_misc.c Sun Mar 19 15:15:34 2017 (r315555) @@ -2544,30 +2544,18 @@ int freebsd32_cpuset_getaffinity(struct thread *td, struct freebsd32_cpuset_getaffinity_args *uap) { - struct cpuset_getaffinity_args ap; - ap.level = uap->level; - ap.which = uap->which; - ap.id = PAIR32TO64(id_t,uap->id); - ap.cpusetsize = uap->cpusetsize; - ap.mask = uap->mask; - - return (sys_cpuset_getaffinity(td, &ap)); + return (kern_cpuset_getaffinity(td, uap->level, uap->which, + PAIR32TO64(id_t,uap->id), uap->cpusetsize, uap->mask)); } int freebsd32_cpuset_setaffinity(struct thread *td, struct freebsd32_cpuset_setaffinity_args *uap) { - struct cpuset_setaffinity_args ap; - - ap.level = uap->level; - ap.which = uap->which; - ap.id = PAIR32TO64(id_t,uap->id); - ap.cpusetsize = uap->cpusetsize; - ap.mask = uap->mask; - return (sys_cpuset_setaffinity(td, &ap)); + return (kern_cpuset_setaffinity(td, uap->level, uap->which, + PAIR32TO64(id_t,uap->id), uap->cpusetsize, uap->mask)); } int Modified: stable/11/sys/compat/linux/linux_misc.c ============================================================================== --- stable/11/sys/compat/linux/linux_misc.c Sun Mar 19 15:07:30 2017 (r315554) +++ stable/11/sys/compat/linux/linux_misc.c Sun Mar 19 15:15:34 2017 (r315555) @@ -2095,7 +2095,6 @@ linux_sched_getaffinity(struct thread *t { int error; struct thread *tdt; - struct cpuset_getaffinity_args cga; #ifdef DEBUG if (ldebug(sched_getaffinity)) @@ -2110,13 +2109,10 @@ linux_sched_getaffinity(struct thread *t return (ESRCH); PROC_UNLOCK(tdt->td_proc); - cga.level = CPU_LEVEL_WHICH; - cga.which = CPU_WHICH_TID; - cga.id = tdt->td_tid; - cga.cpusetsize = sizeof(cpuset_t); - cga.mask = (cpuset_t *) args->user_mask_ptr; - if ((error = sys_cpuset_getaffinity(td, &cga)) == 0) + error = kern_cpuset_getaffinity(td, CPU_LEVEL_WHICH, CPU_WHICH_TID, + tdt->td_tid, sizeof(cpuset_t), (cpuset_t *)args->user_mask_ptr); + if (error == 0) td->td_retval[0] = sizeof(cpuset_t); return (error); @@ -2129,7 +2125,6 @@ int linux_sched_setaffinity(struct thread *td, struct linux_sched_setaffinity_args *args) { - struct cpuset_setaffinity_args csa; struct thread *tdt; #ifdef DEBUG @@ -2145,13 +2140,9 @@ linux_sched_setaffinity(struct thread *t return (ESRCH); PROC_UNLOCK(tdt->td_proc); - csa.level = CPU_LEVEL_WHICH; - csa.which = CPU_WHICH_TID; - csa.id = tdt->td_tid; - csa.cpusetsize = sizeof(cpuset_t); - csa.mask = (cpuset_t *) args->user_mask_ptr; - return (sys_cpuset_setaffinity(td, &csa)); + return (kern_cpuset_setaffinity(td, CPU_LEVEL_WHICH, CPU_WHICH_TID, + tdt->td_tid, sizeof(cpuset_t), (cpuset_t *) args->user_mask_ptr)); } struct linux_rlimit64 { Modified: stable/11/sys/kern/kern_cpuset.c ============================================================================== --- stable/11/sys/kern/kern_cpuset.c Sun Mar 19 15:07:30 2017 (r315554) +++ stable/11/sys/kern/kern_cpuset.c Sun Mar 19 15:15:34 2017 (r315555) @@ -1078,6 +1078,15 @@ struct cpuset_getaffinity_args { int sys_cpuset_getaffinity(struct thread *td, struct cpuset_getaffinity_args *uap) { + + return (kern_cpuset_getaffinity(td, uap->level, uap->which, + uap->id, uap->cpusetsize, uap->mask)); +} + +int +kern_cpuset_getaffinity(struct thread *td, cpulevel_t level, cpuwhich_t which, + id_t id, size_t cpusetsize, cpuset_t *maskp) +{ struct thread *ttd; struct cpuset *nset; struct cpuset *set; @@ -1086,18 +1095,17 @@ sys_cpuset_getaffinity(struct thread *td int error; size_t size; - if (uap->cpusetsize < sizeof(cpuset_t) || - uap->cpusetsize > CPU_MAXSIZE / NBBY) + if (cpusetsize < sizeof(cpuset_t) || cpusetsize > CPU_MAXSIZE / NBBY) return (ERANGE); - size = uap->cpusetsize; + size = cpusetsize; mask = malloc(size, M_TEMP, M_WAITOK | M_ZERO); - error = cpuset_which(uap->which, uap->id, &p, &ttd, &set); + error = cpuset_which(which, id, &p, &ttd, &set); if (error) goto out; - switch (uap->level) { + switch (level) { case CPU_LEVEL_ROOT: case CPU_LEVEL_CPUSET: - switch (uap->which) { + switch (which) { case CPU_WHICH_TID: case CPU_WHICH_PID: thread_lock(ttd); @@ -1112,7 +1120,7 @@ sys_cpuset_getaffinity(struct thread *td error = EINVAL; goto out; } - if (uap->level == CPU_LEVEL_ROOT) + if (level == CPU_LEVEL_ROOT) nset = cpuset_refroot(set); else nset = cpuset_refbase(set); @@ -1120,7 +1128,7 @@ sys_cpuset_getaffinity(struct thread *td cpuset_rel(nset); break; case CPU_LEVEL_WHICH: - switch (uap->which) { + switch (which) { case CPU_WHICH_TID: thread_lock(ttd); CPU_COPY(&ttd->td_cpuset->cs_mask, mask); @@ -1138,13 +1146,13 @@ sys_cpuset_getaffinity(struct thread *td CPU_COPY(&set->cs_mask, mask); break; case CPU_WHICH_IRQ: - error = intr_getaffinity(uap->id, mask); + error = intr_getaffinity(id, mask); break; case CPU_WHICH_DOMAIN: - if (uap->id < 0 || uap->id >= MAXMEMDOM) + if (id < 0 || id >= MAXMEMDOM) error = ESRCH; else - CPU_COPY(&cpuset_domain[uap->id], mask); + CPU_COPY(&cpuset_domain[id], mask); break; } break; @@ -1157,7 +1165,7 @@ sys_cpuset_getaffinity(struct thread *td if (p) PROC_UNLOCK(p); if (error == 0) - error = copyout(mask, uap->mask, size); + error = copyout(mask, maskp, size); out: free(mask, M_TEMP); return (error); @@ -1175,6 +1183,15 @@ struct cpuset_setaffinity_args { int sys_cpuset_setaffinity(struct thread *td, struct cpuset_setaffinity_args *uap) { + + return (kern_cpuset_setaffinity(td, uap->level, uap->which, + uap->id, uap->cpusetsize, uap->mask)); +} + +int +kern_cpuset_setaffinity(struct thread *td, cpulevel_t level, cpuwhich_t which, + id_t id, size_t cpusetsize, const cpuset_t *maskp) +{ struct cpuset *nset; struct cpuset *set; struct thread *ttd; @@ -1182,22 +1199,21 @@ sys_cpuset_setaffinity(struct thread *td cpuset_t *mask; int error; - if (uap->cpusetsize < sizeof(cpuset_t) || - uap->cpusetsize > CPU_MAXSIZE / NBBY) + if (cpusetsize < sizeof(cpuset_t) || cpusetsize > CPU_MAXSIZE / NBBY) return (ERANGE); - mask = malloc(uap->cpusetsize, M_TEMP, M_WAITOK | M_ZERO); - error = copyin(uap->mask, mask, uap->cpusetsize); + mask = malloc(cpusetsize, M_TEMP, M_WAITOK | M_ZERO); + error = copyin(maskp, mask, cpusetsize); if (error) goto out; /* * Verify that no high bits are set. */ - if (uap->cpusetsize > sizeof(cpuset_t)) { + if (cpusetsize > sizeof(cpuset_t)) { char *end; char *cp; end = cp = (char *)&mask->__bits; - end += uap->cpusetsize; + end += cpusetsize; cp += sizeof(cpuset_t); while (cp != end) if (*cp++ != 0) { @@ -1206,13 +1222,13 @@ sys_cpuset_setaffinity(struct thread *td } } - switch (uap->level) { + switch (level) { case CPU_LEVEL_ROOT: case CPU_LEVEL_CPUSET: - error = cpuset_which(uap->which, uap->id, &p, &ttd, &set); + error = cpuset_which(which, id, &p, &ttd, &set); if (error) break; - switch (uap->which) { + switch (which) { case CPU_WHICH_TID: case CPU_WHICH_PID: thread_lock(ttd); @@ -1228,7 +1244,7 @@ sys_cpuset_setaffinity(struct thread *td error = EINVAL; goto out; } - if (uap->level == CPU_LEVEL_ROOT) + if (level == CPU_LEVEL_ROOT) nset = cpuset_refroot(set); else nset = cpuset_refbase(set); @@ -1237,24 +1253,23 @@ sys_cpuset_setaffinity(struct thread *td cpuset_rel(set); break; case CPU_LEVEL_WHICH: - switch (uap->which) { + switch (which) { case CPU_WHICH_TID: - error = cpuset_setthread(uap->id, mask); + error = cpuset_setthread(id, mask); break; case CPU_WHICH_PID: - error = cpuset_setproc(uap->id, NULL, mask); + error = cpuset_setproc(id, NULL, mask); break; case CPU_WHICH_CPUSET: case CPU_WHICH_JAIL: - error = cpuset_which(uap->which, uap->id, &p, - &ttd, &set); + error = cpuset_which(which, id, &p, &ttd, &set); if (error == 0) { error = cpuset_modify(set, mask); cpuset_rel(set); } break; case CPU_WHICH_IRQ: - error = intr_setaffinity(uap->id, mask); + error = intr_setaffinity(id, mask); break; default: error = EINVAL; Modified: stable/11/sys/sys/syscallsubr.h ============================================================================== --- stable/11/sys/sys/syscallsubr.h Sun Mar 19 15:07:30 2017 (r315554) +++ stable/11/sys/sys/syscallsubr.h Sun Mar 19 15:15:34 2017 (r315555) @@ -33,6 +33,7 @@ #include #include #include +#include struct file; struct filecaps; @@ -87,6 +88,11 @@ int kern_clock_settime(struct thread *td int kern_close(struct thread *td, int fd); int kern_connectat(struct thread *td, int dirfd, int fd, struct sockaddr *sa); +int kern_cpuset_getaffinity(struct thread *td, cpulevel_t level, + cpuwhich_t which, id_t id, size_t cpusetsize, cpuset_t *maskp); +int kern_cpuset_setaffinity(struct thread *td, cpulevel_t level, + cpuwhich_t which, id_t id, size_t cpusetsize, + const cpuset_t *maskp); int kern_cpuset_getid(struct thread *td, cpulevel_t level, cpuwhich_t which, id_t id, cpusetid_t *setid); int kern_cpuset_setid(struct thread *td, cpuwhich_t which, From owner-svn-src-stable-11@freebsd.org Sun Mar 19 15:32:13 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A897FD13328; Sun, 19 Mar 2017 15:32:13 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 77A95EE7; Sun, 19 Mar 2017 15:32:13 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JFWCO9093004; Sun, 19 Mar 2017 15:32:12 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JFWCpH093003; Sun, 19 Mar 2017 15:32:12 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191532.v2JFWCpH093003@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 15:32:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315556 - stable/11/sys/compat/linux X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 15:32:13 -0000 Author: trasz Date: Sun Mar 19 15:32:12 2017 New Revision: 315556 URL: https://svnweb.freebsd.org/changeset/base/315556 Log: MFC r313947: There are some Linux binaries that expect the system to obey the "addr" parameter to mmap(2), even if MAP_FIXED is not explicitly specified. Android ART is one example. Implement bug compatibility for this case in linuxulator. Sponsored by: DARPA, AFRL Modified: stable/11/sys/compat/linux/linux_mmap.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linux/linux_mmap.c ============================================================================== --- stable/11/sys/compat/linux/linux_mmap.c Sun Mar 19 15:15:34 2017 (r315555) +++ stable/11/sys/compat/linux/linux_mmap.c Sun Mar 19 15:32:12 2017 (r315556) @@ -203,8 +203,23 @@ linux_mmap_common(struct thread *td, uin } } - error = kern_mmap(td, addr, len, prot, bsd_flags, fd, pos); + /* + * FreeBSD is free to ignore the address hint if MAP_FIXED wasn't + * passed. However, some Linux applications, like the ART runtime, + * depend on the hint. If the MAP_FIXED wasn't passed, but the + * address is not zero, try with MAP_FIXED and MAP_EXCL first, + * and fall back to the normal behaviour if that fails. + */ + if (addr != 0 && (bsd_flags & MAP_FIXED) == 0 && + (bsd_flags & MAP_EXCL) == 0) { + error = kern_mmap(td, addr, len, prot, + bsd_flags | MAP_FIXED | MAP_EXCL, fd, pos); + if (error == 0) + goto out; + } + error = kern_mmap(td, addr, len, prot, bsd_flags, fd, pos); +out: LINUX_CTR2(mmap2, "return: %d (%p)", error, td->td_retval[0]); return (error); From owner-svn-src-stable-11@freebsd.org Sun Mar 19 15:44:09 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8780BD1365B; Sun, 19 Mar 2017 15:44:09 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5699514CF; Sun, 19 Mar 2017 15:44:09 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JFi8N5098044; Sun, 19 Mar 2017 15:44:08 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JFi8wA098043; Sun, 19 Mar 2017 15:44:08 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201703191544.v2JFi8wA098043@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 19 Mar 2017 15:44:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315557 - stable/11/sys/kern X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 15:44:09 -0000 Author: kib Date: Sun Mar 19 15:44:08 2017 New Revision: 315557 URL: https://svnweb.freebsd.org/changeset/base/315557 Log: MFC r315156: Style. Modified: stable/11/sys/kern/imgact_elf.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/imgact_elf.c ============================================================================== --- stable/11/sys/kern/imgact_elf.c Sun Mar 19 15:32:12 2017 (r315556) +++ stable/11/sys/kern/imgact_elf.c Sun Mar 19 15:44:08 2017 (r315557) @@ -508,7 +508,7 @@ __elfN(load_section)(struct image_params size_t map_len; vm_map_t map; vm_object_t object; - vm_offset_t map_addr; + vm_offset_t off, map_addr; int error, rv, cow; size_t copy_len; vm_ooffset_t file_addr; @@ -559,9 +559,8 @@ __elfN(load_section)(struct image_params return (EINVAL); /* we can stop now if we've covered it all */ - if (memsz == filsz) { + if (memsz == filsz) return (0); - } } @@ -580,14 +579,11 @@ __elfN(load_section)(struct image_params if (map_len != 0) { rv = __elfN(map_insert)(imgp, map, NULL, 0, map_addr, map_addr + map_len, VM_PROT_ALL, 0); - if (rv != KERN_SUCCESS) { + if (rv != KERN_SUCCESS) return (EINVAL); - } } if (copy_len != 0) { - vm_offset_t off; - sf = vm_imgact_map_page(object, offset + filsz); if (sf == NULL) return (EIO); @@ -598,14 +594,12 @@ __elfN(load_section)(struct image_params error = copyout((caddr_t)sf_buf_kva(sf) + off, (caddr_t)map_addr, copy_len); vm_imgact_unmap_page(sf); - if (error) { + if (error != 0) return (error); - } } /* * set it to the specified protection. - * XXX had better undo the damage from pasting over the cracks here! */ vm_map_protect(map, trunc_page(map_addr), round_page(map_addr + map_len), prot, FALSE); From owner-svn-src-stable-11@freebsd.org Sun Mar 19 15:46:27 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2A494D136F3; Sun, 19 Mar 2017 15:46:27 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C77B31648; Sun, 19 Mar 2017 15:46:26 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JFkP6B098187; Sun, 19 Mar 2017 15:46:25 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JFkPam098186; Sun, 19 Mar 2017 15:46:25 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201703191546.v2JFkPam098186@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 19 Mar 2017 15:46:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315558 - stable/11/sys/kern X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 15:46:27 -0000 Author: kib Date: Sun Mar 19 15:46:25 2017 New Revision: 315558 URL: https://svnweb.freebsd.org/changeset/base/315558 Log: MFC r315157: Accept linkers representation for ELF segments with zero on-disk length. Modified: stable/11/sys/kern/imgact_elf.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/imgact_elf.c ============================================================================== --- stable/11/sys/kern/imgact_elf.c Sun Mar 19 15:44:08 2017 (r315557) +++ stable/11/sys/kern/imgact_elf.c Sun Mar 19 15:46:25 2017 (r315558) @@ -522,7 +522,8 @@ __elfN(load_section)(struct image_params * While I'm here, might as well check for something else that * is invalid: filsz cannot be greater than memsz. */ - if ((off_t)filsz + offset > imgp->attr->va_size || filsz > memsz) { + if ((filsz != 0 && (off_t)filsz + offset > imgp->attr->va_size) || + filsz > memsz) { uprintf("elf_load_section: truncated ELF file\n"); return (ENOEXEC); } @@ -538,7 +539,9 @@ __elfN(load_section)(struct image_params * early and copy the initialized data into that first page. We * choose the second. */ - if (memsz > filsz) + if (filsz == 0) + map_len = 0; + else if (memsz > filsz) map_len = trunc_page_ps(offset + filsz, pagesize) - file_addr; else map_len = round_page_ps(offset + filsz, pagesize) - file_addr; @@ -570,7 +573,8 @@ __elfN(load_section)(struct image_params * segment in the file is extended to provide bss. It's a neat idea * to try and save a page, but it's a pain in the behind to implement. */ - copy_len = (offset + filsz) - trunc_page_ps(offset + filsz, pagesize); + copy_len = filsz == 0 ? 0 : (offset + filsz) - trunc_page_ps(offset + + filsz, pagesize); map_addr = trunc_page_ps((vm_offset_t)vmaddr + filsz, pagesize); map_len = round_page_ps((vm_offset_t)vmaddr + memsz, pagesize) - map_addr; From owner-svn-src-stable-11@freebsd.org Sun Mar 19 15:48:43 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 580BBD137C2; Sun, 19 Mar 2017 15:48:43 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0AB4718F2; Sun, 19 Mar 2017 15:48:42 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JFmg1O098338; Sun, 19 Mar 2017 15:48:42 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JFmg1j098337; Sun, 19 Mar 2017 15:48:42 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201703191548.v2JFmg1j098337@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 19 Mar 2017 15:48:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315559 - stable/11/sys/kern X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 15:48:43 -0000 Author: kib Date: Sun Mar 19 15:48:41 2017 New Revision: 315559 URL: https://svnweb.freebsd.org/changeset/base/315559 Log: MFC r315159: Avoid reusing p_ksi while it is on queue. Modified: stable/11/sys/kern/kern_exit.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_exit.c ============================================================================== --- stable/11/sys/kern/kern_exit.c Sun Mar 19 15:46:25 2017 (r315558) +++ stable/11/sys/kern/kern_exit.c Sun Mar 19 15:48:41 2017 (r315559) @@ -189,6 +189,7 @@ exit1(struct thread *td, int rval, int s { struct proc *p, *nq, *q, *t; struct thread *tdt; + ksiginfo_t *ksi, *ksi1; mtx_assert(&Giant, MA_NOTOWNED); KASSERT(rval == 0 || signo == 0, ("exit1 rv %d sig %d", rval, signo)); @@ -449,14 +450,32 @@ exit1(struct thread *td, int rval, int s wakeup(q->p_reaper); for (; q != NULL; q = nq) { nq = LIST_NEXT(q, p_sibling); + ksi = ksiginfo_alloc(TRUE); PROC_LOCK(q); q->p_sigparent = SIGCHLD; if (!(q->p_flag & P_TRACED)) { proc_reparent(q, q->p_reaper); if (q->p_state == PRS_ZOMBIE) { + /* + * Inform reaper about the reparented + * zombie, since wait(2) has something + * new to report. Guarantee queueing + * of the SIGCHLD signal, similar to + * the _exit() behaviour, by providing + * our ksiginfo. Ksi is freed by the + * signal delivery. + */ + if (q->p_ksi == NULL) { + ksi1 = NULL; + } else { + ksiginfo_copy(q->p_ksi, ksi); + ksi->ksi_flags |= KSI_INS; + ksi1 = ksi; + ksi = NULL; + } PROC_LOCK(q->p_reaper); - pksignal(q->p_reaper, SIGCHLD, q->p_ksi); + pksignal(q->p_reaper, SIGCHLD, ksi1); PROC_UNLOCK(q->p_reaper); } } else { @@ -489,6 +508,8 @@ exit1(struct thread *td, int rval, int s kern_psignal(q, SIGKILL); } PROC_UNLOCK(q); + if (ksi != NULL) + ksiginfo_free(ksi); } /* From owner-svn-src-stable-11@freebsd.org Sun Mar 19 16:01:45 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E9E49D13F88; Sun, 19 Mar 2017 16:01:45 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C468F9B0; Sun, 19 Mar 2017 16:01:45 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JG1itA005853; Sun, 19 Mar 2017 16:01:44 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JG1iBO005845; Sun, 19 Mar 2017 16:01:44 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201703191601.v2JG1iBO005845@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 19 Mar 2017 16:01:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315563 - in stable/11: lib/libc/sys sys/kern sys/vm X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 16:01:46 -0000 Author: kib Date: Sun Mar 19 16:01:44 2017 New Revision: 315563 URL: https://svnweb.freebsd.org/changeset/base/315563 Log: MFC r313690: Consistently handle negative or wrapping offsets in the mmap(2) syscalls. MFC r315158: Fix two missed places where vm_object offset to index calculation should use unsigned shift. Modified: stable/11/lib/libc/sys/mmap.2 stable/11/sys/kern/uipc_shm.c stable/11/sys/kern/vfs_vnops.c stable/11/sys/vm/device_pager.c stable/11/sys/vm/sg_pager.c stable/11/sys/vm/vm_map.c stable/11/sys/vm/vm_object.h Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/sys/mmap.2 ============================================================================== --- stable/11/lib/libc/sys/mmap.2 Sun Mar 19 15:56:06 2017 (r315562) +++ stable/11/lib/libc/sys/mmap.2 Sun Mar 19 16:01:44 2017 (r315563) @@ -28,7 +28,7 @@ .\" @(#)mmap.2 8.4 (Berkeley) 5/11/95 .\" $FreeBSD$ .\" -.Dd November 25, 2016 +.Dd February 4, 2017 .Dt MMAP 2 .Os .Sh NAME @@ -53,11 +53,37 @@ starting at byte offset .Fa offset . If .Fa len -is not a multiple of the pagesize, the mapped region may extend past the +is not a multiple of the page size, the mapped region may extend past the specified range. Any such extension beyond the end of the mapped object will be zero-filled. .Pp If +.Fa fd +references a regular file or a shared memory object, the range of +bytes starting at +.Fa offset +and continuing for +.Fa len +bytes must be legitimate for the possible (not necessarily +current) offsets in the object. +In particular, the +.Fa offset +value cannot be negative. +If the object is truncated and the process later accesses a pages that +is wholly within the truncated region, the access is aborted and a +.Dv SIGBUS +signal is delivered to the process. +.Pp +If +.Fa fd +references a device file, the interpretation of the +.Fa offset +value is device specific and defined by the device driver. +The virtual memory subsystem does not impose any restrictitions on the +.Fa offset +value in this case, passing it unchanged to the driver. +.Pp +If .Fa addr is non-zero, it is used as a hint to the system. (As a convenience to the system, the actual address of the region may differ @@ -157,7 +183,7 @@ If .Dv MAP_FIXED is specified, .Fa addr -must be a multiple of the pagesize. +must be a multiple of the page size. If .Dv MAP_EXCL is not specified, a successful @@ -361,6 +387,12 @@ The argument is not a valid open file descriptor. .It Bq Er EINVAL +An invalid (negative) value was passed in the +.Fa offset +argument, when +.Fa fd +referenced a regular file or shared memory. +.It Bq Er EINVAL An invalid value was passed in the .Fa prot argument. Modified: stable/11/sys/kern/uipc_shm.c ============================================================================== --- stable/11/sys/kern/uipc_shm.c Sun Mar 19 15:56:06 2017 (r315562) +++ stable/11/sys/kern/uipc_shm.c Sun Mar 19 16:01:44 2017 (r315563) @@ -886,20 +886,20 @@ shm_mmap(struct file *fp, vm_map_t map, return (EACCES); maxprot &= cap_maxprot; + /* See comment in vn_mmap(). */ + if ( +#ifdef _LP64 + objsize > OFF_MAX || +#endif + foff < 0 || foff > OFF_MAX - objsize) + return (EINVAL); + #ifdef MAC error = mac_posixshm_check_mmap(td->td_ucred, shmfd, prot, flags); if (error != 0) return (error); #endif - /* - * XXXRW: This validation is probably insufficient, and subject to - * sign errors. It should be fixed. - */ - if (foff >= shmfd->shm_size || - foff + objsize > round_page(shmfd->shm_size)) - return (EINVAL); - mtx_lock(&shm_timestamp_lock); vfs_timestamp(&shmfd->shm_atime); mtx_unlock(&shm_timestamp_lock); Modified: stable/11/sys/kern/vfs_vnops.c ============================================================================== --- stable/11/sys/kern/vfs_vnops.c Sun Mar 19 15:56:06 2017 (r315562) +++ stable/11/sys/kern/vfs_vnops.c Sun Mar 19 16:01:44 2017 (r315563) @@ -2452,6 +2452,24 @@ vn_mmap(struct file *fp, vm_map_t map, v } maxprot &= cap_maxprot; + /* + * For regular files and shared memory, POSIX requires that + * the value of foff be a legitimate offset within the data + * object. In particular, negative offsets are invalid. + * Blocking negative offsets and overflows here avoids + * possible wraparound or user-level access into reserved + * ranges of the data object later. In contrast, POSIX does + * not dictate how offsets are used by device drivers, so in + * the case of a device mapping a negative offset is passed + * on. + */ + if ( +#ifdef _LP64 + size > OFF_MAX || +#endif + foff < 0 || foff > OFF_MAX - size) + return (EINVAL); + writecounted = FALSE; error = vm_mmap_vnode(td, size, prot, &maxprot, &flags, vp, &foff, &object, &writecounted); Modified: stable/11/sys/vm/device_pager.c ============================================================================== --- stable/11/sys/vm/device_pager.c Sun Mar 19 15:56:06 2017 (r315562) +++ stable/11/sys/vm/device_pager.c Sun Mar 19 16:01:44 2017 (r315563) @@ -139,8 +139,18 @@ cdev_pager_allocate(void *handle, enum o if (foff & PAGE_MASK) return (NULL); + /* + * Treat the mmap(2) file offset as an unsigned value for a + * device mapping. This, in effect, allows a user to pass all + * possible off_t values as the mapping cookie to the driver. At + * this point, we know that both foff and size are a multiple + * of the page size. Do a check to avoid wrap. + */ size = round_page(size); - pindex = OFF_TO_IDX(foff + size); + pindex = UOFF_TO_IDX(foff) + UOFF_TO_IDX(size); + if (pindex > OBJ_MAX_SIZE || pindex < UOFF_TO_IDX(foff) || + pindex < UOFF_TO_IDX(size)) + return (NULL); if (ops->cdev_pg_ctor(handle, size, prot, foff, cred, &color) != 0) return (NULL); Modified: stable/11/sys/vm/sg_pager.c ============================================================================== --- stable/11/sys/vm/sg_pager.c Sun Mar 19 15:56:06 2017 (r315562) +++ stable/11/sys/vm/sg_pager.c Sun Mar 19 16:01:44 2017 (r315563) @@ -96,8 +96,9 @@ sg_pager_alloc(void *handle, vm_ooffset_ * to map beyond that. */ size = round_page(size); - pindex = OFF_TO_IDX(foff + size); - if (pindex > npages) + pindex = UOFF_TO_IDX(foff) + UOFF_TO_IDX(size); + if (pindex > npages || pindex < UOFF_TO_IDX(foff) || + pindex < UOFF_TO_IDX(size)) return (NULL); /* Modified: stable/11/sys/vm/vm_map.c ============================================================================== --- stable/11/sys/vm/vm_map.c Sun Mar 19 15:56:06 2017 (r315562) +++ stable/11/sys/vm/vm_map.c Sun Mar 19 16:01:44 2017 (r315563) @@ -4124,7 +4124,7 @@ RetryLookup:; * Return the object/offset from this entry. If the entry was * copy-on-write or empty, it has been fixed up. */ - *pindex = OFF_TO_IDX((vaddr - entry->start) + entry->offset); + *pindex = UOFF_TO_IDX((vaddr - entry->start) + entry->offset); *object = entry->object.vm_object; *out_prot = prot; @@ -4205,7 +4205,7 @@ vm_map_lookup_locked(vm_map_t *var_map, * Return the object/offset from this entry. If the entry was * copy-on-write or empty, it has been fixed up. */ - *pindex = OFF_TO_IDX((vaddr - entry->start) + entry->offset); + *pindex = UOFF_TO_IDX((vaddr - entry->start) + entry->offset); *object = entry->object.vm_object; *out_prot = prot; Modified: stable/11/sys/vm/vm_object.h ============================================================================== --- stable/11/sys/vm/vm_object.h Sun Mar 19 15:56:06 2017 (r315562) +++ stable/11/sys/vm/vm_object.h Sun Mar 19 16:01:44 2017 (r315563) @@ -195,8 +195,23 @@ struct vm_object { #define OBJ_DISCONNECTWNT 0x4000 /* disconnect from vnode wanted */ #define OBJ_TMPFS 0x8000 /* has tmpfs vnode allocated */ +/* + * Helpers to perform conversion between vm_object page indexes and offsets. + * IDX_TO_OFF() converts an index into an offset. + * OFF_TO_IDX() converts an offset into an index. Since offsets are signed + * by default, the sign propagation in OFF_TO_IDX(), when applied to + * negative offsets, is intentional and returns a vm_object page index + * that cannot be created by a userspace mapping. + * UOFF_TO_IDX() treats the offset as an unsigned value and converts it + * into an index accordingly. Use it only when the full range of offset + * values are allowed. Currently, this only applies to device mappings. + * OBJ_MAX_SIZE specifies the maximum page index corresponding to the + * maximum unsigned offset. + */ #define IDX_TO_OFF(idx) (((vm_ooffset_t)(idx)) << PAGE_SHIFT) #define OFF_TO_IDX(off) ((vm_pindex_t)(((vm_ooffset_t)(off)) >> PAGE_SHIFT)) +#define UOFF_TO_IDX(off) (((vm_pindex_t)(off)) >> PAGE_SHIFT) +#define OBJ_MAX_SIZE (UOFF_TO_IDX(UINT64_MAX) + 1) #ifdef _KERNEL From owner-svn-src-stable-11@freebsd.org Sun Mar 19 20:04:24 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 88FA8D13D5F; Sun, 19 Mar 2017 20:04:24 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 49C95191B; Sun, 19 Mar 2017 20:04:24 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JK4N5l005405; Sun, 19 Mar 2017 20:04:23 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JK4N9E005404; Sun, 19 Mar 2017 20:04:23 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201703192004.v2JK4N9E005404@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sun, 19 Mar 2017 20:04:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315581 - stable/11/contrib/one-true-awk X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 20:04:24 -0000 Author: pfg Date: Sun Mar 19 20:04:23 2017 New Revision: 315581 URL: https://svnweb.freebsd.org/changeset/base/315581 Log: MFC r315426, MFV r315425: one-true-awk: have calloc(3) do the multiplication. Modified: stable/11/contrib/one-true-awk/b.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/one-true-awk/b.c ============================================================================== --- stable/11/contrib/one-true-awk/b.c Sun Mar 19 19:52:47 2017 (r315580) +++ stable/11/contrib/one-true-awk/b.c Sun Mar 19 20:04:23 2017 (r315581) @@ -140,7 +140,7 @@ fa *mkdfa(const char *s, int anchor) /* f->accept = poscnt-1; /* penter has computed number of positions in re */ cfoll(f, p1); /* set up follow sets */ freetr(p1); - if ((f->posns[0] = (int *) calloc(1, *(f->re[0].lfollow)*sizeof(int))) == NULL) + if ((f->posns[0] = (int *) calloc(*(f->re[0].lfollow), sizeof(int))) == NULL) overflo("out of space in makedfa"); if ((f->posns[1] = (int *) calloc(1, sizeof(int))) == NULL) overflo("out of space in makedfa"); @@ -160,7 +160,7 @@ int makeinit(fa *f, int anchor) f->reset = 0; k = *(f->re[0].lfollow); xfree(f->posns[2]); - if ((f->posns[2] = (int *) calloc(1, (k+1)*sizeof(int))) == NULL) + if ((f->posns[2] = (int *) calloc(k+1, sizeof(int))) == NULL) overflo("out of space in makeinit"); for (i=0; i <= k; i++) { (f->posns[2])[i] = (f->re[0].lfollow)[i]; @@ -375,7 +375,7 @@ void cfoll(fa *f, Node *v) /* enter foll setvec[i] = 0; setcnt = 0; follow(v); /* computes setvec and setcnt */ - if ((p = (int *) calloc(1, (setcnt+1)*sizeof(int))) == NULL) + if ((p = (int *) calloc(setcnt+1, sizeof(int))) == NULL) overflo("out of space building follow set"); f->re[info(v)].lfollow = p; *p = setcnt; @@ -549,7 +549,7 @@ int pmatch(fa *f, const char *p0) /* lon for (i = 2; i <= f->curstat; i++) xfree(f->posns[i]); k = *f->posns[0]; - if ((f->posns[2] = (int *) calloc(1, (k+1)*sizeof(int))) == NULL) + if ((f->posns[2] = (int *) calloc(k+1, sizeof(int))) == NULL) overflo("out of space in pmatch"); for (i = 0; i <= k; i++) (f->posns[2])[i] = (f->posns[0])[i]; @@ -606,7 +606,7 @@ int nematch(fa *f, const char *p0) /* no for (i = 2; i <= f->curstat; i++) xfree(f->posns[i]); k = *f->posns[0]; - if ((f->posns[2] = (int *) calloc(1, (k+1)*sizeof(int))) == NULL) + if ((f->posns[2] = (int *) calloc(k+1, sizeof(int))) == NULL) overflo("out of state space"); for (i = 0; i <= k; i++) (f->posns[2])[i] = (f->posns[0])[i]; @@ -943,7 +943,7 @@ int cgoto(fa *f, int s, int c) for (i = 0; i < NCHARS; i++) f->gototab[f->curstat][i] = 0; xfree(f->posns[f->curstat]); - if ((p = (int *) calloc(1, (setcnt+1)*sizeof(int))) == NULL) + if ((p = (int *) calloc(setcnt+1, sizeof(int))) == NULL) overflo("out of space in cgoto"); f->posns[f->curstat] = p; From owner-svn-src-stable-11@freebsd.org Sun Mar 19 22:13:41 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DB813D1350F; Sun, 19 Mar 2017 22:13:41 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A15B61786; Sun, 19 Mar 2017 22:13:41 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JMDe7G058996; Sun, 19 Mar 2017 22:13:40 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JMDeaF058995; Sun, 19 Mar 2017 22:13:40 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703192213.v2JMDeaF058995@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sun, 19 Mar 2017 22:13:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315592 - stable/11/etc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 22:13:42 -0000 Author: ngie Date: Sun Mar 19 22:13:40 2017 New Revision: 315592 URL: https://svnweb.freebsd.org/changeset/base/315592 Log: MFC r311601: Move the mibII module up so uncommenting the bridge module works Add a note about how module ordering and dependent modules Modified: stable/11/etc/snmpd.config Directory Properties: stable/11/ (props changed) Modified: stable/11/etc/snmpd.config ============================================================================== --- stable/11/etc/snmpd.config Sun Mar 19 21:53:12 2017 (r315591) +++ stable/11/etc/snmpd.config Sun Mar 19 22:13:40 2017 (r315592) @@ -122,6 +122,14 @@ snmpEnableAuthenTraps = 2 # order to use the enclosed variables, e.g. `usmUserStatus.$(engine).$(user1)` # can only be used if %usm is uncommented. # +# Modules are loaded in the order listed, so they must be before any +# dependent modules, e.g. "mibII" vs "bridge". +# + +# +# MIB-2 module +# +begemotSnmpdModulePath."mibII" = "/usr/lib/snmp_mibII.so" # # Bridge module @@ -141,11 +149,6 @@ snmpEnableAuthenTraps = 2 #begemotSnmpdModulePath."lm75" = "/usr/lib/snmp_lm75.so" # -# MIB-2 module -# -begemotSnmpdModulePath."mibII" = "/usr/lib/snmp_mibII.so" - -# # Netgraph module # #begemotSnmpdModulePath."netgraph" = "/usr/lib/snmp_netgraph.so" From owner-svn-src-stable-11@freebsd.org Mon Mar 20 00:54:47 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0BB05D149AC; Mon, 20 Mar 2017 00:54:47 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CF1E067E; Mon, 20 Mar 2017 00:54:46 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2K0sjak025212; Mon, 20 Mar 2017 00:54:45 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2K0sj1a025205; Mon, 20 Mar 2017 00:54:45 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201703200054.v2K0sj1a025205@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Mon, 20 Mar 2017 00:54:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315599 - in stable/11: usr.bin/mkimg usr.sbin/mpsutil usr.sbin/nscd usr.sbin/ypbind X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Mar 2017 00:54:47 -0000 Author: pfg Date: Mon Mar 20 00:54:45 2017 New Revision: 315599 URL: https://svnweb.freebsd.org/changeset/base/315599 Log: MFC r315212, r315213, r315214, r315215: mkimg(1): let calloc(3) do the multiplication. nscd(8): let calloc(3) do the multiplying. mpsutil(8): let calloc(3) do the multiplying. ypbind(8): let calloc(3) do the multiplying. MFC after: 1 week Modified: stable/11/usr.bin/mkimg/qcow.c stable/11/usr.sbin/mpsutil/mps_cmd.c stable/11/usr.sbin/nscd/cachelib.c stable/11/usr.sbin/nscd/config.c stable/11/usr.sbin/nscd/hashtable.h stable/11/usr.sbin/nscd/nscd.c stable/11/usr.sbin/ypbind/yp_ping.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/mkimg/qcow.c ============================================================================== --- stable/11/usr.bin/mkimg/qcow.c Sun Mar 19 23:27:17 2017 (r315598) +++ stable/11/usr.bin/mkimg/qcow.c Mon Mar 20 00:54:45 2017 (r315599) @@ -217,7 +217,7 @@ qcow_write(int fd, u_int version) ofs = clstrsz * l2clno; nclstrs = 1 + clstr_l1tblsz + clstr_rctblsz; - l1tbl = calloc(1, clstrsz * clstr_l1tblsz); + l1tbl = calloc(clstr_l1tblsz, clstrsz); if (l1tbl == NULL) { error = ENOMEM; goto out; @@ -248,7 +248,7 @@ qcow_write(int fd, u_int version) } while (n < clstr_rcblks); if (rcclno > 0) { - rctbl = calloc(1, clstrsz * clstr_rctblsz); + rctbl = calloc(clstr_rctblsz, clstrsz); if (rctbl == NULL) { error = ENOMEM; goto out; @@ -298,7 +298,7 @@ qcow_write(int fd, u_int version) l1tbl = NULL; if (rcclno > 0) { - rcblk = calloc(1, clstrsz * clstr_rcblks); + rcblk = calloc(clstr_rcblks, clstrsz); if (rcblk == NULL) { error = ENOMEM; goto out; Modified: stable/11/usr.sbin/mpsutil/mps_cmd.c ============================================================================== --- stable/11/usr.sbin/mpsutil/mps_cmd.c Sun Mar 19 23:27:17 2017 (r315598) +++ stable/11/usr.sbin/mpsutil/mps_cmd.c Mon Mar 20 00:54:45 2017 (r315599) @@ -486,7 +486,7 @@ mps_firmware_get(int fd, unsigned char * } size = reply.ActualImageSize; - *firmware = calloc(1, sizeof(unsigned char) * size); + *firmware = calloc(size, sizeof(unsigned char)); if (*firmware == NULL) { warn("calloc"); return (-1); Modified: stable/11/usr.sbin/nscd/cachelib.c ============================================================================== --- stable/11/usr.sbin/nscd/cachelib.c Sun Mar 19 23:27:17 2017 (r315598) +++ stable/11/usr.sbin/nscd/cachelib.c Mon Mar 20 00:54:45 2017 (r315599) @@ -487,8 +487,8 @@ init_cache(struct cache_params const *pa assert(params != NULL); memcpy(&retval->params, params, sizeof(struct cache_params)); - retval->entries = calloc(1, - sizeof(*retval->entries) * INITIAL_ENTRIES_CAPACITY); + retval->entries = calloc(INITIAL_ENTRIES_CAPACITY, + sizeof(*retval->entries)); assert(retval->entries != NULL); retval->entries_capacity = INITIAL_ENTRIES_CAPACITY; @@ -540,8 +540,8 @@ register_cache_entry(struct cache_ *the_ new_capacity = the_cache->entries_capacity + ENTRIES_CAPACITY_STEP; - new_entries = calloc(1, - sizeof(*new_entries) * new_capacity); + new_entries = calloc(new_capacity, + sizeof(*new_entries)); assert(new_entries != NULL); memcpy(new_entries, the_cache->entries, @@ -582,8 +582,8 @@ register_cache_entry(struct cache_ *the_ else policies_size = 2; - new_common_entry->policies = calloc(1, - sizeof(*new_common_entry->policies) * policies_size); + new_common_entry->policies = calloc(policies_size, + sizeof(*new_common_entry->policies)); assert(new_common_entry->policies != NULL); new_common_entry->policies_size = policies_size; Modified: stable/11/usr.sbin/nscd/config.c ============================================================================== --- stable/11/usr.sbin/nscd/config.c Sun Mar 19 23:27:17 2017 (r315598) +++ stable/11/usr.sbin/nscd/config.c Mon Mar 20 00:54:45 2017 (r315599) @@ -274,9 +274,8 @@ add_configuration_entry(struct configura struct configuration_entry **new_entries; config->entries_capacity *= 2; - new_entries = calloc(1, - sizeof(*new_entries) * - config->entries_capacity); + new_entries = calloc(config->entries_capacity, + sizeof(*new_entries)); assert(new_entries != NULL); memcpy(new_entries, config->entries, sizeof(struct configuration_entry *) * @@ -522,9 +521,8 @@ init_configuration(void) assert(retval != NULL); retval->entries_capacity = INITIAL_ENTRIES_CAPACITY; - retval->entries = calloc(1, - sizeof(*retval->entries) * - retval->entries_capacity); + retval->entries = calloc(retval->entries_capacity, + sizeof(*retval->entries)); assert(retval->entries != NULL); pthread_rwlock_init(&retval->rwlock, NULL); Modified: stable/11/usr.sbin/nscd/hashtable.h ============================================================================== --- stable/11/usr.sbin/nscd/hashtable.h Sun Mar 19 23:27:17 2017 (r315598) +++ stable/11/usr.sbin/nscd/hashtable.h Mon Mar 20 00:54:45 2017 (r315599) @@ -75,8 +75,8 @@ typedef unsigned int hashtable_index_t; #define HASHTABLE_INIT(table, type, field, _entries_size) \ do { \ hashtable_index_t var; \ - (table)->entries = calloc(1, \ - sizeof(*(table)->entries) * (_entries_size)); \ + (table)->entries = calloc(_entries_size, \ + sizeof(*(table)->entries)); \ (table)->entries_size = (_entries_size); \ for (var = 0; var < HASHTABLE_ENTRIES_COUNT(table); ++var) {\ (table)->entries[var].field.capacity = \ Modified: stable/11/usr.sbin/nscd/nscd.c ============================================================================== --- stable/11/usr.sbin/nscd/nscd.c Sun Mar 19 23:27:17 2017 (r315598) +++ stable/11/usr.sbin/nscd/nscd.c Mon Mar 20 00:54:45 2017 (r315599) @@ -828,8 +828,8 @@ main(int argc, char *argv[]) } if (s_configuration->threads_num > 1) { - threads = calloc(1, sizeof(*threads) * - s_configuration->threads_num); + threads = calloc(s_configuration->threads_num, + sizeof(*threads)); for (i = 0; i < s_configuration->threads_num; ++i) { thread_args = malloc( sizeof(*thread_args)); Modified: stable/11/usr.sbin/ypbind/yp_ping.c ============================================================================== --- stable/11/usr.sbin/ypbind/yp_ping.c Sun Mar 19 23:27:17 2017 (r315598) +++ stable/11/usr.sbin/ypbind/yp_ping.c Mon Mar 20 00:54:45 2017 (r315599) @@ -226,7 +226,7 @@ __yp_ping(struct in_addr *restricted_add int validsrvs = 0; /* Set up handles. */ - reqs = calloc(1, sizeof(struct ping_req *) * cnt); + reqs = calloc(cnt, sizeof(struct ping_req *)); xid_seed = time(NULL) ^ getpid(); for (i = 0; i < cnt; i++) { From owner-svn-src-stable-11@freebsd.org Mon Mar 20 01:53:51 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6F0D1D13454; Mon, 20 Mar 2017 01:53:51 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2E7F81D5A; Mon, 20 Mar 2017 01:53:51 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2K1rou2049509; Mon, 20 Mar 2017 01:53:50 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2K1ro7L049508; Mon, 20 Mar 2017 01:53:50 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201703200153.v2K1ro7L049508@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Mon, 20 Mar 2017 01:53:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315602 - stable/11/sys/sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Mar 2017 01:53:51 -0000 Author: pfg Date: Mon Mar 20 01:53:50 2017 New Revision: 315602 URL: https://svnweb.freebsd.org/changeset/base/315602 Log: MFC r312942: Remove GCC's __nonnull() attribute definition. While GCC's __nonnull__ attribute is generally useful to prevent misuse of some functions it also tends to do rather dangerous "optimizations". Now that we have replaced all such uses with the clang nullability qualifiers, the GCC attribute is unnecessary. Remove the definition completely to prevent its use in system's headers. Modified: stable/11/sys/sys/cdefs.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/sys/cdefs.h ============================================================================== --- stable/11/sys/sys/cdefs.h Mon Mar 20 01:19:04 2017 (r315601) +++ stable/11/sys/sys/cdefs.h Mon Mar 20 01:53:50 2017 (r315602) @@ -376,14 +376,6 @@ #define __noinline #endif -#if __GNUC_PREREQ__(3, 3) -#define __nonnull(x) __attribute__((__nonnull__(x))) -#define __nonnull_all __attribute__((__nonnull__)) -#else -#define __nonnull(x) -#define __nonnull_all -#endif - #if __GNUC_PREREQ__(3, 4) #define __fastcall __attribute__((__fastcall__)) #define __result_use_check __attribute__((__warn_unused_result__)) From owner-svn-src-stable-11@freebsd.org Mon Mar 20 02:58:07 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 66801D14497; Mon, 20 Mar 2017 02:58:07 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 24B211B33; Mon, 20 Mar 2017 02:58:07 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2K2w6Dh074193; Mon, 20 Mar 2017 02:58:06 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2K2w6WL074192; Mon, 20 Mar 2017 02:58:06 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703200258.v2K2w6WL074192@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 20 Mar 2017 02:58:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315604 - stable/11/usr.bin/xinstall/tests X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Mar 2017 02:58:07 -0000 Author: ngie Date: Mon Mar 20 02:58:05 2017 New Revision: 315604 URL: https://svnweb.freebsd.org/changeset/base/315604 Log: MFC r315098,r315106,r315108: r315098: Clarify src vs dest path mismatch in :symbolic_link_{absolute,relative}_body Unfortunately kyua does not omit the path mismatch on failure, so it must be coded into the error message. Cache the values, run the test(1) call, then print out the values in an atf_fail call to emit the required diagnostics to debug why things are failing. r315106: Add 3 more testcases demonstrating how install -l sr works The additional testcases use absolute paths for sources and targets, as the other testcase which tested `-l sr` used flat relative paths in the same directory. Please note that these testcases do not test `-l a` -- that's already addressed in the battery of tests. r315108: Restore some of the error message text accidentally removed in r315098 "unexpected symlink contents" is more pedantically correct than "unexpected symlink". Modified: stable/11/usr.bin/xinstall/tests/install_test.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/xinstall/tests/install_test.sh ============================================================================== --- stable/11/usr.bin/xinstall/tests/install_test.sh Mon Mar 20 02:47:28 2017 (r315603) +++ stable/11/usr.bin/xinstall/tests/install_test.sh Mon Mar 20 02:58:05 2017 (r315604) @@ -283,7 +283,11 @@ symbolic_link_absolute_body() { atf_check install -l sa testf copyf [ testf -ef copyf ] || atf_fail "not same file" [ -L copyf ] || atf_fail "copy is not symlink" - [ "$(readlink copyf)" = "$(pwd -P)/testf" ] || atf_fail "unexpected symlink contents" + copyf_path=$(readlink copyf) + testf_path="$(pwd -P)/testf" + if [ "$copyf_path" != "$testf_path" ]; then + atf_fail "unexpected symlink contents ('$copyf_path' != '$testf_path')" + fi } atf_test_case symbolic_link_relative @@ -292,7 +296,74 @@ symbolic_link_relative_body() { atf_check install -l sr testf copyf [ testf -ef copyf ] || atf_fail "not same file" [ -L copyf ] || atf_fail "copy is not symlink" - [ "$(readlink copyf)" = "testf" ] || atf_fail "unexpected symlink contents" + copyf_path=$(readlink copyf) + testf_path="testf" + if [ "$copyf_path" != "$testf_path" ]; then + atf_fail "unexpected symlink contents ('$copyf_path' != '$testf_path')" + fi +} + +atf_test_case symbolic_link_relative_absolute_source_and_dest1 +symbolic_link_relative_absolute_source_and_dest1_head() { + atf_set "descr" "Verify -l rs with absolute paths (.../copyf -> .../a/b/c/testf)" +} +symbolic_link_relative_absolute_source_and_dest1_body() { + src_path=a/b/c/testf + src_path_prefixed=$PWD/$src_path + dest_path=$PWD/copyf + + atf_check mkdir -p a/b/c + atf_check touch $src_path + atf_check install -l sr $src_path_prefixed $dest_path + [ $src_path_prefixed -ef $dest_path ] || atf_fail "not same file" + [ -L $dest_path ] || atf_fail "copy is not symlink" + dest_path_relative=$(readlink $dest_path) + src_path_relative="$src_path" + if [ "$src_path_relative" != "$dest_path_relative" ]; then + atf_fail "unexpected symlink contents ('$src_path_relative' != '$dest_path_relative')" + fi +} + +atf_test_case symbolic_link_relative_absolute_source_and_dest1_double_slash +symbolic_link_relative_absolute_source_and_dest1_double_slash_head() { + atf_set "descr" "Verify -l rs with absolute paths (.../copyf -> .../a/b/c/testf), using double-slashes" +} +symbolic_link_relative_absolute_source_and_dest1_double_slash_body() { + src_path=a//b//c//testf + src_path_prefixed=$PWD/$src_path + dest_path=$PWD/copyf + + atf_check mkdir -p a/b/c + atf_check touch $src_path + atf_check install -l sr $src_path_prefixed $dest_path + [ $src_path_prefixed -ef $dest_path ] || atf_fail "not same file" + [ -L $dest_path ] || atf_fail "copy is not symlink" + dest_path_relative=$(readlink $dest_path) + src_path_relative="$(echo $src_path | sed -e 's,//,/,g')" + if [ "$src_path_relative" != "$dest_path_relative" ]; then + atf_fail "unexpected symlink contents ('$src_path_relative' != '$dest_path_relative')" + fi +} + +atf_test_case symbolic_link_relative_absolute_source_and_dest2 +symbolic_link_relative_absolute_source_and_dest2_head() { + atf_set "descr" "Verify -l rs with absolute paths (.../a/b/c/copyf -> .../testf)" +} +symbolic_link_relative_absolute_source_and_dest2_body() { + src_path=testf + src_path_prefixed=$PWD/$src_path + dest_path=$PWD/a/b/c/copyf + + atf_check mkdir -p a/b/c + atf_check touch $src_path + atf_check install -l sr $src_path_prefixed $dest_path + [ $src_path_prefixed -ef $dest_path ] || atf_fail "not same file" + [ -L $dest_path ] || atf_fail "copy is not symlink" + dest_path_relative=$(readlink $dest_path) + src_path_relative="../../../$src_path" + if [ "$src_path_relative" != "$dest_path_relative" ]; then + atf_fail "unexpected symlink contents ('$src_path_relative' != '$dest_path_relative')" + fi } atf_test_case mkdir_simple @@ -341,5 +412,8 @@ atf_init_test_cases() { atf_add_test_case symbolic_link atf_add_test_case symbolic_link_absolute atf_add_test_case symbolic_link_relative + atf_add_test_case symbolic_link_relative_absolute_source_and_dest1 + atf_add_test_case symbolic_link_relative_absolute_source_and_dest1_double_slash + atf_add_test_case symbolic_link_relative_absolute_source_and_dest2 atf_add_test_case mkdir_simple } From owner-svn-src-stable-11@freebsd.org Mon Mar 20 03:00:21 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 24B1DD14536; Mon, 20 Mar 2017 03:00:21 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F0D5C1CA8; Mon, 20 Mar 2017 03:00:20 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2K30KYk074443; Mon, 20 Mar 2017 03:00:20 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2K30KaU074442; Mon, 20 Mar 2017 03:00:20 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703200300.v2K30KaU074442@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 20 Mar 2017 03:00:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315605 - stable/11/lib/libcam X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Mar 2017 03:00:21 -0000 Author: ngie Date: Mon Mar 20 03:00:19 2017 New Revision: 315605 URL: https://svnweb.freebsd.org/changeset/base/315605 Log: MFC r315132,r315133,r315186: r315132: Use .Dv when referencing NULL This is the correct markup macro, as opposed to .Va (variable names) While here, annotate several bare references to `NULL` with .Dv. r315133: lib/libcam/cam.3: fix manpage warnings - spelling: "mis-named" should be "misnamed". - delete spaces interspersed in literal representation of `struct cam_device` as hard-tabs separate the types and fields. - Add commas after `e.g.`. r315186: lib/libcam/cam.3: note that cam_freeccb(3) with ccb == NULL is a no-op This allows me to accurately test this scenario, and for others to rely on the behavior, instead of relying on knowledge obtained via code inspection. Wording borrowed from free(3). Requested by: ken (D9928) Modified: stable/11/lib/libcam/cam.3 Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libcam/cam.3 ============================================================================== --- stable/11/lib/libcam/cam.3 Mon Mar 20 02:58:05 2017 (r315604) +++ stable/11/lib/libcam/cam.3 Mon Mar 20 03:00:19 2017 (r315605) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 10, 1998 +.Dd March 11, 2017 .Dt CAM 3 .Os .Sh NAME @@ -132,7 +132,7 @@ Many of the CAM library functions use th structure: .Bd -literal struct cam_device { - char device_path[MAXPATHLEN+1];/* + char device_path[MAXPATHLEN+1];/* * Pathname of the * device given by the * user. This may be @@ -151,7 +151,7 @@ struct cam_device { */ char device_name[DEV_IDLEN+1];/* * Name of the device, - * e.g. 'pass' + * e.g., 'pass' */ uint32_t dev_unit_num; /* Unit number of the passthrough * device associated with this @@ -159,7 +159,7 @@ struct cam_device { */ char sim_name[SIM_IDLEN+1];/* - * Controller name, e.g.'ahc' + * Controller name, e.g., 'ahc' */ uint32_t sim_unit_number; /* Controller unit number */ uint32_t bus_id; /* Controller bus number */ @@ -208,7 +208,7 @@ structure. If the .Ar device argument is -.Va NULL , +.Dv NULL , .Fn cam_open_spec_device will allocate space for the .Va cam_device @@ -258,7 +258,9 @@ argument, as with .Fn cam_open_spec_device and .Fn cam_open_btl , -should be NULL if the user wants the CAM library to allocate space for the +should be +.Dv NULL +if the user wants the CAM library to allocate space for the .Va cam_device structure. .Fn cam_close_device @@ -300,6 +302,11 @@ structure. .Fn cam_freeccb frees CCBs allocated by .Fn cam_getccb . +If +.Va ccb +is +.Dv NULL , +no action is taken. .Pp .Fn cam_path_string takes as arguments a @@ -365,11 +372,14 @@ and .Fn cam_open_pass return a pointer to a .Va cam_device -structure, or NULL if there was an error. +structure, or +.Dv NULL +if there was an error. .Pp .Fn cam_getccb -returns an allocated and partially initialized CCB, or NULL if allocation -of the CCB failed. +returns an allocated and partially initialized CCB, or +.Dv NULL +if allocation of the CCB failed. .Pp .Fn cam_send_ccb returns a value of -1 if an error occurred, and @@ -386,7 +396,9 @@ that is passed into .Fn cam_device_dup returns a copy of the .Va device -passed in, or NULL if an error occurred. +passed in, or +.Dv NULL +if an error occurred. .Pp .Fn cam_get_device returns 0 for success, and -1 to indicate failure. @@ -422,4 +434,4 @@ require a definitive way to identify a d .Xr pass 4 device. .Pp -Some of the functions are possibly mis-named or poorly named. +Some of the functions are possibly misnamed or poorly named. From owner-svn-src-stable-11@freebsd.org Mon Mar 20 03:01:22 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 69BA1D14718; Mon, 20 Mar 2017 03:01:22 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 29529F4; Mon, 20 Mar 2017 03:01:22 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2K31LDx076077; Mon, 20 Mar 2017 03:01:21 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2K31L17076076; Mon, 20 Mar 2017 03:01:21 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703200301.v2K31L17076076@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 20 Mar 2017 03:01:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315607 - stable/11/lib/libcam X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Mar 2017 03:01:22 -0000 Author: ngie Date: Mon Mar 20 03:01:21 2017 New Revision: 315607 URL: https://svnweb.freebsd.org/changeset/base/315607 Log: MFC r315202: lib/libcam/cam_cdbparse.3: fix manpage warnings - Add comma before and after 'e.g.'; remove surrounding parentheses that were unnecessary after this change [1]. - Add .Mt when referencing ken and Peter Dufault's email addresses [2]. - Sprinkle around .An use where proper [2]. Bump .Dd for the change Modified: stable/11/lib/libcam/cam_cdbparse.3 Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libcam/cam_cdbparse.3 ============================================================================== --- stable/11/lib/libcam/cam_cdbparse.3 Mon Mar 20 03:00:22 2017 (r315606) +++ stable/11/lib/libcam/cam_cdbparse.3 Mon Mar 20 03:01:21 2017 (r315607) @@ -61,7 +61,7 @@ .\" SUCH DAMAGE. .\" .\" -.Dd October 13, 1998 +.Dd March 13, 2017 .Dt CAM_CDBPARSE 3 .Os .Sh NAME @@ -170,12 +170,11 @@ layer. These functions may be used in new applications, but users may find it easier to use the various SCSI CCB building functions included with the .Xr cam 3 -library. -(e.g.\& +library, e.g., \& .Fn cam_fill_csio , .Fn scsi_start_stop , and -.Fn scsi_read_write ) +.Fn scsi_read_write . .Pp .Fn csio_build builds up a @@ -522,17 +521,18 @@ implemented for the old layer. The encoding/decoding functions in the old .Tn SCSI -code were written by Peter Dufault. +code were written by +.An Peter Dufault Aq Mt dufault@hda.com . .Pp Many systems have comparable interfaces to permit a user to construct a SCSI command in user space. .Pp The old .Va scsireq -data structure was almost identical to the SGI /dev/scsi data -structure. -If anyone knows the name of the authors it should -go here; Peter Dufault first read about it in a 1989 Sun Expert magazine. +data structure was almost identical to the SGI /dev/scsi data structure. +If anyone knows the name of the authors it should go here; +Peter Dufault +first read about it in a 1989 Sun Expert magazine. .Pp The new CCB data structures are derived from the CAM-2 and CAM-3 specifications. @@ -545,11 +545,14 @@ led to the original .Fx .Tn SCSI library and the related kernel ioctl. -If anyone needs that for compatibility contact dufault@hda.com. +If anyone needs that for compatibility, contact +.Mt dufault@hda.com . .Sh AUTHORS -Kenneth Merry implemented the CAM versions of these encoding and decoding -functions. -This current work is based upon earlier work by Peter Dufault. +.An -nosplit +.An Kenneth Merry Aq Mt ken@FreeBSD.org +implemented the CAM versions of these encoding and decoding functions. +This current work is based upon earlier work by +.An Peter Dufault Aq Mt dufault@hda.com . .Sh BUGS There should probably be a function that encodes both the CDB and the data buffer portions of a From owner-svn-src-stable-11@freebsd.org Mon Mar 20 03:06:39 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 69557D14918; Mon, 20 Mar 2017 03:06:39 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 28AC6AD2; Mon, 20 Mar 2017 03:06:39 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2K36cjC079357; Mon, 20 Mar 2017 03:06:38 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2K36cYQ079355; Mon, 20 Mar 2017 03:06:38 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703200306.v2K36cYQ079355@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 20 Mar 2017 03:06:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315609 - in stable/11/sbin/dhclient: . tests X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Mar 2017 03:06:39 -0000 Author: ngie Date: Mon Mar 20 03:06:37 2017 New Revision: 315609 URL: https://svnweb.freebsd.org/changeset/base/315609 Log: MFC r315199,r315200,r315203: r315199: sbin/dhclient: fix a memory leak in parse_client_lease_statement(..) The memory stored by `lease` would have previously been leaked if an unterminated lease declaration was found in an early-return code path. CID: 1007114 r315200: Fix -Wunused-but-set-warning with `ret` While here, resolve Coverity warnings by demonstrating that vfprintf's return value is being explicitly ignored. Tested with: clang, gcc 4.2.1, gcc 6.3.0 r315203: sbin/dhclient: fix `vendor` storage leak in parse_option_decl(..) This ensures the storage isn't leaked when non-NULL and the function returns early, prior to the `free(vendor)` later on in the function. CID: 1007111-1007113 Modified: stable/11/sbin/dhclient/clparse.c stable/11/sbin/dhclient/tests/fake.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/dhclient/clparse.c ============================================================================== --- stable/11/sbin/dhclient/clparse.c Mon Mar 20 03:01:23 2017 (r315608) +++ stable/11/sbin/dhclient/clparse.c Mon Mar 20 03:06:37 2017 (r315609) @@ -510,6 +510,7 @@ parse_client_lease_statement(FILE *cfile token = peek_token(&val, cfile); if (token == EOF) { parse_warn("unterminated lease declaration."); + free_client_lease(lease); return; } if (token == RBRACE) @@ -711,6 +712,7 @@ parse_option_decl(FILE *cfile, struct op parse_warn("expecting identifier after '.'"); if (token != SEMI) skip_to_semi(cfile); + free(vendor); return (NULL); } @@ -723,6 +725,7 @@ parse_option_decl(FILE *cfile, struct op if (!universe) { parse_warn("no vendor named %s.", vendor); skip_to_semi(cfile); + free(vendor); return (NULL); } } else { @@ -744,6 +747,7 @@ parse_option_decl(FILE *cfile, struct op parse_warn("no option named %s for vendor %s", val, vendor); skip_to_semi(cfile); + free(vendor); return (NULL); } Modified: stable/11/sbin/dhclient/tests/fake.c ============================================================================== --- stable/11/sbin/dhclient/tests/fake.c Mon Mar 20 03:01:23 2017 (r315608) +++ stable/11/sbin/dhclient/tests/fake.c Mon Mar 20 03:06:37 2017 (r315609) @@ -14,7 +14,7 @@ error(char *fmt, ...) va_list ap; va_start(ap, fmt); - vfprintf(stderr, fmt, ap); + (void)vfprintf(stderr, fmt, ap); va_end(ap); fprintf(stderr, "\n"); @@ -24,11 +24,10 @@ error(char *fmt, ...) int warning(char *fmt, ...) { - int ret; va_list ap; va_start(ap, fmt); - ret = vfprintf(stderr, fmt, ap); + (void)vfprintf(stderr, fmt, ap); va_end(ap); fprintf(stderr, "\n"); From owner-svn-src-stable-11@freebsd.org Mon Mar 20 03:13:02 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4BD8BD14B31; Mon, 20 Mar 2017 03:13:02 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0DB071088; Mon, 20 Mar 2017 03:13:01 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2K3D1Lw083440; Mon, 20 Mar 2017 03:13:01 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2K3D1Dg083439; Mon, 20 Mar 2017 03:13:01 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703200313.v2K3D1Dg083439@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 20 Mar 2017 03:13:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315611 - stable/11/contrib/bsnmp/snmpd X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Mar 2017 03:13:02 -0000 Author: ngie Date: Mon Mar 20 03:13:00 2017 New Revision: 315611 URL: https://svnweb.freebsd.org/changeset/base/315611 Log: MFC r315206: bsnmpd: fix segfault when trans_insert_port(..) is called with multiple out of order addresses Move `port->transport` initialization before the TAILQ_FOREACH(..) loop to ensure that the value is properly initialized before it's inserted into the TAILQ. PR: 217760 Modified: stable/11/contrib/bsnmp/snmpd/main.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/bsnmp/snmpd/main.c ============================================================================== --- stable/11/contrib/bsnmp/snmpd/main.c Mon Mar 20 03:06:41 2017 (r315610) +++ stable/11/contrib/bsnmp/snmpd/main.c Mon Mar 20 03:13:00 2017 (r315611) @@ -765,13 +765,13 @@ trans_insert_port(struct transport *t, s { struct tport *p; + port->transport = t; TAILQ_FOREACH(p, &t->table, link) { if (asn_compare_oid(&p->index, &port->index) > 0) { TAILQ_INSERT_BEFORE(p, port, link); return; } } - port->transport = t; TAILQ_INSERT_TAIL(&t->table, port, link); } From owner-svn-src-stable-11@freebsd.org Mon Mar 20 08:11:00 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 09DA0D146B2; Mon, 20 Mar 2017 08:11:00 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CAA2B18B2; Mon, 20 Mar 2017 08:10:59 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2K8AwLd000755; Mon, 20 Mar 2017 08:10:58 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2K8AwYe000754; Mon, 20 Mar 2017 08:10:58 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201703200810.v2K8AwYe000754@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 20 Mar 2017 08:10:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315624 - stable/11/sys/net X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Mar 2017 08:11:00 -0000 Author: ae Date: Mon Mar 20 08:10:58 2017 New Revision: 315624 URL: https://svnweb.freebsd.org/changeset/base/315624 Log: MFC r315192: Ignore ifnet renaming in the bpf ifnet departure handler. PR: 213015 Modified: stable/11/sys/net/bpf.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/net/bpf.c ============================================================================== --- stable/11/sys/net/bpf.c Mon Mar 20 08:10:35 2017 (r315623) +++ stable/11/sys/net/bpf.c Mon Mar 20 08:10:58 2017 (r315624) @@ -2678,6 +2678,10 @@ bpf_ifdetach(void *arg __unused, struct struct bpf_if *bp, *bp_temp; int nmatched = 0; + /* Ignore ifnet renaming. */ + if (ifp->if_flags & IFF_RENAMING) + return; + BPF_LOCK(); /* * Find matching entries in free list. From owner-svn-src-stable-11@freebsd.org Tue Mar 21 01:23:35 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CB744D14AEC; Tue, 21 Mar 2017 01:23:35 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8C5A76E5; Tue, 21 Mar 2017 01:23:35 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2L1NYPL028324; Tue, 21 Mar 2017 01:23:34 GMT (envelope-from vangyzen@FreeBSD.org) Received: (from vangyzen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2L1NYWT028321; Tue, 21 Mar 2017 01:23:34 GMT (envelope-from vangyzen@FreeBSD.org) Message-Id: <201703210123.v2L1NYWT028321@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vangyzen set sender to vangyzen@FreeBSD.org using -f From: Eric van Gyzen Date: Tue, 21 Mar 2017 01:23:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315657 - in stable/11/sys: compat/freebsd32 compat/linux kern X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Mar 2017 01:23:35 -0000 Author: vangyzen Date: Tue Mar 21 01:23:34 2017 New Revision: 315657 URL: https://svnweb.freebsd.org/changeset/base/315657 Log: MFC r315510 nanosleep: plug a kernel memory disclosure nanosleep() updates rmtp on EINVAL. In that case, kern_nanosleep() has not updated rmt, so sys_nanosleep() updates the user-space rmtp by copying garbage from its stack frame. This is not only a kernel memory disclosure, it's also not POSIX-compliant. Fix it to update rmtp only on EINTR. Security: possibly Sponsored by: Dell EMC Modified: stable/11/sys/compat/freebsd32/freebsd32_misc.c stable/11/sys/compat/linux/linux_time.c stable/11/sys/kern/kern_time.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- stable/11/sys/compat/freebsd32/freebsd32_misc.c Mon Mar 20 23:07:34 2017 (r315656) +++ stable/11/sys/compat/freebsd32/freebsd32_misc.c Tue Mar 21 01:23:34 2017 (r315657) @@ -2241,7 +2241,7 @@ freebsd32_nanosleep(struct thread *td, s !useracc((caddr_t)uap->rmtp, sizeof(rmt), VM_PROT_WRITE)) return (EFAULT); error = kern_nanosleep(td, &rqt, &rmt); - if (error && uap->rmtp) { + if (error == EINTR && uap->rmtp) { int error2; CP(rmt, rmt32, tv_sec); Modified: stable/11/sys/compat/linux/linux_time.c ============================================================================== --- stable/11/sys/compat/linux/linux_time.c Mon Mar 20 23:07:34 2017 (r315656) +++ stable/11/sys/compat/linux/linux_time.c Tue Mar 21 01:23:34 2017 (r315657) @@ -489,7 +489,7 @@ linux_nanosleep(struct thread *td, struc return (error); } error = kern_nanosleep(td, &rqts, rmtp); - if (args->rmtp != NULL) { + if (error == EINTR && args->rmtp != NULL) { native_to_linux_timespec(&lrmts, rmtp); error2 = copyout(&lrmts, args->rmtp, sizeof(lrmts)); if (error2 != 0) { @@ -551,7 +551,7 @@ linux_clock_nanosleep(struct thread *td, return (error); } error = kern_nanosleep(td, &rqts, rmtp); - if (args->rmtp != NULL) { + if (error == EINTR && args->rmtp != NULL) { /* XXX. Not for TIMER_ABSTIME */ native_to_linux_timespec(&lrmts, rmtp); error2 = copyout(&lrmts, args->rmtp, sizeof(lrmts)); Modified: stable/11/sys/kern/kern_time.c ============================================================================== --- stable/11/sys/kern/kern_time.c Mon Mar 20 23:07:34 2017 (r315656) +++ stable/11/sys/kern/kern_time.c Tue Mar 21 01:23:34 2017 (r315657) @@ -541,7 +541,7 @@ sys_nanosleep(struct thread *td, struct !useracc((caddr_t)uap->rmtp, sizeof(rmt), VM_PROT_WRITE)) return (EFAULT); error = kern_nanosleep(td, &rqt, &rmt); - if (error && uap->rmtp) { + if (error == EINTR && uap->rmtp) { int error2; error2 = copyout(&rmt, uap->rmtp, sizeof(rmt)); From owner-svn-src-stable-11@freebsd.org Tue Mar 21 03:42:30 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 31735D15564; Tue, 21 Mar 2017 03:42:30 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E46A799C; Tue, 21 Mar 2017 03:42:29 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2L3gSJm086307; Tue, 21 Mar 2017 03:42:28 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2L3gS23086306; Tue, 21 Mar 2017 03:42:28 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201703210342.v2L3gS23086306@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Tue, 21 Mar 2017 03:42:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315659 - stable/11/usr.sbin/lpr/common_source X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Mar 2017 03:42:30 -0000 Author: pfg Date: Tue Mar 21 03:42:28 2017 New Revision: 315659 URL: https://svnweb.freebsd.org/changeset/base/315659 Log: MFC r314877: lpr(1): small bounds check with reallocarray(3). While here plug a memory leak upon error and postpose the multiplication until after reallocation has succeded. Hinted partially by: OpenBSD Reviewed by: gad Modified: stable/11/usr.sbin/lpr/common_source/common.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/lpr/common_source/common.c ============================================================================== --- stable/11/usr.sbin/lpr/common_source/common.c Tue Mar 21 01:24:56 2017 (r315658) +++ stable/11/usr.sbin/lpr/common_source/common.c Tue Mar 21 03:42:28 2017 (r315659) @@ -167,11 +167,13 @@ getq(const struct printer *pp, struct jo * realloc the maximum size. */ if (++nitems > arraysz) { - arraysz *= 2; - queue = (struct jobqueue **)realloc((char *)queue, - arraysz * sizeof(struct jobqueue *)); - if (queue == NULL) + queue = (struct jobqueue **)reallocarray((char *)queue, + arraysz, 2 * sizeof(struct jobqueue *)); + if (queue == NULL) { + free(q); goto errdone; + } + arraysz *= 2; } queue[nitems-1] = q; } From owner-svn-src-stable-11@freebsd.org Tue Mar 21 05:13:16 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3FFFDD15B99; Tue, 21 Mar 2017 05:13:16 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 09E84120; Tue, 21 Mar 2017 05:13:15 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2L5DFBT023004; Tue, 21 Mar 2017 05:13:15 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2L5DFes023003; Tue, 21 Mar 2017 05:13:15 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703210513.v2L5DFes023003@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Tue, 21 Mar 2017 05:13:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315660 - stable/11/tools/build/mk X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Mar 2017 05:13:16 -0000 Author: ngie Date: Tue Mar 21 05:13:14 2017 New Revision: 315660 URL: https://svnweb.freebsd.org/changeset/base/315660 Log: MFC r314241,r315228: r314241: Fill in MK_RESCUE by finding paths in ${DESTDIR}/rescue and adding them to OLD_FILES/OLD_DIRS, as necessary. r315228: Redirect standard error from find /rescue to /dev/null This mutes noise from find when /rescue doesn't exist. Modified: stable/11/tools/build/mk/OptionalObsoleteFiles.inc Directory Properties: stable/11/ (props changed) Modified: stable/11/tools/build/mk/OptionalObsoleteFiles.inc ============================================================================== --- stable/11/tools/build/mk/OptionalObsoleteFiles.inc Tue Mar 21 03:42:28 2017 (r315659) +++ stable/11/tools/build/mk/OptionalObsoleteFiles.inc Tue Mar 21 05:13:14 2017 (r315660) @@ -7131,9 +7131,14 @@ OLD_FILES+=usr/share/man/man1/rlog.1.gz OLD_FILES+=usr/share/man/man5/rcsfile.5.gz .endif -#.if ${MK_RESCUE} == no -# to be filled in or replaced with a special target -#.endif +.if ${MK_RESCUE} == no +. if exists(${DESTDIR}${TESTSBASE}) +RESCUE_DIRS!=find ${DESTDIR}/rescue -type d 2>/dev/null | sed -e 's,^${DESTDIR}/,,'; echo +OLD_DIRS+=${RESCUE_DIRS} +RESCUE_FILES!=find ${DESTDIR}/rescue \! -type d 2>/dev/null | sed -e 's,^${DESTDIR}/,,'; echo +OLD_FILES+=${RESCUE_FILES} +. endif +.endif .if ${MK_ROUTED} == no OLD_FILES+=rescue/routed From owner-svn-src-stable-11@freebsd.org Tue Mar 21 08:30:07 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D1912D16B0D; Tue, 21 Mar 2017 08:30:07 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 97C021027; Tue, 21 Mar 2017 08:30:07 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2L8U6cf002097; Tue, 21 Mar 2017 08:30:06 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2L8U6m5002096; Tue, 21 Mar 2017 08:30:06 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201703210830.v2L8U6m5002096@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Tue, 21 Mar 2017 08:30:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315665 - stable/11/sys/dev/xen/netfront X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Mar 2017 08:30:07 -0000 Author: royger Date: Tue Mar 21 08:30:06 2017 New Revision: 315665 URL: https://svnweb.freebsd.org/changeset/base/315665 Log: MFC r314842: xen/netfront: fix inbound packet flags for checksum offload Reviewed by: Wei Liu Sponsored by: Citrix Systems R&D Modified: stable/11/sys/dev/xen/netfront/netfront.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/xen/netfront/netfront.c ============================================================================== --- stable/11/sys/dev/xen/netfront/netfront.c Tue Mar 21 08:24:40 2017 (r315664) +++ stable/11/sys/dev/xen/netfront/netfront.c Tue Mar 21 08:30:06 2017 (r315665) @@ -1178,15 +1178,17 @@ xn_rxeof(struct netfront_rxq *rxq) m->m_pkthdr.rcvif = ifp; if ( rx->flags & NETRXF_data_validated ) { - /* Tell the stack the checksums are okay */ /* - * XXX this isn't necessarily the case - need to add - * check + * According to mbuf(9) the correct way to tell + * the stack that the checksum of an inbound + * packet is correct, without it actually being + * present (because the underlying interface + * doesn't provide it), is to set the + * CSUM_DATA_VALID and CSUM_PSEUDO_HDR flags, + * and the csum_data field to 0xffff. */ - - m->m_pkthdr.csum_flags |= - (CSUM_IP_CHECKED | CSUM_IP_VALID | CSUM_DATA_VALID - | CSUM_PSEUDO_HDR); + m->m_pkthdr.csum_flags |= (CSUM_DATA_VALID + | CSUM_PSEUDO_HDR); m->m_pkthdr.csum_data = 0xffff; } if ((rx->flags & NETRXF_extra_info) != 0 && From owner-svn-src-stable-11@freebsd.org Tue Mar 21 08:34:42 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4E918D16CB3; Tue, 21 Mar 2017 08:34:42 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1D9BC149A; Tue, 21 Mar 2017 08:34:42 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2L8YfMu005908; Tue, 21 Mar 2017 08:34:41 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2L8YfCD005907; Tue, 21 Mar 2017 08:34:41 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201703210834.v2L8YfCD005907@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Tue, 21 Mar 2017 08:34:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315666 - stable/11/sys/dev/xen/timer X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Mar 2017 08:34:42 -0000 Author: royger Date: Tue Mar 21 08:34:41 2017 New Revision: 315666 URL: https://svnweb.freebsd.org/changeset/base/315666 Log: MFC r314094: xen/timer: mark the Xen PV timer as not safe for suspension Submitted by: Liuyingdong Reviewed by: royger Modified: stable/11/sys/dev/xen/timer/timer.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/xen/timer/timer.c ============================================================================== --- stable/11/sys/dev/xen/timer/timer.c Tue Mar 21 08:30:06 2017 (r315665) +++ stable/11/sys/dev/xen/timer/timer.c Tue Mar 21 08:34:41 2017 (r315666) @@ -417,8 +417,20 @@ xentimer_attach(device_t dev) /* Register the timecounter. */ sc->tc.tc_name = "XENTIMER"; sc->tc.tc_quality = XENTIMER_QUALITY; - sc->tc.tc_flags = TC_FLAGS_SUSPEND_SAFE; /* + * FIXME: due to the lack of ordering during resume, FreeBSD cannot + * guarantee that the Xen PV timer is resumed before any other device + * attempts to make use of it, so mark it as not safe for suspension + * (ie: remove the TC_FLAGS_SUSPEND_SAFE flag). + * + * NB: This was not a problem in previous FreeBSD versions because the + * timer was directly attached to the nexus, but it is an issue now + * that the timer is attached to the xenpv bus, and thus resumed + * later. + * + * sc->tc.tc_flags = TC_FLAGS_SUSPEND_SAFE; + */ + /* * The underlying resolution is in nanoseconds, since the timer info * scales TSC frequencies using a fraction that represents time in * terms of nanoseconds. From owner-svn-src-stable-11@freebsd.org Tue Mar 21 08:36:26 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EDAB9D16D88; Tue, 21 Mar 2017 08:36:26 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A257216B6; Tue, 21 Mar 2017 08:36:26 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2L8aPAU006038; Tue, 21 Mar 2017 08:36:25 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2L8aPrv006035; Tue, 21 Mar 2017 08:36:25 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201703210836.v2L8aPrv006035@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Tue, 21 Mar 2017 08:36:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315667 - in stable/11/sys: dev/xen/control dev/xen/xenstore xen/xenstore X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Mar 2017 08:36:27 -0000 Author: royger Date: Tue Mar 21 08:36:25 2017 New Revision: 315667 URL: https://svnweb.freebsd.org/changeset/base/315667 Log: MFC r314841: xenstore: fix suspension when using the xenstore device Submitted by: Liuyingdong Reviewed by: royger Modified: stable/11/sys/dev/xen/control/control.c stable/11/sys/dev/xen/xenstore/xenstore.c stable/11/sys/xen/xenstore/xenstorevar.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/xen/control/control.c ============================================================================== --- stable/11/sys/dev/xen/control/control.c Tue Mar 21 08:34:41 2017 (r315666) +++ stable/11/sys/dev/xen/control/control.c Tue Mar 21 08:36:25 2017 (r315667) @@ -199,7 +199,9 @@ xctrl_suspend() int suspend_cancelled; EVENTHANDLER_INVOKE(power_suspend_early); + xs_lock(); stop_all_proc(); + xs_unlock(); EVENTHANDLER_INVOKE(power_suspend); #ifdef EARLY_AP_STARTUP Modified: stable/11/sys/dev/xen/xenstore/xenstore.c ============================================================================== --- stable/11/sys/dev/xen/xenstore/xenstore.c Tue Mar 21 08:34:41 2017 (r315666) +++ stable/11/sys/dev/xen/xenstore/xenstore.c Tue Mar 21 08:36:25 2017 (r315667) @@ -1699,3 +1699,20 @@ xs_unregister_watch(struct xs_watch *wat sx_xunlock(&xs.xenwatch_mutex); } } + +void +xs_lock(void) +{ + + sx_xlock(&xs.request_mutex); + return; +} + +void +xs_unlock(void) +{ + + sx_xunlock(&xs.request_mutex); + return; +} + Modified: stable/11/sys/xen/xenstore/xenstorevar.h ============================================================================== --- stable/11/sys/xen/xenstore/xenstorevar.h Tue Mar 21 08:34:41 2017 (r315666) +++ stable/11/sys/xen/xenstore/xenstorevar.h Tue Mar 21 08:36:25 2017 (r315667) @@ -338,4 +338,15 @@ void xs_unregister_watch(struct xs_watch */ struct sbuf *xs_join(const char *, const char *); +/** + * Lock the xenstore request mutex. + */ +void xs_lock(void); + +/** + * Unlock the xenstore request mutex. + */ +void xs_unlock(void); + #endif /* _XEN_XENSTORE_XENSTOREVAR_H */ + From owner-svn-src-stable-11@freebsd.org Tue Mar 21 08:38:14 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1A5B4D16E2C; Tue, 21 Mar 2017 08:38:14 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E92EC1831; Tue, 21 Mar 2017 08:38:13 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2L8cDqO006168; Tue, 21 Mar 2017 08:38:13 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2L8cCAJ006163; Tue, 21 Mar 2017 08:38:12 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201703210838.v2L8cCAJ006163@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Tue, 21 Mar 2017 08:38:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315668 - in stable/11/sys: dev/xen/blkfront dev/xen/control dev/xen/netfront xen xen/xenbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Mar 2017 08:38:14 -0000 Author: royger Date: Tue Mar 21 08:38:12 2017 New Revision: 315668 URL: https://svnweb.freebsd.org/changeset/base/315668 Log: MFC r314840: xen: add support for canceled suspend Submitted by: Liuyingdong Reviewed by: royger Modified: stable/11/sys/dev/xen/blkfront/blkfront.c stable/11/sys/dev/xen/control/control.c stable/11/sys/dev/xen/netfront/netfront.c stable/11/sys/xen/xen-os.h stable/11/sys/xen/xenbus/xenbusb.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/xen/blkfront/blkfront.c ============================================================================== --- stable/11/sys/dev/xen/blkfront/blkfront.c Tue Mar 21 08:36:25 2017 (r315667) +++ stable/11/sys/dev/xen/blkfront/blkfront.c Tue Mar 21 08:38:12 2017 (r315668) @@ -1537,6 +1537,11 @@ xbd_resume(device_t dev) { struct xbd_softc *sc = device_get_softc(dev); + if (xen_suspend_cancelled) { + sc->xbd_state = XBD_STATE_CONNECTED; + return (0); + } + DPRINTK("xbd_resume: %s\n", xenbus_get_node(dev)); xbd_free(sc); Modified: stable/11/sys/dev/xen/control/control.c ============================================================================== --- stable/11/sys/dev/xen/control/control.c Tue Mar 21 08:36:25 2017 (r315667) +++ stable/11/sys/dev/xen/control/control.c Tue Mar 21 08:38:12 2017 (r315668) @@ -148,6 +148,7 @@ __FBSDID("$FreeBSD$"); #include +bool xen_suspend_cancelled; /*--------------------------- Forward Declarations --------------------------*/ /** Function signature for shutdown event handlers. */ typedef void (xctrl_shutdown_handler_t)(void); @@ -196,7 +197,6 @@ xctrl_suspend() #ifdef SMP cpuset_t cpu_suspend_map; #endif - int suspend_cancelled; EVENTHANDLER_INVOKE(power_suspend_early); xs_lock(); @@ -269,16 +269,20 @@ xctrl_suspend() intr_suspend(); xen_hvm_suspend(); - suspend_cancelled = HYPERVISOR_suspend(0); + xen_suspend_cancelled = !!HYPERVISOR_suspend(0); - xen_hvm_resume(suspend_cancelled != 0); - intr_resume(suspend_cancelled != 0); + if (!xen_suspend_cancelled) { + xen_hvm_resume(false); + } + intr_resume(xen_suspend_cancelled != 0); enable_intr(); /* * Reset grant table info. */ - gnttab_resume(NULL); + if (!xen_suspend_cancelled) { + gnttab_resume(NULL); + } #ifdef SMP if (!CPU_EMPTY(&cpu_suspend_map)) { Modified: stable/11/sys/dev/xen/netfront/netfront.c ============================================================================== --- stable/11/sys/dev/xen/netfront/netfront.c Tue Mar 21 08:36:25 2017 (r315667) +++ stable/11/sys/dev/xen/netfront/netfront.c Tue Mar 21 08:38:12 2017 (r315668) @@ -439,6 +439,20 @@ static int netfront_resume(device_t dev) { struct netfront_info *info = device_get_softc(dev); + u_int i; + + if (xen_suspend_cancelled) { + for (i = 0; i < info->num_queues; i++) { + XN_RX_LOCK(&info->rxq[i]); + XN_TX_LOCK(&info->txq[i]); + } + netfront_carrier_on(info); + for (i = 0; i < info->num_queues; i++) { + XN_RX_UNLOCK(&info->rxq[i]); + XN_TX_UNLOCK(&info->txq[i]); + } + return (0); + } netif_disconnect_backend(info); return (0); Modified: stable/11/sys/xen/xen-os.h ============================================================================== --- stable/11/sys/xen/xen-os.h Tue Mar 21 08:36:25 2017 (r315667) +++ stable/11/sys/xen/xen-os.h Tue Mar 21 08:38:12 2017 (r315668) @@ -56,6 +56,8 @@ extern char *console_page; extern int xen_disable_pv_disks; extern int xen_disable_pv_nics; +extern bool xen_suspend_cancelled; + enum xen_domain_type { XEN_NATIVE, /* running on bare hardware */ XEN_PV_DOMAIN, /* running in a PV domain */ Modified: stable/11/sys/xen/xenbus/xenbusb.c ============================================================================== --- stable/11/sys/xen/xenbus/xenbusb.c Tue Mar 21 08:36:25 2017 (r315667) +++ stable/11/sys/xen/xenbus/xenbusb.c Tue Mar 21 08:38:12 2017 (r315668) @@ -791,6 +791,11 @@ xenbusb_resume(device_t dev) if (device_get_state(kids[i]) == DS_NOTPRESENT) continue; + if (xen_suspend_cancelled) { + DEVICE_RESUME(kids[i]); + continue; + } + ivars = device_get_ivars(kids[i]); xs_unregister_watch(&ivars->xd_otherend_watch); From owner-svn-src-stable-11@freebsd.org Tue Mar 21 09:14:58 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BB36CD14755; Tue, 21 Mar 2017 09:14:58 +0000 (UTC) (envelope-from ronald-lists@klop.ws) Received: from smarthost1.greenhost.nl (smarthost1.greenhost.nl [195.190.28.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8602D174; Tue, 21 Mar 2017 09:14:57 +0000 (UTC) (envelope-from ronald-lists@klop.ws) Received: from smtp.greenhost.nl ([213.108.104.138]) by smarthost1.greenhost.nl with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1cqFd8-00079V-FA; Tue, 21 Mar 2017 09:59:02 +0100 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org, "Ngie Cooper" Subject: Re: svn commit: r315660 - stable/11/tools/build/mk References: <201703210513.v2L5DFes023003@repo.freebsd.org> Date: Tue, 21 Mar 2017 09:59:01 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: "Ronald Klop" Message-ID: In-Reply-To: <201703210513.v2L5DFes023003@repo.freebsd.org> User-Agent: Opera Mail/12.16 (FreeBSD) X-Authenticated-As-Hash: 398f5522cb258ce43cb679602f8cfe8b62a256d1 X-Virus-Scanned: by clamav at smarthost1.samage.net X-Spam-Level: / X-Spam-Score: -0.2 X-Spam-Status: No, score=-0.2 required=5.0 tests=ALL_TRUSTED, BAYES_50 autolearn=disabled version=3.4.0 X-Scan-Signature: 9b84bad32751a42de3aa9e7877f1ca86 X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Mar 2017 09:14:58 -0000 On Tue, 21 Mar 2017 06:13:15 +0100, Ngie Cooper wrote: > Author: ngie > Date: Tue Mar 21 05:13:14 2017 > New Revision: 315660 > URL: https://svnweb.freebsd.org/changeset/base/315660 > > Log: > MFC r314241,r315228: > r314241: > Fill in MK_RESCUE by finding paths in ${DESTDIR}/rescue and adding > them to OLD_FILES/OLD_DIRS, as necessary. > r315228: > Redirect standard error from find /rescue to /dev/null > This mutes noise from find when /rescue doesn't exist. IMHO it is better to check the existence in an if before the find. My experience is that other errors will show up in the future which are then ignored by piping to /dev/null. Ronald. > > Modified: > stable/11/tools/build/mk/OptionalObsoleteFiles.inc > Directory Properties: > stable/11/ (props changed) > > Modified: stable/11/tools/build/mk/OptionalObsoleteFiles.inc > ============================================================================== > --- stable/11/tools/build/mk/OptionalObsoleteFiles.inc Tue Mar 21 > 03:42:28 2017 (r315659) > +++ stable/11/tools/build/mk/OptionalObsoleteFiles.inc Tue Mar 21 > 05:13:14 2017 (r315660) > @@ -7131,9 +7131,14 @@ OLD_FILES+=usr/share/man/man1/rlog.1.gz > OLD_FILES+=usr/share/man/man5/rcsfile.5.gz > .endif > -#.if ${MK_RESCUE} == no > -# to be filled in or replaced with a special target > -#.endif > +.if ${MK_RESCUE} == no > +. if exists(${DESTDIR}${TESTSBASE}) > +RESCUE_DIRS!=find ${DESTDIR}/rescue -type d 2>/dev/null | sed -e > 's,^${DESTDIR}/,,'; echo > +OLD_DIRS+=${RESCUE_DIRS} > +RESCUE_FILES!=find ${DESTDIR}/rescue \! -type d 2>/dev/null | sed -e > 's,^${DESTDIR}/,,'; echo > +OLD_FILES+=${RESCUE_FILES} > +. endif > +.endif > .if ${MK_ROUTED} == no > OLD_FILES+=rescue/routed > _______________________________________________ > svn-src-all@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-all > To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" From owner-svn-src-stable-11@freebsd.org Wed Mar 22 01:04:22 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 454B0D1691A; Wed, 22 Mar 2017 01:04:22 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EBE6012E2; Wed, 22 Mar 2017 01:04:21 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2M14L5P020488; Wed, 22 Mar 2017 01:04:21 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2M14Ke7020487; Wed, 22 Mar 2017 01:04:20 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703220104.v2M14Ke7020487@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Wed, 22 Mar 2017 01:04:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315695 - in stable/11: etc/mtree lib/libcam lib/libcam/tests X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Mar 2017 01:04:22 -0000 Author: ngie Date: Wed Mar 22 01:04:20 2017 New Revision: 315695 URL: https://svnweb.freebsd.org/changeset/base/315695 Log: MFC r315320: Start adding basic tests for cam(3) This change contains several negative and positive tests for: - cam_open_device - cam_close_device - cam_getccb - cam_freeccb This also contains a test for the failure case noted in bug 217649, i.e., O_RDWR must be specified because pass(4) requires it. This test unfortunately cannot assume that cam-capable devices are present, so the user must explicitly provide a device via `test_suites.FreeBSD.cam_test_device`. In the future, a test kernel module might be shipped, or ctl(4) might be used, as a test device when testing out libcam, which will allow the tests to do away with having to specify an explicit test device. Added: stable/11/lib/libcam/tests/ - copied from r315320, head/lib/libcam/tests/ Modified: stable/11/etc/mtree/BSD.tests.dist stable/11/lib/libcam/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/etc/mtree/BSD.tests.dist ============================================================================== --- stable/11/etc/mtree/BSD.tests.dist Wed Mar 22 00:50:36 2017 (r315694) +++ stable/11/etc/mtree/BSD.tests.dist Wed Mar 22 01:04:20 2017 (r315695) @@ -308,6 +308,8 @@ ttyio .. .. + libcam + .. libcrypt .. libdevdctl Modified: stable/11/lib/libcam/Makefile ============================================================================== --- stable/11/lib/libcam/Makefile Wed Mar 22 00:50:36 2017 (r315694) +++ stable/11/lib/libcam/Makefile Wed Mar 22 01:04:20 2017 (r315695) @@ -43,4 +43,10 @@ CFLAGS+= -I${.CURDIR} -I${SRCTOP}/sys SHLIB_MAJOR= 7 +.include + +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif + .include From owner-svn-src-stable-11@freebsd.org Wed Mar 22 03:05:40 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 184A4D17E69; Wed, 22 Mar 2017 03:05:40 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E82891B0E; Wed, 22 Mar 2017 03:05:39 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 0AD4310A7B9; Tue, 21 Mar 2017 23:05:39 -0400 (EDT) From: John Baldwin To: Slawa Olhovchenkov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r313450 - in stable/11: lib/libc/gen lib/libc/sys sys/compat/freebsd32 sys/kern sys/sys Date: Tue, 21 Mar 2017 20:05:31 -0700 Message-ID: <18428734.CRRuMZqGsJ@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-STABLE; KDE/4.14.10; amd64; ; ) In-Reply-To: <20170315143053.GW15630@zxy.spb.ru> References: <201702081832.v18IWZlC001828@repo.freebsd.org> <20170315143053.GW15630@zxy.spb.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Tue, 21 Mar 2017 23:05:39 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Mar 2017 03:05:40 -0000 On Wednesday, March 15, 2017 05:30:53 PM Slawa Olhovchenkov wrote: > On Wed, Feb 08, 2017 at 06:32:35PM +0000, John Baldwin wrote: > > > Author: jhb > > Date: Wed Feb 8 18:32:35 2017 > > New Revision: 313450 > > URL: https://svnweb.freebsd.org/changeset/base/313450 > > > > Log: > > MFC 310638: > > Rename the 'flags' argument to getfsstat() to 'mode' and validate it. > > > > This argument is not a bitmask of flags, but only accepts a single value. > > Fail with EINVAL if an invalid value is passed to 'flag'. Rename the > > 'flags' argument to getmntinfo(3) to 'mode' as well to match. > > > > This is a followup to r308088. > > > kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize, > > - size_t *countp, enum uio_seg bufseg, int flags) > > + size_t *countp, enum uio_seg bufseg, int mode) > > { > > struct mount *mp, *nmp; > > struct statfs *sfsp, *sp, *sptmp, *tofree; > > size_t count, maxcount; > > int error; > > > > + switch (mode) { > > + case MNT_WAIT: > > + case MNT_NOWAIT: > > + break; > > + default: > > + return (EINVAL); > > + } > > restart: > > This is break net-snmp UCD-SNMP-MIB::dskTable oid: > > 82434 snmpd CALL getfsstat(0,0,) > 82434 snmpd RET getfsstat -1 errno 22 Invalid argument > 82434 snmpd CALL getfsstat(0,0xfffffffffffffe28,MNT_NOWAIT) > 82434 snmpd RET getfsstat -1 errno 22 Invalid argument > 82434 snmpd CALL write(0x9,0x800f162ea,0x1) This doesn't seem to match the code in the port: void Init_HR_FileSys(void) { #if HAVE_GETFSSTAT #if defined(HAVE_STATVFS) && defined(__NetBSD__) fscount = getvfsstat(NULL, 0, ST_NOWAIT); #else fscount = getfsstat(NULL, 0, MNT_NOWAIT); #endif if (fsstats) free((char *) fsstats); fsstats = NULL; fsstats = malloc(fscount * sizeof(*fsstats)); #if defined(HAVE_STATVFS) && defined(__NetBSD__) getvfsstat(fsstats, fscount * sizeof(*fsstats), ST_NOWAIT); #else getfsstat(fsstats, fscount * sizeof(*fsstats), MNT_NOWAIT); #endif HRFS_index = 0; (Here it always calls with MNT_NOWAIT) This is for net-snmp 5.7.3, but it seems like that code hasn't changed in quite a while. -- John Baldwin From owner-svn-src-stable-11@freebsd.org Wed Mar 22 07:09:32 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3DA9FD16F65; Wed, 22 Mar 2017 07:09:32 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 03D3B1CCC; Wed, 22 Mar 2017 07:09:31 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2M79Vjr066683; Wed, 22 Mar 2017 07:09:31 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2M79VS4066682; Wed, 22 Mar 2017 07:09:31 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201703220709.v2M79VS4066682@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Wed, 22 Mar 2017 07:09:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315702 - stable/11/contrib/libc++/include X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Mar 2017 07:09:32 -0000 Author: dim Date: Wed Mar 22 07:09:30 2017 New Revision: 315702 URL: https://svnweb.freebsd.org/changeset/base/315702 Log: Pull in r283944 from upstream libc++ trunk (by Eric Fiselier): Fix std::pair on FreeBSD Summary: FreeBSD ships an old ABI for std::pair which requires that it have non-trivial copy/move constructors. Currently the non-trivial copy/move is achieved by providing explicit definitions of the constructors. This is problematic because it means the constructors don't SFINAE properly. In order to SFINAE copy/move constructors they have to be explicitly defaulted and hense non-trivial. This patch attempts to provide SFINAE'ing copy/move constructors for std::pair while still making them non-trivial. It does this by adding a base class with a non-trivial copy constructor and then allowing pair's constructors to be generated by the compiler. This also allows the constructors to be constexpr. Reviewers: emaste, theraven, rsmith, dim Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25389 This should fix building www/chromium 57.0.2987.110 on stable/11, without further hacks. Direct commit to stable/11, since head already has libc++ 4.0, which includes this fix. Reported by: cpm Modified: stable/11/contrib/libc++/include/utility Modified: stable/11/contrib/libc++/include/utility ============================================================================== --- stable/11/contrib/libc++/include/utility Wed Mar 22 07:05:27 2017 (r315701) +++ stable/11/contrib/libc++/include/utility Wed Mar 22 07:09:30 2017 (r315702) @@ -276,8 +276,20 @@ extern const piecewise_construct_t piece constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); #endif +#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR) +struct __non_trivially_copyable_base { + _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + __non_trivially_copyable_base() _NOEXCEPT {} + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + __non_trivially_copyable_base(__non_trivially_copyable_base const&) _NOEXCEPT {} +}; +#endif + template struct _LIBCPP_TYPE_VIS_ONLY pair +#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR) +: private __non_trivially_copyable_base +#endif { typedef _T1 first_type; typedef _T2 second_type; @@ -307,26 +319,7 @@ struct _LIBCPP_TYPE_VIS_ONLY pair ) : first(__p.first), second(__p.second) {} -#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR) - _LIBCPP_INLINE_VISIBILITY - pair(const pair& __p) - _NOEXCEPT_(is_nothrow_copy_constructible::value && - is_nothrow_copy_constructible::value) - : first(__p.first), - second(__p.second) - { - } - -# ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY - pair(pair&& __p) _NOEXCEPT_(is_nothrow_move_constructible::value && - is_nothrow_move_constructible::value) - : first(_VSTD::forward(__p.first)), - second(_VSTD::forward(__p.second)) - { - } -# endif -#elif !defined(_LIBCPP_CXX03_LANG) +#if !defined(_LIBCPP_CXX03_LANG) pair(pair const&) = default; pair(pair&&) = default; #else From owner-svn-src-stable-11@freebsd.org Wed Mar 22 07:52:26 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CFCB9D170F1; Wed, 22 Mar 2017 07:52:26 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A723819DE; Wed, 22 Mar 2017 07:52:26 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2M7qPKh086392; Wed, 22 Mar 2017 07:52:25 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2M7qPfo086391; Wed, 22 Mar 2017 07:52:25 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703220752.v2M7qPfo086391@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 22 Mar 2017 07:52:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315703 - stable/11/sys/cam/scsi X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Mar 2017 07:52:26 -0000 Author: mav Date: Wed Mar 22 07:52:25 2017 New Revision: 315703 URL: https://svnweb.freebsd.org/changeset/base/315703 Log: MFC r314906: Add initial support for UNMAP granularity. Report UNMAP granularity as stripesize/-offset if we have no other values to report there. Add new quirk DA_Q_STRICT_UNMAP for cases when target is too critical to misaligned UNMAP request, reporting errors instead of being suboptimal. Setting this quirk makes da periph to forcefully align all UNMAP requests to avoid those errors by the cost of some odd ranges not being UNMAP'ed. This makes UNMAP usable within VMware 6.x VMs, just now 100% efficient. Modified: stable/11/sys/cam/scsi/scsi_da.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_da.c Wed Mar 22 07:09:30 2017 (r315702) +++ stable/11/sys/cam/scsi/scsi_da.c Wed Mar 22 07:52:25 2017 (r315703) @@ -123,7 +123,8 @@ typedef enum { DA_Q_NO_RC16 = 0x10, DA_Q_NO_UNMAP = 0x20, DA_Q_RETRY_BUSY = 0x40, - DA_Q_SMR_DM = 0x80 + DA_Q_SMR_DM = 0x80, + DA_Q_STRICT_UNMAP = 0x100 } da_quirks; #define DA_Q_BIT_STRING \ @@ -135,7 +136,8 @@ typedef enum { "\005NO_RC16" \ "\006NO_UNMAP" \ "\007RETRY_BUSY" \ - "\008SMR_DM" + "\010SMR_DM" \ + "\011STRICT_UNMAP" typedef enum { DA_CCB_PROBE_RC = 0x01, @@ -310,6 +312,8 @@ struct da_softc { u_int maxio; uint32_t unmap_max_ranges; uint32_t unmap_max_lba; /* Max LBAs in UNMAP req */ + uint32_t unmap_gran; + uint32_t unmap_gran_align; uint64_t ws_max_blks; da_delete_methods delete_method_pref; da_delete_methods delete_method; @@ -468,9 +472,10 @@ static struct da_quirk_entry da_quirk_ta /* * VMware returns BUSY status when storage has transient * connectivity problems, so better wait. + * Also VMware returns odd errors on misaligned UNMAPs. */ {T_DIRECT, SIP_MEDIA_FIXED, "VMware*", "*", "*"}, - /*quirks*/ DA_Q_RETRY_BUSY + /*quirks*/ DA_Q_RETRY_BUSY | DA_Q_STRICT_UNMAP }, /* USB mass storage devices supported by umass(4) */ { @@ -2395,6 +2400,8 @@ daregister(struct cam_periph *periph, vo softc->flags |= DA_FLAG_PACK_REMOVABLE; softc->unmap_max_ranges = UNMAP_MAX_RANGES; softc->unmap_max_lba = UNMAP_RANGE_MAX; + softc->unmap_gran = 0; + softc->unmap_gran_align = 0; softc->ws_max_blks = WS16_MAX_BLKS; softc->trim_max_ranges = ATA_TRIM_MAX_RANGES; softc->rotating = 1; @@ -3504,11 +3511,11 @@ da_delete_unmap(struct cam_periph *perip struct da_softc *softc = (struct da_softc *)periph->softc;; struct bio *bp1; uint8_t *buf = softc->unmap_buf; + struct scsi_unmap_desc *d = (void *)&buf[UNMAP_HEAD_SIZE]; uint64_t lba, lastlba = (uint64_t)-1; uint64_t totalcount = 0; uint64_t count; - uint32_t lastcount = 0, c; - uint32_t off, ranges = 0; + uint32_t c, lastcount = 0, ranges = 0; /* * Currently this doesn't take the UNMAP @@ -3541,13 +3548,39 @@ da_delete_unmap(struct cam_periph *perip /* Try to extend the previous range. */ if (lba == lastlba) { c = omin(count, UNMAP_RANGE_MAX - lastcount); + lastlba += c; lastcount += c; - off = ((ranges - 1) * UNMAP_RANGE_SIZE) + - UNMAP_HEAD_SIZE; - scsi_ulto4b(lastcount, &buf[off + 8]); + scsi_ulto4b(lastcount, d[ranges - 1].length); count -= c; - lba +=c; + lba += c; totalcount += c; + } else if ((softc->quirks & DA_Q_STRICT_UNMAP) && + softc->unmap_gran != 0) { + /* Align length of the previous range. */ + if ((c = lastcount % softc->unmap_gran) != 0) { + if (lastcount <= c) { + totalcount -= lastcount; + lastlba = (uint64_t)-1; + lastcount = 0; + ranges--; + } else { + totalcount -= c; + lastlba -= c; + lastcount -= c; + scsi_ulto4b(lastcount, d[ranges - 1].length); + } + } + /* Align beginning of the new range. */ + c = (lba - softc->unmap_gran_align) % softc->unmap_gran; + if (c != 0) { + c = softc->unmap_gran - c; + if (count <= c) { + count = 0; + } else { + lba += c; + count -= c; + } + } } while (count > 0) { @@ -3562,16 +3595,15 @@ da_delete_unmap(struct cam_periph *perip ranges, softc->unmap_max_ranges); break; } - off = (ranges * UNMAP_RANGE_SIZE) + UNMAP_HEAD_SIZE; - scsi_u64to8b(lba, &buf[off + 0]); - scsi_ulto4b(c, &buf[off + 8]); + scsi_u64to8b(lba, d[ranges].lba); + scsi_ulto4b(c, d[ranges].length); lba += c; totalcount += c; ranges++; count -= c; + lastlba = lba; lastcount = c; } - lastlba = lba; bp1 = cam_iosched_next_trim(softc->cam_iosched); if (bp1 == NULL) break; @@ -3582,6 +3614,16 @@ da_delete_unmap(struct cam_periph *perip break; } } while (1); + + /* Align length of the last range. */ + if ((softc->quirks & DA_Q_STRICT_UNMAP) && softc->unmap_gran != 0 && + (c = lastcount % softc->unmap_gran) != 0) { + if (lastcount <= c) + ranges--; + else + scsi_ulto4b(lastcount - c, d[ranges - 1].length); + } + scsi_ulto2b(ranges * 16 + 6, &buf[0]); scsi_ulto2b(ranges * 16, &buf[2]); @@ -4454,6 +4496,10 @@ dadone(struct cam_periph *periph, union block_limits->max_unmap_lba_cnt); uint32_t max_unmap_blk_cnt = scsi_4btoul( block_limits->max_unmap_blk_cnt); + uint32_t unmap_gran = scsi_4btoul( + block_limits->opt_unmap_grain); + uint32_t unmap_gran_align = scsi_4btoul( + block_limits->unmap_grain_align); uint64_t ws_max_blks = scsi_8btou64( block_limits->max_write_same_length); @@ -4471,6 +4517,14 @@ dadone(struct cam_periph *periph, union softc->unmap_max_lba = max_unmap_lba_cnt; softc->unmap_max_ranges = min(max_unmap_blk_cnt, UNMAP_MAX_RANGES); + if (unmap_gran > 1) { + softc->unmap_gran = unmap_gran; + if (unmap_gran_align & 0x80000000) { + softc->unmap_gran_align = + unmap_gran_align & + 0x7fffffff; + } + } } else { /* * Unexpected UNMAP limits which means the @@ -5380,6 +5434,10 @@ dasetgeom(struct cam_periph *periph, uin } else if (softc->quirks & DA_Q_4K) { dp->stripesize = 4096; dp->stripeoffset = 0; + } else if (softc->unmap_gran != 0) { + dp->stripesize = block_len * softc->unmap_gran; + dp->stripeoffset = (dp->stripesize - block_len * + softc->unmap_gran_align) % dp->stripesize; } else { dp->stripesize = 0; dp->stripeoffset = 0; From owner-svn-src-stable-11@freebsd.org Wed Mar 22 07:53:58 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 95ADFD17266; Wed, 22 Mar 2017 07:53:58 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6511A1BAC; Wed, 22 Mar 2017 07:53:58 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2M7rv6X086511; Wed, 22 Mar 2017 07:53:57 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2M7rvgN086510; Wed, 22 Mar 2017 07:53:57 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703220753.v2M7rvgN086510@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 22 Mar 2017 07:53:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315704 - stable/11/sys/geom X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Mar 2017 07:53:58 -0000 Author: mav Date: Wed Mar 22 07:53:57 2017 New Revision: 315704 URL: https://svnweb.freebsd.org/changeset/base/315704 Log: MFC r314908: When chunking large DIOCGDELETE, do it on stripe edge. Modified: stable/11/sys/geom/geom_dev.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/geom/geom_dev.c ============================================================================== --- stable/11/sys/geom/geom_dev.c Wed Mar 22 07:52:25 2017 (r315703) +++ stable/11/sys/geom/geom_dev.c Wed Mar 22 07:53:57 2017 (r315704) @@ -458,7 +458,7 @@ g_dev_ioctl(struct cdev *dev, u_long cmd { struct g_consumer *cp; struct g_provider *pp; - off_t offset, length, chunk; + off_t offset, length, chunk, odd; int i, error; cp = dev->si_drv2; @@ -518,6 +518,13 @@ g_dev_ioctl(struct cdev *dev, u_long cmd g_dev_del_max_sectors * cp->provider->sectorsize) { chunk = g_dev_del_max_sectors * cp->provider->sectorsize; + if (cp->provider->stripesize > 0) { + odd = (offset + chunk + + cp->provider->stripeoffset) % + cp->provider->stripesize; + if (chunk > odd) + chunk -= odd; + } } error = g_delete_data(cp, offset, chunk); length -= chunk; From owner-svn-src-stable-11@freebsd.org Wed Mar 22 12:40:58 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 84AA2D17897; Wed, 22 Mar 2017 12:40:58 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 46F7F1956; Wed, 22 Mar 2017 12:40:58 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1cqfZJ-000KTw-W7; Wed, 22 Mar 2017 15:40:50 +0300 Date: Wed, 22 Mar 2017 15:40:49 +0300 From: Slawa Olhovchenkov To: John Baldwin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r313450 - in stable/11: lib/libc/gen lib/libc/sys sys/compat/freebsd32 sys/kern sys/sys Message-ID: <20170322124049.GY70430@zxy.spb.ru> References: <201702081832.v18IWZlC001828@repo.freebsd.org> <20170315143053.GW15630@zxy.spb.ru> <18428734.CRRuMZqGsJ@ralph.baldwin.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <18428734.CRRuMZqGsJ@ralph.baldwin.cx> User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Mar 2017 12:40:58 -0000 On Tue, Mar 21, 2017 at 08:05:31PM -0700, John Baldwin wrote: > On Wednesday, March 15, 2017 05:30:53 PM Slawa Olhovchenkov wrote: > > On Wed, Feb 08, 2017 at 06:32:35PM +0000, John Baldwin wrote: > > > > > Author: jhb > > > Date: Wed Feb 8 18:32:35 2017 > > > New Revision: 313450 > > > URL: https://svnweb.freebsd.org/changeset/base/313450 > > > > > > Log: > > > MFC 310638: > > > Rename the 'flags' argument to getfsstat() to 'mode' and validate it. > > > > > > This argument is not a bitmask of flags, but only accepts a single value. > > > Fail with EINVAL if an invalid value is passed to 'flag'. Rename the > > > 'flags' argument to getmntinfo(3) to 'mode' as well to match. > > > > > > This is a followup to r308088. > > > > > kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize, > > > - size_t *countp, enum uio_seg bufseg, int flags) > > > + size_t *countp, enum uio_seg bufseg, int mode) > > > { > > > struct mount *mp, *nmp; > > > struct statfs *sfsp, *sp, *sptmp, *tofree; > > > size_t count, maxcount; > > > int error; > > > > > > + switch (mode) { > > > + case MNT_WAIT: > > > + case MNT_NOWAIT: > > > + break; > > > + default: > > > + return (EINVAL); > > > + } > > > restart: > > > > This is break net-snmp UCD-SNMP-MIB::dskTable oid: > > > > 82434 snmpd CALL getfsstat(0,0,) > > 82434 snmpd RET getfsstat -1 errno 22 Invalid argument > > 82434 snmpd CALL getfsstat(0,0xfffffffffffffe28,MNT_NOWAIT) > > 82434 snmpd RET getfsstat -1 errno 22 Invalid argument > > 82434 snmpd CALL write(0x9,0x800f162ea,0x1) > > This doesn't seem to match the code in the port: > > void > Init_HR_FileSys(void) > { > #if HAVE_GETFSSTAT > #if defined(HAVE_STATVFS) && defined(__NetBSD__) > fscount = getvfsstat(NULL, 0, ST_NOWAIT); > #else > fscount = getfsstat(NULL, 0, MNT_NOWAIT); > #endif > if (fsstats) > free((char *) fsstats); > fsstats = NULL; > fsstats = malloc(fscount * sizeof(*fsstats)); > #if defined(HAVE_STATVFS) && defined(__NetBSD__) > getvfsstat(fsstats, fscount * sizeof(*fsstats), ST_NOWAIT); > #else > getfsstat(fsstats, fscount * sizeof(*fsstats), MNT_NOWAIT); > #endif > HRFS_index = 0; > > (Here it always calls with MNT_NOWAIT) This is for net-snmp 5.7.3, > but it seems like that code hasn't changed in quite a while. I see, strange. I am also use net-snmp 5.7.3 (net-snmp-5.7.3_12). # dtrace -n 'syscall:freebsd:getfsstat:entry { printf("%s %p %d %d\n", execname, args[0], args[1], args[2]); stack(); ustack();}' dtrace: description 'syscall:freebsd:getfsstat:entry ' matched 1 probe CPU ID FUNCTION:NAME 22 43059 getfsstat:entry snmpd 0 0 0 kernel`amd64_syscall+0x36b kernel`0xffffffff8071c84b libc.so.7`getfsstat+0xa libnetsnmpmibs.so.30.0.3`netsnmp_fsys_load+0x9 libnetsnmpagent.so.30.0.3`0x80083dfbf libnetsnmpmibs.so.30.0.3`var_extensible_disk+0x38 libnetsnmpagent.so.30.0.3`netsnmp_old_api_helper+0x18f libnetsnmpagent.so.30.0.3`netsnmp_call_handler+0x134 libnetsnmpagent.so.30.0.3`netsnmp_bulk_to_next_helper+0x1a1 libnetsnmpagent.so.30.0.3`netsnmp_call_handler+0x134 libnetsnmpagent.so.30.0.3`handle_var_requests+0x67 libnetsnmpagent.so.30.0.3`handle_getnext_loop+0x244 libnetsnmpagent.so.30.0.3`netsnmp_handle_request+0x186 libnetsnmpagent.so.30.0.3`handle_snmp_packet+0x140 libnetsnmp.so.30.0.3`0x800ece6c6 libnetsnmp.so.30.0.3`_sess_read+0x5b9 libnetsnmp.so.30.0.3`snmp_read2+0x3b snmpd`0x404cab snmpd`0x40317f ld-elf.so.1`0x800629000 Ok, what is it: /* * Wrapper routine for re-loading filesystem statistics on demand */ int netsnmp_fsys_load( netsnmp_cache *cache, void *data ) { /* XXX - check cache timeliness */ return _fsys_load(); } /* * Architecture-independent processing of loading filesystem statistics */ static int _fsys_load( void ) { netsnmp_fsys_arch_load(); /* XXX - update cache timestamp */ return 0; } agent/mibgroup/hardware/fsys/fsys_getfsstats.c: void netsnmp_fsys_arch_load( void ) { int n, i; struct NSFS_STATFS *stats; netsnmp_fsys_info *entry; /* * Retrieve information about the currently mounted filesystems... */ n = NSFS_GETFSSTAT( NULL, 0, 0 ); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From owner-svn-src-stable-11@freebsd.org Wed Mar 22 17:19:29 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 84189D185D5; Wed, 22 Mar 2017 17:19:29 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 629BF1239; Wed, 22 Mar 2017 17:19:29 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 4A3EE10A7DB; Wed, 22 Mar 2017 13:19:28 -0400 (EDT) From: John Baldwin To: Slawa Olhovchenkov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r313450 - in stable/11: lib/libc/gen lib/libc/sys sys/compat/freebsd32 sys/kern sys/sys Date: Wed, 22 Mar 2017 09:52:01 -0700 Message-ID: <3048399.ogXM26kenL@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-STABLE; KDE/4.14.10; amd64; ; ) In-Reply-To: <20170322124049.GY70430@zxy.spb.ru> References: <201702081832.v18IWZlC001828@repo.freebsd.org> <18428734.CRRuMZqGsJ@ralph.baldwin.cx> <20170322124049.GY70430@zxy.spb.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Wed, 22 Mar 2017 13:19:28 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Mar 2017 17:19:29 -0000 On Wednesday, March 22, 2017 03:40:49 PM Slawa Olhovchenkov wrote: > On Tue, Mar 21, 2017 at 08:05:31PM -0700, John Baldwin wrote: > > > On Wednesday, March 15, 2017 05:30:53 PM Slawa Olhovchenkov wrote: > > > On Wed, Feb 08, 2017 at 06:32:35PM +0000, John Baldwin wrote: > > > > > > > Author: jhb > > > > Date: Wed Feb 8 18:32:35 2017 > > > > New Revision: 313450 > > > > URL: https://svnweb.freebsd.org/changeset/base/313450 > > > > > > > > Log: > > > > MFC 310638: > > > > Rename the 'flags' argument to getfsstat() to 'mode' and validate it. > > > > > > > > This argument is not a bitmask of flags, but only accepts a single value. > > > > Fail with EINVAL if an invalid value is passed to 'flag'. Rename the > > > > 'flags' argument to getmntinfo(3) to 'mode' as well to match. > > > > > > > > This is a followup to r308088. > > > > > > > kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize, > > > > - size_t *countp, enum uio_seg bufseg, int flags) > > > > + size_t *countp, enum uio_seg bufseg, int mode) > > > > { > > > > struct mount *mp, *nmp; > > > > struct statfs *sfsp, *sp, *sptmp, *tofree; > > > > size_t count, maxcount; > > > > int error; > > > > > > > > + switch (mode) { > > > > + case MNT_WAIT: > > > > + case MNT_NOWAIT: > > > > + break; > > > > + default: > > > > + return (EINVAL); > > > > + } > > > > restart: > > > > > > This is break net-snmp UCD-SNMP-MIB::dskTable oid: > > > > > > 82434 snmpd CALL getfsstat(0,0,) > > > 82434 snmpd RET getfsstat -1 errno 22 Invalid argument > > > 82434 snmpd CALL getfsstat(0,0xfffffffffffffe28,MNT_NOWAIT) > > > 82434 snmpd RET getfsstat -1 errno 22 Invalid argument > > > 82434 snmpd CALL write(0x9,0x800f162ea,0x1) > > > void > netsnmp_fsys_arch_load( void ) > { > int n, i; > struct NSFS_STATFS *stats; > netsnmp_fsys_info *entry; > > /* > * Retrieve information about the currently mounted filesystems... > */ > n = NSFS_GETFSSTAT( NULL, 0, 0 ); > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Ah, thanks. I've created a bug with a patch to the port (218011). Would you be able to verify the patch works correctly? It changes this call to use MNT_NOWAIT. -- John Baldwin From owner-svn-src-stable-11@freebsd.org Wed Mar 22 17:46:09 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7B904D18D19; Wed, 22 Mar 2017 17:46:09 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 47DE315CA; Wed, 22 Mar 2017 17:46:09 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2MHk8PO027952; Wed, 22 Mar 2017 17:46:08 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2MHk8f2027951; Wed, 22 Mar 2017 17:46:08 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201703221746.v2MHk8f2027951@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Wed, 22 Mar 2017 17:46:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315721 - stable/11/bin/kill X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Mar 2017 17:46:09 -0000 Author: bdrewery Date: Wed Mar 22 17:46:08 2017 New Revision: 315721 URL: https://svnweb.freebsd.org/changeset/base/315721 Log: MFC r314714: Don't kill pid -1 on overflow from strtol(3). Modified: stable/11/bin/kill/kill.c Directory Properties: stable/11/ (props changed) Modified: stable/11/bin/kill/kill.c ============================================================================== --- stable/11/bin/kill/kill.c Wed Mar 22 17:37:47 2017 (r315720) +++ stable/11/bin/kill/kill.c Wed Mar 22 17:46:08 2017 (r315721) @@ -66,7 +66,9 @@ static void usage(void); int main(int argc, char *argv[]) { - int errors, numsig, pid, ret; + long pidl; + pid_t pid; + int errors, numsig, ret; char *ep; if (argc < 2) @@ -137,8 +139,10 @@ main(int argc, char *argv[]) else #endif { - pid = strtol(*argv, &ep, 10); - if (!**argv || *ep) + pidl = strtol(*argv, &ep, 10); + /* Check for overflow of pid_t. */ + pid = (pid_t)pidl; + if (!**argv || *ep || pid != pidl) errx(2, "illegal process id: %s", *argv); ret = kill(pid, numsig); } From owner-svn-src-stable-11@freebsd.org Wed Mar 22 17:53:27 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DCB5AD18F9B; Wed, 22 Mar 2017 17:53:27 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A0A3A1CCC; Wed, 22 Mar 2017 17:53:27 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2MHrQlY032022; Wed, 22 Mar 2017 17:53:26 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2MHrPUD032012; Wed, 22 Mar 2017 17:53:25 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201703221753.v2MHrPUD032012@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Wed, 22 Mar 2017 17:53:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315723 - in stable/11: . bin/pwait bin/pwait/tests etc/mtree targets/pseudo/tests usr.bin/timeout/tests X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Mar 2017 17:53:28 -0000 Author: bdrewery Date: Wed Mar 22 17:53:25 2017 New Revision: 315723 URL: https://svnweb.freebsd.org/changeset/base/315723 Log: MFC r314886,r314943,r314944: r314886: pwait: Add a -t flag to specify a timeout before exiting, and tests. r314943: Remove unneeded -x from tests. r314944: Rename some tests to end in _test. Added: stable/11/bin/pwait/tests/ - copied from r314886, head/bin/pwait/tests/ stable/11/bin/pwait/tests/pwait_test.sh - copied unchanged from r314944, head/bin/pwait/tests/pwait_test.sh stable/11/usr.bin/timeout/tests/timeout_test.sh - copied unchanged from r314944, head/usr.bin/timeout/tests/timeout_test.sh Deleted: stable/11/bin/pwait/tests/pwait.sh stable/11/usr.bin/timeout/tests/timeout.sh Modified: stable/11/ObsoleteFiles.inc stable/11/bin/pwait/Makefile stable/11/bin/pwait/pwait.1 stable/11/bin/pwait/pwait.c stable/11/bin/pwait/tests/Makefile stable/11/etc/mtree/BSD.tests.dist stable/11/targets/pseudo/tests/Makefile.depend stable/11/usr.bin/timeout/tests/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/ObsoleteFiles.inc ============================================================================== --- stable/11/ObsoleteFiles.inc Wed Mar 22 17:49:56 2017 (r315722) +++ stable/11/ObsoleteFiles.inc Wed Mar 22 17:53:25 2017 (r315723) @@ -38,6 +38,9 @@ # xargs -n1 | sort | uniq -d; # done +# 20170308: rename some tests +OLD_FILES+=usr/tests/bin/pwait/pwait +OLD_FILES+=usr/tests/usr.bin/timeout/timeout # 20170214: Four files from ggate tests consolidated into one OLD_FILES+=usr/tests/sys/geom/class/gate/1_test OLD_FILES+=usr/tests/sys/geom/class/gate/2_test Modified: stable/11/bin/pwait/Makefile ============================================================================== --- stable/11/bin/pwait/Makefile Wed Mar 22 17:49:56 2017 (r315722) +++ stable/11/bin/pwait/Makefile Wed Mar 22 17:53:25 2017 (r315723) @@ -1,6 +1,12 @@ # $FreeBSD$ +.include + PACKAGE=runtime PROG= pwait +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif + .include Modified: stable/11/bin/pwait/pwait.1 ============================================================================== --- stable/11/bin/pwait/pwait.1 Wed Mar 22 17:49:56 2017 (r315722) +++ stable/11/bin/pwait/pwait.1 Wed Mar 22 17:53:25 2017 (r315723) @@ -32,7 +32,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 1, 2009 +.Dd March 7, 2017 .Dt PWAIT 1 .Os .Sh NAME @@ -40,6 +40,7 @@ .Nd wait for processes to terminate .Sh SYNOPSIS .Nm +.Op Fl t Ar duration .Op Fl v .Ar pid \&... @@ -50,13 +51,36 @@ utility will wait until each of the give .Pp The following option is available: .Bl -tag -width indent +.It Fl t Ar duration +If any process is still running after +.Ar duration , +.Nm +will exit. +The +.Ar duration +value can be integer or decimal numbers. +Values without unit symbols are interpreted as seconds. +.Pp +Supported unit symbols are: +.Bl -tag -width indent -compact +.It s +seconds +.It m +minutes +.It h +hours +.El .It Fl v Print the exit status when each process terminates. .El -.Sh DIAGNOSTICS +.Sh EXIT STATUS The .Nm -utility returns 0 on success, and >0 if an error occurs. +utility exits 0 on success, and >0 if an error occurs. +.Pp +If the +.Fl t +flag is specified and a timeout occurs, the exit status will be 124. .Pp Invalid pids elicit a warning message but are otherwise ignored. .Sh SEE ALSO Modified: stable/11/bin/pwait/pwait.c ============================================================================== --- stable/11/bin/pwait/pwait.c Wed Mar 22 17:49:56 2017 (r315722) +++ stable/11/bin/pwait/pwait.c Wed Mar 22 17:53:25 2017 (r315723) @@ -53,7 +53,7 @@ static void usage(void) { - fprintf(stderr, "usage: pwait [-v] pid ...\n"); + fprintf(stderr, "usage: pwait [-t timeout] [-v] pid ...\n"); exit(EX_USAGE); } @@ -63,15 +63,46 @@ usage(void) int main(int argc, char *argv[]) { + struct itimerval itv; int kq; struct kevent *e; - int verbose = 0; + int tflag, verbose; int opt, nleft, n, i, duplicate, status; long pid; char *s, *end; + double timeout; - while ((opt = getopt(argc, argv, "v")) != -1) { + tflag = verbose = 0; + memset(&itv, 0, sizeof(itv)); + while ((opt = getopt(argc, argv, "t:v")) != -1) { switch (opt) { + case 't': + tflag = 1; + errno = 0; + timeout = strtod(optarg, &end); + if (end == optarg || errno == ERANGE || + timeout < 0) + errx(EX_DATAERR, "timeout value"); + switch(*end) { + case 0: + case 's': + break; + case 'h': + timeout *= 60; + /* FALLTHROUGH */ + case 'm': + timeout *= 60; + break; + default: + errx(EX_DATAERR, "timeout unit"); + } + if (timeout > 100000000L) + errx(EX_DATAERR, "timeout value"); + itv.it_value.tv_sec = (time_t)timeout; + timeout -= (time_t)timeout; + itv.it_value.tv_usec = + (suseconds_t)(timeout * 1000000UL); + break; case 'v': verbose = 1; break; @@ -91,7 +122,7 @@ main(int argc, char *argv[]) if (kq == -1) err(1, "kqueue"); - e = malloc(argc * sizeof(struct kevent)); + e = malloc((argc + tflag) * sizeof(struct kevent)); if (e == NULL) err(1, "malloc"); nleft = 0; @@ -119,12 +150,30 @@ main(int argc, char *argv[]) } } + if (tflag) { + /* + * Explicitly detect SIGALRM so that an exit status of 124 + * can be returned rather than 142. + */ + EV_SET(e + nleft, SIGALRM, EVFILT_SIGNAL, EV_ADD, 0, 0, NULL); + if (kevent(kq, e + nleft, 1, NULL, 0, NULL) == -1) + err(EX_OSERR, "kevent"); + /* Ignore SIGALRM to not interrupt kevent(2). */ + signal(SIGALRM, SIG_IGN); + if (setitimer(ITIMER_REAL, &itv, NULL) == -1) + err(EX_OSERR, "setitimer"); + } while (nleft > 0) { - n = kevent(kq, NULL, 0, e, nleft, NULL); + n = kevent(kq, NULL, 0, e, nleft + tflag, NULL); if (n == -1) err(1, "kevent"); - if (verbose) - for (i = 0; i < n; i++) { + for (i = 0; i < n; i++) { + if (e[i].filter == EVFILT_SIGNAL) { + if (verbose) + printf("timeout\n"); + return (124); + } + if (verbose) { status = e[i].data; if (WIFEXITED(status)) printf("%ld: exited with status %d.\n", @@ -138,7 +187,8 @@ main(int argc, char *argv[]) printf("%ld: terminated.\n", (long)e[i].ident); } - nleft -= n; + --nleft; + } } exit(EX_OK); Modified: stable/11/bin/pwait/tests/Makefile ============================================================================== --- head/bin/pwait/tests/Makefile Tue Mar 7 22:16:55 2017 (r314886) +++ stable/11/bin/pwait/tests/Makefile Wed Mar 22 17:53:25 2017 (r315723) @@ -1,5 +1,5 @@ # $FreeBSD$ -ATF_TESTS_SH= pwait +ATF_TESTS_SH= pwait_test .include Copied: stable/11/bin/pwait/tests/pwait_test.sh (from r314944, head/bin/pwait/tests/pwait_test.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/bin/pwait/tests/pwait_test.sh Wed Mar 22 17:53:25 2017 (r315723, copy of r314944, head/bin/pwait/tests/pwait_test.sh) @@ -0,0 +1,242 @@ +# $FreeBSD$ + +atf_test_case basic +basic_head() +{ + atf_set "descr" "Basic tests on pwait(1) utility" +} + +basic_body() +{ + sleep 1 & + p1=$! + + sleep 5 & + p5=$! + + sleep 10 & + p10=$! + + atf_check \ + -o empty \ + -e empty \ + -s exit:0 \ + timeout --preserve-status 15 pwait $p1 $p5 $p10 + + atf_check \ + -o empty \ + -e inline:"kill: $p1: No such process\n" \ + -s exit:1 \ + kill -0 $p1 + + atf_check \ + -o empty \ + -e inline:"kill: $p5: No such process\n" \ + -s exit:1 \ + kill -0 $p5 + + atf_check \ + -o empty \ + -e inline:"kill: $p10: No such process\n" \ + -s exit:1 \ + kill -0 $p10 + +} + +basic_cleanup() +{ + kill $p1 $p5 $p10 >/dev/null 2>&1 + wait $p1 $p5 $p10 >/dev/null 2>&1 +} + +atf_test_case time_unit +time_unit_head() +{ + atf_set "descr" "Test parsing the timeout unit and value" +} + +time_unit_body() +{ + init=1 + + atf_check \ + -o empty \ + -e inline:"pwait: timeout unit\n" \ + -s exit:65 \ + timeout --preserve-status 2 pwait -t 1d $init + + atf_check \ + -o empty \ + -e inline:"pwait: timeout unit\n" \ + -s exit:65 \ + timeout --preserve-status 2 pwait -t 1d $init + + atf_check \ + -o empty \ + -e inline:"pwait: timeout value\n" \ + -s exit:65 \ + timeout --preserve-status 2 pwait -t -1 $init + + atf_check \ + -o empty \ + -e inline:"pwait: timeout value\n" \ + -s exit:65 \ + timeout --preserve-status 2 pwait -t 100000001 $init + + # These long duration cases are expected to timeout from the + # timeout utility rather than pwait -t. + atf_check \ + -o empty \ + -e empty \ + -s exit:143 \ + timeout --preserve-status 2 pwait -t 100000000 $init + + atf_check \ + -o empty \ + -e empty \ + -s exit:143 \ + timeout --preserve-status 2 pwait -t 1h $init + + atf_check \ + -o empty \ + -e empty \ + -s exit:143 \ + timeout --preserve-status 2 pwait -t 1.5h $init + + atf_check \ + -o empty \ + -e empty \ + -s exit:143 \ + timeout --preserve-status 2 pwait -t 1m $init + + atf_check \ + -o empty \ + -e empty \ + -s exit:143 \ + timeout --preserve-status 2 pwait -t 1.5m $init + + atf_check \ + -o empty \ + -e empty \ + -s exit:143 \ + timeout --preserve-status 2 pwait -t 0 $init + + # The rest are fast enough that pwait -t is expected to trigger + # the timeout. + atf_check \ + -o empty \ + -e empty \ + -s exit:124 \ + timeout --preserve-status 2 pwait -t 1s $init + + atf_check \ + -o empty \ + -e empty \ + -s exit:124 \ + timeout --preserve-status 2 pwait -t 1.5s $init + + atf_check \ + -o empty \ + -e empty \ + -s exit:124 \ + timeout --preserve-status 2 pwait -t 1 $init + + atf_check \ + -o empty \ + -e empty \ + -s exit:124 \ + timeout --preserve-status 2 pwait -t 1.5 $init + + atf_check \ + -o empty \ + -e empty \ + -s exit:124 \ + timeout --preserve-status 2 pwait -t 0.5 $init +} + +atf_test_case timeout_trigger_timeout +timeout_trigger_timeout_head() +{ + atf_set "descr" "Test that exceeding the timeout is detected" +} + +timeout_trigger_timeout_body() +{ + sleep 10 & + p10=$! + + atf_check \ + -o empty \ + -e empty \ + -s exit:124 \ + timeout --preserve-status 6.5 pwait -t 5 $p10 +} + +timeout_trigger_timeout_cleanup() +{ + kill $p10 >/dev/null 2>&1 + wait $p10 >/dev/null 2>&1 +} + +atf_test_case timeout_no_timeout +timeout_no_timeout_head() +{ + atf_set "descr" "Test that not exceeding the timeout continues to wait" +} + +timeout_no_timeout_body() +{ + sleep 10 & + p10=$! + + atf_check \ + -o empty \ + -e empty \ + -s exit:0 \ + timeout --preserve-status 11.5 pwait -t 12 $p10 +} + +timeout_no_timeout_cleanup() +{ + kill $p10 >/dev/null 2>&1 + wait $p10 >/dev/null 2>&1 +} + +atf_test_case timeout_many +timeout_many_head() +{ + atf_set "descr" "Test timeout on many processes" +} + +timeout_many_body() +{ + sleep 1 & + p1=$! + + sleep 5 & + p5=$! + + sleep 10 & + p10=$! + + atf_check \ + -o empty \ + -e empty \ + -s exit:124 \ + timeout --preserve-status 7.5 pwait -t 6 $p1 $p5 $p10 +} + +timeout_many_cleanup() +{ + kill $p1 $p5 $p10 >/dev/null 2>&1 + wait $p1 $p5 $p10 >/dev/null 2>&1 +} + +atf_init_test_cases() +{ + atf_add_test_case basic + atf_add_test_case time_unit + atf_add_test_case timeout_trigger_timeout + atf_add_test_case timeout_no_timeout + atf_add_test_case timeout_many +} Modified: stable/11/etc/mtree/BSD.tests.dist ============================================================================== --- stable/11/etc/mtree/BSD.tests.dist Wed Mar 22 17:49:56 2017 (r315722) +++ stable/11/etc/mtree/BSD.tests.dist Wed Mar 22 17:53:25 2017 (r315723) @@ -626,6 +626,8 @@ .. printf .. + pwait + .. sdiff .. sed Modified: stable/11/targets/pseudo/tests/Makefile.depend ============================================================================== --- stable/11/targets/pseudo/tests/Makefile.depend Wed Mar 22 17:49:56 2017 (r315722) +++ stable/11/targets/pseudo/tests/Makefile.depend Wed Mar 22 17:53:25 2017 (r315723) @@ -307,6 +307,7 @@ DIRDEPS= \ usr.bin/mkimg/tests \ usr.bin/ncal/tests \ usr.bin/printf/tests \ + usr.bin/pwait/tests \ usr.bin/sdiff/tests \ usr.bin/sed/tests \ usr.bin/sed/tests/regress.multitest.out \ Modified: stable/11/usr.bin/timeout/tests/Makefile ============================================================================== --- stable/11/usr.bin/timeout/tests/Makefile Wed Mar 22 17:49:56 2017 (r315722) +++ stable/11/usr.bin/timeout/tests/Makefile Wed Mar 22 17:53:25 2017 (r315723) @@ -1,5 +1,5 @@ # $FreeBSD$ -ATF_TESTS_SH= timeout +ATF_TESTS_SH= timeout_test .include Copied: stable/11/usr.bin/timeout/tests/timeout_test.sh (from r314944, head/usr.bin/timeout/tests/timeout_test.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/usr.bin/timeout/tests/timeout_test.sh Wed Mar 22 17:53:25 2017 (r315723, copy of r314944, head/usr.bin/timeout/tests/timeout_test.sh) @@ -0,0 +1,215 @@ +# $FreeBSD$ + +atf_test_case nominal +nominal_head() +{ + atf_set "descr" "Basic tests on timeout(1) utility" +} + +nominal_body() +{ + atf_check \ + -o empty \ + -e empty \ + -s exit:0 \ + timeout 5 true +} + +atf_test_case time_unit +time_unit_head() +{ + atf_set "descr" "Test parsing the default time unit" +} + +time_unit_body() +{ + atf_check \ + -o empty \ + -e empty \ + -s exit:0 \ + timeout 1d true + + atf_check \ + -o empty \ + -e empty \ + -s exit:0 \ + timeout 1h true + + atf_check \ + -o empty \ + -e empty \ + -s exit:0 \ + timeout 1m true + + atf_check \ + -o empty \ + -e empty \ + -s exit:0 \ + timeout 1s true +} + +atf_test_case no_timeout +no_timeout_head() +{ + atf_set "descr" "Test disabled timeout" +} + +no_timeout_body() +{ + atf_check \ + -o empty \ + -e empty \ + -s exit:0 \ + timeout 0 true +} + +atf_test_case exit_numbers +exit_numbers_head() +{ + atf_set "descr" "Test exit numbers" +} + +exit_numbers_body() +{ + atf_check \ + -o empty \ + -e empty \ + -s exit:2 \ + -x timeout 5 sh -c \'exit 2\' + + atf_check \ + -o empty \ + -e empty \ + -s exit:124 \ + timeout .1 sleep 1 + + # With preserv status exit should be 128 + TERM aka 143 + atf_check \ + -o empty \ + -e empty \ + -s exit:143 \ + timeout --preserve-status .1 sleep 10 + + atf_check \ + -o empty \ + -e empty \ + -s exit:124 \ + timeout -s1 -k1 .1 sleep 10 + + atf_check \ + -o empty \ + -e empty \ + -s exit:0 \ + -x sh -c 'trap "" CHLD; exec timeout 10 true' +} + +atf_test_case with_a_child +with_a_child_head() +{ + atf_set "descr" "When starting with a child (coreutils bug#9098)" +} + +with_a_child_body() +{ + out=$(sleep .1 & exec timeout .5 sh -c 'sleep 2; echo foo') + status=$? + test "$out" = "" && test $status = 124 || atf_fail + +} + +atf_test_case invalid_timeout +invalid_timeout_head() +{ + atf_set "descr" "Invalid timeout" +} + +invalid_timeout_body() +{ + atf_check \ + -o empty \ + -e inline:"timeout: invalid duration\n" \ + -s exit:125 \ + timeout invalid sleep 0 + + atf_check \ + -o empty \ + -e inline:"timeout: invalid duration\n" \ + -s exit:125 \ + timeout --kill-after=invalid 1 sleep 0 + + atf_check \ + -o empty \ + -e inline:"timeout: invalid duration\n" \ + -s exit:125 \ + timeout 42D sleep 0 + + atf_check \ + -o empty \ + -e inline:"timeout: invalid duration\n" \ + -s exit:125 \ + timeout 999999999999999999999999999999999999999999999999999999999999d sleep 0 + + atf_check \ + -o empty \ + -e inline:"timeout: invalid duration\n" \ + -s exit:125 \ + timeout 2.34e+5d sleep 0 +} + +atf_test_case invalid_signal +invalid_signal_head() +{ + atf_set "descr" "Invalid signal" +} + +invalid_signal_body() +{ + atf_check \ + -o empty \ + -e inline:"timeout: invalid signal\n" \ + -s exit:125 \ + timeout --signal=invalid 1 sleep 0 +} + +atf_test_case invalid_command +invalid_command_head() +{ + atf_set "descr" "Invalid command" +} + +invalid_command_body() +{ + atf_check \ + -o empty \ + -e inline:"timeout: exec(.): Permission denied\n" \ + -s exit:126 \ + timeout 10 . +} + +atf_test_case no_such_command +no_such_command_head() +{ + atf_set "descr" "No such command" +} + +no_such_command_body() +{ + atf_check \ + -o empty \ + -e inline:"timeout: exec(enoexists): No such file or directory\n" \ + -s exit:127 \ + timeout 10 enoexists +} + +atf_init_test_cases() +{ + atf_add_test_case nominal + atf_add_test_case time_unit + atf_add_test_case no_timeout + atf_add_test_case exit_numbers + atf_add_test_case with_a_child + atf_add_test_case invalid_timeout + atf_add_test_case invalid_signal + atf_add_test_case invalid_command + atf_add_test_case no_such_command +} From owner-svn-src-stable-11@freebsd.org Wed Mar 22 17:56:48 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7345ED17038; Wed, 22 Mar 2017 17:56:48 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 294E11E44; Wed, 22 Mar 2017 17:56:48 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2MHulRq032209; Wed, 22 Mar 2017 17:56:47 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2MHulhV032207; Wed, 22 Mar 2017 17:56:47 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201703221756.v2MHulhV032207@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Wed, 22 Mar 2017 17:56:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315724 - in stable/11: . lib/libmd X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Mar 2017 17:56:48 -0000 Author: bdrewery Date: Wed Mar 22 17:56:46 2017 New Revision: 315724 URL: https://svnweb.freebsd.org/changeset/base/315724 Log: MFC r314709,r314790,r314794: r314709: Fix bootstrapping mtree after r313404 for older systems. r314790: Added comments for why nmtree/libmd are bootstrapped. r314794: Fix bootstrapping libmd on older systems after r314709. PR: 217673 Modified: stable/11/Makefile.inc1 stable/11/lib/libmd/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/Makefile.inc1 ============================================================================== --- stable/11/Makefile.inc1 Wed Mar 22 17:53:25 2017 (r315723) +++ stable/11/Makefile.inc1 Wed Mar 22 17:56:46 2017 (r315724) @@ -1583,10 +1583,14 @@ ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd ${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4 .endif -.if ${BOOTSTRAPPING} < 1000026 -_nmtree= lib/libnetbsd \ +# r245440 mtree -N support added +# r313404 requires sha384.h for libnetbsd, added to libmd in r292782 +.if ${BOOTSTRAPPING} < 1100093 +_nmtree= lib/libmd \ + lib/libnetbsd \ usr.sbin/nmtree +${_bt}-lib/libnetbsd: ${_bt}-lib/libmd ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd .endif Modified: stable/11/lib/libmd/Makefile ============================================================================== --- stable/11/lib/libmd/Makefile Wed Mar 22 17:53:25 2017 (r315723) +++ stable/11/lib/libmd/Makefile Wed Mar 22 17:56:46 2017 (r315724) @@ -72,6 +72,13 @@ CLEANFILES+= md[245]hl.c md[245].ref md[ skein256.ref skein512.ref skein1024.ref \ skeindriver +# Need src tree sys/md5.h for MD5FileChunk prototype on older systems. +SRCS+= sys/md5.h +CLEANDIRS= sys +CFLAGS+= -I. +sys/md5.h: ${SRCTOP}/sys/${.TARGET} .NOMETA + ln -sf ${.ALLSRC} ${.TARGET} + # Define WEAK_REFS to provide weak aliases for libmd symbols # # Note that the same sources are also used internally by libcrypt, From owner-svn-src-stable-11@freebsd.org Wed Mar 22 18:12:50 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2A02CD179B2; Wed, 22 Mar 2017 18:12:50 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EACF71D8C; Wed, 22 Mar 2017 18:12:49 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2MICnt1040714; Wed, 22 Mar 2017 18:12:49 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2MICncq040713; Wed, 22 Mar 2017 18:12:49 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201703221812.v2MICncq040713@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Wed, 22 Mar 2017 18:12:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315725 - stable/11/lib/libc/gen X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Mar 2017 18:12:50 -0000 Author: pfg Date: Wed Mar 22 18:12:48 2017 New Revision: 315725 URL: https://svnweb.freebsd.org/changeset/base/315725 Log: MFC r315720 (from cem@) scandir: Fix NULL dereference, uninitialized value use in error case This bug was introduced in r315095. Given that it obviously is a bug and we can't afford to have such creatures in libc, do an early merge, Reported by: Coverity CIDs: 1329566, 1372625 Sponsored by: Dell EMC Isilon Modified: stable/11/lib/libc/gen/scandir.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/gen/scandir.c ============================================================================== --- stable/11/lib/libc/gen/scandir.c Wed Mar 22 17:56:46 2017 (r315724) +++ stable/11/lib/libc/gen/scandir.c Wed Mar 22 18:12:48 2017 (r315725) @@ -89,12 +89,12 @@ scandir(const char *dirname, struct dire if ((dirp = opendir(dirname)) == NULL) return(-1); + numitems = 0; arraysz = 32; /* initial estimate of the array size */ names = (struct dirent **)malloc(arraysz * sizeof(struct dirent *)); if (names == NULL) goto fail; - numitems = 0; while ((d = readdir(dirp)) != NULL) { if (select != NULL && !SELECT(d)) continue; /* just selected names */ From owner-svn-src-stable-11@freebsd.org Wed Mar 22 18:28:10 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 07C30D181ED for ; Wed, 22 Mar 2017 18:28:10 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1.freebsd.org (Postfix) with SMTP id C3B1C1E5C for ; Wed, 22 Mar 2017 18:28:09 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: (qmail 91025 invoked by uid 99); 22 Mar 2017 18:28:08 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Mar 2017 18:28:08 +0000 Received: from [192.168.0.104] (unknown [190.157.139.67]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id DA77C1A0193; Wed, 22 Mar 2017 18:28:07 +0000 (UTC) From: Pedro Giffuni Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.2 \(3259\)) Subject: Re: svn commit: r315725 - stable/11/lib/libc/gen Date: Wed, 22 Mar 2017 13:28:24 -0500 References: <201703221812.v2MICncq040713@repo.freebsd.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org In-Reply-To: <201703221812.v2MICncq040713@repo.freebsd.org> Message-Id: <826A8703-3697-4DB6-9651-32A96A36AD9E@FreeBSD.org> X-Mailer: Apple Mail (2.3259) X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Mar 2017 18:28:10 -0000 > Il giorno 22 mar 2017, alle ore 13:12, Pedro F. Giffuni = ha scritto: >=20 > Author: pfg > Date: Wed Mar 22 18:12:48 2017 > New Revision: 315725 > URL: https://svnweb.freebsd.org/changeset/base/315725 >=20 > Log: > MFC r315720 (from cem@) > scandir: Fix NULL dereference, uninitialized value use in error case >=20 > This bug was introduced in r315095. Given that it obviously is a bug = and > we can't afford to have such creatures in libc, do an early merge, >=20 This deserves further explanation: it was done now, before the regular 3 = days before MFC because I will be doing a highly risky operation in my HD (MBR=E2=80=94> = GPT) and may not be able to respond in a while. It is well know cem@ doesn=E2=80=99t do MFCs and the bug was obvious = enough that we wanted it so now was better than in an undetermined future. Pedro. > Reported by: Coverity > CIDs: 1329566, 1372625 > Sponsored by: Dell EMC Isilon >=20 > Modified: > stable/11/lib/libc/gen/scandir.c > Directory Properties: > stable/11/ (props changed) >=20 > Modified: stable/11/lib/libc/gen/scandir.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- stable/11/lib/libc/gen/scandir.c Wed Mar 22 17:56:46 2017 = (r315724) > +++ stable/11/lib/libc/gen/scandir.c Wed Mar 22 18:12:48 2017 = (r315725) > @@ -89,12 +89,12 @@ scandir(const char *dirname, struct dire > if ((dirp =3D opendir(dirname)) =3D=3D NULL) > return(-1); >=20 > + numitems =3D 0; > arraysz =3D 32; /* initial estimate of the array size */ > names =3D (struct dirent **)malloc(arraysz * sizeof(struct = dirent *)); > if (names =3D=3D NULL) > goto fail; >=20 > - numitems =3D 0; > while ((d =3D readdir(dirp)) !=3D NULL) { > if (select !=3D NULL && !SELECT(d)) > continue; /* just selected names */ >=20 From owner-svn-src-stable-11@freebsd.org Thu Mar 23 04:47:58 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9C841D19FE4; Thu, 23 Mar 2017 04:47:58 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 67AE011B0; Thu, 23 Mar 2017 04:47:58 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N4lvoZ005991; Thu, 23 Mar 2017 04:47:57 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N4lvxY005990; Thu, 23 Mar 2017 04:47:57 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703230447.v2N4lvxY005990@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Thu, 23 Mar 2017 04:47:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315782 - stable/11/rescue/rescue X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 04:47:58 -0000 Author: ngie Date: Thu Mar 23 04:47:57 2017 New Revision: 315782 URL: https://svnweb.freebsd.org/changeset/base/315782 Log: MFC r315654: Fix linking /rescue/rescue to multiple programs in usr.bin after r315113 I meant for the line that conditionally added in /usr/bin/nc support to be `+=', not `=`. This restores hardlinks for all programs in usr.bin specified before nc(1), e.g., bunzip2 and tar. Pointyhat to: ngie Modified: stable/11/rescue/rescue/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/rescue/rescue/Makefile ============================================================================== --- stable/11/rescue/rescue/Makefile Thu Mar 23 04:47:43 2017 (r315781) +++ stable/11/rescue/rescue/Makefile Thu Mar 23 04:47:57 2017 (r315782) @@ -214,7 +214,7 @@ CRUNCH_LIBS+= -lcrypto CRUNCH_LIBS+= -lmd .if ${MK_NETCAT} != "no" -CRUNCH_PROGS_usr.bin= nc +CRUNCH_PROGS_usr.bin+= nc .endif .if ${MK_VI} != "no" From owner-svn-src-stable-11@freebsd.org Thu Mar 23 04:49:35 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3D1A0D190EA; Thu, 23 Mar 2017 04:49:35 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E3D751370; Thu, 23 Mar 2017 04:49:34 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N4nX2G006154; Thu, 23 Mar 2017 04:49:33 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N4nXHo006152; Thu, 23 Mar 2017 04:49:33 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703230449.v2N4nXHo006152@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Thu, 23 Mar 2017 04:49:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315783 - stable/11/lib/libkvm X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 04:49:35 -0000 Author: ngie Date: Thu Mar 23 04:49:33 2017 New Revision: 315783 URL: https://svnweb.freebsd.org/changeset/base/315783 Log: MFC r315362,r315363,r315365: r315362: Capitalize .Dt macro argument By convention, per mdoc(7), the document title should be all caps. r315363: Fix manlint errors - Add missing comma after kvm_dpcpu_setcpu .Nm macro use (multiple .Nm entries should be separated by commas) - Add missing section for kvm_dpcpu_setcpu Xr. r315365: Tweak r315363 slightly I noticed after commit that kvm_dpcpu_setcpu was defined in the manpage. Thus, the correct macro for the function reference is .Fn, not .Xr. Modified: stable/11/lib/libkvm/kvm_getpcpu.3 stable/11/lib/libkvm/kvm_native.3 Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libkvm/kvm_getpcpu.3 ============================================================================== --- stable/11/lib/libkvm/kvm_getpcpu.3 Thu Mar 23 04:47:57 2017 (r315782) +++ stable/11/lib/libkvm/kvm_getpcpu.3 Thu Mar 23 04:49:33 2017 (r315783) @@ -28,11 +28,11 @@ .\" .\" $FreeBSD$ .\" -.Dd February 12, 2014 +.Dd March 15, 2017 .Dt KVM_GETPCPU 3 .Os .Sh NAME -.Nm kvm_dpcpu_setcpu +.Nm kvm_dpcpu_setcpu , .Nm kvm_getmaxcpu , .Nm kvm_getpcpu .Nd access per-CPU data @@ -120,7 +120,7 @@ Symbols for dynamic per-CPU data are acc as with other symbols. .Nm libkvm maintains a notion of the "current CPU", set by -.Xr kvm_dpcpu_setcpu , +.Fn kvm_dpcpu_setcpu , which defaults to 0. Once another CPU is selected, .Xr kvm_nlist 3 Modified: stable/11/lib/libkvm/kvm_native.3 ============================================================================== --- stable/11/lib/libkvm/kvm_native.3 Thu Mar 23 04:47:57 2017 (r315782) +++ stable/11/lib/libkvm/kvm_native.3 Thu Mar 23 04:49:33 2017 (r315783) @@ -25,8 +25,8 @@ .\" .\" $FreeBSD$ .\" -.Dd November 27, 2015 -.Dt kvm_native 3 +.Dd March 15, 2017 +.Dt KVM_NATIVE 3 .Os .Sh NAME .Nm kvm_native From owner-svn-src-stable-11@freebsd.org Thu Mar 23 04:50:46 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 04153D191C3; Thu, 23 Mar 2017 04:50:46 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B4D491571; Thu, 23 Mar 2017 04:50:45 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N4oiY6006366; Thu, 23 Mar 2017 04:50:44 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N4oiG1006365; Thu, 23 Mar 2017 04:50:44 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703230450.v2N4oiG1006365@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Thu, 23 Mar 2017 04:50:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315785 - stable/11/lib/libkvm X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 04:50:46 -0000 Author: ngie Date: Thu Mar 23 04:50:44 2017 New Revision: 315785 URL: https://svnweb.freebsd.org/changeset/base/315785 Log: MFC r315360: Return NULL instead of 0 on failure in _kvm_open, kvm_open{,2,files} This is being done for the following reasons: - kvm_open(3), etc says they will return NULL. - NULL by definition is (void*)0 per POSIX, but can be redefined, depending on the compiler, etc. Modified: stable/11/lib/libkvm/kvm.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libkvm/kvm.c ============================================================================== --- stable/11/lib/libkvm/kvm.c Thu Mar 23 04:50:38 2017 (r315784) +++ stable/11/lib/libkvm/kvm.c Thu Mar 23 04:50:44 2017 (r315785) @@ -479,7 +479,7 @@ failed: if (errout != NULL) strlcpy(errout, kd->errbuf, _POSIX2_LINE_MAX); (void)kvm_close(kd); - return (0); + return (NULL); } kvm_t * @@ -492,7 +492,7 @@ kvm_openfiles(const char *uf, const char if (errout != NULL) (void)strlcpy(errout, strerror(errno), _POSIX2_LINE_MAX); - return (0); + return (NULL); } return (_kvm_open(kd, uf, mf, flag, errout)); } @@ -507,7 +507,7 @@ kvm_open(const char *uf, const char *mf, if (errstr != NULL) (void)fprintf(stderr, "%s: %s\n", errstr, strerror(errno)); - return (0); + return (NULL); } kd->program = errstr; return (_kvm_open(kd, uf, mf, flag, NULL)); @@ -523,7 +523,7 @@ kvm_open2(const char *uf, const char *mf if (errout != NULL) (void)strlcpy(errout, strerror(errno), _POSIX2_LINE_MAX); - return (0); + return (NULL); } kd->resolve_symbol = resolver; return (_kvm_open(kd, uf, mf, flag, errout)); From owner-svn-src-stable-11@freebsd.org Thu Mar 23 05:03:58 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DCFDBD19B87; Thu, 23 Mar 2017 05:03:58 +0000 (UTC) (envelope-from aryeh.friedman@gmail.com) Received: from mail-io0-x22d.google.com (mail-io0-x22d.google.com [IPv6:2607:f8b0:4001:c06::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 713C1138A; Thu, 23 Mar 2017 05:03:58 +0000 (UTC) (envelope-from aryeh.friedman@gmail.com) Received: by mail-io0-x22d.google.com with SMTP id f84so75964687ioj.0; Wed, 22 Mar 2017 22:03:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=LZDN3XvNM+VfMpvJ3GcqJbjqncEAnWvH5CxoKa/5h/0=; b=Yln3/g7MBRUI2Cn86kHg/DNYCPNcSTOgmEVtuqo3OHggEGQy6SEXXr2iiuGyYhSxfL e1fOI1DaGVQValPD5MFUHSd8+CYUP6K7nW3sKhBKPCU3sy22bc2TNPH0nU0er9y6Pb8d eeTfw0wOhhGkwQT9ibPU3d4ADLrMdEJbLyPz6tu5tv9V1vD5aCDFQJZjwHYI/7jZ+Yjp wLgefttDoaVdXGpH4F9ybTx2r1ZCol6eAg6RuCCeihemIBMS2oWkNHrFf7jZgJNVJhRz fV8G5XEQ034JVA6aetQIQcd2bLgMTrEnXENkXq1meNSvxKtwN81x2rv6nkheRDppKihF r7cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=LZDN3XvNM+VfMpvJ3GcqJbjqncEAnWvH5CxoKa/5h/0=; b=ftQffp31QP1vfifCKRlHbXhguQ06B81uUSPPftrSTJ1HYY6LWYPImF0n94EMQnWFHr AcG56QjmNBCUVoR5n/8Q84aFzBed0WkCEecR592n+ehYyxU4NwOdV5ogX0U4kG+KSLmr KTuzUe0Ve0MB0QGJ8hyTDlgrIFWSya2/aWm5F7CVS+CvK1ohPsFVRnRYROHhuS4OeWT/ ZJFPVW+bGlwXe4QAc4CT2eIBvxR2mPk9YaCNhL0tVVR2FOyvTBsbX73h9lubgCnR0zfJ +XgiqfTPMbgML2wC83Fx6qdXSfRRYC+yYxMuwUZbIydUgTgmdavZOHurJX3SKkD3bqTe qWYA== X-Gm-Message-State: AFeK/H1q/JUEGwARGvSkfToaYt+M2UNTzpPmXxoB9nxFl6FpIwyVDE+ZN4QD/4iR8rqllDLhDDfU6WjplxLmnw== X-Received: by 10.107.172.134 with SMTP id v128mr1031143ioe.49.1490245435735; Wed, 22 Mar 2017 22:03:55 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.41.131 with HTTP; Wed, 22 Mar 2017 22:03:55 -0700 (PDT) In-Reply-To: <201703221753.v2MHrPUD032012@repo.freebsd.org> References: <201703221753.v2MHrPUD032012@repo.freebsd.org> From: Aryeh Friedman Date: Thu, 23 Mar 2017 01:03:55 -0400 Message-ID: Subject: Re: svn commit: r315723 - in stable/11: . bin/pwait bin/pwait/tests etc/mtree targets/pseudo/tests usr.bin/timeout/tests To: Bryan Drewery Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 05:03:59 -0000 Fails to install on 11-stable due to /usr/test/pwait not existing On Wed, Mar 22, 2017 at 1:53 PM, Bryan Drewery wrote: > Author: bdrewery > Date: Wed Mar 22 17:53:25 2017 > New Revision: 315723 > URL: https://svnweb.freebsd.org/changeset/base/315723 > > Log: > MFC r314886,r314943,r314944: > > r314886: > pwait: Add a -t flag to specify a timeout before exiting, and tests. > r314943: > Remove unneeded -x from tests. > r314944: > Rename some tests to end in _test. > > Added: > stable/11/bin/pwait/tests/ > - copied from r314886, head/bin/pwait/tests/ > stable/11/bin/pwait/tests/pwait_test.sh > - copied unchanged from r314944, head/bin/pwait/tests/pwait_test.sh > stable/11/usr.bin/timeout/tests/timeout_test.sh > - copied unchanged from r314944, head/usr.bin/timeout/tests/ > timeout_test.sh > Deleted: > stable/11/bin/pwait/tests/pwait.sh > stable/11/usr.bin/timeout/tests/timeout.sh > Modified: > stable/11/ObsoleteFiles.inc > stable/11/bin/pwait/Makefile > stable/11/bin/pwait/pwait.1 > stable/11/bin/pwait/pwait.c > stable/11/bin/pwait/tests/Makefile > stable/11/etc/mtree/BSD.tests.dist > stable/11/targets/pseudo/tests/Makefile.depend > stable/11/usr.bin/timeout/tests/Makefile > Directory Properties: > stable/11/ (props changed) > > Modified: stable/11/ObsoleteFiles.inc > ============================================================ > ================== > --- stable/11/ObsoleteFiles.inc Wed Mar 22 17:49:56 2017 (r315722) > +++ stable/11/ObsoleteFiles.inc Wed Mar 22 17:53:25 2017 (r315723) > @@ -38,6 +38,9 @@ > # xargs -n1 | sort | uniq -d; > # done > > +# 20170308: rename some tests > +OLD_FILES+=usr/tests/bin/pwait/pwait > +OLD_FILES+=usr/tests/usr.bin/timeout/timeout > # 20170214: Four files from ggate tests consolidated into one > OLD_FILES+=usr/tests/sys/geom/class/gate/1_test > OLD_FILES+=usr/tests/sys/geom/class/gate/2_test > > Modified: stable/11/bin/pwait/Makefile > ============================================================ > ================== > --- stable/11/bin/pwait/Makefile Wed Mar 22 17:49:56 2017 > (r315722) > +++ stable/11/bin/pwait/Makefile Wed Mar 22 17:53:25 2017 > (r315723) > @@ -1,6 +1,12 @@ > # $FreeBSD$ > > +.include > + > PACKAGE=runtime > PROG= pwait > > +.if ${MK_TESTS} != "no" > +SUBDIR+= tests > +.endif > + > .include > > Modified: stable/11/bin/pwait/pwait.1 > ============================================================ > ================== > --- stable/11/bin/pwait/pwait.1 Wed Mar 22 17:49:56 2017 (r315722) > +++ stable/11/bin/pwait/pwait.1 Wed Mar 22 17:53:25 2017 (r315723) > @@ -32,7 +32,7 @@ > .\" > .\" $FreeBSD$ > .\" > -.Dd November 1, 2009 > +.Dd March 7, 2017 > .Dt PWAIT 1 > .Os > .Sh NAME > @@ -40,6 +40,7 @@ > .Nd wait for processes to terminate > .Sh SYNOPSIS > .Nm > +.Op Fl t Ar duration > .Op Fl v > .Ar pid > \&... > @@ -50,13 +51,36 @@ utility will wait until each of the give > .Pp > The following option is available: > .Bl -tag -width indent > +.It Fl t Ar duration > +If any process is still running after > +.Ar duration , > +.Nm > +will exit. > +The > +.Ar duration > +value can be integer or decimal numbers. > +Values without unit symbols are interpreted as seconds. > +.Pp > +Supported unit symbols are: > +.Bl -tag -width indent -compact > +.It s > +seconds > +.It m > +minutes > +.It h > +hours > +.El > .It Fl v > Print the exit status when each process terminates. > .El > -.Sh DIAGNOSTICS > +.Sh EXIT STATUS > The > .Nm > -utility returns 0 on success, and >0 if an error occurs. > +utility exits 0 on success, and >0 if an error occurs. > +.Pp > +If the > +.Fl t > +flag is specified and a timeout occurs, the exit status will be 124. > .Pp > Invalid pids elicit a warning message but are otherwise ignored. > .Sh SEE ALSO > > Modified: stable/11/bin/pwait/pwait.c > ============================================================ > ================== > --- stable/11/bin/pwait/pwait.c Wed Mar 22 17:49:56 2017 (r315722) > +++ stable/11/bin/pwait/pwait.c Wed Mar 22 17:53:25 2017 (r315723) > @@ -53,7 +53,7 @@ static void > usage(void) > { > > - fprintf(stderr, "usage: pwait [-v] pid ...\n"); > + fprintf(stderr, "usage: pwait [-t timeout] [-v] pid ...\n"); > exit(EX_USAGE); > } > > @@ -63,15 +63,46 @@ usage(void) > int > main(int argc, char *argv[]) > { > + struct itimerval itv; > int kq; > struct kevent *e; > - int verbose = 0; > + int tflag, verbose; > int opt, nleft, n, i, duplicate, status; > long pid; > char *s, *end; > + double timeout; > > - while ((opt = getopt(argc, argv, "v")) != -1) { > + tflag = verbose = 0; > + memset(&itv, 0, sizeof(itv)); > + while ((opt = getopt(argc, argv, "t:v")) != -1) { > switch (opt) { > + case 't': > + tflag = 1; > + errno = 0; > + timeout = strtod(optarg, &end); > + if (end == optarg || errno == ERANGE || > + timeout < 0) > + errx(EX_DATAERR, "timeout value"); > + switch(*end) { > + case 0: > + case 's': > + break; > + case 'h': > + timeout *= 60; > + /* FALLTHROUGH */ > + case 'm': > + timeout *= 60; > + break; > + default: > + errx(EX_DATAERR, "timeout unit"); > + } > + if (timeout > 100000000L) > + errx(EX_DATAERR, "timeout value"); > + itv.it_value.tv_sec = (time_t)timeout; > + timeout -= (time_t)timeout; > + itv.it_value.tv_usec = > + (suseconds_t)(timeout * 1000000UL); > + break; > case 'v': > verbose = 1; > break; > @@ -91,7 +122,7 @@ main(int argc, char *argv[]) > if (kq == -1) > err(1, "kqueue"); > > - e = malloc(argc * sizeof(struct kevent)); > + e = malloc((argc + tflag) * sizeof(struct kevent)); > if (e == NULL) > err(1, "malloc"); > nleft = 0; > @@ -119,12 +150,30 @@ main(int argc, char *argv[]) > } > } > > + if (tflag) { > + /* > + * Explicitly detect SIGALRM so that an exit status of 124 > + * can be returned rather than 142. > + */ > + EV_SET(e + nleft, SIGALRM, EVFILT_SIGNAL, EV_ADD, 0, 0, > NULL); > + if (kevent(kq, e + nleft, 1, NULL, 0, NULL) == -1) > + err(EX_OSERR, "kevent"); > + /* Ignore SIGALRM to not interrupt kevent(2). */ > + signal(SIGALRM, SIG_IGN); > + if (setitimer(ITIMER_REAL, &itv, NULL) == -1) > + err(EX_OSERR, "setitimer"); > + } > while (nleft > 0) { > - n = kevent(kq, NULL, 0, e, nleft, NULL); > + n = kevent(kq, NULL, 0, e, nleft + tflag, NULL); > if (n == -1) > err(1, "kevent"); > - if (verbose) > - for (i = 0; i < n; i++) { > + for (i = 0; i < n; i++) { > + if (e[i].filter == EVFILT_SIGNAL) { > + if (verbose) > + printf("timeout\n"); > + return (124); > + } > + if (verbose) { > status = e[i].data; > if (WIFEXITED(status)) > printf("%ld: exited with status > %d.\n", > @@ -138,7 +187,8 @@ main(int argc, char *argv[]) > printf("%ld: terminated.\n", > (long)e[i].ident); > } > - nleft -= n; > + --nleft; > + } > } > > exit(EX_OK); > > Modified: stable/11/bin/pwait/tests/Makefile > ============================================================ > ================== > --- head/bin/pwait/tests/Makefile Tue Mar 7 22:16:55 2017 > (r314886) > +++ stable/11/bin/pwait/tests/Makefile Wed Mar 22 17:53:25 2017 > (r315723) > @@ -1,5 +1,5 @@ > # $FreeBSD$ > > -ATF_TESTS_SH= pwait > +ATF_TESTS_SH= pwait_test > > .include > > Copied: stable/11/bin/pwait/tests/pwait_test.sh (from r314944, > head/bin/pwait/tests/pwait_test.sh) > ============================================================ > ================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ stable/11/bin/pwait/tests/pwait_test.sh Wed Mar 22 17:53:25 2017 > (r315723, copy of r314944, head/bin/pwait/tests/pwait_test.sh) > @@ -0,0 +1,242 @@ > +# $FreeBSD$ > + > +atf_test_case basic > +basic_head() > +{ > + atf_set "descr" "Basic tests on pwait(1) utility" > +} > + > +basic_body() > +{ > + sleep 1 & > + p1=$! > + > + sleep 5 & > + p5=$! > + > + sleep 10 & > + p10=$! > + > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:0 \ > + timeout --preserve-status 15 pwait $p1 $p5 $p10 > + > + atf_check \ > + -o empty \ > + -e inline:"kill: $p1: No such process\n" \ > + -s exit:1 \ > + kill -0 $p1 > + > + atf_check \ > + -o empty \ > + -e inline:"kill: $p5: No such process\n" \ > + -s exit:1 \ > + kill -0 $p5 > + > + atf_check \ > + -o empty \ > + -e inline:"kill: $p10: No such process\n" \ > + -s exit:1 \ > + kill -0 $p10 > + > +} > + > +basic_cleanup() > +{ > + kill $p1 $p5 $p10 >/dev/null 2>&1 > + wait $p1 $p5 $p10 >/dev/null 2>&1 > +} > + > +atf_test_case time_unit > +time_unit_head() > +{ > + atf_set "descr" "Test parsing the timeout unit and value" > +} > + > +time_unit_body() > +{ > + init=1 > + > + atf_check \ > + -o empty \ > + -e inline:"pwait: timeout unit\n" \ > + -s exit:65 \ > + timeout --preserve-status 2 pwait -t 1d $init > + > + atf_check \ > + -o empty \ > + -e inline:"pwait: timeout unit\n" \ > + -s exit:65 \ > + timeout --preserve-status 2 pwait -t 1d $init > + > + atf_check \ > + -o empty \ > + -e inline:"pwait: timeout value\n" \ > + -s exit:65 \ > + timeout --preserve-status 2 pwait -t -1 $init > + > + atf_check \ > + -o empty \ > + -e inline:"pwait: timeout value\n" \ > + -s exit:65 \ > + timeout --preserve-status 2 pwait -t 100000001 $init > + > + # These long duration cases are expected to timeout from the > + # timeout utility rather than pwait -t. > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:143 \ > + timeout --preserve-status 2 pwait -t 100000000 $init > + > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:143 \ > + timeout --preserve-status 2 pwait -t 1h $init > + > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:143 \ > + timeout --preserve-status 2 pwait -t 1.5h $init > + > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:143 \ > + timeout --preserve-status 2 pwait -t 1m $init > + > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:143 \ > + timeout --preserve-status 2 pwait -t 1.5m $init > + > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:143 \ > + timeout --preserve-status 2 pwait -t 0 $init > + > + # The rest are fast enough that pwait -t is expected to trigger > + # the timeout. > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:124 \ > + timeout --preserve-status 2 pwait -t 1s $init > + > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:124 \ > + timeout --preserve-status 2 pwait -t 1.5s $init > + > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:124 \ > + timeout --preserve-status 2 pwait -t 1 $init > + > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:124 \ > + timeout --preserve-status 2 pwait -t 1.5 $init > + > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:124 \ > + timeout --preserve-status 2 pwait -t 0.5 $init > +} > + > +atf_test_case timeout_trigger_timeout > +timeout_trigger_timeout_head() > +{ > + atf_set "descr" "Test that exceeding the timeout is detected" > +} > + > +timeout_trigger_timeout_body() > +{ > + sleep 10 & > + p10=$! > + > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:124 \ > + timeout --preserve-status 6.5 pwait -t 5 $p10 > +} > + > +timeout_trigger_timeout_cleanup() > +{ > + kill $p10 >/dev/null 2>&1 > + wait $p10 >/dev/null 2>&1 > +} > + > +atf_test_case timeout_no_timeout > +timeout_no_timeout_head() > +{ > + atf_set "descr" "Test that not exceeding the timeout continues to > wait" > +} > + > +timeout_no_timeout_body() > +{ > + sleep 10 & > + p10=$! > + > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:0 \ > + timeout --preserve-status 11.5 pwait -t 12 $p10 > +} > + > +timeout_no_timeout_cleanup() > +{ > + kill $p10 >/dev/null 2>&1 > + wait $p10 >/dev/null 2>&1 > +} > + > +atf_test_case timeout_many > +timeout_many_head() > +{ > + atf_set "descr" "Test timeout on many processes" > +} > + > +timeout_many_body() > +{ > + sleep 1 & > + p1=$! > + > + sleep 5 & > + p5=$! > + > + sleep 10 & > + p10=$! > + > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:124 \ > + timeout --preserve-status 7.5 pwait -t 6 $p1 $p5 $p10 > +} > + > +timeout_many_cleanup() > +{ > + kill $p1 $p5 $p10 >/dev/null 2>&1 > + wait $p1 $p5 $p10 >/dev/null 2>&1 > +} > + > +atf_init_test_cases() > +{ > + atf_add_test_case basic > + atf_add_test_case time_unit > + atf_add_test_case timeout_trigger_timeout > + atf_add_test_case timeout_no_timeout > + atf_add_test_case timeout_many > +} > > Modified: stable/11/etc/mtree/BSD.tests.dist > ============================================================ > ================== > --- stable/11/etc/mtree/BSD.tests.dist Wed Mar 22 17:49:56 2017 > (r315722) > +++ stable/11/etc/mtree/BSD.tests.dist Wed Mar 22 17:53:25 2017 > (r315723) > @@ -626,6 +626,8 @@ > .. > printf > .. > + pwait > + .. > sdiff > .. > sed > > Modified: stable/11/targets/pseudo/tests/Makefile.depend > ============================================================ > ================== > --- stable/11/targets/pseudo/tests/Makefile.depend Wed Mar 22 > 17:49:56 2017 (r315722) > +++ stable/11/targets/pseudo/tests/Makefile.depend Wed Mar 22 > 17:53:25 2017 (r315723) > @@ -307,6 +307,7 @@ DIRDEPS= \ > usr.bin/mkimg/tests \ > usr.bin/ncal/tests \ > usr.bin/printf/tests \ > + usr.bin/pwait/tests \ > usr.bin/sdiff/tests \ > usr.bin/sed/tests \ > usr.bin/sed/tests/regress.multitest.out \ > > Modified: stable/11/usr.bin/timeout/tests/Makefile > ============================================================ > ================== > --- stable/11/usr.bin/timeout/tests/Makefile Wed Mar 22 17:49:56 2017 > (r315722) > +++ stable/11/usr.bin/timeout/tests/Makefile Wed Mar 22 17:53:25 2017 > (r315723) > @@ -1,5 +1,5 @@ > # $FreeBSD$ > > -ATF_TESTS_SH= timeout > +ATF_TESTS_SH= timeout_test > > .include > > Copied: stable/11/usr.bin/timeout/tests/timeout_test.sh (from r314944, > head/usr.bin/timeout/tests/timeout_test.sh) > ============================================================ > ================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ stable/11/usr.bin/timeout/tests/timeout_test.sh Wed Mar 22 > 17:53:25 2017 (r315723, copy of r314944, head/usr.bin/timeout/tests/ > timeout_test.sh) > @@ -0,0 +1,215 @@ > +# $FreeBSD$ > + > +atf_test_case nominal > +nominal_head() > +{ > + atf_set "descr" "Basic tests on timeout(1) utility" > +} > + > +nominal_body() > +{ > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:0 \ > + timeout 5 true > +} > + > +atf_test_case time_unit > +time_unit_head() > +{ > + atf_set "descr" "Test parsing the default time unit" > +} > + > +time_unit_body() > +{ > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:0 \ > + timeout 1d true > + > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:0 \ > + timeout 1h true > + > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:0 \ > + timeout 1m true > + > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:0 \ > + timeout 1s true > +} > + > +atf_test_case no_timeout > +no_timeout_head() > +{ > + atf_set "descr" "Test disabled timeout" > +} > + > +no_timeout_body() > +{ > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:0 \ > + timeout 0 true > +} > + > +atf_test_case exit_numbers > +exit_numbers_head() > +{ > + atf_set "descr" "Test exit numbers" > +} > + > +exit_numbers_body() > +{ > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:2 \ > + -x timeout 5 sh -c \'exit 2\' > + > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:124 \ > + timeout .1 sleep 1 > + > + # With preserv status exit should be 128 + TERM aka 143 > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:143 \ > + timeout --preserve-status .1 sleep 10 > + > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:124 \ > + timeout -s1 -k1 .1 sleep 10 > + > + atf_check \ > + -o empty \ > + -e empty \ > + -s exit:0 \ > + -x sh -c 'trap "" CHLD; exec timeout 10 true' > +} > + > +atf_test_case with_a_child > +with_a_child_head() > +{ > + atf_set "descr" "When starting with a child (coreutils bug#9098)" > +} > + > +with_a_child_body() > +{ > + out=$(sleep .1 & exec timeout .5 sh -c 'sleep 2; echo foo') > + status=$? > + test "$out" = "" && test $status = 124 || atf_fail > + > +} > + > +atf_test_case invalid_timeout > +invalid_timeout_head() > +{ > + atf_set "descr" "Invalid timeout" > +} > + > +invalid_timeout_body() > +{ > + atf_check \ > + -o empty \ > + -e inline:"timeout: invalid duration\n" \ > + -s exit:125 \ > + timeout invalid sleep 0 > + > + atf_check \ > + -o empty \ > + -e inline:"timeout: invalid duration\n" \ > + -s exit:125 \ > + timeout --kill-after=invalid 1 sleep 0 > + > + atf_check \ > + -o empty \ > + -e inline:"timeout: invalid duration\n" \ > + -s exit:125 \ > + timeout 42D sleep 0 > + > + atf_check \ > + -o empty \ > + -e inline:"timeout: invalid duration\n" \ > + -s exit:125 \ > + timeout 999999999999999999999999999999 > 999999999999999999999999999999d sleep 0 > + > + atf_check \ > + -o empty \ > + -e inline:"timeout: invalid duration\n" \ > + -s exit:125 \ > + timeout 2.34e+5d sleep 0 > +} > + > +atf_test_case invalid_signal > +invalid_signal_head() > +{ > + atf_set "descr" "Invalid signal" > +} > + > +invalid_signal_body() > +{ > + atf_check \ > + -o empty \ > + -e inline:"timeout: invalid signal\n" \ > + -s exit:125 \ > + timeout --signal=invalid 1 sleep 0 > +} > + > +atf_test_case invalid_command > +invalid_command_head() > +{ > + atf_set "descr" "Invalid command" > +} > + > +invalid_command_body() > +{ > + atf_check \ > + -o empty \ > + -e inline:"timeout: exec(.): Permission denied\n" \ > + -s exit:126 \ > + timeout 10 . > +} > + > +atf_test_case no_such_command > +no_such_command_head() > +{ > + atf_set "descr" "No such command" > +} > + > +no_such_command_body() > +{ > + atf_check \ > + -o empty \ > + -e inline:"timeout: exec(enoexists): No such file or > directory\n" \ > + -s exit:127 \ > + timeout 10 enoexists > +} > + > +atf_init_test_cases() > +{ > + atf_add_test_case nominal > + atf_add_test_case time_unit > + atf_add_test_case no_timeout > + atf_add_test_case exit_numbers > + atf_add_test_case with_a_child > + atf_add_test_case invalid_timeout > + atf_add_test_case invalid_signal > + atf_add_test_case invalid_command > + atf_add_test_case no_such_command > +} > _______________________________________________ > svn-src-all@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-all > To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" > -- Aryeh M. Friedman, Lead Developer, http://www.PetiteCloud.org From owner-svn-src-stable-11@freebsd.org Thu Mar 23 05:32:03 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B6C9FD1964A; Thu, 23 Mar 2017 05:32:03 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 86372180C; Thu, 23 Mar 2017 05:32:03 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N5W2Ld026016; Thu, 23 Mar 2017 05:32:02 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N5W208026015; Thu, 23 Mar 2017 05:32:02 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703230532.v2N5W208026015@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Thu, 23 Mar 2017 05:32:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315794 - stable/11/etc/mtree X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 05:32:03 -0000 Author: ngie Date: Thu Mar 23 05:32:02 2017 New Revision: 315794 URL: https://svnweb.freebsd.org/changeset/base/315794 Log: MFC r314892: r314892 (by cy): Fix install due to incorrect placement of pwait dir in r314886. Modified: stable/11/etc/mtree/BSD.tests.dist Directory Properties: stable/11/ (props changed) Modified: stable/11/etc/mtree/BSD.tests.dist ============================================================================== --- stable/11/etc/mtree/BSD.tests.dist Thu Mar 23 05:26:44 2017 (r315793) +++ stable/11/etc/mtree/BSD.tests.dist Thu Mar 23 05:32:02 2017 (r315794) @@ -24,6 +24,8 @@ .. pkill .. + pwait + .. sh builtins .. @@ -626,8 +628,6 @@ .. printf .. - pwait - .. sdiff .. sed From owner-svn-src-stable-11@freebsd.org Thu Mar 23 05:33:47 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 20133D1986E; Thu, 23 Mar 2017 05:33:47 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-pg0-x242.google.com (mail-pg0-x242.google.com [IPv6:2607:f8b0:400e:c05::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DF6C41B00; Thu, 23 Mar 2017 05:33:46 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: by mail-pg0-x242.google.com with SMTP id 79so25303535pgf.0; Wed, 22 Mar 2017 22:33:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:mime-version:from:in-reply-to:date:cc:message-id:references :to; bh=UUIvhpPdmyZy3XVJ+3uzTt3dVDUFA+iziiJ6q4LJ4CQ=; b=pMzefZN45u+4lHJ8e+gyLwLAjxtnkGEnbyOCs1HJPr6pH+ZBlTqWUijsnoiRWQ9D52 Apm+krL+WCq4y+rH4AfiVG1ppiRTjeM6Od3jag9pMEpAItSvNY26lGDFzBWXlh/IhvTr yQT2/V53FzoQhCpuBRU6/4pmt9w/F/ma6kz9Hv2fAVM7XrSuiHbpPCcyfMPuBP7lutnq X/pldediHSIZVURY83MfBDLPwPFAPeslVCgI5zqMDkU6bkLQLUzdTe5F6N981Ig22qby IheqeTjAtJ//sjswoqn9sHIR964TKmgvKkCB9hg5I9S4B+t+Q//RCag2RYVms7VLEOVu GlQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:mime-version:from:in-reply-to:date:cc :message-id:references:to; bh=UUIvhpPdmyZy3XVJ+3uzTt3dVDUFA+iziiJ6q4LJ4CQ=; b=JGpk+DinwSAZ819Fy80R1dayaeXX0rDtVBcGFSDu3SrUi3SKCIqCPl4cvDdXGh+5Ni sGtkTGthKU5GHgQ+GmN2k63a8NIg2jZ/oZaPkXp/Tg0RXjFRUz5vgnIhBEl+fZj2bLE7 U1nXGckR4PNO0VGWRwA+cFl5t4qArJL4zLgnuhE37QuGgx55HAZQ5zULSGz9yyCbHI4L HIfA4iy19ynsx90nkM1/ChXiCpJvHzriOr+ElAkSCeyXka+oyi9NHpITzzc1HBG0uhFu P1XrK6k8fFlpIG72QvJWXzKaWXO8jdH8FrSpIZf9S11L9IaMiUj7eo/LUMFs+H2GBuoX gAiQ== X-Gm-Message-State: AFeK/H0d6LSBoQ6GPJcQoXpPr21g2BuyPQ2TncjIsdrSK47z4xQRCpM0oiMbVbge+Z/1VQ== X-Received: by 10.99.222.17 with SMTP id f17mr816165pgg.127.1490247226434; Wed, 22 Mar 2017 22:33:46 -0700 (PDT) Received: from pinklady.local (c-73-19-52-228.hsd1.wa.comcast.net. [73.19.52.228]) by smtp.gmail.com with ESMTPSA id p6sm7181706pgn.40.2017.03.22.22.33.45 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Mar 2017 22:33:45 -0700 (PDT) Subject: Re: svn commit: r315723 - in stable/11: . bin/pwait bin/pwait/tests etc/mtree targets/pseudo/tests usr.bin/timeout/tests Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: multipart/signed; boundary="Apple-Mail=_3C1A0E5B-5A8B-49F4-9337-08F107BD3BBA"; protocol="application/pgp-signature"; micalg=pgp-sha512 X-Pgp-Agent: GPGMail From: "Ngie Cooper (yaneurabeya)" In-Reply-To: Date: Wed, 22 Mar 2017 22:33:44 -0700 Cc: Bryan Drewery , src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Message-Id: References: <201703221753.v2MHrPUD032012@repo.freebsd.org> To: Aryeh Friedman X-Mailer: Apple Mail (2.3124) X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 05:33:47 -0000 --Apple-Mail=_3C1A0E5B-5A8B-49F4-9337-08F107BD3BBA Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Mar 22, 2017, at 22:03, Aryeh Friedman = wrote: >=20 > Fails to install on 11-stable due to /usr/test/pwait not existing Fixed in r315794 =E2=80=94 thanks! -Ngie --Apple-Mail=_3C1A0E5B-5A8B-49F4-9337-08F107BD3BBA Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJY0145AAoJEPWDqSZpMIYVbWUP/1aOFNL/rvyaTxVJ1F+62baQ XXGf9S+3dv41W4zKZZ6CWT8lpA5CBSXfHtWZI2gaCWuDaKJBSU+w3CTczOG1bHcd CzKAniG/fjREGd8z4IuwLf9o27/ohtJ1SfBZdNjZ5wjygqg6i+OTGF8Roq0YTcvR dM4zJf48nkwfBBPxG7/i7vi8MRdAmBJWMv5Dzr2cBwmnhT1Xj4GdgMUNl5LF69wp CLVU2yZGFPt8iP4pQRt0FzZGF2+fw89eDCQhhG2dcp7ImMmx8SltOZgTCI9eR5wx 5DN7GDvZX2pZb1ZIXvIHb2ADRSj+9uupm0+SWuf7Ut6Fik6Ur/0SqQbWRXU3ME69 66L7lnx0vMrwa5PukTPioVHoQhgWPvwi9lD23Nc0gEPEzkxE3PHjeSyHyboqmwGw Vi4GWk6WFg6kE4lxQEZtOSgzdqDmaz07+13jDz5M1jxoby93sij91ZEPyOX6c9so 9cGr0w1LZbw9eQABxKhkIiSkejYUsluxg9WOUvKg7xJe/fXIa2WjzsKhW5cMurpU mRPUa87rV+7ZvB6o+9xz9atncYGi5n17qzeesw3kbm5i/ySCAJCwkmakT5bea2he da6n8ZnD0dddgtjZgNOmXS9TqbVpEDiBU5XoMKqA+SXjlzDINpwyX4PAzZYbQKCN sPt8DOwEBIaUmr7S0VM9 =F85Y -----END PGP SIGNATURE----- --Apple-Mail=_3C1A0E5B-5A8B-49F4-9337-08F107BD3BBA-- From owner-svn-src-stable-11@freebsd.org Thu Mar 23 06:28:36 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2C453D19C9E; Thu, 23 Mar 2017 06:28:36 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ECC3912BC; Thu, 23 Mar 2017 06:28:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N6SZvl048019; Thu, 23 Mar 2017 06:28:35 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6SZRn048018; Thu, 23 Mar 2017 06:28:35 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230628.v2N6SZRn048018@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:28:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315805 - stable/11/sys/dev/cxgb/ulp/tom X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 06:28:36 -0000 Author: mav Date: Thu Mar 23 06:28:34 2017 New Revision: 315805 URL: https://svnweb.freebsd.org/changeset/base/315805 Log: MFC r314952: Fix unused variable when built without INVARIANT_SUPPORT. Modified: stable/11/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c ============================================================================== --- stable/11/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c Thu Mar 23 06:11:31 2017 (r315804) +++ stable/11/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c Thu Mar 23 06:28:34 2017 (r315805) @@ -1621,10 +1621,9 @@ fixup_and_send_ofo(struct toepcb *toep) struct mbuf *m; struct toedev *tod = toep->tp_tod; struct adapter *sc = tod->tod_softc; - struct inpcb *inp = toep->tp_inp; unsigned int tid = toep->tp_tid; - inp_lock_assert(inp); + inp_lock_assert(toep->tp_inp); while ((m = mbufq_dequeue(&toep->out_of_order_queue)) != NULL) { struct ofld_hdr *oh = mtod(m, void *); From owner-svn-src-stable-11@freebsd.org Thu Mar 23 06:31:05 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 21AEAD19005; Thu, 23 Mar 2017 06:31:05 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DB4F8175A; Thu, 23 Mar 2017 06:31:04 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N6V3gr050322; Thu, 23 Mar 2017 06:31:03 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6V3uE050321; Thu, 23 Mar 2017 06:31:03 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230631.v2N6V3uE050321@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:31:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315807 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 06:31:05 -0000 Author: mav Date: Thu Mar 23 06:31:03 2017 New Revision: 315807 URL: https://svnweb.freebsd.org/changeset/base/315807 Log: MFC r314964: Decode modern PIM flags. Modified: stable/11/sbin/camcontrol/camcontrol.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.c Thu Mar 23 06:29:47 2017 (r315806) +++ stable/11/sbin/camcontrol/camcontrol.c Thu Mar 23 06:31:03 2017 (r315807) @@ -5378,6 +5378,12 @@ cpi_print(struct ccb_pathinq *cpi) fprintf(stdout, "%s ", adapter_str); switch(i) { + case PIM_ATA_EXT: + str = "can understand ata_ext requests"; + break; + case PIM_EXTLUNS: + str = "64bit extended LUNs supported"; + break; case PIM_SCANHILO: str = "bus scans from high ID to low ID"; break; @@ -5397,6 +5403,12 @@ cpi_print(struct ccb_pathinq *cpi) case PIM_SEQSCAN: str = "scan bus sequentially"; break; + case PIM_UNMAPPED: + str = "unmapped I/O supported"; + break; + case PIM_NOSCAN: + str = "does its own scanning"; + break; default: str = "unknown PIM bit set"; break; From owner-svn-src-stable-11@freebsd.org Thu Mar 23 06:34:16 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EE7A3D191A3; Thu, 23 Mar 2017 06:34:16 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BB00F1C0C; Thu, 23 Mar 2017 06:34:16 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N6YFVK051945; Thu, 23 Mar 2017 06:34:15 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6YFLV051944; Thu, 23 Mar 2017 06:34:15 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230634.v2N6YFLV051944@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:34:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315808 - stable/11/sys/dev/mpt X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 06:34:17 -0000 Author: mav Date: Thu Mar 23 06:34:15 2017 New Revision: 315808 URL: https://svnweb.freebsd.org/changeset/base/315808 Log: MFC r303874 (by trasz): Remove NULL check after M_WAITOK allocation from mpt(4). Modified: stable/11/sys/dev/mpt/mpt_pci.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mpt/mpt_pci.c ============================================================================== --- stable/11/sys/dev/mpt/mpt_pci.c Thu Mar 23 06:31:03 2017 (r315807) +++ stable/11/sys/dev/mpt/mpt_pci.c Thu Mar 23 06:34:15 2017 (r315808) @@ -654,10 +654,6 @@ mpt_dma_mem_alloc(struct mpt_softc *mpt) len = sizeof (request_t) * MPT_MAX_REQUESTS(mpt); mpt->request_pool = (request_t *)malloc(len, M_DEVBUF, M_WAITOK|M_ZERO); - if (mpt->request_pool == NULL) { - mpt_prt(mpt, "cannot allocate request pool\n"); - return (1); - } /* * Create a parent dma tag for this device. From owner-svn-src-stable-11@freebsd.org Thu Mar 23 06:36:56 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7BBF8D192FE; Thu, 23 Mar 2017 06:36:56 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 31D891ED2; Thu, 23 Mar 2017 06:36:56 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N6at06052163; Thu, 23 Mar 2017 06:36:55 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6atjc052162; Thu, 23 Mar 2017 06:36:55 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230636.v2N6atjc052162@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:36:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315810 - stable/11/sys/dev/mpt X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 06:36:56 -0000 Author: mav Date: Thu Mar 23 06:36:55 2017 New Revision: 315810 URL: https://svnweb.freebsd.org/changeset/base/315810 Log: MFC r308423 (by scottl): Fix the fallout from r308268 (mpt driver causes endless witness warnings in VMWare and elsewhere) with the precision of a dull, rusty butter knife. Modified: stable/11/sys/dev/mpt/mpt.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mpt/mpt.c ============================================================================== --- stable/11/sys/dev/mpt/mpt.c Thu Mar 23 06:34:45 2017 (r315809) +++ stable/11/sys/dev/mpt/mpt.c Thu Mar 23 06:36:55 2017 (r315810) @@ -2695,7 +2695,11 @@ mpt_configure_ioc(struct mpt_softc *mpt, */ mpt->max_cam_seg_cnt = min(mpt->max_seg_cnt, (MAXPHYS / PAGE_SIZE) + 1); + /* XXX Lame Locking! */ + MPT_UNLOCK(mpt); error = mpt_dma_buf_alloc(mpt); + MPT_LOCK(mpt); + if (error != 0) { mpt_prt(mpt, "mpt_dma_buf_alloc() failed!\n"); return (EIO); @@ -2745,6 +2749,7 @@ mpt_configure_ioc(struct mpt_softc *mpt, * retrieved, we are responsible for re-downloading * the firmware after any hard-reset. */ + MPT_UNLOCK(mpt); mpt->fw_image_size = mpt->ioc_facts.FWImageSize; error = mpt_dma_tag_create(mpt, mpt->parent_dmat, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, @@ -2752,6 +2757,7 @@ mpt_configure_ioc(struct mpt_softc *mpt, &mpt->fw_dmat); if (error != 0) { mpt_prt(mpt, "cannot create firmware dma tag\n"); + MPT_LOCK(mpt); return (ENOMEM); } error = bus_dmamem_alloc(mpt->fw_dmat, @@ -2760,6 +2766,7 @@ mpt_configure_ioc(struct mpt_softc *mpt, if (error != 0) { mpt_prt(mpt, "cannot allocate firmware memory\n"); bus_dma_tag_destroy(mpt->fw_dmat); + MPT_LOCK(mpt); return (ENOMEM); } mi.mpt = mpt; @@ -2768,6 +2775,7 @@ mpt_configure_ioc(struct mpt_softc *mpt, mpt->fw_image, mpt->fw_image_size, mpt_map_rquest, &mi, 0); mpt->fw_phys = mi.phys; + MPT_LOCK(mpt); error = mpt_upload_fw(mpt); if (error != 0) { mpt_prt(mpt, "firmware upload failed.\n"); From owner-svn-src-stable-11@freebsd.org Thu Mar 23 06:40:27 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 26A43D19412; Thu, 23 Mar 2017 06:40:27 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D12AC1CF; Thu, 23 Mar 2017 06:40:26 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N6eQha052481; Thu, 23 Mar 2017 06:40:26 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6eKLU052429; Thu, 23 Mar 2017 06:40:20 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230640.v2N6eKLU052429@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:40:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315812 - in stable/11/sys: cam cam/ctl cam/scsi dev/aac dev/aacraid dev/advansys dev/aha dev/ahb dev/ahci dev/aic dev/aic7xxx dev/amr dev/arcmsr dev/ata dev/buslogic dev/ciss dev/dpt d... X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 06:40:27 -0000 Author: mav Date: Thu Mar 23 06:40:20 2017 New Revision: 315812 URL: https://svnweb.freebsd.org/changeset/base/315812 Log: MFC r311305 (by asomers): Always null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name) The sim_vid, hba_vid, and dev_name fields of struct ccb_pathinq are fixed-length strings. AFAICT the only place they're read is in sbin/camcontrol/camcontrol.c, which assumes they'll be null-terminated. However, the kernel doesn't null-terminate them. A bunch of copy-pasted code uses strncpy to write them, and doesn't guarantee null-termination. For at least 4 drivers (mpr, mps, ciss, and hyperv), the hba_vid field actually overflows. You can see the result by doing "camcontrol negotiate da0 -v". This change null-terminates those fields everywhere they're set in the kernel. It also shortens a few strings to ensure they'll fit within the 16-character field. PR: 215474 Reported by: Coverity CID: 1009997 1010000 1010001 1010002 1010003 1010004 1010005 CID: 1331519 1010006 1215097 1010007 1288967 1010008 1306000 CID: 1211924 1010009 1010010 1010011 1010012 1010013 1010014 CID: 1147190 1010017 1010016 1010018 1216435 1010020 1010021 CID: 1010022 1009666 1018185 1010023 1010025 1010026 1010027 CID: 1010028 1010029 1010030 1010031 1010033 1018186 1018187 CID: 1010035 1010036 1010042 1010041 1010040 1010039 Modified: stable/11/sys/cam/cam_xpt.c stable/11/sys/cam/ctl/ctl_frontend_cam_sim.c stable/11/sys/cam/scsi/scsi_low.c stable/11/sys/dev/aac/aac_cam.c stable/11/sys/dev/aacraid/aacraid_cam.c stable/11/sys/dev/advansys/advansys.c stable/11/sys/dev/advansys/adwcam.c stable/11/sys/dev/aha/aha.c stable/11/sys/dev/ahb/ahb.c stable/11/sys/dev/ahci/ahci.c stable/11/sys/dev/ahci/ahciem.c stable/11/sys/dev/aic/aic.c stable/11/sys/dev/aic7xxx/aic79xx_osm.c stable/11/sys/dev/aic7xxx/aic7xxx_osm.c stable/11/sys/dev/amr/amr_cam.c stable/11/sys/dev/arcmsr/arcmsr.c stable/11/sys/dev/ata/ata-all.c stable/11/sys/dev/buslogic/bt.c stable/11/sys/dev/ciss/ciss.c stable/11/sys/dev/dpt/dpt_scsi.c stable/11/sys/dev/esp/ncr53c9x.c stable/11/sys/dev/firewire/sbp.c stable/11/sys/dev/firewire/sbp_targ.c stable/11/sys/dev/hpt27xx/hpt27xx_osm_bsd.c stable/11/sys/dev/hptiop/hptiop.c stable/11/sys/dev/hptmv/entry.c stable/11/sys/dev/hptnr/hptnr_osm_bsd.c stable/11/sys/dev/hptrr/hptrr_osm_bsd.c stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/11/sys/dev/iir/iir.c stable/11/sys/dev/isci/isci_controller.c stable/11/sys/dev/iscsi_initiator/isc_cam.c stable/11/sys/dev/isp/isp_freebsd.c stable/11/sys/dev/mfi/mfi_cam.c stable/11/sys/dev/mly/mly.c stable/11/sys/dev/mpr/mpr_sas.c stable/11/sys/dev/mps/mps_sas.c stable/11/sys/dev/mpt/mpt_cam.c stable/11/sys/dev/mrsas/mrsas_cam.c stable/11/sys/dev/mvs/mvs.c stable/11/sys/dev/ncr/ncr.c stable/11/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c stable/11/sys/dev/ppbus/vpo.c stable/11/sys/dev/siis/siis.c stable/11/sys/dev/sym/sym_hipd.c stable/11/sys/dev/trm/trm.c stable/11/sys/dev/twa/tw_osl_cam.c stable/11/sys/dev/tws/tws_cam.c stable/11/sys/dev/virtio/scsi/virtio_scsi.c stable/11/sys/powerpc/ps3/ps3cdrom.c stable/11/sys/powerpc/pseries/phyp_vscsi.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/cam_xpt.c ============================================================================== --- stable/11/sys/cam/cam_xpt.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/cam/cam_xpt.c Thu Mar 23 06:40:20 2017 (r315812) @@ -5143,9 +5143,9 @@ xptaction(struct cam_sim *sim, union ccb cpi->max_target = 0; cpi->max_lun = 0; cpi->initiator_id = 0; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "", HBA_IDLEN); - strncpy(cpi->dev_name, sim->sim_name, DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "", HBA_IDLEN); + strlcpy(cpi->dev_name, sim->sim_name, DEV_IDLEN); cpi->unit_number = sim->unit_number; cpi->bus_id = sim->bus_id; cpi->base_transfer_speed = 0; Modified: stable/11/sys/cam/ctl/ctl_frontend_cam_sim.c ============================================================================== --- stable/11/sys/cam/ctl/ctl_frontend_cam_sim.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/cam/ctl/ctl_frontend_cam_sim.c Thu Mar 23 06:40:20 2017 (r315812) @@ -786,9 +786,9 @@ cfcs_action(struct cam_sim *sim, union c cpi->hpath_id = 0; cpi->initiator_id = 0; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "FreeBSD", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "FreeBSD", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = 0; cpi->bus_id = 0; cpi->base_transfer_speed = 800000; Modified: stable/11/sys/cam/scsi/scsi_low.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_low.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/cam/scsi/scsi_low.c Thu Mar 23 06:40:20 2017 (r315812) @@ -713,9 +713,9 @@ settings_out: cpi->transport_version = 2; cpi->protocol = PROTO_SCSI; cpi->protocol_version = SCSI_REV_2; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "SCSI_LOW", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "SCSI_LOW", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); Modified: stable/11/sys/dev/aac/aac_cam.c ============================================================================== --- stable/11/sys/dev/aac/aac_cam.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/aac/aac_cam.c Thu Mar 23 06:40:20 2017 (r315812) @@ -317,9 +317,9 @@ aac_cam_action(struct cam_sim *sim, unio cpi->initiator_id = camsc->inf->InitiatorBusId; cpi->bus_id = camsc->inf->BusNumber; cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SPI; cpi->transport_version = 2; Modified: stable/11/sys/dev/aacraid/aacraid_cam.c ============================================================================== --- stable/11/sys/dev/aacraid/aacraid_cam.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/aacraid/aacraid_cam.c Thu Mar 23 06:40:20 2017 (r315812) @@ -1037,9 +1037,9 @@ aac_cam_action(struct cam_sim *sim, unio cpi->transport_version = 0; cpi->protocol_version = SCSI_REV_SPC2; #endif - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "PMC-Sierra", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "PMC-Sierra", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); ccb->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); Modified: stable/11/sys/dev/advansys/advansys.c ============================================================================== --- stable/11/sys/dev/advansys/advansys.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/advansys/advansys.c Thu Mar 23 06:40:20 2017 (r315812) @@ -425,9 +425,9 @@ adv_action(struct cam_sim *sim, union cc cpi->initiator_id = adv->scsi_id; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Advansys", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Advansys", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->ccb_h.status = CAM_REQ_CMP; cpi->transport = XPORT_SPI; Modified: stable/11/sys/dev/advansys/adwcam.c ============================================================================== --- stable/11/sys/dev/advansys/adwcam.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/advansys/adwcam.c Thu Mar 23 06:40:20 2017 (r315812) @@ -708,9 +708,9 @@ adw_action(struct cam_sim *sim, union cc cpi->initiator_id = adw->initiator_id; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "AdvanSys", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "AdvanSys", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SPI; cpi->transport_version = 2; Modified: stable/11/sys/dev/aha/aha.c ============================================================================== --- stable/11/sys/dev/aha/aha.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/aha/aha.c Thu Mar 23 06:40:20 2017 (r315812) @@ -943,9 +943,9 @@ ahaaction(struct cam_sim *sim, union ccb cpi->initiator_id = aha->scsi_id; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SPI; cpi->transport_version = 2; Modified: stable/11/sys/dev/ahb/ahb.c ============================================================================== --- stable/11/sys/dev/ahb/ahb.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/ahb/ahb.c Thu Mar 23 06:40:20 2017 (r315812) @@ -1178,9 +1178,9 @@ ahbaction(struct cam_sim *sim, union ccb cpi->initiator_id = ahb->scsi_id; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SPI; cpi->transport_version = 2; Modified: stable/11/sys/dev/ahci/ahci.c ============================================================================== --- stable/11/sys/dev/ahci/ahci.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/ahci/ahci.c Thu Mar 23 06:40:20 2017 (r315812) @@ -2694,9 +2694,9 @@ ahciaction(struct cam_sim *sim, union cc cpi->initiator_id = 0; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 150000; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "AHCI", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "AHCI", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SATA; cpi->transport_version = XPORT_VERSION_UNSPECIFIED; Modified: stable/11/sys/dev/ahci/ahciem.c ============================================================================== --- stable/11/sys/dev/ahci/ahciem.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/ahci/ahciem.c Thu Mar 23 06:40:20 2017 (r315812) @@ -578,9 +578,9 @@ ahciemaction(struct cam_sim *sim, union cpi->initiator_id = 0; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 150000; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "AHCI", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "AHCI", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SATA; cpi->transport_version = XPORT_VERSION_UNSPECIFIED; Modified: stable/11/sys/dev/aic/aic.c ============================================================================== --- stable/11/sys/dev/aic/aic.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/aic/aic.c Thu Mar 23 06:40:20 2017 (r315812) @@ -281,9 +281,9 @@ aic_action(struct cam_sim *sim, union cc cpi->initiator_id = aic->initiator; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SPI; cpi->transport_version = 2; Modified: stable/11/sys/dev/aic7xxx/aic79xx_osm.c ============================================================================== --- stable/11/sys/dev/aic7xxx/aic79xx_osm.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/aic7xxx/aic79xx_osm.c Thu Mar 23 06:40:20 2017 (r315812) @@ -699,9 +699,9 @@ ahd_action(struct cam_sim *sim, union cc } cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->protocol = PROTO_SCSI; cpi->protocol_version = SCSI_REV_2; Modified: stable/11/sys/dev/aic7xxx/aic7xxx_osm.c ============================================================================== --- stable/11/sys/dev/aic7xxx/aic7xxx_osm.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/aic7xxx/aic7xxx_osm.c Thu Mar 23 06:40:20 2017 (r315812) @@ -797,9 +797,9 @@ ahc_action(struct cam_sim *sim, union cc } cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Adaptec", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->protocol = PROTO_SCSI; cpi->protocol_version = SCSI_REV_2; Modified: stable/11/sys/dev/amr/amr_cam.c ============================================================================== --- stable/11/sys/dev/amr/amr_cam.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/amr/amr_cam.c Thu Mar 23 06:40:20 2017 (r315812) @@ -323,9 +323,9 @@ amr_cam_action(struct cam_sim *sim, unio cpi->max_target = AMR_MAX_TARGETS; cpi->max_lun = 0 /* AMR_MAX_LUNS*/; cpi->initiator_id = 7; /* XXX variable? */ - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "LSI", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "LSI", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 132 * 1024; /* XXX */ Modified: stable/11/sys/dev/arcmsr/arcmsr.c ============================================================================== --- stable/11/sys/dev/arcmsr/arcmsr.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/arcmsr/arcmsr.c Thu Mar 23 06:40:20 2017 (r315812) @@ -2895,9 +2895,9 @@ static void arcmsr_action(struct cam_sim cpi->max_lun = ARCMSR_MAX_TARGETLUN; /* 0-7 */ cpi->initiator_id = ARCMSR_SCSI_INITIATOR_ID; /* 255 */ cpi->bus_id = cam_sim_bus(psim); - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "ARCMSR", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(psim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "ARCMSR", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(psim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(psim); #ifdef CAM_NEW_TRAN_CODE if(acb->adapter_bus_speed == ACB_BUS_SPEED_12G) Modified: stable/11/sys/dev/ata/ata-all.c ============================================================================== --- stable/11/sys/dev/ata/ata-all.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/ata/ata-all.c Thu Mar 23 06:40:20 2017 (r315812) @@ -1163,9 +1163,9 @@ ataaction(struct cam_sim *sim, union ccb cpi->base_transfer_speed = 150000; else cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "ATA", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "ATA", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); if (ch->flags & ATA_SATA) cpi->transport = XPORT_SATA; Modified: stable/11/sys/dev/buslogic/bt.c ============================================================================== --- stable/11/sys/dev/buslogic/bt.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/buslogic/bt.c Thu Mar 23 06:40:20 2017 (r315812) @@ -1363,9 +1363,9 @@ btaction(struct cam_sim *sim, union ccb cpi->initiator_id = bt->scsi_id; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "BusLogic", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "BusLogic", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->ccb_h.status = CAM_REQ_CMP; cpi->transport = XPORT_SPI; Modified: stable/11/sys/dev/ciss/ciss.c ============================================================================== --- stable/11/sys/dev/ciss/ciss.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/ciss/ciss.c Thu Mar 23 06:40:20 2017 (r315812) @@ -3026,9 +3026,9 @@ ciss_cam_action(struct cam_sim *sim, uni cpi->max_target = sc->ciss_cfg->max_logical_supported; cpi->max_lun = 0; /* 'logical drive' channel only */ cpi->initiator_id = sc->ciss_cfg->max_logical_supported; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "msmith@freebsd.org", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "CISS", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 132 * 1024; /* XXX what to set this to? */ Modified: stable/11/sys/dev/dpt/dpt_scsi.c ============================================================================== --- stable/11/sys/dev/dpt/dpt_scsi.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/dpt/dpt_scsi.c Thu Mar 23 06:40:20 2017 (r315812) @@ -1027,9 +1027,9 @@ dpt_action(struct cam_sim *sim, union cc cpi->initiator_id = dpt->hostid[cam_sim_bus(sim)]; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "DPT", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "DPT", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SPI; cpi->transport_version = 2; Modified: stable/11/sys/dev/esp/ncr53c9x.c ============================================================================== --- stable/11/sys/dev/esp/ncr53c9x.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/esp/ncr53c9x.c Thu Mar 23 06:40:20 2017 (r315812) @@ -1013,9 +1013,9 @@ ncr53c9x_action(struct cam_sim *sim, uni cpi->max_target = sc->sc_ntarg - 1; cpi->max_lun = 7; cpi->initiator_id = sc->sc_id; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "NCR", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "NCR", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = 0; cpi->base_transfer_speed = 3300; Modified: stable/11/sys/dev/firewire/sbp.c ============================================================================== --- stable/11/sys/dev/firewire/sbp.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/firewire/sbp.c Thu Mar 23 06:40:20 2017 (r315812) @@ -2489,9 +2489,9 @@ END_DEBUG cpi->initiator_id = SBP_INITIATOR; cpi->bus_id = sim->bus_id; cpi->base_transfer_speed = 400 * 1000 / 8; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "SBP", HBA_IDLEN); - strncpy(cpi->dev_name, sim->sim_name, DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "SBP", HBA_IDLEN); + strlcpy(cpi->dev_name, sim->sim_name, DEV_IDLEN); cpi->unit_number = sim->unit_number; cpi->transport = XPORT_SPI; /* XX should have a FireWire */ cpi->transport_version = 2; Modified: stable/11/sys/dev/firewire/sbp_targ.c ============================================================================== --- stable/11/sys/dev/firewire/sbp_targ.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/firewire/sbp_targ.c Thu Mar 23 06:40:20 2017 (r315812) @@ -1324,9 +1324,9 @@ sbp_targ_action1(struct cam_sim *sim, un cpi->initiator_id = 7; /* XXX */ cpi->bus_id = sim->bus_id; cpi->base_transfer_speed = 400 * 1000 / 8; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "SBP_TARG", HBA_IDLEN); - strncpy(cpi->dev_name, sim->sim_name, DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "SBP_TARG", HBA_IDLEN); + strlcpy(cpi->dev_name, sim->sim_name, DEV_IDLEN); cpi->unit_number = sim->unit_number; cpi->ccb_h.status = CAM_REQ_CMP; Modified: stable/11/sys/dev/hpt27xx/hpt27xx_osm_bsd.c ============================================================================== --- stable/11/sys/dev/hpt27xx/hpt27xx_osm_bsd.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/hpt27xx/hpt27xx_osm_bsd.c Thu Mar 23 06:40:20 2017 (r315812) @@ -934,9 +934,9 @@ static void hpt_action(struct cam_sim *s cpi->initiator_id = osm_max_targets; cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "HPT ", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "HPT ", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->transport = XPORT_SPI; cpi->transport_version = 2; cpi->protocol = PROTO_SCSI; Modified: stable/11/sys/dev/hptiop/hptiop.c ============================================================================== --- stable/11/sys/dev/hptiop/hptiop.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/hptiop/hptiop.c Thu Mar 23 06:40:20 2017 (r315812) @@ -2365,9 +2365,9 @@ static void hptiop_action(struct cam_sim cpi->initiator_id = hba->max_devices; cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "HPT ", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "HPT ", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->transport = XPORT_SPI; cpi->transport_version = 2; cpi->protocol = PROTO_SCSI; Modified: stable/11/sys/dev/hptmv/entry.c ============================================================================== --- stable/11/sys/dev/hptmv/entry.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/hptmv/entry.c Thu Mar 23 06:40:20 2017 (r315812) @@ -2325,9 +2325,9 @@ hpt_action(struct cam_sim *sim, union cc cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "HPT ", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "HPT ", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SPI; cpi->transport_version = 2; Modified: stable/11/sys/dev/hptnr/hptnr_osm_bsd.c ============================================================================== --- stable/11/sys/dev/hptnr/hptnr_osm_bsd.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/hptnr/hptnr_osm_bsd.c Thu Mar 23 06:40:20 2017 (r315812) @@ -1134,9 +1134,9 @@ static void hpt_action(struct cam_sim *s cpi->initiator_id = osm_max_targets; cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "HPT ", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "HPT ", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->transport = XPORT_SPI; cpi->transport_version = 2; cpi->protocol = PROTO_SCSI; Modified: stable/11/sys/dev/hptrr/hptrr_osm_bsd.c ============================================================================== --- stable/11/sys/dev/hptrr/hptrr_osm_bsd.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/hptrr/hptrr_osm_bsd.c Thu Mar 23 06:40:20 2017 (r315812) @@ -782,9 +782,9 @@ static void hpt_action(struct cam_sim *s cpi->initiator_id = osm_max_targets; cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "HPT ", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "HPT ", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->transport = XPORT_SPI; cpi->transport_version = 2; cpi->protocol = PROTO_SCSI; Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Thu Mar 23 06:40:20 2017 (r315812) @@ -266,10 +266,10 @@ static const struct hyperv_guid gBlkVscD }; static struct storvsc_driver_props g_drv_props_table[] = { - {"blkvsc", "Hyper-V IDE Storage Interface", + {"blkvsc", "Hyper-V IDE", BLKVSC_MAX_IDE_DISKS_PER_TARGET, BLKVSC_MAX_IO_REQUESTS, 20*PAGE_SIZE}, - {"storvsc", "Hyper-V SCSI Storage Interface", + {"storvsc", "Hyper-V SCSI", STORVSC_MAX_LUNS_PER_TARGET, STORVSC_MAX_IO_REQUESTS, 20*PAGE_SIZE} }; @@ -1451,9 +1451,9 @@ storvsc_action(struct cam_sim *sim, unio cpi->transport_version = 0; cpi->protocol = PROTO_SCSI; cpi->protocol_version = SCSI_REV_SPC2; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, sc->hs_drv_props->drv_name, HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, sc->hs_drv_props->drv_name, HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); ccb->ccb_h.status = CAM_REQ_CMP; Modified: stable/11/sys/dev/iir/iir.c ============================================================================== --- stable/11/sys/dev/iir/iir.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/iir/iir.c Thu Mar 23 06:40:20 2017 (r315812) @@ -1366,12 +1366,12 @@ iir_action( struct cam_sim *sim, union c cpi->initiator_id = (bus == gdt->sc_virt_bus ? 127 : gdt->sc_bus_id[bus]); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); if (gdt->sc_vendor == INTEL_VENDOR_ID_IIR) - strncpy(cpi->hba_vid, "Intel Corp.", HBA_IDLEN); + strlcpy(cpi->hba_vid, "Intel Corp.", HBA_IDLEN); else - strncpy(cpi->hba_vid, "ICP vortex ", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->hba_vid, "ICP vortex ", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->transport = XPORT_SPI; cpi->transport_version = 2; cpi->protocol = PROTO_SCSI; Modified: stable/11/sys/dev/isci/isci_controller.c ============================================================================== --- stable/11/sys/dev/isci/isci_controller.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/isci/isci_controller.c Thu Mar 23 06:40:20 2017 (r315812) @@ -691,9 +691,9 @@ void isci_action(struct cam_sim *sim, un cpi->bus_id = bus; cpi->initiator_id = SCI_MAX_REMOTE_DEVICES; cpi->base_transfer_speed = 300000; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Intel Corp.", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Intel Corp.", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->transport = XPORT_SAS; cpi->transport_version = 0; cpi->protocol = PROTO_SCSI; Modified: stable/11/sys/dev/iscsi_initiator/isc_cam.c ============================================================================== --- stable/11/sys/dev/iscsi_initiator/isc_cam.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/iscsi_initiator/isc_cam.c Thu Mar 23 06:40:20 2017 (r315812) @@ -76,9 +76,9 @@ _inq(struct cam_sim *sim, union ccb *ccb cpi->max_lun = sp->opt.maxluns - 1; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; // 40000; // XXX: - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "iSCSI", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "iSCSI", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->ccb_h.status = CAM_REQ_CMP; #if defined(KNOB_VALID_ADDRESS) Modified: stable/11/sys/dev/isp/isp_freebsd.c ============================================================================== --- stable/11/sys/dev/isp/isp_freebsd.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/isp/isp_freebsd.c Thu Mar 23 06:40:20 2017 (r315812) @@ -3922,9 +3922,9 @@ isp_action(struct cam_sim *sim, union cc } cpi->protocol = PROTO_SCSI; cpi->protocol_version = SCSI_REV_2; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Qlogic", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Qlogic", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); Modified: stable/11/sys/dev/mfi/mfi_cam.c ============================================================================== --- stable/11/sys/dev/mfi/mfi_cam.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/mfi/mfi_cam.c Thu Mar 23 06:40:20 2017 (r315812) @@ -222,9 +222,9 @@ mfip_cam_action(struct cam_sim *sim, uni cpi->max_target = MFI_SCSI_MAX_TARGETS; cpi->max_lun = MFI_SCSI_MAX_LUNS; cpi->initiator_id = MFI_SCSI_INITIATOR_ID; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "LSI", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "LSI", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 150000; Modified: stable/11/sys/dev/mly/mly.c ============================================================================== --- stable/11/sys/dev/mly/mly.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/mly/mly.c Thu Mar 23 06:40:20 2017 (r315812) @@ -2109,9 +2109,9 @@ mly_cam_action(struct cam_sim *sim, unio cpi->max_target = MLY_MAX_TARGETS - 1; cpi->max_lun = MLY_MAX_LUNS - 1; cpi->initiator_id = sc->mly_controllerparam->initiator_id; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "FreeBSD", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Mylex", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 132 * 1024; /* XXX what to set this to? */ Modified: stable/11/sys/dev/mpr/mpr_sas.c ============================================================================== --- stable/11/sys/dev/mpr/mpr_sas.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/mpr/mpr_sas.c Thu Mar 23 06:40:20 2017 (r315812) @@ -987,9 +987,9 @@ mprsas_action(struct cam_sim *sim, union cpi->max_target = sassc->maxtargets - 1; cpi->max_lun = 255; cpi->initiator_id = sassc->maxtargets - 1; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Avago Tech (LSI)", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Avago Tech", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); /* Modified: stable/11/sys/dev/mps/mps_sas.c ============================================================================== --- stable/11/sys/dev/mps/mps_sas.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/mps/mps_sas.c Thu Mar 23 06:40:20 2017 (r315812) @@ -943,9 +943,9 @@ mpssas_action(struct cam_sim *sim, union cpi->max_target = sassc->maxtargets - 1; cpi->max_lun = 255; cpi->initiator_id = sassc->maxtargets - 1; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Avago Tech (LSI)", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Avago Tech", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 150000; Modified: stable/11/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/11/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:40:20 2017 (r315812) @@ -3583,9 +3583,9 @@ mpt_action(struct cam_sim *sim, union cc } else { cpi->target_sprt = 0; } - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "LSI", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "LSI", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->ccb_h.status = CAM_REQ_CMP; break; Modified: stable/11/sys/dev/mrsas/mrsas_cam.c ============================================================================== --- stable/11/sys/dev/mrsas/mrsas_cam.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/mrsas/mrsas_cam.c Thu Mar 23 06:40:20 2017 (r315812) @@ -333,9 +333,9 @@ mrsas_action(struct cam_sim *sim, union ccb->cpi.bus_id = cam_sim_bus(sim); ccb->cpi.initiator_id = MRSAS_SCSI_INITIATOR_ID; ccb->cpi.base_transfer_speed = 150000; - strncpy(ccb->cpi.sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(ccb->cpi.hba_vid, "AVAGO", HBA_IDLEN); - strncpy(ccb->cpi.dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(ccb->cpi.sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(ccb->cpi.hba_vid, "AVAGO", HBA_IDLEN); + strlcpy(ccb->cpi.dev_name, cam_sim_name(sim), DEV_IDLEN); ccb->cpi.transport = XPORT_SPI; ccb->cpi.transport_version = 2; ccb->cpi.protocol = PROTO_SCSI; Modified: stable/11/sys/dev/mvs/mvs.c ============================================================================== --- stable/11/sys/dev/mvs/mvs.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/mvs/mvs.c Thu Mar 23 06:40:20 2017 (r315812) @@ -2413,9 +2413,9 @@ mvsaction(struct cam_sim *sim, union ccb cpi->initiator_id = 0; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 150000; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Marvell", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Marvell", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SATA; cpi->transport_version = XPORT_VERSION_UNSPECIFIED; Modified: stable/11/sys/dev/ncr/ncr.c ============================================================================== --- stable/11/sys/dev/ncr/ncr.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/ncr/ncr.c Thu Mar 23 06:40:20 2017 (r315812) @@ -4343,9 +4343,9 @@ ncr_action (struct cam_sim *sim, union c cpi->initiator_id = np->myaddr; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Symbios", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Symbios", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SPI; cpi->transport_version = 2; Modified: stable/11/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c ============================================================================== --- stable/11/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c Thu Mar 23 06:40:20 2017 (r315812) @@ -1838,9 +1838,9 @@ static void agtiapi_cam_action( struct c cpi->max_lun = AGTIAPI_MAX_LUN; cpi->maxio = 1024 *1024; /* Max supported I/O size, in bytes. */ cpi->initiator_id = 255; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "PMC", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "PMC", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); // rate is set when XPT_GET_TRAN_SETTINGS is processed Modified: stable/11/sys/dev/ppbus/vpo.c ============================================================================== --- stable/11/sys/dev/ppbus/vpo.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/ppbus/vpo.c Thu Mar 23 06:40:20 2017 (r315812) @@ -390,9 +390,9 @@ vpo_action(struct cam_sim *sim, union cc cpi->initiator_id = VP0_INITIATOR; cpi->bus_id = sim->bus_id; cpi->base_transfer_speed = 93; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Iomega", HBA_IDLEN); - strncpy(cpi->dev_name, sim->sim_name, DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Iomega", HBA_IDLEN); + strlcpy(cpi->dev_name, sim->sim_name, DEV_IDLEN); cpi->unit_number = sim->unit_number; cpi->transport = XPORT_PPB; cpi->transport_version = 0; Modified: stable/11/sys/dev/siis/siis.c ============================================================================== --- stable/11/sys/dev/siis/siis.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/siis/siis.c Thu Mar 23 06:40:20 2017 (r315812) @@ -1955,9 +1955,9 @@ siisaction(struct cam_sim *sim, union cc cpi->initiator_id = 0; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 150000; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "SIIS", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "SIIS", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SATA; cpi->transport_version = XPORT_VERSION_UNSPECIFIED; Modified: stable/11/sys/dev/sym/sym_hipd.c ============================================================================== --- stable/11/sys/dev/sym/sym_hipd.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/sym/sym_hipd.c Thu Mar 23 06:40:20 2017 (r315812) @@ -8047,9 +8047,9 @@ static void sym_action2(struct cam_sim * cpi->bus_id = cam_sim_bus(sim); cpi->initiator_id = np->myaddr; cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Symbios", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Symbios", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->protocol = PROTO_SCSI; Modified: stable/11/sys/dev/trm/trm.c ============================================================================== --- stable/11/sys/dev/trm/trm.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/trm/trm.c Thu Mar 23 06:40:20 2017 (r315812) @@ -636,9 +636,9 @@ trm_action(struct cam_sim *psim, union c cpi->initiator_id = pACB->AdaptSCSIID; cpi->bus_id = cam_sim_bus(psim); cpi->base_transfer_speed = 3300; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Tekram_TRM", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(psim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Tekram_TRM", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(psim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(psim); cpi->transport = XPORT_SPI; cpi->transport_version = 2; Modified: stable/11/sys/dev/twa/tw_osl_cam.c ============================================================================== --- stable/11/sys/dev/twa/tw_osl_cam.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/twa/tw_osl_cam.c Thu Mar 23 06:40:20 2017 (r315812) @@ -424,9 +424,9 @@ twa_action(struct cam_sim *sim, union cc path_inq->bus_id = cam_sim_bus(sim); path_inq->initiator_id = TW_CL_MAX_NUM_UNITS; path_inq->base_transfer_speed = 100000; - strncpy(path_inq->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(path_inq->hba_vid, "3ware", HBA_IDLEN); - strncpy(path_inq->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(path_inq->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(path_inq->hba_vid, "3ware", HBA_IDLEN); + strlcpy(path_inq->dev_name, cam_sim_name(sim), DEV_IDLEN); path_inq->transport = XPORT_SPI; path_inq->transport_version = 2; path_inq->protocol = PROTO_SCSI; Modified: stable/11/sys/dev/tws/tws_cam.c ============================================================================== --- stable/11/sys/dev/tws/tws_cam.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/tws/tws_cam.c Thu Mar 23 06:40:20 2017 (r315812) @@ -309,9 +309,9 @@ tws_action(struct cam_sim *sim, union cc ccb->cpi.bus_id = cam_sim_bus(sim); ccb->cpi.initiator_id = TWS_SCSI_INITIATOR_ID; ccb->cpi.base_transfer_speed = 6000000; - strncpy(ccb->cpi.sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(ccb->cpi.hba_vid, "3ware", HBA_IDLEN); - strncpy(ccb->cpi.dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(ccb->cpi.sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(ccb->cpi.hba_vid, "3ware", HBA_IDLEN); + strlcpy(ccb->cpi.dev_name, cam_sim_name(sim), DEV_IDLEN); #if (__FreeBSD_version >= 700000 ) ccb->cpi.transport = XPORT_SPI; ccb->cpi.transport_version = 2; Modified: stable/11/sys/dev/virtio/scsi/virtio_scsi.c ============================================================================== --- stable/11/sys/dev/virtio/scsi/virtio_scsi.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/dev/virtio/scsi/virtio_scsi.c Thu Mar 23 06:40:20 2017 (r315812) @@ -917,9 +917,9 @@ vtscsi_cam_path_inquiry(struct vtscsi_so cpi->max_lun = sc->vtscsi_max_lun; cpi->initiator_id = VTSCSI_INITIATOR_ID; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "VirtIO", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "VirtIO", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); Modified: stable/11/sys/powerpc/ps3/ps3cdrom.c ============================================================================== --- stable/11/sys/powerpc/ps3/ps3cdrom.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/powerpc/ps3/ps3cdrom.c Thu Mar 23 06:40:20 2017 (r315812) @@ -420,9 +420,9 @@ ps3cdrom_action(struct cam_sim *sim, uni cpi->bus_id = cam_sim_bus(sim); cpi->unit_number = cam_sim_unit(sim); cpi->base_transfer_speed = 150000; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "Sony", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "Sony", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->transport = XPORT_SPI; cpi->transport_version = 2; cpi->protocol = PROTO_SCSI; Modified: stable/11/sys/powerpc/pseries/phyp_vscsi.c ============================================================================== --- stable/11/sys/powerpc/pseries/phyp_vscsi.c Thu Mar 23 06:37:23 2017 (r315811) +++ stable/11/sys/powerpc/pseries/phyp_vscsi.c Thu Mar 23 06:40:20 2017 (r315812) @@ -429,9 +429,9 @@ vscsi_cam_action(struct cam_sim *sim, un cpi->max_target = 0; cpi->max_lun = 0; cpi->initiator_id = ~0; - strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); - strncpy(cpi->hba_vid, "IBM", HBA_IDLEN); - strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strlcpy(cpi->hba_vid, "IBM", HBA_IDLEN); + strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 150000; From owner-svn-src-stable-11@freebsd.org Thu Mar 23 06:42:00 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 31BDCD19656; Thu, 23 Mar 2017 06:42:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F2B8C80A; Thu, 23 Mar 2017 06:41:59 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N6fxEN056484; Thu, 23 Mar 2017 06:41:59 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6fx6I056483; Thu, 23 Mar 2017 06:41:59 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230641.v2N6fx6I056483@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:41:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315814 - stable/11/sys/dev/mpt X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 06:42:00 -0000 Author: mav Date: Thu Mar 23 06:41:58 2017 New Revision: 315814 URL: https://svnweb.freebsd.org/changeset/base/315814 Log: MFC r314966: Report FC link speed. Modified: stable/11/sys/dev/mpt/mpt_cam.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/11/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:41:13 2017 (r315813) +++ stable/11/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:41:58 2017 (r315814) @@ -433,7 +433,23 @@ mpt_read_config_info_fc(struct mpt_softc } mpt2host_config_page_fc_port_0(&mpt->mpt_fcport_page0); - mpt->mpt_fcport_speed = mpt->mpt_fcport_page0.CurrentSpeed; + switch (mpt->mpt_fcport_page0.CurrentSpeed) { + case MPI_FCPORTPAGE0_CURRENT_SPEED_1GBIT: + mpt->mpt_fcport_speed = 1; + break; + case MPI_FCPORTPAGE0_CURRENT_SPEED_2GBIT: + mpt->mpt_fcport_speed = 2; + break; + case MPI_FCPORTPAGE0_CURRENT_SPEED_10GBIT: + mpt->mpt_fcport_speed = 10; + break; + case MPI_FCPORTPAGE0_CURRENT_SPEED_4GBIT: + mpt->mpt_fcport_speed = 4; + break; + default: + mpt->mpt_fcport_speed = 0; + break; + } switch (mpt->mpt_fcport_page0.Flags & MPI_FCPORTPAGE0_FLAGS_ATTACH_TYPE_MASK) { @@ -3465,8 +3481,10 @@ mpt_action(struct cam_sim *sim, union cc cts->protocol_version = SCSI_REV_SPC; cts->transport = XPORT_FC; cts->transport_version = 0; - fc->valid = CTS_FC_VALID_SPEED; - fc->bitrate = 100000; + if (mpt->mpt_fcport_speed != 0) { + fc->valid = CTS_FC_VALID_SPEED; + fc->bitrate = 100000 * mpt->mpt_fcport_speed; + } } else if (mpt->is_sas) { struct ccb_trans_settings_sas *sas = &cts->xport_specific.sas; From owner-svn-src-stable-11@freebsd.org Thu Mar 23 06:45:13 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 44B7DD197D6; Thu, 23 Mar 2017 06:45:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EDF6BCFF; Thu, 23 Mar 2017 06:45:12 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N6jC3D056770; Thu, 23 Mar 2017 06:45:12 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6jBHu056768; Thu, 23 Mar 2017 06:45:11 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230645.v2N6jBHu056768@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:45:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315816 - stable/11/sys/dev/mpt X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 06:45:13 -0000 Author: mav Date: Thu Mar 23 06:45:11 2017 New Revision: 315816 URL: https://svnweb.freebsd.org/changeset/base/315816 Log: MFC r314968: Report some more data in XPT_PATH_INQ. I am not sure they are used anywhere, but why not. Modified: stable/11/sys/dev/mpt/mpt.h stable/11/sys/dev/mpt/mpt_cam.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mpt/mpt.h ============================================================================== --- stable/11/sys/dev/mpt/mpt.h Thu Mar 23 06:42:27 2017 (r315815) +++ stable/11/sys/dev/mpt/mpt.h Thu Mar 23 06:45:11 2017 (r315816) @@ -614,6 +614,7 @@ struct mpt_softc { struct { char wwnn[19]; char wwpn[19]; + uint32_t portid; } fc; } scinfo; Modified: stable/11/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/11/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:42:27 2017 (r315815) +++ stable/11/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:45:11 2017 (r315816) @@ -475,6 +475,12 @@ mpt_read_config_info_fc(struct mpt_softc break; } + mpt->scinfo.fc.wwnn = ((uint64_t)mpt->mpt_fcport_page0.WWNN.High << 32) + | mpt->mpt_fcport_page0.WWNN.Low; + mpt->scinfo.fc.wwpn = ((uint64_t)mpt->mpt_fcport_page0.WWPN.High << 32) + | mpt->mpt_fcport_page0.WWPN.Low; + mpt->scinfo.fc.portid = mpt->mpt_fcport_page0.PortIdentifier; + mpt_lprt(mpt, MPT_PRT_INFO, "FC Port Page 0: Topology <%s> WWNN 0x%08x%08x WWPN 0x%08x%08x " "Speed %u-Gbit\n", topology, @@ -3566,6 +3572,11 @@ mpt_action(struct cam_sim *sim, union cc cpi->transport = XPORT_FC; cpi->transport_version = 0; cpi->protocol_version = SCSI_REV_SPC; + cpi->xport_specific.fc.wwnn = mpt->scinfo.fc.wwnn; + cpi->xport_specific.fc.wwpn = mpt->scinfo.fc.wwpn; + cpi->xport_specific.fc.port = mpt->scinfo.fc.portid; + cpi->xport_specific.fc.bitrate = + 100000 * mpt->mpt_fcport_speed; } else if (mpt->is_sas) { cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED; cpi->base_transfer_speed = 300000; From owner-svn-src-stable-11@freebsd.org Thu Mar 23 06:47:09 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EA829D19920; Thu, 23 Mar 2017 06:47:09 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C2728FB7; Thu, 23 Mar 2017 06:47:09 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N6l8SU056947; Thu, 23 Mar 2017 06:47:08 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6l81D056945; Thu, 23 Mar 2017 06:47:08 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230647.v2N6l81D056945@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:47:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315818 - stable/11/sys/dev/mpt X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 06:47:10 -0000 Author: mav Date: Thu Mar 23 06:47:08 2017 New Revision: 315818 URL: https://svnweb.freebsd.org/changeset/base/315818 Log: MFC r314967: Add support for XPT_GET_SIM_KNOB in FC mode. Modified: stable/11/sys/dev/mpt/mpt.h stable/11/sys/dev/mpt/mpt_cam.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mpt/mpt.h ============================================================================== --- stable/11/sys/dev/mpt/mpt.h Thu Mar 23 06:45:57 2017 (r315817) +++ stable/11/sys/dev/mpt/mpt.h Thu Mar 23 06:47:08 2017 (r315818) @@ -612,8 +612,8 @@ struct mpt_softc { unsigned int initiator_id; } spi; struct { - char wwnn[19]; - char wwpn[19]; + uint64_t wwnn; + uint64_t wwpn; uint32_t portid; } fc; } scinfo; Modified: stable/11/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/11/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:45:57 2017 (r315817) +++ stable/11/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:47:08 2017 (r315818) @@ -482,31 +482,20 @@ mpt_read_config_info_fc(struct mpt_softc mpt->scinfo.fc.portid = mpt->mpt_fcport_page0.PortIdentifier; mpt_lprt(mpt, MPT_PRT_INFO, - "FC Port Page 0: Topology <%s> WWNN 0x%08x%08x WWPN 0x%08x%08x " + "FC Port Page 0: Topology <%s> WWNN 0x%16jx WWPN 0x%16jx " "Speed %u-Gbit\n", topology, - mpt->mpt_fcport_page0.WWNN.High, - mpt->mpt_fcport_page0.WWNN.Low, - mpt->mpt_fcport_page0.WWPN.High, - mpt->mpt_fcport_page0.WWPN.Low, + (uintmax_t)mpt->scinfo.fc.wwnn, (uintmax_t)mpt->scinfo.fc.wwpn, mpt->mpt_fcport_speed); MPT_UNLOCK(mpt); ctx = device_get_sysctl_ctx(mpt->dev); tree = device_get_sysctl_tree(mpt->dev); - snprintf(mpt->scinfo.fc.wwnn, sizeof (mpt->scinfo.fc.wwnn), - "0x%08x%08x", mpt->mpt_fcport_page0.WWNN.High, - mpt->mpt_fcport_page0.WWNN.Low); - - snprintf(mpt->scinfo.fc.wwpn, sizeof (mpt->scinfo.fc.wwpn), - "0x%08x%08x", mpt->mpt_fcport_page0.WWPN.High, - mpt->mpt_fcport_page0.WWPN.Low); - - SYSCTL_ADD_STRING(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "wwnn", CTLFLAG_RD, mpt->scinfo.fc.wwnn, 0, + SYSCTL_ADD_QUAD(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "wwnn", CTLFLAG_RD, &mpt->scinfo.fc.wwnn, "World Wide Node Name"); - SYSCTL_ADD_STRING(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "wwpn", CTLFLAG_RD, mpt->scinfo.fc.wwpn, 0, + SYSCTL_ADD_QUAD(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "wwpn", CTLFLAG_RD, &mpt->scinfo.fc.wwpn, "World Wide Port Name"); MPT_LOCK(mpt); @@ -3528,6 +3517,36 @@ mpt_action(struct cam_sim *sim, union cc KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d", __LINE__)); break; } + case XPT_GET_SIM_KNOB: + { + struct ccb_sim_knob *kp = &ccb->knob; + + if (mpt->is_fc) { + kp->xport_specific.fc.wwnn = mpt->scinfo.fc.wwnn; + kp->xport_specific.fc.wwpn = mpt->scinfo.fc.wwpn; + switch (mpt->role) { + case MPT_ROLE_NONE: + kp->xport_specific.fc.role = KNOB_ROLE_NONE; + break; + case MPT_ROLE_INITIATOR: + kp->xport_specific.fc.role = KNOB_ROLE_INITIATOR; + break; + case MPT_ROLE_TARGET: + kp->xport_specific.fc.role = KNOB_ROLE_TARGET; + break; + case MPT_ROLE_BOTH: + kp->xport_specific.fc.role = KNOB_ROLE_BOTH; + break; + } + kp->xport_specific.fc.valid = + KNOB_VALID_ADDRESS | KNOB_VALID_ROLE; + ccb->ccb_h.status = CAM_REQ_CMP; + } else { + ccb->ccb_h.status = CAM_REQ_INVALID; + } + xpt_done(ccb); + break; + } case XPT_PATH_INQ: /* Path routing inquiry */ { struct ccb_pathinq *cpi = &ccb->cpi; From owner-svn-src-stable-11@freebsd.org Thu Mar 23 06:48:32 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9D62DD19A87; Thu, 23 Mar 2017 06:48:32 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5A56812E1; Thu, 23 Mar 2017 06:48:32 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N6mVG8057104; Thu, 23 Mar 2017 06:48:31 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6mVZZ057102; Thu, 23 Mar 2017 06:48:31 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230648.v2N6mVZZ057102@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:48:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315820 - stable/11/sys/dev/mpt X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 06:48:32 -0000 Author: mav Date: Thu Mar 23 06:48:31 2017 New Revision: 315820 URL: https://svnweb.freebsd.org/changeset/base/315820 Log: MFC r314998: Fix FC target mode in mpt(4), broken in multiple ways. - Not set BufferLength caused receive of empty ATIOs. - CDB length guessing was broken at least for RC16. - mpt_req_untimeout() was called with wrong req parameter. - Sense data reporting was broken in several ways. With this change my LSI7204EP-LC can pass at least basic tests as target. The code is still far from perfect, but finally I found second hw/driver after isp(4) that really can work in CAM target mode. Modified: stable/11/sys/dev/mpt/mpt.h stable/11/sys/dev/mpt/mpt_cam.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mpt/mpt.h ============================================================================== --- stable/11/sys/dev/mpt/mpt.h Thu Mar 23 06:47:48 2017 (r315819) +++ stable/11/sys/dev/mpt/mpt.h Thu Mar 23 06:48:31 2017 (r315820) @@ -949,24 +949,6 @@ void mpt_prtc(struct mpt_softc *, const __printflike(2, 3); /**************************** Target Mode Related ***************************/ -static __inline int mpt_cdblen(uint8_t, int); -static __inline int -mpt_cdblen(uint8_t cdb0, int maxlen) -{ - int group = cdb0 >> 5; - switch (group) { - case 0: - return (6); - case 1: - return (10); - case 4: - case 5: - return (12); - default: - return (16); - } -} - #ifdef INVARIANTS static __inline request_t * mpt_tag_2_req(struct mpt_softc *, uint32_t); static __inline request_t * Modified: stable/11/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/11/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:47:48 2017 (r315819) +++ stable/11/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:48:31 2017 (r315820) @@ -145,7 +145,7 @@ static void mpt_target_start_io(struct m static cam_status mpt_abort_target_ccb(struct mpt_softc *, union ccb *); static int mpt_abort_target_cmd(struct mpt_softc *, request_t *); static void mpt_scsi_tgt_status(struct mpt_softc *, union ccb *, request_t *, - uint8_t, uint8_t const *); + uint8_t, uint8_t const *, u_int); static void mpt_scsi_tgt_tsk_mgmt(struct mpt_softc *, request_t *, mpt_task_mgmt_t, tgt_resource_t *, int); @@ -4168,6 +4168,7 @@ mpt_post_target_command(struct mpt_softc fc = req->req_vbuf; fc->BufferCount = 1; fc->Function = MPI_FUNCTION_TARGET_CMD_BUFFER_POST; + fc->BufferLength = MIN(MPT_REQUEST_AREA - MPT_RQSL(mpt), UINT8_MAX); fc->MsgContext = htole32(req->index | mpt->scsi_tgt_handler_id); cb = &fc->Buffer[0]; @@ -4458,8 +4459,6 @@ mpt_target_start_io(struct mpt_softc *mp ccb->ccb_h.status |= CAM_RELEASE_SIMQ; } } else { - uint8_t *sp = NULL, sense[MPT_SENSE_SIZE]; - /* * XXX: I don't know why this seems to happen, but * XXX: completing the CCB seems to make things happy. @@ -4476,12 +4475,10 @@ mpt_target_start_io(struct mpt_softc *mp xpt_done(ccb); return; } - if (ccb->ccb_h.flags & CAM_SEND_SENSE) { - sp = sense; - memcpy(sp, &csio->sense_data, - min(csio->sense_len, MPT_SENSE_SIZE)); - } - mpt_scsi_tgt_status(mpt, ccb, cmd_req, csio->scsi_status, sp); + mpt_scsi_tgt_status(mpt, ccb, cmd_req, csio->scsi_status, + (void *)&csio->sense_data, + (ccb->ccb_h.flags & CAM_SEND_SENSE) ? + csio->sense_len : 0); } } @@ -4503,7 +4500,7 @@ mpt_scsi_tgt_local(struct mpt_softc *mpt tgt = MPT_TGT_STATE(mpt, cmd_req); if (length == 0 || tgt->resid == 0) { tgt->resid = 0; - mpt_scsi_tgt_status(mpt, NULL, cmd_req, 0, NULL); + mpt_scsi_tgt_status(mpt, NULL, cmd_req, 0, NULL, 0); return; } @@ -4656,7 +4653,7 @@ mpt_abort_target_cmd(struct mpt_softc *m static void mpt_scsi_tgt_status(struct mpt_softc *mpt, union ccb *ccb, request_t *cmd_req, - uint8_t status, uint8_t const *sense_data) + uint8_t status, uint8_t const *sense_data, u_int sense_len) { uint8_t *cmd_vbuf; mpt_tgt_state_t *tgt; @@ -4730,37 +4727,22 @@ mpt_scsi_tgt_status(struct mpt_softc *mp */ memset(rsp, 0, sizeof (MPI_TARGET_FCP_RSP_BUFFER)); - rsp[2] = status; + rsp[2] = htobe32(status); +#define MIN_FCP_RESPONSE_SIZE 24 +#ifndef WE_TRUST_AUTO_GOOD_STATUS + resplen = MIN_FCP_RESPONSE_SIZE; +#endif if (tgt->resid) { - rsp[2] |= 0x800; /* XXXX NEED MNEMONIC!!!! */ + rsp[2] |= htobe32(0x800); /* XXXX NEED MNEMONIC!!!! */ rsp[3] = htobe32(tgt->resid); -#ifdef WE_TRUST_AUTO_GOOD_STATUS - resplen = sizeof (MPI_TARGET_FCP_RSP_BUFFER); -#endif + resplen = MIN_FCP_RESPONSE_SIZE; } - if (status == SCSI_STATUS_CHECK_COND) { - int i; - - rsp[2] |= 0x200; /* XXXX NEED MNEMONIC!!!! */ - rsp[4] = htobe32(MPT_SENSE_SIZE); - if (sense_data) { - memcpy(&rsp[8], sense_data, MPT_SENSE_SIZE); - } else { - mpt_prt(mpt, "mpt_scsi_tgt_status: CHECK CONDI" - "TION but no sense data?\n"); - memset(&rsp, 0, MPT_SENSE_SIZE); - } - for (i = 8; i < (8 + (MPT_SENSE_SIZE >> 2)); i++) { - rsp[i] = htobe32(rsp[i]); - } -#ifdef WE_TRUST_AUTO_GOOD_STATUS - resplen = sizeof (MPI_TARGET_FCP_RSP_BUFFER); -#endif + if (sense_len > 0) { + rsp[2] |= htobe32(0x200); /* XXXX NEED MNEMONIC!!!! */ + rsp[4] = htobe32(sense_len); + memcpy(&rsp[6], sense_data, sense_len); + resplen = MIN_FCP_RESPONSE_SIZE + sense_len; } -#ifndef WE_TRUST_AUTO_GOOD_STATUS - resplen = sizeof (MPI_TARGET_FCP_RSP_BUFFER); -#endif - rsp[2] = htobe32(rsp[2]); } else if (mpt->is_sas) { PTR_MPI_TARGET_SSP_CMD_BUFFER ssp = (PTR_MPI_TARGET_SSP_CMD_BUFFER) cmd_vbuf; @@ -4795,9 +4777,9 @@ mpt_scsi_tgt_status(struct mpt_softc *mp } mpt_lprt(mpt, MPT_PRT_DEBUG, - "STATUS_CCB %p (wit%s sense) tag %x req %p:%u resid %u\n", - ccb, sense_data?"h" : "hout", ccb? ccb->csio.tag_id : -1, req, - req->serno, tgt->resid); + "STATUS_CCB %p (with%s sense) tag %x req %p:%u resid %u\n", + ccb, sense_len > 0 ? "" : "out", ccb ? ccb->csio.tag_id : -1, + req, req->serno, tgt->resid); if (ccb) { ccb->ccb_h.status = CAM_SIM_QUEUED | CAM_REQ_INPROG; mpt_req_timeout(req, SBT_1S * 60, mpt_timeout, ccb); @@ -4816,7 +4798,7 @@ mpt_scsi_tgt_tsk_mgmt(struct mpt_softc * inot = (struct ccb_immediate_notify *) STAILQ_FIRST(&trtp->inots); if (inot == NULL) { mpt_lprt(mpt, MPT_PRT_WARN, "no INOTSs- sending back BSY\n"); - mpt_scsi_tgt_status(mpt, NULL, req, SCSI_STATUS_BUSY, NULL); + mpt_scsi_tgt_status(mpt, NULL, req, SCSI_STATUS_BUSY, NULL, 0); return; } STAILQ_REMOVE_HEAD(&trtp->inots, sim_links.stqe); @@ -4930,8 +4912,8 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, default: mpt_prt(mpt, "CORRUPTED TASK MGMT BITS: 0x%x\n", fc->FcpCntl[2]); - mpt_scsi_tgt_status(mpt, 0, req, - SCSI_STATUS_OK, 0); + mpt_scsi_tgt_status(mpt, NULL, req, + SCSI_STATUS_OK, NULL, 0); return; } } else { @@ -5005,23 +4987,21 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, * REPORT LUNS gets illegal command. * All other commands get 'no such device'. */ - uint8_t *sp, cond, buf[MPT_SENSE_SIZE]; + uint8_t sense[MPT_SENSE_SIZE]; size_t len; - memset(buf, 0, MPT_SENSE_SIZE); - cond = SCSI_STATUS_CHECK_COND; - buf[0] = 0xf0; - buf[2] = 0x5; - buf[7] = 0x8; - sp = buf; + memset(sense, 0, sizeof(sense)); + sense[0] = 0xf0; + sense[2] = 0x5; + sense[7] = 0x8; tgt->tag_id = MPT_MAKE_TAGID(mpt, req, ioindex); switch (cdbp[0]) { case INQUIRY: { if (cdbp[1] != 0) { - buf[12] = 0x26; - buf[13] = 0x01; + sense[12] = 0x26; + sense[13] = 0x01; break; } len = min(tgt->resid, cdbp[4]); @@ -5034,27 +5014,28 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, } case REQUEST_SENSE: { - buf[2] = 0x0; + sense[2] = 0x0; len = min(tgt->resid, cdbp[4]); - len = min(len, sizeof (buf)); + len = min(len, sizeof (sense)); mpt_lprt(mpt, MPT_PRT_DEBUG, "local reqsense %ld bytes\n", (long) len); mpt_scsi_tgt_local(mpt, req, lun, 1, - buf, len); + sense, len); return; } case REPORT_LUNS: mpt_lprt(mpt, MPT_PRT_DEBUG, "REPORT LUNS\n"); - buf[12] = 0x26; + sense[12] = 0x26; return; default: mpt_lprt(mpt, MPT_PRT_DEBUG, "CMD 0x%x to unmanaged lun %jx\n", cdbp[0], (uintmax_t)lun); - buf[12] = 0x25; + sense[12] = 0x25; break; } - mpt_scsi_tgt_status(mpt, NULL, req, cond, sp); + mpt_scsi_tgt_status(mpt, NULL, req, + SCSI_STATUS_CHECK_COND, sense, sizeof(sense)); return; } /* otherwise, leave trtp NULL */ @@ -5069,8 +5050,8 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, if (trtp == NULL) { mpt_prt(mpt, "task mgmt function %x but no listener\n", fct); - mpt_scsi_tgt_status(mpt, 0, req, - SCSI_STATUS_OK, 0); + mpt_scsi_tgt_status(mpt, NULL, req, + SCSI_STATUS_OK, NULL, 0); } else { mpt_scsi_tgt_tsk_mgmt(mpt, req, fct, trtp, GET_INITIATOR_INDEX(reply_desc)); @@ -5086,7 +5067,7 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, mpt->tenabled? "QUEUE FULL" : "BUSY"); mpt_scsi_tgt_status(mpt, NULL, req, mpt->tenabled? SCSI_STATUS_QUEUE_FULL : SCSI_STATUS_BUSY, - NULL); + NULL, 0); return; } STAILQ_REMOVE_HEAD(&trtp->atios, sim_links.stqe); @@ -5098,7 +5079,7 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, atiop->ccb_h.target_lun = lun; atiop->sense_len = 0; atiop->init_id = GET_INITIATOR_INDEX(reply_desc); - atiop->cdb_len = mpt_cdblen(cdbp[0], 16); + atiop->cdb_len = 16; memcpy(atiop->cdb_io.cdb_bytes, cdbp, atiop->cdb_len); /* @@ -5179,8 +5160,6 @@ mpt_scsi_tgt_reply_handler(struct mpt_so break; case TGT_STATE_MOVING_DATA: { - uint8_t *sp = NULL, sense[MPT_SENSE_SIZE]; - ccb = tgt->ccb; if (tgt->req == NULL) { panic("mpt: turbo target reply with null " @@ -5200,12 +5179,12 @@ mpt_scsi_tgt_reply_handler(struct mpt_so mpt_free_request(mpt, tgt->req); tgt->req = NULL; mpt_scsi_tgt_status(mpt, NULL, req, - 0, NULL); + 0, NULL, 0); return (TRUE); } tgt->ccb = NULL; tgt->nxfers++; - mpt_req_untimeout(req, mpt_timeout, ccb); + mpt_req_untimeout(tgt->req, mpt_timeout, ccb); mpt_lprt(mpt, MPT_PRT_DEBUG, "TARGET_ASSIST %p (req %p:%u) done tag 0x%x\n", ccb, tgt->req, tgt->req->serno, ccb->csio.tag_id); @@ -5241,13 +5220,11 @@ mpt_scsi_tgt_reply_handler(struct mpt_so /* * Otherwise, send status (and sense) */ - if (ccb->ccb_h.flags & CAM_SEND_SENSE) { - sp = sense; - memcpy(sp, &ccb->csio.sense_data, - min(ccb->csio.sense_len, MPT_SENSE_SIZE)); - } mpt_scsi_tgt_status(mpt, ccb, req, - ccb->csio.scsi_status, sp); + ccb->csio.scsi_status, + (void *)&ccb->csio.sense_data, + (ccb->ccb_h.flags & CAM_SEND_SENSE) ? + ccb->csio.sense_len : 0); break; } case TGT_STATE_SENDING_STATUS: @@ -5268,7 +5245,7 @@ mpt_scsi_tgt_reply_handler(struct mpt_so TGT_STATE_MOVING_DATA_AND_STATUS) { tgt->nxfers++; } - mpt_req_untimeout(req, mpt_timeout, ccb); + mpt_req_untimeout(tgt->req, mpt_timeout, ccb); if (ccb->ccb_h.flags & CAM_SEND_SENSE) { ccb->ccb_h.status |= CAM_SENT_SENSE; } From owner-svn-src-stable-11@freebsd.org Thu Mar 23 06:49:38 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4634ED19B87; Thu, 23 Mar 2017 06:49:38 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 156681628; Thu, 23 Mar 2017 06:49:38 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N6nb1F057251; Thu, 23 Mar 2017 06:49:37 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6nb11057250; Thu, 23 Mar 2017 06:49:37 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230649.v2N6nb11057250@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:49:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315822 - stable/11/sys/dev/mpt X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 06:49:38 -0000 Author: mav Date: Thu Mar 23 06:49:36 2017 New Revision: 315822 URL: https://svnweb.freebsd.org/changeset/base/315822 Log: MFC r315001: Fix panic on wildcard target LUN disable. Modified: stable/11/sys/dev/mpt/mpt_cam.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/11/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:49:01 2017 (r315821) +++ stable/11/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:49:36 2017 (r315822) @@ -4319,7 +4319,7 @@ mpt_disable_lun(struct mpt_softc *mpt, t mpt->trt[lun].enabled = 0; } for (i = 0; i < MPT_MAX_LUNS; i++) { - if (mpt->trt[lun].enabled) { + if (mpt->trt[i].enabled) { break; } } From owner-svn-src-stable-11@freebsd.org Thu Mar 23 06:50:14 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E4145D19C09; Thu, 23 Mar 2017 06:50:14 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 996DB176F; Thu, 23 Mar 2017 06:50:14 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N6oDG1057357; Thu, 23 Mar 2017 06:50:13 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6oDiK057355; Thu, 23 Mar 2017 06:50:13 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230650.v2N6oDiK057355@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:50:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315823 - stable/11/sys/dev/mpt X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 06:50:15 -0000 Author: mav Date: Thu Mar 23 06:50:13 2017 New Revision: 315823 URL: https://svnweb.freebsd.org/changeset/base/315823 Log: MFC r315002: Improve residuals reporting in target mode. Modified: stable/11/sys/dev/mpt/mpt.h stable/11/sys/dev/mpt/mpt_cam.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mpt/mpt.h ============================================================================== --- stable/11/sys/dev/mpt/mpt.h Thu Mar 23 06:49:36 2017 (r315822) +++ stable/11/sys/dev/mpt/mpt.h Thu Mar 23 06:50:13 2017 (r315823) @@ -331,8 +331,8 @@ typedef struct mpt_config_params { /**************************** MPI Target State Info ***************************/ typedef struct { uint32_t reply_desc; /* current reply descriptor */ - uint32_t resid; /* current data residual */ uint32_t bytes_xfered; /* current relative offset */ + int resid; /* current data residual */ union ccb *ccb; /* pointer to currently active ccb */ request_t *req; /* pointer to currently active assist request */ uint32_t Modified: stable/11/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/11/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:49:36 2017 (r315822) +++ stable/11/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:50:13 2017 (r315823) @@ -4430,6 +4430,7 @@ mpt_target_start_io(struct mpt_softc *mp /* * XXX Should be done after data transfer completes? */ + csio->resid = csio->dxfer_len - ta->DataLength; tgt->resid -= csio->dxfer_len; tgt->bytes_xfered += csio->dxfer_len; @@ -4732,7 +4733,11 @@ mpt_scsi_tgt_status(struct mpt_softc *mp #ifndef WE_TRUST_AUTO_GOOD_STATUS resplen = MIN_FCP_RESPONSE_SIZE; #endif - if (tgt->resid) { + if (tgt->resid < 0) { + rsp[2] |= htobe32(0x400); /* XXXX NEED MNEMONIC!!!! */ + rsp[3] = htobe32(-tgt->resid); + resplen = MIN_FCP_RESPONSE_SIZE; + } else if (tgt->resid > 0) { rsp[2] |= htobe32(0x800); /* XXXX NEED MNEMONIC!!!! */ rsp[3] = htobe32(tgt->resid); resplen = MIN_FCP_RESPONSE_SIZE; From owner-svn-src-stable-11@freebsd.org Thu Mar 23 06:51:54 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D96A9D19E4B; Thu, 23 Mar 2017 06:51:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9BDC91B03; Thu, 23 Mar 2017 06:51:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N6prX7058395; Thu, 23 Mar 2017 06:51:53 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6prbA058393; Thu, 23 Mar 2017 06:51:53 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230651.v2N6prbA058393@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:51:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315825 - stable/11/sys/dev/mpt X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 06:51:55 -0000 Author: mav Date: Thu Mar 23 06:51:53 2017 New Revision: 315825 URL: https://svnweb.freebsd.org/changeset/base/315825 Log: MFC r315004: Add PIM_EXTLUNS support to mpt(4). Target mode is still limited to 256 LUNs due to the way driver is written, but initiator can now use full 8 byte LUN space. Modified: stable/11/sys/dev/mpt/mpt_cam.c stable/11/sys/dev/mpt/mpt_debug.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/11/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:50:46 2017 (r315824) +++ stable/11/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:51:53 2017 (r315825) @@ -133,7 +133,7 @@ static void mpt_recovery_thread(void *ar static void mpt_recover_commands(struct mpt_softc *mpt); static int mpt_scsi_send_tmf(struct mpt_softc *, u_int, u_int, u_int, - u_int, u_int, u_int, int); + target_id_t, lun_id_t, u_int, int); static void mpt_fc_post_els(struct mpt_softc *mpt, request_t *, int); static void mpt_post_target_command(struct mpt_softc *, request_t *, int); @@ -2133,13 +2133,7 @@ mpt_start(struct cam_sim *sim, union ccb /* Which physical device to do the I/O on */ mpt_req->TargetID = tgt; - /* We assume a single level LUN type */ - if (ccb->ccb_h.target_lun >= MPT_MAX_LUNS) { - mpt_req->LUN[0] = 0x40 | ((ccb->ccb_h.target_lun >> 8) & 0x3f); - mpt_req->LUN[1] = ccb->ccb_h.target_lun & 0xff; - } else { - mpt_req->LUN[1] = ccb->ccb_h.target_lun; - } + be64enc(mpt_req->LUN, CAM_EXTLUN_BYTE_SWIZZLE(ccb->ccb_h.target_lun)); /* Set the direction of the transfer */ if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { @@ -3585,7 +3579,8 @@ mpt_action(struct cam_sim *sim, union cc */ cpi->protocol = PROTO_SCSI; if (mpt->is_fc) { - cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED; + cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED | + PIM_EXTLUNS; cpi->base_transfer_speed = 100000; cpi->hba_inquiry = PI_TAG_ABLE; cpi->transport = XPORT_FC; @@ -3597,14 +3592,16 @@ mpt_action(struct cam_sim *sim, union cc cpi->xport_specific.fc.bitrate = 100000 * mpt->mpt_fcport_speed; } else if (mpt->is_sas) { - cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED; + cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED | + PIM_EXTLUNS; cpi->base_transfer_speed = 300000; cpi->hba_inquiry = PI_TAG_ABLE; cpi->transport = XPORT_SAS; cpi->transport_version = 0; cpi->protocol_version = SCSI_REV_SPC2; } else { - cpi->hba_misc = PIM_SEQSCAN | PIM_UNMAPPED; + cpi->hba_misc = PIM_SEQSCAN | PIM_UNMAPPED | + PIM_EXTLUNS; cpi->base_transfer_speed = 3300; cpi->hba_inquiry = PI_SDTR_ABLE|PI_TAG_ABLE|PI_WIDE_16; cpi->transport = XPORT_SPI; @@ -3913,7 +3910,8 @@ mpt_recovery_thread(void *arg) static int mpt_scsi_send_tmf(struct mpt_softc *mpt, u_int type, u_int flags, - u_int channel, u_int target, u_int lun, u_int abort_ctx, int sleep_ok) + u_int channel, target_id_t target, lun_id_t lun, u_int abort_ctx, + int sleep_ok) { MSG_SCSI_TASK_MGMT *tmf_req; int error; @@ -3941,12 +3939,7 @@ mpt_scsi_send_tmf(struct mpt_softc *mpt, tmf_req->MsgFlags = flags; tmf_req->MsgContext = htole32(mpt->tmf_req->index | scsi_tmf_handler_id); - if (lun > MPT_MAX_LUNS) { - tmf_req->LUN[0] = 0x40 | ((lun >> 8) & 0x3f); - tmf_req->LUN[1] = lun & 0xff; - } else { - tmf_req->LUN[1] = lun; - } + be64enc(tmf_req->LUN, CAM_EXTLUN_BYTE_SWIZZLE(lun)); tmf_req->TaskMsgContext = abort_ctx; mpt_lprt(mpt, MPT_PRT_DEBUG, @@ -4413,13 +4406,7 @@ mpt_target_start_io(struct mpt_softc *mp ta->Function = MPI_FUNCTION_TARGET_ASSIST; ta->MsgContext = htole32(req->index | mpt->scsi_tgt_handler_id); ta->ReplyWord = htole32(tgt->reply_desc); - if (csio->ccb_h.target_lun > MPT_MAX_LUNS) { - ta->LUN[0] = - 0x40 | ((csio->ccb_h.target_lun >> 8) & 0x3f); - ta->LUN[1] = csio->ccb_h.target_lun & 0xff; - } else { - ta->LUN[1] = csio->ccb_h.target_lun; - } + be64enc(ta->LUN, CAM_EXTLUN_BYTE_SWIZZLE(csio->ccb_h.target_lun)); ta->RelativeOffset = tgt->bytes_xfered; ta->DataLength = ccb->csio.dxfer_len; @@ -4485,7 +4472,7 @@ mpt_target_start_io(struct mpt_softc *mp static void mpt_scsi_tgt_local(struct mpt_softc *mpt, request_t *cmd_req, - uint32_t lun, int send, uint8_t *data, size_t length) + lun_id_t lun, int send, uint8_t *data, size_t length) { mpt_tgt_state_t *tgt; PTR_MSG_TARGET_ASSIST_REQUEST ta; @@ -4525,12 +4512,7 @@ mpt_scsi_tgt_local(struct mpt_softc *mpt ta->Function = MPI_FUNCTION_TARGET_ASSIST; ta->MsgContext = htole32(req->index | mpt->scsi_tgt_handler_id); ta->ReplyWord = htole32(tgt->reply_desc); - if (lun > MPT_MAX_LUNS) { - ta->LUN[0] = 0x40 | ((lun >> 8) & 0x3f); - ta->LUN[1] = lun & 0xff; - } else { - ta->LUN[1] = lun; - } + be64enc(ta->LUN, CAM_EXTLUN_BYTE_SWIZZLE(lun)); ta->RelativeOffset = 0; ta->DataLength = length; @@ -4958,21 +4940,7 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, itag = sp->Tag; } - /* - * Generate a simple lun - */ - switch (lunptr[0] & 0xc0) { - case 0x40: - lun = ((lunptr[0] & 0x3f) << 8) | lunptr[1]; - break; - case 0: - lun = lunptr[1]; - break; - default: - mpt_lprt(mpt, MPT_PRT_ERROR, "cannot handle this type lun\n"); - lun = 0xffff; - break; - } + lun = CAM_EXTLUN_BYTE_SWIZZLE(be64dec(lunptr)); /* * Deal with non-enabled or bad luns here. Modified: stable/11/sys/dev/mpt/mpt_debug.c ============================================================================== --- stable/11/sys/dev/mpt/mpt_debug.c Thu Mar 23 06:50:46 2017 (r315824) +++ stable/11/sys/dev/mpt/mpt_debug.c Thu Mar 23 06:51:53 2017 (r315825) @@ -536,7 +536,7 @@ mpt_print_scsi_io_request(MSG_SCSI_IO_RE printf("\tBus: %d\n", msg->Bus); printf("\tTargetID %d\n", msg->TargetID); printf("\tSenseBufferLength %d\n", msg->SenseBufferLength); - printf("\tLUN: 0x%0x\n", msg->LUN[1]); + printf("\tLUN: 0x%jx\n", (uintmax_t)be64dec(msg->LUN)); printf("\tControl 0x%08x ", msg->Control); #define MPI_PRINT_FIELD(x) \ case MPI_SCSIIO_CONTROL_ ## x : \ @@ -585,7 +585,7 @@ mpt_print_scsi_tmf_request(MSG_SCSI_TASK { mpt_print_request_hdr((MSG_REQUEST_HEADER *)msg); - printf("\tLun 0x%02x\n", msg->LUN[1]); + printf("\tLun 0x%jx\n", (uintmax_t)be64dec(msg->LUN)); printf("\tTaskType %s\n", mpt_scsi_tm_type(msg->TaskType)); printf("\tTaskMsgContext 0x%08x\n", msg->TaskMsgContext); } @@ -600,7 +600,7 @@ mpt_print_scsi_target_assist_request(PTR printf("\tTargetAssist 0x%02x\n", msg->TargetAssistFlags); printf("\tQueueTag 0x%04x\n", msg->QueueTag); printf("\tReplyWord 0x%08x\n", msg->ReplyWord); - printf("\tLun 0x%02x\n", msg->LUN[1]); + printf("\tLun 0x%jx\n", (uintmax_t)be64dec(msg->LUN)); printf("\tRelativeOff 0x%08x\n", msg->RelativeOffset); printf("\tDataLength 0x%08x\n", msg->DataLength); mpt_dump_sgl(msg->SGL, 0); @@ -616,7 +616,7 @@ mpt_print_scsi_target_status_send_reques printf("\tStatusFlags 0x%02x\n", msg->StatusFlags); printf("\tQueueTag 0x%04x\n", msg->QueueTag); printf("\tReplyWord 0x%08x\n", msg->ReplyWord); - printf("\tLun 0x%02x\n", msg->LUN[1]); + printf("\tLun 0x%jx\n", (uintmax_t)be64dec(msg->LUN)); x.u.Simple = msg->StatusDataSGE; mpt_dump_sgl(&x, 0); } From owner-svn-src-stable-11@freebsd.org Thu Mar 23 06:53:33 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 570B6D19F8C; Thu, 23 Mar 2017 06:53:33 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 236551F71; Thu, 23 Mar 2017 06:53:33 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N6rWtY061393; Thu, 23 Mar 2017 06:53:32 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N6rWWu061391; Thu, 23 Mar 2017 06:53:32 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703230653.v2N6rWWu061391@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 23 Mar 2017 06:53:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315827 - stable/11/sys/dev/mpt X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 06:53:33 -0000 Author: mav Date: Thu Mar 23 06:53:31 2017 New Revision: 315827 URL: https://svnweb.freebsd.org/changeset/base/315827 Log: MFC r315067: Partially fix target task management requests handling. - XPT_NOTIFY_ACKNOWLEDGE was not handled, causing stuck requests. - XPT_ABORT was not even trying to abort active ATIOs/INOTs. - Initiator's tag was not stored and not used where needed. - List of TM request types needed update. - mpt_scsi_tgt_status() missed some useful debugging. After this change global TM requests, such as reset, should work properly. ABORT TASK (ABTS) requests are still not passes to CTL, that is not good and should be fixed. Modified: stable/11/sys/dev/mpt/mpt.h stable/11/sys/dev/mpt/mpt_cam.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mpt/mpt.h ============================================================================== --- stable/11/sys/dev/mpt/mpt.h Thu Mar 23 06:52:29 2017 (r315826) +++ stable/11/sys/dev/mpt/mpt.h Thu Mar 23 06:53:31 2017 (r315827) @@ -338,7 +338,8 @@ typedef struct { uint32_t is_local : 1, nxfers : 31; - uint32_t tag_id; + uint32_t tag_id; /* Our local tag. */ + uint16_t itag; /* Initiator tag. */ enum { TGT_STATE_NIL, TGT_STATE_LOADING, @@ -1053,11 +1054,13 @@ mpt_req_not_spcl(struct mpt_softc *mpt, * Task Management Types, purely for internal consumption */ typedef enum { - MPT_ABORT_TASK_SET=1234, + MPT_QUERY_TASK_SET=1234, + MPT_ABORT_TASK_SET, MPT_CLEAR_TASK_SET, + MPT_QUERY_ASYNC_EVENT, + MPT_LOGICAL_UNIT_RESET, MPT_TARGET_RESET, MPT_CLEAR_ACA, - MPT_TERMINATE_TASK, MPT_NIL_TMT_VALUE=5678 } mpt_task_mgmt_t; Modified: stable/11/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/11/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:52:29 2017 (r315826) +++ stable/11/sys/dev/mpt/mpt_cam.c Thu Mar 23 06:53:31 2017 (r315827) @@ -2937,7 +2937,10 @@ mpt_fc_els_reply_handler(struct mpt_soft } else if (rctl == ABTS && type == 0) { uint16_t rx_id = le16toh(rp->Rxid); uint16_t ox_id = le16toh(rp->Oxid); + mpt_tgt_state_t *tgt; request_t *tgt_req = NULL; + union ccb *ccb; + uint32_t ct_id; mpt_prt(mpt, "ELS: ABTS OX_ID 0x%x RX_ID 0x%x from 0x%08x%08x\n", @@ -2950,47 +2953,37 @@ mpt_fc_els_reply_handler(struct mpt_soft } else { tgt_req = mpt->tgt_cmd_ptrs[rx_id]; } - if (tgt_req) { - mpt_tgt_state_t *tgt = MPT_TGT_STATE(mpt, tgt_req); - union ccb *ccb; - uint32_t ct_id; - - /* - * Check to make sure we have the correct command - * The reply descriptor in the target state should - * should contain an IoIndex that should match the - * RX_ID. - * - * It'd be nice to have OX_ID to crosscheck with - * as well. - */ - ct_id = GET_IO_INDEX(tgt->reply_desc); - - if (ct_id != rx_id) { - mpt_lprt(mpt, MPT_PRT_ERROR, "ABORT Mismatch: " - "RX_ID received=0x%x; RX_ID in cmd=0x%x\n", - rx_id, ct_id); - goto skip; - } - - ccb = tgt->ccb; - if (ccb) { - mpt_prt(mpt, - "CCB (%p): lun %jx flags %x status %x\n", - ccb, (uintmax_t)ccb->ccb_h.target_lun, - ccb->ccb_h.flags, ccb->ccb_h.status); - } - mpt_prt(mpt, "target state 0x%x resid %u xfrd %u rpwrd " - "%x nxfers %x\n", tgt->state, - tgt->resid, tgt->bytes_xfered, tgt->reply_desc, - tgt->nxfers); - skip: - if (mpt_abort_target_cmd(mpt, tgt_req)) { - mpt_prt(mpt, "unable to start TargetAbort\n"); - } - } else { + if (tgt_req == NULL) { mpt_prt(mpt, "no back pointer for RX_ID 0x%x\n", rx_id); + goto skip; } + tgt = MPT_TGT_STATE(mpt, tgt_req); + + /* Check to make sure we have the correct command. */ + ct_id = GET_IO_INDEX(tgt->reply_desc); + if (ct_id != rx_id) { + mpt_lprt(mpt, MPT_PRT_ERROR, "ABORT Mismatch: " + "RX_ID received=0x%x, in cmd=0x%x\n", rx_id, ct_id); + goto skip; + } + if (tgt->itag != ox_id) { + mpt_lprt(mpt, MPT_PRT_ERROR, "ABORT Mismatch: " + "OX_ID received=0x%x, in cmd=0x%x\n", ox_id, tgt->itag); + goto skip; + } + + if ((ccb = tgt->ccb) != NULL) { + mpt_prt(mpt, "CCB (%p): lun %jx flags %x status %x\n", + ccb, (uintmax_t)ccb->ccb_h.target_lun, + ccb->ccb_h.flags, ccb->ccb_h.status); + } + mpt_prt(mpt, "target state 0x%x resid %u xfrd %u rpwrd " + "%x nxfers %x\n", tgt->state, tgt->resid, + tgt->bytes_xfered, tgt->reply_desc, tgt->nxfers); + if (mpt_abort_target_cmd(mpt, tgt_req)) + mpt_prt(mpt, "unable to start TargetAbort\n"); + +skip: memset(elsbuf, 0, 5 * (sizeof (U32))); elsbuf[0] = htobe32(0); elsbuf[1] = htobe32((ox_id << 16) | rx_id); @@ -3652,7 +3645,6 @@ mpt_action(struct cam_sim *sim, union cc } break; } - case XPT_NOTIFY_ACKNOWLEDGE: /* recycle notify ack */ case XPT_IMMEDIATE_NOTIFY: /* Add Immediate Notify Resource */ case XPT_ACCEPT_TARGET_IO: /* Add Accept Target IO Resource */ { @@ -3678,17 +3670,24 @@ mpt_action(struct cam_sim *sim, union cc "Put FREE ATIO %p lun %jx\n", ccb, (uintmax_t)lun); STAILQ_INSERT_TAIL(&trtp->atios, &ccb->ccb_h, sim_links.stqe); - } else if (ccb->ccb_h.func_code == XPT_IMMEDIATE_NOTIFY) { + } else { mpt_lprt(mpt, MPT_PRT_DEBUG1, "Put FREE INOT lun %jx\n", (uintmax_t)lun); STAILQ_INSERT_TAIL(&trtp->inots, &ccb->ccb_h, sim_links.stqe); - } else { - mpt_lprt(mpt, MPT_PRT_ALWAYS, "Got Notify ACK\n"); } mpt_set_ccb_status(ccb, CAM_REQ_INPROG); return; } + case XPT_NOTIFY_ACKNOWLEDGE: /* Task management request done. */ + { + request_t *req = MPT_TAG_2_REQ(mpt, ccb->cna2.tag_id); + + mpt_lprt(mpt, MPT_PRT_DEBUG, "Got Notify ACK\n"); + mpt_scsi_tgt_status(mpt, NULL, req, 0, NULL, 0); + mpt_set_ccb_status(ccb, CAM_REQ_CMP); + break; + } case XPT_CONT_TARGET_IO: mpt_target_start_io(mpt, ccb); return; @@ -4556,40 +4555,44 @@ mpt_abort_target_ccb(struct mpt_softc *m { struct mpt_hdr_stailq *lp; struct ccb_hdr *srch; - int found = 0; union ccb *accb = ccb->cab.abort_ccb; tgt_resource_t *trtp; + mpt_tgt_state_t *tgt; + request_t *req; + uint32_t tag; mpt_lprt(mpt, MPT_PRT_DEBUG, "aborting ccb %p\n", accb); - - if (ccb->ccb_h.target_lun == CAM_LUN_WILDCARD) { + if (ccb->ccb_h.target_lun == CAM_LUN_WILDCARD) trtp = &mpt->trt_wildcard; - } else { + else trtp = &mpt->trt[ccb->ccb_h.target_lun]; - } - if (accb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO) { lp = &trtp->atios; - } else if (accb->ccb_h.func_code == XPT_IMMEDIATE_NOTIFY) { - lp = &trtp->inots; + tag = accb->atio.tag_id; } else { - return (CAM_REQ_INVALID); + lp = &trtp->inots; + tag = accb->cin1.tag_id; } + /* Search the CCB among queued. */ STAILQ_FOREACH(srch, lp, sim_links.stqe) { - if (srch == &accb->ccb_h) { - found = 1; - STAILQ_REMOVE(lp, srch, ccb_hdr, sim_links.stqe); - break; - } - } - if (found) { + if (srch != &accb->ccb_h) + continue; + STAILQ_REMOVE(lp, srch, ccb_hdr, sim_links.stqe); accb->ccb_h.status = CAM_REQ_ABORTED; xpt_done(accb); return (CAM_REQ_CMP); } - mpt_prt(mpt, "mpt_abort_tgt_ccb: CCB %p not found\n", ccb); - return (CAM_PATH_INVALID); + + /* Search the CCB among running. */ + req = MPT_TAG_2_REQ(mpt, tag); + tgt = MPT_TGT_STATE(mpt, req); + if (tgt->tag_id == tag) { + mpt_abort_target_cmd(mpt, req); + return (CAM_REQ_CMP); + } + + return (CAM_UA_ABORT); } /* @@ -4685,6 +4688,7 @@ mpt_scsi_tgt_status(struct mpt_softc *mp paddr += MPT_RQSL(mpt); memset(tp, 0, sizeof (*tp)); + tp->StatusCode = status; tp->Function = MPI_FUNCTION_TARGET_STATUS_SEND; if (mpt->is_fc) { PTR_MPI_TARGET_FCP_CMD_BUFFER fc = @@ -4737,7 +4741,6 @@ mpt_scsi_tgt_status(struct mpt_softc *mp } else { PTR_MPI_TARGET_SCSI_SPI_CMD_BUFFER sp = (PTR_MPI_TARGET_SCSI_SPI_CMD_BUFFER) cmd_vbuf; - tp->StatusCode = status; tp->QueueTag = htole16(sp->Tag); memcpy(tp->LUN, sp->LogicalUnitNumber, sizeof (tp->LUN)); } @@ -4752,12 +4755,11 @@ mpt_scsi_tgt_status(struct mpt_softc *mp tp->MsgFlags |= TARGET_STATUS_SEND_FLAGS_AUTO_GOOD_STATUS; } else { tp->StatusDataSGE.u.Address32 = htole32((uint32_t) paddr); - fl = - MPI_SGE_FLAGS_HOST_TO_IOC | - MPI_SGE_FLAGS_SIMPLE_ELEMENT | - MPI_SGE_FLAGS_LAST_ELEMENT | - MPI_SGE_FLAGS_END_OF_LIST | - MPI_SGE_FLAGS_END_OF_BUFFER; + fl = MPI_SGE_FLAGS_HOST_TO_IOC | + MPI_SGE_FLAGS_SIMPLE_ELEMENT | + MPI_SGE_FLAGS_LAST_ELEMENT | + MPI_SGE_FLAGS_END_OF_LIST | + MPI_SGE_FLAGS_END_OF_BUFFER; fl <<= MPI_SGE_FLAGS_SHIFT; fl |= resplen; tp->StatusDataSGE.FlagsLength = htole32(fl); @@ -4765,8 +4767,10 @@ mpt_scsi_tgt_status(struct mpt_softc *mp mpt_lprt(mpt, MPT_PRT_DEBUG, "STATUS_CCB %p (with%s sense) tag %x req %p:%u resid %u\n", - ccb, sense_len > 0 ? "" : "out", ccb ? ccb->csio.tag_id : -1, + ccb, sense_len > 0 ? "" : "out", tgt->tag_id, req, req->serno, tgt->resid); + if (mpt->verbose > MPT_PRT_DEBUG) + mpt_print_request(req->req_vbuf); if (ccb) { ccb->ccb_h.status = CAM_SIM_QUEUED | CAM_REQ_INPROG; mpt_req_timeout(req, SBT_1S * 60, mpt_timeout, ccb); @@ -4794,36 +4798,40 @@ mpt_scsi_tgt_tsk_mgmt(struct mpt_softc * (uintmax_t)inot->ccb_h.target_lun); inot->initiator_id = init_id; /* XXX */ + inot->tag_id = tgt->tag_id; + inot->seq_id = 0; /* * This is a somewhat grotesque attempt to map from task management * to old style SCSI messages. God help us all. */ switch (fc) { + case MPT_QUERY_TASK_SET: + inot->arg = MSG_QUERY_TASK_SET; + break; case MPT_ABORT_TASK_SET: - inot->arg = MSG_ABORT_TAG; + inot->arg = MSG_ABORT_TASK_SET; break; case MPT_CLEAR_TASK_SET: inot->arg = MSG_CLEAR_TASK_SET; break; + case MPT_QUERY_ASYNC_EVENT: + inot->arg = MSG_QUERY_ASYNC_EVENT; + break; + case MPT_LOGICAL_UNIT_RESET: + inot->arg = MSG_LOGICAL_UNIT_RESET; + break; case MPT_TARGET_RESET: inot->arg = MSG_TARGET_RESET; break; case MPT_CLEAR_ACA: inot->arg = MSG_CLEAR_ACA; break; - case MPT_TERMINATE_TASK: - inot->arg = MSG_ABORT_TAG; - break; default: inot->arg = MSG_NOOP; break; } - /* - * XXX KDM we need the sequence/tag number for the target of the - * task management operation, especially if it is an abort. - */ tgt->ccb = (union ccb *) inot; - inot->ccb_h.status = CAM_MESSAGE_RECV|CAM_DEV_QFRZN; + inot->ccb_h.status = CAM_MESSAGE_RECV; xpt_done((union ccb *)inot); } @@ -4844,7 +4852,6 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, tgt_resource_t *trtp = NULL; U8 *lunptr; U8 *vbuf; - U16 itag; U16 ioindex; mpt_task_mgmt_t fct = MPT_NIL_TMT_VALUE; uint8_t *cdbp; @@ -4854,6 +4861,12 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, */ vbuf = req->req_vbuf; vbuf += MPT_RQSL(mpt); + if (mpt->verbose >= MPT_PRT_DEBUG) { + mpt_dump_data(mpt, "mpt_scsi_tgt_atio response", vbuf, + max(sizeof (MPI_TARGET_FCP_CMD_BUFFER), + max(sizeof (MPI_TARGET_SSP_CMD_BUFFER), + sizeof (MPI_TARGET_SCSI_SPI_CMD_BUFFER)))); + } /* * Get our state pointer set up. @@ -4867,12 +4880,16 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, tgt->state = TGT_STATE_IN_CAM; tgt->reply_desc = reply_desc; ioindex = GET_IO_INDEX(reply_desc); - if (mpt->verbose >= MPT_PRT_DEBUG) { - mpt_dump_data(mpt, "mpt_scsi_tgt_atio response", vbuf, - max(sizeof (MPI_TARGET_FCP_CMD_BUFFER), - max(sizeof (MPI_TARGET_SSP_CMD_BUFFER), - sizeof (MPI_TARGET_SCSI_SPI_CMD_BUFFER)))); - } + + /* + * The tag we construct here allows us to find the + * original request that the command came in with. + * + * This way we don't have to depend on anything but the + * tag to find things when CCBs show back up from CAM. + */ + tgt->tag_id = MPT_MAKE_TAGID(mpt, req, ioindex); + if (mpt->is_fc) { PTR_MPI_TARGET_FCP_CMD_BUFFER fc; fc = (PTR_MPI_TARGET_FCP_CMD_BUFFER) vbuf; @@ -4881,21 +4898,27 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, * Task Management Request */ switch (fc->FcpCntl[2]) { + case 0x1: + fct = MPT_QUERY_TASK_SET; + break; case 0x2: fct = MPT_ABORT_TASK_SET; break; case 0x4: fct = MPT_CLEAR_TASK_SET; break; + case 0x8: + fct = MPT_QUERY_ASYNC_EVENT; + break; + case 0x10: + fct = MPT_LOGICAL_UNIT_RESET; + break; case 0x20: fct = MPT_TARGET_RESET; break; case 0x40: fct = MPT_CLEAR_ACA; break; - case 0x80: - fct = MPT_TERMINATE_TASK; - break; default: mpt_prt(mpt, "CORRUPTED TASK MGMT BITS: 0x%x\n", fc->FcpCntl[2]); @@ -4925,19 +4948,19 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, tgt->resid = be32toh(fc->FcpDl); cdbp = fc->FcpCdb; lunptr = fc->FcpLun; - itag = be16toh(fc->OptionalOxid); + tgt->itag = fc->OptionalOxid; } else if (mpt->is_sas) { PTR_MPI_TARGET_SSP_CMD_BUFFER ssp; ssp = (PTR_MPI_TARGET_SSP_CMD_BUFFER) vbuf; cdbp = ssp->CDB; lunptr = ssp->LogicalUnitNumber; - itag = ssp->InitiatorTag; + tgt->itag = ssp->InitiatorTag; } else { PTR_MPI_TARGET_SCSI_SPI_CMD_BUFFER sp; sp = (PTR_MPI_TARGET_SCSI_SPI_CMD_BUFFER) vbuf; cdbp = sp->CDB; lunptr = sp->LogicalUnitNumber; - itag = sp->Tag; + tgt->itag = sp->Tag; } lun = CAM_EXTLUN_BYTE_SWIZZLE(be64dec(lunptr)); @@ -4967,7 +4990,6 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, sense[0] = 0xf0; sense[2] = 0x5; sense[7] = 0x8; - tgt->tag_id = MPT_MAKE_TAGID(mpt, req, ioindex); switch (cdbp[0]) { case INQUIRY: @@ -5051,19 +5073,10 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, atiop->ccb_h.status = CAM_CDB_RECVD; atiop->ccb_h.target_lun = lun; atiop->sense_len = 0; + atiop->tag_id = tgt->tag_id; atiop->init_id = GET_INITIATOR_INDEX(reply_desc); atiop->cdb_len = 16; memcpy(atiop->cdb_io.cdb_bytes, cdbp, atiop->cdb_len); - - /* - * The tag we construct here allows us to find the - * original request that the command came in with. - * - * This way we don't have to depend on anything but the - * tag to find things when CCBs show back up from CAM. - */ - atiop->tag_id = MPT_MAKE_TAGID(mpt, req, ioindex); - tgt->tag_id = atiop->tag_id; if (tag_action) { atiop->tag_action = tag_action; atiop->ccb_h.flags |= CAM_TAG_ACTION_VALID; @@ -5077,7 +5090,7 @@ mpt_scsi_tgt_atio(struct mpt_softc *mpt, (i == (atiop->cdb_len - 1))? '>' : ' '); } mpt_prtc(mpt, " itag %x tag %x rdesc %x dl=%u\n", - itag, atiop->tag_id, tgt->reply_desc, tgt->resid); + tgt->itag, tgt->tag_id, tgt->reply_desc, tgt->resid); } xpt_done((union ccb *)atiop); @@ -5089,9 +5102,9 @@ mpt_tgt_dump_tgt_state(struct mpt_softc mpt_tgt_state_t *tgt = MPT_TGT_STATE(mpt, req); mpt_prt(mpt, "req %p:%u tgt:rdesc 0x%x resid %u xfrd %u ccb %p treq %p " - "nx %d tag 0x%08x state=%d\n", req, req->serno, tgt->reply_desc, - tgt->resid, tgt->bytes_xfered, tgt->ccb, tgt->req, tgt->nxfers, - tgt->tag_id, tgt->state); + "nx %d tag 0x%08x itag 0x%04x state=%d\n", req, req->serno, + tgt->reply_desc, tgt->resid, tgt->bytes_xfered, tgt->ccb, + tgt->req, tgt->nxfers, tgt->tag_id, tgt->itag, tgt->state); } static void @@ -5242,7 +5255,7 @@ mpt_scsi_tgt_reply_handler(struct mpt_so tgt->ccb = NULL; } else { mpt_lprt(mpt, MPT_PRT_DEBUG, - "TARGET_STATUS non-CAM for req %p:%u\n", + "TARGET_STATUS non-CAM for req %p:%u\n", tgt->req, tgt->req->serno); } TAILQ_REMOVE(&mpt->request_pending_list, From owner-svn-src-stable-11@freebsd.org Thu Mar 23 07:56:08 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B60D8D19EB9; Thu, 23 Mar 2017 07:56:08 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 695A61ECF; Thu, 23 Mar 2017 07:56:08 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N7u7JL085759; Thu, 23 Mar 2017 07:56:07 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N7u77G085758; Thu, 23 Mar 2017 07:56:07 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703230756.v2N7u77G085758@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 23 Mar 2017 07:56:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315830 - stable/11/sys/dev/firewire X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 07:56:08 -0000 Author: avg Date: Thu Mar 23 07:56:07 2017 New Revision: 315830 URL: https://svnweb.freebsd.org/changeset/base/315830 Log: MFC r314864: firewire/sbp: try to improve locking, plus a few style nits Modified: stable/11/sys/dev/firewire/sbp.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/firewire/sbp.c ============================================================================== --- stable/11/sys/dev/firewire/sbp.c Thu Mar 23 07:36:38 2017 (r315829) +++ stable/11/sys/dev/firewire/sbp.c Thu Mar 23 07:56:07 2017 (r315830) @@ -425,7 +425,6 @@ sbp_alloc_lun(struct sbp_target *target) int maxlun, lun, i; sbp = target->sbp; - SBP_LOCK_ASSERT(sbp); crom_init_context(&cc, target->fwdev->csrrom); /* XXX shoud parse appropriate unit directories only */ maxlun = -1; @@ -558,7 +557,9 @@ END_DEBUG goto next; } callout_init_mtx(&ocb->timer, &sbp->mtx, 0); + SBP_LOCK(sbp); sbp_free_ocb(sdev, ocb); + SBP_UNLOCK(sbp); } next: crom_next(&cc); @@ -687,9 +688,8 @@ END_DEBUG && crom_has_specver((fwdev)->csrrom, CSRVAL_ANSIT10, CSRVAL_T10SBP2)) static void -sbp_probe_target(void *arg) +sbp_probe_target(struct sbp_target *target) { - struct sbp_target *target = (struct sbp_target *)arg; struct sbp_softc *sbp = target->sbp; struct sbp_dev *sdev; int i, alive; @@ -701,8 +701,6 @@ SBP_DEBUG(1) (!alive) ? " not " : ""); END_DEBUG - sbp = target->sbp; - SBP_LOCK_ASSERT(sbp); sbp_alloc_lun(target); /* XXX untimeout mgm_ocb and dequeue */ @@ -718,7 +716,9 @@ END_DEBUG sbp_probe_lun(sdev); sbp_show_sdev_info(sdev); + SBP_LOCK(sbp); sbp_abort_all_ocbs(sdev, CAM_SCSI_BUS_RESET); + SBP_UNLOCK(sbp); switch (sdev->status) { case SBP_DEV_RESET: /* new or revived target */ @@ -773,9 +773,9 @@ SBP_DEBUG(0) printf("sbp_post_busreset\n"); END_DEBUG SBP_LOCK(sbp); - if ((sbp->sim->flags & SIMQ_FREEZED) == 0) { + if ((sbp->flags & SIMQ_FREEZED) == 0) { xpt_freeze_simq(sbp->sim, /*count*/1); - sbp->sim->flags |= SIMQ_FREEZED; + sbp->flags |= SIMQ_FREEZED; } microtime(&sbp->last_busreset); SBP_UNLOCK(sbp); @@ -800,19 +800,15 @@ END_DEBUG sbp_cold--; SBP_LOCK(sbp); -#if 0 - /* - * XXX don't let CAM the bus rest. - * CAM tries to do something with freezed (DEV_RETRY) devices. - */ - xpt_async(AC_BUS_RESET, sbp->path, /*arg*/ NULL); -#endif /* Garbage Collection */ for (i = 0; i < SBP_NUM_TARGETS; i++) { target = &sbp->targets[i]; + if (target->fwdev == NULL) + continue; + STAILQ_FOREACH(fwdev, &sbp->fd.fc->devices, link) - if (target->fwdev == NULL || target->fwdev == fwdev) + if (target->fwdev == fwdev) break; if (fwdev == NULL) { /* device has removed in lower driver */ @@ -820,6 +816,7 @@ END_DEBUG sbp_free_target(target); } } + /* traverse device list */ STAILQ_FOREACH(fwdev, &sbp->fd.fc->devices, link) { SBP_DEBUG(0) @@ -846,12 +843,24 @@ END_DEBUG continue; } } - sbp_probe_target((void *)target); + + /* + * It is safe to drop the lock here as the target is already + * reserved, so there should be no contenders for it. + * And the target is not yet exposed, so there should not be + * any other accesses to it. + * Finally, the list being iterated is protected somewhere else. + */ + SBP_UNLOCK(sbp); + sbp_probe_target(target); + SBP_LOCK(sbp); if (target->num_lun == 0) sbp_free_target(target); } - xpt_release_simq(sbp->sim, /*run queue*/TRUE); - sbp->sim->flags &= ~SIMQ_FREEZED; + if ((sbp->flags & SIMQ_FREEZED) != 0) { + xpt_release_simq(sbp->sim, /*run queue*/TRUE); + sbp->flags &= ~SIMQ_FREEZED; + } SBP_UNLOCK(sbp); } @@ -959,30 +968,36 @@ sbp_next_dev(struct sbp_target *target, static void sbp_cam_scan_lun(struct cam_periph *periph, union ccb *ccb) { + struct sbp_softc *sbp; struct sbp_target *target; struct sbp_dev *sdev; sdev = (struct sbp_dev *) ccb->ccb_h.ccb_sdev_ptr; target = sdev->target; - SBP_LOCK_ASSERT(target->sbp); + sbp = target->sbp; + SBP_LOCK(sbp); SBP_DEBUG(0) - device_printf(sdev->target->sbp->fd.dev, + device_printf(sbp->fd.dev, "%s:%s\n", __func__, sdev->bustgtlun); END_DEBUG if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { sdev->status = SBP_DEV_ATTACHED; } else { - device_printf(sdev->target->sbp->fd.dev, + device_printf(sbp->fd.dev, "%s:%s failed\n", __func__, sdev->bustgtlun); } sdev = sbp_next_dev(target, sdev->lun_id + 1); if (sdev == NULL) { + SBP_UNLOCK(sbp); free(ccb, M_SBP); return; } /* reuse ccb */ xpt_setup_ccb(&ccb->ccb_h, sdev->path, SCAN_PRI); ccb->ccb_h.ccb_sdev_ptr = sdev; + ccb->ccb_h.flags |= CAM_DEV_QFREEZE; + SBP_UNLOCK(sbp); + xpt_action(ccb); xpt_release_devq(sdev->path, sdev->freeze, TRUE); sdev->freeze = 1; @@ -1011,6 +1026,8 @@ END_DEBUG printf("sbp_cam_scan_target: malloc failed\n"); return; } + SBP_UNLOCK(target->sbp); + xpt_setup_ccb(&ccb->ccb_h, sdev->path, SCAN_PRI); ccb->ccb_h.func_code = XPT_SCAN_LUN; ccb->ccb_h.cbfcnp = sbp_cam_scan_lun; @@ -1020,6 +1037,8 @@ END_DEBUG /* The scan is in progress now. */ xpt_action(ccb); + + SBP_LOCK(target->sbp); xpt_release_devq(sdev->path, sdev->freeze, TRUE); sdev->freeze = 1; } @@ -1977,8 +1996,8 @@ END_DEBUG sbp->fd.post_explore = sbp_post_explore; if (fc->status != -1) { - sbp_post_busreset((void *)sbp); - sbp_post_explore((void *)sbp); + sbp_post_busreset(sbp); + sbp_post_explore(sbp); } SBP_LOCK(sbp); xpt_async(AC_BUS_RESET, sbp->path, /*arg*/ NULL); From owner-svn-src-stable-11@freebsd.org Thu Mar 23 07:57:39 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2996FD19FC3; Thu, 23 Mar 2017 07:57:39 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ECD261AC; Thu, 23 Mar 2017 07:57:38 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N7vcgm085923; Thu, 23 Mar 2017 07:57:38 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N7vci8085922; Thu, 23 Mar 2017 07:57:38 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703230757.v2N7vci8085922@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 23 Mar 2017 07:57:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315832 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 07:57:39 -0000 Author: avg Date: Thu Mar 23 07:57:37 2017 New Revision: 315832 URL: https://svnweb.freebsd.org/changeset/base/315832 Log: MFC r314912: MFV r314910: 7843 get_clones_stat() is suboptimal for lots of clones Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Thu Mar 23 07:56:13 2017 (r315831) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Thu Mar 23 07:57:37 2017 (r315832) @@ -1766,11 +1766,22 @@ get_clones_stat(dsl_dataset_t *ds, nvlis zap_cursor_t zc; zap_attribute_t za; nvlist_t *propval = fnvlist_alloc(); - nvlist_t *val = fnvlist_alloc(); + nvlist_t *val; ASSERT(dsl_pool_config_held(ds->ds_dir->dd_pool)); /* + * We use nvlist_alloc() instead of fnvlist_alloc() because the + * latter would allocate the list with NV_UNIQUE_NAME flag. + * As a result, every time a clone name is appended to the list + * it would be (linearly) searched for for a duplicate name. + * We already know that all clone names must be unique and we + * want avoid the quadratic complexity of double-checking that + * because we can have a large number of clones. + */ + VERIFY0(nvlist_alloc(&val, 0, KM_SLEEP)); + + /* * There may be missing entries in ds_next_clones_obj * due to a bug in a previous version of the code. * Only trust it if it has the right number of entries. From owner-svn-src-stable-11@freebsd.org Thu Mar 23 08:00:18 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 23071D1937B; Thu, 23 Mar 2017 08:00:18 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E3ABF6A9; Thu, 23 Mar 2017 08:00:17 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N80GlJ086164; Thu, 23 Mar 2017 08:00:16 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N80GNY086163; Thu, 23 Mar 2017 08:00:16 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703230800.v2N80GNY086163@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 23 Mar 2017 08:00:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315834 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 08:00:18 -0000 Author: avg Date: Thu Mar 23 08:00:16 2017 New Revision: 315834 URL: https://svnweb.freebsd.org/changeset/base/315834 Log: MFC r314913: MFV r314911: 7867 ARC space accounting leak Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Thu Mar 23 07:57:42 2017 (r315833) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Thu Mar 23 08:00:16 2017 (r315834) @@ -2612,6 +2612,12 @@ arc_hdr_free_on_write(arc_buf_hdr_t *hdr size, hdr); } (void) refcount_remove_many(&state->arcs_size, size, hdr); + if (type == ARC_BUFC_METADATA) { + arc_space_return(size, ARC_SPACE_META); + } else { + ASSERT(type == ARC_BUFC_DATA); + arc_space_return(size, ARC_SPACE_DATA); + } l2arc_free_data_on_write(hdr->b_l1hdr.b_pdata, size, type); } From owner-svn-src-stable-11@freebsd.org Thu Mar 23 08:02:25 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2CAA4D1962A; Thu, 23 Mar 2017 08:02:25 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E6DB4BD9; Thu, 23 Mar 2017 08:02:24 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N82NZI089111; Thu, 23 Mar 2017 08:02:23 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N82NRH089110; Thu, 23 Mar 2017 08:02:23 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703230802.v2N82NRH089110@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 23 Mar 2017 08:02:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315836 - stable/11/sys/kern X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 08:02:25 -0000 Author: avg Date: Thu Mar 23 08:02:23 2017 New Revision: 315836 URL: https://svnweb.freebsd.org/changeset/base/315836 Log: MFC r315074: actually implement proc:::lwp-exit probe Modified: stable/11/sys/kern/kern_thread.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_thread.c ============================================================================== --- stable/11/sys/kern/kern_thread.c Thu Mar 23 08:00:45 2017 (r315835) +++ stable/11/sys/kern/kern_thread.c Thu Mar 23 08:02:23 2017 (r315836) @@ -473,6 +473,7 @@ thread_exit(void) KASSERT(p != NULL, ("thread exiting without a process")); CTR3(KTR_PROC, "thread_exit: thread %p (pid %ld, %s)", td, (long)p->p_pid, td->td_name); + SDT_PROBE0(proc, , , lwp__exit); KASSERT(TAILQ_EMPTY(&td->td_sigqueue.sq_list), ("signal pending")); #ifdef AUDIT From owner-svn-src-stable-11@freebsd.org Thu Mar 23 08:08:35 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 98D67D19724; Thu, 23 Mar 2017 08:08:35 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5DB1DF29; Thu, 23 Mar 2017 08:08:35 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N88YU5090470; Thu, 23 Mar 2017 08:08:34 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N88YJQ090468; Thu, 23 Mar 2017 08:08:34 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703230808.v2N88YJQ090468@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 23 Mar 2017 08:08:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315838 - stable/11/sys/kern X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 08:08:35 -0000 Author: avg Date: Thu Mar 23 08:08:34 2017 New Revision: 315838 URL: https://svnweb.freebsd.org/changeset/base/315838 Log: MFC r315075: trace thread running state when a thread is run for the first time Modified: stable/11/sys/kern/sched_4bsd.c stable/11/sys/kern/sched_ule.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/sched_4bsd.c ============================================================================== --- stable/11/sys/kern/sched_4bsd.c Thu Mar 23 08:02:29 2017 (r315837) +++ stable/11/sys/kern/sched_4bsd.c Thu Mar 23 08:08:34 2017 (r315838) @@ -1666,6 +1666,10 @@ sched_fork_exit(struct thread *td) lock_profile_obtain_lock_success(&sched_lock.lock_object, 0, 0, __FILE__, __LINE__); THREAD_LOCK_ASSERT(td, MA_OWNED | MA_NOTRECURSED); + + KTR_STATE1(KTR_SCHED, "thread", sched_tdname(td), "running", + "prio:%d", td->td_priority); + SDT_PROBE0(sched, , , on__cpu); } char * Modified: stable/11/sys/kern/sched_ule.c ============================================================================== --- stable/11/sys/kern/sched_ule.c Thu Mar 23 08:02:29 2017 (r315837) +++ stable/11/sys/kern/sched_ule.c Thu Mar 23 08:08:34 2017 (r315838) @@ -2756,6 +2756,10 @@ sched_fork_exit(struct thread *td) TDQ_LOCK_ASSERT(tdq, MA_OWNED | MA_NOTRECURSED); lock_profile_obtain_lock_success( &TDQ_LOCKPTR(tdq)->lock_object, 0, 0, __FILE__, __LINE__); + + KTR_STATE1(KTR_SCHED, "thread", sched_tdname(td), "running", + "prio:%d", td->td_priority); + SDT_PROBE0(sched, , , on__cpu); } /* From owner-svn-src-stable-11@freebsd.org Thu Mar 23 08:10:27 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4ABEDD1984F; Thu, 23 Mar 2017 08:10:27 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1329111AF; Thu, 23 Mar 2017 08:10:27 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N8AQVX090693; Thu, 23 Mar 2017 08:10:26 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N8AQod090692; Thu, 23 Mar 2017 08:10:26 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703230810.v2N8AQod090692@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 23 Mar 2017 08:10:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315840 - stable/11/sys/dev/aacraid X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 08:10:27 -0000 Author: avg Date: Thu Mar 23 08:10:25 2017 New Revision: 315840 URL: https://svnweb.freebsd.org/changeset/base/315840 Log: MFC r315083: aacraid: fix build with AACRAID_DEBUG=2 Modified: stable/11/sys/dev/aacraid/aacraid_cam.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/aacraid/aacraid_cam.c ============================================================================== --- stable/11/sys/dev/aacraid/aacraid_cam.c Thu Mar 23 08:08:39 2017 (r315839) +++ stable/11/sys/dev/aacraid/aacraid_cam.c Thu Mar 23 08:10:25 2017 (r315840) @@ -243,10 +243,12 @@ static int aac_cam_probe(device_t dev) { struct aac_cam *camsc; + struct aac_softc *sc; camsc = (struct aac_cam *)device_get_softc(dev); if (!camsc->inf) return (0); + sc = camsc->inf->aac_sc; fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); return (0); } @@ -1134,15 +1136,17 @@ static void aac_container_complete(struct aac_command *cm) { union ccb *ccb; + struct aac_softc *sc; u_int32_t status; + sc = cm->cm_sc; fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, ""); ccb = cm->cm_ccb; status = ((u_int32_t *)cm->cm_fib->data)[0]; if (cm->cm_flags & AAC_CMD_RESET) { ccb->ccb_h.status = CAM_SCSI_BUS_RESET; - } else if (status == ST_OK) { + } else if (status == ST_OK) { ccb->ccb_h.status = CAM_REQ_CMP; } else if (status == ST_NOT_READY) { ccb->ccb_h.status = CAM_BUSY; From owner-svn-src-stable-11@freebsd.org Thu Mar 23 08:14:43 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A04EFD19AC4; Thu, 23 Mar 2017 08:14:43 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 503691786; Thu, 23 Mar 2017 08:14:43 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N8EgXY094466; Thu, 23 Mar 2017 08:14:42 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N8EfWQ094460; Thu, 23 Mar 2017 08:14:41 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703230814.v2N8EfWQ094460@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 23 Mar 2017 08:14:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315842 - in stable/11/sys: cddl/compat/opensolaris/kern cddl/compat/opensolaris/sys cddl/contrib/opensolaris/uts/common/fs cddl/contrib/opensolaris/uts/common/fs/zfs cddl/contrib/opens... X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 08:14:43 -0000 Author: avg Date: Thu Mar 23 08:14:41 2017 New Revision: 315842 URL: https://svnweb.freebsd.org/changeset/base/315842 Log: MFC r314048,r314194: reimplement zfsctl (.zfs) support Deleted: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/gfs.h Modified: stable/11/sys/cddl/compat/opensolaris/kern/opensolaris_lookup.c stable/11/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c stable/11/sys/cddl/compat/opensolaris/sys/pathname.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ctldir.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_vfsops.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c stable/11/sys/conf/files stable/11/sys/modules/zfs/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/compat/opensolaris/kern/opensolaris_lookup.c ============================================================================== --- stable/11/sys/cddl/compat/opensolaris/kern/opensolaris_lookup.c Thu Mar 23 08:10:42 2017 (r315841) +++ stable/11/sys/cddl/compat/opensolaris/kern/opensolaris_lookup.c Thu Mar 23 08:14:41 2017 (r315842) @@ -62,55 +62,3 @@ lookupnameat(char *dirname, enum uio_seg vn_lock(startvp, ltype | LK_RETRY); return (error); } - -int -traverse(vnode_t **cvpp, int lktype) -{ - vnode_t *cvp; - vnode_t *tvp; - vfs_t *vfsp; - int error; - - cvp = *cvpp; - tvp = NULL; - - /* - * If this vnode is mounted on, then we transparently indirect - * to the vnode which is the root of the mounted file system. - * Before we do this we must check that an unmount is not in - * progress on this vnode. - */ - - for (;;) { - /* - * Reached the end of the mount chain? - */ - vfsp = vn_mountedvfs(cvp); - if (vfsp == NULL) - break; - error = vfs_busy(vfsp, 0); - - /* - * tvp is NULL for *cvpp vnode, which we can't unlock. - */ - if (tvp != NULL) - vput(cvp); - else - vrele(cvp); - if (error) - return (error); - - /* - * The read lock must be held across the call to VFS_ROOT() to - * prevent a concurrent unmount from destroying the vfs. - */ - error = VFS_ROOT(vfsp, lktype, &tvp); - vfs_unbusy(vfsp); - if (error != 0) - return (error); - cvp = tvp; - } - - *cvpp = cvp; - return (0); -} Modified: stable/11/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c ============================================================================== --- stable/11/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c Thu Mar 23 08:10:42 2017 (r315841) +++ stable/11/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c Thu Mar 23 08:14:41 2017 (r315842) @@ -196,10 +196,17 @@ mount_snapshot(kthread_t *td, vnode_t ** td->td_ucred = cr; if (error != 0) { + /* + * Clear VI_MOUNT and decrement the use count "atomically", + * under the vnode lock. This is not strictly required, + * but makes it easier to reason about the life-cycle and + * ownership of the covered vnode. + */ + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); VI_LOCK(vp); vp->v_iflag &= ~VI_MOUNT; VI_UNLOCK(vp); - vrele(vp); + vput(vp); vfs_unbusy(mp); vfs_freeopts(mp->mnt_optnew); vfs_mount_destroy(mp); Modified: stable/11/sys/cddl/compat/opensolaris/sys/pathname.h ============================================================================== --- stable/11/sys/cddl/compat/opensolaris/sys/pathname.h Thu Mar 23 08:10:42 2017 (r315841) +++ stable/11/sys/cddl/compat/opensolaris/sys/pathname.h Thu Mar 23 08:14:41 2017 (r315842) @@ -34,20 +34,9 @@ #include #include -typedef struct pathname { - char *pn_buf; /* underlying storage */ - char *pn_path; /* remaining pathname */ - size_t pn_pathlen; /* remaining length */ - size_t pn_bufsize; /* total size of pn_buf */ -} pathname_t; - -#define pn_alloc(pnp) panic("pn_alloc() called") -#define pn_free(pnp) panic("pn_free() called") - int lookupname(char *, enum uio_seg, enum symfollow, vnode_t **, vnode_t **); int lookupnameat(char *, enum uio_seg, enum symfollow, vnode_t **, vnode_t **, vnode_t *); -int traverse(vnode_t **, int); #endif /* _KERNEL */ Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ctldir.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ctldir.h Thu Mar 23 08:10:42 2017 (r315841) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ctldir.h Thu Mar 23 08:14:41 2017 (r315842) @@ -44,7 +44,7 @@ extern "C" { void zfsctl_create(zfsvfs_t *); void zfsctl_destroy(zfsvfs_t *); -vnode_t *zfsctl_root(znode_t *); +int zfsctl_root(zfsvfs_t *, int, vnode_t **); void zfsctl_init(void); void zfsctl_fini(void); boolean_t zfsctl_is_node(vnode_t *); @@ -53,10 +53,6 @@ int zfsctl_rename_snapshot(const char *f int zfsctl_destroy_snapshot(const char *snapname, int force); int zfsctl_umount_snapshots(vfs_t *, int, cred_t *); -int zfsctl_root_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, pathname_t *pnp, - int flags, vnode_t *rdir, cred_t *cr, caller_context_t *ct, - int *direntflags, pathname_t *realpnp); - int zfsctl_lookup_objset(vfs_t *vfsp, uint64_t objsetid, zfsvfs_t **zfsvfsp); #define ZFSCTL_INO_ROOT 0x1 Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_vfsops.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_vfsops.h Thu Mar 23 08:10:42 2017 (r315841) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_vfsops.h Thu Mar 23 08:14:41 2017 (r315842) @@ -68,7 +68,7 @@ struct zfsvfs { krwlock_t z_teardown_inactive_lock; list_t z_all_znodes; /* all vnodes in the fs */ kmutex_t z_znodes_lock; /* lock for z_all_znodes */ - vnode_t *z_ctldir; /* .zfs directory pointer */ + struct zfsctl_root *z_ctldir; /* .zfs directory pointer */ boolean_t z_show_ctldir; /* expose .zfs in the root dir */ boolean_t z_issnap; /* true if this is a snapshot */ boolean_t z_vscan; /* virus scan on/off */ Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Thu Mar 23 08:10:42 2017 (r315841) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Thu Mar 23 08:14:41 2017 (r315842) @@ -70,136 +70,249 @@ #include #include #include -#include #include #include +#include #include #include #include -#include +#include #include "zfs_namecheck.h" -typedef struct zfsctl_node { - gfs_dir_t zc_gfs_private; - uint64_t zc_id; - timestruc_t zc_cmtime; /* ctime and mtime, always the same */ -} zfsctl_node_t; - -typedef struct zfsctl_snapdir { - zfsctl_node_t sd_node; - kmutex_t sd_lock; - avl_tree_t sd_snaps; -} zfsctl_snapdir_t; +/* + * "Synthetic" filesystem implementation. + */ -typedef struct { - char *se_name; - vnode_t *se_root; - avl_node_t se_node; -} zfs_snapentry_t; - -static int -snapentry_compare(const void *a, const void *b) -{ - const zfs_snapentry_t *sa = a; - const zfs_snapentry_t *sb = b; - int ret = strcmp(sa->se_name, sb->se_name); - - if (ret < 0) - return (-1); - else if (ret > 0) - return (1); - else - return (0); -} - -#ifdef illumos -vnodeops_t *zfsctl_ops_root; -vnodeops_t *zfsctl_ops_snapdir; -vnodeops_t *zfsctl_ops_snapshot; -vnodeops_t *zfsctl_ops_shares; -vnodeops_t *zfsctl_ops_shares_dir; - -static const fs_operation_def_t zfsctl_tops_root[]; -static const fs_operation_def_t zfsctl_tops_snapdir[]; -static const fs_operation_def_t zfsctl_tops_snapshot[]; -static const fs_operation_def_t zfsctl_tops_shares[]; -#else -static struct vop_vector zfsctl_ops_root; -static struct vop_vector zfsctl_ops_snapdir; -static struct vop_vector zfsctl_ops_snapshot; -static struct vop_vector zfsctl_ops_shares; -static struct vop_vector zfsctl_ops_shares_dir; -#endif +/* + * Assert that A implies B. + */ +#define KASSERT_IMPLY(A, B, msg) KASSERT(!(A) || (B), (msg)); -static vnode_t *zfsctl_mknode_snapdir(vnode_t *); -static vnode_t *zfsctl_mknode_shares(vnode_t *); -static vnode_t *zfsctl_snapshot_mknode(vnode_t *, uint64_t objset); -static int zfsctl_unmount_snap(zfs_snapentry_t *, int, cred_t *); - -#ifdef illumos -static gfs_opsvec_t zfsctl_opsvec[] = { - { ".zfs", zfsctl_tops_root, &zfsctl_ops_root }, - { ".zfs/snapshot", zfsctl_tops_snapdir, &zfsctl_ops_snapdir }, - { ".zfs/snapshot/vnode", zfsctl_tops_snapshot, &zfsctl_ops_snapshot }, - { ".zfs/shares", zfsctl_tops_shares, &zfsctl_ops_shares_dir }, - { ".zfs/shares/vnode", zfsctl_tops_shares, &zfsctl_ops_shares }, - { NULL } -}; -#endif +static MALLOC_DEFINE(M_SFSNODES, "sfs_nodes", "synthetic-fs nodes"); + +typedef struct sfs_node { + char sn_name[ZFS_MAX_DATASET_NAME_LEN]; + uint64_t sn_parent_id; + uint64_t sn_id; +} sfs_node_t; /* - * Root directory elements. We only have two entries - * snapshot and shares. + * Check the parent's ID as well as the node's to account for a chance + * that IDs originating from different domains (snapshot IDs, artifical + * IDs, znode IDs) may clash. */ -static gfs_dirent_t zfsctl_root_entries[] = { - { "snapshot", zfsctl_mknode_snapdir, GFS_CACHE_VNODE }, - { "shares", zfsctl_mknode_shares, GFS_CACHE_VNODE }, - { NULL } -}; +static int +sfs_compare_ids(struct vnode *vp, void *arg) +{ + sfs_node_t *n1 = vp->v_data; + sfs_node_t *n2 = arg; + bool equal; + + equal = n1->sn_id == n2->sn_id && + n1->sn_parent_id == n2->sn_parent_id; + + /* Zero means equality. */ + return (!equal); +} + +static int +sfs_vnode_get(const struct mount *mp, int flags, uint64_t parent_id, + uint64_t id, struct vnode **vpp) +{ + sfs_node_t search; + int err; + + search.sn_id = id; + search.sn_parent_id = parent_id; + err = vfs_hash_get(mp, (u_int)id, flags, curthread, vpp, + sfs_compare_ids, &search); + return (err); +} + +static int +sfs_vnode_insert(struct vnode *vp, int flags, uint64_t parent_id, + uint64_t id, struct vnode **vpp) +{ + int err; + + KASSERT(vp->v_data != NULL, ("sfs_vnode_insert with NULL v_data")); + err = vfs_hash_insert(vp, (u_int)id, flags, curthread, vpp, + sfs_compare_ids, vp->v_data); + return (err); +} + +static void +sfs_vnode_remove(struct vnode *vp) +{ + vfs_hash_remove(vp); +} + +typedef void sfs_vnode_setup_fn(vnode_t *vp, void *arg); + +static int +sfs_vgetx(struct mount *mp, int flags, uint64_t parent_id, uint64_t id, + const char *tag, struct vop_vector *vops, + sfs_vnode_setup_fn setup, void *arg, + struct vnode **vpp) +{ + struct vnode *vp; + int error; + + error = sfs_vnode_get(mp, flags, parent_id, id, vpp); + if (error != 0 || *vpp != NULL) { + KASSERT_IMPLY(error == 0, (*vpp)->v_data != NULL, + "sfs vnode with no data"); + return (error); + } + + /* Allocate a new vnode/inode. */ + error = getnewvnode(tag, mp, vops, &vp); + if (error != 0) { + *vpp = NULL; + return (error); + } + + /* + * Exclusively lock the vnode vnode while it's being constructed. + */ + lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL); + error = insmntque(vp, mp); + if (error != 0) { + *vpp = NULL; + return (error); + } + + setup(vp, arg); + + error = sfs_vnode_insert(vp, flags, parent_id, id, vpp); + if (error != 0 || *vpp != NULL) { + KASSERT_IMPLY(error == 0, (*vpp)->v_data != NULL, + "sfs vnode with no data"); + return (error); + } + + *vpp = vp; + return (0); +} + +static void +sfs_print_node(sfs_node_t *node) +{ + printf("\tname = %s\n", node->sn_name); + printf("\tparent_id = %ju\n", (uintmax_t)node->sn_parent_id); + printf("\tid = %ju\n", (uintmax_t)node->sn_id); +} + +static sfs_node_t * +sfs_alloc_node(size_t size, const char *name, uint64_t parent_id, uint64_t id) +{ + struct sfs_node *node; + + KASSERT(strlen(name) < sizeof(node->sn_name), + ("sfs node name is too long")); + KASSERT(size >= sizeof(*node), ("sfs node size is too small")); + node = malloc(size, M_SFSNODES, M_WAITOK | M_ZERO); + strlcpy(node->sn_name, name, sizeof(node->sn_name)); + node->sn_parent_id = parent_id; + node->sn_id = id; + + return (node); +} + +static void +sfs_destroy_node(sfs_node_t *node) +{ + free(node, M_SFSNODES); +} + +static void * +sfs_reclaim_vnode(vnode_t *vp) +{ + sfs_node_t *node; + void *data; + + sfs_vnode_remove(vp); + data = vp->v_data; + vp->v_data = NULL; + return (data); +} + +static int +sfs_readdir_common(uint64_t parent_id, uint64_t id, struct vop_readdir_args *ap, + uio_t *uio, off_t *offp) +{ + struct dirent entry; + int error; + + /* Reset ncookies for subsequent use of vfs_read_dirent. */ + if (ap->a_ncookies != NULL) + *ap->a_ncookies = 0; + + if (uio->uio_resid < sizeof(entry)) + return (SET_ERROR(EINVAL)); + + if (uio->uio_offset < 0) + return (SET_ERROR(EINVAL)); + if (uio->uio_offset == 0) { + entry.d_fileno = id; + entry.d_type = DT_DIR; + entry.d_name[0] = '.'; + entry.d_name[1] = '\0'; + entry.d_namlen = 1; + entry.d_reclen = sizeof(entry); + error = vfs_read_dirent(ap, &entry, uio->uio_offset); + if (error != 0) + return (SET_ERROR(error)); + } + + if (uio->uio_offset < sizeof(entry)) + return (SET_ERROR(EINVAL)); + if (uio->uio_offset == sizeof(entry)) { + entry.d_fileno = parent_id; + entry.d_type = DT_DIR; + entry.d_name[0] = '.'; + entry.d_name[1] = '.'; + entry.d_name[2] = '\0'; + entry.d_namlen = 2; + entry.d_reclen = sizeof(entry); + error = vfs_read_dirent(ap, &entry, uio->uio_offset); + if (error != 0) + return (SET_ERROR(error)); + } -/* include . and .. in the calculation */ -#define NROOT_ENTRIES ((sizeof (zfsctl_root_entries) / \ - sizeof (gfs_dirent_t)) + 1) + if (offp != NULL) + *offp = 2 * sizeof(entry); + return (0); +} /* - * Initialize the various GFS pieces we'll need to create and manipulate .zfs - * directories. This is called from the ZFS init routine, and initializes the - * vnode ops vectors that we'll be using. + * .zfs inode namespace + * + * We need to generate unique inode numbers for all files and directories + * within the .zfs pseudo-filesystem. We use the following scheme: + * + * ENTRY ZFSCTL_INODE + * .zfs 1 + * .zfs/snapshot 2 + * .zfs/snapshot/ objectid(snap) */ +#define ZFSCTL_INO_SNAP(id) (id) + +static struct vop_vector zfsctl_ops_root; +static struct vop_vector zfsctl_ops_snapdir; +static struct vop_vector zfsctl_ops_snapshot; +static struct vop_vector zfsctl_ops_shares_dir; + void zfsctl_init(void) { -#ifdef illumos - VERIFY(gfs_make_opsvec(zfsctl_opsvec) == 0); -#endif } void zfsctl_fini(void) { -#ifdef illumos - /* - * Remove vfsctl vnode ops - */ - if (zfsctl_ops_root) - vn_freevnodeops(zfsctl_ops_root); - if (zfsctl_ops_snapdir) - vn_freevnodeops(zfsctl_ops_snapdir); - if (zfsctl_ops_snapshot) - vn_freevnodeops(zfsctl_ops_snapshot); - if (zfsctl_ops_shares) - vn_freevnodeops(zfsctl_ops_shares); - if (zfsctl_ops_shares_dir) - vn_freevnodeops(zfsctl_ops_shares_dir); - - zfsctl_ops_root = NULL; - zfsctl_ops_snapdir = NULL; - zfsctl_ops_snapshot = NULL; - zfsctl_ops_shares = NULL; - zfsctl_ops_shares_dir = NULL; -#endif /* illumos */ } boolean_t @@ -208,106 +321,114 @@ zfsctl_is_node(vnode_t *vp) return (vn_matchops(vp, zfsctl_ops_root) || vn_matchops(vp, zfsctl_ops_snapdir) || vn_matchops(vp, zfsctl_ops_snapshot) || - vn_matchops(vp, zfsctl_ops_shares) || vn_matchops(vp, zfsctl_ops_shares_dir)); } -/* - * Return the inode number associated with the 'snapshot' or - * 'shares' directory. - */ -/* ARGSUSED */ -static ino64_t -zfsctl_root_inode_cb(vnode_t *vp, int index) -{ - zfsvfs_t *zfsvfs = vp->v_vfsp->vfs_data; - - ASSERT(index < 2); - - if (index == 0) - return (ZFSCTL_INO_SNAPDIR); +typedef struct zfsctl_root { + sfs_node_t node; + sfs_node_t *snapdir; + timestruc_t cmtime; +} zfsctl_root_t; - return (zfsvfs->z_shares_dir); -} /* - * Create the '.zfs' directory. This directory is cached as part of the VFS - * structure. This results in a hold on the vfs_t. The code in zfs_umount() - * therefore checks against a vfs_count of 2 instead of 1. This reference - * is removed when the ctldir is destroyed in the unmount. + * Create the '.zfs' directory. */ void zfsctl_create(zfsvfs_t *zfsvfs) { - vnode_t *vp, *rvp; - zfsctl_node_t *zcp; + zfsctl_root_t *dot_zfs; + sfs_node_t *snapdir; + vnode_t *rvp; uint64_t crtime[2]; ASSERT(zfsvfs->z_ctldir == NULL); - vp = gfs_root_create(sizeof (zfsctl_node_t), zfsvfs->z_vfs, - &zfsctl_ops_root, ZFSCTL_INO_ROOT, zfsctl_root_entries, - zfsctl_root_inode_cb, MAXNAMELEN, NULL, NULL); - zcp = vp->v_data; - zcp->zc_id = ZFSCTL_INO_ROOT; + snapdir = sfs_alloc_node(sizeof(*snapdir), "snapshot", ZFSCTL_INO_ROOT, + ZFSCTL_INO_SNAPDIR); + dot_zfs = (zfsctl_root_t *)sfs_alloc_node(sizeof(*dot_zfs), ".zfs", 0, + ZFSCTL_INO_ROOT); + dot_zfs->snapdir = snapdir; VERIFY(VFS_ROOT(zfsvfs->z_vfs, LK_EXCLUSIVE, &rvp) == 0); VERIFY(0 == sa_lookup(VTOZ(rvp)->z_sa_hdl, SA_ZPL_CRTIME(zfsvfs), - &crtime, sizeof (crtime))); - ZFS_TIME_DECODE(&zcp->zc_cmtime, crtime); - VN_URELE(rvp); - - /* - * We're only faking the fact that we have a root of a filesystem for - * the sake of the GFS interfaces. Undo the flag manipulation it did - * for us. - */ - vp->v_vflag &= ~VV_ROOT; + &crtime, sizeof(crtime))); + ZFS_TIME_DECODE(&dot_zfs->cmtime, crtime); + vput(rvp); - zfsvfs->z_ctldir = vp; - - VOP_UNLOCK(vp, 0); + zfsvfs->z_ctldir = dot_zfs; } /* * Destroy the '.zfs' directory. Only called when the filesystem is unmounted. - * There might still be more references if we were force unmounted, but only - * new zfs_inactive() calls can occur and they don't reference .zfs + * The nodes must not have any associated vnodes by now as they should be + * vflush-ed. */ void zfsctl_destroy(zfsvfs_t *zfsvfs) { - VN_RELE(zfsvfs->z_ctldir); + sfs_destroy_node(zfsvfs->z_ctldir->snapdir); + sfs_destroy_node((sfs_node_t *)zfsvfs->z_ctldir); zfsvfs->z_ctldir = NULL; } -/* - * Given a root znode, retrieve the associated .zfs directory. - * Add a hold to the vnode and return it. - */ -vnode_t * -zfsctl_root(znode_t *zp) +static int +zfsctl_fs_root_vnode(struct mount *mp, void *arg __unused, int flags, + struct vnode **vpp) +{ + return (VFS_ROOT(mp, flags, vpp)); +} + +static void +zfsctl_common_vnode_setup(vnode_t *vp, void *arg) { - ASSERT(zfs_has_ctldir(zp)); - VN_HOLD(zp->z_zfsvfs->z_ctldir); - return (zp->z_zfsvfs->z_ctldir); + ASSERT_VOP_ELOCKED(vp, __func__); + + /* We support shared locking. */ + VN_LOCK_ASHARE(vp); + vp->v_type = VDIR; + vp->v_data = arg; } static int -zfsctl_common_print(ap) - struct vop_print_args /* { - struct vnode *a_vp; - } */ *ap; +zfsctl_root_vnode(struct mount *mp, void *arg __unused, int flags, + struct vnode **vpp) { - vnode_t *vp = ap->a_vp; - gfs_file_t *fp = vp->v_data; + void *node; + int err; - printf(" parent = %p\n", fp->gfs_parent); - printf(" type = %d\n", fp->gfs_type); - printf(" index = %d\n", fp->gfs_index); - printf(" ino = %ju\n", (uintmax_t)fp->gfs_ino); - return (0); + node = ((zfsvfs_t*)mp->mnt_data)->z_ctldir; + err = sfs_vgetx(mp, flags, 0, ZFSCTL_INO_ROOT, "zfs", &zfsctl_ops_root, + zfsctl_common_vnode_setup, node, vpp); + return (err); +} + +static int +zfsctl_snapdir_vnode(struct mount *mp, void *arg __unused, int flags, + struct vnode **vpp) +{ + void *node; + int err; + + node = ((zfsvfs_t*)mp->mnt_data)->z_ctldir->snapdir; + err = sfs_vgetx(mp, flags, ZFSCTL_INO_ROOT, ZFSCTL_INO_SNAPDIR, "zfs", + &zfsctl_ops_snapdir, zfsctl_common_vnode_setup, node, vpp); + return (err); +} + +/* + * Given a root znode, retrieve the associated .zfs directory. + * Add a hold to the vnode and return it. + */ +int +zfsctl_root(zfsvfs_t *zfsvfs, int flags, vnode_t **vpp) +{ + vnode_t *vp; + int error; + + error = zfsctl_root_vnode(zfsvfs->z_vfs, NULL, flags, vpp); + return (error); } /* @@ -350,18 +471,8 @@ zfsctl_common_access(ap) { accmode_t accmode = ap->a_accmode; -#ifdef TODO - if (flags & V_ACE_MASK) { - if (accmode & ACE_ALL_WRITE_PERMS) - return (SET_ERROR(EACCES)); - } else { -#endif - if (accmode & VWRITE) - return (SET_ERROR(EACCES)); -#ifdef TODO - } -#endif - + if (accmode & VWRITE) + return (SET_ERROR(EACCES)); return (0); } @@ -372,6 +483,9 @@ static void zfsctl_common_getattr(vnode_t *vp, vattr_t *vap) { timestruc_t now; + sfs_node_t *node; + + node = vp->v_data; vap->va_uid = 0; vap->va_gid = 0; @@ -394,6 +508,11 @@ zfsctl_common_getattr(vnode_t *vp, vattr vap->va_atime = now; /* FreeBSD: Reset chflags(2) flags. */ vap->va_flags = 0; + + vap->va_nodeid = node->sn_id; + + /* At least '.' and '..'. */ + vap->va_nlink = 2; } /*ARGSUSED*/ @@ -406,81 +525,46 @@ zfsctl_common_fid(ap) { vnode_t *vp = ap->a_vp; fid_t *fidp = (void *)ap->a_fid; - zfsvfs_t *zfsvfs = vp->v_vfsp->vfs_data; - zfsctl_node_t *zcp = vp->v_data; - uint64_t object = zcp->zc_id; + sfs_node_t *node = vp->v_data; + uint64_t object = node->sn_id; zfid_short_t *zfid; int i; - ZFS_ENTER(zfsvfs); - -#ifdef illumos - if (fidp->fid_len < SHORT_FID_LEN) { - fidp->fid_len = SHORT_FID_LEN; - ZFS_EXIT(zfsvfs); - return (SET_ERROR(ENOSPC)); - } -#endif - zfid = (zfid_short_t *)fidp; - zfid->zf_len = SHORT_FID_LEN; - for (i = 0; i < sizeof (zfid->zf_object); i++) + for (i = 0; i < sizeof(zfid->zf_object); i++) zfid->zf_object[i] = (uint8_t)(object >> (8 * i)); - /* .zfs znodes always have a generation number of 0 */ - for (i = 0; i < sizeof (zfid->zf_gen); i++) + /* .zfs nodes always have a generation number of 0 */ + for (i = 0; i < sizeof(zfid->zf_gen); i++) zfid->zf_gen[i] = 0; - ZFS_EXIT(zfsvfs); return (0); } - -/*ARGSUSED*/ static int -zfsctl_shares_fid(ap) - struct vop_fid_args /* { +zfsctl_common_reclaim(ap) + struct vop_reclaim_args /* { struct vnode *a_vp; - struct fid *a_fid; + struct thread *a_td; } */ *ap; { - vnode_t *vp = ap->a_vp; - fid_t *fidp = (void *)ap->a_fid; - zfsvfs_t *zfsvfs = vp->v_vfsp->vfs_data; - znode_t *dzp; - int error; - - ZFS_ENTER(zfsvfs); - - if (zfsvfs->z_shares_dir == 0) { - ZFS_EXIT(zfsvfs); - return (SET_ERROR(ENOTSUP)); - } - - if ((error = zfs_zget(zfsvfs, zfsvfs->z_shares_dir, &dzp)) == 0) { - error = VOP_FID(ZTOV(dzp), fidp); - VN_RELE(ZTOV(dzp)); - } + vnode_t *vp = ap->a_vp; - ZFS_EXIT(zfsvfs); - return (error); + (void) sfs_reclaim_vnode(vp); + return (0); } -/* - * .zfs inode namespace - * - * We need to generate unique inode numbers for all files and directories - * within the .zfs pseudo-filesystem. We use the following scheme: - * - * ENTRY ZFSCTL_INODE - * .zfs 1 - * .zfs/snapshot 2 - * .zfs/snapshot/ objectid(snap) - */ - -#define ZFSCTL_INO_SNAP(id) (id) +static int +zfsctl_common_print(ap) + struct vop_print_args /* { + struct vnode *a_vp; + } */ *ap; +{ + sfs_print_node(ap->a_vp->v_data); + return (0); +} /* * Get root directory attributes. @@ -496,156 +580,132 @@ zfsctl_root_getattr(ap) { struct vnode *vp = ap->a_vp; struct vattr *vap = ap->a_vap; - zfsvfs_t *zfsvfs = vp->v_vfsp->vfs_data; - zfsctl_node_t *zcp = vp->v_data; - - ZFS_ENTER(zfsvfs); - vap->va_nodeid = ZFSCTL_INO_ROOT; - vap->va_nlink = vap->va_size = NROOT_ENTRIES; - vap->va_mtime = vap->va_ctime = zcp->zc_cmtime; - vap->va_birthtime = vap->va_ctime; + zfsctl_root_t *node = vp->v_data; zfsctl_common_getattr(vp, vap); - ZFS_EXIT(zfsvfs); - + vap->va_ctime = node->cmtime; + vap->va_mtime = vap->va_ctime; + vap->va_birthtime = vap->va_ctime; + vap->va_nlink += 1; /* snapdir */ + vap->va_size = vap->va_nlink; return (0); } /* - * Special case the handling of "..". + * When we lookup "." we still can be asked to lock it + * differently, can't we? */ -/* ARGSUSED */ int -zfsctl_root_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, pathname_t *pnp, - int flags, vnode_t *rdir, cred_t *cr, caller_context_t *ct, - int *direntflags, pathname_t *realpnp) +zfsctl_relock_dot(vnode_t *dvp, int ltype) { - zfsvfs_t *zfsvfs = dvp->v_vfsp->vfs_data; - int err; - - /* - * No extended attributes allowed under .zfs - */ - if (flags & LOOKUP_XATTR) - return (SET_ERROR(EINVAL)); - - ZFS_ENTER(zfsvfs); - - if (strcmp(nm, "..") == 0) { -#ifdef illumos - err = VFS_ROOT(dvp->v_vfsp, LK_EXCLUSIVE, vpp); -#else - /* - * NB: can not use VFS_ROOT here as it would acquire - * the vnode lock of the parent (root) vnode while - * holding the child's (.zfs) lock. - */ - znode_t *rootzp; - - err = zfs_zget(zfsvfs, zfsvfs->z_root, &rootzp); - if (err == 0) - *vpp = ZTOV(rootzp); -#endif - } else { - err = gfs_vop_lookup(dvp, nm, vpp, pnp, flags, rdir, - cr, ct, direntflags, realpnp); + vref(dvp); + if (ltype != VOP_ISLOCKED(dvp)) { + if (ltype == LK_EXCLUSIVE) + vn_lock(dvp, LK_UPGRADE | LK_RETRY); + else /* if (ltype == LK_SHARED) */ + vn_lock(dvp, LK_DOWNGRADE | LK_RETRY); + + /* Relock for the "." case may left us with reclaimed vnode. */ + if ((dvp->v_iflag & VI_DOOMED) != 0) { + vrele(dvp); + return (SET_ERROR(ENOENT)); + } } - - ZFS_EXIT(zfsvfs); - - return (err); + return (0); } -static int -zfsctl_freebsd_root_lookup(ap) +/* + * Special case the handling of "..". + */ +int +zfsctl_root_lookup(ap) struct vop_lookup_args /* { struct vnode *a_dvp; struct vnode **a_vpp; struct componentname *a_cnp; } */ *ap; { + struct componentname *cnp = ap->a_cnp; vnode_t *dvp = ap->a_dvp; vnode_t **vpp = ap->a_vpp; cred_t *cr = ap->a_cnp->cn_cred; int flags = ap->a_cnp->cn_flags; int lkflags = ap->a_cnp->cn_lkflags; int nameiop = ap->a_cnp->cn_nameiop; - char nm[NAME_MAX + 1]; int err; + int ltype; - if ((flags & ISLASTCN) && (nameiop == RENAME || nameiop == CREATE)) - return (EOPNOTSUPP); + ASSERT(dvp->v_type == VDIR); - ASSERT(ap->a_cnp->cn_namelen < sizeof(nm)); - strlcpy(nm, ap->a_cnp->cn_nameptr, ap->a_cnp->cn_namelen + 1); -relookup: - err = zfsctl_root_lookup(dvp, nm, vpp, NULL, 0, NULL, cr, NULL, NULL, NULL); - if (err == 0 && (nm[0] != '.' || nm[1] != '\0')) { - if (flags & ISDOTDOT) { - VOP_UNLOCK(dvp, 0); - err = vn_lock(*vpp, lkflags); - if (err != 0) { - vrele(*vpp); - *vpp = NULL; - } - vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY); - } else { - err = vn_lock(*vpp, LK_EXCLUSIVE); - if (err != 0) { - VERIFY3S(err, ==, ENOENT); - goto relookup; - } - } - } - return (err); -} + if ((flags & ISLASTCN) != 0 && nameiop != LOOKUP) + return (SET_ERROR(ENOTSUP)); -static int -zfsctl_root_print(ap) - struct vop_print_args /* { + if (cnp->cn_namelen == 1 && *cnp->cn_nameptr == '.') { + err = zfsctl_relock_dot(dvp, lkflags & LK_TYPE_MASK); + if (err == 0) + *vpp = dvp; + } else if ((flags & ISDOTDOT) != 0) { + err = vn_vget_ino_gen(dvp, zfsctl_fs_root_vnode, NULL, + lkflags, vpp); + } else if (strncmp(cnp->cn_nameptr, "snapshot", cnp->cn_namelen) == 0) { + err = zfsctl_snapdir_vnode(dvp->v_mount, NULL, lkflags, vpp); + } else { + err = SET_ERROR(ENOENT); + } + if (err != 0) + *vpp = NULL; + return (err); +} + +static int +zfsctl_root_readdir(ap) + struct vop_readdir_args /* { struct vnode *a_vp; + struct uio *a_uio; + struct ucred *a_cred; + int *a_eofflag; + int *ncookies; + u_long **a_cookies; } */ *ap; { - printf(" .zfs node\n"); - zfsctl_common_print(ap); + struct dirent entry; + vnode_t *vp = ap->a_vp; + zfsvfs_t *zfsvfs = vp->v_vfsp->vfs_data; + zfsctl_root_t *node = vp->v_data; + uio_t *uio = ap->a_uio; + int *eofp = ap->a_eofflag; + off_t dots_offset; + int error; + + ASSERT(vp->v_type == VDIR); + + error = sfs_readdir_common(zfsvfs->z_root, ZFSCTL_INO_ROOT, ap, uio, *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Thu Mar 23 08:19:32 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CD3FCD19D61; Thu, 23 Mar 2017 08:19:32 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9CB181D67; Thu, 23 Mar 2017 08:19:32 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N8JVWH094823; Thu, 23 Mar 2017 08:19:31 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N8JVCl094822; Thu, 23 Mar 2017 08:19:31 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703230819.v2N8JVCl094822@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 23 Mar 2017 08:19:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315846 - stable/11 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 08:19:32 -0000 Author: avg Date: Thu Mar 23 08:19:31 2017 New Revision: 315846 URL: https://svnweb.freebsd.org/changeset/base/315846 Log: add UPDATING entry for r315842, MFC of re-worked .zfs code Modified: stable/11/UPDATING Modified: stable/11/UPDATING ============================================================================== --- stable/11/UPDATING Thu Mar 23 08:16:53 2017 (r315845) +++ stable/11/UPDATING Thu Mar 23 08:19:31 2017 (r315846) @@ -16,6 +16,12 @@ from older versions of FreeBSD, try WITH the tip of head, and then rebuild without this option. The bootstrap process from older version of current across the gcc/clang cutover is a bit fragile. +20170323: + The code that provides support for ZFS .zfs/ directory functionality + has been reimplemented. It's not possible now to create a snapshot + by mkdir under .zfs/snapshot/. That should be the only user visible + change. + 20170319: Many changes in the IPsec code have been merged from the FreeBSD-CURRENT branch. The IPSEC_FILTERTUNNEL kernel option is removed in favour of From owner-svn-src-stable-11@freebsd.org Thu Mar 23 08:22:29 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 460DED17051; Thu, 23 Mar 2017 08:22:29 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 14F76614; Thu, 23 Mar 2017 08:22:29 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N8MSqn098786; Thu, 23 Mar 2017 08:22:28 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N8MSkC098785; Thu, 23 Mar 2017 08:22:28 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201703230822.v2N8MSkC098785@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 23 Mar 2017 08:22:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315849 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 08:22:29 -0000 Author: avg Date: Thu Mar 23 08:22:27 2017 New Revision: 315849 URL: https://svnweb.freebsd.org/changeset/base/315849 Log: MFC r315076: zfs: provide a special vptocnp method for the .zfs vnode Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Thu Mar 23 08:22:11 2017 (r315848) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Thu Mar 23 08:22:27 2017 (r315849) @@ -706,6 +706,28 @@ zfsctl_root_readdir(ap) return (0); } +static int +zfsctl_root_vptocnp(struct vop_vptocnp_args *ap) +{ + static const char dotzfs_name[4] = ".zfs"; + vnode_t *dvp; + int error; + + if (*ap->a_buflen < sizeof (dotzfs_name)) + return (SET_ERROR(ENOMEM)); + + error = vn_vget_ino_gen(ap->a_vp, zfsctl_fs_root_vnode, NULL, + LK_SHARED, &dvp); + if (error != 0) + return (SET_ERROR(error)); + + VOP_UNLOCK(dvp, 0); + *ap->a_vpp = dvp; + *ap->a_buflen -= sizeof (dotzfs_name); + bcopy(dotzfs_name, ap->a_buf + *ap->a_buflen, sizeof (dotzfs_name)); + return (0); +} + static struct vop_vector zfsctl_ops_root = { .vop_default = &default_vnodeops, .vop_open = zfsctl_common_open, @@ -719,6 +741,7 @@ static struct vop_vector zfsctl_ops_root .vop_reclaim = zfsctl_common_reclaim, .vop_fid = zfsctl_common_fid, .vop_print = zfsctl_common_print, + .vop_vptocnp = zfsctl_root_vptocnp, }; static int From owner-svn-src-stable-11@freebsd.org Thu Mar 23 10:43:30 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DD239D19F2A; Thu, 23 Mar 2017 10:43:30 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A9C0119FA; Thu, 23 Mar 2017 10:43:30 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2NAhTe3056651; Thu, 23 Mar 2017 10:43:29 GMT (envelope-from smh@FreeBSD.org) Received: (from smh@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2NAhTrt056649; Thu, 23 Mar 2017 10:43:29 GMT (envelope-from smh@FreeBSD.org) Message-Id: <201703231043.v2NAhTrt056649@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: smh set sender to smh@FreeBSD.org using -f From: Steven Hartland Date: Thu, 23 Mar 2017 10:43:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315855 - stable/11/lib/libsysdecode X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 10:43:31 -0000 Author: smh Date: Thu Mar 23 10:43:29 2017 New Revision: 315855 URL: https://svnweb.freebsd.org/changeset/base/315855 Log: MFC r315423: Fix libsysdecode vmprot flag decoding Sponsored by: Multiplay Modified: stable/11/lib/libsysdecode/flags.c stable/11/lib/libsysdecode/mktables Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libsysdecode/flags.c ============================================================================== --- stable/11/lib/libsysdecode/flags.c Thu Mar 23 10:22:06 2017 (r315854) +++ stable/11/lib/libsysdecode/flags.c Thu Mar 23 10:43:29 2017 (r315855) @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include Modified: stable/11/lib/libsysdecode/mktables ============================================================================== --- stable/11/lib/libsysdecode/mktables Thu Mar 23 10:22:06 2017 (r315854) +++ stable/11/lib/libsysdecode/mktables Thu Mar 23 10:43:29 2017 (r315855) @@ -135,7 +135,7 @@ gen_table "sockoptudp" "UDP_[[:alnu gen_table "socktype" "SOCK_[A-Z]+[[:space:]]+[1-9]+[0-9]*" "sys/socket.h" gen_table "thrcreateflags" "THR_[A-Z]+[[:space:]]+0x[0-9]+" "sys/thr.h" gen_table "umtxop" "UMTX_OP_[[:alnum:]_]+[[:space:]]+[0-9]+" "sys/umtx.h" -gen_table "vmprot" "VM_PROT_[A-Z]+[[:space:]]+\(\(vm_prot_t\)\)" "vm/vm.h" +gen_table "vmprot" "VM_PROT_[A-Z]+[[:space:]]+\(\(vm_prot_t\)[[:space:]]+0x[0-9]+\)" "vm/vm.h" gen_table "vmresult" "KERN_[A-Z]+[[:space:]]+[0-9]+" "vm/vm_param.h" gen_table "wait6opt" "W[A-Z]+[[:space:]]+[0-9]+" "sys/wait.h" gen_table "seekwhence" "SEEK_[A-Z]+[[:space:]]+[0-9]+" "sys/unistd.h" From owner-svn-src-stable-11@freebsd.org Thu Mar 23 12:45:18 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F1BF1D1991A; Thu, 23 Mar 2017 12:45:18 +0000 (UTC) (envelope-from adamw@adamw.org) Received: from anoxia.adamw.org (anoxia.adamw.org [104.225.8.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "anoxia.adamw.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 75090104; Thu, 23 Mar 2017 12:45:17 +0000 (UTC) (envelope-from adamw@adamw.org) Received: by anoxia.adamw.org (OpenSMTPD) with ESMTPSA id e7c7927e TLS version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO; Thu, 23 Mar 2017 06:45:16 -0600 (MDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 10.2 \(3259\)) Subject: Re: svn commit: r315846 - stable/11 From: Adam Weinberger In-Reply-To: <201703230819.v2N8JVCl094822@repo.freebsd.org> Date: Thu, 23 Mar 2017 06:45:12 -0600 Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <418BBF94-3A30-4476-93EC-5E691156B54D@adamw.org> References: <201703230819.v2N8JVCl094822@repo.freebsd.org> To: Andriy Gapon X-Mailer: Apple Mail (2.3259) X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 12:45:19 -0000 > On 23 Mar, 2017, at 2:19, Andriy Gapon wrote: >=20 > Author: avg > Date: Thu Mar 23 08:19:31 2017 > New Revision: 315846 > URL: https://svnweb.freebsd.org/changeset/base/315846 >=20 > Log: > add UPDATING entry for r315842, MFC of re-worked .zfs code >=20 > Modified: > stable/11/UPDATING >=20 > Modified: stable/11/UPDATING > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- stable/11/UPDATING Thu Mar 23 08:16:53 2017 = (r315845) > +++ stable/11/UPDATING Thu Mar 23 08:19:31 2017 = (r315846) > @@ -16,6 +16,12 @@ from older versions of FreeBSD, try WITH > the tip of head, and then rebuild without this option. The bootstrap = process > from older version of current across the gcc/clang cutover is a bit = fragile. >=20 > +20170323: > + The code that provides support for ZFS .zfs/ directory = functionality > + has been reimplemented. It's not possible now to create a = snapshot Did you want "not" or "now" here? # Adam --=20 Adam Weinberger adamw@adamw.org https://www.adamw.org > + by mkdir under .zfs/snapshot/. That should be the only user = visible > + change. > + > 20170319: > Many changes in the IPsec code have been merged from the = FreeBSD-CURRENT > branch. The IPSEC_FILTERTUNNEL kernel option is removed in = favour of > _______________________________________________ > svn-src-stable-11@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-stable-11 > To unsubscribe, send any mail to = "svn-src-stable-11-unsubscribe@freebsd.org" From owner-svn-src-stable-11@freebsd.org Thu Mar 23 13:06:47 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6DE2FD185EE; Thu, 23 Mar 2017 13:06:47 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citapm.icyb.net.ua (citapm.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 17D4D17F8; Thu, 23 Mar 2017 13:06:42 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citapm.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id PAA02390; Thu, 23 Mar 2017 15:06:41 +0200 (EET) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1cr2Rt-000Ayf-4t; Thu, 23 Mar 2017 15:06:41 +0200 Subject: Re: svn commit: r315846 - stable/11 To: Adam Weinberger References: <201703230819.v2N8JVCl094822@repo.freebsd.org> <418BBF94-3A30-4476-93EC-5E691156B54D@adamw.org> Cc: src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-stable@FreeBSD.org, svn-src-stable-11@FreeBSD.org From: Andriy Gapon Message-ID: <953a4ce5-9ae2-846b-657e-18751ad7124c@FreeBSD.org> Date: Thu, 23 Mar 2017 15:05:19 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <418BBF94-3A30-4476-93EC-5E691156B54D@adamw.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 13:06:47 -0000 On 03/23/2017 14:45, Adam Weinberger wrote: >> On 23 Mar, 2017, at 2:19, Andriy Gapon wrote: >> >> Author: avg >> Date: Thu Mar 23 08:19:31 2017 >> New Revision: 315846 >> URL: https://svnweb.freebsd.org/changeset/base/315846 >> >> Log: >> add UPDATING entry for r315842, MFC of re-worked .zfs code >> >> Modified: >> stable/11/UPDATING >> >> Modified: stable/11/UPDATING >> ============================================================================== >> --- stable/11/UPDATING Thu Mar 23 08:16:53 2017 (r315845) >> +++ stable/11/UPDATING Thu Mar 23 08:19:31 2017 (r315846) >> @@ -16,6 +16,12 @@ from older versions of FreeBSD, try WITH >> the tip of head, and then rebuild without this option. The bootstrap process >> from older version of current across the gcc/clang cutover is a bit fragile. >> >> +20170323: >> + The code that provides support for ZFS .zfs/ directory functionality >> + has been reimplemented. It's not possible now to create a snapshot > > Did you want "not" or "now" here? Sorry, I didn't get your question. There is both "not" and "now" in the quoted sentence, so which "not" or "now" did you mean? -- Andriy Gapon From owner-svn-src-stable-11@freebsd.org Thu Mar 23 13:26:32 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4B319D18C4F; Thu, 23 Mar 2017 13:26:32 +0000 (UTC) (envelope-from marck@rinet.ru) Received: from woozle.rinet.ru (woozle.rinet.ru [195.54.192.68]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CF19112DF; Thu, 23 Mar 2017 13:26:31 +0000 (UTC) (envelope-from marck@rinet.ru) Received: from localhost (localhost [127.0.0.1]) by woozle.rinet.ru (8.14.5/8.14.5) with ESMTP id v2NDHqga033106; Thu, 23 Mar 2017 16:17:52 +0300 (MSK) (envelope-from marck@rinet.ru) Date: Thu, 23 Mar 2017 16:17:52 +0300 (MSK) From: Dmitry Morozovsky To: Adam Weinberger cc: Andriy Gapon , svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r315846 - stable/11 In-Reply-To: <418BBF94-3A30-4476-93EC-5E691156B54D@adamw.org> Message-ID: References: <201703230819.v2N8JVCl094822@repo.freebsd.org> <418BBF94-3A30-4476-93EC-5E691156B54D@adamw.org> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) X-NCC-RegID: ru.rinet X-OpenPGP-Key-ID: 6B691B03 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (woozle.rinet.ru [0.0.0.0]); Thu, 23 Mar 2017 16:17:53 +0300 (MSK) X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 13:26:32 -0000 On Thu, 23 Mar 2017, Adam Weinberger wrote: > > +20170323: > > + The code that provides support for ZFS .zfs/ directory functionality > > + has been reimplemented. It's not possible now to create a snapshot > > Did you want "not" or "now" here? both are at its place; however, the wording is a bit fuzzy, I concur. before you can effectively take a snapshot from a fs by mkdir /path/to/fs/.zfs/snapshot/snapshotname now it leads to "Operation not supported" error. -- Sincerely, D.Marck [DM5020, MCK-RIPE, DM3-RIPN] [ FreeBSD committer: marck@FreeBSD.org ] ------------------------------------------------------------------------ *** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- marck@rinet.ru *** ------------------------------------------------------------------------ From owner-svn-src-stable-11@freebsd.org Thu Mar 23 13:30:18 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3C7D6D18EE7; Thu, 23 Mar 2017 13:30:18 +0000 (UTC) (envelope-from danfe@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1B9B516D4; Thu, 23 Mar 2017 13:30:18 +0000 (UTC) (envelope-from danfe@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 1033) id 63D265EFA; Thu, 23 Mar 2017 13:30:17 +0000 (UTC) Date: Thu, 23 Mar 2017 13:30:17 +0000 From: Alexey Dokuchaev To: Dmitry Morozovsky Cc: Adam Weinberger , svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-11@freebsd.org, Andriy Gapon Subject: Re: svn commit: r315846 - stable/11 Message-ID: <20170323133017.GA87307@FreeBSD.org> References: <201703230819.v2N8JVCl094822@repo.freebsd.org> <418BBF94-3A30-4476-93EC-5E691156B54D@adamw.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.1 (2016-10-04) X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 13:30:18 -0000 On Thu, Mar 23, 2017 at 04:17:52PM +0300, Dmitry Morozovsky wrote: > On Thu, 23 Mar 2017, Adam Weinberger wrote: > > > +20170323: > > > + The code that provides support for ZFS .zfs/ directory functionality > > > + has been reimplemented. It's not possible now to create a snapshot > > > > Did you want "not" or "now" here? > > both are at its place; however, the wording is a bit fuzzy, I concur. Perhaps "It is no longer possible to create a snapshot ..." or something like this? ./danfe From owner-svn-src-stable-11@freebsd.org Thu Mar 23 15:29:30 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C7F96D19740; Thu, 23 Mar 2017 15:29:30 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8A7071AED; Thu, 23 Mar 2017 15:29:30 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1cr4fy-0000EE-5M; Thu, 23 Mar 2017 18:29:22 +0300 Date: Thu, 23 Mar 2017 18:29:22 +0300 From: Slawa Olhovchenkov To: Andriy Gapon Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r315834 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs Message-ID: <20170323152922.GI86500@zxy.spb.ru> References: <201703230800.v2N80GNY086163@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201703230800.v2N80GNY086163@repo.freebsd.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 15:29:30 -0000 On Thu, Mar 23, 2017 at 08:00:16AM +0000, Andriy Gapon wrote: > Author: avg > Date: Thu Mar 23 08:00:16 2017 > New Revision: 315834 > URL: https://svnweb.freebsd.org/changeset/base/315834 > > Log: > MFC r314913: MFV r314911: 7867 ARC space accounting leak Thanks! Now hit ratio regression? From owner-svn-src-stable-11@freebsd.org Thu Mar 23 17:11:36 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 40357D1A1BA; Thu, 23 Mar 2017 17:11:36 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 185601525; Thu, 23 Mar 2017 17:11:36 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2NHBZCG014382; Thu, 23 Mar 2017 17:11:35 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2NHBZTx014381; Thu, 23 Mar 2017 17:11:35 GMT (envelope-from np@FreeBSD.org) Message-Id: <201703231711.v2NHBZTx014381@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Thu, 23 Mar 2017 17:11:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315865 - stable/11/sys/dev/cxgbe/iw_cxgbe X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 17:11:36 -0000 Author: np Date: Thu Mar 23 17:11:34 2017 New Revision: 315865 URL: https://svnweb.freebsd.org/changeset/base/315865 Log: MFC r314814 and r315325. r314814: cxgbe/iw_cxgbe: Abort connection if there is an error during c4iw_modify_qp. r315325: cxgbe/iw_cxgbe: Use the socket and not the toepcb to reach for the inpcb. t4_tom detaches the inpcb from the toepcb as soon as the hardware is done with the connection (in final_cpl_received) but the socket is around as long as the cm_id and the rest of iWARP state is. This fixes an intermittent NULL dereference during abort. Modified: stable/11/sys/dev/cxgbe/iw_cxgbe/qp.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/cxgbe/iw_cxgbe/qp.c ============================================================================== --- stable/11/sys/dev/cxgbe/iw_cxgbe/qp.c Thu Mar 23 16:23:55 2017 (r315864) +++ stable/11/sys/dev/cxgbe/iw_cxgbe/qp.c Thu Mar 23 17:11:34 2017 (r315865) @@ -64,7 +64,7 @@ struct cpl_set_tcb_rpl; #include "iw_cxgbe.h" #include "user.h" -static void creds(struct toepcb *toep, size_t wrsize); +static int creds(struct toepcb *toep, struct inpcb *inp, size_t wrsize); static void set_state(struct c4iw_qp *qhp, enum c4iw_qp_state state) @@ -961,6 +961,7 @@ static inline void build_term_codes(stru static void post_terminate(struct c4iw_qp *qhp, struct t4_cqe *err_cqe, gfp_t gfp) { + int ret; struct fw_ri_wr *wqe; struct terminate_message *term; struct wrqe *wr; @@ -991,7 +992,11 @@ static void post_terminate(struct c4iw_q term->ecode = qhp->attr.ecode; } else build_term_codes(err_cqe, &term->layer_etype, &term->ecode); - creds(toep, sizeof(*wqe)); + ret = creds(toep, inp, sizeof(*wqe)); + if (ret) { + free_wrqe(wr); + return; + } t4_wrq_tx(qhp->rhp->rdev.adap, wr); } @@ -1094,7 +1099,11 @@ rdma_fini(struct c4iw_dev *rhp, struct c c4iw_init_wr_wait(&ep->com.wr_wait); - creds(toep, sizeof(*wqe)); + ret = creds(toep, inp, sizeof(*wqe)); + if (ret) { + free_wrqe(wr); + return ret; + } t4_wrq_tx(sc, wr); ret = c4iw_wait_for_reply(rdev, &ep->com.wr_wait, ep->hwtid, @@ -1127,13 +1136,17 @@ static void build_rtr_msg(u8 p2p_type, s } } -static void -creds(struct toepcb *toep, size_t wrsize) +static int +creds(struct toepcb *toep, struct inpcb *inp, size_t wrsize) { struct ofld_tx_sdesc *txsd; CTR3(KTR_IW_CXGBE, "%s:creB %p %u", __func__, toep , wrsize); - INP_WLOCK(toep->inp); + INP_WLOCK(inp); + if ((inp->inp_flags & (INP_DROPPED | INP_TIMEWAIT)) != 0) { + INP_WUNLOCK(inp); + return (EINVAL); + } txsd = &toep->txsd[toep->txsd_pidx]; txsd->tx_credits = howmany(wrsize, 16); txsd->plen = 0; @@ -1143,9 +1156,10 @@ creds(struct toepcb *toep, size_t wrsize if (__predict_false(++toep->txsd_pidx == toep->txsd_total)) toep->txsd_pidx = 0; toep->txsd_avail--; - INP_WUNLOCK(toep->inp); + INP_WUNLOCK(inp); CTR5(KTR_IW_CXGBE, "%s:creE %p %u %u %u", __func__, toep , txsd->tx_credits, toep->tx_credits, toep->txsd_pidx); + return (0); } static int rdma_init(struct c4iw_dev *rhp, struct c4iw_qp *qhp) @@ -1216,7 +1230,11 @@ static int rdma_init(struct c4iw_dev *rh c4iw_init_wr_wait(&ep->com.wr_wait); - creds(toep, sizeof(*wqe)); + ret = creds(toep, inp, sizeof(*wqe)); + if (ret) { + free_wrqe(wr); + return ret; + } t4_wrq_tx(sc, wr); ret = c4iw_wait_for_reply(rdev, &ep->com.wr_wait, ep->hwtid, @@ -1427,6 +1445,7 @@ err: qhp->ep = NULL; set_state(qhp, C4IW_QP_STATE_ERROR); free = 1; + abort = 1; BUG_ON(!ep); flush_qp(qhp); wake_up(&qhp->wait); From owner-svn-src-stable-11@freebsd.org Thu Mar 23 22:22:26 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 85AC9D1B78D; Thu, 23 Mar 2017 22:22:26 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 388291B0E; Thu, 23 Mar 2017 22:22:26 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2NMMPAn043315; Thu, 23 Mar 2017 22:22:25 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2NMMPjA043313; Thu, 23 Mar 2017 22:22:25 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201703232222.v2NMMPjA043313@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Thu, 23 Mar 2017 22:22:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315874 - stable/11/sys/arm/include X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 22:22:26 -0000 Author: mjg Date: Thu Mar 23 22:22:24 2017 New Revision: 315874 URL: https://svnweb.freebsd.org/changeset/base/315874 Log: MFC r312932,r312933,r312949,r313141 (by cognet) Use strexeq instead of needlessly branch. == (by cognet) Remove useless labels. == (by cognet) Correct the IT instruction in atomic_fcmpset_64(). == (by andrew) Only define atomic_fcmpset_long in the kernel. We may include machine/atomic.h in userspace, however atomic_fcmpset_32 is unimplemented there. Modified: stable/11/sys/arm/include/atomic-v4.h stable/11/sys/arm/include/atomic-v6.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/include/atomic-v4.h ============================================================================== --- stable/11/sys/arm/include/atomic-v4.h Thu Mar 23 22:14:08 2017 (r315873) +++ stable/11/sys/arm/include/atomic-v4.h Thu Mar 23 22:22:24 2017 (r315874) @@ -463,6 +463,8 @@ atomic_cmpset_long(volatile u_long *dst, return (atomic_cmpset_32((volatile uint32_t *)dst, old, newe)); } +#ifdef _KERNEL +/* atomic_fcmpset_32 is only defined for the kernel */ static __inline u_long atomic_fcmpset_long(volatile u_long *dst, u_long *old, u_long newe) { @@ -470,6 +472,7 @@ atomic_fcmpset_long(volatile u_long *dst return (atomic_fcmpset_32((volatile uint32_t *)dst, (uint32_t *)old, newe)); } +#endif static __inline u_long atomic_fetchadd_long(volatile u_long *p, u_long v) Modified: stable/11/sys/arm/include/atomic-v6.h ============================================================================== --- stable/11/sys/arm/include/atomic-v6.h Thu Mar 23 22:14:08 2017 (r315873) +++ stable/11/sys/arm/include/atomic-v6.h Thu Mar 23 22:22:24 2017 (r315874) @@ -198,13 +198,11 @@ atomic_fcmpset_32(volatile uint32_t *p, int ret; __asm __volatile( - "1: mov %0, #1 \n" + " mov %0, #1 \n" " ldrex %1, [%2] \n" " cmp %1, %3 \n" - " it ne \n" - " bne 2f \n" - " strex %0, %4, [%2] \n" - "2:" + " it eq \n" + " strexeq %0, %4, [%2] \n" : "=&r" (ret), "=&r" (tmp), "+r" (p), "+r" (_cmpval), "+r" (newval) : : "cc", "memory"); *cmpval = tmp; @@ -222,7 +220,7 @@ atomic_fcmpset_64(volatile uint64_t *p, "1: mov %[ret], #1 \n" " ldrexd %Q[tmp], %R[tmp], [%[ptr]] \n" " teq %Q[tmp], %Q[_cmpval] \n" - " itee eq \n" + " ite eq \n" " teqeq %R[tmp], %R[_cmpval] \n" " bne 2f \n" " strexd %[ret], %Q[newval], %R[newval], [%[ptr]]\n" From owner-svn-src-stable-11@freebsd.org Fri Mar 24 02:58:22 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 452C9D17452; Fri, 24 Mar 2017 02:58:22 +0000 (UTC) (envelope-from davidcs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0CA0A104A; Fri, 24 Mar 2017 02:58:21 +0000 (UTC) (envelope-from davidcs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2O2wLbN055089; Fri, 24 Mar 2017 02:58:21 GMT (envelope-from davidcs@FreeBSD.org) Received: (from davidcs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2O2wKwt055084; Fri, 24 Mar 2017 02:58:20 GMT (envelope-from davidcs@FreeBSD.org) Message-Id: <201703240258.v2O2wKwt055084@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: davidcs set sender to davidcs@FreeBSD.org using -f From: David C Somayajulu Date: Fri, 24 Mar 2017 02:58:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315881 - stable/11/sys/dev/bxe X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Mar 2017 02:58:22 -0000 Author: davidcs Date: Fri Mar 24 02:58:20 2017 New Revision: 315881 URL: https://svnweb.freebsd.org/changeset/base/315881 Log: MFC r314365 1. state checks in bxe_tx_mq_start_locked() and bxe_tx_mq_start() to sync threads during interface down or detach. 2. add sysctl to set pause frame parameters 3. increase max segs for TSO packets to BXE_TSO_MAX_SEGMENTS (32) 4. add debug messages for PHY 5. HW LRO support restricted to FreeBSD versions 8.x and above. Submitted by: Vaishali.Kulkarni@cavium.com Modified: stable/11/sys/dev/bxe/bxe.c stable/11/sys/dev/bxe/bxe.h stable/11/sys/dev/bxe/bxe_elink.c stable/11/sys/dev/bxe/bxe_stats.c stable/11/sys/dev/bxe/bxe_stats.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/bxe/bxe.c ============================================================================== --- stable/11/sys/dev/bxe/bxe.c Fri Mar 24 01:52:10 2017 (r315880) +++ stable/11/sys/dev/bxe/bxe.c Fri Mar 24 02:58:20 2017 (r315881) @@ -27,7 +27,7 @@ #include __FBSDID("$FreeBSD$"); -#define BXE_DRIVER_VERSION "1.78.89" +#define BXE_DRIVER_VERSION "1.78.90" #include "bxe.h" #include "ecore_sp.h" @@ -496,12 +496,19 @@ static const struct { 4, STATS_FLAGS_FUNC, "mbuf_alloc_tpa"}, { STATS_OFFSET32(tx_queue_full_return), 4, STATS_FLAGS_FUNC, "tx_queue_full_return"}, + { STATS_OFFSET32(bxe_tx_mq_sc_state_failures), + 4, STATS_FLAGS_FUNC, "bxe_tx_mq_sc_state_failures"}, { STATS_OFFSET32(tx_request_link_down_failures), 4, STATS_FLAGS_FUNC, "tx_request_link_down_failures"}, { STATS_OFFSET32(bd_avail_too_less_failures), 4, STATS_FLAGS_FUNC, "bd_avail_too_less_failures"}, { STATS_OFFSET32(tx_mq_not_empty), - 4, STATS_FLAGS_FUNC, "tx_mq_not_empty"} + 4, STATS_FLAGS_FUNC, "tx_mq_not_empty"}, + { STATS_OFFSET32(nsegs_path1_errors), + 4, STATS_FLAGS_FUNC, "nsegs_path1_errors"}, + { STATS_OFFSET32(nsegs_path2_errors), + 4, STATS_FLAGS_FUNC, "nsegs_path2_errors"} + }; @@ -616,12 +623,19 @@ static const struct { 4, "mbuf_alloc_tpa"}, { Q_STATS_OFFSET32(tx_queue_full_return), 4, "tx_queue_full_return"}, + { Q_STATS_OFFSET32(bxe_tx_mq_sc_state_failures), + 4, "bxe_tx_mq_sc_state_failures"}, { Q_STATS_OFFSET32(tx_request_link_down_failures), 4, "tx_request_link_down_failures"}, { Q_STATS_OFFSET32(bd_avail_too_less_failures), 4, "bd_avail_too_less_failures"}, { Q_STATS_OFFSET32(tx_mq_not_empty), - 4, "tx_mq_not_empty"} + 4, "tx_mq_not_empty"}, + { Q_STATS_OFFSET32(nsegs_path1_errors), + 4, "nsegs_path1_errors"}, + { Q_STATS_OFFSET32(nsegs_path2_errors), + 4, "nsegs_path2_errors"} + }; @@ -692,6 +706,7 @@ static void bxe_handle_fp_tq(void *conte static int bxe_add_cdev(struct bxe_softc *sc); static void bxe_del_cdev(struct bxe_softc *sc); +int bxe_grc_dump(struct bxe_softc *sc); static int bxe_alloc_buf_rings(struct bxe_softc *sc); static void bxe_free_buf_rings(struct bxe_softc *sc); @@ -5231,12 +5246,24 @@ bxe_tx_encap(struct bxe_fastpath *fp, st fp->eth_q_stats.tx_dma_mapping_failure++; /* No sense in trying to defrag/copy chain, drop it. :( */ rc = error; - } - else { - /* if the chain is still too long then drop it */ - if (__predict_false(nsegs > BXE_MAX_SEGMENTS)) { - bus_dmamap_unload(fp->tx_mbuf_tag, tx_buf->m_map); - rc = ENODEV; + } else { + /* if the chain is still too long then drop it */ + if(m0->m_pkthdr.csum_flags & CSUM_TSO) { + /* + * in case TSO is enabled nsegs should be checked against + * BXE_TSO_MAX_SEGMENTS + */ + if (__predict_false(nsegs > BXE_TSO_MAX_SEGMENTS)) { + bus_dmamap_unload(fp->tx_mbuf_tag, tx_buf->m_map); + fp->eth_q_stats.nsegs_path1_errors++; + rc = ENODEV; + } + } else { + if (__predict_false(nsegs > BXE_MAX_SEGMENTS)) { + bus_dmamap_unload(fp->tx_mbuf_tag, tx_buf->m_map); + fp->eth_q_stats.nsegs_path2_errors++; + rc = ENODEV; + } } } } @@ -5636,6 +5663,11 @@ bxe_tx_mq_start_locked(struct bxe_softc BXE_FP_TX_LOCK_ASSERT(fp); + if (sc->state != BXE_STATE_OPEN) { + fp->eth_q_stats.bxe_tx_mq_sc_state_failures++; + return ENETDOWN; + } + if (!tx_br) { BLOGE(sc, "Multiqueue TX and no buf_ring!\n"); return (EINVAL); @@ -5757,6 +5789,11 @@ bxe_tx_mq_start(struct ifnet *ifp, fp = &sc->fp[fp_index]; + if (sc->state != BXE_STATE_OPEN) { + fp->eth_q_stats.bxe_tx_mq_sc_state_failures++; + return ENETDOWN; + } + if (BXE_FP_TX_TRYLOCK(fp)) { rc = bxe_tx_mq_start_locked(sc, ifp, fp, m); BXE_FP_TX_UNLOCK(fp); @@ -5779,7 +5816,7 @@ bxe_mq_flush(struct ifnet *ifp) for (i = 0; i < sc->num_queues; i++) { fp = &sc->fp[i]; - if (fp->state != BXE_FP_STATE_OPEN) { + if (fp->state != BXE_FP_STATE_IRQ) { BLOGD(sc, DBG_LOAD, "Not clearing fp[%02d] buf_ring (state=%d)\n", fp->index, fp->state); continue; @@ -5996,6 +6033,7 @@ bxe_free_mem(struct bxe_softc *sc) static int bxe_alloc_mem(struct bxe_softc *sc) { + int context_size; int allocated; int i; @@ -6990,7 +7028,7 @@ bxe_link_attn(struct bxe_softc *sc) /* Make sure that we are synced with the current statistics */ bxe_stats_handle(sc, STATS_EVENT_STOP); - + BLOGI(sc, "link_vars phy_flags : %x\n", sc->link_vars.phy_flags); elink_link_update(&sc->link_params, &sc->link_vars); if (sc->link_vars.link_up) { @@ -11195,7 +11233,9 @@ bxe_get_q_flags(struct bxe_softc *sc, if (if_getcapenable(sc->ifp) & IFCAP_LRO) { bxe_set_bit(ECORE_Q_FLG_TPA, &flags); +#if __FreeBSD_version >= 800000 bxe_set_bit(ECORE_Q_FLG_TPA_IPV6, &flags); +#endif } if (leading) { @@ -11632,13 +11672,13 @@ static void bxe_calc_fc_adv(struct bxe_softc *sc) { uint8_t cfg_idx = bxe_get_link_cfg_idx(sc); + + + sc->port.advertising[cfg_idx] &= ~(ADVERTISED_Asym_Pause | + ADVERTISED_Pause); + switch (sc->link_vars.ieee_fc & MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK) { - case MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE: - default: - sc->port.advertising[cfg_idx] &= ~(ADVERTISED_Asym_Pause | - ADVERTISED_Pause); - break; case MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH: sc->port.advertising[cfg_idx] |= (ADVERTISED_Asym_Pause | @@ -11648,6 +11688,10 @@ bxe_calc_fc_adv(struct bxe_softc *sc) case MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC: sc->port.advertising[cfg_idx] |= ADVERTISED_Asym_Pause; break; + + default: + break; + } } @@ -11729,15 +11773,17 @@ bxe_link_report_locked(struct bxe_softc return; } + ELINK_DEBUG_P2(sc, "Change in link status : cur_data = %x, last_reported_link = %x\n", + cur_data.link_report_flags, sc->last_reported_link.link_report_flags); sc->link_cnt++; + ELINK_DEBUG_P1(sc, "link status change count = %x\n", sc->link_cnt); /* report new link params and remember the state for the next time */ memcpy(&sc->last_reported_link, &cur_data, sizeof(cur_data)); if (bxe_test_bit(BXE_LINK_REPORT_LINK_DOWN, &cur_data.link_report_flags)) { if_link_state_change(sc->ifp, LINK_STATE_DOWN); - BLOGI(sc, "NIC Link is Down\n"); } else { const char *duplex; const char *flow; @@ -11745,8 +11791,10 @@ bxe_link_report_locked(struct bxe_softc if (bxe_test_and_clear_bit(BXE_LINK_REPORT_FULL_DUPLEX, &cur_data.link_report_flags)) { duplex = "full"; + ELINK_DEBUG_P0(sc, "link set to full duplex\n"); } else { duplex = "half"; + ELINK_DEBUG_P0(sc, "link set to half duplex\n"); } /* @@ -12647,6 +12695,7 @@ bxe_init_ifnet(struct bxe_softc *sc) ifmedia_set(&sc->ifmedia, (IFM_ETHER | IFM_AUTO)); sc->ifmedia.ifm_media = sc->ifmedia.ifm_cur->ifm_media; /* XXX ? */ + BLOGI(sc, "IFMEDIA flags : %x\n", sc->ifmedia.ifm_media); /* allocate the ifnet structure */ if ((ifp = if_gethandle(IFT_ETHER)) == NULL) { @@ -13994,6 +14043,8 @@ bxe_link_settings_supported(struct bxe_s BLOGD(sc, DBG_LOAD, "PHY supported 0=0x%08x 1=0x%08x\n", sc->port.supported[0], sc->port.supported[1]); + ELINK_DEBUG_P2(sc, "PHY supported 0=0x%08x 1=0x%08x\n", + sc->port.supported[0], sc->port.supported[1]); } static void @@ -14058,6 +14109,8 @@ bxe_link_settings_requested(struct bxe_s sc->link_params.req_duplex[idx] = DUPLEX_HALF; sc->port.advertising[idx] |= (ADVERTISED_10baseT_Half | ADVERTISED_TP); + ELINK_DEBUG_P1(sc, "driver requesting DUPLEX_HALF req_duplex = %x!\n", + sc->link_params.req_duplex[idx]); } else { BLOGE(sc, "Invalid NVRAM config link_config=0x%08x " "speed_cap_mask=0x%08x\n", @@ -14162,6 +14215,11 @@ bxe_link_settings_requested(struct bxe_s sc->link_params.req_duplex[idx], sc->link_params.req_flow_ctrl[idx], sc->port.advertising[idx]); + ELINK_DEBUG_P3(sc, "req_line_speed=%d req_duplex=%d " + "advertising=0x%x\n", + sc->link_params.req_line_speed[idx], + sc->link_params.req_duplex[idx], + sc->port.advertising[idx]); } } @@ -14174,11 +14232,12 @@ bxe_get_phy_info(struct bxe_softc *sc) /* shmem data already read in bxe_get_shmem_info() */ - BLOGD(sc, DBG_LOAD, "lane_config=0x%08x speed_cap_mask0=0x%08x " + ELINK_DEBUG_P3(sc, "lane_config=0x%08x speed_cap_mask0=0x%08x " "link_config0=0x%08x\n", sc->link_params.lane_config, sc->link_params.speed_cap_mask[0], sc->port.link_config[0]); + bxe_link_settings_supported(sc, sc->link_params.switch_cfg); bxe_link_settings_requested(sc); @@ -14209,6 +14268,7 @@ bxe_get_phy_info(struct bxe_softc *sc) /* get the media type */ bxe_media_detect(sc); + ELINK_DEBUG_P1(sc, "detected media type\n", sc->media); } static void @@ -15564,6 +15624,86 @@ bxe_sysctl_eth_q_stat(SYSCTL_HANDLER_ARG return (sysctl_handle_64(oidp, &value, 0, req)); } +static void bxe_force_link_reset(struct bxe_softc *sc) +{ + + bxe_acquire_phy_lock(sc); + elink_link_reset(&sc->link_params, &sc->link_vars, 1); + bxe_release_phy_lock(sc); +} + +static int +bxe_sysctl_pauseparam(SYSCTL_HANDLER_ARGS) +{ + struct bxe_softc *sc = (struct bxe_softc *)arg1;; + uint32_t cfg_idx = bxe_get_link_cfg_idx(sc); + int rc = 0; + int error; + int result; + + + error = sysctl_handle_int(oidp, &sc->bxe_pause_param, 0, req); + + if (error || !req->newptr) { + return (error); + } + if ((sc->bxe_pause_param < 0) || (sc->bxe_pause_param > 8)) { + BLOGW(sc, "invalid pause param (%d) - use intergers between 1 & 8\n",sc->bxe_pause_param); + sc->bxe_pause_param = 8; + } + + result = (sc->bxe_pause_param << PORT_FEATURE_FLOW_CONTROL_SHIFT); + + + if((result & 0x400) && !(sc->port.supported[cfg_idx] & ELINK_SUPPORTED_Autoneg)) { + BLOGW(sc, "Does not support Autoneg pause_param %d\n", sc->bxe_pause_param); + return -EINVAL; + } + + if(IS_MF(sc)) + return 0; + sc->link_params.req_flow_ctrl[cfg_idx] = ELINK_FLOW_CTRL_AUTO; + if(result & ELINK_FLOW_CTRL_RX) + sc->link_params.req_flow_ctrl[cfg_idx] |= ELINK_FLOW_CTRL_RX; + + if(result & ELINK_FLOW_CTRL_TX) + sc->link_params.req_flow_ctrl[cfg_idx] |= ELINK_FLOW_CTRL_TX; + if(sc->link_params.req_flow_ctrl[cfg_idx] == ELINK_FLOW_CTRL_AUTO) + sc->link_params.req_flow_ctrl[cfg_idx] = ELINK_FLOW_CTRL_NONE; + + if(result & 0x400) { + if (sc->link_params.req_line_speed[cfg_idx] == ELINK_SPEED_AUTO_NEG) { + sc->link_params.req_flow_ctrl[cfg_idx] = + ELINK_FLOW_CTRL_AUTO; + } + sc->link_params.req_fc_auto_adv = 0; + if (result & ELINK_FLOW_CTRL_RX) + sc->link_params.req_fc_auto_adv |= ELINK_FLOW_CTRL_RX; + + if (result & ELINK_FLOW_CTRL_TX) + sc->link_params.req_fc_auto_adv |= ELINK_FLOW_CTRL_TX; + if (!sc->link_params.req_fc_auto_adv) + sc->link_params.req_fc_auto_adv |= ELINK_FLOW_CTRL_NONE; + } + if (IS_PF(sc)) { + if (sc->link_vars.link_up) { + bxe_stats_handle(sc, STATS_EVENT_STOP); + } + if (if_getdrvflags(sc->ifp) & IFF_DRV_RUNNING) { + bxe_force_link_reset(sc); + bxe_acquire_phy_lock(sc); + + rc = elink_phy_init(&sc->link_params, &sc->link_vars); + + bxe_release_phy_lock(sc); + + bxe_calc_fc_adv(sc); + } + } + return rc; +} + + static void bxe_add_sysctls(struct bxe_softc *sc) { @@ -15664,6 +15804,12 @@ bxe_add_sysctls(struct bxe_softc *sc) CTLFLAG_RW, &sc->rx_budget, 0, "rx processing budget"); + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "pause_param", + CTLTYPE_UINT | CTLFLAG_RW, sc, 0, + bxe_sysctl_pauseparam, "IU", + "need pause frames- DEF:0/TX:1/RX:2/BOTH:3/AUTO:4/AUTOTX:5/AUTORX:6/AUTORXTX:7/NONE:8"); + + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "state", CTLTYPE_UINT | CTLFLAG_RW, sc, 0, bxe_sysctl_state, "IU", "dump driver state"); @@ -17998,6 +18144,7 @@ bxe_reset_port(struct bxe_softc *sc) int port = SC_PORT(sc); uint32_t val; + ELINK_DEBUG_P0(sc, "bxe_reset_port called\n"); /* reset physical Link */ bxe_link_reset(sc); @@ -18500,8 +18647,6 @@ bxe_grc_dump(struct bxe_softc *sc) uint32_t reg_val; uint32_t reg_addr; uint32_t cmd_offset; - int context_size; - int allocated; struct ecore_ilt *ilt = SC_ILT(sc); struct bxe_fastpath *fp; struct ilt_client_info *ilt_cli; @@ -18596,67 +18741,80 @@ bxe_grc_dump(struct bxe_softc *sc) bxe_pretend_func(sc, SC_ABS_FUNC(sc)); - context_size = (sizeof(union cdu_context) * BXE_L2_CID_COUNT(sc)); - for (i = 0, allocated = 0; allocated < context_size; i++) { - - BLOGI(sc, "cdu_context i %d paddr %#jx vaddr %p size 0x%zx\n", i, - (uintmax_t)sc->context[i].vcxt_dma.paddr, - sc->context[i].vcxt_dma.vaddr, - sc->context[i].size); - allocated += sc->context[i].size; - } - BLOGI(sc, "fw stats start_paddr %#jx end_paddr %#jx vaddr %p size 0x%x\n", - (uintmax_t)sc->fw_stats_req_mapping, - (uintmax_t)sc->fw_stats_data_mapping, - sc->fw_stats_req, (sc->fw_stats_req_size + sc->fw_stats_data_size)); - BLOGI(sc, "def_status_block paddr %p vaddr %p size 0x%zx\n", - (void *)sc->def_sb_dma.paddr, sc->def_sb, - sizeof(struct host_sp_status_block)); - BLOGI(sc, "event_queue paddr %#jx vaddr %p size 0x%x\n", - (uintmax_t)sc->eq_dma.paddr, sc->eq_dma.vaddr, BCM_PAGE_SIZE); - BLOGI(sc, "slow path paddr %#jx vaddr %p size 0x%zx\n", - (uintmax_t)sc->sp_dma.paddr, sc->sp_dma.vaddr, - sizeof(struct bxe_slowpath)); - BLOGI(sc, "slow path queue paddr %#jx vaddr %p size 0x%x\n", - (uintmax_t)sc->spq_dma.paddr, sc->spq_dma.vaddr, BCM_PAGE_SIZE); - BLOGI(sc, "fw_buf paddr %#jx vaddr %p size 0x%x\n", - (uintmax_t)sc->gz_buf_dma.paddr, sc->gz_buf_dma.vaddr, - FW_BUF_SIZE); - for (i = 0; i < sc->num_queues; i++) { - fp = &sc->fp[i]; - BLOGI(sc, "FP status block fp %d paddr %#jx vaddr %p size 0x%zx\n", i, - (uintmax_t)fp->sb_dma.paddr, fp->sb_dma.vaddr, - sizeof(union bxe_host_hc_status_block)); - BLOGI(sc, "TX BD CHAIN fp %d paddr %#jx vaddr %p size 0x%x\n", i, - (uintmax_t)fp->tx_dma.paddr, fp->tx_dma.vaddr, - (BCM_PAGE_SIZE * TX_BD_NUM_PAGES)); - BLOGI(sc, "RX BD CHAIN fp %d paddr %#jx vaddr %p size 0x%x\n", i, - (uintmax_t)fp->rx_dma.paddr, fp->rx_dma.vaddr, - (BCM_PAGE_SIZE * RX_BD_NUM_PAGES)); - BLOGI(sc, "RX RCQ CHAIN fp %d paddr %#jx vaddr %p size 0x%zx\n", i, - (uintmax_t)fp->rcq_dma.paddr, fp->rcq_dma.vaddr, - (BCM_PAGE_SIZE * RCQ_NUM_PAGES)); - BLOGI(sc, "RX SGE CHAIN fp %d paddr %#jx vaddr %p size 0x%x\n", i, - (uintmax_t)fp->rx_sge_dma.paddr, fp->rx_sge_dma.vaddr, - (BCM_PAGE_SIZE * RX_SGE_NUM_PAGES)); - } - - ilt_cli = &ilt->clients[1]; - for (i = ilt_cli->start; i <= ilt_cli->end; i++) { - BLOGI(sc, "ECORE_ILT paddr %#jx vaddr %p size 0x%x\n", - (uintmax_t)(((struct bxe_dma *)((&ilt->lines[i])->page))->paddr), - ((struct bxe_dma *)((&ilt->lines[i])->page))->vaddr, BCM_PAGE_SIZE); - } - - - cmd_offset = DMAE_REG_CMD_MEM; - for (i = 0; i < 224; i++) { - reg_addr = (cmd_offset +(i * 4)); - reg_val = REG_RD(sc, reg_addr); - BLOGI(sc, "DMAE_REG_CMD_MEM i=%d reg_addr 0x%x reg_val 0x%08x\n",i, - reg_addr, reg_val); - } + if(sc->state == BXE_STATE_OPEN) { + if(sc->fw_stats_req != NULL) { + BLOGI(sc, "fw stats start_paddr %#jx end_paddr %#jx vaddr %p size 0x%x\n", + (uintmax_t)sc->fw_stats_req_mapping, + (uintmax_t)sc->fw_stats_data_mapping, + sc->fw_stats_req, (sc->fw_stats_req_size + sc->fw_stats_data_size)); + } + if(sc->def_sb != NULL) { + BLOGI(sc, "def_status_block paddr %p vaddr %p size 0x%zx\n", + (void *)sc->def_sb_dma.paddr, sc->def_sb, + sizeof(struct host_sp_status_block)); + } + if(sc->eq_dma.vaddr != NULL) { + BLOGI(sc, "event_queue paddr %#jx vaddr %p size 0x%x\n", + (uintmax_t)sc->eq_dma.paddr, sc->eq_dma.vaddr, BCM_PAGE_SIZE); + } + if(sc->sp_dma.vaddr != NULL) { + BLOGI(sc, "slow path paddr %#jx vaddr %p size 0x%zx\n", + (uintmax_t)sc->sp_dma.paddr, sc->sp_dma.vaddr, + sizeof(struct bxe_slowpath)); + } + if(sc->spq_dma.vaddr != NULL) { + BLOGI(sc, "slow path queue paddr %#jx vaddr %p size 0x%x\n", + (uintmax_t)sc->spq_dma.paddr, sc->spq_dma.vaddr, BCM_PAGE_SIZE); + } + if(sc->gz_buf_dma.vaddr != NULL) { + BLOGI(sc, "fw_buf paddr %#jx vaddr %p size 0x%x\n", + (uintmax_t)sc->gz_buf_dma.paddr, sc->gz_buf_dma.vaddr, + FW_BUF_SIZE); + } + for (i = 0; i < sc->num_queues; i++) { + fp = &sc->fp[i]; + if(fp->sb_dma.vaddr != NULL && fp->tx_dma.vaddr != NULL && + fp->rx_dma.vaddr != NULL && fp->rcq_dma.vaddr != NULL && + fp->rx_sge_dma.vaddr != NULL) { + + BLOGI(sc, "FP status block fp %d paddr %#jx vaddr %p size 0x%zx\n", i, + (uintmax_t)fp->sb_dma.paddr, fp->sb_dma.vaddr, + sizeof(union bxe_host_hc_status_block)); + BLOGI(sc, "TX BD CHAIN fp %d paddr %#jx vaddr %p size 0x%x\n", i, + (uintmax_t)fp->tx_dma.paddr, fp->tx_dma.vaddr, + (BCM_PAGE_SIZE * TX_BD_NUM_PAGES)); + BLOGI(sc, "RX BD CHAIN fp %d paddr %#jx vaddr %p size 0x%x\n", i, + (uintmax_t)fp->rx_dma.paddr, fp->rx_dma.vaddr, + (BCM_PAGE_SIZE * RX_BD_NUM_PAGES)); + BLOGI(sc, "RX RCQ CHAIN fp %d paddr %#jx vaddr %p size 0x%zx\n", i, + (uintmax_t)fp->rcq_dma.paddr, fp->rcq_dma.vaddr, + (BCM_PAGE_SIZE * RCQ_NUM_PAGES)); + BLOGI(sc, "RX SGE CHAIN fp %d paddr %#jx vaddr %p size 0x%x\n", i, + (uintmax_t)fp->rx_sge_dma.paddr, fp->rx_sge_dma.vaddr, + (BCM_PAGE_SIZE * RX_SGE_NUM_PAGES)); + } + } + if(ilt != NULL ) { + ilt_cli = &ilt->clients[1]; + if(ilt->lines != NULL) { + for (i = ilt_cli->start; i <= ilt_cli->end; i++) { + BLOGI(sc, "ECORE_ILT paddr %#jx vaddr %p size 0x%x\n", + (uintmax_t)(((struct bxe_dma *)((&ilt->lines[i])->page))->paddr), + ((struct bxe_dma *)((&ilt->lines[i])->page))->vaddr, BCM_PAGE_SIZE); + } + } + } + + + cmd_offset = DMAE_REG_CMD_MEM; + for (i = 0; i < 224; i++) { + reg_addr = (cmd_offset +(i * 4)); + reg_val = REG_RD(sc, reg_addr); + BLOGI(sc, "DMAE_REG_CMD_MEM i=%d reg_addr 0x%x reg_val 0x%08x\n",i, + reg_addr, reg_val); + } + } BLOGI(sc, "Collection of grcdump done\n"); sc->grcdump_done = 1; Modified: stable/11/sys/dev/bxe/bxe.h ============================================================================== --- stable/11/sys/dev/bxe/bxe.h Fri Mar 24 01:52:10 2017 (r315880) +++ stable/11/sys/dev/bxe/bxe.h Fri Mar 24 02:58:20 2017 (r315881) @@ -1335,7 +1335,7 @@ struct bxe_softc { struct ifmedia ifmedia; /* network interface media structure */ int media; - int state; /* device state */ + volatile int state; /* device state */ #define BXE_STATE_CLOSED 0x0000 #define BXE_STATE_OPENING_WAITING_LOAD 0x1000 #define BXE_STATE_OPENING_WAITING_PORT 0x2000 @@ -1794,7 +1794,7 @@ struct bxe_softc { unsigned int trigger_grcdump; unsigned int grcdump_done; unsigned int grcdump_started; - + int bxe_pause_param; void *eeprom; }; /* struct bxe_softc */ @@ -2300,7 +2300,6 @@ void bxe_dump_mem(struct bxe_softc *sc, uint8_t *mem, uint32_t len); void bxe_dump_mbuf_data(struct bxe_softc *sc, char *pTag, struct mbuf *m, uint8_t contents); -extern int bxe_grc_dump(struct bxe_softc *sc); #if __FreeBSD_version >= 800000 #if (__FreeBSD_version >= 1001513 && __FreeBSD_version < 1100000) ||\ Modified: stable/11/sys/dev/bxe/bxe_elink.c ============================================================================== --- stable/11/sys/dev/bxe/bxe_elink.c Fri Mar 24 01:52:10 2017 (r315880) +++ stable/11/sys/dev/bxe/bxe_elink.c Fri Mar 24 02:58:20 2017 (r315881) @@ -4333,6 +4333,7 @@ static void elink_pause_resolve(struct e * although we advertised both, need to enable * RX only. */ + if (params->req_fc_auto_adv == ELINK_FLOW_CTRL_BOTH) { ELINK_DEBUG_P0(sc, "Flow Control: RX & TX\n"); vars->flow_ctrl = ELINK_FLOW_CTRL_BOTH; @@ -5538,6 +5539,7 @@ static void elink_sync_link(struct elink vars->link_up = (vars->link_status & LINK_STATUS_LINK_UP); if (vars->link_up) { ELINK_DEBUG_P0(sc, "phy link up\n"); + ELINK_DEBUG_P1(sc, "link status = %x\n", vars->link_status); vars->phy_link_up = 1; vars->duplex = DUPLEX_FULL; @@ -6443,6 +6445,8 @@ static elink_status_t elink_get_link_spe vars->flow_ctrl = ELINK_FLOW_CTRL_NONE; vars->mac_type = ELINK_MAC_TYPE_NONE; } + ELINK_DEBUG_P2(sc, " in elink_get_link_speed_duplex vars->link_status = %x, vars->duplex = %x\n", + vars->link_status, vars->duplex); ELINK_DEBUG_P2(sc, " phy_link_up %x line_speed %d\n", vars->phy_link_up, vars->line_speed); return ELINK_STATUS_OK; @@ -6462,8 +6466,16 @@ static elink_status_t elink_link_setting MDIO_REG_BANK_GP_STATUS, MDIO_GP_STATUS_TOP_AN_STATUS1, &gp_status); - if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_DUPLEX_STATUS) + if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_DUPLEX_STATUS) { duplex = DUPLEX_FULL; + ELINK_DEBUG_P1(sc, "duplex status read from phy is = %x\n", + duplex); + } else { + ELINK_DEBUG_P1(sc, "phy status does not allow interface to be FULL_DUPLEX : %x\n", + gp_status); + } + + if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS) link_up = 1; speed_mask = gp_status & ELINK_GP_STATUS_SPEED_MASK; @@ -6539,6 +6551,8 @@ static elink_status_t elink_warpcore_rea elink_cl45_read(sc, phy, MDIO_WC_DEVAD, MDIO_WC_REG_DIGITAL5_LINK_STATUS, &link_up); link_up &= 0x1; + ELINK_DEBUG_P1(sc, "params->loopback_mode link_up read = %x\n", + link_up); } else if ((phy->req_line_speed > ELINK_SPEED_10000) && (phy->supported & ELINK_SUPPORTED_20000baseMLD2_Full)) { uint16_t temp_link_up; @@ -6568,6 +6582,8 @@ static elink_status_t elink_warpcore_rea elink_cl45_read(sc, phy, MDIO_AN_DEVAD, MDIO_AN_REG_STATUS, &an_link); link_up |= (an_link & (1<<2)); + ELINK_DEBUG_P2(sc,"an_link = %x, link_up = %x\n", an_link, + link_up); } if (link_up && ELINK_SINGLE_MEDIA_DIRECT(params)) { uint16_t pd, gp_status4; @@ -6587,12 +6603,17 @@ static elink_status_t elink_warpcore_rea if (pd & (1<<15)) vars->link_status |= LINK_STATUS_PARALLEL_DETECTION_USED; + ELINK_DEBUG_P2(sc, "pd = %x, link_status = %x\n", + pd, vars->link_status); } elink_ext_phy_resolve_fc(phy, params, vars); vars->duplex = duplex; + ELINK_DEBUG_P3(sc, " ELINK_SINGLE_MEDIA_DIRECT duplex %x flow_ctrl 0x%x link_status 0x%x\n", + vars->duplex, vars->flow_ctrl, vars->link_status); } } - + ELINK_DEBUG_P3(sc, "duplex %x flow_ctrl 0x%x link_status 0x%x\n", + vars->duplex, vars->flow_ctrl, vars->link_status); if ((vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) && ELINK_SINGLE_MEDIA_DIRECT(params)) { uint16_t val; @@ -6607,7 +6628,8 @@ static elink_status_t elink_warpcore_rea MDIO_CL73_IEEEB1_AN_ADV2_ADVR_10G_KR)) vars->link_status |= LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; - + ELINK_DEBUG_P2(sc, "val = %x, link_status = %x\n", + val, vars->link_status); elink_cl45_read(sc, phy, MDIO_WC_DEVAD, MDIO_WC_REG_DIGITAL3_LP_UP1, &val); @@ -6617,6 +6639,8 @@ static elink_status_t elink_warpcore_rea if (val & (MDIO_OVER_1G_UP1_10G | MDIO_OVER_1G_UP1_10GH)) vars->link_status |= LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE; + ELINK_DEBUG_P2(sc, "val = %x, link_status = %x\n", + val, vars->link_status); } @@ -7808,6 +7832,19 @@ elink_status_t elink_link_update(struct ELINK_DEBUG_P1(sc, "Active external phy selected: %x\n", active_external_phy); } + + ELINK_DEBUG_P3(sc, "vars : phy_flags = %x, mac_type = %x, phy_link_up = %x\n", + vars->phy_flags, vars->mac_type, vars->phy_link_up); + ELINK_DEBUG_P3(sc, "vars : link_up = %x, line_speed = %x, duplex = %x\n", + vars->link_up, vars->line_speed, vars->duplex); + ELINK_DEBUG_P3(sc, "vars : flow_ctrl = %x, ieee_fc = %x, link_status = %x\n", + vars->flow_ctrl, vars->ieee_fc, vars->link_status); + ELINK_DEBUG_P3(sc, "vars : eee_status = %x, fault_detected = %x, check_kr2_recovery_cnt = %x\n", + vars->eee_status, vars->fault_detected, vars->check_kr2_recovery_cnt); + ELINK_DEBUG_P3(sc, "vars : periodic_flags = %x, aeu_int_mask = %x, rx_tx_asic_rst = %x\n", + vars->periodic_flags, vars->aeu_int_mask, vars->rx_tx_asic_rst); + ELINK_DEBUG_P2(sc, "vars : turn_to_run_wc_rt = %x, rsrv2 = %x\n", + vars->turn_to_run_wc_rt, vars->rsrv2); for (phy_index = ELINK_EXT_PHY1; phy_index < params->num_phys; phy_index++) { @@ -7835,6 +7872,7 @@ elink_status_t elink_link_update(struct " link speed %d\n", vars->line_speed, ext_phy_line_speed); vars->phy_link_up = 0; + ELINK_DEBUG_P0(sc, "phy_link_up set to 0\n"); } else if (prev_line_speed != vars->line_speed) { REG_WR(sc, NIG_REG_EGRESS_DRAIN0_MODE + params->port*4, 0); @@ -7883,6 +7921,12 @@ elink_status_t elink_link_update(struct ELINK_SINGLE_MEDIA_DIRECT(params)) && (phy_vars[active_external_phy].fault_detected == 0)); + if(vars->link_up) { + ELINK_DEBUG_P0(sc, "local phy and external phy are up\n"); + } else { + ELINK_DEBUG_P0(sc, "either local phy or external phy or both are down\n"); + } + /* Update the PFC configuration in case it was changed */ if (params->feature_config_flags & ELINK_FEATURE_CONFIG_PFC_ENABLED) vars->link_status |= LINK_STATUS_PFC_ENABLED; @@ -12943,6 +12987,8 @@ static void elink_populate_preemphasis(s phy->tx_preemphasis[i << 1] = ((tx>>16) & 0xffff); phy->tx_preemphasis[(i << 1) + 1] = (tx & 0xffff); + ELINK_DEBUG_P2(sc,"phy->rx_preemphasis = %x, phy->tx_preemphasis = %x\n", + phy->rx_preemphasis[i << 1], phy->tx_preemphasis[i << 1]); } } @@ -13070,6 +13116,8 @@ static elink_status_t elink_populate_int phy->flags |= ELINK_FLAGS_MDC_MDIO_WA; else phy->flags |= ELINK_FLAGS_MDC_MDIO_WA_B0; + ELINK_DEBUG_P3(sc, "media_type = %x, flags = %x, supported = %x\n", + phy->media_type, phy->flags, phy->supported); } else { switch (switch_cfg) { @@ -13300,6 +13348,9 @@ static void elink_phy_def_cfg(struct eli break; } + ELINK_DEBUG_P2(sc, "Default config phy idx %x, req_duplex config %x\n", + phy_index, phy->req_duplex); + switch (link_config & PORT_FEATURE_FLOW_CONTROL_MASK) { case PORT_FEATURE_FLOW_CONTROL_AUTO: phy->req_flow_ctrl = ELINK_FLOW_CTRL_AUTO; @@ -13317,6 +13368,8 @@ static void elink_phy_def_cfg(struct eli phy->req_flow_ctrl = ELINK_FLOW_CTRL_NONE; break; } + ELINK_DEBUG_P3(sc, "Requested Duplex = %x, line_speed = %x, flow_ctrl = %x\n", + phy->req_duplex, phy->req_line_speed, phy->req_flow_ctrl); } uint32_t elink_phy_selection(struct elink_params *params) @@ -13924,6 +13977,18 @@ elink_status_t elink_phy_init(struct eli /* Check if link flap can be avoided */ lfa_status = elink_check_lfa(params); + ELINK_DEBUG_P3(sc, " params : port = %x, loopback_mode = %x req_duplex = %x\n", + params->port, params->loopback_mode, params->req_duplex[0]); + ELINK_DEBUG_P3(sc, " params : switch_cfg = %x, lane_config = %x req_duplex[1] = %x\n", + params->switch_cfg, params->lane_config, params->req_duplex[1]); + ELINK_DEBUG_P3(sc, " params : chip_id = %x, feature_config_flags = %x, num_phys = %x\n", + params->chip_id, params->feature_config_flags, params->num_phys); + ELINK_DEBUG_P3(sc, " params : rsrv = %x, eee_mode = %x, hw_led_mode = x\n", + params->rsrv, params->eee_mode, params->hw_led_mode); + ELINK_DEBUG_P3(sc, " params : multi_phy = %x, req_fc_auto_adv = %x, link_flags = %x\n", + params->multi_phy_config, params->req_fc_auto_adv, params->link_flags); + ELINK_DEBUG_P2(sc, " params : lfa_base = %x, link_attr = %x\n", + params->lfa_base, params->link_attr_sync); if (lfa_status == 0) { ELINK_DEBUG_P0(sc, "Link Flap Avoidance in progress\n"); return elink_avoid_link_flap(params, vars); Modified: stable/11/sys/dev/bxe/bxe_stats.c ============================================================================== --- stable/11/sys/dev/bxe/bxe_stats.c Fri Mar 24 01:52:10 2017 (r315880) +++ stable/11/sys/dev/bxe/bxe_stats.c Fri Mar 24 02:58:20 2017 (r315881) @@ -36,6 +36,8 @@ __FBSDID("$FreeBSD$"); #define BITS_PER_LONG 64 #endif +extern int bxe_grc_dump(struct bxe_softc *sc); + static inline long bxe_hilo(uint32_t *hiref) { Modified: stable/11/sys/dev/bxe/bxe_stats.h ============================================================================== --- stable/11/sys/dev/bxe/bxe_stats.h Fri Mar 24 01:52:10 2017 (r315880) +++ stable/11/sys/dev/bxe/bxe_stats.h Fri Mar 24 02:58:20 2017 (r315881) @@ -267,9 +267,13 @@ struct bxe_eth_stats { /* num. of times tx queue full occurred */ uint32_t tx_queue_full_return; /* debug stats */ + uint32_t bxe_tx_mq_sc_state_failures; uint32_t tx_request_link_down_failures; uint32_t bd_avail_too_less_failures; uint32_t tx_mq_not_empty; + uint32_t nsegs_path1_errors; + uint32_t nsegs_path2_errors; + }; @@ -378,9 +382,13 @@ struct bxe_eth_q_stats { uint32_t tx_queue_full_return; /* debug stats */ + uint32_t bxe_tx_mq_sc_state_failures; uint32_t tx_request_link_down_failures; uint32_t bd_avail_too_less_failures; uint32_t tx_mq_not_empty; + uint32_t nsegs_path1_errors; + uint32_t nsegs_path2_errors; + }; struct bxe_eth_stats_old { From owner-svn-src-stable-11@freebsd.org Fri Mar 24 06:59:42 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3267AD1B7E1; Fri, 24 Mar 2017 06:59:42 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 075F31840; Fri, 24 Mar 2017 06:59:41 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2O6xf8P053325; Fri, 24 Mar 2017 06:59:41 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2O6xfTt053324; Fri, 24 Mar 2017 06:59:41 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703240659.v2O6xfTt053324@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 24 Mar 2017 06:59:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315886 - stable/11/sys/cam/ctl X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Mar 2017 06:59:42 -0000 Author: mav Date: Fri Mar 24 06:59:40 2017 New Revision: 315886 URL: https://svnweb.freebsd.org/changeset/base/315886 Log: MFC r315025: Switch work_queue from TAILQ to STAILQ. It is mostly FIFO and we don't need random removal there. Modified: stable/11/sys/cam/ctl/scsi_ctl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/ctl/scsi_ctl.c ============================================================================== --- stable/11/sys/cam/ctl/scsi_ctl.c Fri Mar 24 03:37:58 2017 (r315885) +++ stable/11/sys/cam/ctl/scsi_ctl.c Fri Mar 24 06:59:40 2017 (r315886) @@ -105,7 +105,7 @@ struct ctlfe_lun_softc { int atios_alloced; /* Number of ATIOs not freed */ int inots_alloced; /* Number of INOTs not freed */ struct task refdrain_task; - TAILQ_HEAD(, ccb_hdr) work_queue; + STAILQ_HEAD(, ccb_hdr) work_queue; STAILQ_ENTRY(ctlfe_lun_softc) links; }; @@ -449,7 +449,7 @@ ctlferegister(struct cam_periph *periph, softc = (struct ctlfe_lun_softc *)arg; bus_softc = softc->parent_softc; - TAILQ_INIT(&softc->work_queue); + STAILQ_INIT(&softc->work_queue); softc->periph = periph; periph->softc = softc; @@ -738,14 +738,13 @@ ctlfestart(struct cam_periph *periph, un softc = (struct ctlfe_lun_softc *)periph->softc; next: - ccb_h = TAILQ_FIRST(&softc->work_queue); + /* Take the ATIO off the work queue */ + ccb_h = STAILQ_FIRST(&softc->work_queue); if (ccb_h == NULL) { xpt_release_ccb(start_ccb); return; } - - /* Take the ATIO off the work queue */ - TAILQ_REMOVE(&softc->work_queue, ccb_h, periph_links.tqe); + STAILQ_REMOVE_HEAD(&softc->work_queue, periph_links.stqe); atio = (struct ccb_accept_tio *)ccb_h; io = (union ctl_io *)ccb_h->io_ptr; csio = &start_ccb->csio; @@ -870,7 +869,7 @@ next: /* * If we still have work to do, ask for another CCB. */ - if (!TAILQ_EMPTY(&softc->work_queue)) + if (!STAILQ_EMPTY(&softc->work_queue)) xpt_schedule(periph, CAM_PRIORITY_NORMAL); } @@ -1196,8 +1195,8 @@ ctlfedone(struct cam_periph *periph, uni io->scsiio.io_hdr.status = CTL_STATUS_NONE; io->io_hdr.flags |= CTL_FLAG_DMA_QUEUED; xpt_release_ccb(done_ccb); - TAILQ_INSERT_HEAD(&softc->work_queue, &atio->ccb_h, - periph_links.tqe); + STAILQ_INSERT_HEAD(&softc->work_queue, &atio->ccb_h, + periph_links.stqe); xpt_schedule(periph, CAM_PRIORITY_NORMAL); break; } @@ -1812,7 +1811,7 @@ ctlfe_dump_queue(struct ctlfe_lun_softc periph = softc->periph; num_items = 0; - TAILQ_FOREACH(hdr, &softc->work_queue, periph_links.tqe) { + STAILQ_FOREACH(hdr, &softc->work_queue, periph_links.stqe) { union ctl_io *io = hdr->io_ptr; num_items++; @@ -1867,8 +1866,8 @@ ctlfe_datamove(union ctl_io *io) io->io_hdr.flags |= CTL_FLAG_DMA_QUEUED; if ((io->io_hdr.status & CTL_STATUS_MASK) != CTL_STATUS_NONE) io->io_hdr.flags |= CTL_FLAG_STATUS_QUEUED; - TAILQ_INSERT_TAIL(&softc->work_queue, &ccb->ccb_h, - periph_links.tqe); + STAILQ_INSERT_TAIL(&softc->work_queue, &ccb->ccb_h, + periph_links.stqe); xpt_schedule(periph, CAM_PRIORITY_NORMAL); cam_periph_unlock(periph); } @@ -1920,8 +1919,8 @@ ctlfe_done(union ctl_io *io) return; } else { io->io_hdr.flags |= CTL_FLAG_STATUS_QUEUED; - TAILQ_INSERT_TAIL(&softc->work_queue, &ccb->ccb_h, - periph_links.tqe); + STAILQ_INSERT_TAIL(&softc->work_queue, &ccb->ccb_h, + periph_links.stqe); xpt_schedule(periph, CAM_PRIORITY_NORMAL); } From owner-svn-src-stable-11@freebsd.org Fri Mar 24 07:01:32 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EF371D1BA14; Fri, 24 Mar 2017 07:01:32 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A450D1CDC; Fri, 24 Mar 2017 07:01:32 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2O71Vmk054232; Fri, 24 Mar 2017 07:01:31 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2O71Vgl054231; Fri, 24 Mar 2017 07:01:31 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703240701.v2O71Vgl054231@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 24 Mar 2017 07:01:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315888 - stable/11/sys/cam/ctl X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Mar 2017 07:01:33 -0000 Author: mav Date: Fri Mar 24 07:01:31 2017 New Revision: 315888 URL: https://svnweb.freebsd.org/changeset/base/315888 Log: MFC r315030: Abort all ATIOs and INOTs queued to SIM on LUN disable. Some SIMs may not abort them implicitly, that either fail the LUN disable request or just make us wait for those CCBs forever. With this change I can successfully disable LUNs on mpt(4). For isp(4), which aborts them implicitly, this change should be irrelevant. Modified: stable/11/sys/cam/ctl/scsi_ctl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/ctl/scsi_ctl.c ============================================================================== --- stable/11/sys/cam/ctl/scsi_ctl.c Fri Mar 24 07:00:16 2017 (r315887) +++ stable/11/sys/cam/ctl/scsi_ctl.c Fri Mar 24 07:01:31 2017 (r315888) @@ -106,6 +106,8 @@ struct ctlfe_lun_softc { int inots_alloced; /* Number of INOTs not freed */ struct task refdrain_task; STAILQ_HEAD(, ccb_hdr) work_queue; + LIST_HEAD(, ccb_hdr) atio_list; /* List of ATIOs queued to SIM. */ + LIST_HEAD(, ccb_hdr) inot_list; /* List of INOTs queued to SIM. */ STAILQ_ENTRY(ctlfe_lun_softc) links; }; @@ -442,7 +444,7 @@ ctlferegister(struct cam_periph *periph, { struct ctlfe_softc *bus_softc; struct ctlfe_lun_softc *softc; - union ccb en_lun_ccb; + union ccb ccb; cam_status status; int i; @@ -450,19 +452,21 @@ ctlferegister(struct cam_periph *periph, bus_softc = softc->parent_softc; STAILQ_INIT(&softc->work_queue); + LIST_INIT(&softc->atio_list); + LIST_INIT(&softc->inot_list); softc->periph = periph; periph->softc = softc; - xpt_setup_ccb(&en_lun_ccb.ccb_h, periph->path, CAM_PRIORITY_NONE); - en_lun_ccb.ccb_h.func_code = XPT_EN_LUN; - en_lun_ccb.cel.grp6_len = 0; - en_lun_ccb.cel.grp7_len = 0; - en_lun_ccb.cel.enable = 1; - xpt_action(&en_lun_ccb); - status = (en_lun_ccb.ccb_h.status & CAM_STATUS_MASK); + xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NONE); + ccb.ccb_h.func_code = XPT_EN_LUN; + ccb.cel.grp6_len = 0; + ccb.cel.grp7_len = 0; + ccb.cel.enable = 1; + xpt_action(&ccb); + status = (ccb.ccb_h.status & CAM_STATUS_MASK); if (status != CAM_REQ_CMP) { xpt_print(periph->path, "%s: Enable LUN failed, status 0x%x\n", - __func__, en_lun_ccb.ccb_h.status); + __func__, ccb.ccb_h.status); return (status); } @@ -496,6 +500,7 @@ ctlferegister(struct cam_periph *periph, PRIV_INFO(new_io) = cmd_info; softc->atios_alloced++; new_ccb->ccb_h.io_ptr = new_io; + LIST_INSERT_HEAD(&softc->atio_list, &new_ccb->ccb_h, periph_links.le); xpt_setup_ccb(&new_ccb->ccb_h, periph->path, /*priority*/ 1); new_ccb->ccb_h.func_code = XPT_ACCEPT_TARGET_IO; @@ -542,6 +547,7 @@ ctlferegister(struct cam_periph *periph, } softc->inots_alloced++; new_ccb->ccb_h.io_ptr = new_io; + LIST_INSERT_HEAD(&softc->inot_list, &new_ccb->ccb_h, periph_links.le); xpt_setup_ccb(&new_ccb->ccb_h, periph->path, /*priority*/ 1); new_ccb->ccb_h.func_code = XPT_IMMEDIATE_NOTIFY; @@ -578,23 +584,34 @@ ctlferegister(struct cam_periph *periph, static void ctlfeoninvalidate(struct cam_periph *periph) { - union ccb en_lun_ccb; - cam_status status; + struct ctlfe_lun_softc *softc = (struct ctlfe_lun_softc *)periph->softc; struct ctlfe_softc *bus_softc; - struct ctlfe_lun_softc *softc; - - softc = (struct ctlfe_lun_softc *)periph->softc; + union ccb ccb; + struct ccb_hdr *hdr; + cam_status status; - xpt_setup_ccb(&en_lun_ccb.ccb_h, periph->path, CAM_PRIORITY_NONE); - en_lun_ccb.ccb_h.func_code = XPT_EN_LUN; - en_lun_ccb.cel.grp6_len = 0; - en_lun_ccb.cel.grp7_len = 0; - en_lun_ccb.cel.enable = 0; - xpt_action(&en_lun_ccb); - status = (en_lun_ccb.ccb_h.status & CAM_STATUS_MASK); + /* Abort all ATIOs and INOTs queued to SIM. */ + xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NONE); + ccb.ccb_h.func_code = XPT_ABORT; + LIST_FOREACH(hdr, &softc->atio_list, periph_links.le) { + ccb.cab.abort_ccb = (union ccb *)hdr; + xpt_action(&ccb); + } + LIST_FOREACH(hdr, &softc->inot_list, periph_links.le) { + ccb.cab.abort_ccb = (union ccb *)hdr; + xpt_action(&ccb); + } + + /* Disable the LUN in SIM. */ + ccb.ccb_h.func_code = XPT_EN_LUN; + ccb.cel.grp6_len = 0; + ccb.cel.grp7_len = 0; + ccb.cel.enable = 0; + xpt_action(&ccb); + status = (ccb.ccb_h.status & CAM_STATUS_MASK); if (status != CAM_REQ_CMP) { xpt_print(periph->path, "%s: Disable LUN failed, status 0x%x\n", - __func__, en_lun_ccb.ccb_h.status); + __func__, ccb.ccb_h.status); /* * XXX KDM what do we do now? */ @@ -952,6 +969,11 @@ ctlfe_requeue_ccb(struct cam_periph *per mtx_unlock(mtx); return; } + softc = (struct ctlfe_lun_softc *)periph->softc; + if (ccb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO) + LIST_INSERT_HEAD(&softc->atio_list, &ccb->ccb_h, periph_links.le); + else + LIST_INSERT_HEAD(&softc->inot_list, &ccb->ccb_h, periph_links.le); if (unlock) cam_periph_unlock(periph); @@ -960,7 +982,6 @@ ctlfe_requeue_ccb(struct cam_periph *per * target/lun. Reset the target and LUN fields back to the wildcard * values before we send them back down to the SIM. */ - softc = (struct ctlfe_lun_softc *)periph->softc; if (softc->flags & CTLFE_LUN_WILDCARD) { ccb->ccb_h.target_id = CAM_TARGET_WILDCARD; ccb->ccb_h.target_lun = CAM_LUN_WILDCARD; @@ -1075,6 +1096,7 @@ ctlfedone(struct cam_periph *periph, uni switch (done_ccb->ccb_h.func_code) { case XPT_ACCEPT_TARGET_IO: { + LIST_REMOVE(&done_ccb->ccb_h, periph_links.le); atio = &done_ccb->atio; status = atio->ccb_h.status & CAM_STATUS_MASK; if (status != CAM_CDB_RECVD) { @@ -1364,6 +1386,7 @@ ctlfedone(struct cam_periph *periph, uni struct ccb_immediate_notify *inot; int send_ctl_io; + LIST_REMOVE(&done_ccb->ccb_h, periph_links.le); inot = &done_ccb->cin1; io = done_ccb->ccb_h.io_ptr; ctl_zero_io(io); From owner-svn-src-stable-11@freebsd.org Fri Mar 24 07:02:53 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3FC7ED1BB8D; Fri, 24 Mar 2017 07:02:53 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F11BD116B; Fri, 24 Mar 2017 07:02:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2O72qNH057208; Fri, 24 Mar 2017 07:02:52 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2O72q2H057207; Fri, 24 Mar 2017 07:02:52 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703240702.v2O72q2H057207@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 24 Mar 2017 07:02:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315890 - stable/11/sys/cam/ctl X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Mar 2017 07:02:53 -0000 Author: mav Date: Fri Mar 24 07:02:51 2017 New Revision: 315890 URL: https://svnweb.freebsd.org/changeset/base/315890 Log: MFC r315022: Request change of SIM target role only when it is different. Separate WWNs change into separate request to know what actually failed. Modified: stable/11/sys/cam/ctl/scsi_ctl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/ctl/scsi_ctl.c ============================================================================== --- stable/11/sys/cam/ctl/scsi_ctl.c Fri Mar 24 07:02:03 2017 (r315889) +++ stable/11/sys/cam/ctl/scsi_ctl.c Fri Mar 24 07:02:51 2017 (r315890) @@ -1503,18 +1503,14 @@ out: static void ctlfe_onoffline(void *arg, int online) { - struct ctlfe_softc *bus_softc; + struct ctlfe_softc *bus_softc = arg; union ccb *ccb; cam_status status; struct cam_path *path; - int set_wwnn; - - bus_softc = (struct ctlfe_softc *)arg; - - set_wwnn = 0; + int set_wwnn = 0; status = xpt_create_path(&path, /*periph*/ NULL, bus_softc->path_id, - CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD); + CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD); if (status != CAM_REQ_CMP) { printf("%s: unable to create path!\n", __func__); return; @@ -1524,21 +1520,9 @@ ctlfe_onoffline(void *arg, int online) ccb->ccb_h.func_code = XPT_GET_SIM_KNOB; xpt_action(ccb); - /* - * Copan WWN format: - * - * Bits 63-60: 0x5 NAA, IEEE registered name - * Bits 59-36: 0x000ED5 IEEE Company name assigned to Copan - * Bits 35-12: Copan SSN (Sequential Serial Number) - * Bits 11-8: Type of port: - * 1 == N-Port - * 2 == F-Port - * 3 == NL-Port - * Bits 7-0: 0 == Node Name, >0 == Port Number - */ + /* Check whether we should change WWNs. */ if (online != 0) { if ((ccb->knob.xport_specific.valid & KNOB_VALID_ADDRESS) != 0){ - printf("%s: %s current WWNN %#jx\n", __func__, bus_softc->port_name, ccb->knob.xport_specific.fc.wwnn); @@ -1571,43 +1555,59 @@ ctlfe_onoffline(void *arg, int online) false, 0, true, ccb->knob.xport_specific.fc.wwpn); } - - - if (set_wwnn != 0) { - printf("%s: %s new WWNN %#jx\n", __func__, - bus_softc->port_name, - ccb->knob.xport_specific.fc.wwnn); - printf("%s: %s new WWPN %#jx\n", __func__, - bus_softc->port_name, - ccb->knob.xport_specific.fc.wwpn); - } } else { printf("%s: %s has no valid WWNN/WWPN\n", __func__, bus_softc->port_name); + if (bus_softc->port.wwnn != 0) { + ccb->knob.xport_specific.fc.wwnn = + bus_softc->port.wwnn; + set_wwnn = 1; + } + if (bus_softc->port.wwpn != 0) { + ccb->knob.xport_specific.fc.wwpn = + bus_softc->port.wwpn; + set_wwnn = 1; + } + } + } + if (set_wwnn) { + ccb->ccb_h.func_code = XPT_SET_SIM_KNOB; + ccb->knob.xport_specific.valid = KNOB_VALID_ADDRESS; + xpt_action(ccb); + if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { + printf("%s: %s (path id %d) failed set WWNs: %#x\n", + __func__, bus_softc->port_name, bus_softc->path_id, + ccb->ccb_h.status); + } else { + printf("%s: %s new WWNN %#jx\n", __func__, + bus_softc->port_name, + ccb->knob.xport_specific.fc.wwnn); + printf("%s: %s new WWPN %#jx\n", __func__, + bus_softc->port_name, + ccb->knob.xport_specific.fc.wwpn); } } - ccb->ccb_h.func_code = XPT_SET_SIM_KNOB; - ccb->knob.xport_specific.valid = KNOB_VALID_ROLE; - if (set_wwnn != 0) - ccb->knob.xport_specific.valid |= KNOB_VALID_ADDRESS; - - if (online != 0) - ccb->knob.xport_specific.fc.role |= KNOB_ROLE_TARGET; - else - ccb->knob.xport_specific.fc.role &= ~KNOB_ROLE_TARGET; - - xpt_action(ccb); - if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { - printf("%s: SIM %s (path id %d) target %s failed with " - "status %#x\n", - __func__, bus_softc->port_name, bus_softc->path_id, - (online != 0) ? "enable" : "disable", - ccb->ccb_h.status); - } else { - printf("%s: SIM %s (path id %d) target %s succeeded\n", - __func__, bus_softc->port_name, bus_softc->path_id, - (online != 0) ? "enable" : "disable"); + /* Check whether we should change role. */ + if ((ccb->knob.xport_specific.valid & KNOB_VALID_ROLE) == 0 || + ((online != 0) ^ + ((ccb->knob.xport_specific.fc.role & KNOB_ROLE_TARGET) != 0)) != 0) { + ccb->ccb_h.func_code = XPT_SET_SIM_KNOB; + ccb->knob.xport_specific.valid = KNOB_VALID_ROLE; + if (online) + ccb->knob.xport_specific.fc.role |= KNOB_ROLE_TARGET; + else + ccb->knob.xport_specific.fc.role &= ~KNOB_ROLE_TARGET; + xpt_action(ccb); + if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { + printf("%s: %s (path id %d) failed %s target role: %#x\n", + __func__, bus_softc->port_name, bus_softc->path_id, + online ? "enable" : "disable", ccb->ccb_h.status); + } else { + printf("%s: %s (path id %d) target role %s succeeded\n", + __func__, bus_softc->port_name, bus_softc->path_id, + online ? "enable" : "disable"); + } } xpt_free_path(path); From owner-svn-src-stable-11@freebsd.org Fri Mar 24 07:14:48 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3DE97D1BF43; Fri, 24 Mar 2017 07:14:48 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0A70019DA; Fri, 24 Mar 2017 07:14:47 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2O7EljY061627; Fri, 24 Mar 2017 07:14:47 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2O7ElsD061626; Fri, 24 Mar 2017 07:14:47 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201703240714.v2O7ElsD061626@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 24 Mar 2017 07:14:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315893 - stable/11/sys/kern X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Mar 2017 07:14:48 -0000 Author: kib Date: Fri Mar 24 07:14:46 2017 New Revision: 315893 URL: https://svnweb.freebsd.org/changeset/base/315893 Log: MFC r315453: When clearing altsigstack settings on exec, do it to the right thread. Modified: stable/11/sys/kern/kern_sig.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_sig.c ============================================================================== --- stable/11/sys/kern/kern_sig.c Fri Mar 24 07:09:33 2017 (r315892) +++ stable/11/sys/kern/kern_sig.c Fri Mar 24 07:14:46 2017 (r315893) @@ -963,7 +963,6 @@ execsigs(struct proc *p) * and are now ignored by default). */ PROC_LOCK_ASSERT(p, MA_OWNED); - td = FIRST_THREAD_IN_PROC(p); ps = p->p_sigacts; mtx_lock(&ps->ps_mtx); while (SIGNOTEMPTY(ps->ps_sigcatch)) { @@ -994,6 +993,8 @@ execsigs(struct proc *p) * Reset stack state to the user stack. * Clear set of signals caught on the signal stack. */ + td = curthread; + MPASS(td->td_proc == p); td->td_sigstk.ss_flags = SS_DISABLE; td->td_sigstk.ss_size = 0; td->td_sigstk.ss_sp = 0; From owner-svn-src-stable-11@freebsd.org Fri Mar 24 08:06:01 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 82E89D1BC4A; Fri, 24 Mar 2017 08:06:01 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 521A61452; Fri, 24 Mar 2017 08:06:01 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2O860l5081819; Fri, 24 Mar 2017 08:06:00 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2O860Mp081818; Fri, 24 Mar 2017 08:06:00 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201703240806.v2O860Mp081818@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Fri, 24 Mar 2017 08:06:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315895 - stable/11/sys/sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Mar 2017 08:06:01 -0000 Author: mjg Date: Fri Mar 24 08:06:00 2017 New Revision: 315895 URL: https://svnweb.freebsd.org/changeset/base/315895 Log: MFC r305383: fd: fix up fdeget_file It was supposed to return NULL if a fp is not installed. Modified: stable/11/sys/sys/filedesc.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/sys/filedesc.h ============================================================================== --- stable/11/sys/sys/filedesc.h Fri Mar 24 07:22:32 2017 (r315894) +++ stable/11/sys/sys/filedesc.h Fri Mar 24 08:06:00 2017 (r315895) @@ -215,13 +215,18 @@ fget_locked(struct filedesc *fdp, int fd static __inline struct filedescent * fdeget_locked(struct filedesc *fdp, int fd) { + struct filedescent *fde; FILEDESC_LOCK_ASSERT(fdp); if ((u_int)fd > fdp->fd_lastfile) return (NULL); - return (&fdp->fd_ofiles[fd]); + fde = &fdp->fd_ofiles[fd]; + if (fde->fde_file == NULL) + return (NULL); + + return (fde); } static __inline bool From owner-svn-src-stable-11@freebsd.org Fri Mar 24 14:19:54 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BF20CD1B787; Fri, 24 Mar 2017 14:19:54 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 816751BB1; Fri, 24 Mar 2017 14:19:54 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2OEJrrW031968; Fri, 24 Mar 2017 14:19:53 GMT (envelope-from des@FreeBSD.org) Received: (from des@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2OEJrqY031963; Fri, 24 Mar 2017 14:19:53 GMT (envelope-from des@FreeBSD.org) Message-Id: <201703241419.v2OEJrqY031963@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: des set sender to des@FreeBSD.org using -f From: =?UTF-8?Q?Dag-Erling_Sm=c3=b8rgrav?= Date: Fri, 24 Mar 2017 14:19:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315902 - stable/11/lib/libfetch X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Mar 2017 14:19:54 -0000 Author: des Date: Fri Mar 24 14:19:52 2017 New Revision: 315902 URL: https://svnweb.freebsd.org/changeset/base/315902 Log: MFH (r313974,r314596): open .netrc early in case we want to drop privs MFH (r314396,r315143): fix a crash caused by an incorrect format string MFH (r314701): fix handling of 416 errors when requesting a range MFH (r315455): fix parsing of IP literals (square brackets) PR: 212065, 217723 Modified: stable/11/lib/libfetch/common.c stable/11/lib/libfetch/common.h stable/11/lib/libfetch/fetch.c stable/11/lib/libfetch/fetch.h stable/11/lib/libfetch/http.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libfetch/common.c ============================================================================== --- stable/11/lib/libfetch/common.c Fri Mar 24 13:46:26 2017 (r315901) +++ stable/11/lib/libfetch/common.c Fri Mar 24 14:19:52 2017 (r315902) @@ -153,7 +153,7 @@ fetch_syserr(void) case EHOSTDOWN: fetchLastErrCode = FETCH_DOWN; break; -default: + default: fetchLastErrCode = FETCH_UNKNOWN; } snprintf(fetchLastErrString, MAXERRSTRING, "%s", strerror(errno)); @@ -248,37 +248,51 @@ fetch_resolve(const char *addr, int port { char hbuf[256], sbuf[8]; struct addrinfo hints, *res; - const char *sep, *host, *service; + const char *hb, *he, *sep; + const char *host, *service; int err, len; - /* split address if necessary */ - err = EAI_SYSTEM; - if ((sep = strchr(addr, ':')) != NULL) { + /* first, check for a bracketed IPv6 address */ + if (*addr == '[') { + hb = addr + 1; + if ((sep = strchr(hb, ']')) == NULL) { + errno = EINVAL; + goto syserr; + } + he = sep++; + } else { + hb = addr; + sep = strchrnul(hb, ':'); + he = sep; + } + + /* see if we need to copy the host name */ + if (*he != '\0') { len = snprintf(hbuf, sizeof(hbuf), - "%.*s", (int)(sep - addr), addr); + "%.*s", (int)(he - hb), hb); if (len < 0) - return (NULL); + goto syserr; if (len >= (int)sizeof(hbuf)) { errno = ENAMETOOLONG; - fetch_syserr(); - return (NULL); + goto syserr; } host = hbuf; - service = sep + 1; - } else if (port != 0) { + } else { + host = hb; + } + + /* was it followed by a service name? */ + if (*sep == '\0' && port != 0) { if (port < 1 || port > 65535) { errno = EINVAL; - fetch_syserr(); - return (NULL); - } - if (snprintf(sbuf, sizeof(sbuf), "%d", port) < 0) { - fetch_syserr(); - return (NULL); + goto syserr; } - host = addr; + if (snprintf(sbuf, sizeof(sbuf), "%d", port) < 0) + goto syserr; service = sbuf; + } else if (*sep != '\0') { + service = sep; } else { - host = addr; service = NULL; } @@ -292,6 +306,9 @@ fetch_resolve(const char *addr, int port return (NULL); } return (res); +syserr: + fetch_syserr(); + return (NULL); } @@ -371,7 +388,7 @@ fetch_connect(const char *host, int port } if (err != 0) { if (verbose) - fetch_info("failed to connect to %s:%s", host, port); + fetch_info("failed to connect to %s:%d", host, port); goto syserr; } @@ -1339,16 +1356,11 @@ fetch_read_word(FILE *f) return (word); } -/* - * Get authentication data for a URL from .netrc - */ -int -fetch_netrc_auth(struct url *url) +static int +fetch_netrc_open(void) { + const char *p; char fn[PATH_MAX]; - const char *word; - char *p; - FILE *f; if ((p = getenv("NETRC")) != NULL) { if (snprintf(fn, sizeof(fn), "%s", p) >= (int)sizeof(fn)) { @@ -1368,8 +1380,25 @@ fetch_netrc_auth(struct url *url) return (-1); } - if ((f = fopen(fn, "r")) == NULL) + return (open(fn, O_RDONLY)); +} + +/* + * Get authentication data for a URL from .netrc + */ +int +fetch_netrc_auth(struct url *url) +{ + const char *word; + FILE *f; + + if (url->netrcfd == -2) + url->netrcfd = fetch_netrc_open(); + if (url->netrcfd < 0) + return (-1); + if ((f = fdopen(url->netrcfd, "r")) == NULL) return (-1); + rewind(f); while ((word = fetch_read_word(f)) != NULL) { if (strcmp(word, "default") == 0) { DEBUG(fetch_info("Using default .netrc settings")); Modified: stable/11/lib/libfetch/common.h ============================================================================== --- stable/11/lib/libfetch/common.h Fri Mar 24 13:46:26 2017 (r315901) +++ stable/11/lib/libfetch/common.h Fri Mar 24 14:19:52 2017 (r315902) @@ -73,7 +73,7 @@ struct iovec; void fetch_seterr(struct fetcherr *, int); void fetch_syserr(void); -void fetch_info(const char *, ...); +void fetch_info(const char *, ...) __printflike(1, 2); int fetch_default_port(const char *); int fetch_default_proxy_port(const char *); struct addrinfo *fetch_resolve(const char *, int, int); Modified: stable/11/lib/libfetch/fetch.c ============================================================================== --- stable/11/lib/libfetch/fetch.c Fri Mar 24 13:46:26 2017 (r315901) +++ stable/11/lib/libfetch/fetch.c Fri Mar 24 14:19:52 2017 (r315902) @@ -284,6 +284,7 @@ fetchMakeURL(const char *scheme, const c seturl(pwd); #undef seturl u->port = port; + u->netrcfd = -2; return (u); } @@ -349,6 +350,7 @@ fetchParseURL(const char *URL) fetch_syserr(); return (NULL); } + u->netrcfd = -2; /* scheme name */ if ((p = strstr(URL, ":/"))) { @@ -384,18 +386,17 @@ fetchParseURL(const char *URL) } /* hostname */ -#ifdef INET6 if (*p == '[' && (q = strchr(p + 1, ']')) != NULL && (*++q == '\0' || *q == '/' || *q == ':')) { - if ((i = q - p - 2) > MAXHOSTNAMELEN) + if ((i = q - p) > MAXHOSTNAMELEN) i = MAXHOSTNAMELEN; - strncpy(u->host, ++p, i); + strncpy(u->host, p, i); p = q; - } else -#endif + } else { for (i = 0; *p && (*p != '/') && (*p != ':'); p++) if (i < MAXHOSTNAMELEN) u->host[i++] = *p; + } /* port */ if (*p == ':') { @@ -442,12 +443,12 @@ nohost: } DEBUG(fprintf(stderr, - "scheme: [%s]\n" - "user: [%s]\n" - "password: [%s]\n" - "host: [%s]\n" - "port: [%d]\n" - "document: [%s]\n", + "scheme: \"%s\"\n" + "user: \"%s\"\n" + "password: \"%s\"\n" + "host: \"%s\"\n" + "port: \"%d\"\n" + "document: \"%s\"\n", u->scheme, u->user, u->pwd, u->host, u->port, u->doc)); Modified: stable/11/lib/libfetch/fetch.h ============================================================================== --- stable/11/lib/libfetch/fetch.h Fri Mar 24 13:46:26 2017 (r315901) +++ stable/11/lib/libfetch/fetch.h Fri Mar 24 14:19:52 2017 (r315902) @@ -47,6 +47,7 @@ struct url { off_t offset; size_t length; time_t ims_time; + int netrcfd; }; struct url_stat { Modified: stable/11/lib/libfetch/http.c ============================================================================== --- stable/11/lib/libfetch/http.c Fri Mar 24 13:46:26 2017 (r315901) +++ stable/11/lib/libfetch/http.c Fri Mar 24 14:19:52 2017 (r315902) @@ -118,7 +118,7 @@ __FBSDID("$FreeBSD$"); || (xyz) == HTTP_USE_PROXY \ || (xyz) == HTTP_SEE_OTHER) -#define HTTP_ERROR(xyz) ((xyz) > 400 && (xyz) < 599) +#define HTTP_ERROR(xyz) ((xyz) >= 400 && (xyz) <= 599) /***************************************************************************** @@ -1604,20 +1604,11 @@ http_request_body(struct url *URL, const if ((conn = http_connect(url, purl, flags)) == NULL) goto ouch; + /* append port number only if necessary */ host = url->host; -#ifdef INET6 - if (strchr(url->host, ':')) { - snprintf(hbuf, sizeof(hbuf), "[%s]", url->host); - host = hbuf; - } -#endif if (url->port != fetch_default_port(url->scheme)) { - if (host != hbuf) { - strcpy(hbuf, host); - host = hbuf; - } - snprintf(hbuf + strlen(hbuf), - sizeof(hbuf) - strlen(hbuf), ":%d", url->port); + snprintf(hbuf, sizeof(hbuf), "%s:%d", host, url->port); + host = hbuf; } /* send request */ @@ -1925,7 +1916,7 @@ http_request_body(struct url *URL, const /* requested range not satisfiable */ if (conn->err == HTTP_BAD_RANGE) { - if (url->offset == size && url->length == 0) { + if (url->offset > 0 && url->length == 0) { /* asked for 0 bytes; fake it */ offset = url->offset; clength = -1; From owner-svn-src-stable-11@freebsd.org Fri Mar 24 14:39:02 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 74275D1BF0F; Fri, 24 Mar 2017 14:39:02 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 23C9CD3B; Fri, 24 Mar 2017 14:39:02 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2OEd1Rq039963; Fri, 24 Mar 2017 14:39:01 GMT (envelope-from des@FreeBSD.org) Received: (from des@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2OEd1kK039961; Fri, 24 Mar 2017 14:39:01 GMT (envelope-from des@FreeBSD.org) Message-Id: <201703241439.v2OEd1kK039961@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: des set sender to des@FreeBSD.org using -f From: =?UTF-8?Q?Dag-Erling_Sm=c3=b8rgrav?= Date: Fri, 24 Mar 2017 14:39:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315906 - stable/11/contrib/openpam/lib/libpam X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Mar 2017 14:39:02 -0000 Author: des Date: Fri Mar 24 14:39:00 2017 New Revision: 315906 URL: https://svnweb.freebsd.org/changeset/base/315906 Log: Subset of upstream r902 which fixes custom prompts. PR: 216172 Modified: stable/11/contrib/openpam/lib/libpam/pam_get_authtok.c stable/11/contrib/openpam/lib/libpam/pam_get_user.c Modified: stable/11/contrib/openpam/lib/libpam/pam_get_authtok.c ============================================================================== --- stable/11/contrib/openpam/lib/libpam/pam_get_authtok.c Fri Mar 24 14:27:29 2017 (r315905) +++ stable/11/contrib/openpam/lib/libpam/pam_get_authtok.c Fri Mar 24 14:39:00 2017 (r315906) @@ -122,9 +122,11 @@ pam_get_authtok(pam_handle_t *pamh, if ((promptp = openpam_get_option(pamh, prompt_option)) != NULL) prompt = promptp; /* no prompt provided, see if there is one tucked away somewhere */ - if (prompt == NULL) - if (pam_get_item(pamh, pitem, &promptp) && promptp != NULL) + if (prompt == NULL) { + r = pam_get_item(pamh, pitem, &promptp); + if (r == PAM_SUCCESS && promptp != NULL) prompt = promptp; + } /* fall back to hardcoded default */ if (prompt == NULL) prompt = default_prompt; Modified: stable/11/contrib/openpam/lib/libpam/pam_get_user.c ============================================================================== --- stable/11/contrib/openpam/lib/libpam/pam_get_user.c Fri Mar 24 14:27:29 2017 (r315905) +++ stable/11/contrib/openpam/lib/libpam/pam_get_user.c Fri Mar 24 14:39:00 2017 (r315906) @@ -78,10 +78,11 @@ pam_get_user(pam_handle_t *pamh, if ((promptp = openpam_get_option(pamh, "user_prompt")) != NULL) prompt = promptp; /* no prompt provided, see if there is one tucked away somewhere */ - if (prompt == NULL) - if (pam_get_item(pamh, PAM_USER_PROMPT, &promptp) && - promptp != NULL) + if (prompt == NULL) { + r = pam_get_item(pamh, PAM_USER_PROMPT, &promptp); + if (r == PAM_SUCCESS && promptp != NULL) prompt = promptp; + } /* fall back to hardcoded default */ if (prompt == NULL) prompt = user_prompt; From owner-svn-src-stable-11@freebsd.org Sat Mar 25 00:52:34 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CC72BD1B12E; Sat, 25 Mar 2017 00:52:34 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8A95E143F; Sat, 25 Mar 2017 00:52:34 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2P0qXI5092822; Sat, 25 Mar 2017 00:52:33 GMT (envelope-from vangyzen@FreeBSD.org) Received: (from vangyzen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2P0qXDR092821; Sat, 25 Mar 2017 00:52:33 GMT (envelope-from vangyzen@FreeBSD.org) Message-Id: <201703250052.v2P0qXDR092821@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vangyzen set sender to vangyzen@FreeBSD.org using -f From: Eric van Gyzen Date: Sat, 25 Mar 2017 00:52:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315919 - stable/11/lib/libc/sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Mar 2017 00:52:34 -0000 Author: vangyzen Date: Sat Mar 25 00:52:33 2017 New Revision: 315919 URL: https://svnweb.freebsd.org/changeset/base/315919 Log: MFC r315694 clock_gettime.2: add some clock IDs Add the CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID clock_id values to the clock_gettime(2) man page. Reformat the excessively long paragraph (sentence!) into a tag list. Sponsored by: Dell EMC Modified: stable/11/lib/libc/sys/clock_gettime.2 Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/sys/clock_gettime.2 ============================================================================== --- stable/11/lib/libc/sys/clock_gettime.2 Fri Mar 24 22:33:03 2017 (r315918) +++ stable/11/lib/libc/sys/clock_gettime.2 Sat Mar 25 00:52:33 2017 (r315919) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 27, 2015 +.Dd March 20, 2017 .Dt CLOCK_GETTIME 2 .Os .Sh NAME @@ -58,31 +58,39 @@ used by a clock which is specified by .Pp The .Fa clock_id -argument -can be one of the following values: -.Dv CLOCK_REALTIME , -.Dv CLOCK_REALTIME_PRECISE , -.Dv CLOCK_REALTIME_FAST -for time that increments as -a wall clock should; -.Dv CLOCK_MONOTONIC , -.Dv CLOCK_MONOTONIC_PRECISE , -.Dv CLOCK_MONOTONIC_FAST -which increments in SI seconds; -.Dv CLOCK_UPTIME , -.Dv CLOCK_UPTIME_PRECISE , -.Dv CLOCK_UPTIME_FAST -which starts at zero when the kernel boots and increments -monotonically in SI seconds while the machine is running; -.Dv CLOCK_VIRTUAL -for time that increments only when -the CPU is running in user mode on behalf of the calling process; -.Dv CLOCK_PROF -for time that increments when the CPU is running in user or -kernel mode; or -.Dv CLOCK_SECOND -which returns the current second without performing a full time counter -query, using in-kernel cached value of current second. +argument can be a value obtained from +.Xr clock_getcpuclockid 3 +or +.Xr pthread_getcpuclockid 3 +as well as the following values: +.Pp +.Bl -tag -width indent -compact +.It Dv CLOCK_REALTIME +.It Dv CLOCK_REALTIME_PRECISE +.It Dv CLOCK_REALTIME_FAST +Increments as a wall clock should. +.It Dv CLOCK_MONOTONIC +.It Dv CLOCK_MONOTONIC_PRECISE +.It Dv CLOCK_MONOTONIC_FAST +Increments in SI seconds. +.It Dv CLOCK_UPTIME +.It Dv CLOCK_UPTIME_PRECISE +.It Dv CLOCK_UPTIME_FAST +Starts at zero when the kernel boots and increments +monotonically in SI seconds while the machine is running. +.It Dv CLOCK_VIRTUAL +Increments only when +the CPU is running in user mode on behalf of the calling process. +.It Dv CLOCK_PROF +Increments when the CPU is running in user or kernel mode. +.It Dv CLOCK_SECOND +Returns the current second without performing a full time counter +query, using an in-kernel cached value of the current second. +.It Dv CLOCK_PROCESS_CPUTIME_ID +Returns the execution time of the calling process. +.It Dv CLOCK_THREAD_CPUTIME_ID +Returns the execution time of the calling thread. +.El .Pp The clock IDs .Fa CLOCK_REALTIME_FAST , @@ -144,7 +152,9 @@ A user other than the super-user attempt .Sh SEE ALSO .Xr date 1 , .Xr adjtime 2 , +.Xr clock_getcpuclockid 3 , .Xr ctime 3 , +.Xr pthread_getcpuclockid 3 , .Xr timed 8 .Sh STANDARDS The From owner-svn-src-stable-11@freebsd.org Sat Mar 25 05:05:14 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 41AD6D1D495; Sat, 25 Mar 2017 05:05:14 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EA5AA181C; Sat, 25 Mar 2017 05:05:13 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2P55Dpo099046; Sat, 25 Mar 2017 05:05:13 GMT (envelope-from grehan@FreeBSD.org) Received: (from grehan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2P55Cx1099042; Sat, 25 Mar 2017 05:05:12 GMT (envelope-from grehan@FreeBSD.org) Message-Id: <201703250505.v2P55Cx1099042@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: grehan set sender to grehan@FreeBSD.org using -f From: Peter Grehan Date: Sat, 25 Mar 2017 05:05:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315927 - in stable/11/sys: amd64/vmm x86/include x86/x86 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Mar 2017 05:05:14 -0000 Author: grehan Date: Sat Mar 25 05:05:12 2017 New Revision: 315927 URL: https://svnweb.freebsd.org/changeset/base/315927 Log: MFC r315361 and r315364: Hide MONITORX/MWAITX from guests. r315361 Add the AMD MONITORX/MWAITX feature definition introduced in Bulldozer/Ryzen CPUs. r315364 Hide the AMD MONITORX/MWAITX capability. Otherwise, recent Linux guests will use these instructions, resulting in #UD exceptions since bhyve doesn't implement MONITOR/MWAIT exits. This fixes boot-time hangs in recent Linux guests on Ryzen CPUs (and probably Bulldozer aka AMD FX as well). Modified: stable/11/sys/amd64/vmm/x86.c stable/11/sys/x86/include/specialreg.h stable/11/sys/x86/x86/identcpu.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/vmm/x86.c ============================================================================== --- stable/11/sys/amd64/vmm/x86.c Sat Mar 25 02:55:13 2017 (r315926) +++ stable/11/sys/amd64/vmm/x86.c Sat Mar 25 05:05:12 2017 (r315927) @@ -176,6 +176,9 @@ x86_emulate_cpuid(struct vm *vm, int vcp /* Don't advertise the OS visible workaround feature */ regs[2] &= ~AMDID2_OSVW; + /* Hide mwaitx/monitorx capability from the guest */ + regs[2] &= ~AMDID2_MWAITX; + /* * Hide rdtscp/ia32_tsc_aux until we know how * to deal with them. Modified: stable/11/sys/x86/include/specialreg.h ============================================================================== --- stable/11/sys/x86/include/specialreg.h Sat Mar 25 02:55:13 2017 (r315926) +++ stable/11/sys/x86/include/specialreg.h Sat Mar 25 05:05:12 2017 (r315927) @@ -227,6 +227,7 @@ #define AMDID2_DBE 0x04000000 #define AMDID2_PTSC 0x08000000 #define AMDID2_PTSCEL2I 0x10000000 +#define AMDID2_MWAITX 0x20000000 /* * CPUID instruction 1 eax info Modified: stable/11/sys/x86/x86/identcpu.c ============================================================================== --- stable/11/sys/x86/x86/identcpu.c Sat Mar 25 02:55:13 2017 (r315926) +++ stable/11/sys/x86/x86/identcpu.c Sat Mar 25 05:05:12 2017 (r315927) @@ -906,7 +906,7 @@ printcpuinfo(void) "\033DBE" /* Data Breakpoint extension */ "\034PTSC" /* Performance TSC */ "\035PL2I" /* L2I perf count */ - "\036" + "\036MWAITX" /* MONITORX/MWAITX instructions */ "\037" "\040" ); From owner-svn-src-stable-11@freebsd.org Sat Mar 25 05:21:50 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8341DD1D9C1; Sat, 25 Mar 2017 05:21:50 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 527AB7D; Sat, 25 Mar 2017 05:21:50 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2P5LniH007225; Sat, 25 Mar 2017 05:21:49 GMT (envelope-from grehan@FreeBSD.org) Received: (from grehan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2P5LnO9007224; Sat, 25 Mar 2017 05:21:49 GMT (envelope-from grehan@FreeBSD.org) Message-Id: <201703250521.v2P5LnO9007224@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: grehan set sender to grehan@FreeBSD.org using -f From: Peter Grehan Date: Sat, 25 Mar 2017 05:21:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315929 - stable/11/usr.sbin/bhyve X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Mar 2017 05:21:50 -0000 Author: grehan Date: Sat Mar 25 05:21:49 2017 New Revision: 315929 URL: https://svnweb.freebsd.org/changeset/base/315929 Log: MFC r315715 Fix a type in bhyve's USB mouse emulation. Modified: stable/11/usr.sbin/bhyve/usb_mouse.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/bhyve/usb_mouse.c ============================================================================== --- stable/11/usr.sbin/bhyve/usb_mouse.c Sat Mar 25 05:09:03 2017 (r315928) +++ stable/11/usr.sbin/bhyve/usb_mouse.c Sat Mar 25 05:21:49 2017 (r315929) @@ -284,7 +284,7 @@ umouse_event(uint8_t button, int x, int /* scale coords to mouse resolution */ sc->um_report.x = MOUSE_MAX_X * x / gc->width; - sc->um_report.y = MOUSE_MAX_X * y / gc->height; + sc->um_report.y = MOUSE_MAX_Y * y / gc->height; sc->newdata = 1; pthread_mutex_unlock(&sc->mtx); From owner-svn-src-stable-11@freebsd.org Sat Mar 25 05:41:36 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2BEDFD1DC39; Sat, 25 Mar 2017 05:41:36 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EC80AAB9; Sat, 25 Mar 2017 05:41:35 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2P5fZxC012089; Sat, 25 Mar 2017 05:41:35 GMT (envelope-from grehan@FreeBSD.org) Received: (from grehan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2P5fZAT012088; Sat, 25 Mar 2017 05:41:35 GMT (envelope-from grehan@FreeBSD.org) Message-Id: <201703250541.v2P5fZAT012088@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: grehan set sender to grehan@FreeBSD.org using -f From: Peter Grehan Date: Sat, 25 Mar 2017 05:41:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315930 - stable/11/sys/dev/usb/input X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Mar 2017 05:41:36 -0000 Author: grehan Date: Sat Mar 25 05:41:34 2017 New Revision: 315930 URL: https://svnweb.freebsd.org/changeset/base/315930 Log: MFC r315716 Bring the handling of the y axis in the ums driver in-line with the other axes. No functional change. Modified: stable/11/sys/dev/usb/input/ums.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/usb/input/ums.c ============================================================================== --- stable/11/sys/dev/usb/input/ums.c Sat Mar 25 05:21:49 2017 (r315929) +++ stable/11/sys/dev/usb/input/ums.c Sat Mar 25 05:41:34 2017 (r315930) @@ -283,7 +283,7 @@ ums_intr_callback(struct usb_xfer *xfer, if ((info->sc_flags & UMS_FLAG_Y_AXIS) && (id == info->sc_iid_y)) - dy = -hid_get_data(buf, len, &info->sc_loc_y); + dy -= hid_get_data(buf, len, &info->sc_loc_y); if ((info->sc_flags & UMS_FLAG_Z_AXIS) && (id == info->sc_iid_z)) { From owner-svn-src-stable-11@freebsd.org Sat Mar 25 11:35:33 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 32A36D1B8CE; Sat, 25 Mar 2017 11:35:33 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D289A18D6; Sat, 25 Mar 2017 11:35:32 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2PBZV2D055253; Sat, 25 Mar 2017 11:35:31 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2PBZVn5055252; Sat, 25 Mar 2017 11:35:31 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703251135.v2PBZVn5055252@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 25 Mar 2017 11:35:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315936 - stable/11/sys/cam X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Mar 2017 11:35:33 -0000 Author: mav Date: Sat Mar 25 11:35:31 2017 New Revision: 315936 URL: https://svnweb.freebsd.org/changeset/base/315936 Log: MFC r315082: Allow XPT_GDEV_STATS for UNCONFIGURED devices. Queue statistics has nothing to do with presence or absence of INQUIRY data, etc. Target mode devices are never configured, but have queues. Modified: stable/11/sys/cam/cam_xpt.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/cam_xpt.c ============================================================================== --- stable/11/sys/cam/cam_xpt.c Sat Mar 25 10:47:58 2017 (r315935) +++ stable/11/sys/cam/cam_xpt.c Sat Mar 25 11:35:31 2017 (r315936) @@ -2688,36 +2688,25 @@ call_sim: } case XPT_GDEV_STATS: { - struct cam_ed *dev; + struct ccb_getdevstats *cgds = &start_ccb->cgds; + struct cam_ed *dev = path->device; + struct cam_eb *bus = path->bus; + struct cam_et *tar = path->target; + struct cam_devq *devq = bus->sim->devq; - dev = path->device; - if ((dev->flags & CAM_DEV_UNCONFIGURED) != 0) { - start_ccb->ccb_h.status = CAM_DEV_NOT_THERE; - } else { - struct ccb_getdevstats *cgds; - struct cam_eb *bus; - struct cam_et *tar; - struct cam_devq *devq; - - cgds = &start_ccb->cgds; - bus = path->bus; - tar = path->target; - devq = bus->sim->devq; - mtx_lock(&devq->send_mtx); - cgds->dev_openings = dev->ccbq.dev_openings; - cgds->dev_active = dev->ccbq.dev_active; - cgds->allocated = dev->ccbq.allocated; - cgds->queued = cam_ccbq_pending_ccb_count(&dev->ccbq); - cgds->held = cgds->allocated - cgds->dev_active - - cgds->queued; - cgds->last_reset = tar->last_reset; - cgds->maxtags = dev->maxtags; - cgds->mintags = dev->mintags; - if (timevalcmp(&tar->last_reset, &bus->last_reset, <)) - cgds->last_reset = bus->last_reset; - mtx_unlock(&devq->send_mtx); - cgds->ccb_h.status = CAM_REQ_CMP; - } + mtx_lock(&devq->send_mtx); + cgds->dev_openings = dev->ccbq.dev_openings; + cgds->dev_active = dev->ccbq.dev_active; + cgds->allocated = dev->ccbq.allocated; + cgds->queued = cam_ccbq_pending_ccb_count(&dev->ccbq); + cgds->held = cgds->allocated - cgds->dev_active - cgds->queued; + cgds->last_reset = tar->last_reset; + cgds->maxtags = dev->maxtags; + cgds->mintags = dev->mintags; + if (timevalcmp(&tar->last_reset, &bus->last_reset, <)) + cgds->last_reset = bus->last_reset; + mtx_unlock(&devq->send_mtx); + cgds->ccb_h.status = CAM_REQ_CMP; break; } case XPT_GDEVLIST: From owner-svn-src-stable-11@freebsd.org Sat Mar 25 11:44:36 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 460E2D1BBB9; Sat, 25 Mar 2017 11:44:36 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EEB8F1E4A; Sat, 25 Mar 2017 11:44:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2PBiZdT059255; Sat, 25 Mar 2017 11:44:35 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2PBiZHH059254; Sat, 25 Mar 2017 11:44:35 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703251144.v2PBiZHH059254@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 25 Mar 2017 11:44:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315938 - stable/11/sys/cam/ctl X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Mar 2017 11:44:36 -0000 Author: mav Date: Sat Mar 25 11:44:34 2017 New Revision: 315938 URL: https://svnweb.freebsd.org/changeset/base/315938 Log: MFC r315084: Increase device openings to tagged maximum. Some SIMs report much less untagged device openings then tagged ones. Target mode devices are not handled by regular probing routines, and so there is nothing to increase queue size for them to the SIM's maximum. To fix that resize the queue explicitly on ctl periph registration. This radically improves performance of mpt(4) in target mode. Also fetch and report device queue statistics in `ctladm dumpstructs`, since regular way of `camcontrol tags` is not usable in target mode. Modified: stable/11/sys/cam/ctl/scsi_ctl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/ctl/scsi_ctl.c ============================================================================== --- stable/11/sys/cam/ctl/scsi_ctl.c Sat Mar 25 11:36:06 2017 (r315937) +++ stable/11/sys/cam/ctl/scsi_ctl.c Sat Mar 25 11:44:34 2017 (r315938) @@ -457,6 +457,16 @@ ctlferegister(struct cam_periph *periph, softc->periph = periph; periph->softc = softc; + /* Increase device openings to maximum for the SIM. */ + if (bus_softc->sim->max_tagged_dev_openings > + bus_softc->sim->max_dev_openings) { + cam_release_devq(periph->path, + /*relsim_flags*/RELSIM_ADJUST_OPENINGS, + /*openings*/bus_softc->sim->max_tagged_dev_openings, + /*timeout*/0, + /*getcount_only*/1); + } + xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NONE); ccb.ccb_h.func_code = XPT_EN_LUN; ccb.cel.grp6_len = 0; @@ -1816,9 +1826,9 @@ static void ctlfe_dump_sim(struct cam_sim *sim) { - printf("%s%d: max tagged openings: %d, max dev openings: %d\n", - sim->sim_name, sim->unit_number, - sim->max_tagged_dev_openings, sim->max_dev_openings); + printf("%s%d: max dev openings: %d, max tagged dev openings: %d\n", + sim->sim_name, sim->unit_number, sim->max_dev_openings, + sim->max_tagged_dev_openings); } /* @@ -1827,11 +1837,21 @@ ctlfe_dump_sim(struct cam_sim *sim) static void ctlfe_dump_queue(struct ctlfe_lun_softc *softc) { + struct cam_periph *periph = softc->periph; struct ccb_hdr *hdr; - struct cam_periph *periph; + struct ccb_getdevstats cgds; int num_items; - periph = softc->periph; + xpt_setup_ccb(&cgds.ccb_h, periph->path, CAM_PRIORITY_NORMAL); + cgds.ccb_h.func_code = XPT_GDEV_STATS; + xpt_action((union ccb *)&cgds); + if ((cgds.ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { + xpt_print(periph->path, "devq: openings %d, active %d, " + "allocated %d, queued %d, held %d\n", + cgds.dev_openings, cgds.dev_active, cgds.allocated, + cgds.queued, cgds.held); + } + num_items = 0; STAILQ_FOREACH(hdr, &softc->work_queue, periph_links.stqe) { From owner-svn-src-stable-11@freebsd.org Sat Mar 25 11:47:24 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B9BC9D1BD4B; Sat, 25 Mar 2017 11:47:24 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 91C001230; Sat, 25 Mar 2017 11:47:24 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2PBlNx2059673; Sat, 25 Mar 2017 11:47:23 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2PBlNFP059672; Sat, 25 Mar 2017 11:47:23 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703251147.v2PBlNFP059672@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 25 Mar 2017 11:47:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315940 - stable/11/share/man/man4 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Mar 2017 11:47:24 -0000 Author: mav Date: Sat Mar 25 11:47:23 2017 New Revision: 315940 URL: https://svnweb.freebsd.org/changeset/base/315940 Log: MFC r315087, r315146: Improve ctl(4) description, including frontends and backends. Modified: stable/11/share/man/man4/ctl.4 Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man4/ctl.4 ============================================================================== --- stable/11/share/man/man4/ctl.4 Sat Mar 25 11:45:19 2017 (r315939) +++ stable/11/share/man/man4/ctl.4 Sat Mar 25 11:47:23 2017 (r315940) @@ -1,5 +1,5 @@ .\" Copyright (c) 2013 Edward Tomasz Napierala -.\" Copyright (c) 2015 Alexander Motin +.\" Copyright (c) 2015-2017 Alexander Motin .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -24,12 +24,12 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd January 19, 2017 +.Dd March 11, 2017 .Dt CTL 4 .Os .Sh NAME .Nm ctl -.Nd CAM Target Layer / iSCSI target +.Nd CAM Target Layer / SCSI target subsystem .Sh SYNOPSIS To compile this driver into the kernel, place the following line in your @@ -48,12 +48,12 @@ ctl_load="YES" .Sh DESCRIPTION The .Nm -subsystem provides SCSI disk and processor emulation. +subsystem provides SCSI target devices emulation. It supports features such as: .Pp .Bl -bullet -compact .It -Disk, processor and cdrom device emulation +Disk, CD-ROM and processor device emulation .It Tagged queueing .It @@ -61,32 +61,73 @@ SCSI task attribute support (ordered, he .It SCSI implicit command ordering support .It -Full task management support (abort, LUN reset, target reset, etc.) +Full task management support (abort, query, reset, etc.) .It -Support for multiple ports +Support for multiple ports, initiators, targets and backing stores .It -Support for multiple simultaneous initiators -.It -Support for multiple simultaneous backing stores -.It -Support for VMWare VAAI: COMPARE AND WRITE, XCOPY, WRITE SAME, -and UNMAP commands -.It -Support for Microsoft ODX: POPULATE TOKEN/WRITE USING TOKEN, -WRITE SAME, and UNMAP commands +Support for VMWare VAAI and Microsoft ODX offload (COMPARE AND WRITE, +XCOPY, POPULATE TOKEN/WRITE USING TOKEN, WRITE SAME and UNMAP) .It Persistent reservation support .It -Mode sense/select support +Extensive VPD/mode/log pages support .It -Error injection support +Featured error reporting, error injection and basic SMART support .It High Availability clustering support with ALUA .It All I/O handled in-kernel, no userland context switch overhead .El .Pp -It also serves as a kernel component of the native iSCSI target. +The +.Nm +subsystem includes multiple frontends to provide access using different +transport protocols and implementations: +.Bl -tag -width cfumass +.It camsim +Provides access for local system via virtual initiator mode +.Xr CAM 4 +SIM. +.It camtgt +Provides access for remote systems via target mode +.Xr CAM 4 +SIMs, such as Fibre Channel +.Xr isp 4 +and +.Xr mpt 4 . +.It cfumass +Provides access for remote systems via USB Mass Storage Class +Bulk Only (BBB) Transport. +.It ha +Internal frontend used to receive requests from other node ports in +High Availability cluster. +.It ioctl +Provides access for local user-level applications via +.Xr ioctl 2 +based API. +.It iscsi +Combined with +.Xr iscsi 4 +and +.Xr ctld 8 , +provides access for remote systems via iSCSI protocol. +.It tpc +Internal frontend used to receive requests from Third Party Copy engine, +implementing copy offload operations. +.El +.Pp +The +.Nm +subsystem includes two backends to create logical units using different +kinds of backing stores: +.Bl -tag -width ramdisk +.It block +Stores data in ZFS ZVOLs, files or raw block devices. +.It ramdisk +Stores data in RAM, that makes it mostly useful for performance testing. +Depending on configured capacity can work as black hole, thin or thick +provisioned disk. +.El .Sh SYSCTL VARIABLES The following variables are available as both .Xr sysctl 8 @@ -146,7 +187,7 @@ primary; .It 1 secondary. .El -This role can be overriden on per-LUN basis using "ha_role" LUN option, +This role can be overridden on per-LUN basis using "ha_role" LUN option, so that for one LUN one node is primary, while for another -- another. Role change from primary to secondary for HA modes 0 and 2 closes backends, the opposite change -- opens. From owner-svn-src-stable-11@freebsd.org Sat Mar 25 12:21:22 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1CCFBD1DF90; Sat, 25 Mar 2017 12:21:22 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D181E1746; Sat, 25 Mar 2017 12:21:21 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2PCLKJs071873; Sat, 25 Mar 2017 12:21:20 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2PCLKQf071872; Sat, 25 Mar 2017 12:21:20 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201703251221.v2PCLKQf071872@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sat, 25 Mar 2017 12:21:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315942 - stable/11/lib/libcompiler_rt X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Mar 2017 12:21:22 -0000 Author: dim Date: Sat Mar 25 12:21:20 2017 New Revision: 315942 URL: https://svnweb.freebsd.org/changeset/base/315942 Log: MFC r315689: Gcc has incompatible internal declarations for __divtc3 and __multc3 as defined in compiler-rt, but it has no option to silence its warning, so make gcc warnings for libcompiler_rt non-fatal. Noticed by: lwhsu Modified: stable/11/lib/libcompiler_rt/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libcompiler_rt/Makefile ============================================================================== --- stable/11/lib/libcompiler_rt/Makefile Sat Mar 25 11:48:12 2017 (r315941) +++ stable/11/lib/libcompiler_rt/Makefile Sat Mar 25 12:21:20 2017 (r315942) @@ -16,6 +16,10 @@ CFLAGS+= -I${SRCTOP}/contrib/libcxxrt CWARNFLAGS.gcc_personality_v0.c+= -Wno-typedef-redefinition .endif +# gcc has incompatible internal declarations for __divtc3 and __multc3, but has +# no option to silence its warning, so make warnings non-fatal. +NO_WERROR.gcc= + .include "Makefile.inc" .if ${MK_INSTALLLIB} != "no" From owner-svn-src-stable-11@freebsd.org Sat Mar 25 12:29:16 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BCDDCD1B1C5; Sat, 25 Mar 2017 12:29:16 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 895711B28; Sat, 25 Mar 2017 12:29:16 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2PCTFrc075792; Sat, 25 Mar 2017 12:29:15 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2PCTF5I075791; Sat, 25 Mar 2017 12:29:15 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201703251229.v2PCTF5I075791@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sat, 25 Mar 2017 12:29:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315943 - in stable: 10/contrib/libcxxrt 11/contrib/libcxxrt 9/contrib/libcxxrt X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Mar 2017 12:29:16 -0000 Author: dim Date: Sat Mar 25 12:29:15 2017 New Revision: 315943 URL: https://svnweb.freebsd.org/changeset/base/315943 Log: MFC r315745: Cherry-pick libcxxrt commit 8a853717e61d5d55cbdf74d9d0a7545da5d5ff92: Author: David Chisnall Date: Wed Mar 22 12:27:08 2017 +0000 Simplify some code. realloc() with a null pointer is equivalent to malloc, so we don't need to handle the two cases independently. Fixes #46 This should help with lang/beignet and other programs, which expect __cxa_demangle(name, NULL, NULL, &status) to return zero in status. PR: 213732 Modified: stable/11/contrib/libcxxrt/typeinfo.cc Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/10/contrib/libcxxrt/typeinfo.cc stable/9/contrib/libcxxrt/typeinfo.cc Directory Properties: stable/10/ (props changed) stable/9/ (props changed) stable/9/contrib/ (props changed) stable/9/contrib/libcxxrt/ (props changed) Modified: stable/11/contrib/libcxxrt/typeinfo.cc ============================================================================== --- stable/11/contrib/libcxxrt/typeinfo.cc Sat Mar 25 12:21:20 2017 (r315942) +++ stable/11/contrib/libcxxrt/typeinfo.cc Sat Mar 25 12:29:15 2017 (r315943) @@ -86,15 +86,7 @@ extern "C" char* __cxa_demangle(const ch if (NULL != demangled) { size_t len = strlen(demangled); - if (buf == NULL) - { - if (n) - { - *n = len; - } - return demangled; - } - if (*n < len+1) + if (!buf || (*n < len+1)) { buf = static_cast(realloc(buf, len+1)); } From owner-svn-src-stable-11@freebsd.org Sat Mar 25 13:33:26 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2D2AAD1CB44; Sat, 25 Mar 2017 13:33:26 +0000 (UTC) (envelope-from badger@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B89661577; Sat, 25 Mar 2017 13:33:25 +0000 (UTC) (envelope-from badger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2PDXOEt004377; Sat, 25 Mar 2017 13:33:24 GMT (envelope-from badger@FreeBSD.org) Received: (from badger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2PDXOmS004369; Sat, 25 Mar 2017 13:33:24 GMT (envelope-from badger@FreeBSD.org) Message-Id: <201703251333.v2PDXOmS004369@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: badger set sender to badger@FreeBSD.org using -f From: Eric Badger Date: Sat, 25 Mar 2017 13:33:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315949 - in stable: 10/sys/kern 10/sys/sys 10/tests/sys/kern 11/sys/kern 11/sys/sys 11/tests/sys/kern X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Mar 2017 13:33:26 -0000 Author: badger Date: Sat Mar 25 13:33:23 2017 New Revision: 315949 URL: https://svnweb.freebsd.org/changeset/base/315949 Log: MFC r313992, r314075, r314118, r315484: r315484: ptrace_test: eliminate assumption about thread scheduling A couple of the ptrace tests make assumptions about which thread in a multithreaded process will run after a halt. This makes the tests less portable across branches, and susceptible to future breakage. Instead, twiddle thread scheduling and priorities to match the tests' expectation. r314118: Actually fix buildworlds other than i386/amd64/sparc64 after r313992 Disable offending test for platforms without a userspace visible breakpoint(). r314075: Fix world build for archs where __builtin_debugtrap() does not work. The offending code was introduced in r313992. r313992: Defer ptracestop() signals that cannot be delivered immediately When a thread is stopped in ptracestop(), the ptrace(2) user may request a signal be delivered upon resumption of the thread. Heretofore, those signals were discarded unless ptracestop()'s caller was issignal(). Fix this by modifying ptracestop() to queue up signals requested by the ptrace user that will be delivered when possible. Take special care when the signal is SIGKILL (usually generated from a PT_KILL request); no new stop events should be triggered after a PT_KILL. Add a number of tests for the new functionality. Several tests were authored by jhb. PR: 212607 Sponsored by: Dell EMC Modified: stable/11/sys/kern/kern_fork.c stable/11/sys/kern/kern_sig.c stable/11/sys/kern/kern_thr.c stable/11/sys/kern/subr_syscall.c stable/11/sys/kern/sys_process.c stable/11/sys/sys/signalvar.h stable/11/tests/sys/kern/Makefile stable/11/tests/sys/kern/ptrace_test.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/10/sys/kern/kern_fork.c stable/10/sys/kern/kern_sig.c stable/10/sys/kern/kern_thr.c stable/10/sys/kern/subr_syscall.c stable/10/sys/kern/sys_process.c stable/10/sys/sys/signalvar.h stable/10/tests/sys/kern/Makefile stable/10/tests/sys/kern/ptrace_test.c Directory Properties: stable/10/ (props changed) Modified: stable/11/sys/kern/kern_fork.c ============================================================================== --- stable/11/sys/kern/kern_fork.c Sat Mar 25 13:32:28 2017 (r315948) +++ stable/11/sys/kern/kern_fork.c Sat Mar 25 13:33:23 2017 (r315949) @@ -1083,7 +1083,7 @@ fork_return(struct thread *td, struct tr proc_reparent(p, dbg); sx_xunlock(&proctree_lock); td->td_dbgflags |= TDB_CHILD | TDB_SCX | TDB_FSTP; - ptracestop(td, SIGSTOP); + ptracestop(td, SIGSTOP, NULL); td->td_dbgflags &= ~(TDB_CHILD | TDB_SCX); } else { /* @@ -1104,7 +1104,7 @@ fork_return(struct thread *td, struct tr _STOPEVENT(p, S_SCX, td->td_dbg_sc_code); if ((p->p_ptevents & PTRACE_SCX) != 0 || (td->td_dbgflags & TDB_BORN) != 0) - ptracestop(td, SIGTRAP); + ptracestop(td, SIGTRAP, NULL); td->td_dbgflags &= ~(TDB_SCX | TDB_BORN); PROC_UNLOCK(p); } Modified: stable/11/sys/kern/kern_sig.c ============================================================================== --- stable/11/sys/kern/kern_sig.c Sat Mar 25 13:32:28 2017 (r315948) +++ stable/11/sys/kern/kern_sig.c Sat Mar 25 13:33:23 2017 (r315949) @@ -278,6 +278,7 @@ sigqueue_init(sigqueue_t *list, struct p { SIGEMPTYSET(list->sq_signals); SIGEMPTYSET(list->sq_kill); + SIGEMPTYSET(list->sq_ptrace); TAILQ_INIT(&list->sq_list); list->sq_proc = p; list->sq_flags = SQ_INIT; @@ -301,9 +302,15 @@ sigqueue_get(sigqueue_t *sq, int signo, if (!SIGISMEMBER(sq->sq_signals, signo)) return (0); + if (SIGISMEMBER(sq->sq_ptrace, signo)) { + count++; + SIGDELSET(sq->sq_ptrace, signo); + si->ksi_flags |= KSI_PTRACE; + } if (SIGISMEMBER(sq->sq_kill, signo)) { count++; - SIGDELSET(sq->sq_kill, signo); + if (count == 1) + SIGDELSET(sq->sq_kill, signo); } TAILQ_FOREACH_SAFE(ksi, &sq->sq_list, ksi_link, next) { @@ -347,7 +354,8 @@ sigqueue_take(ksiginfo_t *ksi) if (kp->ksi_signo == ksi->ksi_signo) break; } - if (kp == NULL && !SIGISMEMBER(sq->sq_kill, ksi->ksi_signo)) + if (kp == NULL && !SIGISMEMBER(sq->sq_kill, ksi->ksi_signo) && + !SIGISMEMBER(sq->sq_ptrace, ksi->ksi_signo)) SIGDELSET(sq->sq_signals, ksi->ksi_signo); } @@ -360,6 +368,10 @@ sigqueue_add(sigqueue_t *sq, int signo, KASSERT(sq->sq_flags & SQ_INIT, ("sigqueue not inited")); + /* + * SIGKILL/SIGSTOP cannot be caught or masked, so take the fast path + * for these signals. + */ if (signo == SIGKILL || signo == SIGSTOP || si == NULL) { SIGADDSET(sq->sq_kill, signo); goto out_set_bit; @@ -398,16 +410,19 @@ sigqueue_add(sigqueue_t *sq, int signo, ksi->ksi_sigq = sq; } - if ((si->ksi_flags & KSI_TRAP) != 0 || - (si->ksi_flags & KSI_SIGQ) == 0) { - if (ret != 0) + if (ret != 0) { + if ((si->ksi_flags & KSI_PTRACE) != 0) { + SIGADDSET(sq->sq_ptrace, signo); + ret = 0; + goto out_set_bit; + } else if ((si->ksi_flags & KSI_TRAP) != 0 || + (si->ksi_flags & KSI_SIGQ) == 0) { SIGADDSET(sq->sq_kill, signo); - ret = 0; - goto out_set_bit; - } - - if (ret != 0) + ret = 0; + goto out_set_bit; + } return (ret); + } out_set_bit: SIGADDSET(sq->sq_signals, signo); @@ -434,6 +449,7 @@ sigqueue_flush(sigqueue_t *sq) SIGEMPTYSET(sq->sq_signals); SIGEMPTYSET(sq->sq_kill); + SIGEMPTYSET(sq->sq_ptrace); } static void @@ -466,6 +482,11 @@ sigqueue_move_set(sigqueue_t *src, sigqu SIGSETOR(dst->sq_kill, tmp); SIGSETNAND(src->sq_kill, tmp); + tmp = src->sq_ptrace; + SIGSETAND(tmp, *set); + SIGSETOR(dst->sq_ptrace, tmp); + SIGSETNAND(src->sq_ptrace, tmp); + tmp = src->sq_signals; SIGSETAND(tmp, *set); SIGSETOR(dst->sq_signals, tmp); @@ -502,6 +523,7 @@ sigqueue_delete_set(sigqueue_t *sq, cons } } SIGSETNAND(sq->sq_kill, *set); + SIGSETNAND(sq->sq_ptrace, *set); SIGSETNAND(sq->sq_signals, *set); } @@ -2501,69 +2523,116 @@ sig_suspend_threads(struct thread *td, s return (wakeup_swapper); } +/* + * Stop the process for an event deemed interesting to the debugger. If si is + * non-NULL, this is a signal exchange; the new signal requested by the + * debugger will be returned for handling. If si is NULL, this is some other + * type of interesting event. The debugger may request a signal be delivered in + * that case as well, however it will be deferred until it can be handled. + */ int -ptracestop(struct thread *td, int sig) +ptracestop(struct thread *td, int sig, ksiginfo_t *si) { struct proc *p = td->td_proc; + struct thread *td2; + ksiginfo_t ksi; + int prop; PROC_LOCK_ASSERT(p, MA_OWNED); KASSERT(!(p->p_flag & P_WEXIT), ("Stopping exiting process")); WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, &p->p_mtx.lock_object, "Stopping for traced signal"); - td->td_dbgflags |= TDB_XSIG; td->td_xsig = sig; - CTR4(KTR_PTRACE, "ptracestop: tid %d (pid %d) flags %#x sig %d", - td->td_tid, p->p_pid, td->td_dbgflags, sig); - PROC_SLOCK(p); - while ((p->p_flag & P_TRACED) && (td->td_dbgflags & TDB_XSIG)) { - if (p->p_flag & P_SINGLE_EXIT && - !(td->td_dbgflags & TDB_EXIT)) { + + if (si == NULL || (si->ksi_flags & KSI_PTRACE) == 0) { + td->td_dbgflags |= TDB_XSIG; + CTR4(KTR_PTRACE, "ptracestop: tid %d (pid %d) flags %#x sig %d", + td->td_tid, p->p_pid, td->td_dbgflags, sig); + PROC_SLOCK(p); + while ((p->p_flag & P_TRACED) && (td->td_dbgflags & TDB_XSIG)) { + if (P_KILLED(p)) { + /* + * Ensure that, if we've been PT_KILLed, the + * exit status reflects that. Another thread + * may also be in ptracestop(), having just + * received the SIGKILL, but this thread was + * unsuspended first. + */ + td->td_dbgflags &= ~TDB_XSIG; + td->td_xsig = SIGKILL; + p->p_ptevents = 0; + break; + } + if (p->p_flag & P_SINGLE_EXIT && + !(td->td_dbgflags & TDB_EXIT)) { + /* + * Ignore ptrace stops except for thread exit + * events when the process exits. + */ + td->td_dbgflags &= ~TDB_XSIG; + PROC_SUNLOCK(p); + return (0); + } + /* - * Ignore ptrace stops except for thread exit - * events when the process exits. + * Make wait(2) work. Ensure that right after the + * attach, the thread which was decided to become the + * leader of attach gets reported to the waiter. + * Otherwise, just avoid overwriting another thread's + * assignment to p_xthread. If another thread has + * already set p_xthread, the current thread will get + * a chance to report itself upon the next iteration. */ - td->td_dbgflags &= ~TDB_XSIG; - PROC_SUNLOCK(p); - return (sig); - } - - /* - * Make wait(2) work. Ensure that right after the - * attach, the thread which was decided to become the - * leader of attach gets reported to the waiter. - * Otherwise, just avoid overwriting another thread's - * assignment to p_xthread. If another thread has - * already set p_xthread, the current thread will get - * a chance to report itself upon the next iteration. - */ - if ((td->td_dbgflags & TDB_FSTP) != 0 || - ((p->p_flag2 & P2_PTRACE_FSTP) == 0 && - p->p_xthread == NULL)) { - p->p_xsig = sig; - p->p_xthread = td; - td->td_dbgflags &= ~TDB_FSTP; - p->p_flag2 &= ~P2_PTRACE_FSTP; - p->p_flag |= P_STOPPED_SIG | P_STOPPED_TRACE; - sig_suspend_threads(td, p, 0); - } - if ((td->td_dbgflags & TDB_STOPATFORK) != 0) { - td->td_dbgflags &= ~TDB_STOPATFORK; - cv_broadcast(&p->p_dbgwait); - } + if ((td->td_dbgflags & TDB_FSTP) != 0 || + ((p->p_flag2 & P2_PTRACE_FSTP) == 0 && + p->p_xthread == NULL)) { + p->p_xsig = sig; + p->p_xthread = td; + td->td_dbgflags &= ~TDB_FSTP; + p->p_flag2 &= ~P2_PTRACE_FSTP; + p->p_flag |= P_STOPPED_SIG | P_STOPPED_TRACE; + sig_suspend_threads(td, p, 0); + } + if ((td->td_dbgflags & TDB_STOPATFORK) != 0) { + td->td_dbgflags &= ~TDB_STOPATFORK; + cv_broadcast(&p->p_dbgwait); + } stopme: - thread_suspend_switch(td, p); - if (p->p_xthread == td) - p->p_xthread = NULL; - if (!(p->p_flag & P_TRACED)) - break; - if (td->td_dbgflags & TDB_SUSPEND) { - if (p->p_flag & P_SINGLE_EXIT) + thread_suspend_switch(td, p); + if (p->p_xthread == td) + p->p_xthread = NULL; + if (!(p->p_flag & P_TRACED)) break; - goto stopme; + if (td->td_dbgflags & TDB_SUSPEND) { + if (p->p_flag & P_SINGLE_EXIT) + break; + goto stopme; + } } + PROC_SUNLOCK(p); } - PROC_SUNLOCK(p); + + if (si != NULL && sig == td->td_xsig) { + /* Parent wants us to take the original signal unchanged. */ + si->ksi_flags |= KSI_HEAD; + if (sigqueue_add(&td->td_sigqueue, sig, si) != 0) + si->ksi_signo = 0; + } else if (td->td_xsig != 0) { + /* + * If parent wants us to take a new signal, then it will leave + * it in td->td_xsig; otherwise we just look for signals again. + */ + ksiginfo_init(&ksi); + ksi.ksi_signo = td->td_xsig; + ksi.ksi_flags |= KSI_PTRACE; + prop = sigprop(td->td_xsig); + td2 = sigtd(p, td->td_xsig, prop); + tdsendsignal(p, td2, td->td_xsig, &ksi); + if (td != td2) + return (0); + } + return (td->td_xsig); } @@ -2721,7 +2790,7 @@ issignal(struct thread *td) struct sigacts *ps; struct sigqueue *queue; sigset_t sigpending; - int sig, prop, newsig; + int sig, prop; p = td->td_proc; ps = p->p_sigacts; @@ -2784,47 +2853,18 @@ issignal(struct thread *td) } mtx_unlock(&ps->ps_mtx); - newsig = ptracestop(td, sig); + sig = ptracestop(td, sig, &td->td_dbgksi); mtx_lock(&ps->ps_mtx); - if (sig != newsig) { - - /* - * If parent wants us to take the signal, - * then it will leave it in p->p_xsig; - * otherwise we just look for signals again. - */ - if (newsig == 0) - continue; - sig = newsig; - - /* - * Put the new signal into td_sigqueue. If the - * signal is being masked, look for other - * signals. - */ - sigqueue_add(queue, sig, NULL); - if (SIGISMEMBER(td->td_sigmask, sig)) - continue; - signotify(td); - } else { - if (td->td_dbgksi.ksi_signo != 0) { - td->td_dbgksi.ksi_flags |= KSI_HEAD; - if (sigqueue_add(&td->td_sigqueue, sig, - &td->td_dbgksi) != 0) - td->td_dbgksi.ksi_signo = 0; - } - if (td->td_dbgksi.ksi_signo == 0) - sigqueue_add(&td->td_sigqueue, sig, - NULL); - } - - /* + /* + * Keep looking if the debugger discarded the signal + * or replaced it with a masked signal. + * * If the traced bit got turned off, go back up * to the top to rescan signals. This ensures * that p_sig* and p_sigact are consistent. */ - if ((p->p_flag & P_TRACED) == 0) + if (sig == 0 || (p->p_flag & P_TRACED) == 0) continue; } Modified: stable/11/sys/kern/kern_thr.c ============================================================================== --- stable/11/sys/kern/kern_thr.c Sat Mar 25 13:32:28 2017 (r315948) +++ stable/11/sys/kern/kern_thr.c Sat Mar 25 13:33:23 2017 (r315949) @@ -357,7 +357,7 @@ kern_thr_exit(struct thread *td) p->p_pendingexits++; td->td_dbgflags |= TDB_EXIT; if (p->p_ptevents & PTRACE_LWP) - ptracestop(td, SIGTRAP); + ptracestop(td, SIGTRAP, NULL); PROC_UNLOCK(p); tidhash_remove(td); PROC_LOCK(p); Modified: stable/11/sys/kern/subr_syscall.c ============================================================================== --- stable/11/sys/kern/subr_syscall.c Sat Mar 25 13:32:28 2017 (r315948) +++ stable/11/sys/kern/subr_syscall.c Sat Mar 25 13:33:23 2017 (r315949) @@ -88,7 +88,7 @@ syscallenter(struct thread *td, struct s td->td_dbg_sc_code = sa->code; td->td_dbg_sc_narg = sa->narg; if (p->p_ptevents & PTRACE_SCE) - ptracestop((td), SIGTRAP); + ptracestop((td), SIGTRAP, NULL); PROC_UNLOCK(p); } if (td->td_dbgflags & TDB_USERWR) { @@ -222,7 +222,7 @@ syscallret(struct thread *td, int error, if (traced && ((td->td_dbgflags & (TDB_FORK | TDB_EXEC)) != 0 || (p->p_ptevents & PTRACE_SCX) != 0)) - ptracestop(td, SIGTRAP); + ptracestop(td, SIGTRAP, NULL); td->td_dbgflags &= ~(TDB_SCX | TDB_EXEC | TDB_FORK); PROC_UNLOCK(p); } @@ -259,7 +259,7 @@ again: if (td->td_dbgflags & TDB_VFORK) { PROC_LOCK(p); if (p->p_ptevents & PTRACE_VFORK) - ptracestop(td, SIGTRAP); + ptracestop(td, SIGTRAP, NULL); td->td_dbgflags &= ~TDB_VFORK; PROC_UNLOCK(p); } Modified: stable/11/sys/kern/sys_process.c ============================================================================== --- stable/11/sys/kern/sys_process.c Sat Mar 25 13:32:28 2017 (r315948) +++ stable/11/sys/kern/sys_process.c Sat Mar 25 13:33:23 2017 (r315949) @@ -1125,6 +1125,16 @@ kern_ptrace(struct thread *td, int req, td2->td_dbgflags &= ~TDB_XSIG; td2->td_xsig = data; + /* + * P_WKILLED is insurance that a PT_KILL/SIGKILL always + * works immediately, even if another thread is + * unsuspended first and attempts to handle a different + * signal or if the POSIX.1b style signal queue cannot + * accommodate any new signals. + */ + if (data == SIGKILL) + p->p_flag |= P_WKILLED; + if (req == PT_DETACH) { FOREACH_THREAD_IN_PROC(p, td3) td3->td_dbgflags &= ~TDB_SUSPEND; Modified: stable/11/sys/sys/signalvar.h ============================================================================== --- stable/11/sys/sys/signalvar.h Sat Mar 25 13:32:28 2017 (r315948) +++ stable/11/sys/sys/signalvar.h Sat Mar 25 13:33:23 2017 (r315949) @@ -237,13 +237,15 @@ typedef struct ksiginfo { #define KSI_INS 0x04 /* Directly insert ksi, not the copy */ #define KSI_SIGQ 0x08 /* Generated by sigqueue, might ret EAGAIN. */ #define KSI_HEAD 0x10 /* Insert into head, not tail. */ -#define KSI_COPYMASK (KSI_TRAP|KSI_SIGQ) +#define KSI_PTRACE 0x20 /* Generated by ptrace. */ +#define KSI_COPYMASK (KSI_TRAP | KSI_SIGQ | KSI_PTRACE) #define KSI_ONQ(ksi) ((ksi)->ksi_sigq != NULL) typedef struct sigqueue { sigset_t sq_signals; /* All pending signals. */ sigset_t sq_kill; /* Legacy depth 1 queue. */ + sigset_t sq_ptrace; /* Depth 1 queue for ptrace(2). */ TAILQ_HEAD(, ksiginfo) sq_list;/* Queued signal info. */ struct proc *sq_proc; int sq_flags; @@ -370,7 +372,7 @@ void pgsigio(struct sigio **sigiop, int void pgsignal(struct pgrp *pgrp, int sig, int checkctty, ksiginfo_t *ksi); int postsig(int sig); void kern_psignal(struct proc *p, int sig); -int ptracestop(struct thread *td, int sig); +int ptracestop(struct thread *td, int sig, ksiginfo_t *si); void sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *retmask); struct sigacts *sigacts_alloc(void); void sigacts_copy(struct sigacts *dest, struct sigacts *src); Modified: stable/11/tests/sys/kern/Makefile ============================================================================== --- stable/11/tests/sys/kern/Makefile Sat Mar 25 13:32:28 2017 (r315948) +++ stable/11/tests/sys/kern/Makefile Sat Mar 25 13:33:23 2017 (r315949) @@ -8,6 +8,7 @@ TESTSDIR= ${TESTSBASE}/sys/kern ATF_TESTS_C+= kern_copyin ATF_TESTS_C+= kern_descrip_test ATF_TESTS_C+= ptrace_test +TEST_METADATA.ptrace_test+= timeout="15" ATF_TESTS_C+= reaper PLAIN_TESTS_C+= subr_unit_test ATF_TESTS_C+= unix_seqpacket_test Modified: stable/11/tests/sys/kern/ptrace_test.c ============================================================================== --- stable/11/tests/sys/kern/ptrace_test.c Sat Mar 25 13:32:28 2017 (r315948) +++ stable/11/tests/sys/kern/ptrace_test.c Sat Mar 25 13:33:23 2017 (r315949) @@ -28,13 +28,21 @@ __FBSDID("$FreeBSD$"); #include +#include +#include +#include #include +#include +#include #include #include #include #include #include +#include #include +#include +#include #include #include #include @@ -1673,6 +1681,1143 @@ ATF_TC_BODY(ptrace__ptrace_vfork_follow, ATF_REQUIRE(errno == ECHILD); } +/* + * XXX: There's nothing inherently platform specific about this test, however a + * userspace visible breakpoint() is a prerequisite. + */ + #if defined(__amd64__) || defined(__i386__) || defined(__sparc64__) +/* + * Verify that no more events are reported after PT_KILL except for the + * process exit when stopped due to a breakpoint trap. + */ +ATF_TC_WITHOUT_HEAD(ptrace__PT_KILL_breakpoint); +ATF_TC_BODY(ptrace__PT_KILL_breakpoint, tc) +{ + pid_t fpid, wpid; + int status; + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + trace_me(); + breakpoint(); + exit(1); + } + + /* The first wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + /* Continue the child ignoring the SIGSTOP. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* The second wait() should report hitting the breakpoint. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGTRAP); + + /* Kill the child process. */ + ATF_REQUIRE(ptrace(PT_KILL, fpid, 0, 0) == 0); + + /* The last wait() should report the SIGKILL. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSIGNALED(status)); + ATF_REQUIRE(WTERMSIG(status) == SIGKILL); + + wpid = wait(&status); + ATF_REQUIRE(wpid == -1); + ATF_REQUIRE(errno == ECHILD); +} +#endif /* defined(__amd64__) || defined(__i386__) || defined(__sparc64__) */ + +/* + * Verify that no more events are reported after PT_KILL except for the + * process exit when stopped inside of a system call. + */ +ATF_TC_WITHOUT_HEAD(ptrace__PT_KILL_system_call); +ATF_TC_BODY(ptrace__PT_KILL_system_call, tc) +{ + struct ptrace_lwpinfo pl; + pid_t fpid, wpid; + int status; + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + trace_me(); + getpid(); + exit(1); + } + + /* The first wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + /* Continue the child ignoring the SIGSTOP and tracing system calls. */ + ATF_REQUIRE(ptrace(PT_SYSCALL, fpid, (caddr_t)1, 0) == 0); + + /* The second wait() should report a system call entry for getpid(). */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGTRAP); + + ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl, sizeof(pl)) != -1); + ATF_REQUIRE(pl.pl_flags & PL_FLAG_SCE); + + /* Kill the child process. */ + ATF_REQUIRE(ptrace(PT_KILL, fpid, 0, 0) == 0); + + /* The last wait() should report the SIGKILL. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSIGNALED(status)); + ATF_REQUIRE(WTERMSIG(status) == SIGKILL); + + wpid = wait(&status); + ATF_REQUIRE(wpid == -1); + ATF_REQUIRE(errno == ECHILD); +} + +/* + * Verify that no more events are reported after PT_KILL except for the + * process exit when killing a multithreaded process. + */ +ATF_TC_WITHOUT_HEAD(ptrace__PT_KILL_threads); +ATF_TC_BODY(ptrace__PT_KILL_threads, tc) +{ + struct ptrace_lwpinfo pl; + pid_t fpid, wpid; + lwpid_t main_lwp; + int status; + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + trace_me(); + simple_thread_main(); + } + + /* The first wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl, + sizeof(pl)) != -1); + main_lwp = pl.pl_lwpid; + + ATF_REQUIRE(ptrace(PT_LWP_EVENTS, wpid, NULL, 1) == 0); + + /* Continue the child ignoring the SIGSTOP. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* The first event should be for the child thread's birth. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGTRAP); + + ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl, sizeof(pl)) != -1); + ATF_REQUIRE((pl.pl_flags & (PL_FLAG_BORN | PL_FLAG_SCX)) == + (PL_FLAG_BORN | PL_FLAG_SCX)); + ATF_REQUIRE(pl.pl_lwpid != main_lwp); + + /* Kill the child process. */ + ATF_REQUIRE(ptrace(PT_KILL, fpid, 0, 0) == 0); + + /* The last wait() should report the SIGKILL. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSIGNALED(status)); + ATF_REQUIRE(WTERMSIG(status) == SIGKILL); + + wpid = wait(&status); + ATF_REQUIRE(wpid == -1); + ATF_REQUIRE(errno == ECHILD); +} + +static void * +mask_usr1_thread(void *arg) +{ + pthread_barrier_t *pbarrier; + sigset_t sigmask; + + pbarrier = (pthread_barrier_t*)arg; + + sigemptyset(&sigmask); + sigaddset(&sigmask, SIGUSR1); + CHILD_REQUIRE(pthread_sigmask(SIG_BLOCK, &sigmask, NULL) == 0); + + /* Sync up with other thread after sigmask updated. */ + pthread_barrier_wait(pbarrier); + + for (;;) + sleep(60); + + return (NULL); +} + +/* + * Verify that the SIGKILL from PT_KILL takes priority over other signals + * and prevents spurious stops due to those other signals. + */ +ATF_TC_WITHOUT_HEAD(ptrace__PT_KILL_competing_signal); +ATF_TC_BODY(ptrace__PT_KILL_competing_signal, tc) +{ + pid_t fpid, wpid; + int status; + cpuset_t setmask; + pthread_t t; + pthread_barrier_t barrier; + struct sched_param sched_param; + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + /* Bind to one CPU so only one thread at a time will run. */ + CPU_ZERO(&setmask); + CPU_SET(0, &setmask); + cpusetid_t setid; + CHILD_REQUIRE(cpuset(&setid) == 0); + CHILD_REQUIRE(cpuset_setaffinity(CPU_LEVEL_CPUSET, + CPU_WHICH_CPUSET, setid, sizeof(setmask), &setmask) == 0); + + CHILD_REQUIRE(pthread_barrier_init(&barrier, NULL, 2) == 0); + + CHILD_REQUIRE(pthread_create(&t, NULL, mask_usr1_thread, + (void*)&barrier) == 0); + + /* + * Give the main thread higher priority. The test always + * assumes that, if both threads are able to run, the main + * thread runs first. + */ + sched_param.sched_priority = + (sched_get_priority_max(SCHED_FIFO) + + sched_get_priority_min(SCHED_FIFO)) / 2; + CHILD_REQUIRE(pthread_setschedparam(pthread_self(), + SCHED_FIFO, &sched_param) == 0); + sched_param.sched_priority -= RQ_PPQ; + CHILD_REQUIRE(pthread_setschedparam(t, SCHED_FIFO, + &sched_param) == 0); + + sigset_t sigmask; + sigemptyset(&sigmask); + sigaddset(&sigmask, SIGUSR2); + CHILD_REQUIRE(pthread_sigmask(SIG_BLOCK, &sigmask, NULL) == 0); + + /* Sync up with other thread after sigmask updated. */ + pthread_barrier_wait(&barrier); + + trace_me(); + + for (;;) + sleep(60); + + exit(1); + } + + /* The first wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + /* Continue the child ignoring the SIGSTOP. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* Send a signal that only the second thread can handle. */ + ATF_REQUIRE(kill(fpid, SIGUSR2) == 0); + + /* The second wait() should report the SIGUSR2. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGUSR2); + + /* Send a signal that only the first thread can handle. */ + ATF_REQUIRE(kill(fpid, SIGUSR1) == 0); + + /* Replace the SIGUSR2 with a kill. */ + ATF_REQUIRE(ptrace(PT_KILL, fpid, 0, 0) == 0); + + /* The last wait() should report the SIGKILL (not the SIGUSR signal). */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSIGNALED(status)); + ATF_REQUIRE(WTERMSIG(status) == SIGKILL); + + wpid = wait(&status); + ATF_REQUIRE(wpid == -1); + ATF_REQUIRE(errno == ECHILD); +} + +/* + * Verify that the SIGKILL from PT_KILL takes priority over other stop events + * and prevents spurious stops caused by those events. + */ +ATF_TC_WITHOUT_HEAD(ptrace__PT_KILL_competing_stop); +ATF_TC_BODY(ptrace__PT_KILL_competing_stop, tc) +{ + pid_t fpid, wpid; + int status; + cpuset_t setmask; + pthread_t t; + pthread_barrier_t barrier; + lwpid_t main_lwp; + struct ptrace_lwpinfo pl; + struct sched_param sched_param; + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + trace_me(); + + /* Bind to one CPU so only one thread at a time will run. */ + CPU_ZERO(&setmask); + CPU_SET(0, &setmask); + cpusetid_t setid; + CHILD_REQUIRE(cpuset(&setid) == 0); + CHILD_REQUIRE(cpuset_setaffinity(CPU_LEVEL_CPUSET, + CPU_WHICH_CPUSET, setid, sizeof(setmask), &setmask) == 0); + + CHILD_REQUIRE(pthread_barrier_init(&barrier, NULL, 2) == 0); + + CHILD_REQUIRE(pthread_create(&t, NULL, mask_usr1_thread, + (void*)&barrier) == 0); + + /* + * Give the main thread higher priority. The test always + * assumes that, if both threads are able to run, the main + * thread runs first. + */ + sched_param.sched_priority = + (sched_get_priority_max(SCHED_FIFO) + + sched_get_priority_min(SCHED_FIFO)) / 2; + CHILD_REQUIRE(pthread_setschedparam(pthread_self(), + SCHED_FIFO, &sched_param) == 0); + sched_param.sched_priority -= RQ_PPQ; + CHILD_REQUIRE(pthread_setschedparam(t, SCHED_FIFO, + &sched_param) == 0); + + sigset_t sigmask; + sigemptyset(&sigmask); + sigaddset(&sigmask, SIGUSR2); + CHILD_REQUIRE(pthread_sigmask(SIG_BLOCK, &sigmask, NULL) == 0); + + /* Sync up with other thread after sigmask updated. */ + pthread_barrier_wait(&barrier); + + /* Sync up with the test before doing the getpid(). */ + raise(SIGSTOP); + + getpid(); + exit(1); + } + + /* The first wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl, sizeof(pl)) != -1); + main_lwp = pl.pl_lwpid; + + /* Continue the child ignoring the SIGSTOP and tracing system calls. */ + ATF_REQUIRE(ptrace(PT_SYSCALL, fpid, (caddr_t)1, 0) == 0); + + /* + * Continue until child is done with setup, which is indicated with + * SIGSTOP. Ignore system calls in the meantime. + */ + for (;;) { + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + if (WSTOPSIG(status) == SIGTRAP) { + ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl, + sizeof(pl)) != -1); + ATF_REQUIRE(pl.pl_flags & (PL_FLAG_SCE | PL_FLAG_SCX)); + } else { + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + break; + } + ATF_REQUIRE(ptrace(PT_SYSCALL, fpid, (caddr_t)1, 0) == 0); + } + + /* Proceed, allowing main thread to hit syscall entry for getpid(). */ + ATF_REQUIRE(ptrace(PT_SYSCALL, fpid, (caddr_t)1, 0) == 0); + + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGTRAP); + + ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl, + sizeof(pl)) != -1); + ATF_REQUIRE(pl.pl_lwpid == main_lwp); + ATF_REQUIRE(pl.pl_flags & PL_FLAG_SCE); + /* Prevent the main thread from hitting its syscall exit for now. */ + ATF_REQUIRE(ptrace(PT_SUSPEND, main_lwp, 0, 0) == 0); + + /* + * Proceed, allowing second thread to hit syscall exit for + * pthread_barrier_wait(). + */ + ATF_REQUIRE(ptrace(PT_SYSCALL, fpid, (caddr_t)1, 0) == 0); + + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGTRAP); + + ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl, + sizeof(pl)) != -1); + ATF_REQUIRE(pl.pl_lwpid != main_lwp); + ATF_REQUIRE(pl.pl_flags & PL_FLAG_SCX); + + /* Send a signal that only the second thread can handle. */ + ATF_REQUIRE(kill(fpid, SIGUSR2) == 0); + + ATF_REQUIRE(ptrace(PT_SYSCALL, fpid, (caddr_t)1, 0) == 0); + + /* The next wait() should report the SIGUSR2. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGUSR2); + + /* Allow the main thread to try to finish its system call. */ + ATF_REQUIRE(ptrace(PT_RESUME, main_lwp, 0, 0) == 0); + + /* + * At this point, the main thread is in the middle of a system call and + * has been resumed. The second thread has taken a SIGUSR2 which will + * be replaced with a SIGKILL below. The main thread will get to run + * first. It should notice the kill request (even though the signal + * replacement occurred in the other thread) and exit accordingly. It + * should not stop for the system call exit event. + */ + + /* Replace the SIGUSR2 with a kill. */ + ATF_REQUIRE(ptrace(PT_KILL, fpid, 0, 0) == 0); + + /* The last wait() should report the SIGKILL (not a syscall exit). */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSIGNALED(status)); + ATF_REQUIRE(WTERMSIG(status) == SIGKILL); + + wpid = wait(&status); + ATF_REQUIRE(wpid == -1); + ATF_REQUIRE(errno == ECHILD); +} + +static void +sigusr1_handler(int sig) +{ + + CHILD_REQUIRE(sig == SIGUSR1); + _exit(2); +} + +/* + * Verify that even if the signal queue is full for a child process, + * a PT_KILL will kill the process. + */ +ATF_TC_WITHOUT_HEAD(ptrace__PT_KILL_with_signal_full_sigqueue); +ATF_TC_BODY(ptrace__PT_KILL_with_signal_full_sigqueue, tc) +{ + pid_t fpid, wpid; + int status; + int max_pending_per_proc; + size_t len; + int i; + + ATF_REQUIRE(signal(SIGUSR1, sigusr1_handler) != SIG_ERR); + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + trace_me(); + exit(1); + } + + /* The first wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + len = sizeof(max_pending_per_proc); + ATF_REQUIRE(sysctlbyname("kern.sigqueue.max_pending_per_proc", + &max_pending_per_proc, &len, NULL, 0) == 0); + + /* Fill the signal queue. */ + for (i = 0; i < max_pending_per_proc; ++i) + ATF_REQUIRE(kill(fpid, SIGUSR1) == 0); + + /* Kill the child process. */ + ATF_REQUIRE(ptrace(PT_KILL, fpid, 0, 0) == 0); + + /* The last wait() should report the SIGKILL. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSIGNALED(status)); + ATF_REQUIRE(WTERMSIG(status) == SIGKILL); + + wpid = wait(&status); + ATF_REQUIRE(wpid == -1); + ATF_REQUIRE(errno == ECHILD); +} + +/* + * Verify that when stopped at a system call entry, a signal can be + * requested with PT_CONTINUE which will be delivered once the system + * call is complete. + */ +ATF_TC_WITHOUT_HEAD(ptrace__PT_CONTINUE_with_signal_system_call_entry); +ATF_TC_BODY(ptrace__PT_CONTINUE_with_signal_system_call_entry, tc) +{ + struct ptrace_lwpinfo pl; + pid_t fpid, wpid; + int status; + + ATF_REQUIRE(signal(SIGUSR1, sigusr1_handler) != SIG_ERR); + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + trace_me(); + getpid(); + exit(1); + } + + /* The first wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + /* Continue the child ignoring the SIGSTOP and tracing system calls. */ + ATF_REQUIRE(ptrace(PT_SYSCALL, fpid, (caddr_t)1, 0) == 0); + + /* The second wait() should report a system call entry for getpid(). */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Sat Mar 25 14:25:21 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BA2D6D1C8BD; Sat, 25 Mar 2017 14:25:21 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8938E1EED; Sat, 25 Mar 2017 14:25:21 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2PEPKLu024820; Sat, 25 Mar 2017 14:25:20 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2PEPKo3024819; Sat, 25 Mar 2017 14:25:20 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201703251425.v2PEPKo3024819@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sat, 25 Mar 2017 14:25:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315953 - stable/11/sys/compat/linux X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Mar 2017 14:25:21 -0000 Author: dchagin Date: Sat Mar 25 14:25:20 2017 New Revision: 315953 URL: https://svnweb.freebsd.org/changeset/base/315953 Log: MFC r315278: Fix usage of the same 'i' variable in the external and nested loops. Modified: stable/11/sys/compat/linux/linux_vdso.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linux/linux_vdso.c ============================================================================== --- stable/11/sys/compat/linux/linux_vdso.c Sat Mar 25 14:14:11 2017 (r315952) +++ stable/11/sys/compat/linux/linux_vdso.c Sat Mar 25 14:25:20 2017 (r315953) @@ -147,7 +147,7 @@ __elfN(linux_vdso_reloc)(struct sysentve Elf_Shdr *shdr; Elf_Dyn *dyn; Elf_Sym *sym; - int i, symcnt; + int i, j, symcnt; ehdr = (Elf_Ehdr *) sv->sv_sigcode; @@ -205,7 +205,7 @@ __elfN(linux_vdso_reloc)(struct sysentve sym = (Elf_Sym *)((caddr_t)ehdr + shdr[i].sh_offset); symcnt = shdr[i].sh_size / sizeof(*sym); - for(i = 0; i < symcnt; i++, sym++) { + for(j = 0; j < symcnt; j++, sym++) { if (sym->st_shndx == SHN_UNDEF || sym->st_shndx == SHN_ABS) continue; From owner-svn-src-stable-11@freebsd.org Sat Mar 25 14:26:47 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2AA0BD1C959; Sat, 25 Mar 2017 14:26:47 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EB4061044; Sat, 25 Mar 2017 14:26:46 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2PEQkQU024918; Sat, 25 Mar 2017 14:26:46 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2PEQk7h024917; Sat, 25 Mar 2017 14:26:46 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201703251426.v2PEQk7h024917@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sat, 25 Mar 2017 14:26:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315954 - stable/11/sys/compat/linux X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Mar 2017 14:26:47 -0000 Author: dchagin Date: Sat Mar 25 14:26:45 2017 New Revision: 315954 URL: https://svnweb.freebsd.org/changeset/base/315954 Log: MFC r315503: As noted by Roel Bouwman Linux allows a large buffer size than the struct ucred size. Fix this. PR: 102956 Modified: stable/11/sys/compat/linux/linux_socket.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linux/linux_socket.c ============================================================================== --- stable/11/sys/compat/linux/linux_socket.c Sat Mar 25 14:25:20 2017 (r315953) +++ stable/11/sys/compat/linux/linux_socket.c Sat Mar 25 14:26:45 2017 (r315954) @@ -1621,7 +1621,7 @@ linux_getsockopt(struct thread *td, stru /* NOTREACHED */ break; case LOCAL_PEERCRED: - if (args->optlen != sizeof(lxu)) + if (args->optlen < sizeof(lxu)) return (EINVAL); xulen = sizeof(xu); error = kern_getsockopt(td, args->s, bsd_args.level, From owner-svn-src-stable-11@freebsd.org Sat Mar 25 14:28:22 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1881ED1C9E4; Sat, 25 Mar 2017 14:28:22 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DBCF8118A; Sat, 25 Mar 2017 14:28:21 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2PESK4Y025039; Sat, 25 Mar 2017 14:28:20 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2PESKG4025038; Sat, 25 Mar 2017 14:28:20 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201703251428.v2PESKG4025038@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sat, 25 Mar 2017 14:28:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315955 - stable/11/sys/compat/linux X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Mar 2017 14:28:22 -0000 Author: dchagin Date: Sat Mar 25 14:28:20 2017 New Revision: 315955 URL: https://svnweb.freebsd.org/changeset/base/315955 Log: MFC r315499: Remove superflous break statment. Modified: stable/11/sys/compat/linux/linux_socket.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linux/linux_socket.c ============================================================================== --- stable/11/sys/compat/linux/linux_socket.c Sat Mar 25 14:26:45 2017 (r315954) +++ stable/11/sys/compat/linux/linux_socket.c Sat Mar 25 14:28:20 2017 (r315955) @@ -1547,7 +1547,6 @@ linux_setsockopt(struct thread *td, stru return (kern_setsockopt(td, args->s, bsd_args.level, name, &tv, UIO_SYSSPACE, sizeof(tv))); /* NOTREACHED */ - break; default: break; } @@ -1619,7 +1618,6 @@ linux_getsockopt(struct thread *td, stru return (copyout(&linux_tv, PTRIN(args->optval), sizeof(linux_tv))); /* NOTREACHED */ - break; case LOCAL_PEERCRED: if (args->optlen < sizeof(lxu)) return (EINVAL); @@ -1636,7 +1634,6 @@ linux_getsockopt(struct thread *td, stru lxu.gid = xu.cr_gid; return (copyout(&lxu, PTRIN(args->optval), sizeof(lxu))); /* NOTREACHED */ - break; case SO_ERROR: len = sizeof(newval); error = kern_getsockopt(td, args->s, bsd_args.level, From owner-svn-src-stable-11@freebsd.org Sat Mar 25 20:14:09 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AD111D1D845; Sat, 25 Mar 2017 20:14:09 +0000 (UTC) (envelope-from badger@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 633F61E4E; Sat, 25 Mar 2017 20:14:09 +0000 (UTC) (envelope-from badger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2PKE8OE065218; Sat, 25 Mar 2017 20:14:08 GMT (envelope-from badger@FreeBSD.org) Received: (from badger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2PKE8Qh065216; Sat, 25 Mar 2017 20:14:08 GMT (envelope-from badger@FreeBSD.org) Message-Id: <201703252014.v2PKE8Qh065216@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: badger set sender to badger@FreeBSD.org using -f From: Eric Badger Date: Sat, 25 Mar 2017 20:14:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315963 - in stable: 10/sys/kern 10/tests/sys/kern 11/sys/kern 11/tests/sys/kern X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Mar 2017 20:14:09 -0000 Author: badger Date: Sat Mar 25 20:14:08 2017 New Revision: 315963 URL: https://svnweb.freebsd.org/changeset/base/315963 Log: MFC r315412, r314852: r315412: Don't clear p_ptevents on normal SIGKILL delivery The ptrace() user has the option of discarding the signal. In such a case, p_ptevents should not be modified. If the ptrace() user decides to send a SIGKILL, ptevents will be cleared in ptracestop(). procfs events do not have the capability to discard the signal, so continue to clear the mask in that case. r314852: don't stop in issignal() if P_SINGLE_EXIT is set Suppose a traced process is stopped in ptracestop() due to receipt of a SIGSTOP signal, and is awaiting orders from the tracing process on how to handle the signal. Before sending any such orders, the tracing process exits. This should kill the traced process. But suppose a second thread handles the SIGKILL and proceeds to exit1(), calling thread_single(). The first thread will now awaken and will have a chance to check once more if it should go to sleep due to the SIGSTOP. It must not sleep after P_SINGLE_EXIT has been set; this would prevent the SIGKILL from taking effect, leaving a stopped orphan behind after the tracing process dies. Also add new tests for this condition. Sponsored by: Dell EMC Modified: stable/11/sys/kern/kern_sig.c stable/11/tests/sys/kern/ptrace_test.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/10/sys/kern/kern_sig.c stable/10/tests/sys/kern/ptrace_test.c Directory Properties: stable/10/ (props changed) Modified: stable/11/sys/kern/kern_sig.c ============================================================================== --- stable/11/sys/kern/kern_sig.c Sat Mar 25 19:46:53 2017 (r315962) +++ stable/11/sys/kern/kern_sig.c Sat Mar 25 20:14:08 2017 (r315963) @@ -2213,11 +2213,9 @@ tdsendsignal(struct proc *p, struct thre if (action == SIG_HOLD && !((prop & SA_CONT) && (p->p_flag & P_STOPPED_SIG))) return (ret); - /* - * SIGKILL: Remove procfs STOPEVENTs and ptrace events. - */ + + /* SIGKILL: Remove procfs STOPEVENTs. */ if (sig == SIGKILL) { - p->p_ptevents = 0; /* from procfs_ioctl.c: PIOCBIC */ p->p_stops = 0; /* from procfs_ioctl.c: PIOCCONT */ @@ -2893,14 +2891,15 @@ issignal(struct thread *td) break; /* == ignore */ } /* - * If there is a pending stop signal to process - * with default action, stop here, - * then clear the signal. However, - * if process is member of an orphaned - * process group, ignore tty stop signals. + * If there is a pending stop signal to process with + * default action, stop here, then clear the signal. + * Traced or exiting processes should ignore stops. + * Additionally, a member of an orphaned process group + * should ignore tty stops. */ if (prop & SA_STOP) { - if (p->p_flag & (P_TRACED|P_WEXIT) || + if (p->p_flag & + (P_TRACED | P_WEXIT | P_SINGLE_EXIT) || (p->p_pgrp->pg_jobc == 0 && prop & SA_TTYSTOP)) break; /* == ignore */ Modified: stable/11/tests/sys/kern/ptrace_test.c ============================================================================== --- stable/11/tests/sys/kern/ptrace_test.c Sat Mar 25 19:46:53 2017 (r315962) +++ stable/11/tests/sys/kern/ptrace_test.c Sat Mar 25 20:14:08 2017 (r315963) @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -2818,6 +2819,212 @@ ATF_TC_BODY(ptrace__PT_CONTINUE_with_sig ATF_REQUIRE(errno == ECHILD); } +static void * +raise_sigstop_thread(void *arg __unused) +{ + + raise(SIGSTOP); + return NULL; +} + +static void * +sleep_thread(void *arg __unused) +{ + + sleep(60); + return NULL; +} + +static void +terminate_with_pending_sigstop(bool sigstop_from_main_thread) +{ + pid_t fpid, wpid; + int status, i; + cpuset_t setmask; + cpusetid_t setid; + pthread_t t; + + /* + * Become the reaper for this process tree. We need to be able to check + * that both child and grandchild have died. + */ + ATF_REQUIRE(procctl(P_PID, getpid(), PROC_REAP_ACQUIRE, NULL) == 0); + + fpid = fork(); + ATF_REQUIRE(fpid >= 0); + if (fpid == 0) { + fpid = fork(); + CHILD_REQUIRE(fpid >= 0); + if (fpid == 0) { + trace_me(); + + /* Pin to CPU 0 to serialize thread execution. */ + CPU_ZERO(&setmask); + CPU_SET(0, &setmask); + CHILD_REQUIRE(cpuset(&setid) == 0); + CHILD_REQUIRE(cpuset_setaffinity(CPU_LEVEL_CPUSET, + CPU_WHICH_CPUSET, setid, + sizeof(setmask), &setmask) == 0); + + if (sigstop_from_main_thread) { + /* + * We expect the SIGKILL sent when our parent + * dies to be delivered to the new thread. + * Raise the SIGSTOP in this thread so the + * threads compete. + */ + CHILD_REQUIRE(pthread_create(&t, NULL, + sleep_thread, NULL) == 0); + raise(SIGSTOP); + } else { + /* + * We expect the SIGKILL to be delivered to + * this thread. After creating the new thread, + * just get off the CPU so the other thread can + * raise the SIGSTOP. + */ + CHILD_REQUIRE(pthread_create(&t, NULL, + raise_sigstop_thread, NULL) == 0); + sleep(60); + } + + exit(0); + } + /* First stop is trace_me() immediately after fork. */ + wpid = waitpid(fpid, &status, 0); + CHILD_REQUIRE(wpid == fpid); + CHILD_REQUIRE(WIFSTOPPED(status)); + CHILD_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + CHILD_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* Second stop is from the raise(SIGSTOP). */ + wpid = waitpid(fpid, &status, 0); + CHILD_REQUIRE(wpid == fpid); + CHILD_REQUIRE(WIFSTOPPED(status)); + CHILD_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + /* + * Terminate tracing process without detaching. Our child + * should be killed. + */ + exit(0); + } + + /* + * We should get a normal exit from our immediate child and a SIGKILL + * exit from our grandchild. The latter case is the interesting one. + * Our grandchild should not have stopped due to the SIGSTOP that was + * left dangling when its parent died. + */ + for (i = 0; i < 2; ++i) { + wpid = wait(&status); + if (wpid == fpid) + ATF_REQUIRE(WIFEXITED(status) && + WEXITSTATUS(status) == 0); + else + ATF_REQUIRE(WIFSIGNALED(status) && + WTERMSIG(status) == SIGKILL); + } +} + +/* + * These two tests ensure that if the tracing process exits without detaching + * just after the child received a SIGSTOP, the child is cleanly killed and + * doesn't go to sleep due to the SIGSTOP. The parent's death will send a + * SIGKILL to the child. If the SIGKILL and the SIGSTOP are handled by + * different threads, the SIGKILL must win. There are two variants of this + * test, designed to catch the case where the SIGKILL is delivered to the + * younger thread (the first test) and the case where the SIGKILL is delivered + * to the older thread (the second test). This behavior has changed in the + * past, so make no assumption. + */ +ATF_TC_WITHOUT_HEAD(ptrace__parent_terminate_with_pending_sigstop1); +ATF_TC_BODY(ptrace__parent_terminate_with_pending_sigstop1, tc) +{ + + terminate_with_pending_sigstop(true); +} +ATF_TC_WITHOUT_HEAD(ptrace__parent_terminate_with_pending_sigstop2); +ATF_TC_BODY(ptrace__parent_terminate_with_pending_sigstop2, tc) +{ + + terminate_with_pending_sigstop(false); +} + +/* + * Verify that after ptrace() discards a SIGKILL signal, the event mask + * is not modified. + */ +ATF_TC_WITHOUT_HEAD(ptrace__event_mask_sigkill_discard); +ATF_TC_BODY(ptrace__event_mask_sigkill_discard, tc) +{ + struct ptrace_lwpinfo pl; + pid_t fpid, wpid; + int status, event_mask, new_event_mask; + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + trace_me(); + raise(SIGSTOP); + exit(0); + } + + /* The first wait() should report the stop from trace_me(). */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + /* Set several unobtrusive event bits. */ + event_mask = PTRACE_EXEC | PTRACE_FORK | PTRACE_LWP; + ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, wpid, (caddr_t)&event_mask, + sizeof(event_mask)) == 0); + + /* Send a SIGKILL without using ptrace. */ + ATF_REQUIRE(kill(fpid, SIGKILL) == 0); + + /* Continue the child ignoring the SIGSTOP. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* The next stop should be due to the SIGKILL. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGKILL); + + ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl, sizeof(pl)) != -1); + ATF_REQUIRE(pl.pl_flags & PL_FLAG_SI); + ATF_REQUIRE(pl.pl_siginfo.si_signo == SIGKILL); + + /* Continue the child ignoring the SIGKILL. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* The next wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + /* Check the current event mask. It should not have changed. */ + new_event_mask = 0; + ATF_REQUIRE(ptrace(PT_GET_EVENT_MASK, wpid, (caddr_t)&new_event_mask, + sizeof(new_event_mask)) == 0); + ATF_REQUIRE(event_mask == new_event_mask); + + /* Continue the child to let it exit. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* The last event should be for the child process's exit. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(WIFEXITED(status)); + ATF_REQUIRE(WEXITSTATUS(status) == 0); + + wpid = wait(&status); + ATF_REQUIRE(wpid == -1); + ATF_REQUIRE(errno == ECHILD); +} + ATF_TP_ADD_TCS(tp) { @@ -2862,6 +3069,9 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, ptrace__PT_CONTINUE_with_signal_mix); ATF_TP_ADD_TC(tp, ptrace__PT_CONTINUE_with_signal_kqueue); ATF_TP_ADD_TC(tp, ptrace__PT_CONTINUE_with_signal_thread_sigmask); + ATF_TP_ADD_TC(tp, ptrace__parent_terminate_with_pending_sigstop1); + ATF_TP_ADD_TC(tp, ptrace__parent_terminate_with_pending_sigstop2); + ATF_TP_ADD_TC(tp, ptrace__event_mask_sigkill_discard); return (atf_no_error()); }