From owner-svn-src-stable@freebsd.org Sun Aug 20 01:08:25 2017 Return-Path: Delivered-To: svn-src-stable@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 0F4FCDCFBBC; Sun, 20 Aug 2017 01:08:25 +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 A53096C681; Sun, 20 Aug 2017 01:08: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 v7K18NnN021060; Sun, 20 Aug 2017 01:08:23 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7K18NYH021054; Sun, 20 Aug 2017 01:08:23 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201708200108.v7K18NYH021054@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sun, 20 Aug 2017 01:08: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: r322711 - in stable/11/sys: conf fs/ext2fs modules/ext2fs X-SVN-Group: stable-11 X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: in stable/11/sys: conf fs/ext2fs modules/ext2fs X-SVN-Commit-Revision: 322711 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Aug 2017 01:08:25 -0000 Author: pfg Date: Sun Aug 20 01:08:23 2017 New Revision: 322711 URL: https://svnweb.freebsd.org/changeset/base/322711 Log: MFC r316341, r317779, r319071, r319077, r319557, r319558, r319827, r319829: ext2fs: add read-write support for Extended Attributes and linux ACLs. Extended attributes and their particular implementation in linux are different from FreeBSD so in this case we have started diverging from the UFS EA implementation, which would be the natural reference. Support for linux ext2fs posix-draft ACLs. Submitted by: Fedor Uporov Reviewed by: pfg Include fixes from: cem, pluknet Added: stable/11/sys/fs/ext2fs/ext2_acl.c - copied, changed from r319071, head/sys/fs/ext2fs/ext2_acl.c stable/11/sys/fs/ext2fs/ext2_acl.h - copied unchanged from r319071, head/sys/fs/ext2fs/ext2_acl.h stable/11/sys/fs/ext2fs/ext2_extattr.c - copied, changed from r316341, head/sys/fs/ext2fs/ext2_extattr.c stable/11/sys/fs/ext2fs/ext2_extattr.h - copied, changed from r316341, head/sys/fs/ext2fs/ext2_extattr.h Modified: stable/11/sys/conf/files stable/11/sys/fs/ext2fs/ext2_alloc.c stable/11/sys/fs/ext2fs/ext2_extern.h stable/11/sys/fs/ext2fs/ext2_inode.c stable/11/sys/fs/ext2fs/ext2_inode_cnv.c stable/11/sys/fs/ext2fs/ext2_vnops.c stable/11/sys/fs/ext2fs/ext2fs.h stable/11/sys/fs/ext2fs/inode.h stable/11/sys/modules/ext2fs/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/conf/files ============================================================================== --- stable/11/sys/conf/files Sun Aug 20 00:41:49 2017 (r322710) +++ stable/11/sys/conf/files Sun Aug 20 01:08:23 2017 (r322711) @@ -3329,9 +3329,11 @@ geom/virstor/binstream.c optional geom_virstor geom/virstor/g_virstor.c optional geom_virstor geom/virstor/g_virstor_md.c optional geom_virstor geom/zero/g_zero.c optional geom_zero +fs/ext2fs/ext2_acl.c optional ext2fs fs/ext2fs/ext2_alloc.c optional ext2fs fs/ext2fs/ext2_balloc.c optional ext2fs fs/ext2fs/ext2_bmap.c optional ext2fs +fs/ext2fs/ext2_extattr.c optional ext2fs fs/ext2fs/ext2_extents.c optional ext2fs fs/ext2fs/ext2_inode.c optional ext2fs fs/ext2fs/ext2_inode_cnv.c optional ext2fs Copied and modified: stable/11/sys/fs/ext2fs/ext2_acl.c (from r319071, head/sys/fs/ext2fs/ext2_acl.c) ============================================================================== --- head/sys/fs/ext2fs/ext2_acl.c Sun May 28 15:39:11 2017 (r319071, copy source) +++ stable/11/sys/fs/ext2fs/ext2_acl.c Sun Aug 20 01:08:23 2017 (r322711) @@ -49,6 +49,8 @@ #include #include +#ifdef UFS_ACL + void ext2_sync_acl_from_inode(struct inode *ip, struct acl *acl) { @@ -127,13 +129,18 @@ ext2_sync_inode_from_acl(struct acl *acl, struct inode static int ext4_acl_from_disk(char *value, size_t size, struct acl *acl) { - const char *end = value + size; + const char *end; int n, count, s; + if (value == NULL) + return (EINVAL); + + end = value + size; + if (((struct ext2_acl_header *)value)->a_version != EXT4_ACL_VERSION) return (EINVAL); - if (!value || size < sizeof(struct ext2_acl_header)) + if (size < sizeof(struct ext2_acl_header)) return (EINVAL); s = size - sizeof(struct ext2_acl_header); @@ -210,11 +217,6 @@ ext2_getacl_posix1e(struct vop_getacl_args *ap) int len; int error; - len = sizeof(*ap->a_aclp) + sizeof(struct ext2_acl_header); - value = malloc(len, M_ACL, M_WAITOK); - if (!value) - return (ENOMEM); - switch (ap->a_type) { case ACL_TYPE_DEFAULT: attrnamespace = POSIX1E_ACL_DEFAULT_EXTATTR_NAMESPACE; @@ -228,10 +230,14 @@ ext2_getacl_posix1e(struct vop_getacl_args *ap) return (EINVAL); } + len = sizeof(*ap->a_aclp) + sizeof(struct ext2_acl_header); + value = malloc(len, M_ACL, M_WAITOK); + if (!value) + return (ENOMEM); + error = vn_extattr_get(ap->a_vp, IO_NODELOCKED, attrnamespace, attrname, &len, value, ap->a_td); - switch (error) { - case ENOATTR: + if (error == ENOATTR) { switch (ap->a_type) { case ACL_TYPE_ACCESS: ap->a_aclp->acl_cnt = 3; @@ -250,22 +256,21 @@ ext2_getacl_posix1e(struct vop_getacl_args *ap) ap->a_aclp->acl_cnt = 0; break; } - case 0: - if (!error) { - error = ext4_acl_from_disk(value, len, ap->a_aclp); - if (error) - goto out; - } + } else if (error != 0) + goto out; - if (error == ENOATTR) - error = 0; - - if (ap->a_type == ACL_TYPE_ACCESS) - ext2_sync_acl_from_inode(VTOI(ap->a_vp), ap->a_aclp); - default: - break; + if (!error) { + error = ext4_acl_from_disk(value, len, ap->a_aclp); + if (error) + goto out; } + if (error == ENOATTR) + error = 0; + + if (ap->a_type == ACL_TYPE_ACCESS) + ext2_sync_acl_from_inode(VTOI(ap->a_vp), ap->a_aclp); + out: free(value, M_TEMP); return (error); @@ -276,7 +281,7 @@ ext2_getacl(struct vop_getacl_args *ap) { if (((ap->a_vp->v_mount->mnt_flag & MNT_ACLS) == 0) || - ((ap->a_vp->v_mount->mnt_flag & MNT_NFS4ACLS) == 1)) + ((ap->a_vp->v_mount->mnt_flag & MNT_NFS4ACLS) != 0)) return (EOPNOTSUPP); if (ap->a_type == ACL_TYPE_NFS4) @@ -473,7 +478,7 @@ int ext2_setacl(struct vop_setacl_args *ap) { if (((ap->a_vp->v_mount->mnt_flag & MNT_ACLS) == 0) || - ((ap->a_vp->v_mount->mnt_flag & MNT_NFS4ACLS) == 1)) + ((ap->a_vp->v_mount->mnt_flag & MNT_NFS4ACLS) != 0)) return (EOPNOTSUPP); if (ap->a_type == ACL_TYPE_NFS4) @@ -490,7 +495,7 @@ ext2_aclcheck(struct vop_aclcheck_args *ap) { if (((ap->a_vp->v_mount->mnt_flag & MNT_ACLS) == 0) || - ((ap->a_vp->v_mount->mnt_flag & MNT_NFS4ACLS) == 1)) + ((ap->a_vp->v_mount->mnt_flag & MNT_NFS4ACLS) != 0)) return (EOPNOTSUPP); if (ap->a_type == ACL_TYPE_NFS4) @@ -518,4 +523,6 @@ ext2_aclcheck(struct vop_aclcheck_args *ap) } return (acl_posix1e_check(ap->a_aclp)); -} \ No newline at end of file +} + +#endif /* UFS_ACL */ Copied: stable/11/sys/fs/ext2fs/ext2_acl.h (from r319071, head/sys/fs/ext2fs/ext2_acl.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/fs/ext2fs/ext2_acl.h Sun Aug 20 01:08:23 2017 (r322711, copy of r319071, head/sys/fs/ext2fs/ext2_acl.h) @@ -0,0 +1,55 @@ +/*- + * Copyright (c) 2017, Fedor Uporov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _FS_EXT2FS_EXT2_ACL_H_ +#define _FS_EXT2FS_EXT2_ACL_H_ + +#define EXT4_ACL_VERSION 0x0001 + +struct ext2_acl_entry { + int16_t ae_tag; + int16_t ae_perm; + int32_t ae_id; +}; + +struct ext2_acl_entry_short { + int16_t ae_tag; + int16_t ae_perm; +}; + +struct ext2_acl_header { + int32_t a_version; +}; + +void ext2_sync_acl_from_inode(struct inode *ip, struct acl *acl); + +int ext2_getacl(struct vop_getacl_args *); +int ext2_setacl(struct vop_setacl_args *); +int ext2_aclcheck(struct vop_aclcheck_args *); + +#endif /* !_FS_EXT2FS_EXT2_ACL_H_ */ Modified: stable/11/sys/fs/ext2fs/ext2_alloc.c ============================================================================== --- stable/11/sys/fs/ext2fs/ext2_alloc.c Sun Aug 20 00:41:49 2017 (r322710) +++ stable/11/sys/fs/ext2fs/ext2_alloc.c Sun Aug 20 01:08:23 2017 (r322711) @@ -132,6 +132,25 @@ nospace: } /* + * Allocate EA's block for inode. + */ +daddr_t +ext2_allocfacl(struct inode *ip) +{ + struct m_ext2fs *fs; + daddr_t facl; + + fs = ip->i_e2fs; + + EXT2_LOCK(ip->i_ump); + facl = ext2_alloccg(ip, ino_to_cg(fs, ip->i_number), 0, fs->e2fs_bsize); + if (0 == facl) + EXT2_UNLOCK(ip->i_ump); + + return (facl); +} + +/* * Reallocate a sequence of blocks into a contiguous sequence of blocks. * * The vnode and an array of buffer pointers for a range of sequential Copied and modified: stable/11/sys/fs/ext2fs/ext2_extattr.c (from r316341, head/sys/fs/ext2fs/ext2_extattr.c) ============================================================================== --- head/sys/fs/ext2fs/ext2_extattr.c Sat Apr 1 01:00:36 2017 (r316341, copy source) +++ stable/11/sys/fs/ext2fs/ext2_extattr.c Sun Aug 20 01:08:23 2017 (r322711) @@ -44,24 +44,126 @@ #include #include #include +#include +static int +ext2_extattr_attrnamespace_to_bsd(int attrnamespace) +{ + switch (attrnamespace) { + case EXT4_XATTR_INDEX_SYSTEM: + return (EXTATTR_NAMESPACE_SYSTEM); + + case EXT4_XATTR_INDEX_USER: + return (EXTATTR_NAMESPACE_USER); + + case EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT: + return (POSIX1E_ACL_DEFAULT_EXTATTR_NAMESPACE); + + case EXT4_XATTR_INDEX_POSIX_ACL_ACCESS: + return (POSIX1E_ACL_ACCESS_EXTATTR_NAMESPACE); + } + + return (EXTATTR_NAMESPACE_EMPTY); +} + +static const char * +ext2_extattr_name_to_bsd(int attrnamespace, const char *name, int* name_len) +{ + + if (attrnamespace == EXT4_XATTR_INDEX_SYSTEM) + return (name); + else if (attrnamespace == EXT4_XATTR_INDEX_USER) + return (name); + else if (attrnamespace == EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT) { + *name_len = strlen(POSIX1E_ACL_DEFAULT_EXTATTR_NAME); + return (POSIX1E_ACL_DEFAULT_EXTATTR_NAME); + } else if (attrnamespace == EXT4_XATTR_INDEX_POSIX_ACL_ACCESS) { + *name_len = strlen(POSIX1E_ACL_ACCESS_EXTATTR_NAME); + return (POSIX1E_ACL_ACCESS_EXTATTR_NAME); + } + + /* + * XXX: Not all linux namespaces are mapped to bsd for now, + * return NULL, which will be converted to ENOTSUP on upper layer. + */ +#ifdef EXT2FS_DEBUG + printf("can not convert ext2fs name to bsd: namespace=%d\n", attrnamespace); +#endif + + return (NULL); +} + static int -ext2_extattr_index_to_bsd(int index) +ext2_extattr_attrnamespace_to_linux(int attrnamespace, const char *name) { - switch (index) { - case EXT4_XATTR_INDEX_USER: - return EXTATTR_NAMESPACE_USER; - case EXT4_XATTR_INDEX_SYSTEM: - return EXTATTR_NAMESPACE_SYSTEM; + if (attrnamespace == POSIX1E_ACL_DEFAULT_EXTATTR_NAMESPACE && + !strcmp(name, POSIX1E_ACL_DEFAULT_EXTATTR_NAME)) + return (EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT); - default: - return EXTATTR_NAMESPACE_EMPTY; + if (attrnamespace == POSIX1E_ACL_ACCESS_EXTATTR_NAMESPACE && + !strcmp(name, POSIX1E_ACL_ACCESS_EXTATTR_NAME)) + return (EXT4_XATTR_INDEX_POSIX_ACL_ACCESS); + + switch (attrnamespace) { + case EXTATTR_NAMESPACE_SYSTEM: + return (EXT4_XATTR_INDEX_SYSTEM); + + case EXTATTR_NAMESPACE_USER: + return (EXT4_XATTR_INDEX_USER); } + + /* + * In this case namespace conversion should be unique, + * so this point is unreachable. + */ + return (-1); } +static const char * +ext2_extattr_name_to_linux(int attrnamespace, const char *name) +{ + + if (attrnamespace == POSIX1E_ACL_DEFAULT_EXTATTR_NAMESPACE || + attrnamespace == POSIX1E_ACL_ACCESS_EXTATTR_NAMESPACE) + return (""); + else + return (name); +} + int +ext2_extattr_valid_attrname(int attrnamespace, const char *attrname) +{ + if (attrnamespace == EXTATTR_NAMESPACE_EMPTY) + return (EINVAL); + + if (strlen(attrname) == 0) + return (EINVAL); + + if (strlen(attrname) + 1 > EXT2_EXTATTR_NAMELEN_MAX) + return (ENAMETOOLONG); + + return (0); +} + +static int +ext2_extattr_check(struct ext2fs_extattr_entry *entry, char *end) +{ + struct ext2fs_extattr_entry *next; + + while (!EXT2_IS_LAST_ENTRY(entry)) { + next = EXT2_EXTATTR_NEXT(entry); + if ((char *)next >= end) + return (EIO); + + entry = next; + } + + return (0); +} + +int ext2_extattr_inode_list(struct inode *ip, int attrnamespace, struct uio *uio, size_t *size) { @@ -69,8 +171,8 @@ ext2_extattr_inode_list(struct inode *ip, int attrname struct buf *bp; struct ext2fs_extattr_dinode_header *header; struct ext2fs_extattr_entry *entry; - struct ext2fs_extattr_entry *next; - char *end; + const char *attr_name; + int name_len; int error; fs = ip->i_e2fs; @@ -95,38 +197,43 @@ ext2_extattr_inode_list(struct inode *ip, int attrname return (0); } - /* Check attributes integrity */ - entry = EXT2_IFIRST(header); - end = (char *)dinode + EXT2_INODE_SIZE(fs); - while (!EXT2_IS_LAST_ENTRY(entry)) { - next = EXT2_EXTATTR_NEXT(entry); - if ((char *)next >= end) { - brelse(bp); - return (EIO); - } - - entry = next; + error = ext2_extattr_check(EXT2_IFIRST(header), + (char *)dinode + EXT2_INODE_SIZE(fs)); + if (error) { + brelse(bp); + return (error); } for (entry = EXT2_IFIRST(header); !EXT2_IS_LAST_ENTRY(entry); - entry = EXT2_EXTATTR_NEXT(entry)) { - if (ext2_extattr_index_to_bsd(entry->e_name_index) != attrnamespace) + entry = EXT2_EXTATTR_NEXT(entry)) { + if (ext2_extattr_attrnamespace_to_bsd(entry->e_name_index) != + attrnamespace) continue; + name_len = entry->e_name_len; + attr_name = ext2_extattr_name_to_bsd(entry->e_name_index, + entry->e_name, &name_len); + if (!attr_name) { + brelse(bp); + return (ENOTSUP); + } + if (uio == NULL) - *size += entry->e_name_len + 1; + *size += name_len + 1; else { - char *attr_name = malloc(entry->e_name_len + 1, M_TEMP, M_WAITOK); - attr_name[0] = entry->e_name_len; - memcpy(&attr_name[1], entry->e_name, entry->e_name_len); - error = uiomove(attr_name, entry->e_name_len + 1, uio); - free(attr_name, M_TEMP); + char *name = malloc(name_len + 1, M_TEMP, M_WAITOK); + name[0] = name_len; + memcpy(&name[1], attr_name, name_len); + error = uiomove(name, name_len + 1, uio); + free(name, M_TEMP); + if (error) + break; } } brelse(bp); - return (0); + return (error); } int @@ -137,8 +244,8 @@ ext2_extattr_block_list(struct inode *ip, int attrname struct buf *bp; struct ext2fs_extattr_header *header; struct ext2fs_extattr_entry *entry; - struct ext2fs_extattr_entry *next; - char *end; + const char *attr_name; + int name_len; int error; fs = ip->i_e2fs; @@ -157,38 +264,42 @@ ext2_extattr_block_list(struct inode *ip, int attrname return (EINVAL); } - /* Check attributes integrity */ - end = bp->b_data + bp->b_bufsize; - entry = EXT2_FIRST_ENTRY(bp); - while (!EXT2_IS_LAST_ENTRY(entry)) { - next = EXT2_EXTATTR_NEXT(entry); - if ((char *)next >= end) { - brelse(bp); - return (EIO); - } - - entry = next; + error = ext2_extattr_check(EXT2_FIRST_ENTRY(bp), bp->b_data + bp->b_bufsize); + if (error) { + brelse(bp); + return (error); } for (entry = EXT2_FIRST_ENTRY(bp); !EXT2_IS_LAST_ENTRY(entry); entry = EXT2_EXTATTR_NEXT(entry)) { - if (ext2_extattr_index_to_bsd(entry->e_name_index) != attrnamespace) + if (ext2_extattr_attrnamespace_to_bsd(entry->e_name_index) != + attrnamespace) continue; + name_len = entry->e_name_len; + attr_name = ext2_extattr_name_to_bsd(entry->e_name_index, + entry->e_name, &name_len); + if (!attr_name) { + brelse(bp); + return (ENOTSUP); + } + if (uio == NULL) - *size += entry->e_name_len + 1; + *size += name_len + 1; else { - char *attr_name = malloc(entry->e_name_len + 1, M_TEMP, M_WAITOK); - attr_name[0] = entry->e_name_len; - memcpy(&attr_name[1], entry->e_name, entry->e_name_len); - error = uiomove(attr_name, entry->e_name_len + 1, uio); - free(attr_name, M_TEMP); + char *name = malloc(name_len + 1, M_TEMP, M_WAITOK); + name[0] = name_len; + memcpy(&name[1], attr_name, name_len); + error = uiomove(name, name_len + 1, uio); + free(name, M_TEMP); + if (error) + break; } } brelse(bp); - return (0); + return (error); } int @@ -199,8 +310,8 @@ ext2_extattr_inode_get(struct inode *ip, int attrnames struct buf *bp; struct ext2fs_extattr_dinode_header *header; struct ext2fs_extattr_entry *entry; - struct ext2fs_extattr_entry *next; - char *end; + const char *attr_name; + int name_len; int error; fs = ip->i_e2fs; @@ -222,45 +333,47 @@ ext2_extattr_inode_get(struct inode *ip, int attrnames if (header->h_magic != EXTATTR_MAGIC) { brelse(bp); - return (0); + return (ENOATTR); } - /* Check attributes integrity */ - entry = EXT2_IFIRST(header); - end = (char *)dinode + EXT2_INODE_SIZE(fs); - while (!EXT2_IS_LAST_ENTRY(entry)) { - next = EXT2_EXTATTR_NEXT(entry); - if ((char *)next >= end) { - brelse(bp); - return (EIO); - } - - entry = next; + error = ext2_extattr_check(EXT2_IFIRST(header), + (char *)dinode + EXT2_INODE_SIZE(fs)); + if (error) { + brelse(bp); + return (error); } for (entry = EXT2_IFIRST(header); !EXT2_IS_LAST_ENTRY(entry); entry = EXT2_EXTATTR_NEXT(entry)) { - if (ext2_extattr_index_to_bsd(entry->e_name_index) != attrnamespace) + if (ext2_extattr_attrnamespace_to_bsd(entry->e_name_index) != + attrnamespace) continue; - if (strlen(name) == entry->e_name_len && - 0 == strncmp(entry->e_name, name, entry->e_name_len)) { + name_len = entry->e_name_len; + attr_name = ext2_extattr_name_to_bsd(entry->e_name_index, + entry->e_name, &name_len); + if (!attr_name) { + brelse(bp); + return (ENOTSUP); + } + + if (strlen(name) == name_len && + 0 == strncmp(attr_name, name, name_len)) { if (uio == NULL) *size += entry->e_value_size; else { - error = uiomove(((char *)EXT2_IFIRST(header)) + entry->e_value_offs, - entry->e_value_size, uio); - if (error) { - brelse(bp); - return (error); - } + error = uiomove(((char *)EXT2_IFIRST(header)) + + entry->e_value_offs, entry->e_value_size, uio); } + + brelse(bp); + return (error); } } brelse(bp); - return (0); + return (ENOATTR); } int @@ -271,8 +384,8 @@ ext2_extattr_block_get(struct inode *ip, int attrnames struct buf *bp; struct ext2fs_extattr_header *header; struct ext2fs_extattr_entry *entry; - struct ext2fs_extattr_entry *next; - char *end; + const char *attr_name; + int name_len; int error; fs = ip->i_e2fs; @@ -291,40 +404,822 @@ ext2_extattr_block_get(struct inode *ip, int attrnames return (EINVAL); } - /* Check attributes integrity */ - end = bp->b_data + bp->b_bufsize; - entry = EXT2_FIRST_ENTRY(bp); - while (!EXT2_IS_LAST_ENTRY(entry)) { - next = EXT2_EXTATTR_NEXT(entry); - if ((char *)next >= end) { - brelse(bp); - return (EIO); - } - - entry = next; + error = ext2_extattr_check(EXT2_FIRST_ENTRY(bp), bp->b_data + bp->b_bufsize); + if (error) { + brelse(bp); + return (error); } for (entry = EXT2_FIRST_ENTRY(bp); !EXT2_IS_LAST_ENTRY(entry); entry = EXT2_EXTATTR_NEXT(entry)) { - if (ext2_extattr_index_to_bsd(entry->e_name_index) != attrnamespace) + if (ext2_extattr_attrnamespace_to_bsd(entry->e_name_index) != + attrnamespace) continue; - if (strlen(name) == entry->e_name_len && - 0 == strncmp(entry->e_name, name, entry->e_name_len)) { + name_len = entry->e_name_len; + attr_name = ext2_extattr_name_to_bsd(entry->e_name_index, + entry->e_name, &name_len); + if (!attr_name) { + brelse(bp); + return (ENOTSUP); + } + + if (strlen(name) == name_len && + 0 == strncmp(attr_name, name, name_len)) { if (uio == NULL) *size += entry->e_value_size; else { error = uiomove(bp->b_data + entry->e_value_offs, entry->e_value_size, uio); - if (error) { - brelse(bp); - return (error); - } } + + brelse(bp); + return (error); } } brelse(bp); + + return (ENOATTR); +} + +static uint16_t +ext2_extattr_delete_value(char *off, + struct ext2fs_extattr_entry *first_entry, + struct ext2fs_extattr_entry *entry, char *end) +{ + uint16_t min_offs; + struct ext2fs_extattr_entry *next; + + min_offs = end - off; + next = first_entry; + while (!EXT2_IS_LAST_ENTRY(next)) { + if (min_offs > next->e_value_offs && next->e_value_offs > 0) + min_offs = next->e_value_offs; + + next = EXT2_EXTATTR_NEXT(next); + } + + if (entry->e_value_size == 0) + return (min_offs); + + memmove(off + min_offs + EXT2_EXTATTR_SIZE(entry->e_value_size), + off + min_offs, entry->e_value_offs - min_offs); + + /* Adjust all value offsets */ + next = first_entry; + while (!EXT2_IS_LAST_ENTRY(next)) + { + if (next->e_value_offs > 0 && + next->e_value_offs < entry->e_value_offs) + next->e_value_offs += + EXT2_EXTATTR_SIZE(entry->e_value_size); + + next = EXT2_EXTATTR_NEXT(next); + } + + min_offs += EXT2_EXTATTR_SIZE(entry->e_value_size); + + return (min_offs); +} + +static void +ext2_extattr_delete_entry(char *off, + struct ext2fs_extattr_entry *first_entry, + struct ext2fs_extattr_entry *entry, char *end) +{ + char *pad; + struct ext2fs_extattr_entry *next; + + /* Clean entry value */ + ext2_extattr_delete_value(off, first_entry, entry, end); + + /* Clean the entry */ + next = first_entry; + while (!EXT2_IS_LAST_ENTRY(next)) + next = EXT2_EXTATTR_NEXT(next); + + pad = (char*)next + sizeof(uint32_t); + + memmove(entry, (char *)entry + EXT2_EXTATTR_LEN(entry->e_name_len), + pad - ((char *)entry + EXT2_EXTATTR_LEN(entry->e_name_len))); +} + +int +ext2_extattr_inode_delete(struct inode *ip, int attrnamespace, const char *name) +{ + struct m_ext2fs *fs; + struct buf *bp; + struct ext2fs_extattr_dinode_header *header; + struct ext2fs_extattr_entry *entry; + const char *attr_name; + int name_len; + int error; + + fs = ip->i_e2fs; + + if ((error = bread(ip->i_devvp, + fsbtodb(fs, ino_to_fsba(fs, ip->i_number)), + (int)fs->e2fs_bsize, NOCRED, &bp)) != 0) { + brelse(bp); + return (error); + } + + struct ext2fs_dinode *dinode = (struct ext2fs_dinode *) + ((char *)bp->b_data + + EXT2_INODE_SIZE(fs) * ino_to_fsbo(fs, ip->i_number)); + + /* Check attributes magic value */ + header = (struct ext2fs_extattr_dinode_header *)((char *)dinode + + E2FS_REV0_INODE_SIZE + dinode->e2di_extra_isize); + + if (header->h_magic != EXTATTR_MAGIC) { + brelse(bp); + return (ENOATTR); + } + + error = ext2_extattr_check(EXT2_IFIRST(header), + (char *)dinode + EXT2_INODE_SIZE(fs)); + if (error) { + brelse(bp); + return (error); + } + + /* If I am last entry, just make magic zero */ + entry = EXT2_IFIRST(header); + if ((EXT2_IS_LAST_ENTRY(EXT2_EXTATTR_NEXT(entry))) && + (ext2_extattr_attrnamespace_to_bsd(entry->e_name_index) == + attrnamespace)) { + + name_len = entry->e_name_len; + attr_name = ext2_extattr_name_to_bsd(entry->e_name_index, + entry->e_name, &name_len); + if (!attr_name) { + brelse(bp); + return (ENOTSUP); + } + + if (strlen(name) == name_len && + 0 == strncmp(attr_name, name, name_len)) { + memset(header, 0, sizeof(struct ext2fs_extattr_dinode_header)); + + return (bwrite(bp)); + } + } + + for (entry = EXT2_IFIRST(header); !EXT2_IS_LAST_ENTRY(entry); + entry = EXT2_EXTATTR_NEXT(entry)) { + if (ext2_extattr_attrnamespace_to_bsd(entry->e_name_index) != + attrnamespace) + continue; + + name_len = entry->e_name_len; + attr_name = ext2_extattr_name_to_bsd(entry->e_name_index, + entry->e_name, &name_len); + if (!attr_name) { + brelse(bp); + return (ENOTSUP); + } + + if (strlen(name) == name_len && + 0 == strncmp(attr_name, name, name_len)) { + ext2_extattr_delete_entry((char *)EXT2_IFIRST(header), + EXT2_IFIRST(header), entry, + (char *)dinode + EXT2_INODE_SIZE(fs)); + + return (bwrite(bp)); + } + } + + brelse(bp); + + return (ENOATTR); +} + +static int +ext2_extattr_block_clone(struct inode *ip, struct buf **bpp) +{ + struct m_ext2fs *fs; + struct buf *sbp; + struct buf *cbp; + struct ext2fs_extattr_header *header; + uint64_t facl; + + fs = ip->i_e2fs; + sbp = *bpp; + + header = EXT2_HDR(sbp); + if (header->h_magic != EXTATTR_MAGIC || header->h_refcount == 1) + return (EINVAL); + + facl = ext2_allocfacl(ip); + if (!facl) + return (ENOSPC); + + cbp = getblk(ip->i_devvp, fsbtodb(fs, facl), fs->e2fs_bsize, 0, 0, 0); + if (!cbp) { + ext2_blkfree(ip, facl, fs->e2fs_bsize); + return (EIO); + } + + memcpy(cbp->b_data, sbp->b_data, fs->e2fs_bsize); + header->h_refcount--; + bwrite(sbp); + + ip->i_facl = facl; + ext2_update(ip->i_vnode, 1); + + header = EXT2_HDR(cbp); + header->h_refcount = 1; + + *bpp = cbp; + + return (0); +} + +int +ext2_extattr_block_delete(struct inode *ip, int attrnamespace, const char *name) +{ + struct m_ext2fs *fs; + struct buf *bp; + struct ext2fs_extattr_header *header; + struct ext2fs_extattr_entry *entry; + const char *attr_name; + int name_len; + int error; + + fs = ip->i_e2fs; + + error = bread(ip->i_devvp, fsbtodb(fs, ip->i_facl), + fs->e2fs_bsize, NOCRED, &bp); + if (error) { + brelse(bp); + return (error); + } + + /* Check attributes magic value */ + header = EXT2_HDR(bp); + if (header->h_magic != EXTATTR_MAGIC || header->h_blocks != 1) { + brelse(bp); + return (EINVAL); + } + + error = ext2_extattr_check(EXT2_FIRST_ENTRY(bp), bp->b_data + bp->b_bufsize); + if (error) { + brelse(bp); + return (error); + } + + if (header->h_refcount > 1) { + error = ext2_extattr_block_clone(ip, &bp); + if (error) { + brelse(bp); + return (error); + } + } + + /* If I am last entry, clean me and free the block */ + entry = EXT2_FIRST_ENTRY(bp); + if (EXT2_IS_LAST_ENTRY(EXT2_EXTATTR_NEXT(entry)) && + (ext2_extattr_attrnamespace_to_bsd(entry->e_name_index) == + attrnamespace)) { + + name_len = entry->e_name_len; + attr_name = ext2_extattr_name_to_bsd(entry->e_name_index, + entry->e_name, &name_len); + if (!attr_name) { + brelse(bp); + return (ENOTSUP); + } + + if (strlen(name) == name_len && + 0 == strncmp(attr_name, name, name_len)) { + ip->i_blocks -= btodb(fs->e2fs_bsize); + ext2_blkfree(ip, ip->i_facl, fs->e2fs_bsize); + ip->i_facl = 0; + error = ext2_update(ip->i_vnode, 1); + + brelse(bp); + return (error); + } + } + + for (entry = EXT2_FIRST_ENTRY(bp); !EXT2_IS_LAST_ENTRY(entry); + entry = EXT2_EXTATTR_NEXT(entry)) { + if (ext2_extattr_attrnamespace_to_bsd(entry->e_name_index) != + attrnamespace) + continue; + + name_len = entry->e_name_len; + attr_name = ext2_extattr_name_to_bsd(entry->e_name_index, + entry->e_name, &name_len); + if (!attr_name) { + brelse(bp); + return (ENOTSUP); + } + + if (strlen(name) == name_len && + 0 == strncmp(attr_name, name, name_len)) { + ext2_extattr_delete_entry(bp->b_data, + EXT2_FIRST_ENTRY(bp), entry, + bp->b_data + bp->b_bufsize); + + return (bwrite(bp)); + } + } + + brelse(bp); + + return (ENOATTR); +} + +static struct ext2fs_extattr_entry * +allocate_entry(const char *name, int attrnamespace, uint16_t offs, + uint32_t size, uint32_t hash) +{ + const char *attr_name; + int name_len; + struct ext2fs_extattr_entry *entry; + + attr_name = ext2_extattr_name_to_linux(attrnamespace, name); + name_len = strlen(attr_name); + + entry = malloc(sizeof(struct ext2fs_extattr_entry) + name_len, + M_TEMP, M_WAITOK); + + entry->e_name_len = name_len; + entry->e_name_index = ext2_extattr_attrnamespace_to_linux(attrnamespace, name); + entry->e_value_offs = offs; + entry->e_value_block = 0; + entry->e_value_size = size; + entry->e_hash = hash; + memcpy(entry->e_name, name, name_len); + + return (entry); +} + +static void +free_entry(struct ext2fs_extattr_entry *entry) +{ + + free(entry, M_TEMP); +} + +static int +ext2_extattr_get_size(struct ext2fs_extattr_entry *first_entry, + struct ext2fs_extattr_entry *exist_entry, int header_size, + int name_len, int new_size) +{ + struct ext2fs_extattr_entry *entry; + int size; + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Sun Aug 20 01:27:35 2017 Return-Path: Delivered-To: svn-src-stable@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 53FD5DD17B2; Sun, 20 Aug 2017 01:27:35 +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 1F4116D111; Sun, 20 Aug 2017 01:27:35 +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 v7K1RYac028903; Sun, 20 Aug 2017 01:27:34 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7K1RXVl028896; Sun, 20 Aug 2017 01:27:33 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201708200127.v7K1RXVl028896@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sun, 20 Aug 2017 01:27: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: r322712 - in stable/11/sys: conf fs/ext2fs modules/ext2fs X-SVN-Group: stable-11 X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: in stable/11/sys: conf fs/ext2fs modules/ext2fs X-SVN-Commit-Revision: 322712 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Aug 2017 01:27:35 -0000 Author: pfg Date: Sun Aug 20 01:27:33 2017 New Revision: 322712 URL: https://svnweb.freebsd.org/changeset/base/322712 Log: MFC r320145: ext2fs: Add uninit_bg feature support. From the linux tune2fs(8) manpage: "Allow the kernel to initialize bitmaps and inode tables and keep a high watermark for the unused inodes in a filesystem, to reduce e2fsck(8) time. This first e2fsck run after enabling this feature will take the full time, but subsequent e2fsck runs will take only a fraction of the original time, depending on how full the file system is." Submitted by: Fedor Uporov Added: stable/11/sys/fs/ext2fs/ext2_csum.c - copied unchanged from r320145, head/sys/fs/ext2fs/ext2_csum.c Modified: stable/11/sys/conf/files stable/11/sys/fs/ext2fs/ext2_alloc.c stable/11/sys/fs/ext2fs/ext2_extern.h stable/11/sys/fs/ext2fs/ext2_vfsops.c stable/11/sys/fs/ext2fs/ext2fs.h stable/11/sys/modules/ext2fs/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/conf/files ============================================================================== --- stable/11/sys/conf/files Sun Aug 20 01:08:23 2017 (r322711) +++ stable/11/sys/conf/files Sun Aug 20 01:27:33 2017 (r322712) @@ -3333,6 +3333,7 @@ fs/ext2fs/ext2_acl.c optional ext2fs fs/ext2fs/ext2_alloc.c optional ext2fs fs/ext2fs/ext2_balloc.c optional ext2fs fs/ext2fs/ext2_bmap.c optional ext2fs +fs/ext2fs/ext2_csum.c optional ext2fs fs/ext2fs/ext2_extattr.c optional ext2fs fs/ext2fs/ext2_extents.c optional ext2fs fs/ext2fs/ext2_inode.c optional ext2fs Modified: stable/11/sys/fs/ext2fs/ext2_alloc.c ============================================================================== --- stable/11/sys/fs/ext2fs/ext2_alloc.c Sun Aug 20 01:08:23 2017 (r322711) +++ stable/11/sys/fs/ext2fs/ext2_alloc.c Sun Aug 20 01:27:33 2017 (r322712) @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -657,6 +658,135 @@ ext2_hashalloc(struct inode *ip, int cg, long pref, in return (0); } +static unsigned long +ext2_cg_num_gdb(struct m_ext2fs *fs, int cg) +{ + int gd_per_block, metagroup, first, last; + + gd_per_block = fs->e2fs_bsize / sizeof(struct ext2_gd); + metagroup = cg / gd_per_block; + first = metagroup * gd_per_block; + last = first + gd_per_block - 1; + + if (!EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_META_BG) || + metagroup < fs->e2fs->e3fs_first_meta_bg) { + if (!ext2_cg_has_sb(fs, cg)) + return (0); + if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_META_BG)) + return (fs->e2fs->e3fs_first_meta_bg); + return (fs->e2fs_gdbcount); + } + + if (cg == first || cg == first + 1 || cg == last) + return (1); + return (0); + +} + +static int +ext2_num_base_meta_blocks(struct m_ext2fs *fs, int cg) +{ + int num, gd_per_block; + + gd_per_block = fs->e2fs_bsize / sizeof(struct ext2_gd); + num = ext2_cg_has_sb(fs, cg); + + if (!EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_META_BG) || + cg < fs->e2fs->e3fs_first_meta_bg * gd_per_block) { + if (num) { + num += ext2_cg_num_gdb(fs, cg); + num += fs->e2fs->e2fs_reserved_ngdb; + } + } else { + num += ext2_cg_num_gdb(fs, cg); + } + + return (num); +} + +static int +ext2_get_cg_number(struct m_ext2fs *fs, daddr_t blk) +{ + int cg; + + if (fs->e2fs->e2fs_bpg == fs->e2fs_bsize * 8) + cg = (blk - fs->e2fs->e2fs_first_dblock) / (fs->e2fs_bsize * 8); + else + cg = blk - fs->e2fs->e2fs_first_dblock; + + return (cg); +} + +static void +ext2_mark_bitmap_end(int start_bit, int end_bit, char *bitmap) +{ + int i; + + if (start_bit >= end_bit) + return; + + for (i = start_bit; i < ((start_bit + 7) & ~7UL); i++) + setbit(bitmap, i); + if (i < end_bit) + memset(bitmap + (i >> 3), 0xff, (end_bit - i) >> 3); +} + +static int +ext2_cg_block_bitmap_init(struct m_ext2fs *fs, int cg, struct buf *bp) +{ + int bit, bit_max, inodes_per_block; + uint32_t start, tmp; + + if (!EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM) || + !(fs->e2fs_gd[cg].ext4bgd_flags & EXT2_BG_BLOCK_UNINIT)) + return (0); + + memset(bp->b_data, 0, fs->e2fs_bsize); + + bit_max = ext2_num_base_meta_blocks(fs, cg); + if ((bit_max >> 3) >= fs->e2fs_bsize) + return (EINVAL); + + for (bit = 0; bit < bit_max; bit++) + setbit(bp->b_data, bit); + + start = cg * fs->e2fs->e2fs_bpg + fs->e2fs->e2fs_first_dblock; + + /* Set bits for block and inode bitmaps, and inode table */ + tmp = fs->e2fs_gd[cg].ext2bgd_b_bitmap; + if (!EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_FLEX_BG) || + tmp == ext2_get_cg_number(fs, cg)) + setbit(bp->b_data, tmp - start); + + tmp = fs->e2fs_gd[cg].ext2bgd_i_bitmap; + if (!EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_FLEX_BG) || + tmp == ext2_get_cg_number(fs, cg)) + setbit(bp->b_data, tmp - start); + + tmp = fs->e2fs_gd[cg].ext2bgd_i_tables; + inodes_per_block = fs->e2fs_bsize/EXT2_INODE_SIZE(fs); + while( tmp < fs->e2fs_gd[cg].ext2bgd_i_tables + + fs->e2fs->e2fs_ipg / inodes_per_block ) { + if (!EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_FLEX_BG) || + tmp == ext2_get_cg_number(fs, cg)) + setbit(bp->b_data, tmp - start); + tmp++; + } + + /* + * Also if the number of blocks within the group is less than + * the blocksize * 8 ( which is the size of bitmap ), set rest + * of the block bitmap to 1 + */ + ext2_mark_bitmap_end(fs->e2fs->e2fs_bpg, fs->e2fs_bsize * 8, + bp->b_data); + + /* Clean the flag */ + fs->e2fs_gd[cg].ext4bgd_flags &= ~EXT2_BG_BLOCK_UNINIT; + + return (0); +} + /* * Determine whether a block can be allocated. * @@ -686,6 +816,14 @@ ext2_alloccg(struct inode *ip, int cg, daddr_t bpref, EXT2_LOCK(ump); return (0); } + if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM)) { + error = ext2_cg_block_bitmap_init(fs, cg, bp); + if (error) { + brelse(bp); + EXT2_LOCK(ump); + return (0); + } + } if (fs->e2fs_gd[cg].ext2bgd_nbfree == 0) { /* * Another thread allocated the last block in this @@ -899,6 +1037,41 @@ fail: return (0); } +static int +ext2_zero_inode_table(struct inode *ip, int cg) +{ + struct m_ext2fs *fs; + struct buf *bp; + int i, all_blks, used_blks; + + fs = ip->i_e2fs; + + if (fs->e2fs_gd[cg].ext4bgd_flags & EXT2_BG_INODE_ZEROED) + return (0); + + all_blks = fs->e2fs->e2fs_inode_size * fs->e2fs->e2fs_ipg / + fs->e2fs_bsize; + + used_blks = howmany(fs->e2fs->e2fs_ipg - + fs->e2fs_gd[cg].ext4bgd_i_unused, + fs->e2fs_bsize / EXT2_INODE_SIZE(fs)); + + for (i = 0; i < all_blks - used_blks; i++) { + bp = getblk(ip->i_devvp, fsbtodb(fs, + fs->e2fs_gd[cg].ext2bgd_i_tables + used_blks + i), + fs->e2fs_bsize, 0, 0, 0); + if (!bp) + return (EIO); + + vfs_bio_bzero_buf(bp, 0, fs->e2fs_bsize); + bawrite(bp); + } + + fs->e2fs_gd[cg].ext4bgd_flags |= EXT2_BG_INODE_ZEROED; + + return (0); +} + /* * Determine whether an inode can be allocated. * @@ -930,6 +1103,18 @@ ext2_nodealloccg(struct inode *ip, int cg, daddr_t ipr EXT2_LOCK(ump); return (0); } + if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM)) { + if (fs->e2fs_gd[cg].ext4bgd_flags & EXT2_BG_INODE_UNINIT) { + memset(bp->b_data, 0, fs->e2fs_bsize); + fs->e2fs_gd[cg].ext4bgd_flags &= ~EXT2_BG_INODE_UNINIT; + } + error = ext2_zero_inode_table(ip, cg); + if (error) { + brelse(bp); + EXT2_LOCK(ump); + return (0); + } + } if (fs->e2fs_gd[cg].ext2bgd_nifree == 0) { /* * Another thread allocated the last i-node in this @@ -964,6 +1149,8 @@ gotit: setbit(ibp, ipref); EXT2_LOCK(ump); fs->e2fs_gd[cg].ext2bgd_nifree--; + if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM)) + fs->e2fs_gd[cg].ext4bgd_i_unused--; fs->e2fs->e2fs_ficount--; fs->e2fs_fmod = 1; if ((mode & IFMT) == IFDIR) { @@ -1062,6 +1249,8 @@ ext2_vfree(struct vnode *pvp, ino_t ino, int mode) EXT2_LOCK(ump); fs->e2fs->e2fs_ficount++; fs->e2fs_gd[cg].ext2bgd_nifree++; + if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM)) + fs->e2fs_gd[cg].ext4bgd_i_unused++; if ((mode & IFMT) == IFDIR) { fs->e2fs_gd[cg].ext2bgd_ndirs--; fs->e2fs_total_dir--; @@ -1122,16 +1311,31 @@ ext2_fserr(struct m_ext2fs *fs, uid_t uid, char *cp) } int -cg_has_sb(int i) +ext2_cg_has_sb(struct m_ext2fs *fs, int cg) { int a3, a5, a7; - if (i == 0 || i == 1) - return 1; + if (cg == 0) + return (1); + + if (EXT2_HAS_COMPAT_FEATURE(fs, EXT2F_COMPAT_SPARSESUPER2)) { + if (cg == fs->e2fs->e4fs_backup_bgs[0] || + cg == fs->e2fs->e4fs_backup_bgs[1]) + return (1); + return (0); + } + + if ((cg <= 1) || + !EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_SPARSESUPER)) + return (1); + + if (!(cg & 1)) + return (0); + for (a3 = 3, a5 = 5, a7 = 7; - a3 <= i || a5 <= i || a7 <= i; + a3 <= cg || a5 <= cg || a7 <= cg; a3 *= 3, a5 *= 5, a7 *= 7) - if (i == a3 || i == a5 || i == a7) - return 1; - return 0; + if (cg == a3 || cg == a5 || cg == a7) + return (1); + return (0); } Copied: stable/11/sys/fs/ext2fs/ext2_csum.c (from r320145, head/sys/fs/ext2fs/ext2_csum.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/fs/ext2fs/ext2_csum.c Sun Aug 20 01:27:33 2017 (r322712, copy of r320145, head/sys/fs/ext2fs/ext2_csum.c) @@ -0,0 +1,147 @@ +/*- + * Copyright (c) 2017, Fedor Uporov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +static uint16_t +ext2_crc16(uint16_t crc, const void *buffer, unsigned int len) +{ + const unsigned char *cp = buffer; + /* CRC table for the CRC-16. The poly is 0x8005 (x16 + x15 + x2 + 1). */ + static uint16_t const crc16_table[256] = { + 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, + 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, + 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, + 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841, + 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40, + 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41, + 0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641, + 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040, + 0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240, + 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441, + 0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41, + 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840, + 0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41, + 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40, + 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640, + 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041, + 0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240, + 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441, + 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41, + 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840, + 0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41, + 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40, + 0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640, + 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041, + 0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241, + 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440, + 0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40, + 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841, + 0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40, + 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41, + 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641, + 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040 + }; + + while (len--) + crc = (((crc >> 8) & 0xffU) ^ + crc16_table[(crc ^ *cp++) & 0xffU]) & 0x0000ffffU; + return crc; +} + +static uint16_t +ext2_gd_csum(struct m_ext2fs *fs, uint32_t block_group, struct ext2_gd *gd) +{ + size_t offset; + uint16_t crc; + + offset = offsetof(struct ext2_gd, ext4bgd_csum); + + if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM)) { + crc = ext2_crc16(~0, fs->e2fs->e2fs_uuid, + sizeof(fs->e2fs->e2fs_uuid)); + crc = ext2_crc16(crc, (uint8_t *)&block_group, + sizeof(block_group)); + crc = ext2_crc16(crc, (uint8_t *)gd, offset); + offset += sizeof(gd->ext4bgd_csum); /* skip checksum */ + if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_64BIT) && + offset < fs->e2fs->e3fs_desc_size) + crc = ext2_crc16(crc, (uint8_t *)gd + offset, + fs->e2fs->e3fs_desc_size - offset); + return (crc); + } + + return (0); +} + +int +ext2_gd_csum_verify(struct m_ext2fs *fs, struct cdev *dev) +{ + unsigned int i; + int error = 0; + + for (i = 0; i < fs->e2fs_gcount; i++) { + if (fs->e2fs_gd[i].ext4bgd_csum != + ext2_gd_csum(fs, i, &fs->e2fs_gd[i])) { + printf( +"WARNING: mount of %s denied due bad gd=%d csum=0x%x, expected=0x%x - run fsck\n", + devtoname(dev), i, fs->e2fs_gd[i].ext4bgd_csum, + ext2_gd_csum(fs, i, &fs->e2fs_gd[i])); + error = EINVAL; + break; + } + } + + return (error); +} + +void +ext2_gd_csum_set(struct m_ext2fs *fs) +{ + unsigned int i; + + for (i = 0; i < fs->e2fs_gcount; i++) + fs->e2fs_gd[i].ext4bgd_csum = + ext2_gd_csum(fs, i, &fs->e2fs_gd[i]); +} Modified: stable/11/sys/fs/ext2fs/ext2_extern.h ============================================================================== --- stable/11/sys/fs/ext2fs/ext2_extern.h Sun Aug 20 01:08:23 2017 (r322711) +++ stable/11/sys/fs/ext2fs/ext2_extern.h Sun Aug 20 01:27:33 2017 (r322712) @@ -85,7 +85,7 @@ int ext2_dirrewrite(struct inode *, struct inode *, struct componentname *); int ext2_dirempty(struct inode *, ino_t, struct ucred *); int ext2_checkpath(struct inode *, struct inode *, struct ucred *); -int cg_has_sb(int i); +int ext2_cg_has_sb(struct m_ext2fs *fs, int cg); int ext2_inactive(struct vop_inactive_args *); int ext2_htree_add_entry(struct vnode *, struct ext2fs_direct_2 *, struct componentname *); @@ -98,6 +98,8 @@ int ext2_htree_lookup(struct inode *, const char *, in int *, doff_t *, doff_t *, doff_t *, struct ext2fs_searchslot *); int ext2_search_dirblock(struct inode *, void *, int *, const char *, int, int *, doff_t *, doff_t *, doff_t *, struct ext2fs_searchslot *); +int ext2_gd_csum_verify(struct m_ext2fs *fs, struct cdev *dev); +void ext2_gd_csum_set(struct m_ext2fs *fs); /* Flags to low-level allocation routines. Modified: stable/11/sys/fs/ext2fs/ext2_vfsops.c ============================================================================== --- stable/11/sys/fs/ext2fs/ext2_vfsops.c Sun Aug 20 01:08:23 2017 (r322711) +++ stable/11/sys/fs/ext2fs/ext2_vfsops.c Sun Aug 20 01:27:33 2017 (r322712) @@ -349,6 +349,13 @@ compute_sb_data(struct vnode *devvp, struct ext2fs *es printf("ext2fs: no space for extra inode timestamps\n"); return (EINVAL); } + /* Check for group descriptor size */ + if (EXT2_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_64BIT) && + (es->e3fs_desc_size != sizeof(struct ext2_gd))) { + printf("ext2fs: group descriptor size unsupported %d\n", + es->e3fs_desc_size); + return (EINVAL); + } fs->e2fs_ipb = fs->e2fs_bsize / EXT2_INODE_SIZE(fs); fs->e2fs_itpg = fs->e2fs_ipg / fs->e2fs_ipb; @@ -387,6 +394,12 @@ compute_sb_data(struct vnode *devvp, struct ext2fs *es brelse(bp); bp = NULL; } + /* Verify cg csum */ + if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM)) { + error = ext2_gd_csum_verify(fs, devvp->v_rdev); + if (error) + return (error); + } /* Initialization for the ext2 Orlov allocator variant. */ fs->e2fs_total_dir = 0; for (i = 0; i < fs->e2fs_gcount; i++) @@ -781,7 +794,7 @@ ext2_statfs(struct mount *mp, struct statfs *sbp) if (fs->e2fs->e2fs_rev > E2FS_REV0 && fs->e2fs->e2fs_features_rocompat & EXT2F_ROCOMPAT_SPARSESUPER) { for (i = 0, ngroups = 0; i < fs->e2fs_gcount; i++) { - if (cg_has_sb(i)) + if (ext2_cg_has_sb(fs, i)) ngroups++; } } else { @@ -1062,6 +1075,11 @@ ext2_cgupdate(struct ext2mount *mp, int waitfor) int i, error = 0, allerror = 0; allerror = ext2_sbupdate(mp, waitfor); + + /* Update gd csums */ + if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM)) + ext2_gd_csum_set(fs); + for (i = 0; i < fs->e2fs_gdbcount; i++) { bp = getblk(mp->um_devvp, fsbtodb(fs, fs->e2fs->e2fs_first_dblock + Modified: stable/11/sys/fs/ext2fs/ext2fs.h ============================================================================== --- stable/11/sys/fs/ext2fs/ext2fs.h Sun Aug 20 01:08:23 2017 (r322711) +++ stable/11/sys/fs/ext2fs/ext2fs.h Sun Aug 20 01:27:33 2017 (r322712) @@ -259,6 +259,7 @@ struct csum { #define EXT2F_COMPAT_SUPP EXT2F_COMPAT_DIRHASHINDEX #define EXT2F_ROCOMPAT_SUPP (EXT2F_ROCOMPAT_SPARSESUPER | \ EXT2F_ROCOMPAT_LARGEFILE | \ + EXT2F_ROCOMPAT_GDT_CSUM | \ EXT2F_ROCOMPAT_HUGE_FILE | \ EXT2F_ROCOMPAT_EXTRA_ISIZE) #define EXT2F_INCOMPAT_SUPP EXT2F_INCOMPAT_FTYPE @@ -293,6 +294,10 @@ struct csum { */ #define E2FS_SIGNED_HASH 0x0001 #define E2FS_UNSIGNED_HASH 0x0002 + +#define EXT2_BG_INODE_UNINIT 0x0001 /* Inode table/bitmap not in use */ +#define EXT2_BG_BLOCK_UNINIT 0x0002 /* Block bitmap not in use */ +#define EXT2_BG_INODE_ZEROED 0x0004 /* On-disk itable initialized to zero */ /* ext2 file system block group descriptor */ Modified: stable/11/sys/modules/ext2fs/Makefile ============================================================================== --- stable/11/sys/modules/ext2fs/Makefile Sun Aug 20 01:08:23 2017 (r322711) +++ stable/11/sys/modules/ext2fs/Makefile Sun Aug 20 01:27:33 2017 (r322712) @@ -3,8 +3,9 @@ .PATH: ${SRCTOP}/sys/fs/ext2fs KMOD= ext2fs SRCS= opt_ddb.h opt_directio.h opt_quota.h opt_suiddir.h vnode_if.h \ - ext2_acl.c ext2_alloc.c ext2_balloc.c ext2_bmap.c ext2_extattr.c \ - ext2_extents.c ext2_hash.c ext2_htree.c ext2_inode.c ext2_inode_cnv.c \ - ext2_lookup.c ext2_subr.c ext2_vfsops.c ext2_vnops.c + ext2_acl.c ext2_alloc.c ext2_balloc.c ext2_bmap.c ext2_csum.c \ + ext2_extattr.c ext2_extents.c ext2_hash.c ext2_htree.c \ + ext2_inode.c ext2_inode_cnv.c ext2_lookup.c ext2_subr.c \ + ext2_vfsops.c ext2_vnops.c .include From owner-svn-src-stable@freebsd.org Sun Aug 20 06:07:42 2017 Return-Path: Delivered-To: svn-src-stable@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 E11C8DE1B10; Sun, 20 Aug 2017 06:07:42 +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 9BDF374CBC; Sun, 20 Aug 2017 06:07:42 +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 v7K67fWO042778; Sun, 20 Aug 2017 06:07:41 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7K67eZN042764; Sun, 20 Aug 2017 06:07:40 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201708200607.v7K67eZN042764@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sun, 20 Aug 2017 06:07: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: r322715 - in stable/11: etc/mtree lib/libcasper lib/libcasper/services lib/libcasper/services/cap_dns lib/libcasper/services/cap_dns/tests lib/libcasper/services/cap_grp lib/libcasper/s... X-SVN-Group: stable-11 X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: in stable/11: etc/mtree lib/libcasper lib/libcasper/services lib/libcasper/services/cap_dns lib/libcasper/services/cap_dns/tests lib/libcasper/services/cap_grp lib/libcasper/services/cap_grp/tests lib... X-SVN-Commit-Revision: 322715 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Aug 2017 06:07:43 -0000 Author: ngie Date: Sun Aug 20 06:07:40 2017 New Revision: 322715 URL: https://svnweb.freebsd.org/changeset/base/322715 Log: MFC r305626,r305629,r307863,r322447,r322448,r322449,r322450,r322451: r305626 (by oshogbo): Move libcasper tests from regression/capsicum/libcasper/ to lib/libcasper/service/${service_name}/tests. r305629 (by jkim): Add new directories added in r305626 to fix "make installworld". r307863 (by emaste): Set SHLIBDIR before .including src.opts.mk in libcapser services bsd.own.mk (included from src.opts.mk) sets SHLIBDIR?=${LIBDIR}, so SHLIBDIR must be set before including either one of them. MFC with: 305626 r322447: Fix result printing - Flushing stdout prevents the buffer from being printed twice, fixing issues with stdout printing out the testplan, etc, twice. - Don't print out raw source/line numbers; hide them behind comments. r322448: Make root-privileges a requirement for the test Some of the testcases try to manipulate sysctls that require root privileges, e.g., "kern.sync_on_panic". Make root-privileges a hard requirement so the tests don't raise false positives due to privilege issues when calling sysctlbyname(3) on writable sysctls. r322449: Use hardcoded IPv4/IPv6 addresses for google-public-dns-a.google.com instead of freefall.freebsd.org to unbreak the DNS tests The address allocations for freefall.freebsd.org have changed in the past 4 years. Use a more stable set of hardcoded addresses for now to make the tests succeed reliably. The hostname should be resolved dynamically instead of hardcoding the addresses in the future. This is just a bandaid. r322450: Integrate the tests moved in r305626 in to the FreeBSD test suite The reachover Kyuafiles were never added, and thus the tests were installed as standalone tests, and not integrated into the full suite. MFC with: r305626, 305629, r307863, r322447, r322448, r322449 r322451: TESTSDIR isn't required; remove it MFC with: r322450 Added: stable/11/lib/libcasper/services/cap_dns/tests/ - copied from r305626, head/lib/libcasper/services/cap_dns/tests/ stable/11/lib/libcasper/services/cap_grp/tests/ - copied from r305626, head/lib/libcasper/services/cap_grp/tests/ stable/11/lib/libcasper/services/cap_pwd/tests/ - copied from r305626, head/lib/libcasper/services/cap_pwd/tests/ stable/11/lib/libcasper/services/cap_sysctl/tests/ - copied from r305626, head/lib/libcasper/services/cap_sysctl/tests/ stable/11/lib/libcasper/services/tests/ - copied from r322450, head/lib/libcasper/services/tests/ stable/11/lib/libcasper/tests/ - copied from r322450, head/lib/libcasper/tests/ Deleted: stable/11/tools/regression/capsicum/libcasper/ Modified: stable/11/etc/mtree/BSD.tests.dist stable/11/lib/libcasper/Makefile stable/11/lib/libcasper/services/Makefile stable/11/lib/libcasper/services/cap_dns/Makefile stable/11/lib/libcasper/services/cap_dns/tests/dns_test.c stable/11/lib/libcasper/services/cap_grp/Makefile stable/11/lib/libcasper/services/cap_grp/tests/grp_test.c stable/11/lib/libcasper/services/cap_pwd/Makefile stable/11/lib/libcasper/services/cap_pwd/tests/pwd_test.c stable/11/lib/libcasper/services/cap_sysctl/Makefile stable/11/lib/libcasper/services/cap_sysctl/tests/Makefile stable/11/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c stable/11/lib/libcasper/services/tests/Makefile stable/11/lib/libcasper/tests/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/etc/mtree/BSD.tests.dist ============================================================================== --- stable/11/etc/mtree/BSD.tests.dist Sun Aug 20 01:42:01 2017 (r322714) +++ stable/11/etc/mtree/BSD.tests.dist Sun Aug 20 06:07:40 2017 (r322715) @@ -316,6 +316,18 @@ .. libcam .. + libcasper + services + cap_dns + .. + cap_grp + .. + cap_pwd + .. + cap_sysctl + .. + .. + .. libcrypt .. libdevdctl Modified: stable/11/lib/libcasper/Makefile ============================================================================== --- stable/11/lib/libcasper/Makefile Sun Aug 20 01:42:01 2017 (r322714) +++ stable/11/lib/libcasper/Makefile Sun Aug 20 06:07:40 2017 (r322715) @@ -3,6 +3,8 @@ SUBDIR= libcasper SUBDIR+= services +SUBDIR.${MK_TESTS}+= tests + SUBDIR_PARALLEL= .include Modified: stable/11/lib/libcasper/services/Makefile ============================================================================== --- stable/11/lib/libcasper/services/Makefile Sun Aug 20 01:42:01 2017 (r322714) +++ stable/11/lib/libcasper/services/Makefile Sun Aug 20 06:07:40 2017 (r322715) @@ -6,6 +6,8 @@ SUBDIR+= cap_pwd SUBDIR+= cap_random SUBDIR+= cap_sysctl +SUBDIR.${MK_TESTS}+= tests + SUBDIR_PARALLEL= .include Modified: stable/11/lib/libcasper/services/cap_dns/Makefile ============================================================================== --- stable/11/lib/libcasper/services/cap_dns/Makefile Sun Aug 20 01:42:01 2017 (r322714) +++ stable/11/lib/libcasper/services/cap_dns/Makefile Sun Aug 20 06:07:40 2017 (r322715) @@ -1,10 +1,13 @@ # $FreeBSD$ +SHLIBDIR?= /lib/casper + +.include + PACKAGE=libcasper LIB= cap_dns SHLIB_MAJOR= 0 -SHLIBDIR?= /lib/casper INCSDIR?= ${INCLUDEDIR}/casper SRCS= cap_dns.c @@ -14,5 +17,9 @@ INCS= cap_dns.h LIBADD= nv CFLAGS+=-I${.CURDIR} + +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif .include Modified: stable/11/lib/libcasper/services/cap_dns/tests/dns_test.c ============================================================================== --- head/lib/libcasper/services/cap_dns/tests/dns_test.c Thu Sep 8 20:01:26 2016 (r305626) +++ stable/11/lib/libcasper/services/cap_dns/tests/dns_test.c Sun Aug 20 06:07:40 2017 (r322715) @@ -52,18 +52,20 @@ static int ntest = 1; #define CHECK(expr) do { \ if ((expr)) \ - printf("ok %d %s:%u\n", ntest, __FILE__, __LINE__); \ + printf("ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \ else \ - printf("not ok %d %s:%u\n", ntest, __FILE__, __LINE__); \ + printf("not ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \ + fflush(stdout); \ ntest++; \ } while (0) #define CHECKX(expr) do { \ if ((expr)) { \ - printf("ok %d %s:%u\n", ntest, __FILE__, __LINE__); \ + printf("ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \ } else { \ - printf("not ok %d %s:%u\n", ntest, __FILE__, __LINE__); \ + printf("not ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \ exit(1); \ } \ + fflush(stdout); \ ntest++; \ } while (0) @@ -295,32 +297,26 @@ runtest(cap_channel_t *capdns) freeaddrinfo(aic); } - /* - * 8.8.178.135 is IPv4 address of freefall.freebsd.org - * as of 27 October 2013. - */ - inet_pton(AF_INET, "8.8.178.135", &ip4); + /* XXX: hardcoded addresses for "google-public-dns-a.google.com". */ +#define GOOGLE_DNS_IPV4 "8.8.8.8" +#define GOOGLE_DNS_IPV6 "2001:4860:4860::8888" + + inet_pton(AF_INET, GOOGLE_DNS_IPV4, &ip4); hps = gethostbyaddr(&ip4, sizeof(ip4), AF_INET); if (hps == NULL) - fprintf(stderr, "Unable to resolve %s.\n", "8.8.178.135"); + fprintf(stderr, "Unable to resolve %s.\n", GOOGLE_DNS_IPV4); hpc = cap_gethostbyaddr(capdns, &ip4, sizeof(ip4), AF_INET); if (hostent_compare(hps, hpc)) result |= GETHOSTBYADDR_AF_INET; - /* - * 2001:1900:2254:206c::16:87 is IPv6 address of freefall.freebsd.org - * as of 27 October 2013. - */ - inet_pton(AF_INET6, "2001:1900:2254:206c::16:87", &ip6); + inet_pton(AF_INET6, GOOGLE_DNS_IPV6, &ip6); hps = gethostbyaddr(&ip6, sizeof(ip6), AF_INET6); if (hps == NULL) { - fprintf(stderr, "Unable to resolve %s.\n", - "2001:1900:2254:206c::16:87"); + fprintf(stderr, "Unable to resolve %s.\n", GOOGLE_DNS_IPV6); } hpc = cap_gethostbyaddr(capdns, &ip6, sizeof(ip6), AF_INET6); if (hostent_compare(hps, hpc)) result |= GETHOSTBYADDR_AF_INET6; - return (result); } @@ -332,6 +328,7 @@ main(void) int families[2]; printf("1..91\n"); + fflush(stdout); capcas = cap_init(); CHECKX(capcas != NULL); Modified: stable/11/lib/libcasper/services/cap_grp/Makefile ============================================================================== --- stable/11/lib/libcasper/services/cap_grp/Makefile Sun Aug 20 01:42:01 2017 (r322714) +++ stable/11/lib/libcasper/services/cap_grp/Makefile Sun Aug 20 06:07:40 2017 (r322715) @@ -1,10 +1,13 @@ # $FreeBSD$ +SHLIBDIR?= /lib/casper + +.include + PACKAGE=libcasper LIB= cap_grp SHLIB_MAJOR= 0 -SHLIBDIR?= /lib/casper INCSDIR?= ${INCLUDEDIR}/casper SRCS= cap_grp.c @@ -14,5 +17,9 @@ INCS= cap_grp.h LIBADD= nv CFLAGS+=-I${.CURDIR} + +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif .include Modified: stable/11/lib/libcasper/services/cap_grp/tests/grp_test.c ============================================================================== --- head/lib/libcasper/services/cap_grp/tests/grp_test.c Thu Sep 8 20:01:26 2016 (r305626) +++ stable/11/lib/libcasper/services/cap_grp/tests/grp_test.c Sun Aug 20 06:07:40 2017 (r322715) @@ -52,6 +52,7 @@ static int ntest = 1; printf("ok %d %s:%u\n", ntest, __FILE__, __LINE__); \ else \ printf("not ok %d %s:%u\n", ntest, __FILE__, __LINE__); \ + fflush(stdout); \ ntest++; \ } while (0) #define CHECKX(expr) do { \ @@ -61,6 +62,7 @@ static int ntest = 1; printf("not ok %d %s:%u\n", ntest, __FILE__, __LINE__); \ exit(1); \ } \ + fflush(stdout); \ ntest++; \ } while (0) @@ -1524,6 +1526,7 @@ main(void) cap_channel_t *capcas, *capgrp; printf("1..199\n"); + fflush(stdout); capcas = cap_init(); CHECKX(capcas != NULL); Modified: stable/11/lib/libcasper/services/cap_pwd/Makefile ============================================================================== --- stable/11/lib/libcasper/services/cap_pwd/Makefile Sun Aug 20 01:42:01 2017 (r322714) +++ stable/11/lib/libcasper/services/cap_pwd/Makefile Sun Aug 20 06:07:40 2017 (r322715) @@ -1,10 +1,13 @@ # $FreeBSD$ +SHLIBDIR?= /lib/casper + +.include + PACKAGE=libcasper LIB= cap_pwd SHLIB_MAJOR= 0 -SHLIBDIR?= /lib/casper INCSDIR?= ${INCLUDEDIR}/casper SRCS= cap_pwd.c @@ -14,5 +17,9 @@ INCS= cap_pwd.h LIBADD= nv CFLAGS+=-I${.CURDIR} + +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif .include Modified: stable/11/lib/libcasper/services/cap_pwd/tests/pwd_test.c ============================================================================== --- head/lib/libcasper/services/cap_pwd/tests/pwd_test.c Thu Sep 8 20:01:26 2016 (r305626) +++ stable/11/lib/libcasper/services/cap_pwd/tests/pwd_test.c Sun Aug 20 06:07:40 2017 (r322715) @@ -49,18 +49,20 @@ static int ntest = 1; #define CHECK(expr) do { \ if ((expr)) \ - printf("ok %d %s:%u\n", ntest, __FILE__, __LINE__); \ + printf("ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \ else \ - printf("not ok %d %s:%u\n", ntest, __FILE__, __LINE__);\ + printf("not ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \ + fflush(stdout); \ ntest++; \ } while (0) #define CHECKX(expr) do { \ if ((expr)) { \ - printf("ok %d %s:%u\n", ntest, __FILE__, __LINE__); \ + printf("ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \ } else { \ - printf("not ok %d %s:%u\n", ntest, __FILE__, __LINE__);\ + printf("not ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \ exit(1); \ } \ + fflush(stdout); \ ntest++; \ } while (0) @@ -1510,6 +1512,7 @@ main(void) cap_channel_t *capcas, *cappwd; printf("1..188\n"); + fflush(stdout); capcas = cap_init(); CHECKX(capcas != NULL); Modified: stable/11/lib/libcasper/services/cap_sysctl/Makefile ============================================================================== --- stable/11/lib/libcasper/services/cap_sysctl/Makefile Sun Aug 20 01:42:01 2017 (r322714) +++ stable/11/lib/libcasper/services/cap_sysctl/Makefile Sun Aug 20 06:07:40 2017 (r322715) @@ -1,10 +1,13 @@ # $FreeBSD$ +SHLIBDIR?= /lib/casper + +.include + PACKAGE=libcasper LIB= cap_sysctl SHLIB_MAJOR= 0 -SHLIBDIR?= /lib/casper INCSDIR?= ${INCLUDEDIR}/casper SRCS= cap_sysctl.c @@ -14,5 +17,9 @@ INCS= cap_sysctl.h LIBADD= nv CFLAGS+=-I${.CURDIR} + +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif .include Modified: stable/11/lib/libcasper/services/cap_sysctl/tests/Makefile ============================================================================== --- head/lib/libcasper/services/cap_sysctl/tests/Makefile Thu Sep 8 20:01:26 2016 (r305626) +++ stable/11/lib/libcasper/services/cap_sysctl/tests/Makefile Sun Aug 20 06:07:40 2017 (r322715) @@ -8,4 +8,6 @@ LIBADD+= nv WARNS?= 3 +TEST_METADATA.sysctl_test+= required_user="root" + .include Modified: stable/11/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c ============================================================================== --- head/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c Thu Sep 8 20:01:26 2016 (r305626) +++ stable/11/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c Sun Aug 20 06:07:40 2017 (r322715) @@ -61,18 +61,20 @@ static int ntest = 1; #define CHECK(expr) do { \ if ((expr)) \ - printf("ok %d %s:%u\n", ntest, __FILE__, __LINE__); \ + printf("ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \ else \ - printf("not ok %d %s:%u\n", ntest, __FILE__, __LINE__); \ + printf("not ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \ + fflush(stdout); \ ntest++; \ } while (0) #define CHECKX(expr) do { \ if ((expr)) { \ - printf("ok %d %s:%u\n", ntest, __FILE__, __LINE__); \ + printf("ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \ } else { \ - printf("not ok %d %s:%u\n", ntest, __FILE__, __LINE__); \ + printf("not ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \ exit(1); \ } \ + fflush(stdout); \ ntest++; \ } while (0) @@ -1472,6 +1474,7 @@ main(void) size_t scsize; printf("1..256\n"); + fflush(stdout); scsize = sizeof(scvalue0); CHECKX(sysctlbyname(SYSCTL0_NAME, &scvalue0, &scsize, NULL, 0) == 0); Modified: stable/11/lib/libcasper/services/tests/Makefile ============================================================================== --- head/lib/libcasper/services/tests/Makefile Sun Aug 13 01:04:44 2017 (r322450) +++ stable/11/lib/libcasper/services/tests/Makefile Sun Aug 20 06:07:40 2017 (r322715) @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libcasper/services - .PATH: ${SRCTOP}/tests KYUAFILE= yes Modified: stable/11/lib/libcasper/tests/Makefile ============================================================================== --- head/lib/libcasper/tests/Makefile Sun Aug 13 01:04:44 2017 (r322450) +++ stable/11/lib/libcasper/tests/Makefile Sun Aug 20 06:07:40 2017 (r322715) @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libcasper - .PATH: ${SRCTOP}/tests KYUAFILE= yes From owner-svn-src-stable@freebsd.org Sun Aug 20 07:04:25 2017 Return-Path: Delivered-To: svn-src-stable@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 391A8DE3F6B; Sun, 20 Aug 2017 07:04:25 +0000 (UTC) (envelope-from delphij@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 ED2477664D; Sun, 20 Aug 2017 07:04:24 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7K74OGK066765; Sun, 20 Aug 2017 07:04:24 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7K74OMW066764; Sun, 20 Aug 2017 07:04:24 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201708200704.v7K74OMW066764@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Sun, 20 Aug 2017 07:04: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: r322716 - stable/11/sys/mips/atheros X-SVN-Group: stable-11 X-SVN-Commit-Author: delphij X-SVN-Commit-Paths: stable/11/sys/mips/atheros X-SVN-Commit-Revision: 322716 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Aug 2017 07:04:25 -0000 Author: delphij Date: Sun Aug 20 07:04:23 2017 New Revision: 322716 URL: https://svnweb.freebsd.org/changeset/base/322716 Log: MFC r322527: Plug memory leak in arge_encap(). Reported by: Ilja Van Sprundel Submitted by: Domagoj Stolfa Reviewed by: adrian Modified: stable/11/sys/mips/atheros/if_arge.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/mips/atheros/if_arge.c ============================================================================== --- stable/11/sys/mips/atheros/if_arge.c Sun Aug 20 06:07:40 2017 (r322715) +++ stable/11/sys/mips/atheros/if_arge.c Sun Aug 20 07:04:23 2017 (r322716) @@ -1515,6 +1515,7 @@ arge_encap(struct arge_softc *sc, struct mbuf **m_head sc->stats.tx_pkts_unaligned++; m = m_defrag(*m_head, M_NOWAIT); if (m == NULL) { + m_freem(*m_head); *m_head = NULL; return (ENOBUFS); } From owner-svn-src-stable@freebsd.org Sun Aug 20 16:52:29 2017 Return-Path: Delivered-To: svn-src-stable@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 3D27DDDF731; Sun, 20 Aug 2017 16:52:29 +0000 (UTC) (envelope-from marius@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 E82826B701; Sun, 20 Aug 2017 16:52:28 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7KGqRhl014309; Sun, 20 Aug 2017 16:52:27 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7KGqRNo014303; Sun, 20 Aug 2017 16:52:27 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201708201652.v7KGqRNo014303@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Sun, 20 Aug 2017 16:52:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r322724 - in stable/10/sys: arm/broadcom/bcm2835 conf dev/usb/controller dev/usb/net X-SVN-Group: stable-10 X-SVN-Commit-Author: marius X-SVN-Commit-Paths: in stable/10/sys: arm/broadcom/bcm2835 conf dev/usb/controller dev/usb/net X-SVN-Commit-Revision: 322724 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Aug 2017 16:52:29 -0000 Author: marius Date: Sun Aug 20 16:52:27 2017 New Revision: 322724 URL: https://svnweb.freebsd.org/changeset/base/322724 Log: MFC: r266470, r273546, r276017, r277932, r279153, r279778, r279780, r278797, r278861, r280283, r280284, r280294, r280452, r280558, r280571, r281863, r282049, r282357, r282440, r282441, r282358, r282359, r283550, r283918, r290171, r290667, r290381, r290533, r290666, r292483, r295659, r297545, r298305, r298383, r298428, r306489, r306557, r307067, r307068, r307087, r307088, r307089, r307091, r307092, r307093, r307098, r307115, r307154, r307240, r307241, r315967, r316476 Unbreak BCM2835/RPI-B support by bringing it in line with stable/11 and head: - Optimise reading of pending interrupt registers. - Fix a bug where some DTS layouts could cause the premature ending of the search (i.e. without returning any result) and you would end up with a random MAC address. - Reduce the diff between head and arm_intrng with the bcm2835 interrupt controller. - Allow the retrieving of the reserved pins state. - Add support to the bcm2835 mailbox driver to work before interrupts are enabled. This will be needed to enable the power on devices early on in the boot process. - Add support for enabling the USB on the Raspberry Pi boards when it hasn't been done by U-Boot. This allows the USB to work when we load the kernel directly. - Call config_intrhook_disestablish on failure of the bcm2835 fb and fbd intr hooks. With this we can get through the boot even if these functions fail. - Add the structures needed to get/set the power state. These can be used when, for example, we boot without U-Boot and wish to enable USB, or to suspend an unneeded device. - Add a mask to match only the relative base address of BSC controllers. - Move the code to set the device power to the bcm2835 mailbox driver so it can be reused by other drivers. - Add the SOC_BCM2835 and SOC_BCM2836 options for the arm kernel and add the former to std.bcm2835. - Add a helper function to read clock frequencies from videocore and use this to get the default frequency of the sdhci device. - Add partial support for the Raspberry Pi 2. - Remove a debug #error from the bcm2835 sdhci driver. - Fetch the SDHCI frequency from videocore (our prefered source) and only if it fails, fetch the clock-frequency from DTB. If both methods fail, use the hardcoded default. - Pass the supplied buffer length instead of a fixed size. - Add the routines to query and setup the framebuffer state using the BCM2835_MBOX_CHAN_PROP channel. The old channel (BCM2835_MBOX_CHAN_FB) seems deprecated on recent firmware versions and is causing a freeze on RPi 2. - Fix DMA on RPi 2. BCM2836 has a different base address for peripherals. - Enable DMA for sdhci on RPi 2 (BCM2836). - Add a missing wakeup when releasing ownership of the SPI hardware. - Fix framebuffer compatibility with new RPi firmware. - Refactor bcm2835_cpufreq to use bcm2835_mbox_property API. - Fix the sc(4) framebuffer driver on RPi 2. - Fix the vt(4) framebuffer driver on RPi 2. - Remove unused mutex and softc variables. - Refactor mailbox property API to make it usable for /dev/vcio driver. - Replace semaphore-base locking with sleep/wait synchronization. - Fix infinite loop if response from VideoCore never received. - Set have_message in interrupt to handle "response before READ" case. - Serialize access to property channel when using bcm2835_mbox_property. - Force framebuffer virtual viewport to be the same as physical. - Use proper type of tag in bcm2835_mbox_fb_init. - bcm2835_cpufreq: Only attach driver if we correcly match on the machine compatible string. - Add dev.fb.X.resync sysctl to resync ARM framebuffer with VideoCore. - Do not use DMA channels used by GPU. - Define local-intc for BCM2836 platform (RPI2) and make BCM2835 intc a child of it. - Fix build for Pi kernels with syscons enabled. - Use VM_MEMATTR_WRITE_COMBINING memattr for mmap(2) on framebuffer. - Make intc driver compatible with upstream DTS. - Make Rapsberry Pi watchdog driver compatible with upstream DTS. - Make sure intc is attached before interrupt consumers. - Make framebuffer driver compatible with upstream DT. - Add one more heuristic to determine MAC address of the SMSC device. - Add compatibility strings from upstream DT. - Fix spelling mistake, BCM2835_PASWORD -> BCM2835_PASSWORD. Approved by: re (kib) Added: stable/10/sys/arm/broadcom/bcm2835/bcm2836.c - copied unchanged from r280558, head/sys/arm/broadcom/bcm2835/bcm2836.c stable/10/sys/arm/broadcom/bcm2835/bcm2836.h - copied unchanged from r280558, head/sys/arm/broadcom/bcm2835/bcm2836.h stable/10/sys/arm/broadcom/bcm2835/bcm283x_dwc_fdt.c - copied, changed from r279778, head/sys/arm/broadcom/bcm2835/bcm283x_dwc_fdt.c stable/10/sys/arm/broadcom/bcm2835/files.bcm2836 - copied unchanged from r280558, head/sys/arm/broadcom/bcm2835/files.bcm2836 stable/10/sys/arm/broadcom/bcm2835/std.bcm2836 - copied unchanged from r280558, head/sys/arm/broadcom/bcm2835/std.bcm2836 stable/10/sys/dev/usb/controller/dwc_otg_fdt.h - copied unchanged from r279778, head/sys/dev/usb/controller/dwc_otg_fdt.h Modified: stable/10/sys/arm/broadcom/bcm2835/bcm2835_bsc.c stable/10/sys/arm/broadcom/bcm2835/bcm2835_bscvar.h stable/10/sys/arm/broadcom/bcm2835/bcm2835_common.c stable/10/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c stable/10/sys/arm/broadcom/bcm2835/bcm2835_dma.c stable/10/sys/arm/broadcom/bcm2835/bcm2835_dma.h stable/10/sys/arm/broadcom/bcm2835/bcm2835_fb.c stable/10/sys/arm/broadcom/bcm2835/bcm2835_fbd.c stable/10/sys/arm/broadcom/bcm2835/bcm2835_gpio.c stable/10/sys/arm/broadcom/bcm2835/bcm2835_intr.c stable/10/sys/arm/broadcom/bcm2835/bcm2835_machdep.c stable/10/sys/arm/broadcom/bcm2835/bcm2835_mbox.c stable/10/sys/arm/broadcom/bcm2835/bcm2835_mbox_prop.h stable/10/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c stable/10/sys/arm/broadcom/bcm2835/bcm2835_spi.c stable/10/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h stable/10/sys/arm/broadcom/bcm2835/bcm2835_wdog.c stable/10/sys/arm/broadcom/bcm2835/files.bcm2835 stable/10/sys/arm/broadcom/bcm2835/std.bcm2835 stable/10/sys/conf/options.arm stable/10/sys/dev/usb/controller/dwc_otg_fdt.c stable/10/sys/dev/usb/net/if_smsc.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/arm/broadcom/bcm2835/bcm2835_bsc.c ============================================================================== --- stable/10/sys/arm/broadcom/bcm2835/bcm2835_bsc.c Sun Aug 20 11:18:16 2017 (r322723) +++ stable/10/sys/arm/broadcom/bcm2835/bcm2835_bsc.c Sun Aug 20 16:52:27 2017 (r322724) @@ -52,6 +52,13 @@ __FBSDID("$FreeBSD$"); #include "iicbus_if.h" +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-bsc", 1}, + {"brcm,bcm2708-i2c", 1}, + {"brcm,bcm2835-i2c", 1}, + {NULL, 0} +}; + static void bcm_bsc_intr(void *); static int bcm_bsc_detach(device_t); @@ -214,7 +221,7 @@ bcm_bsc_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-bsc")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); device_set_desc(dev, "BCM2708/2835 BSC controller"); @@ -247,7 +254,7 @@ bcm_bsc_attach(device_t dev) /* Check the unit we are attaching by its base address. */ start = rman_get_start(sc->sc_mem_res); for (i = 0; i < nitems(bcm_bsc_pins); i++) { - if (bcm_bsc_pins[i].start == start) + if (bcm_bsc_pins[i].start == (start & BCM_BSC_BASE_MASK)) break; } if (i == nitems(bcm_bsc_pins)) { Modified: stable/10/sys/arm/broadcom/bcm2835/bcm2835_bscvar.h ============================================================================== --- stable/10/sys/arm/broadcom/bcm2835/bcm2835_bscvar.h Sun Aug 20 11:18:16 2017 (r322723) +++ stable/10/sys/arm/broadcom/bcm2835/bcm2835_bscvar.h Sun Aug 20 16:52:27 2017 (r322724) @@ -35,9 +35,10 @@ struct { uint32_t scl; unsigned long start; } bcm_bsc_pins[] = { - { 0, 1, 0x20205000 }, /* BSC0 GPIO pins and base address. */ - { 2, 3, 0x20804000 } /* BSC1 GPIO pins and base address. */ + { 0, 1, 0x205000 }, /* BSC0 GPIO pins and base address. */ + { 2, 3, 0x804000 } /* BSC1 GPIO pins and base address. */ }; +#define BCM_BSC_BASE_MASK 0x00ffffff struct bcm_bsc_softc { device_t sc_dev; Modified: stable/10/sys/arm/broadcom/bcm2835/bcm2835_common.c ============================================================================== --- stable/10/sys/arm/broadcom/bcm2835/bcm2835_common.c Sun Aug 20 11:18:16 2017 (r322723) +++ stable/10/sys/arm/broadcom/bcm2835/bcm2835_common.c Sun Aug 20 16:52:27 2017 (r322724) @@ -58,14 +58,22 @@ fdt_intc_decode_ic(phandle_t node, pcell_t *intr, int int *pol) { - if (!fdt_is_compatible(node, "broadcom,bcm2835-armctrl-ic")) - return (ENXIO); - - *interrupt = fdt32_to_cpu(intr[0]); - *trig = INTR_TRIGGER_CONFORM; - *pol = INTR_POLARITY_CONFORM; - - return (0); + if (fdt_is_compatible(node, "broadcom,bcm2835-armctrl-ic") || + fdt_is_compatible(node, "brcm,bcm2836-armctrl-ic")) { + *interrupt = fdt32_to_cpu(intr[0]); + *trig = INTR_TRIGGER_CONFORM; + *pol = INTR_POLARITY_CONFORM; + return (0); + } +#ifdef SOC_BCM2836 + if (fdt_is_compatible(node, "brcm,bcm2836-l1-intc")) { + *interrupt = fdt32_to_cpu(intr[0]) + 72; + *trig = INTR_TRIGGER_CONFORM; + *pol = INTR_POLARITY_CONFORM; + return (0); + } +#endif + return (ENXIO); } Modified: stable/10/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c ============================================================================== --- stable/10/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c Sun Aug 20 11:18:16 2017 (r322723) +++ stable/10/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c Sun Aug 20 16:52:27 2017 (r322724) @@ -44,6 +44,11 @@ __FBSDID("$FreeBSD$"); #include #include +#include + +#include +#include + #include #include #include @@ -108,17 +113,17 @@ struct bcm2835_cpufreq_softc { int voltage_sdram_p; int turbo_mode; - /* mbox buffer (physical address) */ - bus_dma_tag_t dma_tag; - bus_dmamap_t dma_map; - bus_size_t dma_size; - void *dma_buf; - bus_addr_t dma_phys; - /* initial hook for waiting mbox intr */ struct intr_config_hook init_hook; }; +static struct ofw_compat_data compat_data[] = { + { "broadcom,bcm2835-vc", 1 }, + { "broadcom,bcm2708-vc", 1 }, + { "brcm,bcm2709", 1 }, + { NULL, 0 } +}; + static int cpufreq_verbose = 0; TUNABLE_INT("hw.bcm2835.cpufreq.verbose", &cpufreq_verbose); static int cpufreq_lowest_freq = DEFAULT_LOWEST_FREQ; @@ -144,84 +149,10 @@ bcm2835_dump(const void *data, int len) #endif static int -bcm2835_mbox_call_prop(struct bcm2835_cpufreq_softc *sc) -{ - struct bcm2835_mbox_hdr *msg = (struct bcm2835_mbox_hdr *)sc->dma_buf; - struct bcm2835_mbox_tag_hdr *tag, *last; - uint8_t *up; - device_t mbox; - size_t hdr_size; - int idx; - int err; - - /* - * For multiple calls, locking is not here. The caller must have - * VC semaphore. - */ - - /* get mbox device */ - mbox = devclass_get_device(devclass_find("mbox"), 0); - if (mbox == NULL) { - device_printf(sc->dev, "can't find mbox\n"); - return (-1); - } - - /* go mailbox property */ -#ifdef PROP_DEBUG - bcm2835_dump(msg, 64); -#endif - bus_dmamap_sync(sc->dma_tag, sc->dma_map, - BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); - MBOX_WRITE(mbox, BCM2835_MBOX_CHAN_PROP, (uint32_t)sc->dma_phys); - MBOX_READ(mbox, BCM2835_MBOX_CHAN_PROP, &err); - bus_dmamap_sync(sc->dma_tag, sc->dma_map, BUS_DMASYNC_POSTREAD); -#ifdef PROP_DEBUG - bcm2835_dump(msg, 64); -#endif - - /* check response code */ - if (msg->code != BCM2835_MBOX_CODE_RESP_SUCCESS) { - device_printf(sc->dev, "mbox response error\n"); - return (-1); - } - - /* tag = first tag */ - up = (uint8_t *)msg; - hdr_size = sizeof(struct bcm2835_mbox_hdr); - tag = (struct bcm2835_mbox_tag_hdr *)(up + hdr_size); - /* last = end of buffer specified by header */ - last = (struct bcm2835_mbox_tag_hdr *)(up + msg->buf_size); - - /* loop unitl end tag (=0x0) */ - hdr_size = sizeof(struct bcm2835_mbox_tag_hdr); - for (idx = 0; tag->tag != 0; idx++) { - if ((tag->val_len & BCM2835_MBOX_TAG_VAL_LEN_RESPONSE) == 0) { - device_printf(sc->dev, "tag%d response error\n", idx); - return (-1); - } - /* clear response bit */ - tag->val_len &= ~BCM2835_MBOX_TAG_VAL_LEN_RESPONSE; - - /* get next tag */ - up = (uint8_t *)tag; - tag = (struct bcm2835_mbox_tag_hdr *)(up + hdr_size + - tag->val_buf_size); - - /* check buffer size of header */ - if (tag > last) { - device_printf(sc->dev, "mbox buffer size error\n"); - return (-1); - } - } - - return (0); -} - -static int bcm2835_cpufreq_get_clock_rate(struct bcm2835_cpufreq_softc *sc, uint32_t clock_id) { - struct msg_get_clock_rate *msg; + struct msg_get_clock_rate msg; int rate; int err; @@ -239,26 +170,18 @@ bcm2835_cpufreq_get_clock_rate(struct bcm2835_cpufreq_ * u32: rate (in Hz) */ - /* using DMA buffer for VC */ - msg = (struct msg_get_clock_rate *)sc->dma_buf; - if (sizeof(*msg) > sc->dma_size) { - device_printf(sc->dev, "DMA size overflow (%zu>%lu)\n", - sizeof(*msg), sc->dma_size); - return (MSG_ERROR); - } - /* setup single tag buffer */ - memset(msg, 0, sizeof(*msg)); - msg->hdr.buf_size = sizeof(*msg); - msg->hdr.code = BCM2835_MBOX_CODE_REQ; - msg->tag_hdr.tag = BCM2835_MBOX_TAG_GET_CLOCK_RATE; - msg->tag_hdr.val_buf_size = sizeof(msg->body); - msg->tag_hdr.val_len = sizeof(msg->body.req); - msg->body.req.clock_id = clock_id; - msg->end_tag = 0; + memset(&msg, 0, sizeof(msg)); + msg.hdr.buf_size = sizeof(msg); + msg.hdr.code = BCM2835_MBOX_CODE_REQ; + msg.tag_hdr.tag = BCM2835_MBOX_TAG_GET_CLOCK_RATE; + msg.tag_hdr.val_buf_size = sizeof(msg.body); + msg.tag_hdr.val_len = sizeof(msg.body.req); + msg.body.req.clock_id = clock_id; + msg.end_tag = 0; /* call mailbox property */ - err = bcm2835_mbox_call_prop(sc); + err = bcm2835_mbox_property(&msg, sizeof(msg)); if (err) { device_printf(sc->dev, "can't get clock rate (id=%u)\n", clock_id); @@ -266,7 +189,7 @@ bcm2835_cpufreq_get_clock_rate(struct bcm2835_cpufreq_ } /* result (Hz) */ - rate = (int)msg->body.resp.rate_hz; + rate = (int)msg.body.resp.rate_hz; DPRINTF("clock = %d(Hz)\n", rate); return (rate); } @@ -275,7 +198,7 @@ static int bcm2835_cpufreq_get_max_clock_rate(struct bcm2835_cpufreq_softc *sc, uint32_t clock_id) { - struct msg_get_max_clock_rate *msg; + struct msg_get_max_clock_rate msg; int rate; int err; @@ -293,26 +216,18 @@ bcm2835_cpufreq_get_max_clock_rate(struct bcm2835_cpuf * u32: rate (in Hz) */ - /* using DMA buffer for VC */ - msg = (struct msg_get_max_clock_rate *)sc->dma_buf; - if (sizeof(*msg) > sc->dma_size) { - device_printf(sc->dev, "DMA size overflow (%zu>%lu)\n", - sizeof(*msg), sc->dma_size); - return (MSG_ERROR); - } - /* setup single tag buffer */ - memset(msg, 0, sizeof(*msg)); - msg->hdr.buf_size = sizeof(*msg); - msg->hdr.code = BCM2835_MBOX_CODE_REQ; - msg->tag_hdr.tag = BCM2835_MBOX_TAG_GET_MAX_CLOCK_RATE; - msg->tag_hdr.val_buf_size = sizeof(msg->body); - msg->tag_hdr.val_len = sizeof(msg->body.req); - msg->body.req.clock_id = clock_id; - msg->end_tag = 0; + memset(&msg, 0, sizeof(msg)); + msg.hdr.buf_size = sizeof(msg); + msg.hdr.code = BCM2835_MBOX_CODE_REQ; + msg.tag_hdr.tag = BCM2835_MBOX_TAG_GET_MAX_CLOCK_RATE; + msg.tag_hdr.val_buf_size = sizeof(msg.body); + msg.tag_hdr.val_len = sizeof(msg.body.req); + msg.body.req.clock_id = clock_id; + msg.end_tag = 0; /* call mailbox property */ - err = bcm2835_mbox_call_prop(sc); + err = bcm2835_mbox_property(&msg, sizeof(msg)); if (err) { device_printf(sc->dev, "can't get max clock rate (id=%u)\n", clock_id); @@ -320,7 +235,7 @@ bcm2835_cpufreq_get_max_clock_rate(struct bcm2835_cpuf } /* result (Hz) */ - rate = (int)msg->body.resp.rate_hz; + rate = (int)msg.body.resp.rate_hz; DPRINTF("clock = %d(Hz)\n", rate); return (rate); } @@ -329,7 +244,7 @@ static int bcm2835_cpufreq_get_min_clock_rate(struct bcm2835_cpufreq_softc *sc, uint32_t clock_id) { - struct msg_get_min_clock_rate *msg; + struct msg_get_min_clock_rate msg; int rate; int err; @@ -347,26 +262,18 @@ bcm2835_cpufreq_get_min_clock_rate(struct bcm2835_cpuf * u32: rate (in Hz) */ - /* using DMA buffer for VC */ - msg = (struct msg_get_min_clock_rate *)sc->dma_buf; - if (sizeof(*msg) > sc->dma_size) { - device_printf(sc->dev, "DMA size overflow (%zu>%lu)\n", - sizeof(*msg), sc->dma_size); - return (MSG_ERROR); - } - /* setup single tag buffer */ - memset(msg, 0, sizeof(*msg)); - msg->hdr.buf_size = sizeof(*msg); - msg->hdr.code = BCM2835_MBOX_CODE_REQ; - msg->tag_hdr.tag = BCM2835_MBOX_TAG_GET_MIN_CLOCK_RATE; - msg->tag_hdr.val_buf_size = sizeof(msg->body); - msg->tag_hdr.val_len = sizeof(msg->body.req); - msg->body.req.clock_id = clock_id; - msg->end_tag = 0; + memset(&msg, 0, sizeof(msg)); + msg.hdr.buf_size = sizeof(msg); + msg.hdr.code = BCM2835_MBOX_CODE_REQ; + msg.tag_hdr.tag = BCM2835_MBOX_TAG_GET_MIN_CLOCK_RATE; + msg.tag_hdr.val_buf_size = sizeof(msg.body); + msg.tag_hdr.val_len = sizeof(msg.body.req); + msg.body.req.clock_id = clock_id; + msg.end_tag = 0; /* call mailbox property */ - err = bcm2835_mbox_call_prop(sc); + err = bcm2835_mbox_property(&msg, sizeof(msg)); if (err) { device_printf(sc->dev, "can't get min clock rate (id=%u)\n", clock_id); @@ -374,7 +281,7 @@ bcm2835_cpufreq_get_min_clock_rate(struct bcm2835_cpuf } /* result (Hz) */ - rate = (int)msg->body.resp.rate_hz; + rate = (int)msg.body.resp.rate_hz; DPRINTF("clock = %d(Hz)\n", rate); return (rate); } @@ -383,7 +290,7 @@ static int bcm2835_cpufreq_set_clock_rate(struct bcm2835_cpufreq_softc *sc, uint32_t clock_id, uint32_t rate_hz) { - struct msg_set_clock_rate *msg; + struct msg_set_clock_rate msg; int rate; int err; @@ -402,27 +309,19 @@ bcm2835_cpufreq_set_clock_rate(struct bcm2835_cpufreq_ * u32: rate (in Hz) */ - /* using DMA buffer for VC */ - msg = (struct msg_set_clock_rate *)sc->dma_buf; - if (sizeof(*msg) > sc->dma_size) { - device_printf(sc->dev, "DMA size overflow (%zu>%lu)\n", - sizeof(*msg), sc->dma_size); - return (MSG_ERROR); - } - /* setup single tag buffer */ - memset(msg, 0, sizeof(*msg)); - msg->hdr.buf_size = sizeof(*msg); - msg->hdr.code = BCM2835_MBOX_CODE_REQ; - msg->tag_hdr.tag = BCM2835_MBOX_TAG_SET_CLOCK_RATE; - msg->tag_hdr.val_buf_size = sizeof(msg->body); - msg->tag_hdr.val_len = sizeof(msg->body.req); - msg->body.req.clock_id = clock_id; - msg->body.req.rate_hz = rate_hz; - msg->end_tag = 0; + memset(&msg, 0, sizeof(msg)); + msg.hdr.buf_size = sizeof(msg); + msg.hdr.code = BCM2835_MBOX_CODE_REQ; + msg.tag_hdr.tag = BCM2835_MBOX_TAG_SET_CLOCK_RATE; + msg.tag_hdr.val_buf_size = sizeof(msg.body); + msg.tag_hdr.val_len = sizeof(msg.body.req); + msg.body.req.clock_id = clock_id; + msg.body.req.rate_hz = rate_hz; + msg.end_tag = 0; /* call mailbox property */ - err = bcm2835_mbox_call_prop(sc); + err = bcm2835_mbox_property(&msg, sizeof(msg)); if (err) { device_printf(sc->dev, "can't set clock rate (id=%u)\n", clock_id); @@ -440,18 +339,18 @@ bcm2835_cpufreq_set_clock_rate(struct bcm2835_cpufreq_ */ /* setup single tag buffer */ - memset(msg, 0, sizeof(*msg)); - msg->hdr.buf_size = sizeof(*msg); - msg->hdr.code = BCM2835_MBOX_CODE_REQ; - msg->tag_hdr.tag = BCM2835_MBOX_TAG_SET_CLOCK_RATE; - msg->tag_hdr.val_buf_size = sizeof(msg->body); - msg->tag_hdr.val_len = sizeof(msg->body.req); - msg->body.req.clock_id = clock_id; - msg->body.req.rate_hz = rate_hz; - msg->end_tag = 0; + memset(&msg, 0, sizeof(msg)); + msg.hdr.buf_size = sizeof(msg); + msg.hdr.code = BCM2835_MBOX_CODE_REQ; + msg.tag_hdr.tag = BCM2835_MBOX_TAG_SET_CLOCK_RATE; + msg.tag_hdr.val_buf_size = sizeof(msg.body); + msg.tag_hdr.val_len = sizeof(msg.body.req); + msg.body.req.clock_id = clock_id; + msg.body.req.rate_hz = rate_hz; + msg.end_tag = 0; /* call mailbox property */ - err = bcm2835_mbox_call_prop(sc); + err = bcm2835_mbox_property(&msg, sizeof(msg)); if (err) { device_printf(sc->dev, "can't set clock rate (id=%u)\n", clock_id); @@ -460,7 +359,7 @@ bcm2835_cpufreq_set_clock_rate(struct bcm2835_cpufreq_ } /* result (Hz) */ - rate = (int)msg->body.resp.rate_hz; + rate = (int)msg.body.resp.rate_hz; DPRINTF("clock = %d(Hz)\n", rate); return (rate); } @@ -468,7 +367,7 @@ bcm2835_cpufreq_set_clock_rate(struct bcm2835_cpufreq_ static int bcm2835_cpufreq_get_turbo(struct bcm2835_cpufreq_softc *sc) { - struct msg_get_turbo *msg; + struct msg_get_turbo msg; int level; int err; @@ -486,33 +385,25 @@ bcm2835_cpufreq_get_turbo(struct bcm2835_cpufreq_softc * u32: level */ - /* using DMA buffer for VC */ - msg = (struct msg_get_turbo *)sc->dma_buf; - if (sizeof(*msg) > sc->dma_size) { - device_printf(sc->dev, "DMA size overflow (%zu>%lu)\n", - sizeof(*msg), sc->dma_size); - return (MSG_ERROR); - } - /* setup single tag buffer */ - memset(msg, 0, sizeof(*msg)); - msg->hdr.buf_size = sizeof(*msg); - msg->hdr.code = BCM2835_MBOX_CODE_REQ; - msg->tag_hdr.tag = BCM2835_MBOX_TAG_GET_TURBO; - msg->tag_hdr.val_buf_size = sizeof(msg->body); - msg->tag_hdr.val_len = sizeof(msg->body.req); - msg->body.req.id = 0; - msg->end_tag = 0; + memset(&msg, 0, sizeof(msg)); + msg.hdr.buf_size = sizeof(msg); + msg.hdr.code = BCM2835_MBOX_CODE_REQ; + msg.tag_hdr.tag = BCM2835_MBOX_TAG_GET_TURBO; + msg.tag_hdr.val_buf_size = sizeof(msg.body); + msg.tag_hdr.val_len = sizeof(msg.body.req); + msg.body.req.id = 0; + msg.end_tag = 0; /* call mailbox property */ - err = bcm2835_mbox_call_prop(sc); + err = bcm2835_mbox_property(&msg, sizeof(msg)); if (err) { device_printf(sc->dev, "can't get turbo\n"); return (MSG_ERROR); } /* result 0=non-turbo, 1=turbo */ - level = (int)msg->body.resp.level; + level = (int)msg.body.resp.level; DPRINTF("level = %d\n", level); return (level); } @@ -520,7 +411,7 @@ bcm2835_cpufreq_get_turbo(struct bcm2835_cpufreq_softc static int bcm2835_cpufreq_set_turbo(struct bcm2835_cpufreq_softc *sc, uint32_t level) { - struct msg_set_turbo *msg; + struct msg_set_turbo msg; int value; int err; @@ -539,38 +430,30 @@ bcm2835_cpufreq_set_turbo(struct bcm2835_cpufreq_softc * u32: level */ - /* using DMA buffer for VC */ - msg = (struct msg_set_turbo *)sc->dma_buf; - if (sizeof(*msg) > sc->dma_size) { - device_printf(sc->dev, "DMA size overflow (%zu>%lu)\n", - sizeof(*msg), sc->dma_size); - return (MSG_ERROR); - } - /* replace unknown value to OFF */ if (level != BCM2835_MBOX_TURBO_ON && level != BCM2835_MBOX_TURBO_OFF) level = BCM2835_MBOX_TURBO_OFF; /* setup single tag buffer */ - memset(msg, 0, sizeof(*msg)); - msg->hdr.buf_size = sizeof(*msg); - msg->hdr.code = BCM2835_MBOX_CODE_REQ; - msg->tag_hdr.tag = BCM2835_MBOX_TAG_SET_TURBO; - msg->tag_hdr.val_buf_size = sizeof(msg->body); - msg->tag_hdr.val_len = sizeof(msg->body.req); - msg->body.req.id = 0; - msg->body.req.level = level; - msg->end_tag = 0; + memset(&msg, 0, sizeof(msg)); + msg.hdr.buf_size = sizeof(msg); + msg.hdr.code = BCM2835_MBOX_CODE_REQ; + msg.tag_hdr.tag = BCM2835_MBOX_TAG_SET_TURBO; + msg.tag_hdr.val_buf_size = sizeof(msg.body); + msg.tag_hdr.val_len = sizeof(msg.body.req); + msg.body.req.id = 0; + msg.body.req.level = level; + msg.end_tag = 0; /* call mailbox property */ - err = bcm2835_mbox_call_prop(sc); + err = bcm2835_mbox_property(&msg, sizeof(msg)); if (err) { device_printf(sc->dev, "can't set turbo\n"); return (MSG_ERROR); } /* result 0=non-turbo, 1=turbo */ - value = (int)msg->body.resp.level; + value = (int)msg.body.resp.level; DPRINTF("level = %d\n", value); return (value); } @@ -579,7 +462,7 @@ static int bcm2835_cpufreq_get_voltage(struct bcm2835_cpufreq_softc *sc, uint32_t voltage_id) { - struct msg_get_voltage *msg; + struct msg_get_voltage msg; int value; int err; @@ -597,33 +480,25 @@ bcm2835_cpufreq_get_voltage(struct bcm2835_cpufreq_sof * u32: value (offset from 1.2V in units of 0.025V) */ - /* using DMA buffer for VC */ - msg = (struct msg_get_voltage *)sc->dma_buf; - if (sizeof(*msg) > sc->dma_size) { - device_printf(sc->dev, "DMA size overflow (%zu>%lu)\n", - sizeof(*msg), sc->dma_size); - return (MSG_ERROR); - } - /* setup single tag buffer */ - memset(msg, 0, sizeof(*msg)); - msg->hdr.buf_size = sizeof(*msg); - msg->hdr.code = BCM2835_MBOX_CODE_REQ; - msg->tag_hdr.tag = BCM2835_MBOX_TAG_GET_VOLTAGE; - msg->tag_hdr.val_buf_size = sizeof(msg->body); - msg->tag_hdr.val_len = sizeof(msg->body.req); - msg->body.req.voltage_id = voltage_id; - msg->end_tag = 0; + memset(&msg, 0, sizeof(msg)); + msg.hdr.buf_size = sizeof(msg); + msg.hdr.code = BCM2835_MBOX_CODE_REQ; + msg.tag_hdr.tag = BCM2835_MBOX_TAG_GET_VOLTAGE; + msg.tag_hdr.val_buf_size = sizeof(msg.body); + msg.tag_hdr.val_len = sizeof(msg.body.req); + msg.body.req.voltage_id = voltage_id; + msg.end_tag = 0; /* call mailbox property */ - err = bcm2835_mbox_call_prop(sc); + err = bcm2835_mbox_property(&msg, sizeof(msg)); if (err) { device_printf(sc->dev, "can't get voltage\n"); return (MSG_ERROR); } /* result (offset from 1.2V) */ - value = (int)msg->body.resp.value; + value = (int)msg.body.resp.value; DPRINTF("value = %d\n", value); return (value); } @@ -632,7 +507,7 @@ static int bcm2835_cpufreq_get_max_voltage(struct bcm2835_cpufreq_softc *sc, uint32_t voltage_id) { - struct msg_get_max_voltage *msg; + struct msg_get_max_voltage msg; int value; int err; @@ -650,33 +525,25 @@ bcm2835_cpufreq_get_max_voltage(struct bcm2835_cpufreq * u32: value (offset from 1.2V in units of 0.025V) */ - /* using DMA buffer for VC */ - msg = (struct msg_get_max_voltage *)sc->dma_buf; - if (sizeof(*msg) > sc->dma_size) { - device_printf(sc->dev, "DMA size overflow (%zu>%lu)\n", - sizeof(*msg), sc->dma_size); - return (MSG_ERROR); - } - /* setup single tag buffer */ - memset(msg, 0, sizeof(*msg)); - msg->hdr.buf_size = sizeof(*msg); - msg->hdr.code = BCM2835_MBOX_CODE_REQ; - msg->tag_hdr.tag = BCM2835_MBOX_TAG_GET_MAX_VOLTAGE; - msg->tag_hdr.val_buf_size = sizeof(msg->body); - msg->tag_hdr.val_len = sizeof(msg->body.req); - msg->body.req.voltage_id = voltage_id; - msg->end_tag = 0; + memset(&msg, 0, sizeof(msg)); + msg.hdr.buf_size = sizeof(msg); + msg.hdr.code = BCM2835_MBOX_CODE_REQ; + msg.tag_hdr.tag = BCM2835_MBOX_TAG_GET_MAX_VOLTAGE; + msg.tag_hdr.val_buf_size = sizeof(msg.body); + msg.tag_hdr.val_len = sizeof(msg.body.req); + msg.body.req.voltage_id = voltage_id; + msg.end_tag = 0; /* call mailbox property */ - err = bcm2835_mbox_call_prop(sc); + err = bcm2835_mbox_property(&msg, sizeof(msg)); if (err) { device_printf(sc->dev, "can't get max voltage\n"); return (MSG_ERROR); } /* result (offset from 1.2V) */ - value = (int)msg->body.resp.value; + value = (int)msg.body.resp.value; DPRINTF("value = %d\n", value); return (value); } @@ -684,7 +551,7 @@ static int bcm2835_cpufreq_get_min_voltage(struct bcm2835_cpufreq_softc *sc, uint32_t voltage_id) { - struct msg_get_min_voltage *msg; + struct msg_get_min_voltage msg; int value; int err; @@ -702,33 +569,25 @@ bcm2835_cpufreq_get_min_voltage(struct bcm2835_cpufreq * u32: value (offset from 1.2V in units of 0.025V) */ - /* using DMA buffer for VC */ - msg = (struct msg_get_min_voltage *)sc->dma_buf; - if (sizeof(*msg) > sc->dma_size) { - device_printf(sc->dev, "DMA size overflow (%zu>%lu)\n", - sizeof(*msg), sc->dma_size); - return (MSG_ERROR); - } - /* setup single tag buffer */ - memset(msg, 0, sizeof(*msg)); - msg->hdr.buf_size = sizeof(*msg); - msg->hdr.code = BCM2835_MBOX_CODE_REQ; - msg->tag_hdr.tag = BCM2835_MBOX_TAG_GET_MIN_VOLTAGE; - msg->tag_hdr.val_buf_size = sizeof(msg->body); - msg->tag_hdr.val_len = sizeof(msg->body.req); - msg->body.req.voltage_id = voltage_id; - msg->end_tag = 0; + memset(&msg, 0, sizeof(msg)); + msg.hdr.buf_size = sizeof(msg); + msg.hdr.code = BCM2835_MBOX_CODE_REQ; + msg.tag_hdr.tag = BCM2835_MBOX_TAG_GET_MIN_VOLTAGE; + msg.tag_hdr.val_buf_size = sizeof(msg.body); + msg.tag_hdr.val_len = sizeof(msg.body.req); + msg.body.req.voltage_id = voltage_id; + msg.end_tag = 0; /* call mailbox property */ - err = bcm2835_mbox_call_prop(sc); + err = bcm2835_mbox_property(&msg, sizeof(msg)); if (err) { device_printf(sc->dev, "can't get min voltage\n"); return (MSG_ERROR); } /* result (offset from 1.2V) */ - value = (int)msg->body.resp.value; + value = (int)msg.body.resp.value; DPRINTF("value = %d\n", value); return (value); } @@ -737,7 +596,7 @@ static int bcm2835_cpufreq_set_voltage(struct bcm2835_cpufreq_softc *sc, uint32_t voltage_id, int32_t value) { - struct msg_set_voltage *msg; + struct msg_set_voltage msg; int err; /* @@ -766,34 +625,26 @@ bcm2835_cpufreq_set_voltage(struct bcm2835_cpufreq_sof return (MSG_ERROR); } - /* using DMA buffer for VC */ - msg = (struct msg_set_voltage *)sc->dma_buf; - if (sizeof(*msg) > sc->dma_size) { - device_printf(sc->dev, "DMA size overflow (%zu>%lu)\n", - sizeof(*msg), sc->dma_size); - return (MSG_ERROR); - } - /* setup single tag buffer */ - memset(msg, 0, sizeof(*msg)); - msg->hdr.buf_size = sizeof(*msg); - msg->hdr.code = BCM2835_MBOX_CODE_REQ; - msg->tag_hdr.tag = BCM2835_MBOX_TAG_SET_VOLTAGE; - msg->tag_hdr.val_buf_size = sizeof(msg->body); - msg->tag_hdr.val_len = sizeof(msg->body.req); - msg->body.req.voltage_id = voltage_id; - msg->body.req.value = (uint32_t)value; - msg->end_tag = 0; + memset(&msg, 0, sizeof(msg)); + msg.hdr.buf_size = sizeof(msg); + msg.hdr.code = BCM2835_MBOX_CODE_REQ; + msg.tag_hdr.tag = BCM2835_MBOX_TAG_SET_VOLTAGE; + msg.tag_hdr.val_buf_size = sizeof(msg.body); + msg.tag_hdr.val_len = sizeof(msg.body.req); + msg.body.req.voltage_id = voltage_id; + msg.body.req.value = (uint32_t)value; + msg.end_tag = 0; /* call mailbox property */ - err = bcm2835_mbox_call_prop(sc); + err = bcm2835_mbox_property(&msg, sizeof(msg)); if (err) { device_printf(sc->dev, "can't set voltage\n"); return (MSG_ERROR); } /* result (offset from 1.2V) */ - value = (int)msg->body.resp.value; + value = (int)msg.body.resp.value; DPRINTF("value = %d\n", value); return (value); } @@ -801,7 +652,7 @@ bcm2835_cpufreq_set_voltage(struct bcm2835_cpufreq_sof static int bcm2835_cpufreq_get_temperature(struct bcm2835_cpufreq_softc *sc) { - struct msg_get_temperature *msg; + struct msg_get_temperature msg; int value; int err; @@ -819,33 +670,25 @@ bcm2835_cpufreq_get_temperature(struct bcm2835_cpufreq * u32: value */ - /* using DMA buffer for VC */ - msg = (struct msg_get_temperature *)sc->dma_buf; - if (sizeof(*msg) > sc->dma_size) { - device_printf(sc->dev, "DMA size overflow (%zu>%lu)\n", - sizeof(*msg), sc->dma_size); - return (MSG_ERROR); - } - /* setup single tag buffer */ - memset(msg, 0, sizeof(*msg)); - msg->hdr.buf_size = sizeof(*msg); - msg->hdr.code = BCM2835_MBOX_CODE_REQ; - msg->tag_hdr.tag = BCM2835_MBOX_TAG_GET_TEMPERATURE; - msg->tag_hdr.val_buf_size = sizeof(msg->body); - msg->tag_hdr.val_len = sizeof(msg->body.req); - msg->body.req.temperature_id = 0; - msg->end_tag = 0; + memset(&msg, 0, sizeof(msg)); + msg.hdr.buf_size = sizeof(msg); + msg.hdr.code = BCM2835_MBOX_CODE_REQ; + msg.tag_hdr.tag = BCM2835_MBOX_TAG_GET_TEMPERATURE; + msg.tag_hdr.val_buf_size = sizeof(msg.body); + msg.tag_hdr.val_len = sizeof(msg.body.req); + msg.body.req.temperature_id = 0; + msg.end_tag = 0; /* call mailbox property */ - err = bcm2835_mbox_call_prop(sc); + err = bcm2835_mbox_property(&msg, sizeof(msg)); if (err) { device_printf(sc->dev, "can't get temperature\n"); return (MSG_ERROR); } /* result (temperature of degree C) */ - value = (int)msg->body.resp.value; + value = (int)msg.body.resp.value; DPRINTF("value = %d\n", value); return (value); } @@ -1406,7 +1249,17 @@ bcm2835_cpufreq_init(void *arg) static void bcm2835_cpufreq_identify(driver_t *driver, device_t parent) { + const struct ofw_compat_data *compat; + phandle_t root; + root = OF_finddevice("/"); + for (compat = compat_data; compat->ocd_str != NULL; compat++) + if (fdt_is_compatible(root, compat->ocd_str)) + break; + + if (compat->ocd_data == 0) + return; + DPRINTF("driver=%p, parent=%p\n", driver, parent); if (device_find_child(parent, "bcm2835_cpufreq", -1) != NULL) return; @@ -1422,23 +1275,11 @@ bcm2835_cpufreq_probe(device_t dev) return (0); } -static void -bcm2835_cpufreq_cb(void *arg, bus_dma_segment_t *segs, int nseg, int err) -{ - bus_addr_t *addr; - - if (err) - return; - addr = (bus_addr_t *)arg; - *addr = PHYS_TO_VCBUS(segs[0].ds_addr); -} - static int bcm2835_cpufreq_attach(device_t dev) { struct bcm2835_cpufreq_softc *sc; struct sysctl_oid *oid; - int err; /* set self dev */ sc = device_get_softc(dev); @@ -1454,41 +1295,6 @@ bcm2835_cpufreq_attach(device_t dev) sc->max_voltage_core = 0; sc->min_voltage_core = 0; - /* create VC mbox buffer */ - sc->dma_size = PAGE_SIZE; - err = bus_dma_tag_create( - bus_get_dma_tag(sc->dev), - PAGE_SIZE, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - sc->dma_size, 1, /* maxsize, nsegments */ - sc->dma_size, 0, /* maxsegsize, flags */ - NULL, NULL, /* lockfunc, lockarg */ - &sc->dma_tag); - if (err) { - device_printf(dev, "can't create DMA tag\n"); - return (ENXIO); - } - - err = bus_dmamem_alloc(sc->dma_tag, (void **)&sc->dma_buf, 0, - &sc->dma_map); - if (err) { - bus_dma_tag_destroy(sc->dma_tag); - device_printf(dev, "can't allocate dmamem\n"); - return (ENXIO); - } - - err = bus_dmamap_load(sc->dma_tag, sc->dma_map, sc->dma_buf, - sc->dma_size, bcm2835_cpufreq_cb, &sc->dma_phys, 0); - if (err) { - bus_dmamem_free(sc->dma_tag, sc->dma_buf, sc->dma_map); - bus_dma_tag_destroy(sc->dma_tag); - device_printf(dev, "can't load DMA map\n"); - return (ENXIO); - } - /* OK, ready to use VC buffer */ - /* setup sysctl at first device */ if (device_get_unit(dev) == 0) { sysctl_ctx_init(&bcm2835_sysctl_ctx); @@ -1558,9 +1364,6 @@ bcm2835_cpufreq_attach(device_t dev) sc->init_hook.ich_arg = sc; if (config_intrhook_establish(&sc->init_hook) != 0) { - bus_dmamap_unload(sc->dma_tag, sc->dma_map); - bus_dmamem_free(sc->dma_tag, sc->dma_buf, sc->dma_map); - bus_dma_tag_destroy(sc->dma_tag); device_printf(dev, "config_intrhook_establish failed\n"); return (ENOMEM); } @@ -1579,13 +1382,6 @@ bcm2835_cpufreq_detach(device_t dev) sc = device_get_softc(dev); sema_destroy(&vc_sema); - - if (sc->dma_phys != 0) - bus_dmamap_unload(sc->dma_tag, sc->dma_map); - if (sc->dma_buf != NULL) - bus_dmamem_free(sc->dma_tag, sc->dma_buf, sc->dma_map); - if (sc->dma_tag != NULL) - bus_dma_tag_destroy(sc->dma_tag); return (cpufreq_unregister(dev)); } Modified: stable/10/sys/arm/broadcom/bcm2835/bcm2835_dma.c ============================================================================== --- stable/10/sys/arm/broadcom/bcm2835/bcm2835_dma.c Sun Aug 20 11:18:16 2017 (r322723) +++ stable/10/sys/arm/broadcom/bcm2835/bcm2835_dma.c Sun Aug 20 16:52:27 2017 (r322724) @@ -104,6 +104,15 @@ __FBSDID("$FreeBSD$"); /* relative offset from BCM_VC_DMA0_BASE (p.39) */ #define BCM_DMA_CH(n) (0x100*(n)) +/* channels used by GPU */ +#define BCM_DMA_CH_BULK 0 +#define BCM_DMA_CH_FAST1 2 +#define BCM_DMA_CH_FAST2 3 + +#define BCM_DMA_CH_GPU_MASK ((1 << BCM_DMA_CH_BULK) | \ + (1 << BCM_DMA_CH_FAST1) | \ + (1 << BCM_DMA_CH_FAST2)) + /* DMA Control Block - 256bit aligned (p.40) */ struct bcm_dma_cb { uint32_t info; /* Transfer Information */ @@ -143,7 +152,14 @@ struct bcm_dma_softc { }; static struct bcm_dma_softc *bcm_dma_sc = NULL; +static uint32_t bcm_dma_channel_mask; +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-dma", 1}, + {"brcm,bcm2835-dma", 1}, + {NULL, 0} +}; + static void bcm_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int err) @@ -205,16 +221,32 @@ static int bcm_dma_init(device_t dev) { struct bcm_dma_softc *sc = device_get_softc(dev); - uint32_t mask; + uint32_t reg; struct bcm_dma_ch *ch; void *cb_virt; vm_paddr_t cb_phys; int err; int i; - /* disable and clear interrupt status */ - bus_write_4(sc->sc_mem, BCM_DMA_ENABLE, 0); - bus_write_4(sc->sc_mem, BCM_DMA_INT_STATUS, 0); + /* + * Only channels set in bcm_dma_channel_mask can be controlled by us. + * The others are out of our control as well as the corresponding bits + * in both BCM_DMA_ENABLE and BCM_DMA_INT_STATUS global registers. As + * these registers are RW ones, there is no safe way how to write only + * the bits which can be controlled by us. + * + * Fortunately, after reset, all channels are enabled in BCM_DMA_ENABLE + * register and all statuses are cleared in BCM_DMA_INT_STATUS one. + * Not touching these registers is a trade off between correct + * initialization which does not count on anything and not messing up + * something we have no control over. + */ + reg = bus_read_4(sc->sc_mem, BCM_DMA_ENABLE); + if ((reg & bcm_dma_channel_mask) != bcm_dma_channel_mask) + device_printf(dev, "channels are not enabled\n"); + reg = bus_read_4(sc->sc_mem, BCM_DMA_INT_STATUS); + if ((reg & bcm_dma_channel_mask) != 0) + device_printf(dev, "statuses are not cleared\n"); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Sun Aug 20 19:21:07 2017 Return-Path: Delivered-To: svn-src-stable@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 3ACD2DE7B94; Sun, 20 Aug 2017 19:21:07 +0000 (UTC) (envelope-from delphij@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 09A9A6FD2C; Sun, 20 Aug 2017 19:21:06 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7KJL64b072149; Sun, 20 Aug 2017 19:21:06 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7KJL6XI072148; Sun, 20 Aug 2017 19:21:06 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201708201921.v7KJL6XI072148@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Sun, 20 Aug 2017 19:21:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r322725 - stable/10/sys/mips/atheros X-SVN-Group: stable-10 X-SVN-Commit-Author: delphij X-SVN-Commit-Paths: stable/10/sys/mips/atheros X-SVN-Commit-Revision: 322725 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Aug 2017 19:21:07 -0000 Author: delphij Date: Sun Aug 20 19:21:06 2017 New Revision: 322725 URL: https://svnweb.freebsd.org/changeset/base/322725 Log: MFC r322527: Plug memory leak in arge_encap(). Reported by: Ilja Van Sprundel Submitted by: Domagoj Stolfa Reviewed by: adrian Approved by: re (kib) Modified: stable/10/sys/mips/atheros/if_arge.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/mips/atheros/if_arge.c ============================================================================== --- stable/10/sys/mips/atheros/if_arge.c Sun Aug 20 16:52:27 2017 (r322724) +++ stable/10/sys/mips/atheros/if_arge.c Sun Aug 20 19:21:06 2017 (r322725) @@ -1111,6 +1111,7 @@ arge_encap(struct arge_softc *sc, struct mbuf **m_head sc->stats.tx_pkts_unaligned++; m = m_defrag(*m_head, M_NOWAIT); if (m == NULL) { + m_freem(*m_head); *m_head = NULL; return (ENOBUFS); } From owner-svn-src-stable@freebsd.org Sun Aug 20 21:21:48 2017 Return-Path: Delivered-To: svn-src-stable@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 27683DCC239; Sun, 20 Aug 2017 21:21:48 +0000 (UTC) (envelope-from marius@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 E853B7425C; Sun, 20 Aug 2017 21:21:47 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7KLLlZW022633; Sun, 20 Aug 2017 21:21:47 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7KLLkLY022631; Sun, 20 Aug 2017 21:21:46 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201708202121.v7KLLkLY022631@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Sun, 20 Aug 2017 21:21:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r322737 - in stable/10: etc/pkg release/pkg_repos X-SVN-Group: stable-10 X-SVN-Commit-Author: marius X-SVN-Commit-Paths: in stable/10: etc/pkg release/pkg_repos X-SVN-Commit-Revision: 322737 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Aug 2017 21:21:48 -0000 Author: marius Date: Sun Aug 20 21:21:46 2017 New Revision: 322737 URL: https://svnweb.freebsd.org/changeset/base/322737 Log: Switch the pkg(8) configuration for the default installation and the dvd1.iso to use the quarterly set, i. e. 2017Q3, during the 10.4-BETA phase. Approved by: re (implicit) Modified: stable/10/etc/pkg/FreeBSD.conf stable/10/release/pkg_repos/release-dvd.conf Modified: stable/10/etc/pkg/FreeBSD.conf ============================================================================== --- stable/10/etc/pkg/FreeBSD.conf Sun Aug 20 21:04:03 2017 (r322736) +++ stable/10/etc/pkg/FreeBSD.conf Sun Aug 20 21:21:46 2017 (r322737) @@ -8,7 +8,7 @@ # FreeBSD: { - url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest", + url: "pkg+http://pkg.FreeBSD.org/${ABI}/quarterly", mirror_type: "srv", signature_type: "fingerprints", fingerprints: "/usr/share/keys/pkg", Modified: stable/10/release/pkg_repos/release-dvd.conf ============================================================================== --- stable/10/release/pkg_repos/release-dvd.conf Sun Aug 20 21:04:03 2017 (r322736) +++ stable/10/release/pkg_repos/release-dvd.conf Sun Aug 20 21:21:46 2017 (r322737) @@ -1,6 +1,6 @@ # $FreeBSD$ release: { - url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest", + url: "pkg+http://pkg.FreeBSD.org/${ABI}/quarterly", mirror_type: "srv", signature_type: "fingerprints", fingerprints: "/usr/share/keys/pkg", From owner-svn-src-stable@freebsd.org Sun Aug 20 23:05:38 2017 Return-Path: Delivered-To: svn-src-stable@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 216BDDD3D0E; Sun, 20 Aug 2017 23:05:38 +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 EF4B177060; Sun, 20 Aug 2017 23:05:37 +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 v7KN5b2l064715; Sun, 20 Aug 2017 23:05:37 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7KN5bmT064713; Sun, 20 Aug 2017 23:05:37 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201708202305.v7KN5bmT064713@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sun, 20 Aug 2017 23:05: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: r322738 - stable/11/sys/fs/ext2fs X-SVN-Group: stable-11 X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: stable/11/sys/fs/ext2fs X-SVN-Commit-Revision: 322738 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Aug 2017 23:05:38 -0000 Author: pfg Date: Sun Aug 20 23:05:36 2017 New Revision: 322738 URL: https://svnweb.freebsd.org/changeset/base/322738 Log: MFC r320578: ext2fs: be more verbose about unsupported ext2fs features. It is useful to know exactly what features may be lacking when trying to mount ext4 filesystems. Submitted by: Fedor Uporov Modified: stable/11/sys/fs/ext2fs/ext2_vfsops.c stable/11/sys/fs/ext2fs/ext2fs.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/ext2fs/ext2_vfsops.c ============================================================================== --- stable/11/sys/fs/ext2fs/ext2_vfsops.c Sun Aug 20 21:21:46 2017 (r322737) +++ stable/11/sys/fs/ext2fs/ext2_vfsops.c Sun Aug 20 23:05:36 2017 (r322738) @@ -279,6 +279,7 @@ ext2_mount(struct mount *mp) static int ext2_check_sb_compat(struct ext2fs *es, struct cdev *dev, int ronly) { + uint32_t i, mask; if (es->e2fs_magic != E2FS_MAGIC) { printf("ext2fs: %s: wrong magic number %#x (expected %#x)\n", @@ -286,17 +287,29 @@ ext2_check_sb_compat(struct ext2fs *es, struct cdev *d return (1); } if (es->e2fs_rev > E2FS_REV0) { - if (es->e2fs_features_incompat & ~(EXT2F_INCOMPAT_SUPP | - EXT4F_RO_INCOMPAT_SUPP)) { - printf( -"WARNING: mount of %s denied due to unsupported optional features\n", - devtoname(dev)); + mask = es->e2fs_features_incompat & ~(EXT2F_INCOMPAT_SUPP | + EXT4F_RO_INCOMPAT_SUPP); + if (mask) { + printf("WARNING: mount of %s denied due to " + "unsupported optional features:\n", devtoname(dev)); + for (i = 0; + i < sizeof(incompat)/sizeof(struct ext2_feature); + i++) + if (mask & incompat[i].mask) + printf("%s ", incompat[i].name); + printf("\n"); return (1); } - if (!ronly && - (es->e2fs_features_rocompat & ~EXT2F_ROCOMPAT_SUPP)) { + mask = es->e2fs_features_rocompat & ~EXT2F_ROCOMPAT_SUPP; + if (!ronly && mask) { printf("WARNING: R/W mount of %s denied due to " - "unsupported optional features\n", devtoname(dev)); + "unsupported optional features:\n", devtoname(dev)); + for (i = 0; + i < sizeof(ro_compat)/sizeof(struct ext2_feature); + i++) + if (mask & ro_compat[i].mask) + printf("%s ", ro_compat[i].name); + printf("\n"); return (1); } } Modified: stable/11/sys/fs/ext2fs/ext2fs.h ============================================================================== --- stable/11/sys/fs/ext2fs/ext2fs.h Sun Aug 20 21:21:46 2017 (r322737) +++ stable/11/sys/fs/ext2fs/ext2fs.h Sun Aug 20 23:05:36 2017 (r322738) @@ -203,10 +203,13 @@ struct csum { * compatible/incompatible features */ #define EXT2F_COMPAT_PREALLOC 0x0001 +#define EXT2F_COMPAT_IMAGIC_INODES 0x0002 #define EXT2F_COMPAT_HASJOURNAL 0x0004 #define EXT2F_COMPAT_EXT_ATTR 0x0008 #define EXT2F_COMPAT_RESIZE 0x0010 #define EXT2F_COMPAT_DIRHASHINDEX 0x0020 +#define EXT2F_COMPAT_LAZY_BG 0x0040 +#define EXT2F_COMPAT_EXCLUDE_BITMAP 0x0100 #define EXT2F_COMPAT_SPARSESUPER2 0x0200 #define EXT2F_ROCOMPAT_SPARSESUPER 0x0001 @@ -216,15 +219,18 @@ struct csum { #define EXT2F_ROCOMPAT_GDT_CSUM 0x0010 #define EXT2F_ROCOMPAT_DIR_NLINK 0x0020 #define EXT2F_ROCOMPAT_EXTRA_ISIZE 0x0040 +#define EXT2F_ROCOMPAT_HAS_SNAPSHOT 0x0080 #define EXT2F_ROCOMPAT_QUOTA 0x0100 #define EXT2F_ROCOMPAT_BIGALLOC 0x0200 #define EXT2F_ROCOMPAT_METADATA_CKSUM 0x0400 +#define EXT2F_ROCOMPAT_REPLICA 0x0800 #define EXT2F_ROCOMPAT_READONLY 0x1000 #define EXT2F_ROCOMPAT_PROJECT 0x2000 #define EXT2F_INCOMPAT_COMP 0x0001 #define EXT2F_INCOMPAT_FTYPE 0x0002 #define EXT2F_INCOMPAT_RECOVER 0x0004 +#define EXT2F_INCOMPAT_JOURNAL_DEV 0x0008 #define EXT2F_INCOMPAT_META_BG 0x0010 #define EXT2F_INCOMPAT_EXTENTS 0x0040 #define EXT2F_INCOMPAT_64BIT 0x0080 @@ -236,6 +242,58 @@ struct csum { #define EXT2F_INCOMPAT_LARGEDIR 0x4000 #define EXT2F_INCOMPAT_INLINE_DATA 0x8000 #define EXT2F_INCOMPAT_ENCRYPT 0x10000 + +struct ext2_feature +{ + int mask; + const char *name; +}; + +static const struct ext2_feature compat[] = { + { EXT2F_COMPAT_PREALLOC, "dir_prealloc" }, + { EXT2F_COMPAT_IMAGIC_INODES, "imagic_inodes" }, + { EXT2F_COMPAT_HASJOURNAL, "has_journal" }, + { EXT2F_COMPAT_EXT_ATTR, "ext_attr" }, + { EXT2F_COMPAT_RESIZE, "resize_inode" }, + { EXT2F_COMPAT_DIRHASHINDEX, "dir_index" }, + { EXT2F_COMPAT_EXCLUDE_BITMAP, "snapshot_bitmap" }, + { EXT2F_COMPAT_SPARSESUPER2, "sparse_super2" } +}; + +static const struct ext2_feature ro_compat[] = { + { EXT2F_ROCOMPAT_SPARSESUPER, "sparse_super" }, + { EXT2F_ROCOMPAT_LARGEFILE, "large_file" }, + { EXT2F_ROCOMPAT_BTREE_DIR, "btree_dir" }, + { EXT2F_ROCOMPAT_HUGE_FILE, "huge_file" }, + { EXT2F_ROCOMPAT_GDT_CSUM, "uninit_groups" }, + { EXT2F_ROCOMPAT_DIR_NLINK, "dir_nlink" }, + { EXT2F_ROCOMPAT_EXTRA_ISIZE, "extra_isize" }, + { EXT2F_ROCOMPAT_HAS_SNAPSHOT, "snapshot" }, + { EXT2F_ROCOMPAT_QUOTA, "quota" }, + { EXT2F_ROCOMPAT_BIGALLOC, "bigalloc" }, + { EXT2F_ROCOMPAT_METADATA_CKSUM, "metadata_csum" }, + { EXT2F_ROCOMPAT_REPLICA, "replica" }, + { EXT2F_ROCOMPAT_READONLY, "ro" }, + { EXT2F_ROCOMPAT_PROJECT, "project" } +}; + +static const struct ext2_feature incompat[] = { + { EXT2F_INCOMPAT_COMP, "compression" }, + { EXT2F_INCOMPAT_FTYPE, "filetype" }, + { EXT2F_INCOMPAT_RECOVER, "needs_recovery" }, + { EXT2F_INCOMPAT_JOURNAL_DEV, "journal_dev" }, + { EXT2F_INCOMPAT_META_BG, "meta_bg" }, + { EXT2F_INCOMPAT_EXTENTS, "extents" }, + { EXT2F_INCOMPAT_64BIT, "64bit" }, + { EXT2F_INCOMPAT_MMP, "mmp" }, + { EXT2F_INCOMPAT_FLEX_BG, "flex_bg" }, + { EXT2F_INCOMPAT_EA_INODE, "ea_inode" }, + { EXT2F_INCOMPAT_DIRDATA, "dirdata" }, + { EXT2F_INCOMPAT_CSUM_SEED, "metadata_csum_seed" }, + { EXT2F_INCOMPAT_LARGEDIR, "large_dir" }, + { EXT2F_INCOMPAT_INLINE_DATA, "inline_data" }, + { EXT2F_INCOMPAT_ENCRYPT, "encrypt" } +}; /* * Features supported in this implementation From owner-svn-src-stable@freebsd.org Mon Aug 21 05:25:32 2017 Return-Path: Delivered-To: svn-src-stable@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 13D46DE982E; Mon, 21 Aug 2017 05:25:32 +0000 (UTC) (envelope-from sephe@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 BE12CC4E; Mon, 21 Aug 2017 05:25:31 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7L5PV1H019028; Mon, 21 Aug 2017 05:25:31 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7L5PVO9019026; Mon, 21 Aug 2017 05:25:31 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201708210525.v7L5PVO9019026@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 21 Aug 2017 05:25:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r322739 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 X-SVN-Commit-Author: sephe X-SVN-Commit-Paths: stable/10/sys/dev/hyperv/netvsc X-SVN-Commit-Revision: 322739 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Aug 2017 05:25:32 -0000 Author: sephe Date: Mon Aug 21 05:25:30 2017 New Revision: 322739 URL: https://svnweb.freebsd.org/changeset/base/322739 Log: MFC 322299,322483,322485-322487 322299 hyperv/hn: Implement transparent mode network VF. How network VF works with hn(4) on Hyper-V in transparent mode: - Each network VF has a cooresponding hn(4). - The network VF and the it's cooresponding hn(4) have the same hardware address. - Once the network VF is attached, the cooresponding hn(4) waits several seconds to make sure that the network VF attach routing completes, then: o Set the intersection of the network VF's if_capabilities and the cooresponding hn(4)'s if_capabilities to the cooresponding hn(4)'s if_capabilities. And adjust the cooresponding hn(4) if_capable and if_hwassist accordingly. (*) o Make sure that the cooresponding hn(4)'s TSO parameters meet the constraints posed by both the network VF and the cooresponding hn(4). (*) o The network VF's if_input is overridden. The overriding if_input changes the input packet's rcvif to the cooreponding hn(4). The network layers are tricked into thinking that all packets are neceived by the cooresponding hn(4). o If the cooresponding hn(4) was brought up, bring up the network VF. The transmission dispatched to the cooresponding hn(4) are redispatched to the network VF. o Bringing down the cooresponding hn(4) also brings down the network VF. o All IOCTLs issued to the cooresponding hn(4) are pass-through'ed to the network VF; the cooresponding hn(4) changes its internal state if necessary. o The media status of the cooresponding hn(4) solely relies on the network VF. o If there are multicast filters on the cooresponding hn(4), allmulti will be enabled on the network VF. (**) - Once the network VF is detached. Undo all damages did to the cooresponding hn(4) in the above item. NOTE: No operation should be issued directly to the network VF, if the network VF transparent mode is enabled. The network VF transparent mode can be enabled by setting tunable hw.hn.vf_transparent to 1. The network VF transparent mode is _not_ enabled by default, as of this commit. The benefit of the network VF transparent mode is that the network VF attachment and detachment are transparent to all network layers; e.g. live migration detaches and reattaches the network VF. The major drawbacks of the network VF transparent mode: - The netmap(4) support is lost, even if the VF supports it. - ALTQ does not work, since if_start method cannot be properly supported. (*) These decisions were made so that things will not be messed up too much during the transition period. (**) This does _not_ need to go through the fancy multicast filter management stuffs like what vlan(4) has, at least currently: - As of this write, multicast does not work in Azure. - As of this write, multicast packets go through the cooresponding hn(4). Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D11803 322483 hyperv/hn: Update VF's ibytes properly under transparent VF mode. While, I'm here add comment about why updating VF's imcast stat is not necessary. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D11948 322485 hyperv/hn: Fix/enhance receiving path when VF is activated. - Update hn(4)'s stats properly for non-transparent mode VF. - Allow BPF tapping to hn(4) for non-transparent mode VF. - Don't setup mbuf hash, if 'options RSS' is set. In Azure, when VF is activated, TCP SYN and SYN|ACK go through hn(4) while the rest of segments and ACKs belonging to the same TCP 4-tuple go through the VF. So don't setup mbuf hash, if a VF is activated and 'options RSS' is not enabled. hn(4) and the VF may use neither the same RSS hash key nor the same RSS hash function, so the hash value for packets belonging to the same flow could be different! - Disable LRO. hn(4) will only receive broadcast packets, multicast packets, TCP SYN and SYN|ACK (in Azure), LRO is useless for these packet types. For non-transparent, we definitely _cannot_ enable LRO at all, since the LRO flush will use hn(4) as the receiving interface; i.e. hn_ifp->if_input(hn_ifp, m). While I'm here, remove unapplied comment and minor style change. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D11978 322486 hyperv/hn: Minor cleanup Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D11979 322487 hyperv/hn: Re-set datapath after synthetic parts reattached. Do this even for non-transparent mode VF. Better safe than sorry. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D11981 Approved by: re (delphij) Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c stable/10/sys/dev/hyperv/netvsc/if_hnreg.h stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hn.c Sun Aug 20 23:05:36 2017 (r322738) +++ stable/10/sys/dev/hyperv/netvsc/if_hn.c Mon Aug 21 05:25:30 2017 (r322739) @@ -122,6 +122,8 @@ __FBSDID("$FreeBSD$"); #define HN_VFMAP_SIZE_DEF 8 +#define HN_XPNT_VF_ATTWAIT_MIN 2 /* seconds */ + /* YYY should get it from the underlying channel */ #define HN_TX_DESC_CNT 512 @@ -258,6 +260,7 @@ static void hn_ifnet_event(void *, struct ifnet *, i static void hn_ifaddr_event(void *, struct ifnet *); static void hn_ifnet_attevent(void *, struct ifnet *); static void hn_ifnet_detevent(void *, struct ifnet *); +static void hn_ifnet_lnkevent(void *, struct ifnet *, int); static bool hn_ismyvf(const struct hn_softc *, const struct ifnet *); @@ -265,6 +268,17 @@ static void hn_rxvf_change(struct hn_softc *, struct ifnet *, bool); static void hn_rxvf_set(struct hn_softc *, struct ifnet *); static void hn_rxvf_set_task(void *, int); +static void hn_xpnt_vf_input(struct ifnet *, struct mbuf *); +static int hn_xpnt_vf_iocsetflags(struct hn_softc *); +static int hn_xpnt_vf_iocsetcaps(struct hn_softc *, + struct ifreq *); +static void hn_xpnt_vf_saveifflags(struct hn_softc *); +static bool hn_xpnt_vf_isready(struct hn_softc *); +static void hn_xpnt_vf_setready(struct hn_softc *); +static void hn_xpnt_vf_init_taskfunc(void *, int); +static void hn_xpnt_vf_init(struct hn_softc *); +static void hn_xpnt_vf_setenable(struct hn_softc *); +static void hn_xpnt_vf_setdisable(struct hn_softc *, bool); static int hn_rndis_rxinfo(const void *, int, struct hn_rxinfo *); @@ -315,6 +329,8 @@ static int hn_vf_sysctl(SYSCTL_HANDLER_ARGS); static int hn_rxvf_sysctl(SYSCTL_HANDLER_ARGS); static int hn_vflist_sysctl(SYSCTL_HANDLER_ARGS); static int hn_vfmap_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_xpnt_vf_accbpf_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_xpnt_vf_enabled_sysctl(SYSCTL_HANDLER_ARGS); static void hn_stop(struct hn_softc *, bool); static void hn_init_locked(struct hn_softc *); @@ -345,6 +361,7 @@ static void hn_disable_rx(struct hn_softc *); static void hn_drain_rxtx(struct hn_softc *, int); static void hn_polling(struct hn_softc *, u_int); static void hn_chan_polling(struct vmbus_channel *, u_int); +static void hn_mtu_change_fixup(struct hn_softc *); static void hn_update_link_status(struct hn_softc *); static void hn_change_network(struct hn_softc *); @@ -520,6 +537,22 @@ SYSCTL_PROC(_hw_hn, OID_AUTO, vflist, CTLFLAG_RD | CTL SYSCTL_PROC(_hw_hn, OID_AUTO, vfmap, CTLFLAG_RD | CTLTYPE_STRING, 0, 0, hn_vfmap_sysctl, "A", "VF mapping"); +/* Transparent VF */ +static int hn_xpnt_vf = 0; +SYSCTL_INT(_hw_hn, OID_AUTO, vf_transparent, CTLFLAG_RDTUN, + &hn_xpnt_vf, 0, "Transparent VF mod"); + +/* Accurate BPF support for Transparent VF */ +static int hn_xpnt_vf_accbpf = 0; +SYSCTL_INT(_hw_hn, OID_AUTO, vf_xpnt_accbpf, CTLFLAG_RDTUN, + &hn_xpnt_vf_accbpf, 0, "Accurate BPF for transparent VF"); + +/* Extra wait for transparent VF attach routing; unit seconds. */ +static int hn_xpnt_vf_attwait = HN_XPNT_VF_ATTWAIT_MIN; +SYSCTL_INT(_hw_hn, OID_AUTO, vf_xpnt_attwait, CTLFLAG_RWTUN, + &hn_xpnt_vf_attwait, 0, + "Extra wait for transparent VF attach routing; unit: seconds"); + static u_int hn_cpu_index; /* next CPU for channel */ static struct taskqueue **hn_tx_taskque;/* shared TX taskqueues */ @@ -536,6 +569,12 @@ hn_rss_key_default[NDIS_HASH_KEYSIZE_TOEPLITZ] = { 0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa }; +static const struct hyperv_guid hn_guid = { + .hv_guid = { + 0x63, 0x51, 0x61, 0xf8, 0x3e, 0xdf, 0xc5, 0x46, + 0x91, 0x3f, 0xf2, 0xd2, 0xf9, 0x65, 0xed, 0x0e } +}; + static device_method_t hn_methods[] = { /* Device interface */ DEVMETHOD(device_probe, hn_probe), @@ -796,8 +835,12 @@ hn_rxfilter_config(struct hn_softc *sc) HN_LOCK_ASSERT(sc); - if ((ifp->if_flags & IFF_PROMISC) || - (sc->hn_flags & HN_FLAG_RXVF)) { + /* + * If the non-transparent mode VF is activated, we don't know how + * its RX filter is configured, so stick the synthetic device in + * the promiscous mode. + */ + if ((ifp->if_flags & IFF_PROMISC) || (sc->hn_flags & HN_FLAG_RXVF)) { filter = NDIS_PACKET_TYPE_PROMISCUOUS; } else { filter = NDIS_PACKET_TYPE_DIRECTED; @@ -1073,7 +1116,7 @@ hn_rxvf_change(struct hn_softc *sc, struct ifnet *ifp, } hn_nvs_set_datapath(sc, - rxvf ? HN_NVS_DATAPATH_VF : HN_NVS_DATAPATH_SYNTHETIC); + rxvf ? HN_NVS_DATAPATH_VF : HN_NVS_DATAPATH_SYNTH); hn_rxvf_set(sc, rxvf ? ifp : NULL); @@ -1113,7 +1156,376 @@ hn_ifaddr_event(void *arg, struct ifnet *ifp) hn_rxvf_change(arg, ifp, ifp->if_flags & IFF_UP); } +static int +hn_xpnt_vf_iocsetcaps(struct hn_softc *sc, struct ifreq *ifr) +{ + struct ifnet *ifp, *vf_ifp; + uint64_t tmp; + int error; + + HN_LOCK_ASSERT(sc); + ifp = sc->hn_ifp; + vf_ifp = sc->hn_vf_ifp; + + /* + * Fix up requested capabilities w/ supported capabilities, + * since the supported capabilities could have been changed. + */ + ifr->ifr_reqcap &= ifp->if_capabilities; + /* Pass SIOCSIFCAP to VF. */ + error = vf_ifp->if_ioctl(vf_ifp, SIOCSIFCAP, (caddr_t)ifr); + + /* + * NOTE: + * The error will be propagated to the callers, however, it + * is _not_ useful here. + */ + + /* + * Merge VF's enabled capabilities. + */ + ifp->if_capenable = vf_ifp->if_capenable & ifp->if_capabilities; + + tmp = vf_ifp->if_hwassist & HN_CSUM_IP_HWASSIST(sc); + if (ifp->if_capenable & IFCAP_TXCSUM) + ifp->if_hwassist |= tmp; + else + ifp->if_hwassist &= ~tmp; + + tmp = vf_ifp->if_hwassist & HN_CSUM_IP6_HWASSIST(sc); + if (ifp->if_capenable & IFCAP_TXCSUM_IPV6) + ifp->if_hwassist |= tmp; + else + ifp->if_hwassist &= ~tmp; + + tmp = vf_ifp->if_hwassist & CSUM_IP_TSO; + if (ifp->if_capenable & IFCAP_TSO4) + ifp->if_hwassist |= tmp; + else + ifp->if_hwassist &= ~tmp; + + tmp = vf_ifp->if_hwassist & CSUM_IP6_TSO; + if (ifp->if_capenable & IFCAP_TSO6) + ifp->if_hwassist |= tmp; + else + ifp->if_hwassist &= ~tmp; + + return (error); +} + +static int +hn_xpnt_vf_iocsetflags(struct hn_softc *sc) +{ + struct ifnet *vf_ifp; + struct ifreq ifr; + + HN_LOCK_ASSERT(sc); + vf_ifp = sc->hn_vf_ifp; + + memset(&ifr, 0, sizeof(ifr)); + strlcpy(ifr.ifr_name, vf_ifp->if_xname, sizeof(ifr.ifr_name)); + ifr.ifr_flags = vf_ifp->if_flags & 0xffff; + ifr.ifr_flagshigh = vf_ifp->if_flags >> 16; + return (vf_ifp->if_ioctl(vf_ifp, SIOCSIFFLAGS, (caddr_t)&ifr)); +} + static void +hn_xpnt_vf_saveifflags(struct hn_softc *sc) +{ + struct ifnet *ifp = sc->hn_ifp; + int allmulti = 0; + + HN_LOCK_ASSERT(sc); + + /* XXX vlan(4) style mcast addr maintenance */ + if (!TAILQ_EMPTY(&ifp->if_multiaddrs)) + allmulti = IFF_ALLMULTI; + + /* Always set the VF's if_flags */ + sc->hn_vf_ifp->if_flags = ifp->if_flags | allmulti; +} + +static void +hn_xpnt_vf_input(struct ifnet *vf_ifp, struct mbuf *m) +{ + struct rm_priotracker pt; + struct ifnet *hn_ifp = NULL; + struct mbuf *mn; + + /* + * XXX racy, if hn(4) ever detached. + */ + rm_rlock(&hn_vfmap_lock, &pt); + if (vf_ifp->if_index < hn_vfmap_size) + hn_ifp = hn_vfmap[vf_ifp->if_index]; + rm_runlock(&hn_vfmap_lock, &pt); + + if (hn_ifp != NULL) { + for (mn = m; mn != NULL; mn = mn->m_nextpkt) { + /* + * Allow tapping on the VF. + */ + ETHER_BPF_MTAP(vf_ifp, mn); + + /* + * Update VF stats. + */ + if ((vf_ifp->if_capenable & IFCAP_HWSTATS) == 0) { + if_inc_counter(vf_ifp, IFCOUNTER_IBYTES, + mn->m_pkthdr.len); + } + /* + * XXX IFCOUNTER_IMCAST + * This stat updating is kinda invasive, since it + * requires two checks on the mbuf: the length check + * and the ethernet header check. As of this write, + * all multicast packets go directly to hn(4), which + * makes imcast stat updating in the VF a try in vian. + */ + + /* + * Fix up rcvif and increase hn(4)'s ipackets. + */ + mn->m_pkthdr.rcvif = hn_ifp; + if_inc_counter(hn_ifp, IFCOUNTER_IPACKETS, 1); + } + /* + * Go through hn(4)'s if_input. + */ + hn_ifp->if_input(hn_ifp, m); + } else { + /* + * In the middle of the transition; free this + * mbuf chain. + */ + while (m != NULL) { + mn = m->m_nextpkt; + m->m_nextpkt = NULL; + m_freem(m); + m = mn; + } + } +} + +static void +hn_mtu_change_fixup(struct hn_softc *sc) +{ + struct ifnet *ifp; + + HN_LOCK_ASSERT(sc); + ifp = sc->hn_ifp; + + hn_set_tso_maxsize(sc, hn_tso_maxlen, ifp->if_mtu); +#if __FreeBSD_version >= 1100099 + if (sc->hn_rx_ring[0].hn_lro.lro_length_lim < HN_LRO_LENLIM_MIN(ifp)) + hn_set_lro_lenlim(sc, HN_LRO_LENLIM_MIN(ifp)); +#endif +} + +static void +hn_xpnt_vf_setready(struct hn_softc *sc) +{ + struct ifnet *ifp, *vf_ifp; + struct ifreq ifr; + + HN_LOCK_ASSERT(sc); + ifp = sc->hn_ifp; + vf_ifp = sc->hn_vf_ifp; + + /* + * Mark the VF ready. + */ + sc->hn_vf_rdytick = 0; + + /* + * Save information for restoration. + */ + sc->hn_saved_caps = ifp->if_capabilities; + sc->hn_saved_tsomax = ifp->if_hw_tsomax; + sc->hn_saved_tsosegcnt = ifp->if_hw_tsomaxsegcount; + sc->hn_saved_tsosegsz = ifp->if_hw_tsomaxsegsize; + + /* + * Intersect supported/enabled capabilities. + * + * NOTE: + * if_hwassist is not changed here. + */ + ifp->if_capabilities &= vf_ifp->if_capabilities; + ifp->if_capenable &= ifp->if_capabilities; + + /* + * Fix TSO settings. + */ + if (ifp->if_hw_tsomax > vf_ifp->if_hw_tsomax) + ifp->if_hw_tsomax = vf_ifp->if_hw_tsomax; + if (ifp->if_hw_tsomaxsegcount > vf_ifp->if_hw_tsomaxsegcount) + ifp->if_hw_tsomaxsegcount = vf_ifp->if_hw_tsomaxsegcount; + if (ifp->if_hw_tsomaxsegsize > vf_ifp->if_hw_tsomaxsegsize) + ifp->if_hw_tsomaxsegsize = vf_ifp->if_hw_tsomaxsegsize; + + /* + * Change VF's enabled capabilities. + */ + memset(&ifr, 0, sizeof(ifr)); + strlcpy(ifr.ifr_name, vf_ifp->if_xname, sizeof(ifr.ifr_name)); + ifr.ifr_reqcap = ifp->if_capenable; + hn_xpnt_vf_iocsetcaps(sc, &ifr); + + if (ifp->if_mtu != ETHERMTU) { + int error; + + /* + * Change VF's MTU. + */ + memset(&ifr, 0, sizeof(ifr)); + strlcpy(ifr.ifr_name, vf_ifp->if_xname, sizeof(ifr.ifr_name)); + ifr.ifr_mtu = ifp->if_mtu; + error = vf_ifp->if_ioctl(vf_ifp, SIOCSIFMTU, (caddr_t)&ifr); + if (error) { + if_printf(ifp, "%s SIOCSIFMTU %lu failed\n", + vf_ifp->if_xname, ifp->if_mtu); + if (ifp->if_mtu > ETHERMTU) { + if_printf(ifp, "change MTU to %d\n", ETHERMTU); + + /* + * XXX + * No need to adjust the synthetic parts' MTU; + * failure of the adjustment will cause us + * infinite headache. + */ + ifp->if_mtu = ETHERMTU; + hn_mtu_change_fixup(sc); + } + } + } +} + +static bool +hn_xpnt_vf_isready(struct hn_softc *sc) +{ + + HN_LOCK_ASSERT(sc); + + if (!hn_xpnt_vf || sc->hn_vf_ifp == NULL) + return (false); + + if (sc->hn_vf_rdytick == 0) + return (true); + + if (sc->hn_vf_rdytick > ticks) + return (false); + + /* Mark VF as ready. */ + hn_xpnt_vf_setready(sc); + return (true); +} + +static void +hn_xpnt_vf_setenable(struct hn_softc *sc) +{ + int i; + + HN_LOCK_ASSERT(sc); + + /* NOTE: hn_vf_lock for hn_transmit()/hn_qflush() */ + rm_wlock(&sc->hn_vf_lock); + sc->hn_xvf_flags |= HN_XVFFLAG_ENABLED; + rm_wunlock(&sc->hn_vf_lock); + + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) + sc->hn_rx_ring[i].hn_rx_flags |= HN_RX_FLAG_XPNT_VF; +} + +static void +hn_xpnt_vf_setdisable(struct hn_softc *sc, bool clear_vf) +{ + int i; + + HN_LOCK_ASSERT(sc); + + /* NOTE: hn_vf_lock for hn_transmit()/hn_qflush() */ + rm_wlock(&sc->hn_vf_lock); + sc->hn_xvf_flags &= ~HN_XVFFLAG_ENABLED; + if (clear_vf) + sc->hn_vf_ifp = NULL; + rm_wunlock(&sc->hn_vf_lock); + + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) + sc->hn_rx_ring[i].hn_rx_flags &= ~HN_RX_FLAG_XPNT_VF; +} + +static void +hn_xpnt_vf_init(struct hn_softc *sc) +{ + int error; + + HN_LOCK_ASSERT(sc); + + KASSERT((sc->hn_xvf_flags & HN_XVFFLAG_ENABLED) == 0, + ("%s: transparent VF was enabled", sc->hn_ifp->if_xname)); + + if (bootverbose) { + if_printf(sc->hn_ifp, "try bringing up %s\n", + sc->hn_vf_ifp->if_xname); + } + + /* + * Bring the VF up. + */ + hn_xpnt_vf_saveifflags(sc); + sc->hn_vf_ifp->if_flags |= IFF_UP; + error = hn_xpnt_vf_iocsetflags(sc); + if (error) { + if_printf(sc->hn_ifp, "bringing up %s failed: %d\n", + sc->hn_vf_ifp->if_xname, error); + return; + } + + /* + * NOTE: + * Datapath setting must happen _after_ bringing the VF up. + */ + hn_nvs_set_datapath(sc, HN_NVS_DATAPATH_VF); + + /* Mark transparent mode VF as enabled. */ + hn_xpnt_vf_setenable(sc); +} + +static void +hn_xpnt_vf_init_taskfunc(void *xsc, int pending __unused) +{ + struct hn_softc *sc = xsc; + + HN_LOCK(sc); + + if ((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0) + goto done; + if (sc->hn_vf_ifp == NULL) + goto done; + if (sc->hn_xvf_flags & HN_XVFFLAG_ENABLED) + goto done; + + if (sc->hn_vf_rdytick != 0) { + /* Mark VF as ready. */ + hn_xpnt_vf_setready(sc); + } + + if (sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING) { + /* + * Delayed VF initialization. + */ + if (bootverbose) { + if_printf(sc->hn_ifp, "delayed initialize %s\n", + sc->hn_vf_ifp->if_xname); + } + hn_xpnt_vf_init(sc); + } +done: + HN_UNLOCK(sc); +} + +static void hn_ifnet_attevent(void *xsc, struct ifnet *ifp) { struct hn_softc *sc = xsc; @@ -1132,6 +1544,16 @@ hn_ifnet_attevent(void *xsc, struct ifnet *ifp) goto done; } + if (hn_xpnt_vf && ifp->if_start != NULL) { + /* + * ifnet.if_start is _not_ supported by transparent + * mode VF; mainly due to the IFF_DRV_OACTIVE flag. + */ + if_printf(sc->hn_ifp, "%s uses if_start, which is unsupported " + "in transparent VF mode.\n", ifp->if_xname); + goto done; + } + rm_wlock(&hn_vfmap_lock); if (ifp->if_index >= hn_vfmap_size) { @@ -1155,7 +1577,37 @@ hn_ifnet_attevent(void *xsc, struct ifnet *ifp) rm_wunlock(&hn_vfmap_lock); + /* NOTE: hn_vf_lock for hn_transmit()/hn_qflush() */ + rm_wlock(&sc->hn_vf_lock); + KASSERT((sc->hn_xvf_flags & HN_XVFFLAG_ENABLED) == 0, + ("%s: transparent VF was enabled", sc->hn_ifp->if_xname)); sc->hn_vf_ifp = ifp; + rm_wunlock(&sc->hn_vf_lock); + + if (hn_xpnt_vf) { + int wait_ticks; + + /* + * Install if_input for vf_ifp, which does vf_ifp -> hn_ifp. + * Save vf_ifp's current if_input for later restoration. + */ + sc->hn_vf_input = ifp->if_input; + ifp->if_input = hn_xpnt_vf_input; + + /* + * Stop link status management; use the VF's. + */ + hn_suspend_mgmt(sc); + + /* + * Give VF sometime to complete its attach routing. + */ + wait_ticks = hn_xpnt_vf_attwait * hz; + sc->hn_vf_rdytick = ticks + wait_ticks; + + taskqueue_enqueue_timeout(sc->hn_vf_taskq, &sc->hn_vf_init, + wait_ticks); + } done: HN_UNLOCK(sc); } @@ -1173,8 +1625,59 @@ hn_ifnet_detevent(void *xsc, struct ifnet *ifp) if (!hn_ismyvf(sc, ifp)) goto done; - sc->hn_vf_ifp = NULL; + if (hn_xpnt_vf) { + /* + * Make sure that the delayed initialization is not running. + * + * NOTE: + * - This lock _must_ be released, since the hn_vf_init task + * will try holding this lock. + * - It is safe to release this lock here, since the + * hn_ifnet_attevent() is interlocked by the hn_vf_ifp. + * + * XXX racy, if hn(4) ever detached. + */ + HN_UNLOCK(sc); + taskqueue_drain_timeout(sc->hn_vf_taskq, &sc->hn_vf_init); + HN_LOCK(sc); + KASSERT(sc->hn_vf_input != NULL, ("%s VF input is not saved", + sc->hn_ifp->if_xname)); + ifp->if_input = sc->hn_vf_input; + sc->hn_vf_input = NULL; + + if (sc->hn_xvf_flags & HN_XVFFLAG_ENABLED) + hn_nvs_set_datapath(sc, HN_NVS_DATAPATH_SYNTH); + + if (sc->hn_vf_rdytick == 0) { + /* + * The VF was ready; restore some settings. + */ + sc->hn_ifp->if_capabilities = sc->hn_saved_caps; + /* + * NOTE: + * There is _no_ need to fixup if_capenable and + * if_hwassist, since the if_capabilities before + * restoration was an intersection of the VF's + * if_capabilites and the synthetic device's + * if_capabilites. + */ + sc->hn_ifp->if_hw_tsomax = sc->hn_saved_tsomax; + sc->hn_ifp->if_hw_tsomaxsegcount = + sc->hn_saved_tsosegcnt; + sc->hn_ifp->if_hw_tsomaxsegsize = sc->hn_saved_tsosegsz; + } + + /* + * Resume link status management, which was suspended + * by hn_ifnet_attevent(). + */ + hn_resume_mgmt(sc); + } + + /* Mark transparent mode VF as disabled. */ + hn_xpnt_vf_setdisable(sc, true /* clear hn_vf_ifp */); + rm_wlock(&hn_vfmap_lock); KASSERT(ifp->if_index < hn_vfmap_size, @@ -1192,18 +1695,20 @@ done: HN_UNLOCK(sc); } -/* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */ -static const struct hyperv_guid g_net_vsc_device_type = { - .hv_guid = {0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, - 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E} -}; +static void +hn_ifnet_lnkevent(void *xsc, struct ifnet *ifp, int link_state) +{ + struct hn_softc *sc = xsc; + if (sc->hn_vf_ifp == ifp) + if_link_state_change(sc->hn_ifp, link_state); +} + static int hn_probe(device_t dev) { - if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, - &g_net_vsc_device_type) == 0) { + if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, &hn_guid) == 0) { device_set_desc(dev, "Hyper-V Network Interface"); return BUS_PROBE_DEFAULT; } @@ -1223,6 +1728,9 @@ hn_attach(device_t dev) sc->hn_dev = dev; sc->hn_prichan = vmbus_get_channel(dev); HN_LOCK_INIT(sc); + rm_init(&sc->hn_vf_lock, "hnvf"); + if (hn_xpnt_vf && hn_xpnt_vf_accbpf) + sc->hn_xvf_flags |= HN_XVFFLAG_ACCBPF; /* * Initialize these tunables once. @@ -1262,6 +1770,18 @@ hn_attach(device_t dev) TIMEOUT_TASK_INIT(sc->hn_mgmt_taskq0, &sc->hn_netchg_status, 0, hn_netchg_status_taskfunc, sc); + if (hn_xpnt_vf) { + /* + * Setup taskqueue for VF tasks, e.g. delayed VF bringing up. + */ + sc->hn_vf_taskq = taskqueue_create("hn_vf", M_WAITOK, + taskqueue_thread_enqueue, &sc->hn_vf_taskq); + taskqueue_start_threads(&sc->hn_vf_taskq, 1, PI_NET, "%s vf", + device_get_nameunit(dev)); + TIMEOUT_TASK_INIT(sc->hn_vf_taskq, &sc->hn_vf_init, 0, + hn_xpnt_vf_init_taskfunc, sc); + } + /* * Allocate ifnet and setup its name earlier, so that if_printf * can be used by functions, which will be called after @@ -1384,6 +1904,14 @@ hn_attach(device_t dev) SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "hwassist", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, hn_hwassist_sysctl, "A", "hwassist"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "tso_max", + CTLFLAG_RD, &ifp->if_hw_tsomax, 0, "max TSO size"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "tso_maxsegcnt", + CTLFLAG_RD, &ifp->if_hw_tsomaxsegcount, 0, + "max # of TSO segments"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "tso_maxsegsz", + CTLFLAG_RD, &ifp->if_hw_tsomaxsegsize, 0, + "max size of TSO segment"); SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rxfilter", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, hn_rxfilter_sysctl, "A", "rxfilter"); @@ -1423,9 +1951,20 @@ hn_attach(device_t dev) SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "vf", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, hn_vf_sysctl, "A", "Virtual Function's name"); - SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rxvf", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, - hn_rxvf_sysctl, "A", "activated Virtual Function's name"); + if (!hn_xpnt_vf) { + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rxvf", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_rxvf_sysctl, "A", "activated Virtual Function's name"); + } else { + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "vf_xpnt_enabled", + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_xpnt_vf_enabled_sysctl, "I", + "Transparent VF enabled"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "vf_xpnt_accbpf", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, + hn_xpnt_vf_accbpf_sysctl, "I", + "Accurate BPF for transparent VF"); + } /* * Setup the ifmedia, which has been initialized earlier. @@ -1463,7 +2002,7 @@ hn_attach(device_t dev) ifp->if_qflush = hn_xmit_qflush; } - ifp->if_capabilities |= IFCAP_RXCSUM | IFCAP_LRO; + ifp->if_capabilities |= IFCAP_RXCSUM | IFCAP_LRO | IFCAP_LINKSTATE; #ifdef foo /* We can't diff IPv6 packets from IPv4 packets on RX path. */ ifp->if_capabilities |= IFCAP_RXCSUM_IPV6; @@ -1498,7 +2037,13 @@ hn_attach(device_t dev) ifp->if_hwassist &= ~(HN_CSUM_IP6_MASK | CSUM_IP6_TSO); if (ifp->if_capabilities & (IFCAP_TSO6 | IFCAP_TSO4)) { + /* + * Lock hn_set_tso_maxsize() to simplify its + * internal logic. + */ + HN_LOCK(sc); hn_set_tso_maxsize(sc, hn_tso_maxlen, ETHERMTU); + HN_UNLOCK(sc); ifp->if_hw_tsomaxsegcount = HN_TX_DATA_SEGCNT_MAX; ifp->if_hw_tsomaxsegsize = PAGE_SIZE; } @@ -1519,10 +2064,15 @@ hn_attach(device_t dev) sc->hn_mgmt_taskq = sc->hn_mgmt_taskq0; hn_update_link_status(sc); - sc->hn_ifnet_evthand = EVENTHANDLER_REGISTER(ifnet_event, - hn_ifnet_event, sc, EVENTHANDLER_PRI_ANY); - sc->hn_ifaddr_evthand = EVENTHANDLER_REGISTER(ifaddr_event, - hn_ifaddr_event, sc, EVENTHANDLER_PRI_ANY); + if (!hn_xpnt_vf) { + sc->hn_ifnet_evthand = EVENTHANDLER_REGISTER(ifnet_event, + hn_ifnet_event, sc, EVENTHANDLER_PRI_ANY); + sc->hn_ifaddr_evthand = EVENTHANDLER_REGISTER(ifaddr_event, + hn_ifaddr_event, sc, EVENTHANDLER_PRI_ANY); + } else { + sc->hn_ifnet_lnkhand = EVENTHANDLER_REGISTER(ifnet_link_event, + hn_ifnet_lnkevent, sc, EVENTHANDLER_PRI_ANY); + } /* * NOTE: @@ -1549,6 +2099,14 @@ hn_detach(device_t dev) struct hn_softc *sc = device_get_softc(dev); struct ifnet *ifp = sc->hn_ifp, *vf_ifp; + if (sc->hn_xact != NULL && vmbus_chan_is_revoked(sc->hn_prichan)) { + /* + * In case that the vmbus missed the orphan handler + * installation. + */ + vmbus_xact_ctx_orphan(sc->hn_xact); + } + if (sc->hn_ifaddr_evthand != NULL) EVENTHANDLER_DEREGISTER(ifaddr_event, sc->hn_ifaddr_evthand); if (sc->hn_ifnet_evthand != NULL) @@ -1561,20 +2119,14 @@ hn_detach(device_t dev) EVENTHANDLER_DEREGISTER(ifnet_departure_event, sc->hn_ifnet_dethand); } + if (sc->hn_ifnet_lnkhand != NULL) + EVENTHANDLER_DEREGISTER(ifnet_link_event, sc->hn_ifnet_lnkhand); vf_ifp = sc->hn_vf_ifp; __compiler_membar(); if (vf_ifp != NULL) hn_ifnet_detevent(sc, vf_ifp); - if (sc->hn_xact != NULL && vmbus_chan_is_revoked(sc->hn_prichan)) { - /* - * In case that the vmbus missed the orphan handler - * installation. - */ - vmbus_xact_ctx_orphan(sc->hn_xact); - } - if (device_is_attached(dev)) { HN_LOCK(sc); if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) { @@ -1604,6 +2156,8 @@ hn_detach(device_t dev) free(sc->hn_tx_taskqs, M_DEVBUF); } taskqueue_free(sc->hn_mgmt_taskq0); + if (sc->hn_vf_taskq != NULL) + taskqueue_free(sc->hn_vf_taskq); if (sc->hn_xact != NULL) { /* @@ -1617,6 +2171,7 @@ hn_detach(device_t dev) if_free(ifp); HN_LOCK_DESTROY(sc); + rm_destroy(&sc->hn_vf_lock); return (0); } @@ -2458,13 +3013,16 @@ static int hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int dlen, const struct hn_rxinfo *info) { - struct ifnet *ifp; + struct ifnet *ifp, *hn_ifp = rxr->hn_ifp; struct mbuf *m_new; int size, do_lro = 0, do_csum = 1; int hash_type = M_HASHTYPE_OPAQUE; - /* If the VF is active, inject the packet through the VF */ - ifp = rxr->hn_rxvf_ifp ? rxr->hn_rxvf_ifp : rxr->hn_ifp; + /* + * If the non-transparent mode VF is active, inject this packet + * into the VF. + */ + ifp = rxr->hn_rxvf_ifp ? rxr->hn_rxvf_ifp : hn_ifp; if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { /* @@ -2478,10 +3036,15 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int return (0); } + if (__predict_false(dlen < ETHER_HDR_LEN)) { + if_inc_counter(hn_ifp, IFCOUNTER_IERRORS, 1); + return (0); + } + if (dlen <= MHLEN) { m_new = m_gethdr(M_NOWAIT, MT_DATA); if (m_new == NULL) { - if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); + if_inc_counter(hn_ifp, IFCOUNTER_IQDROPS, 1); return (0); } memcpy(mtod(m_new, void *), data, dlen); @@ -2502,7 +3065,7 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int m_new = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, size); if (m_new == NULL) { - if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); + if_inc_counter(hn_ifp, IFCOUNTER_IQDROPS, 1); return (0); } @@ -2510,7 +3073,7 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int } m_new->m_pkthdr.rcvif = ifp; - if (__predict_false((ifp->if_capenable & IFCAP_RXCSUM) == 0)) + if (__predict_false((hn_ifp->if_capenable & IFCAP_RXCSUM) == 0)) do_csum = 0; /* receive side checksum offload */ @@ -2551,8 +3114,9 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int int hoff; hoff = sizeof(*eh); - if (m_new->m_len < hoff) - goto skip; + /* Checked at the beginning of this function. */ + KASSERT(m_new->m_len >= hoff, ("not ethernet frame")); + eh = mtod(m_new, struct ether_header *); etype = ntohs(eh->ether_type); if (etype == ETHERTYPE_VLAN) { @@ -2607,6 +3171,37 @@ skip: m_new->m_flags |= M_VLANTAG; } + /* + * If VF is activated (tranparent/non-transparent mode does not + * matter here). + * + * - Don't setup mbuf hash, if 'options RSS' is set. + * + * In Azure, when VF is activated, TCP SYN and SYN|ACK go + * through hn(4) while the rest of segments and ACKs belonging + * to the same TCP 4-tuple go through the VF. So don't setup + * mbuf hash, if a VF is activated and 'options RSS' is not + * enabled. hn(4) and the VF may use neither the same RSS + * hash key nor the same RSS hash function, so the hash value + * for packets belonging to the same flow could be different! + * + * - Disable LRO + * + * hn(4) will only receive broadcast packets, multicast packets, + * TCP SYN and SYN|ACK (in Azure), LRO is useless for these + * packet types. + * + * For non-transparent, we definitely _cannot_ enable LRO at + * all, since the LRO flush will use hn(4) as the receiving + * interface; i.e. hn_ifp->if_input(hn_ifp, m). + */ + if (hn_ifp != ifp || (rxr->hn_rx_flags & HN_RX_FLAG_XPNT_VF)) { + do_lro = 0; /* disable LRO. */ +#ifndef RSS + goto skip_hash; /* skip mbuf hash setup */ +#endif + } + if (info->hash_info != HN_NDIS_HASH_INFO_INVALID) { rxr->hn_rss_pkts++; m_new->m_pkthdr.flowid = info->hash_value; @@ -2654,15 +3249,36 @@ skip: } M_HASHTYPE_SET(m_new, hash_type); - /* - * Note: Moved RX completion back to hv_nv_on_receive() so all - * messages (not just data messages) will trigger a response. - */ +#ifndef RSS +skip_hash: +#endif + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); + if (hn_ifp != ifp) { + const struct ether_header *eh; - ifp->if_ipackets++; + /* + * Non-transparent mode VF is activated. + */ + + /* + * Allow tapping on hn(4). + */ + ETHER_BPF_MTAP(hn_ifp, m_new); + + /* + * Update hn(4)'s stats. + */ + if_inc_counter(hn_ifp, IFCOUNTER_IPACKETS, 1); + if_inc_counter(hn_ifp, IFCOUNTER_IBYTES, m_new->m_pkthdr.len); + /* Checked at the beginning of this function. */ + KASSERT(m_new->m_len >= ETHER_HDR_LEN, ("not ethernet frame")); + eh = mtod(m_new, struct ether_header *); + if (ETHER_IS_MULTICAST(eh->ether_dhost)) + if_inc_counter(hn_ifp, IFCOUNTER_IMCASTS, 1); + } rxr->hn_pkts++; - if ((ifp->if_capenable & IFCAP_LRO) && do_lro) { + if ((hn_ifp->if_capenable & IFCAP_LRO) && do_lro) { #if defined(INET) || defined(INET6) struct lro_ctrl *lro = &rxr->hn_lro; @@ -2675,10 +3291,8 @@ skip: } #endif } + ifp->if_input(ifp, m_new); - /* We're not holding the lock here, so don't release it */ - (*ifp->if_input)(ifp, m_new); - return (0); } @@ -2686,7 +3300,8 @@ static int hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { struct hn_softc *sc = ifp->if_softc; - struct ifreq *ifr = (struct ifreq *)data; + struct ifreq *ifr = (struct ifreq *)data, ifr_vf; + struct ifnet *vf_ifp; int mask, error = 0; switch (cmd) { @@ -2715,6 +3330,21 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; } + if (hn_xpnt_vf_isready(sc)) { + vf_ifp = sc->hn_vf_ifp; + ifr_vf = *ifr; + strlcpy(ifr_vf.ifr_name, vf_ifp->if_xname, + sizeof(ifr_vf.ifr_name)); + error = vf_ifp->if_ioctl(vf_ifp, SIOCSIFMTU, + (caddr_t)&ifr_vf); + if (error) { + HN_UNLOCK(sc); + if_printf(ifp, "%s SIOCSIFMTU %d failed: %d\n", + vf_ifp->if_xname, ifr->ifr_mtu, error); + break; + } + } + /* * Suspend this interface before the synthetic parts * are ripped. @@ -2743,23 +3373,33 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) ifp->if_mtu = ifr->ifr_mtu; /* - * Make sure that various parameters based on MTU are - * still valid, after the MTU change. + * Synthetic parts' reattach may change the chimney *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Mon Aug 21 09:03:22 2017 Return-Path: Delivered-To: svn-src-stable@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 2F6E9DEFFBB; Mon, 21 Aug 2017 09:03:22 +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 087EA65BFB; Mon, 21 Aug 2017 09:03:21 +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 v7L93LoJ009085; Mon, 21 Aug 2017 09:03:21 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7L93KuH009080; Mon, 21 Aug 2017 09:03:20 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201708210903.v7L93KuH009080@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 21 Aug 2017 09:03: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: r322741 - in stable/11/sys: net netipsec X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: in stable/11/sys: net netipsec X-SVN-Commit-Revision: 322741 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Aug 2017 09:03:22 -0000 Author: ae Date: Mon Aug 21 09:03:20 2017 New Revision: 322741 URL: https://svnweb.freebsd.org/changeset/base/322741 Log: MFC r321779: Add inpcb pointer to struct ipsec_ctx_data and pass it to the pfil hook from enc_hhook(). This should solve the problem when pf is used with if_enc(4) interface, and outbound packet with existing PCB checked by pf, and this leads to deadlock due to pf does its own PCB lookup and tries to take rlock when wlock is already held. Now we pass PCB pointer if it is known to the pfil hook, this helps to avoid extra PCB lookup and thus rlock acquiring is not needed. For inbound packets it is safe to pass NULL, because we do not held any PCB locks yet. PR: 220217 Sponsored by: Yandex LLC Modified: stable/11/sys/net/if_enc.c stable/11/sys/net/if_enc.h stable/11/sys/netipsec/ipsec.h stable/11/sys/netipsec/ipsec_input.c stable/11/sys/netipsec/ipsec_output.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/net/if_enc.c ============================================================================== --- stable/11/sys/net/if_enc.c Mon Aug 21 07:03:02 2017 (r322740) +++ stable/11/sys/net/if_enc.c Mon Aug 21 09:03:20 2017 (r322741) @@ -284,7 +284,7 @@ enc_hhook(int32_t hhook_type, int32_t hhook_id, void * /* Make a packet looks like it was received on enc(4) */ rcvif = (*ctx->mp)->m_pkthdr.rcvif; (*ctx->mp)->m_pkthdr.rcvif = ifp; - if (pfil_run_hooks(ph, ctx->mp, ifp, pdir, NULL) != 0 || + if (pfil_run_hooks(ph, ctx->mp, ifp, pdir, ctx->inp) != 0 || *ctx->mp == NULL) { *ctx->mp = NULL; /* consumed by filter */ return (EACCES); Modified: stable/11/sys/net/if_enc.h ============================================================================== --- stable/11/sys/net/if_enc.h Mon Aug 21 07:03:02 2017 (r322740) +++ stable/11/sys/net/if_enc.h Mon Aug 21 09:03:20 2017 (r322741) @@ -33,6 +33,7 @@ struct ipsec_ctx_data { struct mbuf **mp; struct secasvar *sav; + struct inpcb *inp; uint8_t af; #define IPSEC_ENC_BEFORE 0x01 #define IPSEC_ENC_AFTER 0x02 Modified: stable/11/sys/netipsec/ipsec.h ============================================================================== --- stable/11/sys/netipsec/ipsec.h Mon Aug 21 07:03:02 2017 (r322740) +++ stable/11/sys/netipsec/ipsec.h Mon Aug 21 09:03:20 2017 (r322741) @@ -253,8 +253,9 @@ struct ipsecstat { #include struct ipsec_ctx_data; -#define IPSEC_INIT_CTX(_ctx, _mp, _sav, _af, _enc) do { \ +#define IPSEC_INIT_CTX(_ctx, _mp, _inp, _sav, _af, _enc) do { \ (_ctx)->mp = (_mp); \ + (_ctx)->inp = (_inp); \ (_ctx)->sav = (_sav); \ (_ctx)->af = (_af); \ (_ctx)->enc = (_enc); \ Modified: stable/11/sys/netipsec/ipsec_input.c ============================================================================== --- stable/11/sys/netipsec/ipsec_input.c Mon Aug 21 07:03:02 2017 (r322740) +++ stable/11/sys/netipsec/ipsec_input.c Mon Aug 21 09:03:20 2017 (r322741) @@ -325,7 +325,7 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar (prot == IPPROTO_UDP || prot == IPPROTO_TCP)) udp_ipsec_adjust_cksum(m, sav, prot, skip); - IPSEC_INIT_CTX(&ctx, &m, sav, AF_INET, IPSEC_ENC_BEFORE); + IPSEC_INIT_CTX(&ctx, &m, NULL, sav, AF_INET, IPSEC_ENC_BEFORE); if ((error = ipsec_run_hhooks(&ctx, HHOOK_TYPE_IPSEC_IN)) != 0) goto bad; ip = mtod(m, struct ip *); /* update pointer */ @@ -416,7 +416,7 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar goto bad; } - IPSEC_INIT_CTX(&ctx, &m, sav, af, IPSEC_ENC_AFTER); + IPSEC_INIT_CTX(&ctx, &m, NULL, sav, af, IPSEC_ENC_AFTER); if ((error = ipsec_run_hhooks(&ctx, HHOOK_TYPE_IPSEC_IN)) != 0) goto bad; @@ -522,7 +522,7 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar goto bad; } - IPSEC_INIT_CTX(&ctx, &m, sav, af, IPSEC_ENC_BEFORE); + IPSEC_INIT_CTX(&ctx, &m, NULL, sav, af, IPSEC_ENC_BEFORE); if ((error = ipsec_run_hhooks(&ctx, HHOOK_TYPE_IPSEC_IN)) != 0) goto bad; @@ -593,7 +593,7 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar else #endif af = AF_INET6; - IPSEC_INIT_CTX(&ctx, &m, sav, af, IPSEC_ENC_AFTER); + IPSEC_INIT_CTX(&ctx, &m, NULL, sav, af, IPSEC_ENC_AFTER); if ((error = ipsec_run_hhooks(&ctx, HHOOK_TYPE_IPSEC_IN)) != 0) goto bad; if (skip == 0) { Modified: stable/11/sys/netipsec/ipsec_output.c ============================================================================== --- stable/11/sys/netipsec/ipsec_output.c Mon Aug 21 07:03:02 2017 (r322740) +++ stable/11/sys/netipsec/ipsec_output.c Mon Aug 21 09:03:20 2017 (r322741) @@ -181,7 +181,8 @@ next: * IPsec output logic for IPv4. */ static int -ipsec4_perform_request(struct mbuf *m, struct secpolicy *sp, u_int idx) +ipsec4_perform_request(struct mbuf *m, struct secpolicy *sp, + struct inpcb *inp, u_int idx) { struct ipsec_ctx_data ctx; union sockaddr_union *dst; @@ -211,7 +212,7 @@ ipsec4_perform_request(struct mbuf *m, struct secpolic /* * XXXAE: most likely ip_sum at this point is wrong. */ - IPSEC_INIT_CTX(&ctx, &m, sav, AF_INET, IPSEC_ENC_BEFORE); + IPSEC_INIT_CTX(&ctx, &m, inp, sav, AF_INET, IPSEC_ENC_BEFORE); if ((error = ipsec_run_hhooks(&ctx, HHOOK_TYPE_IPSEC_OUT)) != 0) goto bad; @@ -235,9 +236,10 @@ ipsec4_perform_request(struct mbuf *m, struct secpolic /* XXXAE: IPSEC_OSTAT_INC(tunnel); */ goto bad; } + inp = NULL; } - IPSEC_INIT_CTX(&ctx, &m, sav, dst->sa.sa_family, IPSEC_ENC_AFTER); + IPSEC_INIT_CTX(&ctx, &m, inp, sav, dst->sa.sa_family, IPSEC_ENC_AFTER); if ((error = ipsec_run_hhooks(&ctx, HHOOK_TYPE_IPSEC_OUT)) != 0) goto bad; @@ -285,7 +287,7 @@ ipsec4_process_packet(struct mbuf *m, struct secpolicy struct inpcb *inp) { - return (ipsec4_perform_request(m, sp, 0)); + return (ipsec4_perform_request(m, sp, inp, 0)); } static int @@ -491,7 +493,8 @@ next: * IPsec output logic for IPv6. */ static int -ipsec6_perform_request(struct mbuf *m, struct secpolicy *sp, u_int idx) +ipsec6_perform_request(struct mbuf *m, struct secpolicy *sp, + struct inpcb *inp, u_int idx) { struct ipsec_ctx_data ctx; union sockaddr_union *dst; @@ -514,7 +517,7 @@ ipsec6_perform_request(struct mbuf *m, struct secpolic ip6 = mtod(m, struct ip6_hdr *); ip6->ip6_plen = htons(m->m_pkthdr.len - sizeof(*ip6)); - IPSEC_INIT_CTX(&ctx, &m, sav, AF_INET6, IPSEC_ENC_BEFORE); + IPSEC_INIT_CTX(&ctx, &m, inp, sav, AF_INET6, IPSEC_ENC_BEFORE); if ((error = ipsec_run_hhooks(&ctx, HHOOK_TYPE_IPSEC_OUT)) != 0) goto bad; @@ -540,9 +543,10 @@ ipsec6_perform_request(struct mbuf *m, struct secpolic /* XXXAE: IPSEC_OSTAT_INC(tunnel); */ goto bad; } + inp = NULL; } - IPSEC_INIT_CTX(&ctx, &m, sav, dst->sa.sa_family, IPSEC_ENC_AFTER); + IPSEC_INIT_CTX(&ctx, &m, inp, sav, dst->sa.sa_family, IPSEC_ENC_AFTER); if ((error = ipsec_run_hhooks(&ctx, HHOOK_TYPE_IPSEC_OUT)) != 0) goto bad; @@ -585,7 +589,7 @@ ipsec6_process_packet(struct mbuf *m, struct secpolicy struct inpcb *inp) { - return (ipsec6_perform_request(m, sp, 0)); + return (ipsec6_perform_request(m, sp, inp, 0)); } static int @@ -750,14 +754,14 @@ ipsec_process_done(struct mbuf *m, struct secpolicy *s case AF_INET: key_freesav(&sav); IPSECSTAT_INC(ips_out_bundlesa); - return (ipsec4_perform_request(m, sp, idx)); + return (ipsec4_perform_request(m, sp, NULL, idx)); /* NOTREACHED */ #endif #ifdef INET6 case AF_INET6: key_freesav(&sav); IPSEC6STAT_INC(ips_out_bundlesa); - return (ipsec6_perform_request(m, sp, idx)); + return (ipsec6_perform_request(m, sp, NULL, idx)); /* NOTREACHED */ #endif /* INET6 */ default: From owner-svn-src-stable@freebsd.org Mon Aug 21 09:04:44 2017 Return-Path: Delivered-To: svn-src-stable@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 E4B7BDC817D; Mon, 21 Aug 2017 09:04:44 +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 AFEDC65E37; Mon, 21 Aug 2017 09:04:44 +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 v7L94hwT009193; Mon, 21 Aug 2017 09:04:43 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7L94hfE009192; Mon, 21 Aug 2017 09:04:43 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201708210904.v7L94hfE009192@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 21 Aug 2017 09:04:43 +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: r322742 - stable/11/sys/amd64/include X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/amd64/include X-SVN-Commit-Revision: 322742 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Aug 2017 09:04:45 -0000 Author: kib Date: Mon Aug 21 09:04:43 2017 New Revision: 322742 URL: https://svnweb.freebsd.org/changeset/base/322742 Log: MFC r322495: Add {rd,wr}{fs,gs}base C wrappers for instructions. Modified: stable/11/sys/amd64/include/cpufunc.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/include/cpufunc.h ============================================================================== --- stable/11/sys/amd64/include/cpufunc.h Mon Aug 21 09:03:20 2017 (r322741) +++ stable/11/sys/amd64/include/cpufunc.h Mon Aug 21 09:04:43 2017 (r322742) @@ -651,6 +651,38 @@ load_gs(u_short sel) } #endif +static __inline uint64_t +rdfsbase(void) +{ + uint64_t x; + + __asm __volatile("rdfsbase %0" : "=r" (x)); + return (x); +} + +static __inline void +wrfsbase(uint64_t x) +{ + + __asm __volatile("wrfsbase %0" : : "r" (x)); +} + +static __inline uint64_t +rdgsbase(void) +{ + uint64_t x; + + __asm __volatile("rdgsbase %0" : "=r" (x)); + return (x); +} + +static __inline void +wrgsbase(uint64_t x) +{ + + __asm __volatile("wrgsbase %0" : : "r" (x)); +} + static __inline void bare_lgdt(struct region_descriptor *addr) { From owner-svn-src-stable@freebsd.org Mon Aug 21 09:52:16 2017 Return-Path: Delivered-To: svn-src-stable@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 9ABA3DCCFA7; Mon, 21 Aug 2017 09:52:16 +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 5D9B16778D; Mon, 21 Aug 2017 09:52:16 +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 v7L9qFQi028596; Mon, 21 Aug 2017 09:52:15 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7L9qF6K028595; Mon, 21 Aug 2017 09:52:15 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201708210952.v7L9qF6K028595@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 21 Aug 2017 09:52: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: r322743 - stable/11/sys/amd64/amd64 X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/amd64/amd64 X-SVN-Commit-Revision: 322743 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Aug 2017 09:52:16 -0000 Author: kib Date: Mon Aug 21 09:52:15 2017 New Revision: 322743 URL: https://svnweb.freebsd.org/changeset/base/322743 Log: MFC r322496: Print whole machine state on double fault. Modified: stable/11/sys/amd64/amd64/trap.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/trap.c ============================================================================== --- stable/11/sys/amd64/amd64/trap.c Mon Aug 21 09:04:43 2017 (r322742) +++ stable/11/sys/amd64/amd64/trap.c Mon Aug 21 09:52:15 2017 (r322743) @@ -822,10 +822,24 @@ dblfault_handler(struct trapframe *frame) if (dtrace_doubletrap_func != NULL) (*dtrace_doubletrap_func)(); #endif - printf("\nFatal double fault\n"); - printf("rip = 0x%lx\n", frame->tf_rip); - printf("rsp = 0x%lx\n", frame->tf_rsp); - printf("rbp = 0x%lx\n", frame->tf_rbp); + printf("\nFatal double fault\n" + "rip %#lx rsp %#lx rbp %#lx\n" + "rax %#lx rdx %#lx rbx %#lx\n" + "rcx %#lx rsi %#lx rdi %#lx\n" + "r8 %#lx r9 %#lx r10 %#lx\n" + "r11 %#lx r12 %#lx r13 %#lx\n" + "r14 %#lx r15 %#lx rflags %#lx\n" + "cs %#lx ss %#lx ds %#hx es %#hx fs %#hx gs %#hx\n" + "fsbase %#lx gsbase %#lx kgsbase %#lx\n", + frame->tf_rip, frame->tf_rsp, frame->tf_rbp, + frame->tf_rax, frame->tf_rdx, frame->tf_rbx, + frame->tf_rcx, frame->tf_rdi, frame->tf_rsi, + frame->tf_r8, frame->tf_r9, frame->tf_r10, + frame->tf_r11, frame->tf_r12, frame->tf_r13, + frame->tf_r14, frame->tf_r15, frame->tf_rflags, + frame->tf_cs, frame->tf_ss, frame->tf_ds, frame->tf_es, + frame->tf_fs, frame->tf_gs, + rdmsr(MSR_FSBASE), rdmsr(MSR_GSBASE), rdmsr(MSR_KGSBASE)); #ifdef SMP /* two separate prints in case of a trap on an unmapped page */ printf("cpuid = %d; ", PCPU_GET(cpuid)); From owner-svn-src-stable@freebsd.org Mon Aug 21 10:07:14 2017 Return-Path: Delivered-To: svn-src-stable@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 6006FDCDBB6; Mon, 21 Aug 2017 10:07:14 +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 3A3A86811A; Mon, 21 Aug 2017 10:07:14 +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 v7LA7Dcv033339; Mon, 21 Aug 2017 10:07:13 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7LA7DvM033335; Mon, 21 Aug 2017 10:07:13 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201708211007.v7LA7DvM033335@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 21 Aug 2017 10:07:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r322744 - in stable/10: share/man/man4 sys/conf sys/modules/geom/geom_map X-SVN-Group: stable-10 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: in stable/10: share/man/man4 sys/conf sys/modules/geom/geom_map X-SVN-Commit-Revision: 322744 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Aug 2017 10:07:14 -0000 Author: ae Date: Mon Aug 21 10:07:12 2017 New Revision: 322744 URL: https://svnweb.freebsd.org/changeset/base/322744 Log: MFC r284152: Add makefile to build geom_map kld. Document some GEOM_* options in NOTES and geom(4). PR: 197766 Approved by: re (kib) Added: stable/10/sys/modules/geom/geom_map/ - copied from r284152, head/sys/modules/geom/geom_map/ Modified: stable/10/share/man/man4/geom.4 stable/10/share/man/man4/geom_map.4 stable/10/sys/conf/NOTES stable/10/sys/conf/options Directory Properties: stable/10/ (props changed) Modified: stable/10/share/man/man4/geom.4 ============================================================================== --- stable/10/share/man/man4/geom.4 Mon Aug 21 09:52:15 2017 (r322743) +++ stable/10/share/man/man4/geom.4 Mon Aug 21 10:07:12 2017 (r322744) @@ -34,7 +34,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 10, 2013 +.Dd June 8, 2015 .Dt GEOM 4 .Os .Sh NAME @@ -52,12 +52,14 @@ .Cd options GEOM_JOURNAL .Cd options GEOM_LABEL .Cd options GEOM_LINUX_LVM +.Cd options GEOM_MAP .Cd options GEOM_MBR .Cd options GEOM_MIRROR .Cd options GEOM_MULTIPATH .Cd options GEOM_NOP .Cd options GEOM_PART_APM .Cd options GEOM_PART_BSD +.Cd options GEOM_PART_BSD64 .Cd options GEOM_PART_EBR .Cd options GEOM_PART_EBR_COMPAT .Cd options GEOM_PART_GPT @@ -71,6 +73,7 @@ .Cd options GEOM_SHSEC .Cd options GEOM_STRIPE .Cd options GEOM_SUNLABEL +.Cd options GEOM_UNCOMPRESS .Cd options GEOM_UZIP .Cd options GEOM_VIRSTOR .Cd options GEOM_VOL Modified: stable/10/share/man/man4/geom_map.4 ============================================================================== --- stable/10/share/man/man4/geom_map.4 Mon Aug 21 09:52:15 2017 (r322743) +++ stable/10/share/man/man4/geom_map.4 Mon Aug 21 10:07:12 2017 (r322744) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 17, 2011 +.Dd June 8, 2015 .Dt GEOM_MAP 4 .Os .Sh NAME @@ -36,7 +36,7 @@ To compile this driver into the kernel, place the following line in your kernel configuration file: .Bd -ragged -offset indent -.Cd "device geom_map" +.Cd "options geom_map" .Ed .Sh DESCRIPTION The Modified: stable/10/sys/conf/NOTES ============================================================================== --- stable/10/sys/conf/NOTES Mon Aug 21 09:52:15 2017 (r322743) +++ stable/10/sys/conf/NOTES Mon Aug 21 10:07:12 2017 (r322744) @@ -156,6 +156,7 @@ options GEOM_GATE # Userland services. options GEOM_JOURNAL # Journaling. options GEOM_LABEL # Providers labelization. options GEOM_LINUX_LVM # Linux LVM2 volumes +options GEOM_MAP # Map based partitioning options GEOM_MBR # DOS/MBR partitioning options GEOM_MIRROR # Disk mirroring. options GEOM_MULTIPATH # Disk multipath @@ -176,6 +177,7 @@ options GEOM_RAID3 # RAID3 functionality. options GEOM_SHSEC # Shared secret. options GEOM_STRIPE # Disk striping. options GEOM_SUNLABEL # Sun/Solaris partitioning +options GEOM_UNCOMPRESS # Read-only compressed disks (lzma, zip) options GEOM_UZIP # Read-only compressed disks options GEOM_VINUM # Vinum logical volume manager options GEOM_VIRSTOR # Virtual storage. Modified: stable/10/sys/conf/options ============================================================================== --- stable/10/sys/conf/options Mon Aug 21 09:52:15 2017 (r322743) +++ stable/10/sys/conf/options Mon Aug 21 10:07:12 2017 (r322744) @@ -104,6 +104,7 @@ GEOM_GATE opt_geom.h GEOM_JOURNAL opt_geom.h GEOM_LABEL opt_geom.h GEOM_LINUX_LVM opt_geom.h +GEOM_MAP opt_geom.h GEOM_MBR opt_geom.h GEOM_MIRROR opt_geom.h GEOM_MOUNTVER opt_geom.h From owner-svn-src-stable@freebsd.org Mon Aug 21 10:26:12 2017 Return-Path: Delivered-To: svn-src-stable@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 B5C77DD00B5; Mon, 21 Aug 2017 10:26:12 +0000 (UTC) (envelope-from lwhsu@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 81DDA691F7; Mon, 21 Aug 2017 10:26:12 +0000 (UTC) (envelope-from lwhsu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7LAQBHE041555; Mon, 21 Aug 2017 10:26:11 GMT (envelope-from lwhsu@FreeBSD.org) Received: (from lwhsu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7LAQBNW041554; Mon, 21 Aug 2017 10:26:11 GMT (envelope-from lwhsu@FreeBSD.org) Message-Id: <201708211026.v7LAQBNW041554@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: lwhsu set sender to lwhsu@FreeBSD.org using -f From: Li-Wen Hsu Date: Mon, 21 Aug 2017 10:26: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: r322745 - stable/11/share/mk X-SVN-Group: stable-11 X-SVN-Commit-Author: lwhsu X-SVN-Commit-Paths: stable/11/share/mk X-SVN-Commit-Revision: 322745 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Aug 2017 10:26:12 -0000 Author: lwhsu (ports committer) Date: Mon Aug 21 10:26:11 2017 New Revision: 322745 URL: https://svnweb.freebsd.org/changeset/base/322745 Log: MFC r322434: Re-remove excess / for installing SYMLINKS This excess / was introduced in r280129, and fixed in r295230, but got re-introduced while merging another branch in r298107. Approved by: gjb Differential Revision: https://reviews.freebsd.org/D11995 Modified: stable/11/share/mk/bsd.links.mk Directory Properties: stable/11/ (props changed) Modified: stable/11/share/mk/bsd.links.mk ============================================================================== --- stable/11/share/mk/bsd.links.mk Mon Aug 21 10:07:12 2017 (r322744) +++ stable/11/share/mk/bsd.links.mk Mon Aug 21 10:26:11 2017 (r322745) @@ -20,5 +20,5 @@ _installlinks: .endfor .for s t in ${SYMLINKS} @${ECHO} "${t} -> ${s}" ;\ - ${INSTALL_SYMLINK} ${TAG_ARGS} ${s} ${DESTDIR}/${t} + ${INSTALL_SYMLINK} ${TAG_ARGS} ${s} ${DESTDIR}${t} .endfor From owner-svn-src-stable@freebsd.org Mon Aug 21 12:23:12 2017 Return-Path: Delivered-To: svn-src-stable@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 AF759DD7B7D; Mon, 21 Aug 2017 12:23:12 +0000 (UTC) (envelope-from emaste@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 7DCD06D59D; Mon, 21 Aug 2017 12:23:12 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7LCNBgE090869; Mon, 21 Aug 2017 12:23:11 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7LCNBbN090868; Mon, 21 Aug 2017 12:23:11 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201708211223.v7LCNBbN090868@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 21 Aug 2017 12:23: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: r322748 - stable/11/sys/arm64/arm64 X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/sys/arm64/arm64 X-SVN-Commit-Revision: 322748 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Aug 2017 12:23:12 -0000 Author: emaste Date: Mon Aug 21 12:23:11 2017 New Revision: 322748 URL: https://svnweb.freebsd.org/changeset/base/322748 Log: MFC r322627: arm64: return error instead of panic in unimplemented ptrace ops We don't need a panic as a reminder that these need to be implemented. Reported by: Shawn Webb Sponsored by: The FreeBSD Foundation Modified: stable/11/sys/arm64/arm64/machdep.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm64/arm64/machdep.c ============================================================================== --- stable/11/sys/arm64/arm64/machdep.c Mon Aug 21 11:56:47 2017 (r322747) +++ stable/11/sys/arm64/arm64/machdep.c Mon Aug 21 12:23:11 2017 (r322748) @@ -242,22 +242,24 @@ int fill_dbregs(struct thread *td, struct dbreg *regs) { - panic("ARM64TODO: fill_dbregs"); + printf("ARM64TODO: fill_dbregs"); + return (EDOOFUS); } int set_dbregs(struct thread *td, struct dbreg *regs) { - panic("ARM64TODO: set_dbregs"); + printf("ARM64TODO: set_dbregs"); + return (EDOOFUS); } int ptrace_set_pc(struct thread *td, u_long addr) { - panic("ARM64TODO: ptrace_set_pc"); - return (0); + printf("ARM64TODO: ptrace_set_pc"); + return (EDOOFUS); } int From owner-svn-src-stable@freebsd.org Mon Aug 21 15:11:59 2017 Return-Path: Delivered-To: svn-src-stable@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 AAB4ADE1BAE; Mon, 21 Aug 2017 15:11:59 +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 78E07739AC; Mon, 21 Aug 2017 15:11:59 +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 v7LFBwiq066130; Mon, 21 Aug 2017 15:11:58 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7LFBwC9066129; Mon, 21 Aug 2017 15:11:58 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201708211511.v7LFBwC9066129@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 21 Aug 2017 15:11: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: r322753 - stable/11/sys/i386/i386 X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/i386/i386 X-SVN-Commit-Revision: 322753 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Aug 2017 15:11:59 -0000 Author: kib Date: Mon Aug 21 15:11:58 2017 New Revision: 322753 URL: https://svnweb.freebsd.org/changeset/base/322753 Log: MFC r322667,r322706: Improve i386 #UD low-level kdtrace hook. Modified: stable/11/sys/i386/i386/exception.s Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/i386/i386/exception.s ============================================================================== --- stable/11/sys/i386/i386/exception.s Mon Aug 21 14:14:13 2017 (r322752) +++ stable/11/sys/i386/i386/exception.s Mon Aug 21 15:11:58 2017 (r322753) @@ -183,21 +183,29 @@ calltrap: #ifdef KDTRACE_HOOKS SUPERALIGN_TEXT IDTVEC(ill) - /* Check if there is no DTrace hook registered. */ - cmpl $0,dtrace_invop_jump_addr + /* + * Check if a DTrace hook is registered. The default (data) segment + * cannot be used for this since %ds is not known good until we + * verify that the entry was from kernel mode. + */ + cmpl $0,%ss:dtrace_invop_jump_addr je norm_ill - /* Check if this is a user fault. */ - cmpl $GSEL_KPL, 4(%esp) /* Check the code segment. */ - - /* If so, just handle it as a normal trap. */ + /* + * Check if this is a user fault. If so, just handle it as a normal + * trap. + */ + cmpl $GSEL_KPL, 4(%esp) /* Check the code segment */ jne norm_ill + testl $PSL_VM, 8(%esp) /* and vm86 mode. */ + jnz norm_ill /* * This is a kernel instruction fault that might have been caused * by a DTrace provider. */ - pushal /* Push all registers onto the stack. */ + pushal + cld /* * Set our jump address for the jump back in the event that From owner-svn-src-stable@freebsd.org Mon Aug 21 15:44:58 2017 Return-Path: Delivered-To: svn-src-stable@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 4F207DE3843; Mon, 21 Aug 2017 15:44:58 +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 1DB4374CE7; Mon, 21 Aug 2017 15:44:58 +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 v7LFivsE078701; Mon, 21 Aug 2017 15:44:57 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7LFivHB078700; Mon, 21 Aug 2017 15:44:57 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201708211544.v7LFivHB078700@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 21 Aug 2017 15:44:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r322755 - stable/10/sys/i386/i386 X-SVN-Group: stable-10 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/10/sys/i386/i386 X-SVN-Commit-Revision: 322755 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Aug 2017 15:44:58 -0000 Author: kib Date: Mon Aug 21 15:44:57 2017 New Revision: 322755 URL: https://svnweb.freebsd.org/changeset/base/322755 Log: MFC r322667,r322706: Improve i386 #UD low-level kdtrace hook. Approved by: re (marius) Modified: stable/10/sys/i386/i386/exception.s Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/i386/i386/exception.s ============================================================================== --- stable/10/sys/i386/i386/exception.s Mon Aug 21 15:39:48 2017 (r322754) +++ stable/10/sys/i386/i386/exception.s Mon Aug 21 15:44:57 2017 (r322755) @@ -185,21 +185,29 @@ calltrap: #ifdef KDTRACE_HOOKS SUPERALIGN_TEXT IDTVEC(ill) - /* Check if there is no DTrace hook registered. */ - cmpl $0,dtrace_invop_jump_addr + /* + * Check if a DTrace hook is registered. The default (data) segment + * cannot be used for this since %ds is not known good until we + * verify that the entry was from kernel mode. + */ + cmpl $0,%ss:dtrace_invop_jump_addr je norm_ill - /* Check if this is a user fault. */ - cmpl $GSEL_KPL, 4(%esp) /* Check the code segment. */ - - /* If so, just handle it as a normal trap. */ + /* + * Check if this is a user fault. If so, just handle it as a normal + * trap. + */ + cmpl $GSEL_KPL, 4(%esp) /* Check the code segment */ jne norm_ill + testl $PSL_VM, 8(%esp) /* and vm86 mode. */ + jnz norm_ill /* * This is a kernel instruction fault that might have been caused * by a DTrace provider. */ - pushal /* Push all registers onto the stack. */ + pushal + cld /* * Set our jump address for the jump back in the event that From owner-svn-src-stable@freebsd.org Mon Aug 21 17:20:32 2017 Return-Path: Delivered-To: svn-src-stable@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 87781DE9011; Mon, 21 Aug 2017 17:20:32 +0000 (UTC) (envelope-from gjb@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 548E27C34F; Mon, 21 Aug 2017 17:20:32 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7LHKVB0015475; Mon, 21 Aug 2017 17:20:31 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7LHKVFq015474; Mon, 21 Aug 2017 17:20:31 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201708211720.v7LHKVFq015474@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Mon, 21 Aug 2017 17:20:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r322759 - stable/10/bin/chmod/tests X-SVN-Group: stable-10 X-SVN-Commit-Author: gjb X-SVN-Commit-Paths: stable/10/bin/chmod/tests X-SVN-Commit-Revision: 322759 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Aug 2017 17:20:32 -0000 Author: gjb Date: Mon Aug 21 17:20:31 2017 New Revision: 322759 URL: https://svnweb.freebsd.org/changeset/base/322759 Log: MFC r321949, r321950, r322101: r321949 (ngie): Add expected failures for ZFS - :f_flag fails on ZFS because UF_IMMUTABLE isn't supported. - :v_flag fails on ZFS because the mode for foo is [always] updated unnecessarily. get_filesystem(..) (supporting function that was added to the test script) is based on equivalent logic in usr.bin/extattr/tests/extattr_test.sh . r321950 (ngie): Always use first parameter passed to get_filesystem(..) instead of discarding it and using `.` instead. r322101 (ngie): Don't check result of chflags in f_flag_cleanup() This will prevent false positives from occurring if the test is run on ZFS since ZFS doesn't support fflags throbbing like UFS. PR: 221188, 221189 Approved by: re (marius) Sponsored by: The FreeBSD Foundation Modified: stable/10/bin/chmod/tests/chmod_test.sh Directory Properties: stable/10/ (props changed) Modified: stable/10/bin/chmod/tests/chmod_test.sh ============================================================================== --- stable/10/bin/chmod/tests/chmod_test.sh Mon Aug 21 17:05:43 2017 (r322758) +++ stable/10/bin/chmod/tests/chmod_test.sh Mon Aug 21 17:20:31 2017 (r322759) @@ -25,6 +25,13 @@ # # $FreeBSD$ +get_filesystem() +{ + local mountpoint=$1 + + df -T $mountpoint | tail -n 1 | cut -wf 2 +} + atf_test_case RH_flag RH_flag_head() { @@ -94,6 +101,11 @@ f_flag_body() { atf_check truncate -s 0 foo bar atf_check chmod 0750 foo bar + case "$(get_filesystem .)" in + zfs) + atf_expect_fail "ZFS doesn't support UF_IMMUTABLE; returns EPERM - bug 221189" + ;; + esac atf_check chflags uchg foo atf_check -e not-empty -s not-exit:0 chmod 0700 foo bar atf_check -o inline:'100750\n100700\n' stat -f '%p' foo bar @@ -103,7 +115,7 @@ f_flag_body() f_flag_cleanup() { - atf_check chflags 0 foo + chflags 0 foo || : } atf_test_case h_flag @@ -140,6 +152,11 @@ v_flag_body() atf_check truncate -s 0 foo bar atf_check chmod 0600 foo atf_check chmod 0750 bar + case "$(get_filesystem .)" in + zfs) + atf_expect_fail "ZFS updates mode for foo unnecessarily - bug 221188" + ;; + esac atf_check -o 'inline:bar\n' chmod -v 0600 foo bar atf_check chmod -v 0600 foo bar for f in foo bar; do From owner-svn-src-stable@freebsd.org Mon Aug 21 17:29:39 2017 Return-Path: Delivered-To: svn-src-stable@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 2DB8FDE990E; Mon, 21 Aug 2017 17:29:39 +0000 (UTC) (envelope-from jhb@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 F0D7F7C9FE; Mon, 21 Aug 2017 17:29:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7LHTcAt019558; Mon, 21 Aug 2017 17:29:38 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7LHTcV8019557; Mon, 21 Aug 2017 17:29:38 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201708211729.v7LHTcV8019557@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 21 Aug 2017 17:29: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: r322760 - stable/11/sys/arm64/arm64 X-SVN-Group: stable-11 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/11/sys/arm64/arm64 X-SVN-Commit-Revision: 322760 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Aug 2017 17:29:39 -0000 Author: jhb Date: Mon Aug 21 17:29:37 2017 New Revision: 322760 URL: https://svnweb.freebsd.org/changeset/base/322760 Log: MFC 322436: Don't panic for PT_GETFPREGS. Only fetch the VFP state from the CPU if the thread whose registers are being requested is the current thread. If a stopped thread's registers are being fetched by a debugger, the saved state in the PCB is already valid. Modified: stable/11/sys/arm64/arm64/machdep.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm64/arm64/machdep.c ============================================================================== --- stable/11/sys/arm64/arm64/machdep.c Mon Aug 21 17:20:31 2017 (r322759) +++ stable/11/sys/arm64/arm64/machdep.c Mon Aug 21 17:29:37 2017 (r322760) @@ -213,7 +213,8 @@ fill_fpregs(struct thread *td, struct fpreg *regs) * If we have just been running VFP instructions we will * need to save the state to memcpy it below. */ - vfp_save_state(td, pcb); + if (td == curthread) + vfp_save_state(td, pcb); memcpy(regs->fp_q, pcb->pcb_vfp, sizeof(regs->fp_q)); regs->fp_cr = pcb->pcb_fpcr; From owner-svn-src-stable@freebsd.org Mon Aug 21 17:35:06 2017 Return-Path: Delivered-To: svn-src-stable@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 14C4DDE9FF9; Mon, 21 Aug 2017 17:35:06 +0000 (UTC) (envelope-from jhb@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 E288B7CEE0; Mon, 21 Aug 2017 17:35:05 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7LHZ45A023566; Mon, 21 Aug 2017 17:35:04 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7LHZ4UG023562; Mon, 21 Aug 2017 17:35:04 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201708211735.v7LHZ4UG023562@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 21 Aug 2017 17:35:04 +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: r322761 - in stable/11/sys/arm64: arm64 include X-SVN-Group: stable-11 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable/11/sys/arm64: arm64 include X-SVN-Commit-Revision: 322761 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Aug 2017 17:35:06 -0000 Author: jhb Date: Mon Aug 21 17:35:04 2017 New Revision: 322761 URL: https://svnweb.freebsd.org/changeset/base/322761 Log: MFC 322437: Reliably enable debug exceptions on all CPUs. Previously, debug exceptions were only enabled on the boot CPU if DDB was enabled in the dbg_monitor_init() function. APs also called this function, but since mp_machdep.c doesn't include opt_ddb.h, the APs ended up calling an empty stub defined in instead of the real function. Also, if DDB was not enabled in the kernel, the boot CPU would not enable debug exceptions. Fix this by adding a new dbg_init() function that always clears the OS lock to enable debug exceptions which the boot CPU and the APs call. This function also calls dbg_monitor_init() to enable hardware breakpoints from DDB on all CPUs if DDB is enabled. Eventually base support for hardware breakpoints/watchpoints will need to move out of the DDB-only debug_monitor.c for use by userland debuggers. Modified: stable/11/sys/arm64/arm64/debug_monitor.c stable/11/sys/arm64/arm64/machdep.c stable/11/sys/arm64/arm64/mp_machdep.c stable/11/sys/arm64/include/machdep.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm64/arm64/debug_monitor.c ============================================================================== --- stable/11/sys/arm64/arm64/debug_monitor.c Mon Aug 21 17:29:37 2017 (r322760) +++ stable/11/sys/arm64/arm64/debug_monitor.c Mon Aug 21 17:35:04 2017 (r322761) @@ -453,15 +453,12 @@ dbg_monitor_init(void) { u_int i; - /* Clear OS lock */ - WRITE_SPECIALREG(OSLAR_EL1, 0); - /* Find out many breakpoints and watchpoints we can use */ dbg_watchpoint_num = ((READ_SPECIALREG(ID_AA64DFR0_EL1) >> 20) & 0xf) + 1; dbg_breakpoint_num = ((READ_SPECIALREG(ID_AA64DFR0_EL1) >> 12) & 0xf) + 1; if (bootverbose && PCPU_GET(cpuid) == 0) { - db_printf("%d watchpoints and %d breakpoints supported\n", + printf("%d watchpoints and %d breakpoints supported\n", dbg_watchpoint_num, dbg_breakpoint_num); } Modified: stable/11/sys/arm64/arm64/machdep.c ============================================================================== --- stable/11/sys/arm64/arm64/machdep.c Mon Aug 21 17:29:37 2017 (r322760) +++ stable/11/sys/arm64/arm64/machdep.c Mon Aug 21 17:35:04 2017 (r322761) @@ -970,11 +970,24 @@ initarm(struct arm64_bootparams *abp) mutex_init(); init_param2(physmem); - dbg_monitor_init(); + dbg_init(); kdb_init(); pan_enable(); early_boot = 0; +} + +void +dbg_init(void) +{ + + /* Clear OS lock */ + WRITE_SPECIALREG(OSLAR_EL1, 0); + + /* This permits DDB to use debug registers for watchpoints. */ + dbg_monitor_init(); + + /* TODO: Eventually will need to initialize debug registers here. */ } #ifdef DDB Modified: stable/11/sys/arm64/arm64/mp_machdep.c ============================================================================== --- stable/11/sys/arm64/arm64/mp_machdep.c Mon Aug 21 17:29:37 2017 (r322760) +++ stable/11/sys/arm64/arm64/mp_machdep.c Mon Aug 21 17:35:04 2017 (r322761) @@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #ifdef VFP @@ -277,7 +276,7 @@ init_secondary(uint64_t cpu) vfp_init(); #endif - dbg_monitor_init(); + dbg_init(); pan_enable(); /* Enable interrupts */ Modified: stable/11/sys/arm64/include/machdep.h ============================================================================== --- stable/11/sys/arm64/include/machdep.h Mon Aug 21 17:29:37 2017 (r322760) +++ stable/11/sys/arm64/include/machdep.h Mon Aug 21 17:35:04 2017 (r322761) @@ -40,6 +40,7 @@ struct arm64_bootparams { extern vm_paddr_t physmap[]; extern u_int physmap_idx; +void dbg_init(void); void initarm(struct arm64_bootparams *); extern void (*pagezero)(void *); From owner-svn-src-stable@freebsd.org Mon Aug 21 17:40:52 2017 Return-Path: Delivered-To: svn-src-stable@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 9E7F6DEA515; Mon, 21 Aug 2017 17:40:52 +0000 (UTC) (envelope-from glebius@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 6D8DE7D398; Mon, 21 Aug 2017 17:40:52 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7LHepo2024660; Mon, 21 Aug 2017 17:40:51 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7LHepx1024659; Mon, 21 Aug 2017 17:40:51 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201708211740.v7LHepx1024659@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Mon, 21 Aug 2017 17:40: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: r322764 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: glebius X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 322764 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Aug 2017 17:40:52 -0000 Author: glebius Date: Mon Aug 21 17:40:51 2017 New Revision: 322764 URL: https://svnweb.freebsd.org/changeset/base/322764 Log: Merge r322321: Plug uninitialized stack variable leak in sendfile(2). Reported by: Ilja Van Sprundel Submitted by: Domagoj Stolfa Security: uninitialized stack variable leak Modified: stable/11/sys/kern/kern_sendfile.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_sendfile.c ============================================================================== --- stable/11/sys/kern/kern_sendfile.c Mon Aug 21 17:39:12 2017 (r322763) +++ stable/11/sys/kern/kern_sendfile.c Mon Aug 21 17:40:51 2017 (r322764) @@ -930,6 +930,7 @@ sendfile(struct thread *td, struct sendfile_args *uap, if (uap->offset < 0) return (EINVAL); + sbytes = 0; hdr_uio = trl_uio = NULL; if (uap->hdtr != NULL) { From owner-svn-src-stable@freebsd.org Tue Aug 22 02:03:02 2017 Return-Path: Delivered-To: svn-src-stable@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 E0731DE6376; Tue, 22 Aug 2017 02:03:02 +0000 (UTC) (envelope-from kevans@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 BD0F36B8A8; Tue, 22 Aug 2017 02:03:02 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7M231Bf032472; Tue, 22 Aug 2017 02:03:01 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7M231OI032470; Tue, 22 Aug 2017 02:03:01 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708220203.v7M231OI032470@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 22 Aug 2017 02:03: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: r322777 - in stable/11: contrib/netbsd-tests/usr.bin/grep usr.bin/grep X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11: contrib/netbsd-tests/usr.bin/grep usr.bin/grep X-SVN-Commit-Revision: 322777 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Aug 2017 02:03:03 -0000 Author: kevans Date: Tue Aug 22 02:03:01 2017 New Revision: 322777 URL: https://svnweb.freebsd.org/changeset/base/322777 Log: MFC r321450: bsdgrep(1): Don't exit before processing every file Given an empty pattern (i.e. grep "" A B), bsdgrep(1) would previously exit() with the appropriate exit code upon encountering an empty file. Likely intended as an optimization, but this behavior is technically incorrect since an empty pattern should match every line. PR: 220924 Approved by: emaste (mentor, blanket MFC) Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh stable/11/usr.bin/grep/util.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh ============================================================================== --- stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Tue Aug 22 00:10:15 2017 (r322776) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Tue Aug 22 02:03:01 2017 (r322777) @@ -667,6 +667,24 @@ mmap_eof_not_eol_body() atf_check -s exit:0 -o not-empty \ env MALLOC_CONF="redzone:true" grep --mmap -e " " test2 } + +atf_test_case matchall +matchall_head() +{ + atf_set "descr" "Check proper behavior of matching all with an empty string" +} +matchall_body() +{ + printf "" > test1 + printf "A" > test2 + printf "A\nB" > test3 + + atf_check -o inline:"test2:A\ntest3:A\ntest3:B\n" grep "" test1 test2 test3 + atf_check -o inline:"test3:A\ntest3:B\ntest2:A\n" grep "" test3 test1 test2 + atf_check -o inline:"test2:A\ntest3:A\ntest3:B\n" grep "" test2 test3 test1 + + atf_check -s exit:1 grep "" test1 +} # End FreeBSD atf_init_test_cases() @@ -707,5 +725,6 @@ atf_init_test_cases() atf_add_test_case badcontext atf_add_test_case mmap atf_add_test_case mmap_eof_not_eol + atf_add_test_case matchall # End FreeBSD } Modified: stable/11/usr.bin/grep/util.c ============================================================================== --- stable/11/usr.bin/grep/util.c Tue Aug 22 00:10:15 2017 (r322776) +++ stable/11/usr.bin/grep/util.c Tue Aug 22 02:03:01 2017 (r322777) @@ -259,16 +259,8 @@ procfile(const char *fn) pc.ln.boff = 0; pc.ln.off += pc.ln.len + 1; if ((pc.ln.dat = grep_fgetln(f, &pc.ln.len)) == NULL || - pc.ln.len == 0) { - if (pc.ln.line_no == 0 && matchall) - /* - * An empty file with an empty pattern and the - * -w flag does not match - */ - exit(matchall && wflag ? 1 : 0); - else - break; - } + pc.ln.len == 0) + break; if (pc.ln.len > 0 && pc.ln.dat[pc.ln.len - 1] == fileeol) --pc.ln.len; From owner-svn-src-stable@freebsd.org Tue Aug 22 03:59:38 2017 Return-Path: Delivered-To: svn-src-stable@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 B059FDEDC9A; Tue, 22 Aug 2017 03:59:38 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-pg0-x22e.google.com (mail-pg0-x22e.google.com [IPv6:2607:f8b0:400e:c05::22e]) (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 767066FE52; Tue, 22 Aug 2017 03:59:38 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: by mail-pg0-x22e.google.com with SMTP id m133so28330856pga.5; Mon, 21 Aug 2017 20:59:38 -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=kK8mEkF+7Vo6Y7b48fNt+CeDhLtkzAnpTRF1zQqfu54=; b=PWCE4TrG36Q7wMaf/iEGYa3xGPoRRPB6TkF+tvmgfhvA7RNvVxkC219qXCMS7vmP9H f+vQOLr4Zp6V893roAI/kHmO3jDREWJWp96/A4Q9UjFIEky0mqPzWZrRKyjiJ2G7GPNa 8+JSnqp8RnSx9SGVVzGBj9Lpx8qDRu/X/rkRvQ9PUEEqZ4J+bHCiVya1aybC3vGch+r/ mcyV2pIdLYiIIiRQmymAVGa6hgsJHsTQqOeT6aQSg17DdoNlMA2C0EYjLvR+mjbsl8R7 RFisoGoOFcr9UzncoJy+CLW7B2L5nAWtgE8/ZUXzBrNGzszAeWjxKdITuDeEONwFHR3x KDUA== 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=kK8mEkF+7Vo6Y7b48fNt+CeDhLtkzAnpTRF1zQqfu54=; b=oDIFcR3+CtND7iuN+/4nliu/dVhp0oKBJJOBPVpIufu+KkP6jyTgXVVxPATI+sZMKm m8Rhnmt9tp8UisKaTyz0YICSnNV4UpNK9uq0G0P9/9d9K379rBPXG07gfMASDUy/3606 Q/lGNcJRoaoXV3bmU1rLnqXwrd38FJiAq9nWk+ZR1eJgZvYkkvllQOxX2zlANQrpFijs bgQ0NcHi1xlR1c6ECbsUYfuqjo+4SJbZiuX1nlTWQMw7jl4jX3Qo1JglK9d1+1wNayHD ZwJ/YyQC9h0tVMvZTWAud07Mow9o5Iumfuo5tE4XzcLYgMwLpyYaPNodqCY4dXv8hk2k 5Pxg== X-Gm-Message-State: AHYfb5get5x8WD0Nry7FcCNrKmj4f6Otl+h/CniUKJXwrEbUY3spHNFs xhlFfQBca4u5PoK281Q= X-Received: by 10.98.55.134 with SMTP id e128mr19549083pfa.176.1503374377758; Mon, 21 Aug 2017 20:59:37 -0700 (PDT) Received: from [10.0.1.119] ([12.37.166.67]) by smtp.gmail.com with ESMTPSA id z8sm20457541pgc.93.2017.08.21.20.59.36 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Aug 2017 20:59:37 -0700 (PDT) Subject: Re: svn commit: r322759 - stable/10/bin/chmod/tests Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: multipart/signed; boundary="Apple-Mail=_62A078E9-33ED-4997-88F8-EF1398CB460E"; protocol="application/pgp-signature"; micalg=pgp-sha512 X-Pgp-Agent: GPGMail From: "Ngie Cooper (yaneurabeya)" In-Reply-To: <201708211720.v7LHKVFq015474@repo.freebsd.org> Date: Mon, 21 Aug 2017 20:59:34 -0700 Cc: src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Message-Id: <7CF71981-566F-4990-A230-86C5C020ACBD@gmail.com> References: <201708211720.v7LHKVFq015474@repo.freebsd.org> To: Glen Barber X-Mailer: Apple Mail (2.3124) X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Aug 2017 03:59:38 -0000 --Apple-Mail=_62A078E9-33ED-4997-88F8-EF1398CB460E Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii > On Aug 21, 2017, at 10:20, Glen Barber wrote: > > Author: gjb > Date: Mon Aug 21 17:20:31 2017 > New Revision: 322759 > URL: https://svnweb.freebsd.org/changeset/base/322759 > > Log: > MFC r321949, r321950, r322101: Thanks Glen! -Ngie --Apple-Mail=_62A078E9-33ED-4997-88F8-EF1398CB460E 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 iQIcBAEBCgAGBQJZm6wnAAoJEPWDqSZpMIYVZeUP/RCcChqkJJ3pijUP1B8xy8Dw GVjqJwKv9NspEjPETsHNtL/QVvH2qjXAAvbE/CpNKpckYXNViNoWb1Y2KBOqu/F6 Wx4+F82GNy0Fl8Xx7fYBWufjFbsGFG0uJYhdR7gXN37c7ldk9Px2d/l+4OvPgwfL mY3HiPjb9MeyDTr+aVm6gi53dgoG4BH7OPh2OFc89VVfRNuKcExhfjN3kSgT0kk0 moScYVmA/bwKwboX9s8jXEPT2rh7P2elGBquXjYrNEIUHAjw6Kuvig25JF8VbEzK +P3Tt7INMoqSTxr2ViYQcrz4htopL7b4Xv+lWWs8lnca9oVZi31ns9MxxmcoHoYe tOMaknL+vqX/56glSCkGeYn3lBKxe80NIsj+leDb5n1786tv23vCCfWjO3mFsHOo lvamvTjMjkZW5tOhkkLSKdhJz6o36xwrlQLcMPHC9PzR2FHU3AGUC1GxtAcYyJiF 2G4KynXMhtj+916cAZ0AVXFQmJ92/ZBUP2bbw52fCLj51gB6SMvCAtu3jjLJjlUw lgooUYoHK9Fe4RAAUW6NYxrJ7/oEuJERZbw14Ytsp2ALx4atDlufpjuDKYBDy4Pu le7S3C2ydGL6gwMXfpaoC5ivWyNYuXdCCbdHgRjBTZCVrnY+jQ4wuMcLF1mSuzla IiVXEHy+gdYhjavoxIzO =M+04 -----END PGP SIGNATURE----- --Apple-Mail=_62A078E9-33ED-4997-88F8-EF1398CB460E-- From owner-svn-src-stable@freebsd.org Tue Aug 22 13:59:51 2017 Return-Path: Delivered-To: svn-src-stable@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 DC6F7DECF8F; Tue, 22 Aug 2017 13:59:51 +0000 (UTC) (envelope-from ken@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 B74D63359; Tue, 22 Aug 2017 13:59:51 +0000 (UTC) (envelope-from ken@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7MDxoXW022709; Tue, 22 Aug 2017 13:59:50 GMT (envelope-from ken@FreeBSD.org) Received: (from ken@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7MDxo32022708; Tue, 22 Aug 2017 13:59:50 GMT (envelope-from ken@FreeBSD.org) Message-Id: <201708221359.v7MDxo32022708@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ken set sender to ken@FreeBSD.org using -f From: "Kenneth D. Merry" Date: Tue, 22 Aug 2017 13:59: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: r322788 - stable/11/usr.bin/mt X-SVN-Group: stable-11 X-SVN-Commit-Author: ken X-SVN-Commit-Paths: stable/11/usr.bin/mt X-SVN-Commit-Revision: 322788 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Aug 2017 13:59:52 -0000 Author: ken Date: Tue Aug 22 13:59:50 2017 New Revision: 322788 URL: https://svnweb.freebsd.org/changeset/base/322788 Log: MFC r322410: ------------------------------------------------------------------------ r322410 | ken | 2017-08-11 12:43:52 -0600 (Fri, 11 Aug 2017) | 16 lines Add historical notes on QIC tape drives and fix a couple of issues in mt(1). o Density code 0x5 is also known as QIC-11, and should have a footnote reference. o Add notes on QIC tape drives from the bug report. These may help anyone trying to use a QIC drive. o Take out a "more more" instance found by igor. o Bump the man page date. The PR is 14 years old, so it's past time to retire it. PR: doc/53596 Submitted by: tedm@toybox.placo.com Reviewed by: bcr Sponsored by: Spectra Logic ------------------------------------------------------------------------ Modified: stable/11/usr.bin/mt/mt.1 Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/mt/mt.1 ============================================================================== --- stable/11/usr.bin/mt/mt.1 Tue Aug 22 13:53:53 2017 (r322787) +++ stable/11/usr.bin/mt/mt.1 Tue Aug 22 13:59:50 2017 (r322788) @@ -29,7 +29,7 @@ .\" @(#)mt.1 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd August 3, 2017 +.Dd August 11, 2017 .Dt MT 1 .Os .Sh NAME @@ -333,7 +333,7 @@ The default protection method used is Reed-Solomon CRC 1), as specified in ECMA-319. The default protection information length used with Reed-Solomon CRC is 4 bytes. -To enable all settings except one more more settings, specify the +To enable all settings except one more setting, specify the .Fl e argument and then explicitly disable settings that you do not wish to enable. @@ -463,7 +463,7 @@ Value Width Tracks Density Code Typ 0x01 12.7 (0.5) 9 32 (800) NRZI R X3.22-1983 2 0x02 12.7 (0.5) 9 63 (1,600) PE R X3.39-1986 2 0x03 12.7 (0.5) 9 246 (6,250) GCR R X3.54-1986 2 -0x05 6.3 (0.25) 4/9 315 (8,000) GCR C X3.136-1986 1 +0x05 6.3 (0.25) 4/9 315 (8,000) GCR C X3.136-1986 1,3 0x06 12.7 (0.5) 9 126 (3,200) PE R X3.157-1987 2 0x07 6.3 (0.25) 4 252 (6,400) IMFM C X3.116-1986 1 0x08 3.81 (0.15) 4 315 (8,000) GCR CS X3.158-1987 1 @@ -566,6 +566,60 @@ NOTES density code is 0x8c. 13. This density code (0x48) was also used for DAT-160. .Ed +.Bd -literal -offset 2n +NOTE ON QIC STREAMERS + +The following is a table of Data Cartridge types as used in the 1/4 inch +tape drives such as the Archive Viper 150, Wangtek 5525ES, and Tandberg +TDC4220 tape drives: + +Value Reference Format Cartridge Type Capacity Tracks Length +----- --------- ------ -------------- -------- ------ ------ + +0x05 QIC-11 DC300 15MB 4 300ft +0x05 QIC-11 DC300XL/P 20MB 4 450ft +0x05 QIC-11 DC600 27MB 4 600ft +0x05 X3.136-1986 QIC-24 DC615A 15MB 9 150ft +0x05 X3.136-1986 QIC-24 DC300XL/P 45MB 9 450ft +0x05 X3.136-1986 QIC-24 DC600A 60MB 9 600ft +0x0F QIC-120 QIC-120 DC600A/DC6150 120MB 15 620ft +0x10 QIC-150 QIC-150 DC600XTD/DC6150 150MB 18 620ft +0x10 QIC-150 QIC-150 DC6250 250MB 18 1,020ft +0x11 QIC-320 QIC-525 DC6320 320MB 26 620ft +0x11 QIC-320 QIC-525 DC6525 525MB 26 1,020ft +0x1E QIC-1000C QIC-1000 DC9100/DL9135 1.0GB 30 760ft +0x1E QIC-1000C QIC-1000 DC9150 1.2GB 30 950ft +0x22 QIC-2GB(C) QIC-2GB DC9200 2.0GB 42 950ft +0x22 QIC-2GB(C) QIC-2GB DC9250 2.5GB 42 1,200ft +.Ed +.Pp +Notes: +.Pp +QIC-24, QIC-120, QIC-150 use fixed blocksize of 512 bytes, QIC-525, QIC-1000 +and QIC-2GB can use blocksize of 1,024 bytes. +DDS (DAT) drives generally use variable blocks. +.Pp +QIC-02 and QIC-36 are interface standards for tape drives. +The QIC-02 and QIC-36 streamers such as the Wangtek 5250EQ are otherwise +identical to their SCSI versions (i.e.: Wangtek 5250ES). +.Pp +It seems that the 150MB and larger streamers cannot write QIC-24 9 track +formats, only read them. +.Pp +DC600A cartridges marked "10,000ftpi" can only be used as QIC-11, QIC-24, +and QIC-120 format. +DC600A cartridges marked 12,500ftpi can be used as both QIC-120 and QIC-150 +format. +.Pp +Some manufacturers do not use "DC" on their cartridges. +Verbatim uses DL, Maxell uses MC, Sony uses QD, Quill uses DQ. +.Pp +3M/Imation & Fuji use DC. +Thus a DL6250, MC-6250, QD6250, DQ6250 are all identical media to a DC6250. +.Pp +QIC tape media is not "connected" to the take up reels and will de-spool +if the tape drive has dust covering the light sensor that looks for the end +of tape holes in the media. .Sh ENVIRONMENT .Bl -tag -width ".Ev TAPE" .It Ev TAPE From owner-svn-src-stable@freebsd.org Tue Aug 22 14:40:58 2017 Return-Path: Delivered-To: svn-src-stable@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 19C58DEF3D7; Tue, 22 Aug 2017 14:40:58 +0000 (UTC) (envelope-from ken@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 E546263CBF; Tue, 22 Aug 2017 14:40:57 +0000 (UTC) (envelope-from ken@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7MEevKA039109; Tue, 22 Aug 2017 14:40:57 GMT (envelope-from ken@FreeBSD.org) Received: (from ken@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7MEevsh039108; Tue, 22 Aug 2017 14:40:57 GMT (envelope-from ken@FreeBSD.org) Message-Id: <201708221440.v7MEevsh039108@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ken set sender to ken@FreeBSD.org using -f From: "Kenneth D. Merry" Date: Tue, 22 Aug 2017 14:40:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r322790 - stable/10/usr.bin/mt X-SVN-Group: stable-10 X-SVN-Commit-Author: ken X-SVN-Commit-Paths: stable/10/usr.bin/mt X-SVN-Commit-Revision: 322790 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Aug 2017 14:40:58 -0000 Author: ken Date: Tue Aug 22 14:40:56 2017 New Revision: 322790 URL: https://svnweb.freebsd.org/changeset/base/322790 Log: MFC r322410: ------------------------------------------------------------------------ r322410 | ken | 2017-08-11 12:43:52 -0600 (Fri, 11 Aug 2017) | 16 lines Add historical notes on QIC tape drives and fix a couple of issues in mt(1). o Density code 0x5 is also known as QIC-11, and should have a footnote reference. o Add notes on QIC tape drives from the bug report. These may help anyone trying to use a QIC drive. o Take out a "more more" instance found by igor. o Bump the man page date. The PR is 14 years old, so it's past time to retire it. PR: doc/53596 Submitted by: tedm@toybox.placo.com Reviewed by: bcr Sponsored by: Spectra Logic ------------------------------------------------------------------------ Approved by: re (gjb) Modified: stable/10/usr.bin/mt/mt.1 Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/mt/mt.1 ============================================================================== --- stable/10/usr.bin/mt/mt.1 Tue Aug 22 14:06:43 2017 (r322789) +++ stable/10/usr.bin/mt/mt.1 Tue Aug 22 14:40:56 2017 (r322790) @@ -29,7 +29,7 @@ .\" @(#)mt.1 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd August 3, 2017 +.Dd August 11, 2017 .Dt MT 1 .Os .Sh NAME @@ -333,7 +333,7 @@ The default protection method used is Reed-Solomon CRC 1), as specified in ECMA-319. The default protection information length used with Reed-Solomon CRC is 4 bytes. -To enable all settings except one more more settings, specify the +To enable all settings except one more setting, specify the .Fl e argument and then explicitly disable settings that you do not wish to enable. @@ -463,7 +463,7 @@ Value Width Tracks Density Code Typ 0x01 12.7 (0.5) 9 32 (800) NRZI R X3.22-1983 2 0x02 12.7 (0.5) 9 63 (1,600) PE R X3.39-1986 2 0x03 12.7 (0.5) 9 246 (6,250) GCR R X3.54-1986 2 -0x05 6.3 (0.25) 4/9 315 (8,000) GCR C X3.136-1986 1 +0x05 6.3 (0.25) 4/9 315 (8,000) GCR C X3.136-1986 1,3 0x06 12.7 (0.5) 9 126 (3,200) PE R X3.157-1987 2 0x07 6.3 (0.25) 4 252 (6,400) IMFM C X3.116-1986 1 0x08 3.81 (0.15) 4 315 (8,000) GCR CS X3.158-1987 1 @@ -566,6 +566,60 @@ NOTES density code is 0x8c. 13. This density code (0x48) was also used for DAT-160. .Ed +.Bd -literal -offset 2n +NOTE ON QIC STREAMERS + +The following is a table of Data Cartridge types as used in the 1/4 inch +tape drives such as the Archive Viper 150, Wangtek 5525ES, and Tandberg +TDC4220 tape drives: + +Value Reference Format Cartridge Type Capacity Tracks Length +----- --------- ------ -------------- -------- ------ ------ + +0x05 QIC-11 DC300 15MB 4 300ft +0x05 QIC-11 DC300XL/P 20MB 4 450ft +0x05 QIC-11 DC600 27MB 4 600ft +0x05 X3.136-1986 QIC-24 DC615A 15MB 9 150ft +0x05 X3.136-1986 QIC-24 DC300XL/P 45MB 9 450ft +0x05 X3.136-1986 QIC-24 DC600A 60MB 9 600ft +0x0F QIC-120 QIC-120 DC600A/DC6150 120MB 15 620ft +0x10 QIC-150 QIC-150 DC600XTD/DC6150 150MB 18 620ft +0x10 QIC-150 QIC-150 DC6250 250MB 18 1,020ft +0x11 QIC-320 QIC-525 DC6320 320MB 26 620ft +0x11 QIC-320 QIC-525 DC6525 525MB 26 1,020ft +0x1E QIC-1000C QIC-1000 DC9100/DL9135 1.0GB 30 760ft +0x1E QIC-1000C QIC-1000 DC9150 1.2GB 30 950ft +0x22 QIC-2GB(C) QIC-2GB DC9200 2.0GB 42 950ft +0x22 QIC-2GB(C) QIC-2GB DC9250 2.5GB 42 1,200ft +.Ed +.Pp +Notes: +.Pp +QIC-24, QIC-120, QIC-150 use fixed blocksize of 512 bytes, QIC-525, QIC-1000 +and QIC-2GB can use blocksize of 1,024 bytes. +DDS (DAT) drives generally use variable blocks. +.Pp +QIC-02 and QIC-36 are interface standards for tape drives. +The QIC-02 and QIC-36 streamers such as the Wangtek 5250EQ are otherwise +identical to their SCSI versions (i.e.: Wangtek 5250ES). +.Pp +It seems that the 150MB and larger streamers cannot write QIC-24 9 track +formats, only read them. +.Pp +DC600A cartridges marked "10,000ftpi" can only be used as QIC-11, QIC-24, +and QIC-120 format. +DC600A cartridges marked 12,500ftpi can be used as both QIC-120 and QIC-150 +format. +.Pp +Some manufacturers do not use "DC" on their cartridges. +Verbatim uses DL, Maxell uses MC, Sony uses QD, Quill uses DQ. +.Pp +3M/Imation & Fuji use DC. +Thus a DL6250, MC-6250, QD6250, DQ6250 are all identical media to a DC6250. +.Pp +QIC tape media is not "connected" to the take up reels and will de-spool +if the tape drive has dust covering the light sensor that looks for the end +of tape holes in the media. .Sh ENVIRONMENT .Bl -tag -width ".Ev TAPE" .It Ev TAPE From owner-svn-src-stable@freebsd.org Tue Aug 22 15:16:11 2017 Return-Path: Delivered-To: svn-src-stable@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 29228DC8963; Tue, 22 Aug 2017 15:16:11 +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 E69A265B54; Tue, 22 Aug 2017 15:16:10 +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 v7MFGA41056351; Tue, 22 Aug 2017 15:16:10 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7MFGAwl056350; Tue, 22 Aug 2017 15:16:10 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201708221516.v7MFGAwl056350@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Tue, 22 Aug 2017 15:16:10 +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: r322791 - stable/11/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil X-SVN-Group: stable-11 X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: stable/11/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil X-SVN-Commit-Revision: 322791 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Aug 2017 15:16:11 -0000 Author: ngie Date: Tue Aug 22 15:16:09 2017 New Revision: 322791 URL: https://svnweb.freebsd.org/changeset/base/322791 Log: MFC r321387: Don't use incorrect hardcoded path to ksh -- use /usr/bin/env to find ksh instead Modified: stable/11/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.CoalesceTrace.d Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.CoalesceTrace.d ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.CoalesceTrace.d Tue Aug 22 14:40:56 2017 (r322790) +++ stable/11/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/dtraceUtil/man.CoalesceTrace.d Tue Aug 22 15:16:09 2017 (r322791) @@ -1,4 +1,4 @@ -#!/bin/ksh -p +#!/usr/bin/env ksh -p /* * CDDL HEADER START From owner-svn-src-stable@freebsd.org Tue Aug 22 15:20:49 2017 Return-Path: Delivered-To: svn-src-stable@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 DE941DC8F7D; Tue, 22 Aug 2017 15:20:49 +0000 (UTC) (envelope-from mckusick@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 B385365F58; Tue, 22 Aug 2017 15:20:49 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7MFKmhH056608; Tue, 22 Aug 2017 15:20:48 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7MFKmJ7056606; Tue, 22 Aug 2017 15:20:48 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201708221520.v7MFKmJ7056606@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Tue, 22 Aug 2017 15:20: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: r322792 - stable/11/sys/geom/journal X-SVN-Group: stable-11 X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: stable/11/sys/geom/journal X-SVN-Commit-Revision: 322792 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Aug 2017 15:20:50 -0000 Author: mckusick Date: Tue Aug 22 15:20:48 2017 New Revision: 322792 URL: https://svnweb.freebsd.org/changeset/base/322792 Log: MFC of 322179, 322463, and 322464: 322179: Correct ordering of bio's in gjournal queue 322463: Eliminate a variable that is set-only in g_journal.c 322464: Correct check for reads in gjournal Submitted by: Dr. Andreas Longwitz Discussed with: kib Modified: stable/11/sys/geom/journal/g_journal.c stable/11/sys/geom/journal/g_journal.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/geom/journal/g_journal.c ============================================================================== --- stable/11/sys/geom/journal/g_journal.c Tue Aug 22 15:16:09 2017 (r322791) +++ stable/11/sys/geom/journal/g_journal.c Tue Aug 22 15:20:48 2017 (r322792) @@ -1236,7 +1236,7 @@ g_journal_flush(struct g_journal_softc *sc) struct g_provider *pp; struct bio **bioq; struct bio *bp, *fbp, *pbp; - off_t joffset, size; + off_t joffset; u_char *data, hash[16]; MD5_CTX ctx; u_int i; @@ -1244,7 +1244,6 @@ g_journal_flush(struct g_journal_softc *sc) if (sc->sc_current_count == 0) return; - size = 0; pp = sc->sc_jprovider; GJ_VALIDATE_OFFSET(sc->sc_journal_offset, sc); joffset = sc->sc_journal_offset; @@ -1261,7 +1260,7 @@ g_journal_flush(struct g_journal_softc *sc) strlcpy(hdr.jrh_magic, GJ_RECORD_HEADER_MAGIC, sizeof(hdr.jrh_magic)); bioq = &sc->sc_active.jj_queue; - pbp = sc->sc_flush_queue; + GJQ_LAST(sc->sc_flush_queue, pbp); fbp = g_alloc_bio(); fbp->bio_parent = NULL; @@ -1294,7 +1293,6 @@ g_journal_flush(struct g_journal_softc *sc) ent->je_offset = bp->bio_offset; ent->je_joffset = joffset; ent->je_length = bp->bio_length; - size += ent->je_length; data = bp->bio_data; if (sc->sc_flags & GJF_DEVICE_CHECKSUM) @@ -1516,49 +1514,10 @@ g_journal_read_find(struct bio *head, int sorted, stru } /* - * Try to find requested data in cache. - */ -static struct bio * -g_journal_read_queue_find(struct bio_queue *head, struct bio *pbp, off_t ostart, - off_t oend) -{ - off_t cstart, cend; - struct bio *bp; - - TAILQ_FOREACH(bp, head, bio_queue) { - cstart = MAX(ostart, bp->bio_offset); - cend = MIN(oend, bp->bio_offset + bp->bio_length); - if (cend <= ostart) - continue; - else if (cstart >= oend) - continue; - KASSERT(bp->bio_data != NULL, - ("%s: bio_data == NULL", __func__)); - GJ_DEBUG(3, "READ(%p): (%jd, %jd) (bp=%p)", head, cstart, cend, - bp); - bcopy(bp->bio_data + cstart - bp->bio_offset, - pbp->bio_data + cstart - pbp->bio_offset, cend - cstart); - pbp->bio_completed += cend - cstart; - if (pbp->bio_completed == pbp->bio_length) { - /* - * Cool, the whole request was in cache, deliver happy - * message. - */ - g_io_deliver(pbp, 0); - return (pbp); - } - break; - } - return (bp); -} - -/* - * This function is used for colecting data on read. + * This function is used for collecting data on read. * The complexity is because parts of the data can be stored in four different * places: - * - in delayed requests * - in memory - the data not yet send to the active journal provider - * - in requests which are going to be sent to the active journal * - in the active journal * - in the inactive journal * - in the data provider @@ -1576,20 +1535,14 @@ g_journal_read(struct g_journal_softc *sc, struct bio cstart = cend = -1; bp = NULL; head = NULL; - for (i = 0; i <= 5; i++) { + for (i = 1; i <= 5; i++) { switch (i) { - case 0: /* Delayed requests. */ - head = NULL; - sorted = 0; - break; case 1: /* Not-yet-send data. */ head = sc->sc_current_queue; sorted = 1; break; - case 2: /* In-flight to the active journal. */ - head = sc->sc_flush_queue; - sorted = 0; - break; + case 2: /* Skip flush queue as they are also in active queue */ + continue; case 3: /* Active journal. */ head = sc->sc_active.jj_queue; sorted = 1; @@ -1608,10 +1561,7 @@ g_journal_read(struct g_journal_softc *sc, struct bio default: panic("gjournal %s: i=%d", __func__, i); } - if (i == 0) - bp = g_journal_read_queue_find(&sc->sc_delayed_queue.queue, pbp, ostart, oend); - else - bp = g_journal_read_find(head, sorted, pbp, ostart, oend); + bp = g_journal_read_find(head, sorted, pbp, ostart, oend); if (bp == pbp) { /* Got the whole request. */ GJ_DEBUG(2, "Got the whole request from %u.", i); return; Modified: stable/11/sys/geom/journal/g_journal.h ============================================================================== --- stable/11/sys/geom/journal/g_journal.h Tue Aug 22 15:16:09 2017 (r322791) +++ stable/11/sys/geom/journal/g_journal.h Tue Aug 22 15:20:48 2017 (r322792) @@ -182,6 +182,17 @@ struct g_journal_softc { (pbp)->bio_next = (bp); \ } \ } while (0) +#define GJQ_LAST(head, bp) do { \ + struct bio *_bp; \ + \ + if ((head) == NULL) { \ + (bp) = (head); \ + break; \ + } \ + for (_bp = (head); _bp->bio_next != NULL; _bp = _bp->bio_next) \ + continue; \ + (bp) = (_bp); \ +} while (0) #define GJQ_FIRST(head) (head) #define GJQ_REMOVE(head, bp) do { \ struct bio *_bp; \ From owner-svn-src-stable@freebsd.org Tue Aug 22 15:26:48 2017 Return-Path: Delivered-To: svn-src-stable@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 8BE59DCB8C4; Tue, 22 Aug 2017 15:26:48 +0000 (UTC) (envelope-from mckusick@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 65F9C66530; Tue, 22 Aug 2017 15:26:48 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7MFQlkk060561; Tue, 22 Aug 2017 15:26:47 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7MFQl6Q060559; Tue, 22 Aug 2017 15:26:47 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201708221526.v7MFQl6Q060559@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Tue, 22 Aug 2017 15:26:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r322793 - stable/10/sys/geom/journal X-SVN-Group: stable-10 X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: stable/10/sys/geom/journal X-SVN-Commit-Revision: 322793 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Aug 2017 15:26:48 -0000 Author: mckusick Date: Tue Aug 22 15:26:47 2017 New Revision: 322793 URL: https://svnweb.freebsd.org/changeset/base/322793 Log: MFC of 269692, 322179, 322463, and 322464: 269692: cswitch is unsigned, so don't compare it < 0 322179: Correct ordering of bio's in gjournal queue 322463: Eliminate a variable that is set-only in g_journal.c 322464: Correct check for reads in gjournal Submitted by: Dr. Andreas Longwitz Discussed with: kib Approved by: re (marius) Modified: stable/10/sys/geom/journal/g_journal.c stable/10/sys/geom/journal/g_journal.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/geom/journal/g_journal.c ============================================================================== --- stable/10/sys/geom/journal/g_journal.c Tue Aug 22 15:20:48 2017 (r322792) +++ stable/10/sys/geom/journal/g_journal.c Tue Aug 22 15:26:47 2017 (r322793) @@ -175,7 +175,7 @@ g_journal_cache_switch_sysctl(SYSCTL_HANDLER_ARGS) error = sysctl_handle_int(oidp, &cswitch, 0, req); if (error != 0 || req->newptr == NULL) return (error); - if (cswitch < 0 || cswitch > 100) + if (cswitch > 100) return (EINVAL); g_journal_cache_switch = cswitch; g_journal_cache_low = (g_journal_cache_limit / 100) * cswitch; @@ -1239,7 +1239,7 @@ g_journal_flush(struct g_journal_softc *sc) struct g_provider *pp; struct bio **bioq; struct bio *bp, *fbp, *pbp; - off_t joffset, size; + off_t joffset; u_char *data, hash[16]; MD5_CTX ctx; u_int i; @@ -1247,7 +1247,6 @@ g_journal_flush(struct g_journal_softc *sc) if (sc->sc_current_count == 0) return; - size = 0; pp = sc->sc_jprovider; GJ_VALIDATE_OFFSET(sc->sc_journal_offset, sc); joffset = sc->sc_journal_offset; @@ -1264,7 +1263,7 @@ g_journal_flush(struct g_journal_softc *sc) strlcpy(hdr.jrh_magic, GJ_RECORD_HEADER_MAGIC, sizeof(hdr.jrh_magic)); bioq = &sc->sc_active.jj_queue; - pbp = sc->sc_flush_queue; + GJQ_LAST(sc->sc_flush_queue, pbp); fbp = g_alloc_bio(); fbp->bio_parent = NULL; @@ -1297,7 +1296,6 @@ g_journal_flush(struct g_journal_softc *sc) ent->je_offset = bp->bio_offset; ent->je_joffset = joffset; ent->je_length = bp->bio_length; - size += ent->je_length; data = bp->bio_data; if (sc->sc_flags & GJF_DEVICE_CHECKSUM) @@ -1519,49 +1517,10 @@ g_journal_read_find(struct bio *head, int sorted, stru } /* - * Try to find requested data in cache. - */ -static struct bio * -g_journal_read_queue_find(struct bio_queue *head, struct bio *pbp, off_t ostart, - off_t oend) -{ - off_t cstart, cend; - struct bio *bp; - - TAILQ_FOREACH(bp, head, bio_queue) { - cstart = MAX(ostart, bp->bio_offset); - cend = MIN(oend, bp->bio_offset + bp->bio_length); - if (cend <= ostart) - continue; - else if (cstart >= oend) - continue; - KASSERT(bp->bio_data != NULL, - ("%s: bio_data == NULL", __func__)); - GJ_DEBUG(3, "READ(%p): (%jd, %jd) (bp=%p)", head, cstart, cend, - bp); - bcopy(bp->bio_data + cstart - bp->bio_offset, - pbp->bio_data + cstart - pbp->bio_offset, cend - cstart); - pbp->bio_completed += cend - cstart; - if (pbp->bio_completed == pbp->bio_length) { - /* - * Cool, the whole request was in cache, deliver happy - * message. - */ - g_io_deliver(pbp, 0); - return (pbp); - } - break; - } - return (bp); -} - -/* - * This function is used for colecting data on read. + * This function is used for collecting data on read. * The complexity is because parts of the data can be stored in four different * places: - * - in delayed requests * - in memory - the data not yet send to the active journal provider - * - in requests which are going to be sent to the active journal * - in the active journal * - in the inactive journal * - in the data provider @@ -1579,20 +1538,14 @@ g_journal_read(struct g_journal_softc *sc, struct bio cstart = cend = -1; bp = NULL; head = NULL; - for (i = 0; i <= 5; i++) { + for (i = 1; i <= 5; i++) { switch (i) { - case 0: /* Delayed requests. */ - head = NULL; - sorted = 0; - break; case 1: /* Not-yet-send data. */ head = sc->sc_current_queue; sorted = 1; break; - case 2: /* In-flight to the active journal. */ - head = sc->sc_flush_queue; - sorted = 0; - break; + case 2: /* Skip flush queue as they are also in active queue */ + continue; case 3: /* Active journal. */ head = sc->sc_active.jj_queue; sorted = 1; @@ -1611,10 +1564,7 @@ g_journal_read(struct g_journal_softc *sc, struct bio default: panic("gjournal %s: i=%d", __func__, i); } - if (i == 0) - bp = g_journal_read_queue_find(&sc->sc_delayed_queue.queue, pbp, ostart, oend); - else - bp = g_journal_read_find(head, sorted, pbp, ostart, oend); + bp = g_journal_read_find(head, sorted, pbp, ostart, oend); if (bp == pbp) { /* Got the whole request. */ GJ_DEBUG(2, "Got the whole request from %u.", i); return; Modified: stable/10/sys/geom/journal/g_journal.h ============================================================================== --- stable/10/sys/geom/journal/g_journal.h Tue Aug 22 15:20:48 2017 (r322792) +++ stable/10/sys/geom/journal/g_journal.h Tue Aug 22 15:26:47 2017 (r322793) @@ -182,6 +182,17 @@ struct g_journal_softc { (pbp)->bio_next = (bp); \ } \ } while (0) +#define GJQ_LAST(head, bp) do { \ + struct bio *_bp; \ + \ + if ((head) == NULL) { \ + (bp) = (head); \ + break; \ + } \ + for (_bp = (head); _bp->bio_next != NULL; _bp = _bp->bio_next) \ + continue; \ + (bp) = (_bp); \ +} while (0) #define GJQ_FIRST(head) (head) #define GJQ_REMOVE(head, bp) do { \ struct bio *_bp; \ From owner-svn-src-stable@freebsd.org Tue Aug 22 15:59:42 2017 Return-Path: Delivered-To: svn-src-stable@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 94637DCDE2D; Tue, 22 Aug 2017 15:59:42 +0000 (UTC) (envelope-from lwhsu@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [96.47.72.132]) (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 755B96797C; Tue, 22 Aug 2017 15:59:42 +0000 (UTC) (envelope-from lwhsu@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 1129) id C5E6F18E7; Tue, 22 Aug 2017 15:59:41 +0000 (UTC) Date: Tue, 22 Aug 2017 15:59:41 +0000 From: Li-Wen Hsu 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: r322761 - in stable/11/sys/arm64: arm64 include Message-ID: <20170822155941.GA52559@freefall.freebsd.org> References: <201708211735.v7LHZ4UG023562@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201708211735.v7LHZ4UG023562@repo.freebsd.org> User-Agent: Mutt/1.8.3 (2017-05-23) X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Aug 2017 15:59:42 -0000 On Mon, Aug 21, 2017 at 17:35:04 +0000, John Baldwin wrote: > Author: jhb > Date: Mon Aug 21 17:35:04 2017 > New Revision: 322761 > URL: https://svnweb.freebsd.org/changeset/base/322761 > > Log: > MFC 322437: Reliably enable debug exceptions on all CPUs. > > Previously, debug exceptions were only enabled on the boot CPU if > DDB was enabled in the dbg_monitor_init() function. APs also called > this function, but since mp_machdep.c doesn't include opt_ddb.h, the > APs ended up calling an empty stub defined in > instead of the real function. Also, if DDB was not enabled in the kernel, > the boot CPU would not enable debug exceptions. > > Fix this by adding a new dbg_init() function that always clears the OS > lock to enable debug exceptions which the boot CPU and the APs call. > This function also calls dbg_monitor_init() to enable hardware breakpoints > from DDB on all CPUs if DDB is enabled. Eventually base support for > hardware breakpoints/watchpoints will need to move out of the DDB-only > debug_monitor.c for use by userland debuggers. > > Modified: > stable/11/sys/arm64/arm64/debug_monitor.c > stable/11/sys/arm64/arm64/machdep.c > stable/11/sys/arm64/arm64/mp_machdep.c > stable/11/sys/arm64/include/machdep.h > Directory Properties: > stable/11/ (props changed) > > Modified: stable/11/sys/arm64/arm64/mp_machdep.c > ============================================================================== > --- stable/11/sys/arm64/arm64/mp_machdep.c Mon Aug 21 17:29:37 2017 (r322760) > +++ stable/11/sys/arm64/arm64/mp_machdep.c Mon Aug 21 17:35:04 2017 (r322761) > @@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$"); > #include > #include > > -#include > #include > #include > #ifdef VFP > @@ -277,7 +276,7 @@ init_secondary(uint64_t cpu) > vfp_init(); > #endif > > - dbg_monitor_init(); > + dbg_init(); > pan_enable(); > > /* Enable interrupts */ > Hi, This seems breaking aarch64 build: https://ci.freebsd.org/job/FreeBSD-stable-11-aarch64-build/1504/console --- mp_machdep.o --- /usr/src/sys/arm64/arm64/mp_machdep.c:279:2: error: implicit declaration of function 'dbg_init' is invalid in C99 [-Werror,-Wimplicit-function-declaration] dbg_init(); ^ /usr/src/sys/arm64/arm64/mp_machdep.c:279:2: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes] 2 errors generated. *** [mp_machdep.o] Error code 1 make[2]: stopped in /usr/obj/arm64.aarch64/usr/src/sys/GENERIC Forgot including? Plase check, thanks! Best, Li-Wen -- Li-Wen Hsu https://lwhsu.org From owner-svn-src-stable@freebsd.org Tue Aug 22 17:58:22 2017 Return-Path: Delivered-To: svn-src-stable@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 92376DD877C; Tue, 22 Aug 2017 17:58:22 +0000 (UTC) (envelope-from andrew@fubar.geek.nz) Received: from fry.fubar.geek.nz (fry.fubar.geek.nz [139.59.165.16]) by mx1.freebsd.org (Postfix) with ESMTP id 44DD06E239; Tue, 22 Aug 2017 17:58:21 +0000 (UTC) (envelope-from andrew@fubar.geek.nz) Received: from dhcp-10-248-113-1.eduroam.wireless.private.cam.ac.uk (global-5-143.nat-2.net.cam.ac.uk [131.111.5.143]) by fry.fubar.geek.nz (Postfix) with ESMTPSA id 601484E769; Tue, 22 Aug 2017 17:49:13 +0000 (UTC) From: Andrew Turner Message-Id: Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: svn commit: r322761 - in stable/11/sys/arm64: arm64 include Date: Tue, 22 Aug 2017 18:49:12 +0100 In-Reply-To: <20170822155941.GA52559@freefall.freebsd.org> Cc: John Baldwin , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org To: Li-Wen Hsu References: <201708211735.v7LHZ4UG023562@repo.freebsd.org> <20170822155941.GA52559@freefall.freebsd.org> X-Mailer: Apple Mail (2.3273) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Aug 2017 17:58:22 -0000 > On 22 Aug 2017, at 16:59, Li-Wen Hsu wrote: >=20 > On Mon, Aug 21, 2017 at 17:35:04 +0000, John Baldwin wrote: >> Author: jhb >> Date: Mon Aug 21 17:35:04 2017 >> New Revision: 322761 >> URL: https://svnweb.freebsd.org/changeset/base/322761 >>=20 >> Log: >> MFC 322437: Reliably enable debug exceptions on all CPUs. >>=20 >> Previously, debug exceptions were only enabled on the boot CPU if >> DDB was enabled in the dbg_monitor_init() function. APs also called >> this function, but since mp_machdep.c doesn't include opt_ddb.h, the >> APs ended up calling an empty stub defined in = >> instead of the real function. Also, if DDB was not enabled in the = kernel, >> the boot CPU would not enable debug exceptions. >>=20 >> Fix this by adding a new dbg_init() function that always clears the = OS >> lock to enable debug exceptions which the boot CPU and the APs call. >> This function also calls dbg_monitor_init() to enable hardware = breakpoints >> from DDB on all CPUs if DDB is enabled. Eventually base support for >> hardware breakpoints/watchpoints will need to move out of the = DDB-only >> debug_monitor.c for use by userland debuggers. >>=20 >> Modified: >> stable/11/sys/arm64/arm64/debug_monitor.c >> stable/11/sys/arm64/arm64/machdep.c >> stable/11/sys/arm64/arm64/mp_machdep.c >> stable/11/sys/arm64/include/machdep.h >> Directory Properties: >> stable/11/ (props changed) >>=20 >> Modified: stable/11/sys/arm64/arm64/mp_machdep.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/sys/arm64/arm64/mp_machdep.c Mon Aug 21 17:29:37 2017 = (r322760) >> +++ stable/11/sys/arm64/arm64/mp_machdep.c Mon Aug 21 17:35:04 2017 = (r322761) >> @@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$"); >> #include >> #include >>=20 >> -#include >> #include >> #include >> #ifdef VFP >> @@ -277,7 +276,7 @@ init_secondary(uint64_t cpu) >> vfp_init(); >> #endif >>=20 >> - dbg_monitor_init(); >> + dbg_init(); >> pan_enable(); >>=20 >> /* Enable interrupts */ >>=20 >=20 > Hi, >=20 > This seems breaking aarch64 build: >=20 > = https://ci.freebsd.org/job/FreeBSD-stable-11-aarch64-build/1504/console = >=20 > --- mp_machdep.o --- > /usr/src/sys/arm64/arm64/mp_machdep.c:279:2: error: implicit = declaration of function 'dbg_init' is invalid in C99 = [-Werror,-Wimplicit-function-declaration] > dbg_init(); > ^ > /usr/src/sys/arm64/arm64/mp_machdep.c:279:2: error: this function = declaration is not a prototype [-Werror,-Wstrict-prototypes] > 2 errors generated. > *** [mp_machdep.o] Error code 1 >=20 > make[2]: stopped in /usr/obj/arm64.aarch64/usr/src/sys/GENERIC >=20 >=20 > Forgot including? Plase check, thanks! mp_machdep.c includes machine/machdep.h in head, but not stable/11. It = was added in a change that wasn=E2=80=99t (and shouldn=E2=80=99t be) = MFCd. Andrew From owner-svn-src-stable@freebsd.org Tue Aug 22 19:48:34 2017 Return-Path: Delivered-To: svn-src-stable@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 CB20BDDFBB0; Tue, 22 Aug 2017 19:48:34 +0000 (UTC) (envelope-from jhb@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 955ED726B6; Tue, 22 Aug 2017 19:48:34 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7MJmXlA071343; Tue, 22 Aug 2017 19:48:33 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7MJmXkK071342; Tue, 22 Aug 2017 19:48:33 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201708221948.v7MJmXkK071342@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Tue, 22 Aug 2017 19:48: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: r322801 - stable/11/sys/arm64/arm64 X-SVN-Group: stable-11 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/11/sys/arm64/arm64 X-SVN-Commit-Revision: 322801 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Aug 2017 19:48:34 -0000 Author: jhb Date: Tue Aug 22 19:48:33 2017 New Revision: 322801 URL: https://svnweb.freebsd.org/changeset/base/322801 Log: Add missing #include to fix build after r322761. Reported by: lwhsu Pointy hat to: jhb Modified: stable/11/sys/arm64/arm64/mp_machdep.c Modified: stable/11/sys/arm64/arm64/mp_machdep.c ============================================================================== --- stable/11/sys/arm64/arm64/mp_machdep.c Tue Aug 22 18:20:25 2017 (r322800) +++ stable/11/sys/arm64/arm64/mp_machdep.c Tue Aug 22 19:48:33 2017 (r322801) @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #ifdef VFP From owner-svn-src-stable@freebsd.org Wed Aug 23 04:35:05 2017 Return-Path: Delivered-To: svn-src-stable@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 3C093DDA8AB; Wed, 23 Aug 2017 04:35:05 +0000 (UTC) (envelope-from mckusick@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 153B61E1F; Wed, 23 Aug 2017 04:35:05 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7N4Z4re086386; Wed, 23 Aug 2017 04:35:04 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7N4Z4l4086383; Wed, 23 Aug 2017 04:35:04 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201708230435.v7N4Z4l4086383@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Wed, 23 Aug 2017 04:35:04 +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: r322806 - in stable/11: sbin/fsck_ffs sbin/newfs sys/ufs/ffs X-SVN-Group: stable-11 X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: in stable/11: sbin/fsck_ffs sbin/newfs sys/ufs/ffs X-SVN-Commit-Revision: 322806 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Aug 2017 04:35:05 -0000 Author: mckusick Date: Wed Aug 23 04:35:03 2017 New Revision: 322806 URL: https://svnweb.freebsd.org/changeset/base/322806 Log: MFC of 322200, 322201, 322271, and 322297 322200: Remove (broken) search for alternate superblocks 322201: Show differences when alternate superblock fails to match 322271: Cleanup for 322200. 322297: Restore fsck_ffs ability to find alternate superblocks Discussed with: kib, imp Differential Revision: https://reviews.freebsd.org/D11589 Modified: stable/11/sbin/fsck_ffs/setup.c stable/11/sbin/newfs/mkfs.c stable/11/sys/ufs/ffs/fs.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/fsck_ffs/setup.c ============================================================================== --- stable/11/sbin/fsck_ffs/setup.c Wed Aug 23 03:54:34 2017 (r322805) +++ stable/11/sbin/fsck_ffs/setup.c Wed Aug 23 04:35:03 2017 (r322806) @@ -58,7 +58,9 @@ struct bufarea asblk; #define altsblock (*asblk.b_un.b_fs) #define POWEROF2(num) (((num) & ((num) - 1)) == 0) -static void badsb(int listerr, const char *s); +static int calcsb(char *dev, int devfd, struct fs *fs); +static void saverecovery(int readfd, int writefd); +static int chkrecovery(int devfd); /* * Read in a superblock finding an alternate if necessary. @@ -176,7 +178,7 @@ setup(char *dev) */ if (readsb(1) == 0) { skipclean = 0; - if (bflag || preen) + if (bflag || preen || calcsb(dev, fsreadfd, &proto) == 0) return(0); if (reply("LOOK FOR ALTERNATE SUPERBLOCKS") == 0) return (0); @@ -234,6 +236,10 @@ setup(char *dev) memmove(&altsblock, &sblock, (size_t)sblock.fs_sbsize); flush(fswritefd, &asblk); } + if (preen == 0 && yflag == 0 && sblock.fs_magic == FS_UFS2_MAGIC && + fswritefd != -1 && chkrecovery(fsreadfd) == 0 && + reply("SAVE DATA TO FIND ALTERNATE SUPERBLOCKS") != 0) + saverecovery(fsreadfd, fswritefd); /* * read in the summary info. */ @@ -313,7 +319,7 @@ int readsb(int listerr) { ufs2_daddr_t super; - int i; + int i, bad; if (bflag) { super = bflag; @@ -363,40 +369,57 @@ readsb(int listerr) dev_bsize = sblock.fs_fsize / fsbtodb(&sblock, 1); sblk.b_bno = super / dev_bsize; sblk.b_size = SBLOCKSIZE; - if (bflag) - goto out; /* * Compare all fields that should not differ in alternate super block. * When an alternate super-block is specified this check is skipped. */ + if (bflag) + goto out; getblk(&asblk, cgsblock(&sblock, sblock.fs_ncg - 1), sblock.fs_sbsize); if (asblk.b_errs) return (0); - if (altsblock.fs_sblkno != sblock.fs_sblkno || - altsblock.fs_cblkno != sblock.fs_cblkno || - altsblock.fs_iblkno != sblock.fs_iblkno || - altsblock.fs_dblkno != sblock.fs_dblkno || - altsblock.fs_ncg != sblock.fs_ncg || - altsblock.fs_bsize != sblock.fs_bsize || - altsblock.fs_fsize != sblock.fs_fsize || - altsblock.fs_frag != sblock.fs_frag || - altsblock.fs_bmask != sblock.fs_bmask || - altsblock.fs_fmask != sblock.fs_fmask || - altsblock.fs_bshift != sblock.fs_bshift || - altsblock.fs_fshift != sblock.fs_fshift || - altsblock.fs_fragshift != sblock.fs_fragshift || - altsblock.fs_fsbtodb != sblock.fs_fsbtodb || - altsblock.fs_sbsize != sblock.fs_sbsize || - altsblock.fs_nindir != sblock.fs_nindir || - altsblock.fs_inopb != sblock.fs_inopb || - altsblock.fs_cssize != sblock.fs_cssize || - altsblock.fs_ipg != sblock.fs_ipg || - altsblock.fs_fpg != sblock.fs_fpg || - altsblock.fs_magic != sblock.fs_magic) { - badsb(listerr, - "VALUES IN SUPER BLOCK DISAGREE WITH THOSE IN FIRST ALTERNATE"); - return (0); + bad = 0; +#define CHK(x, y) \ + if (altsblock.x != sblock.x) { \ + bad++; \ + if (listerr && debug) \ + printf("SUPER BLOCK VS ALTERNATE MISMATCH %s: " y " vs " y "\n", \ + #x, (intmax_t)sblock.x, (intmax_t)altsblock.x); \ } + CHK(fs_sblkno, "%jd"); + CHK(fs_cblkno, "%jd"); + CHK(fs_iblkno, "%jd"); + CHK(fs_dblkno, "%jd"); + CHK(fs_ncg, "%jd"); + CHK(fs_bsize, "%jd"); + CHK(fs_fsize, "%jd"); + CHK(fs_frag, "%jd"); + CHK(fs_bmask, "%#jx"); + CHK(fs_fmask, "%#jx"); + CHK(fs_bshift, "%jd"); + CHK(fs_fshift, "%jd"); + CHK(fs_fragshift, "%jd"); + CHK(fs_fsbtodb, "%jd"); + CHK(fs_sbsize, "%jd"); + CHK(fs_nindir, "%jd"); + CHK(fs_inopb, "%jd"); + CHK(fs_cssize, "%jd"); + CHK(fs_ipg, "%jd"); + CHK(fs_fpg, "%jd"); + CHK(fs_magic, "%#jx"); +#undef CHK + if (bad) { + if (listerr == 0) + return (0); + if (preen) + printf("%s: ", cdevname); + printf( + "VALUES IN SUPER BLOCK LSB=%jd DISAGREE WITH THOSE IN\n" + "LAST ALTERNATE LSB=%jd\n", + sblk.b_bno, asblk.b_bno); + if (reply("IGNORE ALTERNATE SUPER BLOCK") == 0) + return (0); + } out: /* * If not yet done, update UFS1 superblock with new wider fields. @@ -417,17 +440,6 @@ out: return (1); } -static void -badsb(int listerr, const char *s) -{ - - if (!listerr) - return; - if (preen) - printf("%s: ", cdevname); - pfatal("BAD SUPER BLOCK: %s\n", s); -} - void sblock_init(void) { @@ -442,4 +454,74 @@ sblock_init(void) if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL) errx(EEXIT, "cannot allocate space for superblock"); dev_bsize = secsize = DEV_BSIZE; +} + +/* + * Calculate a prototype superblock based on information in the boot area. + * When done the cgsblock macro can be calculated and the fs_ncg field + * can be used. Do NOT attempt to use other macros without verifying that + * their needed information is available! + */ +static int +calcsb(char *dev, int devfd, struct fs *fs) +{ + struct fsrecovery fsr; + + /* + * We need fragments-per-group and the partition-size. + * + * Newfs stores these details at the end of the boot block area + * at the start of the filesystem partition. If they have been + * overwritten by a boot block, we fail. But usually they are + * there and we can use them. + */ + if (blread(devfd, (char *)&fsr, + (SBLOCK_UFS2 - sizeof(fsr)) / dev_bsize, sizeof(fsr)) || + fsr.fsr_magic != FS_UFS2_MAGIC) + return (0); + memset(fs, 0, sizeof(struct fs)); + fs->fs_fpg = fsr.fsr_fpg; + fs->fs_fsbtodb = fsr.fsr_fsbtodb; + fs->fs_sblkno = fsr.fsr_sblkno; + fs->fs_magic = fsr.fsr_magic; + fs->fs_ncg = fsr.fsr_ncg; + return (1); +} + +/* + * Check to see if recovery information exists. + */ +static int +chkrecovery(int devfd) +{ + struct fsrecovery fsr; + + if (blread(devfd, (char *)&fsr, + (SBLOCK_UFS2 - sizeof(fsr)) / dev_bsize, sizeof(fsr)) || + fsr.fsr_magic != FS_UFS2_MAGIC) + return (0); + return (1); +} + +/* + * Read the last sector of the boot block, replace the last + * 20 bytes with the recovery information, then write it back. + * The recovery information only works for UFS2 filesystems. + */ +static void +saverecovery(int readfd, int writefd) +{ + struct fsrecovery fsr; + + if (sblock.fs_magic != FS_UFS2_MAGIC || + blread(readfd, (char *)&fsr, + (SBLOCK_UFS2 - sizeof(fsr)) / dev_bsize, sizeof(fsr))) + return; + fsr.fsr_magic = sblock.fs_magic; + fsr.fsr_fpg = sblock.fs_fpg; + fsr.fsr_fsbtodb = sblock.fs_fsbtodb; + fsr.fsr_sblkno = sblock.fs_sblkno; + fsr.fsr_ncg = sblock.fs_ncg; + blwrite(writefd, (char *)&fsr, (SBLOCK_UFS2 - sizeof(fsr)) / dev_bsize, + sizeof(fsr)); } Modified: stable/11/sbin/newfs/mkfs.c ============================================================================== --- stable/11/sbin/newfs/mkfs.c Wed Aug 23 03:54:34 2017 (r322805) +++ stable/11/sbin/newfs/mkfs.c Wed Aug 23 04:35:03 2017 (r322806) @@ -121,6 +121,7 @@ mkfs(struct partition *pp, char *fsys) ino_t maxinum; int minfragsperinode; /* minimum ratio of frags to inodes */ char tmpbuf[100]; /* XXX this will break in about 2,500 years */ + struct fsrecovery fsr; union { struct fs fdummy; char cdummy[SBLOCKSIZE]; @@ -615,6 +616,25 @@ restart: wtfs(fsbtodb(&sblock, sblock.fs_csaddr + numfrags(&sblock, i)), MIN(sblock.fs_cssize - i, sblock.fs_bsize), ((char *)fscs) + i); + /* + * Read the last sector of the boot block, replace the last + * 20 bytes with the recovery information, then write it back. + * The recovery information only works for UFS2 filesystems. + */ + if (sblock.fs_magic == FS_UFS2_MAGIC) { + i = bread(&disk, + part_ofs + (SBLOCK_UFS2 - sizeof(fsr)) / disk.d_bsize, + (char *)&fsr, sizeof(fsr)); + if (i == -1) + err(1, "can't read recovery area: %s", disk.d_error); + fsr.fsr_magic = sblock.fs_magic; + fsr.fsr_fpg = sblock.fs_fpg; + fsr.fsr_fsbtodb = sblock.fs_fsbtodb; + fsr.fsr_sblkno = sblock.fs_sblkno; + fsr.fsr_ncg = sblock.fs_ncg; + wtfs((SBLOCK_UFS2 - sizeof(fsr)) / disk.d_bsize, sizeof(fsr), + (char *)&fsr); + } /* * Update information about this partition in pack * label, to that it may be updated on disk. Modified: stable/11/sys/ufs/ffs/fs.h ============================================================================== --- stable/11/sys/ufs/ffs/fs.h Wed Aug 23 03:54:34 2017 (r322805) +++ stable/11/sys/ufs/ffs/fs.h Wed Aug 23 04:35:03 2017 (r322806) @@ -234,6 +234,20 @@ struct fsck_cmd { }; /* + * A recovery structure placed at the end of the boot block area by newfs + * that can be used by fsck to search for alternate superblocks. + */ +#define RESID (4096 - 20) /* disk sector size minus recovery area size */ +struct fsrecovery { + char block[RESID]; /* unused part of sector */ + int32_t fsr_magic; /* magic number */ + int32_t fsr_fsbtodb; /* fsbtodb and dbtofsb shift constant */ + int32_t fsr_sblkno; /* offset of super-block in filesys */ + int32_t fsr_fpg; /* blocks per group * fs_frag */ + u_int32_t fsr_ncg; /* number of cylinder groups */ +}; + +/* * Per cylinder group information; summarized in blocks allocated * from first cylinder group data blocks. These blocks have to be * read in from fs_csaddr (size fs_cssize) in addition to the From owner-svn-src-stable@freebsd.org Wed Aug 23 04:43:51 2017 Return-Path: Delivered-To: svn-src-stable@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 690A7DDB284; Wed, 23 Aug 2017 04:43:51 +0000 (UTC) (envelope-from mckusick@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 3485C2547; Wed, 23 Aug 2017 04:43:51 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7N4ho3q090467; Wed, 23 Aug 2017 04:43:50 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7N4hoNY090466; Wed, 23 Aug 2017 04:43:50 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201708230443.v7N4hoNY090466@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Wed, 23 Aug 2017 04:43: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: r322807 - stable/11 X-SVN-Group: stable-11 X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: stable/11 X-SVN-Commit-Revision: 322807 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Aug 2017 04:43:51 -0000 Author: mckusick Date: Wed Aug 23 04:43:50 2017 New Revision: 322807 URL: https://svnweb.freebsd.org/changeset/base/322807 Log: MFC of 322298 noting MFC 322806 in UPDATING Modified: stable/11/UPDATING Modified: stable/11/UPDATING ============================================================================== --- stable/11/UPDATING Wed Aug 23 04:35:03 2017 (r322806) +++ stable/11/UPDATING Wed Aug 23 04:43:50 2017 (r322807) @@ -16,6 +16,19 @@ from older versions of FreeBSD, try WITHOUT_CLANG and 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. +20170822: + Since the switch to GPT disk labels, fsck for UFS/FFS has been + unable to automatically find alternate superblocks. As of r322806, + the information needed to find alternate superblocks has been + moved to the end of the area reserved for the boot block. + Filesystems created with a newfs of this vintage or later + will create the recovery information. If you have a filesystem + created prior to this change and wish to have a recovery block + created for your filesystem, you can do so by running fsck in + forground mode (i.e., do not use the -p or -y options). As it + starts, fsck will ask ``SAVE DATA TO FIND ALTERNATE SUPERBLOCKS'' + to which you should answer yes. + 20170518: arm64 builds now use the base system LLD 4.0.0 linker by default, instead of requiring that the aarch64-binutils port or package be From owner-svn-src-stable@freebsd.org Wed Aug 23 08:56:20 2017 Return-Path: Delivered-To: svn-src-stable@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 41340DE1BB6; Wed, 23 Aug 2017 08:56: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 1CE63679FE; Wed, 23 Aug 2017 08:56: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 v7N8uJAM091886; Wed, 23 Aug 2017 08:56:19 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7N8uJg1091884; Wed, 23 Aug 2017 08:56:19 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201708230856.v7N8uJg1091884@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Wed, 23 Aug 2017 08:56: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: r322808 - in stable/11: share/man/man4 sys/net X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: in stable/11: share/man/man4 sys/net X-SVN-Commit-Revision: 322808 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Aug 2017 08:56:20 -0000 Author: ae Date: Wed Aug 23 08:56:18 2017 New Revision: 322808 URL: https://svnweb.freebsd.org/changeset/base/322808 Log: MFC r322310: Add to if_enc(4) ability to capture packets via BPF after pfil processing. New flag 0x4 can be configured in net.enc.[in|out].ipsec_bpf_mask. When it is set, if_enc(4) additionally captures a packet via BPF after invoking pfil hook. This may be useful for debugging. Sponsored by: Yandex LLC Modified: stable/11/share/man/man4/enc.4 stable/11/sys/net/if_enc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man4/enc.4 ============================================================================== --- stable/11/share/man/man4/enc.4 Wed Aug 23 04:43:50 2017 (r322807) +++ stable/11/share/man/man4/enc.4 Wed Aug 23 08:56:18 2017 (r322808) @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 28, 2007 +.Dd August 9, 2017 .Dt ENC 4 .Os .Sh NAME @@ -44,6 +44,13 @@ kernel configuration file: .Bd -ragged -offset indent .Cd "device enc" .Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +if_enc_load="YES" +.Ed .Sh DESCRIPTION The .Nm @@ -115,6 +122,11 @@ outgoing path Most people will want to run with the suggested defaults for .Cm ipsec_filter_mask and rely on the security policy database for the outer headers. +.Pp +Note that packets are captured by BPF before firewall processing. +The special value 0x4 can be configured in the +.Ar ipsec_bpf_mask +and packets will be also captured after firewall processing. .Sh EXAMPLES To see the packets the processed via .Xr ipsec 4 , Modified: stable/11/sys/net/if_enc.c ============================================================================== --- stable/11/sys/net/if_enc.c Wed Aug 23 04:43:50 2017 (r322807) +++ stable/11/sys/net/if_enc.c Wed Aug 23 08:56:18 2017 (r322808) @@ -99,9 +99,15 @@ static void enc_remove_hhooks(struct enc_softc *); static const char encname[] = "enc"; +#define IPSEC_ENC_AFTER_PFIL 0x04 /* * Before and after are relative to when we are stripping the * outer IP header. + * + * AFTER_PFIL flag used only for bpf_mask_*. It enables BPF capturing + * after PFIL hook execution. It might be useful when PFIL hook does + * some changes to the packet, e.g. address translation. If PFIL hook + * consumes mbuf, nothing will be captured. */ static VNET_DEFINE(int, filter_mask_in) = IPSEC_ENC_BEFORE; static VNET_DEFINE(int, bpf_mask_in) = IPSEC_ENC_BEFORE; @@ -194,6 +200,30 @@ enc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) return (0); } +static void +enc_bpftap(struct ifnet *ifp, struct mbuf *m, const struct secasvar *sav, + int32_t hhook_type, uint8_t enc, uint8_t af) +{ + struct enchdr hdr; + + if (hhook_type == HHOOK_TYPE_IPSEC_IN && + (enc & V_bpf_mask_in) == 0) + return; + else if (hhook_type == HHOOK_TYPE_IPSEC_OUT && + (enc & V_bpf_mask_out) == 0) + return; + if (bpf_peers_present(ifp->if_bpf) == 0) + return; + hdr.af = af; + hdr.spi = sav->spi; + hdr.flags = 0; + if (sav->alg_enc != SADB_EALG_NONE) + hdr.flags |= M_CONF; + if (sav->alg_auth != SADB_AALG_NONE) + hdr.flags |= M_AUTH; + bpf_mtap2(ifp->if_bpf, &hdr, sizeof(hdr), m); +} + /* * One helper hook function is used by any hook points. * + from hhook_type we can determine the packet direction: @@ -206,7 +236,6 @@ static int enc_hhook(int32_t hhook_type, int32_t hhook_id, void *udata, void *ctx_data, void *hdata, struct osd *hosd) { - struct enchdr hdr; struct ipsec_ctx_data *ctx; struct enc_softc *sc; struct ifnet *ifp, *rcvif; @@ -223,21 +252,7 @@ enc_hhook(int32_t hhook_type, int32_t hhook_id, void * if (ctx->af != hhook_id) return (EPFNOSUPPORT); - if (((hhook_type == HHOOK_TYPE_IPSEC_IN && - (ctx->enc & V_bpf_mask_in) != 0) || - (hhook_type == HHOOK_TYPE_IPSEC_OUT && - (ctx->enc & V_bpf_mask_out) != 0)) && - bpf_peers_present(ifp->if_bpf) != 0) { - hdr.af = ctx->af; - hdr.spi = ctx->sav->spi; - hdr.flags = 0; - if (ctx->sav->alg_enc != SADB_EALG_NONE) - hdr.flags |= M_CONF; - if (ctx->sav->alg_auth != SADB_AALG_NONE) - hdr.flags |= M_AUTH; - bpf_mtap2(ifp->if_bpf, &hdr, sizeof(hdr), *ctx->mp); - } - + enc_bpftap(ifp, *ctx->mp, ctx->sav, hhook_type, ctx->enc, ctx->af); switch (hhook_type) { case HHOOK_TYPE_IPSEC_IN: if (ctx->enc == IPSEC_ENC_BEFORE) { @@ -290,6 +305,8 @@ enc_hhook(int32_t hhook_type, int32_t hhook_id, void * return (EACCES); } (*ctx->mp)->m_pkthdr.rcvif = rcvif; + enc_bpftap(ifp, *ctx->mp, ctx->sav, hhook_type, + IPSEC_ENC_AFTER_PFIL, ctx->af); return (0); } From owner-svn-src-stable@freebsd.org Wed Aug 23 15:44:00 2017 Return-Path: Delivered-To: svn-src-stable@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 5DCC5DE9EF8; Wed, 23 Aug 2017 15:44:00 +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 2BF767512F; Wed, 23 Aug 2017 15:44:00 +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 v7NFhxoq062396; Wed, 23 Aug 2017 15:43:59 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7NFhxVY062394; Wed, 23 Aug 2017 15:43:59 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201708231543.v7NFhxVY062394@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Wed, 23 Aug 2017 15:43: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: r322814 - stable/11/sys/fs/ext2fs X-SVN-Group: stable-11 X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: stable/11/sys/fs/ext2fs X-SVN-Commit-Revision: 322814 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Aug 2017 15:44:00 -0000 Author: pfg Date: Wed Aug 23 15:43:59 2017 New Revision: 322814 URL: https://svnweb.freebsd.org/changeset/base/322814 Log: MFC r320146, r320170, 320842: Minor grammar changes and cleanups in order to facilitate future merges. Modified: stable/11/sys/fs/ext2fs/ext2_inode_cnv.c stable/11/sys/fs/ext2fs/ext2fs.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/ext2fs/ext2_inode_cnv.c ============================================================================== --- stable/11/sys/fs/ext2fs/ext2_inode_cnv.c Wed Aug 23 15:08:51 2017 (r322813) +++ stable/11/sys/fs/ext2fs/ext2_inode_cnv.c Wed Aug 23 15:43:59 2017 (r322814) @@ -126,7 +126,7 @@ ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip) ip->i_gid = ei->e2di_gid; ip->i_uid |= (uint32_t)ei->e2di_uid_high << 16; ip->i_gid |= (uint32_t)ei->e2di_gid_high << 16; - /* XXX use memcpy */ + for (i = 0; i < NDADDR; i++) ip->i_db[i] = ei->e2di_blocks[i]; for (i = 0; i < NIADDR; i++) @@ -176,7 +176,7 @@ ext2_i2ei(struct inode *ip, struct ext2fs_dinode *ei) ei->e2di_uid_high = ip->i_uid >> 16 & 0xffff; ei->e2di_gid = ip->i_gid & 0xffff; ei->e2di_gid_high = ip->i_gid >> 16 & 0xffff; - /* XXX use memcpy */ + for (i = 0; i < NDADDR; i++) ei->e2di_blocks[i] = ip->i_db[i]; for (i = 0; i < NIADDR; i++) Modified: stable/11/sys/fs/ext2fs/ext2fs.h ============================================================================== --- stable/11/sys/fs/ext2fs/ext2fs.h Wed Aug 23 15:08:51 2017 (r322813) +++ stable/11/sys/fs/ext2fs/ext2fs.h Wed Aug 23 15:43:59 2017 (r322814) @@ -374,9 +374,8 @@ struct ext2_gd { uint16_t ext4bgd_csum; /* group descriptor checksum */ }; - -/* EXT2FS metadatas are stored in little-endian byte order. These macros - * helps reading these metadatas +/* EXT2FS metadata is stored in little-endian byte order. These macros + * help reading it. */ #define e2fs_cgload(old, new, size) memcpy((new), (old), (size)); From owner-svn-src-stable@freebsd.org Wed Aug 23 15:47:43 2017 Return-Path: Delivered-To: svn-src-stable@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 E7411DEA05D; Wed, 23 Aug 2017 15:47:43 +0000 (UTC) (envelope-from benno@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 B5CAA7537A; Wed, 23 Aug 2017 15:47:43 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7NFlgKG062612; Wed, 23 Aug 2017 15:47:42 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7NFlgxG062611; Wed, 23 Aug 2017 15:47:42 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201708231547.v7NFlgxG062611@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Wed, 23 Aug 2017 15:47: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: r322815 - stable/11/usr.sbin/ctladm X-SVN-Group: stable-11 X-SVN-Commit-Author: benno X-SVN-Commit-Paths: stable/11/usr.sbin/ctladm X-SVN-Commit-Revision: 322815 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Aug 2017 15:47:44 -0000 Author: benno Date: Wed Aug 23 15:47:42 2017 New Revision: 322815 URL: https://svnweb.freebsd.org/changeset/base/322815 Log: MFC r322804: Correct typo in usage string. Submitted by: peterpakos (GitHub username) Modified: stable/11/usr.sbin/ctladm/ctladm.c Modified: stable/11/usr.sbin/ctladm/ctladm.c ============================================================================== --- stable/11/usr.sbin/ctladm/ctladm.c Wed Aug 23 15:43:59 2017 (r322814) +++ stable/11/usr.sbin/ctladm/ctladm.c Wed Aug 23 15:47:42 2017 (r322815) @@ -3958,7 +3958,7 @@ usage(int error) "-q : omit header in list output\n" "-x : output port list in XML format\n" "portlist options:\n" -"-f fronetnd : specify frontend type\n" +"-f frontend : specify frontend type\n" "-i : report target and initiators addresses\n" "-l : report LUN mapping\n" "-p targ_port : specify target port number\n" From owner-svn-src-stable@freebsd.org Wed Aug 23 17:12:27 2017 Return-Path: Delivered-To: svn-src-stable@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 CBE48DEB8A6; Wed, 23 Aug 2017 17:12:27 +0000 (UTC) (envelope-from gjb@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 9B88977B5C; Wed, 23 Aug 2017 17:12:27 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7NHCQNJ099422; Wed, 23 Aug 2017 17:12:26 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7NHCQ6H099421; Wed, 23 Aug 2017 17:12:26 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201708231712.v7NHCQ6H099421@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Wed, 23 Aug 2017 17:12: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: r322817 - stable/11/release X-SVN-Group: stable-11 X-SVN-Commit-Author: gjb X-SVN-Commit-Paths: stable/11/release X-SVN-Commit-Revision: 322817 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Aug 2017 17:12:27 -0000 Author: gjb Date: Wed Aug 23 17:12:26 2017 New Revision: 322817 URL: https://svnweb.freebsd.org/changeset/base/322817 Log: MFC r322544: Always expand the full path to the configuration file specified with the '-c' flag. Sponsored by: The FreeBSD Foundation Modified: stable/11/release/release.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/release/release.sh ============================================================================== --- stable/11/release/release.sh Wed Aug 23 16:50:10 2017 (r322816) +++ stable/11/release/release.sh Wed Aug 23 17:12:26 2017 (r322817) @@ -390,7 +390,7 @@ main() { while getopts c: opt; do case ${opt} in c) - RELEASECONF="${OPTARG}" + RELEASECONF="$(realpath ${OPTARG})" ;; \?) usage From owner-svn-src-stable@freebsd.org Wed Aug 23 17:47:58 2017 Return-Path: Delivered-To: svn-src-stable@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 E5543DEBFED; Wed, 23 Aug 2017 17:47:58 +0000 (UTC) (envelope-from gjb@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 B4C527CBAA; Wed, 23 Aug 2017 17:47:58 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7NHlvPY012138; Wed, 23 Aug 2017 17:47:57 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7NHlvGm012137; Wed, 23 Aug 2017 17:47:57 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201708231747.v7NHlvGm012137@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Wed, 23 Aug 2017 17:47:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r322818 - stable/10/release X-SVN-Group: stable-10 X-SVN-Commit-Author: gjb X-SVN-Commit-Paths: stable/10/release X-SVN-Commit-Revision: 322818 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Aug 2017 17:47:59 -0000 Author: gjb Date: Wed Aug 23 17:47:57 2017 New Revision: 322818 URL: https://svnweb.freebsd.org/changeset/base/322818 Log: MFC r322544: Always expand the full path to the configuration file specified with the '-c' flag. This fixes an issue where the configuration file would not properly be located intermittently. Approved by: re (kib, marius) Sponsored by: The FreeBSD Foundation Modified: stable/10/release/release.sh Directory Properties: stable/10/ (props changed) Modified: stable/10/release/release.sh ============================================================================== --- stable/10/release/release.sh Wed Aug 23 17:12:26 2017 (r322817) +++ stable/10/release/release.sh Wed Aug 23 17:47:57 2017 (r322818) @@ -384,7 +384,7 @@ main() { while getopts c: opt; do case ${opt} in c) - RELEASECONF="${OPTARG}" + RELEASECONF="$(realpath ${OPTARG})" ;; \?) usage From owner-svn-src-stable@freebsd.org Thu Aug 24 08:02:28 2017 Return-Path: Delivered-To: svn-src-stable@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 301C4DD906A; Thu, 24 Aug 2017 08:02:28 +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 F07FF6E79F; Thu, 24 Aug 2017 08:02:27 +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 v7O82RbR061978; Thu, 24 Aug 2017 08:02:27 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7O82Rs1061977; Thu, 24 Aug 2017 08:02:27 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201708240802.v7O82Rs1061977@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 24 Aug 2017 08:02: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: r322829 - stable/11/sys/ufs/ffs X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/ufs/ffs X-SVN-Commit-Revision: 322829 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2017 08:02:28 -0000 Author: kib Date: Thu Aug 24 08:02:26 2017 New Revision: 322829 URL: https://svnweb.freebsd.org/changeset/base/322829 Log: MFC r322756: Style. Modified: stable/11/sys/ufs/ffs/ffs_softdep.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- stable/11/sys/ufs/ffs/ffs_softdep.c Thu Aug 24 07:05:42 2017 (r322828) +++ stable/11/sys/ufs/ffs/ffs_softdep.c Thu Aug 24 08:02:26 2017 (r322829) @@ -14051,7 +14051,7 @@ softdep_count_dependencies(bp, wantcount) } out: FREE_LOCK(ump); - return retval; + return (retval); } /* From owner-svn-src-stable@freebsd.org Thu Aug 24 13:37:23 2017 Return-Path: Delivered-To: svn-src-stable@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 EDC2CDDFB7F; Thu, 24 Aug 2017 13:37:23 +0000 (UTC) (envelope-from gjb@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 B8A157C3C8; Thu, 24 Aug 2017 13:37:23 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7ODbMR3097183; Thu, 24 Aug 2017 13:37:22 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7ODbMev097182; Thu, 24 Aug 2017 13:37:22 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201708241337.v7ODbMev097182@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Thu, 24 Aug 2017 13:37:22 +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: r322834 - stable/11/usr.sbin/chown/tests X-SVN-Group: stable-11 X-SVN-Commit-Author: gjb X-SVN-Commit-Paths: stable/11/usr.sbin/chown/tests X-SVN-Commit-Revision: 322834 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2017 13:37:24 -0000 Author: gjb Date: Thu Aug 24 13:37:22 2017 New Revision: 322834 URL: https://svnweb.freebsd.org/changeset/base/322834 Log: MFC r322770, r322796: r322770: Apply changes from bin/chmod/tests/chmod_test.sh, adding atf_expect_fail() before chflags(8) is invoked if the filesystem is ZFS, which does not support UF_IMMUTABLE. r322796: Revert part of r322770 in usr.sbin/chown/tests/chown_test.sh, which incorrectly adds atf_expect_fail() where there is no failure case. Sponsored by: The FreeBSD Foundation Modified: stable/11/usr.sbin/chown/tests/chown_test.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/chown/tests/chown_test.sh ============================================================================== --- stable/11/usr.sbin/chown/tests/chown_test.sh Thu Aug 24 10:57:34 2017 (r322833) +++ stable/11/usr.sbin/chown/tests/chown_test.sh Thu Aug 24 13:37:22 2017 (r322834) @@ -25,6 +25,13 @@ # # $FreeBSD$ +get_filesystem() +{ + local mountpoint=$1 + + df -T $mountpoint | tail -n 1 | cut -wf 2 +} + atf_test_case RH_flag RH_flag_head() { @@ -98,6 +105,11 @@ f_flag_body() { atf_check truncate -s 0 foo bar atf_check chown 0:0 foo bar + case "$(get_filesystem .)" in + zfs) + atf_expect_fail "ZFS does not support UF_IMMUTABLE; returns EPERM" + ;; + esac atf_check chflags uchg foo atf_check -e not-empty -s not-exit:0 chown 42:42 foo bar atf_check -o inline:'0:0\n42:42\n' stat -f '%u:%g' foo bar @@ -107,7 +119,7 @@ f_flag_body() f_flag_cleanup() { - atf_check chflags 0 foo + chflags 0 foo || : } atf_test_case h_flag From owner-svn-src-stable@freebsd.org Thu Aug 24 13:39:25 2017 Return-Path: Delivered-To: svn-src-stable@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 975BADDFC04; Thu, 24 Aug 2017 13:39:25 +0000 (UTC) (envelope-from gjb@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 662C57C6B0; Thu, 24 Aug 2017 13:39:25 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7ODdOsa097293; Thu, 24 Aug 2017 13:39:24 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7ODdOIU097292; Thu, 24 Aug 2017 13:39:24 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201708241339.v7ODdOIU097292@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Thu, 24 Aug 2017 13:39:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r322835 - stable/10/usr.sbin/chown/tests X-SVN-Group: stable-10 X-SVN-Commit-Author: gjb X-SVN-Commit-Paths: stable/10/usr.sbin/chown/tests X-SVN-Commit-Revision: 322835 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2017 13:39:25 -0000 Author: gjb Date: Thu Aug 24 13:39:24 2017 New Revision: 322835 URL: https://svnweb.freebsd.org/changeset/base/322835 Log: MFC r322770, r322796: r322770: Apply changes from bin/chmod/tests/chmod_test.sh, adding atf_expect_fail() before chflags(8) is invoked if the filesystem is ZFS, which does not support UF_IMMUTABLE. r322796: Revert part of r322770 in usr.sbin/chown/tests/chown_test.sh, which incorrectly adds atf_expect_fail() where there is no failure case. Approved by: re (marius) Sponsored by: The FreeBSD Foundation Modified: stable/10/usr.sbin/chown/tests/chown_test.sh Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/chown/tests/chown_test.sh ============================================================================== --- stable/10/usr.sbin/chown/tests/chown_test.sh Thu Aug 24 13:37:22 2017 (r322834) +++ stable/10/usr.sbin/chown/tests/chown_test.sh Thu Aug 24 13:39:24 2017 (r322835) @@ -25,6 +25,13 @@ # # $FreeBSD$ +get_filesystem() +{ + local mountpoint=$1 + + df -T $mountpoint | tail -n 1 | cut -wf 2 +} + atf_test_case RH_flag RH_flag_head() { @@ -98,6 +105,11 @@ f_flag_body() { atf_check truncate -s 0 foo bar atf_check chown 0:0 foo bar + case "$(get_filesystem .)" in + zfs) + atf_expect_fail "ZFS does not support UF_IMMUTABLE; returns EPERM" + ;; + esac atf_check chflags uchg foo atf_check -e not-empty -s not-exit:0 chown 42:42 foo bar atf_check -o inline:'0:0\n42:42\n' stat -f '%u:%g' foo bar @@ -107,7 +119,7 @@ f_flag_body() f_flag_cleanup() { - atf_check chflags 0 foo + chflags 0 foo || : } atf_test_case h_flag From owner-svn-src-stable@freebsd.org Thu Aug 24 16:49:35 2017 Return-Path: Delivered-To: svn-src-stable@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 65B9CDE3E0C; Thu, 24 Aug 2017 16:49:35 +0000 (UTC) (envelope-from gjb@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 2C5D8840E5; Thu, 24 Aug 2017 16:49:35 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7OGnYd5078719; Thu, 24 Aug 2017 16:49:34 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7OGnYBD078718; Thu, 24 Aug 2017 16:49:34 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201708241649.v7OGnYBD078718@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Thu, 24 Aug 2017 16:49: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: r322847 - stable/11/share/man/man7 X-SVN-Group: stable-11 X-SVN-Commit-Author: gjb X-SVN-Commit-Paths: stable/11/share/man/man7 X-SVN-Commit-Revision: 322847 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2017 16:49:35 -0000 Author: gjb Date: Thu Aug 24 16:49:34 2017 New Revision: 322847 URL: https://svnweb.freebsd.org/changeset/base/322847 Log: MFC r322752: Update the tests(7) manual page to note the test suite is installed by default as of 11.0-RELEASE. Sponsored by: The FreeBSD Foundation Modified: stable/11/share/man/man7/tests.7 Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man7/tests.7 ============================================================================== --- stable/11/share/man/man7/tests.7 Thu Aug 24 16:35:42 2017 (r322846) +++ stable/11/share/man/man7/tests.7 Thu Aug 24 16:49:34 2017 (r322847) @@ -26,7 +26,7 @@ .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd March 22, 2017 +.Dd August 21, 2017 .Dt TESTS 7 .Os .Sh NAME @@ -59,10 +59,9 @@ hierarchy. This manual page describes how to run the test suite and how to configure some of its optional features. .Ss Installing the test suite -The test suite is not yet installed by default as part of -.Fx , -but this is bound to change during the development of -.Fx 11.0 . +The test suite is installed by default as of +.Fx +11.0-RELEASE. .Pp If the .Pa /usr/tests From owner-svn-src-stable@freebsd.org Thu Aug 24 17:25:18 2017 Return-Path: Delivered-To: svn-src-stable@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 5742FDE4664; Thu, 24 Aug 2017 17:25:18 +0000 (UTC) (envelope-from will@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 287CC84F85; Thu, 24 Aug 2017 17:25:18 +0000 (UTC) (envelope-from will@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7OHPHbx094944; Thu, 24 Aug 2017 17:25:17 GMT (envelope-from will@FreeBSD.org) Received: (from will@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7OHPHf1094942; Thu, 24 Aug 2017 17:25:17 GMT (envelope-from will@FreeBSD.org) Message-Id: <201708241725.v7OHPHf1094942@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: will set sender to will@FreeBSD.org using -f From: Will Andrews Date: Thu, 24 Aug 2017 17:25:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r322848 - in stable/10: etc sys/kern X-SVN-Group: stable-10 X-SVN-Commit-Author: will X-SVN-Commit-Paths: in stable/10: etc sys/kern X-SVN-Commit-Revision: 322848 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2017 17:25:18 -0000 Author: will Date: Thu Aug 24 17:25:16 2017 New Revision: 322848 URL: https://svnweb.freebsd.org/changeset/base/322848 Log: MFC r278479,278494,278525,278545,278592,279237,280410: This change merges devctl notification for userland coredumps. r278479 (rpaulo): Notify devd(8) when a process crashed. This change implements a notification (via devctl) to userland when the kernel produces coredumps after a process has crashed. devd can then run a specific command to produce a human readable crash report. The command is most usually a helper that runs gdb/lldb commands on the file/coredump pair. It's possible to use this functionality for implementing automatic generation of crash reports. devd(8) will be notified of the full path of the binary that crashed and the full path of the coredump file. r278494 (rpaulo): Sanitise the coredump file names sent to devd. While there, add a sysctl to turn this feature off as requested by kib@. r278525 (rpaulo): Remove a printf and an strlen() from the coredump code. r278545 (rpaulo): Restore the data array in coredump(), but use a different style to calculate the length. r278592 (rpaulo): Remove check against NULL after M_WAITOK. r279237 (kib): Keep a reference on the coredump vnode for vn_fullpath() call. Do it by moving vn_close() after the point where notification is sent. r280410 (rpaulo): Disable coredump_devctl because it could lead to leaking paths to jails. Approved by: re Modified: stable/10/etc/devd.conf stable/10/sys/kern/kern_sig.c Directory Properties: stable/10/ (props changed) Modified: stable/10/etc/devd.conf ============================================================================== --- stable/10/etc/devd.conf Thu Aug 24 16:49:34 2017 (r322847) +++ stable/10/etc/devd.conf Thu Aug 24 17:25:16 2017 (r322848) @@ -324,4 +324,16 @@ notify 100 { action "/usr/sbin/automount -c"; }; +# Handle userland coredumps. +# This commented out handler makes it possible to run an +# automated debugging session after the core dump is generated. +# Replace action with a proper coredump handler, but be aware that +# it will run with elevated privileges. +notify 10 { + match "system" "kernel"; + match "subsystem" "signal"; + match "type" "coredump"; + action "logger $comm $core"; +}; + */ Modified: stable/10/sys/kern/kern_sig.c ============================================================================== --- stable/10/sys/kern/kern_sig.c Thu Aug 24 16:49:34 2017 (r322847) +++ stable/10/sys/kern/kern_sig.c Thu Aug 24 17:25:16 2017 (r322848) @@ -44,10 +44,12 @@ __FBSDID("$FreeBSD$"); #include "opt_procdesc.h" #include +#include #include #include #include #include +#include #include #include #include @@ -183,6 +185,10 @@ static int set_core_nodump_flag = 0; SYSCTL_INT(_kern, OID_AUTO, nodump_coredump, CTLFLAG_RW, &set_core_nodump_flag, 0, "Enable setting the NODUMP flag on coredump files"); +static int coredump_devctl = 0; +SYSCTL_INT(_kern, OID_AUTO, coredump_devctl, CTLFLAG_RW, &coredump_devctl, + 0, "Generate a devctl notification when processes coredump"); + /* * Signal properties and actions. * The array below categorizes the signals and their default actions @@ -3317,6 +3323,24 @@ out: return (0); } +static int +coredump_sanitise_path(const char *path) +{ + size_t i; + + /* + * Only send a subset of ASCII to devd(8) because it + * might pass these strings to sh -c. + */ + for (i = 0; path[i]; i++) + if (!(isalpha(path[i]) || isdigit(path[i])) && + path[i] != '/' && path[i] != '.' && + path[i] != '-') + return (0); + + return (1); +} + /* * Dump a process' core. The main routine does some * policy checking, and creates the name of the coredump; @@ -3338,6 +3362,11 @@ coredump(struct thread *td) char *name; /* name of corefile */ off_t limit; int compress; + char *data = NULL; + char *fullpath, *freepath = NULL; + size_t len; + static const char comm_name[] = "comm="; + static const char core_name[] = "core="; #ifdef COMPRESS_USER_CORES compress = compress_user_cores; @@ -3380,7 +3409,7 @@ restart: vattr.va_nlink != 1) { VOP_UNLOCK(vp, 0); error = EFAULT; - goto close; + goto out; } VOP_UNLOCK(vp, 0); @@ -3425,14 +3454,39 @@ restart: lf.l_type = F_UNLCK; VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &lf, F_FLOCK); } -close: + + /* + * Notify the userland helper that a process triggered a core dump. + * This allows the helper to run an automated debugging session. + */ + if (error != 0 || coredump_devctl == 0) + goto out; + len = MAXPATHLEN * 2 + sizeof(comm_name) - 1 + + sizeof(' ') + sizeof(core_name) - 1; + data = malloc(len, M_TEMP, M_WAITOK); + if (vn_fullpath_global(td, p->p_textvp, &fullpath, &freepath) != 0) + goto out; + if (!coredump_sanitise_path(fullpath)) + goto out; + snprintf(data, len, "%s%s ", comm_name, fullpath); + free(freepath, M_TEMP); + freepath = NULL; + if (vn_fullpath_global(td, vp, &fullpath, &freepath) != 0) + goto out; + if (!coredump_sanitise_path(fullpath)) + goto out; + strlcat(data, core_name, len); + strlcat(data, fullpath, len); + devctl_notify("kernel", "signal", "coredump", data); +out: error1 = vn_close(vp, FWRITE, cred, td); if (error == 0) error = error1; -out: #ifdef AUDIT audit_proc_coredump(td, name, error); #endif + free(freepath, M_TEMP); + free(data, M_TEMP); free(name, M_TEMP); return (error); } From owner-svn-src-stable@freebsd.org Thu Aug 24 17:36:11 2017 Return-Path: Delivered-To: svn-src-stable@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 E6555DE4903; Thu, 24 Aug 2017 17:36:11 +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 85F6B66D; Thu, 24 Aug 2017 17:36:11 +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 v7OHaAjZ099036; Thu, 24 Aug 2017 17:36:10 GMT (envelope-from davidcs@FreeBSD.org) Received: (from davidcs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7OHaATM099032; Thu, 24 Aug 2017 17:36:10 GMT (envelope-from davidcs@FreeBSD.org) Message-Id: <201708241736.v7OHaATM099032@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: davidcs set sender to davidcs@FreeBSD.org using -f From: David C Somayajulu Date: Thu, 24 Aug 2017 17:36:10 +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: r322849 - in stable/11/sys: dev/qlnx/qlnxe modules/qlnx/qlnxe X-SVN-Group: stable-11 X-SVN-Commit-Author: davidcs X-SVN-Commit-Paths: in stable/11/sys: dev/qlnx/qlnxe modules/qlnx/qlnxe X-SVN-Commit-Revision: 322849 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2017 17:36:12 -0000 Author: davidcs Date: Thu Aug 24 17:36:10 2017 New Revision: 322849 URL: https://svnweb.freebsd.org/changeset/base/322849 Log: MFC r322331 Provide compile option to choose receive processing in either Ithread or Taskqueue Thread. Modified: stable/11/sys/dev/qlnx/qlnxe/qlnx_os.c stable/11/sys/dev/qlnx/qlnxe/qlnx_ver.h stable/11/sys/modules/qlnx/qlnxe/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/qlnx/qlnxe/qlnx_os.c ============================================================================== --- stable/11/sys/dev/qlnx/qlnxe/qlnx_os.c Thu Aug 24 17:25:16 2017 (r322848) +++ stable/11/sys/dev/qlnx/qlnxe/qlnx_os.c Thu Aug 24 17:36:10 2017 (r322849) @@ -397,10 +397,14 @@ qlnx_fp_taskqueue(void *context, int pending) struct ifnet *ifp; struct mbuf *mp; int ret; + struct thread *cthread; + +#ifdef QLNX_RCV_IN_TASKQ int lro_enable; int rx_int = 0, total_rx_count = 0; - struct thread *cthread; +#endif /* #ifdef QLNX_RCV_IN_TASKQ */ + fp = context; if (fp == NULL) @@ -419,55 +423,60 @@ qlnx_fp_taskqueue(void *context, int pending) ifp = ha->ifp; - lro_enable = ha->ifp->if_capenable & IFCAP_LRO; +#ifdef QLNX_RCV_IN_TASKQ + { + lro_enable = ifp->if_capenable & IFCAP_LRO; - rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold, lro_enable); + rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold, lro_enable); - if (rx_int) { - fp->rx_pkts += rx_int; - total_rx_count += rx_int; - } + if (rx_int) { + fp->rx_pkts += rx_int; + total_rx_count += rx_int; + } #ifdef QLNX_SOFT_LRO - { - struct lro_ctrl *lro; + { + struct lro_ctrl *lro; + + lro = &fp->rxq->lro; - lro = &fp->rxq->lro; + if (lro_enable && total_rx_count) { - if (lro_enable && total_rx_count) { - #if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) - if (ha->dbg_trace_lro_cnt) { - if (lro->lro_mbuf_count & ~1023) - fp->lro_cnt_1024++; - else if (lro->lro_mbuf_count & ~511) - fp->lro_cnt_512++; - else if (lro->lro_mbuf_count & ~255) - fp->lro_cnt_256++; - else if (lro->lro_mbuf_count & ~127) - fp->lro_cnt_128++; - else if (lro->lro_mbuf_count & ~63) - fp->lro_cnt_64++; - } - tcp_lro_flush_all(lro); + if (ha->dbg_trace_lro_cnt) { + if (lro->lro_mbuf_count & ~1023) + fp->lro_cnt_1024++; + else if (lro->lro_mbuf_count & ~511) + fp->lro_cnt_512++; + else if (lro->lro_mbuf_count & ~255) + fp->lro_cnt_256++; + else if (lro->lro_mbuf_count & ~127) + fp->lro_cnt_128++; + else if (lro->lro_mbuf_count & ~63) + fp->lro_cnt_64++; + } + tcp_lro_flush_all(lro); #else - struct lro_entry *queued; + struct lro_entry *queued; - while ((!SLIST_EMPTY(&lro->lro_active))) { - queued = SLIST_FIRST(&lro->lro_active); - SLIST_REMOVE_HEAD(&lro->lro_active, next); - tcp_lro_flush(lro, queued); - } + while ((!SLIST_EMPTY(&lro->lro_active))) { + queued = SLIST_FIRST(&lro->lro_active); + SLIST_REMOVE_HEAD(&lro->lro_active, next); + tcp_lro_flush(lro, queued); + } #endif /* #if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) */ + } } - } #endif /* #ifdef QLNX_SOFT_LRO */ - ecore_sb_update_sb_idx(fp->sb_info); - rmb(); + ecore_sb_update_sb_idx(fp->sb_info); + rmb(); + } +#endif /* #ifdef QLNX_RCV_IN_TASKQ */ + mtx_lock(&fp->tx_mtx); if (((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != @@ -477,10 +486,6 @@ qlnx_fp_taskqueue(void *context, int pending) goto qlnx_fp_taskqueue_exit; } -// for (tc = 0; tc < ha->num_tc; tc++) { -// (void)qlnx_tx_int(ha, fp, fp->txq[tc]); -// } - mp = drbr_peek(ifp, fp->tx_br); while (mp != NULL) { @@ -516,13 +521,11 @@ qlnx_fp_taskqueue(void *context, int pending) mp = drbr_peek(ifp, fp->tx_br); } -// for (tc = 0; tc < ha->num_tc; tc++) { -// (void)qlnx_tx_int(ha, fp, fp->txq[tc]); -// } - mtx_unlock(&fp->tx_mtx); qlnx_fp_taskqueue_exit: + +#ifdef QLNX_RCV_IN_TASKQ if (rx_int) { if (fp->fp_taskqueue != NULL) taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task); @@ -532,6 +535,7 @@ qlnx_fp_taskqueue_exit: } ecore_sb_ack(fp->sb_info, IGU_INT_ENABLE, 1); } +#endif /* #ifdef QLNX_RCV_IN_TASKQ */ QL_DPRINT2(ha, "exit ret = %d\n", ret); return; @@ -4262,6 +4266,7 @@ next_cqe: /* don't consume bd rx buffer */ return rx_pkt; } + /* * fast path interrupt */ @@ -4292,9 +4297,82 @@ qlnx_fp_isr(void *arg) if (fp == NULL) { ha->err_fp_null++; } else { + +#ifdef QLNX_RCV_IN_TASKQ ecore_sb_ack(fp->sb_info, IGU_INT_DISABLE, 0); if (fp->fp_taskqueue != NULL) taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task); +#else + int rx_int = 0, total_rx_count = 0; + int lro_enable, tc; + + lro_enable = ha->ifp->if_capenable & IFCAP_LRO; + + ecore_sb_ack(fp->sb_info, IGU_INT_DISABLE, 0); + + do { + for (tc = 0; tc < ha->num_tc; tc++) { + if (mtx_trylock(&fp->tx_mtx)) { + qlnx_tx_int(ha, fp, fp->txq[tc]); + mtx_unlock(&fp->tx_mtx); + } + } + + rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold, + lro_enable); + + if (rx_int) { + fp->rx_pkts += rx_int; + total_rx_count += rx_int; + } + + } while (rx_int); + + +#ifdef QLNX_SOFT_LRO + { + struct lro_ctrl *lro; + + lro = &fp->rxq->lro; + + if (lro_enable && total_rx_count) { + +#if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) + +#ifdef QLNX_TRACE_LRO_CNT + if (lro->lro_mbuf_count & ~1023) + fp->lro_cnt_1024++; + else if (lro->lro_mbuf_count & ~511) + fp->lro_cnt_512++; + else if (lro->lro_mbuf_count & ~255) + fp->lro_cnt_256++; + else if (lro->lro_mbuf_count & ~127) + fp->lro_cnt_128++; + else if (lro->lro_mbuf_count & ~63) + fp->lro_cnt_64++; +#endif /* #ifdef QLNX_TRACE_LRO_CNT */ + + tcp_lro_flush_all(lro); + +#else + struct lro_entry *queued; + + while ((!SLIST_EMPTY(&lro->lro_active))) { + queued = SLIST_FIRST(&lro->lro_active); + SLIST_REMOVE_HEAD(&lro->lro_active, \ + next); + tcp_lro_flush(lro, queued); + } +#endif /* #if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) */ + } + } +#endif /* #ifdef QLNX_SOFT_LRO */ + + ecore_sb_update_sb_idx(fp->sb_info); + rmb(); + ecore_sb_ack(fp->sb_info, IGU_INT_ENABLE, 1); + +#endif /* #ifdef QLNX_RCV_IN_TASKQ */ } return; Modified: stable/11/sys/dev/qlnx/qlnxe/qlnx_ver.h ============================================================================== --- stable/11/sys/dev/qlnx/qlnxe/qlnx_ver.h Thu Aug 24 17:25:16 2017 (r322848) +++ stable/11/sys/dev/qlnx/qlnxe/qlnx_ver.h Thu Aug 24 17:36:10 2017 (r322849) @@ -39,5 +39,5 @@ #define QLNX_VERSION_MAJOR 1 #define QLNX_VERSION_MINOR 4 -#define QLNX_VERSION_BUILD 5 +#define QLNX_VERSION_BUILD 6 Modified: stable/11/sys/modules/qlnx/qlnxe/Makefile ============================================================================== --- stable/11/sys/modules/qlnx/qlnxe/Makefile Thu Aug 24 17:25:16 2017 (r322848) +++ stable/11/sys/modules/qlnx/qlnxe/Makefile Thu Aug 24 17:36:10 2017 (r322849) @@ -63,6 +63,7 @@ CFLAGS += -DECORE_CONFIG_DIRECT_HWFN #CFLAGS += -DQLNX_SOFT_LRO #CFLAGS += -DQLNX_QSORT_LRO #CFLAGS += -DQLNX_MAX_COALESCE +#CFLAGS += -DQLNX_RCV_IN_TASKQ .include From owner-svn-src-stable@freebsd.org Thu Aug 24 18:01:19 2017 Return-Path: Delivered-To: svn-src-stable@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 4BB29DE5189; Thu, 24 Aug 2017 18:01:19 +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 25BB112F9; Thu, 24 Aug 2017 18:01:19 +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 v7OI1I9c007513; Thu, 24 Aug 2017 18:01:18 GMT (envelope-from davidcs@FreeBSD.org) Received: (from davidcs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7OI1IRY007510; Thu, 24 Aug 2017 18:01:18 GMT (envelope-from davidcs@FreeBSD.org) Message-Id: <201708241801.v7OI1IRY007510@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: davidcs set sender to davidcs@FreeBSD.org using -f From: David C Somayajulu Date: Thu, 24 Aug 2017 18:01:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r322850 - in stable/10/sys: dev/qlnx/qlnxe modules/qlnx/qlnxe X-SVN-Group: stable-10 X-SVN-Commit-Author: davidcs X-SVN-Commit-Paths: in stable/10/sys: dev/qlnx/qlnxe modules/qlnx/qlnxe X-SVN-Commit-Revision: 322850 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2017 18:01:19 -0000 Author: davidcs Date: Thu Aug 24 18:01:17 2017 New Revision: 322850 URL: https://svnweb.freebsd.org/changeset/base/322850 Log: MFC r322331 Provide compile option to choose receive processing in either Ithread or Taskqueue Thread. Approved by: re(marius) Modified: stable/10/sys/dev/qlnx/qlnxe/qlnx_os.c stable/10/sys/dev/qlnx/qlnxe/qlnx_ver.h stable/10/sys/modules/qlnx/qlnxe/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/qlnx/qlnxe/qlnx_os.c ============================================================================== --- stable/10/sys/dev/qlnx/qlnxe/qlnx_os.c Thu Aug 24 17:36:10 2017 (r322849) +++ stable/10/sys/dev/qlnx/qlnxe/qlnx_os.c Thu Aug 24 18:01:17 2017 (r322850) @@ -397,10 +397,14 @@ qlnx_fp_taskqueue(void *context, int pending) struct ifnet *ifp; struct mbuf *mp; int ret; + struct thread *cthread; + +#ifdef QLNX_RCV_IN_TASKQ int lro_enable; int rx_int = 0, total_rx_count = 0; - struct thread *cthread; +#endif /* #ifdef QLNX_RCV_IN_TASKQ */ + fp = context; if (fp == NULL) @@ -419,55 +423,60 @@ qlnx_fp_taskqueue(void *context, int pending) ifp = ha->ifp; - lro_enable = ha->ifp->if_capenable & IFCAP_LRO; +#ifdef QLNX_RCV_IN_TASKQ + { + lro_enable = ifp->if_capenable & IFCAP_LRO; - rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold, lro_enable); + rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold, lro_enable); - if (rx_int) { - fp->rx_pkts += rx_int; - total_rx_count += rx_int; - } + if (rx_int) { + fp->rx_pkts += rx_int; + total_rx_count += rx_int; + } #ifdef QLNX_SOFT_LRO - { - struct lro_ctrl *lro; + { + struct lro_ctrl *lro; + + lro = &fp->rxq->lro; - lro = &fp->rxq->lro; + if (lro_enable && total_rx_count) { - if (lro_enable && total_rx_count) { - #if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) - if (ha->dbg_trace_lro_cnt) { - if (lro->lro_mbuf_count & ~1023) - fp->lro_cnt_1024++; - else if (lro->lro_mbuf_count & ~511) - fp->lro_cnt_512++; - else if (lro->lro_mbuf_count & ~255) - fp->lro_cnt_256++; - else if (lro->lro_mbuf_count & ~127) - fp->lro_cnt_128++; - else if (lro->lro_mbuf_count & ~63) - fp->lro_cnt_64++; - } - tcp_lro_flush_all(lro); + if (ha->dbg_trace_lro_cnt) { + if (lro->lro_mbuf_count & ~1023) + fp->lro_cnt_1024++; + else if (lro->lro_mbuf_count & ~511) + fp->lro_cnt_512++; + else if (lro->lro_mbuf_count & ~255) + fp->lro_cnt_256++; + else if (lro->lro_mbuf_count & ~127) + fp->lro_cnt_128++; + else if (lro->lro_mbuf_count & ~63) + fp->lro_cnt_64++; + } + tcp_lro_flush_all(lro); #else - struct lro_entry *queued; + struct lro_entry *queued; - while ((!SLIST_EMPTY(&lro->lro_active))) { - queued = SLIST_FIRST(&lro->lro_active); - SLIST_REMOVE_HEAD(&lro->lro_active, next); - tcp_lro_flush(lro, queued); - } + while ((!SLIST_EMPTY(&lro->lro_active))) { + queued = SLIST_FIRST(&lro->lro_active); + SLIST_REMOVE_HEAD(&lro->lro_active, next); + tcp_lro_flush(lro, queued); + } #endif /* #if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) */ + } } - } #endif /* #ifdef QLNX_SOFT_LRO */ - ecore_sb_update_sb_idx(fp->sb_info); - rmb(); + ecore_sb_update_sb_idx(fp->sb_info); + rmb(); + } +#endif /* #ifdef QLNX_RCV_IN_TASKQ */ + mtx_lock(&fp->tx_mtx); if (((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != @@ -477,10 +486,6 @@ qlnx_fp_taskqueue(void *context, int pending) goto qlnx_fp_taskqueue_exit; } -// for (tc = 0; tc < ha->num_tc; tc++) { -// (void)qlnx_tx_int(ha, fp, fp->txq[tc]); -// } - mp = drbr_peek(ifp, fp->tx_br); while (mp != NULL) { @@ -516,13 +521,11 @@ qlnx_fp_taskqueue(void *context, int pending) mp = drbr_peek(ifp, fp->tx_br); } -// for (tc = 0; tc < ha->num_tc; tc++) { -// (void)qlnx_tx_int(ha, fp, fp->txq[tc]); -// } - mtx_unlock(&fp->tx_mtx); qlnx_fp_taskqueue_exit: + +#ifdef QLNX_RCV_IN_TASKQ if (rx_int) { if (fp->fp_taskqueue != NULL) taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task); @@ -532,6 +535,7 @@ qlnx_fp_taskqueue_exit: } ecore_sb_ack(fp->sb_info, IGU_INT_ENABLE, 1); } +#endif /* #ifdef QLNX_RCV_IN_TASKQ */ QL_DPRINT2(ha, "exit ret = %d\n", ret); return; @@ -4262,6 +4266,7 @@ next_cqe: /* don't consume bd rx buffer */ return rx_pkt; } + /* * fast path interrupt */ @@ -4292,9 +4297,82 @@ qlnx_fp_isr(void *arg) if (fp == NULL) { ha->err_fp_null++; } else { + +#ifdef QLNX_RCV_IN_TASKQ ecore_sb_ack(fp->sb_info, IGU_INT_DISABLE, 0); if (fp->fp_taskqueue != NULL) taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task); +#else + int rx_int = 0, total_rx_count = 0; + int lro_enable, tc; + + lro_enable = ha->ifp->if_capenable & IFCAP_LRO; + + ecore_sb_ack(fp->sb_info, IGU_INT_DISABLE, 0); + + do { + for (tc = 0; tc < ha->num_tc; tc++) { + if (mtx_trylock(&fp->tx_mtx)) { + qlnx_tx_int(ha, fp, fp->txq[tc]); + mtx_unlock(&fp->tx_mtx); + } + } + + rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold, + lro_enable); + + if (rx_int) { + fp->rx_pkts += rx_int; + total_rx_count += rx_int; + } + + } while (rx_int); + + +#ifdef QLNX_SOFT_LRO + { + struct lro_ctrl *lro; + + lro = &fp->rxq->lro; + + if (lro_enable && total_rx_count) { + +#if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) + +#ifdef QLNX_TRACE_LRO_CNT + if (lro->lro_mbuf_count & ~1023) + fp->lro_cnt_1024++; + else if (lro->lro_mbuf_count & ~511) + fp->lro_cnt_512++; + else if (lro->lro_mbuf_count & ~255) + fp->lro_cnt_256++; + else if (lro->lro_mbuf_count & ~127) + fp->lro_cnt_128++; + else if (lro->lro_mbuf_count & ~63) + fp->lro_cnt_64++; +#endif /* #ifdef QLNX_TRACE_LRO_CNT */ + + tcp_lro_flush_all(lro); + +#else + struct lro_entry *queued; + + while ((!SLIST_EMPTY(&lro->lro_active))) { + queued = SLIST_FIRST(&lro->lro_active); + SLIST_REMOVE_HEAD(&lro->lro_active, \ + next); + tcp_lro_flush(lro, queued); + } +#endif /* #if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) */ + } + } +#endif /* #ifdef QLNX_SOFT_LRO */ + + ecore_sb_update_sb_idx(fp->sb_info); + rmb(); + ecore_sb_ack(fp->sb_info, IGU_INT_ENABLE, 1); + +#endif /* #ifdef QLNX_RCV_IN_TASKQ */ } return; Modified: stable/10/sys/dev/qlnx/qlnxe/qlnx_ver.h ============================================================================== --- stable/10/sys/dev/qlnx/qlnxe/qlnx_ver.h Thu Aug 24 17:36:10 2017 (r322849) +++ stable/10/sys/dev/qlnx/qlnxe/qlnx_ver.h Thu Aug 24 18:01:17 2017 (r322850) @@ -39,5 +39,5 @@ #define QLNX_VERSION_MAJOR 1 #define QLNX_VERSION_MINOR 4 -#define QLNX_VERSION_BUILD 5 +#define QLNX_VERSION_BUILD 6 Modified: stable/10/sys/modules/qlnx/qlnxe/Makefile ============================================================================== --- stable/10/sys/modules/qlnx/qlnxe/Makefile Thu Aug 24 17:36:10 2017 (r322849) +++ stable/10/sys/modules/qlnx/qlnxe/Makefile Thu Aug 24 18:01:17 2017 (r322850) @@ -63,6 +63,7 @@ CFLAGS += -DECORE_CONFIG_DIRECT_HWFN #CFLAGS += -DQLNX_SOFT_LRO #CFLAGS += -DQLNX_QSORT_LRO #CFLAGS += -DQLNX_MAX_COALESCE +#CFLAGS += -DQLNX_RCV_IN_TASKQ .include From owner-svn-src-stable@freebsd.org Thu Aug 24 18:51:58 2017 Return-Path: Delivered-To: svn-src-stable@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 11DA0DE6082; Thu, 24 Aug 2017 18:51:58 +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 44B2C2D31; Thu, 24 Aug 2017 18:51:57 +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 v7OIpub6030308; Thu, 24 Aug 2017 18:51:56 GMT (envelope-from davidcs@FreeBSD.org) Received: (from davidcs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7OIpume030304; Thu, 24 Aug 2017 18:51:56 GMT (envelope-from davidcs@FreeBSD.org) Message-Id: <201708241851.v7OIpume030304@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: davidcs set sender to davidcs@FreeBSD.org using -f From: David C Somayajulu Date: Thu, 24 Aug 2017 18:51: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: r322851 - in stable/11/sys: dev/qlnx/qlnxe modules/qlnx/qlnxe X-SVN-Group: stable-11 X-SVN-Commit-Author: davidcs X-SVN-Commit-Paths: in stable/11/sys: dev/qlnx/qlnxe modules/qlnx/qlnxe X-SVN-Commit-Revision: 322851 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2017 18:51:58 -0000 Author: davidcs Date: Thu Aug 24 18:51:55 2017 New Revision: 322851 URL: https://svnweb.freebsd.org/changeset/base/322851 Log: MFC r322408 Performance enhancements to reduce CPU utililization for large number of TCP connections (order of tens of thousands), with predominantly Transmits. Submitted by: Vaishali.Kulkarni@cavium.com Modified: stable/11/sys/dev/qlnx/qlnxe/qlnx_def.h stable/11/sys/dev/qlnx/qlnxe/qlnx_os.c stable/11/sys/dev/qlnx/qlnxe/qlnx_ver.h stable/11/sys/modules/qlnx/qlnxe/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/qlnx/qlnxe/qlnx_def.h ============================================================================== --- stable/11/sys/dev/qlnx/qlnxe/qlnx_def.h Thu Aug 24 18:01:17 2017 (r322850) +++ stable/11/sys/dev/qlnx/qlnxe/qlnx_def.h Thu Aug 24 18:51:55 2017 (r322851) @@ -50,9 +50,10 @@ struct qlnx_ivec { typedef struct qlnx_ivec qlnx_ivec_t; -//#define QLNX_MAX_RSS 30 -#define QLNX_MAX_RSS 16 -#define QLNX_MAX_TC 1 +//#define QLNX_MAX_RSS 30 +#define QLNX_MAX_RSS 36 +#define QLNX_DEFAULT_RSS 16 +#define QLNX_MAX_TC 1 enum QLNX_STATE { QLNX_STATE_CLOSED, @@ -201,6 +202,17 @@ struct qlnx_fastpath { uint64_t tx_pkts_freed; uint64_t tx_pkts_transmitted; uint64_t tx_pkts_completed; + uint64_t tx_tso_pkts; + uint64_t tx_non_tso_pkts; + +#ifdef QLNX_TRACE_PERF_DATA + uint64_t tx_pkts_trans_ctx; + uint64_t tx_pkts_compl_ctx; + uint64_t tx_pkts_trans_fp; + uint64_t tx_pkts_compl_fp; + uint64_t tx_pkts_compl_intr; +#endif + uint64_t tx_lso_wnd_min_len; uint64_t tx_defrag; uint64_t tx_nsegs_gt_elem_left; @@ -209,6 +221,13 @@ struct qlnx_fastpath { uint32_t tx_tso_max_pkt_len; uint32_t tx_tso_min_pkt_len; uint64_t tx_pkts[QLNX_FP_MAX_SEGS]; + +#ifdef QLNX_TRACE_PERF_DATA + uint64_t tx_pkts_hist[QLNX_FP_MAX_SEGS]; + uint64_t tx_comInt[QLNX_FP_MAX_SEGS]; + uint64_t tx_pkts_q[QLNX_FP_MAX_SEGS]; +#endif + uint64_t err_tx_nsegs_gt_elem_left; uint64_t err_tx_dmamap_create; uint64_t err_tx_defrag_dmamap_load; @@ -301,8 +320,13 @@ typedef struct qlnx_link_output qlnx_link_output_t; #define QLNX_MFW_VERSION_LENGTH 32 #define QLNX_STORMFW_VERSION_LENGTH 32 -#define QLNX_TX_ELEM_RESERVE 2 +#define QLNX_TX_ELEM_RESERVE 2 +#define QLNX_TX_ELEM_THRESH 128 +#define QLNX_TX_ELEM_MAX_THRESH 512 +#define QLNX_TX_ELEM_MIN_THRESH 32 +#define QLNX_TX_COMPL_THRESH 32 + #define QLNX_TPA_MAX_AGG_BUFFERS (20) #define QLNX_MAX_NUM_MULTICAST_ADDRS ECORE_MAX_MC_ADDRS @@ -454,6 +478,7 @@ struct qlnx_host { qlnx_storm_stats_t storm_stats[QLNX_STORM_STATS_TOTAL]; uint32_t storm_stats_index; uint32_t storm_stats_enable; + uint32_t storm_stats_gather; uint32_t personality; }; @@ -470,8 +495,11 @@ typedef struct qlnx_host qlnx_host_t; #define QLNX_MAX_MTU 9000 #define QLNX_MAX_SEGMENTS_NON_TSO (ETH_TX_MAX_BDS_PER_NON_LSO_PACKET - 1) -#define QLNX_MAX_TSO_FRAME_SIZE ((64 * 1024 - 1) + 22) +//#define QLNX_MAX_TSO_FRAME_SIZE ((64 * 1024 - 1) + 22) +#define QLNX_MAX_TSO_FRAME_SIZE 65536 +#define QLNX_MAX_TX_MBUF_SIZE 65536 /* bytes - bd_len = 16bits */ + #define QL_MAC_CMP(mac1, mac2) \ ((((*(uint32_t *) mac1) == (*(uint32_t *) mac2) && \ (*(uint16_t *)(mac1 + 4)) == (*(uint16_t *)(mac2 + 4)))) ? 0 : 1) @@ -702,6 +730,18 @@ extern void qlnx_fill_link(struct ecore_hwfn *hwfn, #define CQE_HAS_VLAN(flags) \ ((flags) & (PARSING_AND_ERR_FLAGS_TAG8021QEXIST_MASK \ << PARSING_AND_ERR_FLAGS_TAG8021QEXIST_SHIFT)) + +#if defined(__i386__) || defined(__amd64__) + +static __inline +void prefetch(void *x) +{ + __asm volatile("prefetcht0 %0" :: "m" (*(unsigned long *)x)); +} + +#else +#define prefetch(x) +#endif #endif /* #ifndef _QLNX_DEF_H_ */ Modified: stable/11/sys/dev/qlnx/qlnxe/qlnx_os.c ============================================================================== --- stable/11/sys/dev/qlnx/qlnxe/qlnx_os.c Thu Aug 24 18:01:17 2017 (r322850) +++ stable/11/sys/dev/qlnx/qlnxe/qlnx_os.c Thu Aug 24 18:51:55 2017 (r322851) @@ -94,6 +94,8 @@ static int qlnx_get_ifq_snd_maxlen(qlnx_host_t *ha); static uint32_t qlnx_get_optics(qlnx_host_t *ha, struct qlnx_link_output *if_link); static int qlnx_transmit(struct ifnet *ifp, struct mbuf *mp); +static int qlnx_transmit_locked(struct ifnet *ifp, struct qlnx_fastpath *fp, + struct mbuf *mp); static void qlnx_qflush(struct ifnet *ifp); static int qlnx_alloc_parent_dma_tag(qlnx_host_t *ha); @@ -133,6 +135,8 @@ static void qlnx_timer(void *arg); static int qlnx_alloc_tx_br(qlnx_host_t *ha, struct qlnx_fastpath *fp); static void qlnx_free_tx_br(qlnx_host_t *ha, struct qlnx_fastpath *fp); static void qlnx_trigger_dump(qlnx_host_t *ha); +static uint16_t qlnx_num_tx_compl(qlnx_host_t *ha, struct qlnx_fastpath *fp, + struct qlnx_tx_queue *txq); static void qlnx_tx_int(qlnx_host_t *ha, struct qlnx_fastpath *fp, struct qlnx_tx_queue *txq); static int qlnx_rx_int(qlnx_host_t *ha, struct qlnx_fastpath *fp, int budget, @@ -215,6 +219,12 @@ char qlnx_name_str[NAME_SIZE]; #define QLOGIC_PCI_DEVICE_ID_8070 0x8070 #endif +SYSCTL_NODE(_hw, OID_AUTO, qlnxe, CTLFLAG_RD, 0, "qlnxe driver parameters"); +/* Number of Queues: 0 (Auto) or 1 to 32 (fixed queue number) */ +static int qlnxe_queue_count = QLNX_DEFAULT_RSS; +SYSCTL_INT(_hw_qlnxe, OID_AUTO, queue_count, CTLFLAG_RDTUN, + &qlnxe_queue_count, 0, "Multi-Queue queue count"); + static int qlnx_valid_device(device_t dev) { @@ -302,7 +312,26 @@ qlnx_pci_probe(device_t dev) return (BUS_PROBE_DEFAULT); } +static uint16_t +qlnx_num_tx_compl(qlnx_host_t *ha, struct qlnx_fastpath *fp, + struct qlnx_tx_queue *txq) +{ + u16 hw_bd_cons; + u16 ecore_cons_idx; + uint16_t diff; + hw_bd_cons = le16toh(*txq->hw_cons_ptr); + + ecore_cons_idx = ecore_chain_get_cons_idx(&txq->tx_pbl); + if (hw_bd_cons < ecore_cons_idx) { + diff = (1 << 16) - (ecore_cons_idx - hw_bd_cons); + } else { + diff = hw_bd_cons - ecore_cons_idx; + } + return diff; +} + + static void qlnx_sp_intr(void *arg) { @@ -395,14 +424,11 @@ qlnx_fp_taskqueue(void *context, int pending) struct qlnx_fastpath *fp; qlnx_host_t *ha; struct ifnet *ifp; - struct mbuf *mp; - int ret; - struct thread *cthread; #ifdef QLNX_RCV_IN_TASKQ int lro_enable; int rx_int = 0, total_rx_count = 0; - + struct thread *cthread; #endif /* #ifdef QLNX_RCV_IN_TASKQ */ fp = context; @@ -410,6 +436,12 @@ qlnx_fp_taskqueue(void *context, int pending) if (fp == NULL) return; + ha = (qlnx_host_t *)fp->edev; + + ifp = ha->ifp; + +#ifdef QLNX_RCV_IN_TASKQ + cthread = curthread; thread_lock(cthread); @@ -419,112 +451,81 @@ qlnx_fp_taskqueue(void *context, int pending) thread_unlock(cthread); - ha = (qlnx_host_t *)fp->edev; + lro_enable = ifp->if_capenable & IFCAP_LRO; - ifp = ha->ifp; + rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold, lro_enable); -#ifdef QLNX_RCV_IN_TASKQ - { - lro_enable = ifp->if_capenable & IFCAP_LRO; + if (rx_int) { + fp->rx_pkts += rx_int; + total_rx_count += rx_int; + } - rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold, lro_enable); - - if (rx_int) { - fp->rx_pkts += rx_int; - total_rx_count += rx_int; - } - #ifdef QLNX_SOFT_LRO - { - struct lro_ctrl *lro; - - lro = &fp->rxq->lro; + { + struct lro_ctrl *lro; - if (lro_enable && total_rx_count) { + lro = &fp->rxq->lro; + if (lro_enable && total_rx_count) { + #if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) - if (ha->dbg_trace_lro_cnt) { - if (lro->lro_mbuf_count & ~1023) - fp->lro_cnt_1024++; - else if (lro->lro_mbuf_count & ~511) - fp->lro_cnt_512++; - else if (lro->lro_mbuf_count & ~255) - fp->lro_cnt_256++; - else if (lro->lro_mbuf_count & ~127) - fp->lro_cnt_128++; - else if (lro->lro_mbuf_count & ~63) - fp->lro_cnt_64++; - } - tcp_lro_flush_all(lro); + if (ha->dbg_trace_lro_cnt) { + if (lro->lro_mbuf_count & ~1023) + fp->lro_cnt_1024++; + else if (lro->lro_mbuf_count & ~511) + fp->lro_cnt_512++; + else if (lro->lro_mbuf_count & ~255) + fp->lro_cnt_256++; + else if (lro->lro_mbuf_count & ~127) + fp->lro_cnt_128++; + else if (lro->lro_mbuf_count & ~63) + fp->lro_cnt_64++; + } + tcp_lro_flush_all(lro); #else - struct lro_entry *queued; + struct lro_entry *queued; - while ((!SLIST_EMPTY(&lro->lro_active))) { - queued = SLIST_FIRST(&lro->lro_active); - SLIST_REMOVE_HEAD(&lro->lro_active, next); - tcp_lro_flush(lro, queued); - } -#endif /* #if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) */ + while ((!SLIST_EMPTY(&lro->lro_active))) { + queued = SLIST_FIRST(&lro->lro_active); + SLIST_REMOVE_HEAD(&lro->lro_active, next); + tcp_lro_flush(lro, queued); } +#endif /* #if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) */ } + } #endif /* #ifdef QLNX_SOFT_LRO */ - ecore_sb_update_sb_idx(fp->sb_info); - rmb(); - } + ecore_sb_update_sb_idx(fp->sb_info); + rmb(); #endif /* #ifdef QLNX_RCV_IN_TASKQ */ - mtx_lock(&fp->tx_mtx); + if(ifp->if_drv_flags & IFF_DRV_RUNNING) { - if (((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != - IFF_DRV_RUNNING) || (!ha->link_up)) { + if (!drbr_empty(ifp, fp->tx_br)) { - mtx_unlock(&fp->tx_mtx); - goto qlnx_fp_taskqueue_exit; - } + if(mtx_trylock(&fp->tx_mtx)) { - mp = drbr_peek(ifp, fp->tx_br); +#ifdef QLNX_TRACE_PERF_DATA + tx_pkts = fp->tx_pkts_transmitted; + tx_compl = fp->tx_pkts_completed; +#endif - while (mp != NULL) { + qlnx_transmit_locked(ifp, fp, NULL); - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { - ret = qlnx_send(ha, fp, &mp); - } else { - ret = -1; - } - - if (ret) { - - if (mp != NULL) { - drbr_putback(ifp, fp->tx_br, mp); - } else { - fp->tx_pkts_processed++; - drbr_advance(ifp, fp->tx_br); +#ifdef QLNX_TRACE_PERF_DATA + fp->tx_pkts_trans_fp += + (fp->tx_pkts_transmitted - tx_pkts); + fp->tx_pkts_compl_fp += + (fp->tx_pkts_completed - tx_compl); +#endif + mtx_unlock(&fp->tx_mtx); } - - mtx_unlock(&fp->tx_mtx); - - goto qlnx_fp_taskqueue_exit; - - } else { - drbr_advance(ifp, fp->tx_br); - fp->tx_pkts_transmitted++; - fp->tx_pkts_processed++; } - - if (fp->tx_ring_full) - break; - - mp = drbr_peek(ifp, fp->tx_br); } - mtx_unlock(&fp->tx_mtx); - -qlnx_fp_taskqueue_exit: - #ifdef QLNX_RCV_IN_TASKQ if (rx_int) { if (fp->fp_taskqueue != NULL) @@ -537,7 +538,7 @@ qlnx_fp_taskqueue_exit: } #endif /* #ifdef QLNX_RCV_IN_TASKQ */ - QL_DPRINT2(ha, "exit ret = %d\n", ret); + QL_DPRINT2(ha, "exit \n"); return; } @@ -611,6 +612,17 @@ qlnx_drain_fp_taskqueues(qlnx_host_t *ha) return; } +static void +qlnx_get_params(qlnx_host_t *ha) +{ + if ((qlnxe_queue_count < 0) || (qlnxe_queue_count > QLNX_MAX_RSS)) { + device_printf(ha->pci_dev, "invalid queue_count value (%d)\n", + qlnxe_queue_count); + qlnxe_queue_count = 0; + } + return; +} + /* * Name: qlnx_pci_attach * Function: attaches the device to the operating system @@ -706,10 +718,21 @@ qlnx_pci_attach(device_t dev) if (qlnx_init_hw(ha) != 0) goto qlnx_pci_attach_err; + qlnx_get_params(ha); + + if((pci_get_device(dev) == QLOGIC_PCI_DEVICE_ID_1644) && + (qlnxe_queue_count == QLNX_DEFAULT_RSS)) { + qlnxe_queue_count = QLNX_MAX_RSS; + } + /* * Allocate MSI-x vectors */ - ha->num_rss = QLNX_MAX_RSS; + if(qlnxe_queue_count == 0) + ha->num_rss = QLNX_DEFAULT_RSS; + else + ha->num_rss = qlnxe_queue_count; + ha->num_tc = QLNX_MAX_TC; ha->msix_count = pci_msix_count(dev); @@ -1236,6 +1259,44 @@ qlnx_add_fp_stats_sysctls(qlnx_host_t *ha) CTLFLAG_RD, &ha->fp_array[i].tx_pkts_completed, "No. of transmit completions"); + SYSCTL_ADD_QUAD(ctx, node_children, + OID_AUTO, "tx_non_tso_pkts", + CTLFLAG_RD, &ha->fp_array[i].tx_non_tso_pkts, + "No. of non LSO transmited packets"); + +#ifdef QLNX_TRACE_PERF_DATA + + SYSCTL_ADD_QUAD(ctx, node_children, + OID_AUTO, "tx_pkts_trans_ctx", + CTLFLAG_RD, &ha->fp_array[i].tx_pkts_trans_ctx, + "No. of transmitted packets in transmit context"); + + SYSCTL_ADD_QUAD(ctx, node_children, + OID_AUTO, "tx_pkts_compl_ctx", + CTLFLAG_RD, &ha->fp_array[i].tx_pkts_compl_ctx, + "No. of transmit completions in transmit context"); + + SYSCTL_ADD_QUAD(ctx, node_children, + OID_AUTO, "tx_pkts_trans_fp", + CTLFLAG_RD, &ha->fp_array[i].tx_pkts_trans_fp, + "No. of transmitted packets in taskqueue"); + + SYSCTL_ADD_QUAD(ctx, node_children, + OID_AUTO, "tx_pkts_compl_fp", + CTLFLAG_RD, &ha->fp_array[i].tx_pkts_compl_fp, + "No. of transmit completions in taskqueue"); + + SYSCTL_ADD_QUAD(ctx, node_children, + OID_AUTO, "tx_pkts_compl_intr", + CTLFLAG_RD, &ha->fp_array[i].tx_pkts_compl_intr, + "No. of transmit completions in interrupt ctx"); +#endif + + SYSCTL_ADD_QUAD(ctx, node_children, + OID_AUTO, "tx_tso_pkts", + CTLFLAG_RD, &ha->fp_array[i].tx_tso_pkts, + "No. of LSO transmited packets"); + SYSCTL_ADD_QUAD(ctx, node_children, OID_AUTO, "tx_lso_wnd_min_len", CTLFLAG_RD, &ha->fp_array[i].tx_lso_wnd_min_len, @@ -1284,6 +1345,39 @@ qlnx_add_fp_stats_sysctls(qlnx_host_t *ha) &ha->fp_array[i].tx_pkts[j], name_str); } +#ifdef QLNX_TRACE_PERF_DATA + for (j = 0; j < 18; j++) { + + bzero(name_str, (sizeof(uint8_t) * sizeof(name_str))); + snprintf(name_str, sizeof(name_str), + "tx_pkts_hist_%02d", (j+1)); + + SYSCTL_ADD_QUAD(ctx, node_children, + OID_AUTO, name_str, CTLFLAG_RD, + &ha->fp_array[i].tx_pkts_hist[j], name_str); + } + for (j = 0; j < 5; j++) { + + bzero(name_str, (sizeof(uint8_t) * sizeof(name_str))); + snprintf(name_str, sizeof(name_str), + "tx_comInt_%02d", (j+1)); + + SYSCTL_ADD_QUAD(ctx, node_children, + OID_AUTO, name_str, CTLFLAG_RD, + &ha->fp_array[i].tx_comInt[j], name_str); + } + for (j = 0; j < 18; j++) { + + bzero(name_str, (sizeof(uint8_t) * sizeof(name_str))); + snprintf(name_str, sizeof(name_str), + "tx_pkts_q_%02d", (j+1)); + + SYSCTL_ADD_QUAD(ctx, node_children, + OID_AUTO, name_str, CTLFLAG_RD, + &ha->fp_array[i].tx_pkts_q[j], name_str); + } +#endif + SYSCTL_ADD_QUAD(ctx, node_children, OID_AUTO, "err_tx_nsegs_gt_elem_left", CTLFLAG_RD, &ha->fp_array[i].err_tx_nsegs_gt_elem_left, @@ -1979,6 +2073,12 @@ qlnx_init_ifnet(device_t dev, qlnx_host_t *ha) ifp->if_capabilities |= IFCAP_TSO6; ifp->if_capabilities |= IFCAP_LRO; + ifp->if_hw_tsomax = QLNX_MAX_TSO_FRAME_SIZE - + (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); + ifp->if_hw_tsomaxsegcount = QLNX_MAX_SEGMENTS - 1 /* hdr */; + ifp->if_hw_tsomaxsegsize = QLNX_MAX_TX_MBUF_SIZE; + + ifp->if_capenable = ifp->if_capabilities; ifp->if_hwassist = CSUM_IP; @@ -2543,6 +2643,7 @@ qlnx_tx_int(qlnx_host_t *ha, struct qlnx_fastpath *fp, u16 hw_bd_cons; u16 ecore_cons_idx; uint16_t diff; + uint16_t idx, idx2; hw_bd_cons = le16toh(*txq->hw_cons_ptr); @@ -2580,6 +2681,11 @@ qlnx_tx_int(qlnx_host_t *ha, struct qlnx_fastpath *fp, qlnx_trigger_dump(ha); } + idx = (txq->sw_tx_cons + 1) & (TX_RING_SIZE - 1); + idx2 = (txq->sw_tx_cons + 2) & (TX_RING_SIZE - 1); + prefetch(txq->sw_tx_ring[idx].mp); + prefetch(txq->sw_tx_ring[idx2].mp); + qlnx_free_tx_pkt(ha, fp, txq); txq->sw_tx_cons = (txq->sw_tx_cons + 1) & (TX_RING_SIZE - 1); @@ -2588,12 +2694,71 @@ qlnx_tx_int(qlnx_host_t *ha, struct qlnx_fastpath *fp, } static int +qlnx_transmit_locked(struct ifnet *ifp,struct qlnx_fastpath *fp, struct mbuf *mp) +{ + int ret = 0; + struct qlnx_tx_queue *txq; + qlnx_host_t * ha; + uint16_t elem_left; + + txq = fp->txq[0]; + ha = (qlnx_host_t *)fp->edev; + + + if ((!(ifp->if_drv_flags & IFF_DRV_RUNNING)) || (!ha->link_up)) { + if(mp != NULL) + ret = drbr_enqueue(ifp, fp->tx_br, mp); + return (ret); + } + + if(mp != NULL) + ret = drbr_enqueue(ifp, fp->tx_br, mp); + + mp = drbr_peek(ifp, fp->tx_br); + + while (mp != NULL) { + + if (qlnx_send(ha, fp, &mp)) { + + if (mp != NULL) { + drbr_putback(ifp, fp->tx_br, mp); + } else { + fp->tx_pkts_processed++; + drbr_advance(ifp, fp->tx_br); + } + goto qlnx_transmit_locked_exit; + + } else { + drbr_advance(ifp, fp->tx_br); + fp->tx_pkts_transmitted++; + fp->tx_pkts_processed++; + } + + mp = drbr_peek(ifp, fp->tx_br); + } + +qlnx_transmit_locked_exit: + if((qlnx_num_tx_compl(ha,fp, fp->txq[0]) > QLNX_TX_COMPL_THRESH) || + ((int)(elem_left = ecore_chain_get_elem_left(&txq->tx_pbl)) + < QLNX_TX_ELEM_MAX_THRESH)) + (void)qlnx_tx_int(ha, fp, fp->txq[0]); + + QL_DPRINT2(ha, "%s: exit ret = %d\n", __func__, ret); + return ret; +} + + +static int qlnx_transmit(struct ifnet *ifp, struct mbuf *mp) { qlnx_host_t *ha = (qlnx_host_t *)ifp->if_softc; struct qlnx_fastpath *fp; int rss_id = 0, ret = 0; +#ifdef QLNX_TRACEPERF_DATA + uint64_t tx_pkts = 0, tx_compl = 0; +#endif + QL_DPRINT2(ha, "enter\n"); #if __FreeBSD_version >= 1100000 @@ -2611,15 +2776,27 @@ qlnx_transmit(struct ifnet *ifp, struct mbuf *mp) goto qlnx_transmit_exit; } - if (mp != NULL) { - ret = drbr_enqueue(ifp, fp->tx_br, mp); - } + if (mtx_trylock(&fp->tx_mtx)) { - if (fp->fp_taskqueue != NULL) - taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task); +#ifdef QLNX_TRACEPERF_DATA + tx_pkts = fp->tx_pkts_transmitted; + tx_compl = fp->tx_pkts_completed; +#endif - ret = 0; + ret = qlnx_transmit_locked(ifp, fp, mp); +#ifdef QLNX_TRACEPERF_DATA + fp->tx_pkts_trans_ctx += (fp->tx_pkts_transmitted - tx_pkts); + fp->tx_pkts_compl_ctx += (fp->tx_pkts_completed - tx_compl); +#endif + mtx_unlock(&fp->tx_mtx); + } else { + if (mp != NULL && (fp->fp_taskqueue != NULL)) { + ret = drbr_enqueue(ifp, fp->tx_br, mp); + taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task); + } + } + qlnx_transmit_exit: QL_DPRINT2(ha, "exit ret = %d\n", ret); @@ -2799,6 +2976,10 @@ qlnx_send(qlnx_host_t *ha, struct qlnx_fastpath *fp, s uint32_t nbds_in_hdr = 0; uint32_t offset = 0; +#ifdef QLNX_TRACE_PERF_DATA + uint16_t bd_used; +#endif + QL_DPRINT8(ha, "enter\n"); if (!ha->link_up) @@ -2811,15 +2992,15 @@ qlnx_send(qlnx_host_t *ha, struct qlnx_fastpath *fp, s txq = fp->txq[0]; - if (fp->tx_ring_full) { - elem_left = ecore_chain_get_elem_left(&txq->tx_pbl); + if ((int)(elem_left = ecore_chain_get_elem_left(&txq->tx_pbl)) < + QLNX_TX_ELEM_MIN_THRESH) { - if (elem_left < (TX_RING_SIZE >> 4)) - return (-1); - else - fp->tx_ring_full = 0; - } + fp->tx_nsegs_gt_elem_left++; + fp->err_tx_nsegs_gt_elem_left++; + return (ENOBUFS); + } + idx = txq->sw_tx_prod; map = txq->sw_tx_ring[idx].map; @@ -2829,14 +3010,18 @@ qlnx_send(qlnx_host_t *ha, struct qlnx_fastpath *fp, s BUS_DMA_NOWAIT); if (ha->dbg_trace_tso_pkt_len) { - if (!fp->tx_tso_min_pkt_len) { - fp->tx_tso_min_pkt_len = m_head->m_pkthdr.len; - fp->tx_tso_min_pkt_len = m_head->m_pkthdr.len; - } else { - if (fp->tx_tso_min_pkt_len > m_head->m_pkthdr.len) + if (m_head->m_pkthdr.csum_flags & CSUM_TSO) { + if (!fp->tx_tso_min_pkt_len) { fp->tx_tso_min_pkt_len = m_head->m_pkthdr.len; - if (fp->tx_tso_max_pkt_len < m_head->m_pkthdr.len) - fp->tx_tso_max_pkt_len = m_head->m_pkthdr.len; + fp->tx_tso_min_pkt_len = m_head->m_pkthdr.len; + } else { + if (fp->tx_tso_min_pkt_len > m_head->m_pkthdr.len) + fp->tx_tso_min_pkt_len = + m_head->m_pkthdr.len; + if (fp->tx_tso_max_pkt_len < m_head->m_pkthdr.len) + fp->tx_tso_max_pkt_len = + m_head->m_pkthdr.len; + } } } @@ -2923,6 +3108,105 @@ qlnx_send(qlnx_host_t *ha, struct qlnx_fastpath *fp, s fp->tx_pkts[(QLNX_FP_MAX_SEGS - 1)]++; } +#ifdef QLNX_TRACE_PERF_DATA + if (m_head->m_pkthdr.csum_flags & CSUM_TSO) { + if(m_head->m_pkthdr.len <= 2048) + fp->tx_pkts_hist[0]++; + else if((m_head->m_pkthdr.len > 2048) && + (m_head->m_pkthdr.len <= 4096)) + fp->tx_pkts_hist[1]++; + else if((m_head->m_pkthdr.len > 4096) && + (m_head->m_pkthdr.len <= 8192)) + fp->tx_pkts_hist[2]++; + else if((m_head->m_pkthdr.len > 8192) && + (m_head->m_pkthdr.len <= 12288 )) + fp->tx_pkts_hist[3]++; + else if((m_head->m_pkthdr.len > 11288) && + (m_head->m_pkthdr.len <= 16394)) + fp->tx_pkts_hist[4]++; + else if((m_head->m_pkthdr.len > 16384) && + (m_head->m_pkthdr.len <= 20480)) + fp->tx_pkts_hist[5]++; + else if((m_head->m_pkthdr.len > 20480) && + (m_head->m_pkthdr.len <= 24576)) + fp->tx_pkts_hist[6]++; + else if((m_head->m_pkthdr.len > 24576) && + (m_head->m_pkthdr.len <= 28672)) + fp->tx_pkts_hist[7]++; + else if((m_head->m_pkthdr.len > 28762) && + (m_head->m_pkthdr.len <= 32768)) + fp->tx_pkts_hist[8]++; + else if((m_head->m_pkthdr.len > 32768) && + (m_head->m_pkthdr.len <= 36864)) + fp->tx_pkts_hist[9]++; + else if((m_head->m_pkthdr.len > 36864) && + (m_head->m_pkthdr.len <= 40960)) + fp->tx_pkts_hist[10]++; + else if((m_head->m_pkthdr.len > 40960) && + (m_head->m_pkthdr.len <= 45056)) + fp->tx_pkts_hist[11]++; + else if((m_head->m_pkthdr.len > 45056) && + (m_head->m_pkthdr.len <= 49152)) + fp->tx_pkts_hist[12]++; + else if((m_head->m_pkthdr.len > 49512) && + m_head->m_pkthdr.len <= 53248)) + fp->tx_pkts_hist[13]++; + else if((m_head->m_pkthdr.len > 53248) && + (m_head->m_pkthdr.len <= 57344)) + fp->tx_pkts_hist[14]++; + else if((m_head->m_pkthdr.len > 53248) && + (m_head->m_pkthdr.len <= 57344)) + fp->tx_pkts_hist[15]++; + else if((m_head->m_pkthdr.len > 57344) && + (m_head->m_pkthdr.len <= 61440)) + fp->tx_pkts_hist[16]++; + else + fp->tx_pkts_hist[17]++; + } + + if (m_head->m_pkthdr.csum_flags & CSUM_TSO) { + + elem_left = ecore_chain_get_elem_left(&txq->tx_pbl); + bd_used = TX_RING_SIZE - elem_left; + + if(bd_used <= 100) + fp->tx_pkts_q[0]++; + else if((bd_used > 100) && (bd_used <= 500)) + fp->tx_pkts_q[1]++; + else if((bd_used > 500) && (bd_used <= 1000)) + fp->tx_pkts_q[2]++; + else if((bd_used > 1000) && (bd_used <= 2000)) + fp->tx_pkts_q[3]++; + else if((bd_used > 3000) && (bd_used <= 4000)) + fp->tx_pkts_q[4]++; + else if((bd_used > 4000) && (bd_used <= 5000)) + fp->tx_pkts_q[5]++; + else if((bd_used > 6000) && (bd_used <= 7000)) + fp->tx_pkts_q[6]++; + else if((bd_used > 7000) && (bd_used <= 8000)) + fp->tx_pkts_q[7]++; + else if((bd_used > 8000) && (bd_used <= 9000)) + fp->tx_pkts_q[8]++; + else if((bd_used > 9000) && (bd_used <= 10000)) + fp->tx_pkts_q[9]++; + else if((bd_used > 10000) && (bd_used <= 11000)) + fp->tx_pkts_q[10]++; + else if((bd_used > 11000) && (bd_used <= 12000)) + fp->tx_pkts_q[11]++; + else if((bd_used > 12000) && (bd_used <= 13000)) + fp->tx_pkts_q[12]++; + else if((bd_used > 13000) && (bd_used <= 14000)) + fp->tx_pkts_q[13]++; + else if((bd_used > 14000) && (bd_used <= 15000)) + fp->tx_pkts_q[14]++; + else if((bd_used > 15000) && (bd_used <= 16000)) + fp->tx_pkts_q[15]++; + else + fp->tx_pkts_q[16]++; + } + +#endif /* end of QLNX_TRACE_PERF_DATA */ + if ((nsegs + QLNX_TX_ELEM_RESERVE) > (int)(elem_left = ecore_chain_get_elem_left(&txq->tx_pbl))) { @@ -2943,7 +3227,8 @@ qlnx_send(qlnx_host_t *ha, struct qlnx_fastpath *fp, s fp->err_tx_nsegs_gt_elem_left++; fp->tx_ring_full = 1; - ha->storm_stats_enable = 1; + if (ha->storm_stats_enable) + ha->storm_stats_gather = 1; return (ENOBUFS); } } @@ -3131,6 +3416,7 @@ qlnx_send(qlnx_host_t *ha, struct qlnx_fastpath *fp, s third_bd->data.bitfields |= (nbds_in_hdr<tx_tso_pkts++; } else { segs++; for (seg_idx = 1; seg_idx < nsegs; seg_idx++) { @@ -3147,6 +3433,7 @@ qlnx_send(qlnx_host_t *ha, struct qlnx_fastpath *fp, s << ETH_TX_DATA_1ST_BD_PKT_LEN_SHIFT; first_bd->data.bitfields = htole16(first_bd->data.bitfields); + fp->tx_non_tso_pkts++; } @@ -4303,8 +4590,10 @@ qlnx_fp_isr(void *arg) if (fp->fp_taskqueue != NULL) taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task); #else - int rx_int = 0, total_rx_count = 0; - int lro_enable, tc; + int rx_int = 0, total_rx_count = 0; + int lro_enable, tc; + struct qlnx_tx_queue *txq; + uint16_t elem_left; lro_enable = ha->ifp->if_capenable & IFCAP_LRO; @@ -4312,10 +4601,36 @@ qlnx_fp_isr(void *arg) do { for (tc = 0; tc < ha->num_tc; tc++) { - if (mtx_trylock(&fp->tx_mtx)) { - qlnx_tx_int(ha, fp, fp->txq[tc]); - mtx_unlock(&fp->tx_mtx); - } + + txq = fp->txq[tc]; + + if((int)(elem_left = + ecore_chain_get_elem_left(&txq->tx_pbl)) < + QLNX_TX_ELEM_THRESH) { + + if (mtx_trylock(&fp->tx_mtx)) { +#ifdef QLNX_TRACE_PERF_DATA + tx_compl = fp->tx_pkts_completed; +#endif + + qlnx_tx_int(ha, fp, fp->txq[tc]); +#ifdef QLNX_TRACE_PERF_DATA + fp->tx_pkts_compl_intr += + (fp->tx_pkts_completed - tx_compl); + if ((fp->tx_pkts_completed - tx_compl) <= 32) + fp->tx_comInt[0]++; + else if (((fp->tx_pkts_completed - tx_compl) > 32) && + ((fp->tx_pkts_completed - tx_compl) <= 64)) + fp->tx_comInt[1]++; + else if(((fp->tx_pkts_completed - tx_compl) > 64) && + ((fp->tx_pkts_completed - tx_compl) <= 128)) + fp->tx_comInt[2]++; + else if(((fp->tx_pkts_completed - tx_compl) > 128)) + fp->tx_comInt[3]++; +#endif + mtx_unlock(&fp->tx_mtx); + } + } } rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold, @@ -4328,7 +4643,6 @@ qlnx_fp_isr(void *arg) } while (rx_int); - #ifdef QLNX_SOFT_LRO { struct lro_ctrl *lro; @@ -4608,8 +4922,8 @@ qlnx_alloc_tx_dma_tag(qlnx_host_t *ha) NULL, NULL, /* filter, filterarg */ QLNX_MAX_TSO_FRAME_SIZE, /* maxsize */ QLNX_MAX_SEGMENTS, /* nsegments */ - (PAGE_SIZE * 4), /* maxsegsize */ - BUS_DMA_ALLOCNOW, /* flags */ + QLNX_MAX_TX_MBUF_SIZE, /* maxsegsize */ + 0, /* flags */ NULL, /* lockfunc */ NULL, /* lockfuncarg */ &ha->tx_tag)) { @@ -4642,7 +4956,7 @@ qlnx_alloc_rx_dma_tag(qlnx_host_t *ha) MJUM9BYTES, /* maxsize */ 1, /* nsegments */ MJUM9BYTES, /* maxsegsize */ - BUS_DMA_ALLOCNOW, /* flags */ + 0, /* flags */ NULL, /* lockfunc */ NULL, /* lockfuncarg */ &ha->rx_tag)) { @@ -5255,6 +5569,14 @@ qlnx_init_fp(qlnx_host_t *ha) fp->tx_pkts_freed = 0; fp->tx_pkts_transmitted = 0; fp->tx_pkts_completed = 0; + +#ifdef QLNX_TRACE_PERF_DATA + fp->tx_pkts_trans_ctx = 0; + fp->tx_pkts_compl_ctx = 0; + fp->tx_pkts_trans_fp = 0; + fp->tx_pkts_compl_fp = 0; + fp->tx_pkts_compl_intr = 0; +#endif fp->tx_lso_wnd_min_len = 0; fp->tx_defrag = 0; fp->tx_nsegs_gt_elem_left = 0; @@ -6606,7 +6928,7 @@ qlnx_timer(void *arg) ecore_get_vport_stats(&ha->cdev, &ha->hw_stats); - if (ha->storm_stats_enable) + if (ha->storm_stats_gather) qlnx_sample_storm_stats(ha); callout_reset(&ha->qlnx_callout, hz, qlnx_timer, ha); @@ -6855,7 +7177,7 @@ qlnx_sample_storm_stats(qlnx_host_t *ha) struct ecore_hwfn *hwfn; if (ha->storm_stats_index >= QLNX_STORM_STATS_SAMPLES_PER_HWFN) { - ha->storm_stats_enable = 0; + ha->storm_stats_gather = 0; return; } Modified: stable/11/sys/dev/qlnx/qlnxe/qlnx_ver.h ============================================================================== --- stable/11/sys/dev/qlnx/qlnxe/qlnx_ver.h Thu Aug 24 18:01:17 2017 (r322850) +++ stable/11/sys/dev/qlnx/qlnxe/qlnx_ver.h Thu Aug 24 18:51:55 2017 (r322851) @@ -39,5 +39,5 @@ #define QLNX_VERSION_MAJOR 1 #define QLNX_VERSION_MINOR 4 -#define QLNX_VERSION_BUILD 6 +#define QLNX_VERSION_BUILD 7 Modified: stable/11/sys/modules/qlnx/qlnxe/Makefile ============================================================================== --- stable/11/sys/modules/qlnx/qlnxe/Makefile Thu Aug 24 18:01:17 2017 (r322850) +++ stable/11/sys/modules/qlnx/qlnxe/Makefile Thu Aug 24 18:51:55 2017 (r322851) @@ -52,7 +52,7 @@ SRCS+= pci_if.h CWARNEXTRA += -Wno-cast-qual -CFLAGS += -DQLNX_DEBUG +#CFLAGS += -DQLNX_DEBUG CFLAGS += -DECORE_PACKAGE CFLAGS += -DCONFIG_ECORE_L2 CFLAGS += -DECORE_CONFIG_DIRECT_HWFN From owner-svn-src-stable@freebsd.org Thu Aug 24 20:51:18 2017 Return-Path: Delivered-To: svn-src-stable@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 F3E93DE7E0F; Thu, 24 Aug 2017 20:51:17 +0000 (UTC) (envelope-from marius@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 BFEDD65AE3; Thu, 24 Aug 2017 20:51:17 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7OKpG6g080869; Thu, 24 Aug 2017 20:51:16 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7OKpGQS080868; Thu, 24 Aug 2017 20:51:16 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201708242051.v7OKpGQS080868@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Thu, 24 Aug 2017 20:51: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: r322857 - stable/11/etc/periodic/daily X-SVN-Group: stable-11 X-SVN-Commit-Author: marius X-SVN-Commit-Paths: stable/11/etc/periodic/daily X-SVN-Commit-Revision: 322857 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2017 20:51:18 -0000 Author: marius Date: Thu Aug 24 20:51:16 2017 New Revision: 322857 URL: https://svnweb.freebsd.org/changeset/base/322857 Log: MFC: r322726 Bring back the much more readable unified format for differences in /etc/{group,master.passwd}. This was originally turned on for all of /etc/{aliases,group,master.passwd} in r55196, but then backed out only for the latter two in r56697, as the adaption of the sed(1)ing done in r56308 was incorrect. This left us with inconsistent diff(1) formats in the daily output of periodic(8) ever since, despite in r56697 having been promised to be revisited. So properly adapt the password hash filtering to the unified format and turn the later on again for /etc/{group,master.passwd}, too. Modified: stable/11/etc/periodic/daily/200.backup-passwd Directory Properties: stable/11/ (props changed) Modified: stable/11/etc/periodic/daily/200.backup-passwd ============================================================================== --- stable/11/etc/periodic/daily/200.backup-passwd Thu Aug 24 20:49:19 2017 (r322856) +++ stable/11/etc/periodic/daily/200.backup-passwd Thu Aug 24 20:51:16 2017 (r322857) @@ -41,8 +41,8 @@ case "$daily_backup_passwd_enable" in then [ $rc -lt 1 ] && rc=1 echo "$host passwd diffs:" - diff -I '^#' $bak/master.passwd.bak /etc/master.passwd |\ - sed 's/^\([<>] [^:]*\):[^:]*:/\1:(password):/' + diff -uI '^#' $bak/master.passwd.bak /etc/master.passwd |\ + sed 's/^\([-+][^-+:]*\):[^:]*:/\1:(password):/' mv $bak/master.passwd.bak $bak/master.passwd.bak2 cp -p /etc/master.passwd $bak/master.passwd.bak || rc=3 fi @@ -58,7 +58,7 @@ case "$daily_backup_passwd_enable" in then [ $rc -lt 1 ] && rc=1 echo "$host group diffs:" - diff $bak/group.bak /etc/group + diff -u $bak/group.bak /etc/group mv $bak/group.bak $bak/group.bak2 cp -p /etc/group $bak/group.bak || rc=3 fi From owner-svn-src-stable@freebsd.org Thu Aug 24 20:52:29 2017 Return-Path: Delivered-To: svn-src-stable@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 6B9D8DE7FD4; Thu, 24 Aug 2017 20:52:29 +0000 (UTC) (envelope-from marius@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 33BF565E11; Thu, 24 Aug 2017 20:52:29 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7OKqS0w081682; Thu, 24 Aug 2017 20:52:28 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7OKqSt9081681; Thu, 24 Aug 2017 20:52:28 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201708242052.v7OKqSt9081681@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Thu, 24 Aug 2017 20:52:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r322859 - stable/10/etc/periodic/daily X-SVN-Group: stable-10 X-SVN-Commit-Author: marius X-SVN-Commit-Paths: stable/10/etc/periodic/daily X-SVN-Commit-Revision: 322859 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2017 20:52:29 -0000 Author: marius Date: Thu Aug 24 20:52:28 2017 New Revision: 322859 URL: https://svnweb.freebsd.org/changeset/base/322859 Log: MFC: r322726 Bring back the much more readable unified format for differences in /etc/{group,master.passwd}. This was originally turned on for all of /etc/{aliases,group,master.passwd} in r55196, but then backed out only for the latter two in r56697, as the adaption of the sed(1)ing done in r56308 was incorrect. This left us with inconsistent diff(1) formats in the daily output of periodic(8) ever since, despite in r56697 having been promised to be revisited. So properly adapt the password hash filtering to the unified format and turn the later on again for /etc/{group,master.passwd}, too. Approved by: re (kib) Modified: stable/10/etc/periodic/daily/200.backup-passwd Directory Properties: stable/10/ (props changed) Modified: stable/10/etc/periodic/daily/200.backup-passwd ============================================================================== --- stable/10/etc/periodic/daily/200.backup-passwd Thu Aug 24 20:52:02 2017 (r322858) +++ stable/10/etc/periodic/daily/200.backup-passwd Thu Aug 24 20:52:28 2017 (r322859) @@ -41,8 +41,8 @@ case "$daily_backup_passwd_enable" in then [ $rc -lt 1 ] && rc=1 echo "$host passwd diffs:" - diff -I '^#' $bak/master.passwd.bak /etc/master.passwd |\ - sed 's/^\([<>] [^:]*\):[^:]*:/\1:(password):/' + diff -uI '^#' $bak/master.passwd.bak /etc/master.passwd |\ + sed 's/^\([-+][^-+:]*\):[^:]*:/\1:(password):/' mv $bak/master.passwd.bak $bak/master.passwd.bak2 cp -p /etc/master.passwd $bak/master.passwd.bak || rc=3 fi @@ -58,7 +58,7 @@ case "$daily_backup_passwd_enable" in then [ $rc -lt 1 ] && rc=1 echo "$host group diffs:" - diff $bak/group.bak /etc/group + diff -u $bak/group.bak /etc/group mv $bak/group.bak $bak/group.bak2 cp -p /etc/group $bak/group.bak || rc=3 fi From owner-svn-src-stable@freebsd.org Thu Aug 24 21:44:25 2017 Return-Path: Delivered-To: svn-src-stable@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 768E9DE8B02; Thu, 24 Aug 2017 21:44:25 +0000 (UTC) (envelope-from mckusick@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 405DC6719B; Thu, 24 Aug 2017 21:44:25 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7OLiOvU002186; Thu, 24 Aug 2017 21:44:24 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7OLiNSI002175; Thu, 24 Aug 2017 21:44:23 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201708242144.v7OLiNSI002175@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Thu, 24 Aug 2017 21:44:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r322860 - in stable/10: sbin/fsck_ffs sbin/fsirand sbin/newfs sbin/newfs_msdos share/man/man4 sys/geom sys/sys sys/ufs/ffs X-SVN-Group: stable-10 X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: in stable/10: sbin/fsck_ffs sbin/fsirand sbin/newfs sbin/newfs_msdos share/man/man4 sys/geom sys/sys sys/ufs/ffs X-SVN-Commit-Revision: 322860 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2017 21:44:25 -0000 Author: mckusick Date: Thu Aug 24 21:44:23 2017 New Revision: 322860 URL: https://svnweb.freebsd.org/changeset/base/322860 Log: MFC of 276737, 322200, 322201, 322271, and 322297 276737: Remove old ioctl use and support 322200: Remove (broken) search for alternate superblocks 322201: Show differences when alternate superblock fails to match 322271: Cleanup for 322200. 322297: Restore fsck_ffs ability to find alternate superblocks Discussed with: kib, imp Differential Revision: https://reviews.freebsd.org/D11589 Approved by: re (kib) Modified: stable/10/sbin/fsck_ffs/setup.c stable/10/sbin/fsirand/fsirand.c stable/10/sbin/newfs/mkfs.c stable/10/sbin/newfs/newfs.c stable/10/sbin/newfs_msdos/newfs_msdos.c stable/10/share/man/man4/cd.4 stable/10/share/man/man4/mcd.4 stable/10/sys/geom/geom_bsd.c stable/10/sys/sys/disklabel.h stable/10/sys/ufs/ffs/fs.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/fsck_ffs/setup.c ============================================================================== --- stable/10/sbin/fsck_ffs/setup.c Thu Aug 24 20:52:28 2017 (r322859) +++ stable/10/sbin/fsck_ffs/setup.c Thu Aug 24 21:44:23 2017 (r322860) @@ -58,9 +58,9 @@ struct bufarea asblk; #define altsblock (*asblk.b_un.b_fs) #define POWEROF2(num) (((num) & ((num) - 1)) == 0) -static void badsb(int listerr, const char *s); static int calcsb(char *dev, int devfd, struct fs *fs); -static struct disklabel *getdisklabel(char *s, int fd); +static void saverecovery(int readfd, int writefd); +static int chkrecovery(int devfd); /* * Read in a superblock finding an alternate if necessary. @@ -236,6 +236,10 @@ setup(char *dev) memmove(&altsblock, &sblock, (size_t)sblock.fs_sbsize); flush(fswritefd, &asblk); } + if (preen == 0 && yflag == 0 && sblock.fs_magic == FS_UFS2_MAGIC && + fswritefd != -1 && chkrecovery(fsreadfd) == 0 && + reply("SAVE DATA TO FIND ALTERNATE SUPERBLOCKS") != 0) + saverecovery(fsreadfd, fswritefd); /* * read in the summary info. */ @@ -319,7 +323,7 @@ int readsb(int listerr) { ufs2_daddr_t super; - int i; + int i, bad; if (bflag) { super = bflag; @@ -369,40 +373,57 @@ readsb(int listerr) dev_bsize = sblock.fs_fsize / fsbtodb(&sblock, 1); sblk.b_bno = super / dev_bsize; sblk.b_size = SBLOCKSIZE; - if (bflag) - goto out; /* * Compare all fields that should not differ in alternate super block. * When an alternate super-block is specified this check is skipped. */ + if (bflag) + goto out; getblk(&asblk, cgsblock(&sblock, sblock.fs_ncg - 1), sblock.fs_sbsize); if (asblk.b_errs) return (0); - if (altsblock.fs_sblkno != sblock.fs_sblkno || - altsblock.fs_cblkno != sblock.fs_cblkno || - altsblock.fs_iblkno != sblock.fs_iblkno || - altsblock.fs_dblkno != sblock.fs_dblkno || - altsblock.fs_ncg != sblock.fs_ncg || - altsblock.fs_bsize != sblock.fs_bsize || - altsblock.fs_fsize != sblock.fs_fsize || - altsblock.fs_frag != sblock.fs_frag || - altsblock.fs_bmask != sblock.fs_bmask || - altsblock.fs_fmask != sblock.fs_fmask || - altsblock.fs_bshift != sblock.fs_bshift || - altsblock.fs_fshift != sblock.fs_fshift || - altsblock.fs_fragshift != sblock.fs_fragshift || - altsblock.fs_fsbtodb != sblock.fs_fsbtodb || - altsblock.fs_sbsize != sblock.fs_sbsize || - altsblock.fs_nindir != sblock.fs_nindir || - altsblock.fs_inopb != sblock.fs_inopb || - altsblock.fs_cssize != sblock.fs_cssize || - altsblock.fs_ipg != sblock.fs_ipg || - altsblock.fs_fpg != sblock.fs_fpg || - altsblock.fs_magic != sblock.fs_magic) { - badsb(listerr, - "VALUES IN SUPER BLOCK DISAGREE WITH THOSE IN FIRST ALTERNATE"); - return (0); + bad = 0; +#define CHK(x, y) \ + if (altsblock.x != sblock.x) { \ + bad++; \ + if (listerr && debug) \ + printf("SUPER BLOCK VS ALTERNATE MISMATCH %s: " y " vs " y "\n", \ + #x, (intmax_t)sblock.x, (intmax_t)altsblock.x); \ } + CHK(fs_sblkno, "%jd"); + CHK(fs_cblkno, "%jd"); + CHK(fs_iblkno, "%jd"); + CHK(fs_dblkno, "%jd"); + CHK(fs_ncg, "%jd"); + CHK(fs_bsize, "%jd"); + CHK(fs_fsize, "%jd"); + CHK(fs_frag, "%jd"); + CHK(fs_bmask, "%#jx"); + CHK(fs_fmask, "%#jx"); + CHK(fs_bshift, "%jd"); + CHK(fs_fshift, "%jd"); + CHK(fs_fragshift, "%jd"); + CHK(fs_fsbtodb, "%jd"); + CHK(fs_sbsize, "%jd"); + CHK(fs_nindir, "%jd"); + CHK(fs_inopb, "%jd"); + CHK(fs_cssize, "%jd"); + CHK(fs_ipg, "%jd"); + CHK(fs_fpg, "%jd"); + CHK(fs_magic, "%#jx"); +#undef CHK + if (bad) { + if (listerr == 0) + return (0); + if (preen) + printf("%s: ", cdevname); + printf( + "VALUES IN SUPER BLOCK LSB=%jd DISAGREE WITH THOSE IN\n" + "LAST ALTERNATE LSB=%jd\n", + sblk.b_bno, asblk.b_bno); + if (reply("IGNORE ALTERNATE SUPER BLOCK") == 0) + return (0); + } out: /* * If not yet done, update UFS1 superblock with new wider fields. @@ -423,21 +444,9 @@ out: return (1); } -static void -badsb(int listerr, const char *s) -{ - - if (!listerr) - return; - if (preen) - printf("%s: ", cdevname); - pfatal("BAD SUPER BLOCK: %s\n", s); -} - void sblock_init(void) { - struct disklabel *lp; fswritefd = -1; fsmodified = 0; @@ -448,14 +457,11 @@ sblock_init(void) asblk.b_un.b_buf = Malloc(SBLOCKSIZE); if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL) errx(EEXIT, "cannot allocate space for superblock"); - if ((lp = getdisklabel(NULL, fsreadfd))) - real_dev_bsize = dev_bsize = secsize = lp->d_secsize; - else - dev_bsize = secsize = DEV_BSIZE; + dev_bsize = secsize = DEV_BSIZE; } /* - * Calculate a prototype superblock based on information in the disk label. + * Calculate a prototype superblock based on information in the boot area. * When done the cgsblock macro can be calculated and the fs_ncg field * can be used. Do NOT attempt to use other macros without verifying that * their needed information is available! @@ -463,74 +469,63 @@ sblock_init(void) static int calcsb(char *dev, int devfd, struct fs *fs) { - struct disklabel *lp; - struct partition *pp; - char *cp; - int i, nspf; + struct fsrecovery fsr; - cp = strchr(dev, '\0') - 1; - if (cp == (char *)-1 || ((*cp < 'a' || *cp > 'h') && !isdigit(*cp))) { - pfatal("%s: CANNOT FIGURE OUT FILE SYSTEM PARTITION\n", dev); + /* + * We need fragments-per-group and the partition-size. + * + * Newfs stores these details at the end of the boot block area + * at the start of the filesystem partition. If they have been + * overwritten by a boot block, we fail. But usually they are + * there and we can use them. + */ + if (blread(devfd, (char *)&fsr, + (SBLOCK_UFS2 - sizeof(fsr)) / dev_bsize, sizeof(fsr)) || + fsr.fsr_magic != FS_UFS2_MAGIC) return (0); - } - lp = getdisklabel(dev, devfd); - if (isdigit(*cp)) - pp = &lp->d_partitions[0]; - else - pp = &lp->d_partitions[*cp - 'a']; - if (pp->p_fstype != FS_BSDFFS) { - pfatal("%s: NOT LABELED AS A BSD FILE SYSTEM (%s)\n", - dev, pp->p_fstype < FSMAXTYPES ? - fstypenames[pp->p_fstype] : "unknown"); - return (0); - } - if (pp->p_fsize == 0 || pp->p_frag == 0 || - pp->p_cpg == 0 || pp->p_size == 0) { - pfatal("%s: %s: type %s fsize %d, frag %d, cpg %d, size %d\n", - dev, "INCOMPLETE LABEL", fstypenames[pp->p_fstype], - pp->p_fsize, pp->p_frag, pp->p_cpg, pp->p_size); - return (0); - } memset(fs, 0, sizeof(struct fs)); - fs->fs_fsize = pp->p_fsize; - fs->fs_frag = pp->p_frag; - fs->fs_size = pp->p_size; - fs->fs_sblkno = roundup( - howmany(lp->d_bbsize + lp->d_sbsize, fs->fs_fsize), - fs->fs_frag); - nspf = fs->fs_fsize / lp->d_secsize; - for (fs->fs_fsbtodb = 0, i = nspf; i > 1; i >>= 1) - fs->fs_fsbtodb++; - dev_bsize = lp->d_secsize; - if (fs->fs_magic == FS_UFS2_MAGIC) { - fs->fs_fpg = pp->p_cpg; - fs->fs_ncg = howmany(fs->fs_size, fs->fs_fpg); - } else /* if (fs->fs_magic == FS_UFS1_MAGIC) */ { - fs->fs_old_cpg = pp->p_cpg; - fs->fs_old_cgmask = 0xffffffff; - for (i = lp->d_ntracks; i > 1; i >>= 1) - fs->fs_old_cgmask <<= 1; - if (!POWEROF2(lp->d_ntracks)) - fs->fs_old_cgmask <<= 1; - fs->fs_old_cgoffset = roundup(howmany(lp->d_nsectors, nspf), - fs->fs_frag); - fs->fs_fpg = (fs->fs_old_cpg * lp->d_secpercyl) / nspf; - fs->fs_ncg = howmany(fs->fs_size / lp->d_secpercyl, - fs->fs_old_cpg); - } + fs->fs_fpg = fsr.fsr_fpg; + fs->fs_fsbtodb = fsr.fsr_fsbtodb; + fs->fs_sblkno = fsr.fsr_sblkno; + fs->fs_magic = fsr.fsr_magic; + fs->fs_ncg = fsr.fsr_ncg; return (1); } -static struct disklabel * -getdisklabel(char *s, int fd) +/* + * Check to see if recovery information exists. + */ +static int +chkrecovery(int devfd) { - static struct disklabel lab; + struct fsrecovery fsr; - if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) { - if (s == NULL) - return ((struct disklabel *)NULL); - pwarn("ioctl (GCINFO): %s\n", strerror(errno)); - errx(EEXIT, "%s: can't read disk label", s); - } - return (&lab); + if (blread(devfd, (char *)&fsr, + (SBLOCK_UFS2 - sizeof(fsr)) / dev_bsize, sizeof(fsr)) || + fsr.fsr_magic != FS_UFS2_MAGIC) + return (0); + return (1); +} + +/* + * Read the last sector of the boot block, replace the last + * 20 bytes with the recovery information, then write it back. + * The recovery information only works for UFS2 filesystems. + */ +static void +saverecovery(int readfd, int writefd) +{ + struct fsrecovery fsr; + + if (sblock.fs_magic != FS_UFS2_MAGIC || + blread(readfd, (char *)&fsr, + (SBLOCK_UFS2 - sizeof(fsr)) / dev_bsize, sizeof(fsr))) + return; + fsr.fsr_magic = sblock.fs_magic; + fsr.fsr_fpg = sblock.fs_fpg; + fsr.fsr_fsbtodb = sblock.fs_fsbtodb; + fsr.fsr_sblkno = sblock.fs_sblkno; + fsr.fsr_ncg = sblock.fs_ncg; + blwrite(writefd, (char *)&fsr, (SBLOCK_UFS2 - sizeof(fsr)) / dev_bsize, + sizeof(fsr)); } Modified: stable/10/sbin/fsirand/fsirand.c ============================================================================== --- stable/10/sbin/fsirand/fsirand.c Thu Aug 24 20:52:28 2017 (r322859) +++ stable/10/sbin/fsirand/fsirand.c Thu Aug 24 21:44:23 2017 (r322860) @@ -36,7 +36,6 @@ static const char rcsid[] = #endif /* not lint */ #include -#include #include #include @@ -120,20 +119,10 @@ fsirand(char *device) char sbuf[SBLOCKSIZE], sbuftmp[SBLOCKSIZE]; int i, devfd, n, cg; u_int32_t bsize = DEV_BSIZE; - struct disklabel label; if ((devfd = open(device, printonly ? O_RDONLY : O_RDWR)) < 0) { warn("can't open %s", device); return (1); - } - - /* Get block size (usually 512) from disklabel if possible */ - if (!ignorelabel) { - if (ioctl(devfd, DIOCGDINFO, &label) < 0) - warn("can't read disklabel, using sector size of %d", - bsize); - else - bsize = label.d_secsize; } dp1 = NULL; Modified: stable/10/sbin/newfs/mkfs.c ============================================================================== --- stable/10/sbin/newfs/mkfs.c Thu Aug 24 20:52:28 2017 (r322859) +++ stable/10/sbin/newfs/mkfs.c Thu Aug 24 21:44:23 2017 (r322860) @@ -121,6 +121,7 @@ mkfs(struct partition *pp, char *fsys) ino_t maxinum; int minfragsperinode; /* minimum ratio of frags to inodes */ char tmpbuf[100]; /* XXX this will break in about 2,500 years */ + struct fsrecovery fsr; union { struct fs fdummy; char cdummy[SBLOCKSIZE]; @@ -618,6 +619,25 @@ restart: sblock.fs_cssize - i < sblock.fs_bsize ? sblock.fs_cssize - i : sblock.fs_bsize, ((char *)fscs) + i); + /* + * Read the last sector of the boot block, replace the last + * 20 bytes with the recovery information, then write it back. + * The recovery information only works for UFS2 filesystems. + */ + if (sblock.fs_magic == FS_UFS2_MAGIC) { + i = bread(&disk, + part_ofs + (SBLOCK_UFS2 - sizeof(fsr)) / disk.d_bsize, + (char *)&fsr, sizeof(fsr)); + if (i == -1) + err(1, "can't read recovery area: %s", disk.d_error); + fsr.fsr_magic = sblock.fs_magic; + fsr.fsr_fpg = sblock.fs_fpg; + fsr.fsr_fsbtodb = sblock.fs_fsbtodb; + fsr.fsr_sblkno = sblock.fs_sblkno; + fsr.fsr_ncg = sblock.fs_ncg; + wtfs((SBLOCK_UFS2 - sizeof(fsr)) / disk.d_bsize, sizeof(fsr), + (char *)&fsr); + } /* * Update information about this partition in pack * label, to that it may be updated on disk. Modified: stable/10/sbin/newfs/newfs.c ============================================================================== --- stable/10/sbin/newfs/newfs.c Thu Aug 24 20:52:28 2017 (r322859) +++ stable/10/sbin/newfs/newfs.c Thu Aug 24 21:44:23 2017 (r322860) @@ -117,11 +117,9 @@ static u_char bootarea[BBSIZE]; static int is_file; /* work on a file, not a device */ static char *dkname; static char *disktype; -static int unlabeled; static void getfssize(intmax_t *, const char *p, intmax_t, intmax_t); static struct disklabel *getdisklabel(char *s); -static void rewritelabel(char *s, struct disklabel *lp); static void usage(void); static int expand_number_int(const char *buf, int *num); @@ -403,12 +401,6 @@ main(int argc, char *argv[]) pp->p_size *= secperblk; } mkfs(pp, special); - if (!unlabeled) { - if (realsectorsize != DEV_BSIZE) - pp->p_size /= realsectorsize / DEV_BSIZE; - if (!Nflag && bcmp(pp, &oldpartition, sizeof(oldpartition))) - rewritelabel(special, lp); - } ufs_disk_close(&disk); if (!jflag) exit(0); @@ -452,34 +444,12 @@ getdisklabel(char *s) return &lab; } - if (ioctl(disk.d_fd, DIOCGDINFO, (char *)&lab) != -1) - return (&lab); - unlabeled++; if (disktype) { lp = getdiskbyname(disktype); if (lp != NULL) return (lp); } return (NULL); -} - -void -rewritelabel(char *s, struct disklabel *lp) -{ - if (unlabeled) - return; - lp->d_checksum = 0; - lp->d_checksum = dkcksum(lp); - if (is_file) { - bsd_disklabel_le_enc(bootarea + 0 /* labeloffset */ + - 1 /* labelsoffset */ * sectorsize, lp); - lseek(disk.d_fd, 0, SEEK_SET); - if (write(disk.d_fd, bootarea, BBSIZE) != BBSIZE) - errx(1, "cannot write label"); - return; - } - if (ioctl(disk.d_fd, DIOCWDINFO, (char *)lp) == -1) - warn("ioctl (WDINFO): %s: can't rewrite disk label", s); } static void Modified: stable/10/sbin/newfs_msdos/newfs_msdos.c ============================================================================== --- stable/10/sbin/newfs_msdos/newfs_msdos.c Thu Aug 24 20:52:28 2017 (r322859) +++ stable/10/sbin/newfs_msdos/newfs_msdos.c Thu Aug 24 21:44:23 2017 (r322860) @@ -829,28 +829,26 @@ getdiskinfo(int fd, const char *fname, const char *dty if (lp == NULL) { if (bpb->bpbBytesPerSec) dlp.d_secsize = bpb->bpbBytesPerSec; - if (ioctl(fd, DIOCGDINFO, &dlp) == -1) { - if (bpb->bpbBytesPerSec == 0 && ioctl(fd, DIOCGSECTORSIZE, - &dlp.d_secsize) == -1) - err(1, "cannot get sector size"); + if (bpb->bpbBytesPerSec == 0 && ioctl(fd, DIOCGSECTORSIZE, + &dlp.d_secsize) == -1) + err(1, "cannot get sector size"); - dlp.d_secperunit = ms / dlp.d_secsize; + dlp.d_secperunit = ms / dlp.d_secsize; - if (bpb->bpbSecPerTrack == 0 && ioctl(fd, DIOCGFWSECTORS, - &dlp.d_nsectors) == -1) { - warn("cannot get number of sectors per track"); - dlp.d_nsectors = 63; - } - if (bpb->bpbHeads == 0 && - ioctl(fd, DIOCGFWHEADS, &dlp.d_ntracks) == -1) { - warn("cannot get number of heads"); - if (dlp.d_secperunit <= 63*1*1024) - dlp.d_ntracks = 1; - else if (dlp.d_secperunit <= 63*16*1024) - dlp.d_ntracks = 16; - else - dlp.d_ntracks = 255; - } + if (bpb->bpbSecPerTrack == 0 && ioctl(fd, DIOCGFWSECTORS, + &dlp.d_nsectors) == -1) { + warn("cannot get number of sectors per track"); + dlp.d_nsectors = 63; + } + if (bpb->bpbHeads == 0 && + ioctl(fd, DIOCGFWHEADS, &dlp.d_ntracks) == -1) { + warn("cannot get number of heads"); + if (dlp.d_secperunit <= 63*1*1024) + dlp.d_ntracks = 1; + else if (dlp.d_secperunit <= 63*16*1024) + dlp.d_ntracks = 16; + else + dlp.d_ntracks = 255; } hs = (ms / dlp.d_secsize) - dlp.d_secperunit; Modified: stable/10/share/man/man4/cd.4 ============================================================================== --- stable/10/share/man/man4/cd.4 Thu Aug 24 20:52:28 2017 (r322859) +++ stable/10/share/man/man4/cd.4 Thu Aug 24 21:44:23 2017 (r322860) @@ -101,16 +101,6 @@ in the header files and .In sys/disklabel.h . .Bl -tag -width CDIOCREADSUBCHANNEL -.It Dv DIOCGDINFO -.It Dv DIOCSDINFO -.Pq Li "struct disklabel" -Read or write the in-core copy of the disklabel for the -drive. -The disklabel is initialized with information -read from the scsi inquiry commands, and should be the same as -the information printed at boot. -This structure is defined in the header file -.In sys/disklabel.h . .It Dv CDIOCPLAYTRACKS .Pq Li "struct ioc_play_track" Start audio playback given a track address and length. Modified: stable/10/share/man/man4/mcd.4 ============================================================================== --- stable/10/share/man/man4/mcd.4 Thu Aug 24 20:52:28 2017 (r322859) +++ stable/10/share/man/man4/mcd.4 Thu Aug 24 21:44:23 2017 (r322860) @@ -61,12 +61,8 @@ The driver responds to disk-specific .Fn ioctl commands, namely the -.Dv DIOCGDINFO , -.Dv DIOCGPART , -.Dv DIOCWDINFO , -and -.Dv DIOCSDINFO , -commands. +.Dv DIOCGPART +command. Other disk-specific .Fn ioctl commands will return an error. Modified: stable/10/sys/geom/geom_bsd.c ============================================================================== --- stable/10/sys/geom/geom_bsd.c Thu Aug 24 20:52:28 2017 (r322859) +++ stable/10/sys/geom/geom_bsd.c Thu Aug 24 21:44:23 2017 (r322860) @@ -305,8 +305,8 @@ g_bsd_hotwrite(void *arg, int flag) gsp = gp->softc; ms = gsp->softc; gsl = &gsp->slices[bp->bio_to->index]; - p = (u_char*)bp->bio_data + ms->labeloffset - - (bp->bio_offset + gsl->offset); + p = (u_char*)bp->bio_data + ms->labeloffset - + (bp->bio_offset + gsl->offset); error = g_bsd_modify(gp, p); if (error) { g_io_deliver(bp, EPERM); @@ -315,94 +315,7 @@ g_bsd_hotwrite(void *arg, int flag) g_slice_finish_hot(bp); } -/*- - * This start routine is only called for non-trivial requests, all the - * trivial ones are handled autonomously by the slice code. - * For requests we handle here, we must call the g_io_deliver() on the - * bio, and return non-zero to indicate to the slice code that we did so. - * This code executes in the "DOWN" I/O path, this means: - * * No sleeping. - * * Don't grab the topology lock. - * * Don't call biowait, g_getattr(), g_setattr() or g_read_data() - */ static int -g_bsd_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, struct thread *td) -{ - struct g_geom *gp; - struct g_bsd_softc *ms; - struct g_slicer *gsp; - u_char *label; - int error; - - gp = pp->geom; - gsp = gp->softc; - ms = gsp->softc; - - switch(cmd) { - case DIOCGDINFO: - /* Return a copy of the disklabel to userland. */ - bsd_disklabel_le_dec(ms->label, data, MAXPARTITIONS); - return(0); - case DIOCBSDBB: { - struct g_consumer *cp; - u_char *buf; - void *p; - int error, i; - uint64_t sum; - - if (!(fflag & FWRITE)) - return (EPERM); - /* The disklabel to set is the ioctl argument. */ - buf = g_malloc(BBSIZE, M_WAITOK); - p = *(void **)data; - error = copyin(p, buf, BBSIZE); - if (!error) { - /* XXX: Rude, but supposedly safe */ - DROP_GIANT(); - g_topology_lock(); - /* Validate and modify our slice instance to match. */ - error = g_bsd_modify(gp, buf + ms->labeloffset); - if (!error) { - cp = LIST_FIRST(&gp->consumer); - if (ms->labeloffset == ALPHA_LABEL_OFFSET) { - sum = 0; - for (i = 0; i < 63; i++) - sum += le64dec(buf + i * 8); - le64enc(buf + 504, sum); - } - error = g_write_data(cp, 0, buf, BBSIZE); - } - g_topology_unlock(); - PICKUP_GIANT(); - } - g_free(buf); - return (error); - } - case DIOCSDINFO: - case DIOCWDINFO: { - if (!(fflag & FWRITE)) - return (EPERM); - label = g_malloc(LABELSIZE, M_WAITOK); - /* The disklabel to set is the ioctl argument. */ - bsd_disklabel_le_enc(label, data); - - DROP_GIANT(); - g_topology_lock(); - /* Validate and modify our slice instance to match. */ - error = g_bsd_modify(gp, label); - if (error == 0 && cmd == DIOCWDINFO) - error = g_bsd_writelabel(gp, NULL); - g_topology_unlock(); - PICKUP_GIANT(); - g_free(label); - return(error); - } - default: - return (ENOIOCTL); - } -} - -static int g_bsd_start(struct bio *bp) { struct g_geom *gp; @@ -698,7 +611,6 @@ static struct g_class g_bsd_class = { .taste = g_bsd_taste, .ctlreq = g_bsd_config, .dumpconf = g_bsd_dumpconf, - .ioctl = g_bsd_ioctl, }; DECLARE_GEOM_CLASS(g_bsd_class, g_bsd); Modified: stable/10/sys/sys/disklabel.h ============================================================================== --- stable/10/sys/sys/disklabel.h Thu Aug 24 20:52:28 2017 (r322859) +++ stable/10/sys/sys/disklabel.h Thu Aug 24 21:44:23 2017 (r322860) @@ -284,15 +284,8 @@ static const char *fstypenames[] = { #define D_CHAIN 0x10 /* can do back-back transfers */ /* - * Disklabel-specific ioctls. - * * NB: defines ioctls from 'd'/128 and up. */ - /* get and set disklabel */ -#define DIOCGDINFO _IOR('d', 101, struct disklabel)/* get */ -#define DIOCSDINFO _IOW('d', 102, struct disklabel)/* set */ -#define DIOCWDINFO _IOW('d', 103, struct disklabel)/* set, update disk */ -#define DIOCBSDBB _IOW('d', 110, void *) /* write bootblocks */ /* * Functions for proper encoding/decoding of struct disklabel into/from Modified: stable/10/sys/ufs/ffs/fs.h ============================================================================== --- stable/10/sys/ufs/ffs/fs.h Thu Aug 24 20:52:28 2017 (r322859) +++ stable/10/sys/ufs/ffs/fs.h Thu Aug 24 21:44:23 2017 (r322860) @@ -234,6 +234,20 @@ struct fsck_cmd { }; /* + * A recovery structure placed at the end of the boot block area by newfs + * that can be used by fsck to search for alternate superblocks. + */ +#define RESID (4096 - 20) /* disk sector size minus recovery area size */ +struct fsrecovery { + char block[RESID]; /* unused part of sector */ + int32_t fsr_magic; /* magic number */ + int32_t fsr_fsbtodb; /* fsbtodb and dbtofsb shift constant */ + int32_t fsr_sblkno; /* offset of super-block in filesys */ + int32_t fsr_fpg; /* blocks per group * fs_frag */ + u_int32_t fsr_ncg; /* number of cylinder groups */ +}; + +/* * Per cylinder group information; summarized in blocks allocated * from first cylinder group data blocks. These blocks have to be * read in from fs_csaddr (size fs_cssize) in addition to the From owner-svn-src-stable@freebsd.org Thu Aug 24 21:49:45 2017 Return-Path: Delivered-To: svn-src-stable@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 AF457DE8B8B; Thu, 24 Aug 2017 21:49:45 +0000 (UTC) (envelope-from mckusick@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 6F9386730A; Thu, 24 Aug 2017 21:49:45 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7OLnitZ002390; Thu, 24 Aug 2017 21:49:44 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7OLniu1002389; Thu, 24 Aug 2017 21:49:44 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201708242149.v7OLniu1002389@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Thu, 24 Aug 2017 21:49:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r322861 - stable/10 X-SVN-Group: stable-10 X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: stable/10 X-SVN-Commit-Revision: 322861 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2017 21:49:45 -0000 Author: mckusick Date: Thu Aug 24 21:49:44 2017 New Revision: 322861 URL: https://svnweb.freebsd.org/changeset/base/322861 Log: Note change brought on by 322860 MFC. Discussed with: kib, imp Differential Revision: https://reviews.freebsd.org/D11589 Approved by: re (kib) Modified: stable/10/UPDATING Modified: stable/10/UPDATING ============================================================================== --- stable/10/UPDATING Thu Aug 24 21:44:23 2017 (r322860) +++ stable/10/UPDATING Thu Aug 24 21:49:44 2017 (r322861) @@ -16,6 +16,19 @@ from older versions of FreeBSD, try WITHOUT_CLANG to b stable/10, and then rebuild without this option. The bootstrap process from older version of current is a bit fragile. +20170824: + Since the switch to GPT disk labels, fsck for UFS/FFS has been + unable to automatically find alternate superblocks. As of r322860, + the information needed to find alternate superblocks has been + moved to the end of the area reserved for the boot block. + Filesystems created with a newfs of this vintage or later + will create the recovery information. If you have a filesystem + created prior to this change and wish to have a recovery block + created for your filesystem, you can do so by running fsck in + forground mode (i.e., do not use the -p or -y options). As it + starts, fsck will ask ``SAVE DATA TO FIND ALTERNATE SUPERBLOCKS'' + to which you should answer yes. + 20170511: The mmcsd.ko module now additionally depends on geom_flashmap.ko. Also, mmc.ko and mmcsd.ko need to be a matching pair built from the From owner-svn-src-stable@freebsd.org Thu Aug 24 22:33:44 2017 Return-Path: Delivered-To: svn-src-stable@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 88C54DE9689; Thu, 24 Aug 2017 22:33:44 +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 4D3CA688D9; Thu, 24 Aug 2017 22:33:44 +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 v7OMXhrw022513; Thu, 24 Aug 2017 22:33:43 GMT (envelope-from davidcs@FreeBSD.org) Received: (from davidcs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7OMXhOL022509; Thu, 24 Aug 2017 22:33:43 GMT (envelope-from davidcs@FreeBSD.org) Message-Id: <201708242233.v7OMXhOL022509@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: davidcs set sender to davidcs@FreeBSD.org using -f From: David C Somayajulu Date: Thu, 24 Aug 2017 22:33:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r322864 - in stable/10/sys: dev/qlnx/qlnxe modules/qlnx/qlnxe X-SVN-Group: stable-10 X-SVN-Commit-Author: davidcs X-SVN-Commit-Paths: in stable/10/sys: dev/qlnx/qlnxe modules/qlnx/qlnxe X-SVN-Commit-Revision: 322864 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2017 22:33:44 -0000 Author: davidcs Date: Thu Aug 24 22:33:42 2017 New Revision: 322864 URL: https://svnweb.freebsd.org/changeset/base/322864 Log: MFC r322408 Performance enhancements to reduce CPU utililization for large number of TCP connections (order of tens of thousands), with predominantly Transmits. Submitted by: Vaishali.Kulkarni@cavium.com Approved by: re(marius) Modified: stable/10/sys/dev/qlnx/qlnxe/qlnx_def.h stable/10/sys/dev/qlnx/qlnxe/qlnx_os.c stable/10/sys/dev/qlnx/qlnxe/qlnx_ver.h stable/10/sys/modules/qlnx/qlnxe/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/qlnx/qlnxe/qlnx_def.h ============================================================================== --- stable/10/sys/dev/qlnx/qlnxe/qlnx_def.h Thu Aug 24 22:11:10 2017 (r322863) +++ stable/10/sys/dev/qlnx/qlnxe/qlnx_def.h Thu Aug 24 22:33:42 2017 (r322864) @@ -50,9 +50,10 @@ struct qlnx_ivec { typedef struct qlnx_ivec qlnx_ivec_t; -//#define QLNX_MAX_RSS 30 -#define QLNX_MAX_RSS 16 -#define QLNX_MAX_TC 1 +//#define QLNX_MAX_RSS 30 +#define QLNX_MAX_RSS 36 +#define QLNX_DEFAULT_RSS 16 +#define QLNX_MAX_TC 1 enum QLNX_STATE { QLNX_STATE_CLOSED, @@ -201,6 +202,17 @@ struct qlnx_fastpath { uint64_t tx_pkts_freed; uint64_t tx_pkts_transmitted; uint64_t tx_pkts_completed; + uint64_t tx_tso_pkts; + uint64_t tx_non_tso_pkts; + +#ifdef QLNX_TRACE_PERF_DATA + uint64_t tx_pkts_trans_ctx; + uint64_t tx_pkts_compl_ctx; + uint64_t tx_pkts_trans_fp; + uint64_t tx_pkts_compl_fp; + uint64_t tx_pkts_compl_intr; +#endif + uint64_t tx_lso_wnd_min_len; uint64_t tx_defrag; uint64_t tx_nsegs_gt_elem_left; @@ -209,6 +221,13 @@ struct qlnx_fastpath { uint32_t tx_tso_max_pkt_len; uint32_t tx_tso_min_pkt_len; uint64_t tx_pkts[QLNX_FP_MAX_SEGS]; + +#ifdef QLNX_TRACE_PERF_DATA + uint64_t tx_pkts_hist[QLNX_FP_MAX_SEGS]; + uint64_t tx_comInt[QLNX_FP_MAX_SEGS]; + uint64_t tx_pkts_q[QLNX_FP_MAX_SEGS]; +#endif + uint64_t err_tx_nsegs_gt_elem_left; uint64_t err_tx_dmamap_create; uint64_t err_tx_defrag_dmamap_load; @@ -301,8 +320,13 @@ typedef struct qlnx_link_output qlnx_link_output_t; #define QLNX_MFW_VERSION_LENGTH 32 #define QLNX_STORMFW_VERSION_LENGTH 32 -#define QLNX_TX_ELEM_RESERVE 2 +#define QLNX_TX_ELEM_RESERVE 2 +#define QLNX_TX_ELEM_THRESH 128 +#define QLNX_TX_ELEM_MAX_THRESH 512 +#define QLNX_TX_ELEM_MIN_THRESH 32 +#define QLNX_TX_COMPL_THRESH 32 + #define QLNX_TPA_MAX_AGG_BUFFERS (20) #define QLNX_MAX_NUM_MULTICAST_ADDRS ECORE_MAX_MC_ADDRS @@ -454,6 +478,7 @@ struct qlnx_host { qlnx_storm_stats_t storm_stats[QLNX_STORM_STATS_TOTAL]; uint32_t storm_stats_index; uint32_t storm_stats_enable; + uint32_t storm_stats_gather; uint32_t personality; }; @@ -470,8 +495,11 @@ typedef struct qlnx_host qlnx_host_t; #define QLNX_MAX_MTU 9000 #define QLNX_MAX_SEGMENTS_NON_TSO (ETH_TX_MAX_BDS_PER_NON_LSO_PACKET - 1) -#define QLNX_MAX_TSO_FRAME_SIZE ((64 * 1024 - 1) + 22) +//#define QLNX_MAX_TSO_FRAME_SIZE ((64 * 1024 - 1) + 22) +#define QLNX_MAX_TSO_FRAME_SIZE 65536 +#define QLNX_MAX_TX_MBUF_SIZE 65536 /* bytes - bd_len = 16bits */ + #define QL_MAC_CMP(mac1, mac2) \ ((((*(uint32_t *) mac1) == (*(uint32_t *) mac2) && \ (*(uint16_t *)(mac1 + 4)) == (*(uint16_t *)(mac2 + 4)))) ? 0 : 1) @@ -702,6 +730,18 @@ extern void qlnx_fill_link(struct ecore_hwfn *hwfn, #define CQE_HAS_VLAN(flags) \ ((flags) & (PARSING_AND_ERR_FLAGS_TAG8021QEXIST_MASK \ << PARSING_AND_ERR_FLAGS_TAG8021QEXIST_SHIFT)) + +#if defined(__i386__) || defined(__amd64__) + +static __inline +void prefetch(void *x) +{ + __asm volatile("prefetcht0 %0" :: "m" (*(unsigned long *)x)); +} + +#else +#define prefetch(x) +#endif #endif /* #ifndef _QLNX_DEF_H_ */ Modified: stable/10/sys/dev/qlnx/qlnxe/qlnx_os.c ============================================================================== --- stable/10/sys/dev/qlnx/qlnxe/qlnx_os.c Thu Aug 24 22:11:10 2017 (r322863) +++ stable/10/sys/dev/qlnx/qlnxe/qlnx_os.c Thu Aug 24 22:33:42 2017 (r322864) @@ -94,6 +94,8 @@ static int qlnx_get_ifq_snd_maxlen(qlnx_host_t *ha); static uint32_t qlnx_get_optics(qlnx_host_t *ha, struct qlnx_link_output *if_link); static int qlnx_transmit(struct ifnet *ifp, struct mbuf *mp); +static int qlnx_transmit_locked(struct ifnet *ifp, struct qlnx_fastpath *fp, + struct mbuf *mp); static void qlnx_qflush(struct ifnet *ifp); static int qlnx_alloc_parent_dma_tag(qlnx_host_t *ha); @@ -133,6 +135,8 @@ static void qlnx_timer(void *arg); static int qlnx_alloc_tx_br(qlnx_host_t *ha, struct qlnx_fastpath *fp); static void qlnx_free_tx_br(qlnx_host_t *ha, struct qlnx_fastpath *fp); static void qlnx_trigger_dump(qlnx_host_t *ha); +static uint16_t qlnx_num_tx_compl(qlnx_host_t *ha, struct qlnx_fastpath *fp, + struct qlnx_tx_queue *txq); static void qlnx_tx_int(qlnx_host_t *ha, struct qlnx_fastpath *fp, struct qlnx_tx_queue *txq); static int qlnx_rx_int(qlnx_host_t *ha, struct qlnx_fastpath *fp, int budget, @@ -215,6 +219,12 @@ char qlnx_name_str[NAME_SIZE]; #define QLOGIC_PCI_DEVICE_ID_8070 0x8070 #endif +SYSCTL_NODE(_hw, OID_AUTO, qlnxe, CTLFLAG_RD, 0, "qlnxe driver parameters"); +/* Number of Queues: 0 (Auto) or 1 to 32 (fixed queue number) */ +static int qlnxe_queue_count = QLNX_DEFAULT_RSS; +SYSCTL_INT(_hw_qlnxe, OID_AUTO, queue_count, CTLFLAG_RDTUN, + &qlnxe_queue_count, 0, "Multi-Queue queue count"); + static int qlnx_valid_device(device_t dev) { @@ -302,7 +312,26 @@ qlnx_pci_probe(device_t dev) return (BUS_PROBE_DEFAULT); } +static uint16_t +qlnx_num_tx_compl(qlnx_host_t *ha, struct qlnx_fastpath *fp, + struct qlnx_tx_queue *txq) +{ + u16 hw_bd_cons; + u16 ecore_cons_idx; + uint16_t diff; + hw_bd_cons = le16toh(*txq->hw_cons_ptr); + + ecore_cons_idx = ecore_chain_get_cons_idx(&txq->tx_pbl); + if (hw_bd_cons < ecore_cons_idx) { + diff = (1 << 16) - (ecore_cons_idx - hw_bd_cons); + } else { + diff = hw_bd_cons - ecore_cons_idx; + } + return diff; +} + + static void qlnx_sp_intr(void *arg) { @@ -395,14 +424,11 @@ qlnx_fp_taskqueue(void *context, int pending) struct qlnx_fastpath *fp; qlnx_host_t *ha; struct ifnet *ifp; - struct mbuf *mp; - int ret; - struct thread *cthread; #ifdef QLNX_RCV_IN_TASKQ int lro_enable; int rx_int = 0, total_rx_count = 0; - + struct thread *cthread; #endif /* #ifdef QLNX_RCV_IN_TASKQ */ fp = context; @@ -410,6 +436,12 @@ qlnx_fp_taskqueue(void *context, int pending) if (fp == NULL) return; + ha = (qlnx_host_t *)fp->edev; + + ifp = ha->ifp; + +#ifdef QLNX_RCV_IN_TASKQ + cthread = curthread; thread_lock(cthread); @@ -419,112 +451,81 @@ qlnx_fp_taskqueue(void *context, int pending) thread_unlock(cthread); - ha = (qlnx_host_t *)fp->edev; + lro_enable = ifp->if_capenable & IFCAP_LRO; - ifp = ha->ifp; + rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold, lro_enable); -#ifdef QLNX_RCV_IN_TASKQ - { - lro_enable = ifp->if_capenable & IFCAP_LRO; + if (rx_int) { + fp->rx_pkts += rx_int; + total_rx_count += rx_int; + } - rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold, lro_enable); - - if (rx_int) { - fp->rx_pkts += rx_int; - total_rx_count += rx_int; - } - #ifdef QLNX_SOFT_LRO - { - struct lro_ctrl *lro; - - lro = &fp->rxq->lro; + { + struct lro_ctrl *lro; - if (lro_enable && total_rx_count) { + lro = &fp->rxq->lro; + if (lro_enable && total_rx_count) { + #if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) - if (ha->dbg_trace_lro_cnt) { - if (lro->lro_mbuf_count & ~1023) - fp->lro_cnt_1024++; - else if (lro->lro_mbuf_count & ~511) - fp->lro_cnt_512++; - else if (lro->lro_mbuf_count & ~255) - fp->lro_cnt_256++; - else if (lro->lro_mbuf_count & ~127) - fp->lro_cnt_128++; - else if (lro->lro_mbuf_count & ~63) - fp->lro_cnt_64++; - } - tcp_lro_flush_all(lro); + if (ha->dbg_trace_lro_cnt) { + if (lro->lro_mbuf_count & ~1023) + fp->lro_cnt_1024++; + else if (lro->lro_mbuf_count & ~511) + fp->lro_cnt_512++; + else if (lro->lro_mbuf_count & ~255) + fp->lro_cnt_256++; + else if (lro->lro_mbuf_count & ~127) + fp->lro_cnt_128++; + else if (lro->lro_mbuf_count & ~63) + fp->lro_cnt_64++; + } + tcp_lro_flush_all(lro); #else - struct lro_entry *queued; + struct lro_entry *queued; - while ((!SLIST_EMPTY(&lro->lro_active))) { - queued = SLIST_FIRST(&lro->lro_active); - SLIST_REMOVE_HEAD(&lro->lro_active, next); - tcp_lro_flush(lro, queued); - } -#endif /* #if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) */ + while ((!SLIST_EMPTY(&lro->lro_active))) { + queued = SLIST_FIRST(&lro->lro_active); + SLIST_REMOVE_HEAD(&lro->lro_active, next); + tcp_lro_flush(lro, queued); } +#endif /* #if (__FreeBSD_version >= 1100101) || (defined QLNX_QSORT_LRO) */ } + } #endif /* #ifdef QLNX_SOFT_LRO */ - ecore_sb_update_sb_idx(fp->sb_info); - rmb(); - } + ecore_sb_update_sb_idx(fp->sb_info); + rmb(); #endif /* #ifdef QLNX_RCV_IN_TASKQ */ - mtx_lock(&fp->tx_mtx); + if(ifp->if_drv_flags & IFF_DRV_RUNNING) { - if (((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != - IFF_DRV_RUNNING) || (!ha->link_up)) { + if (!drbr_empty(ifp, fp->tx_br)) { - mtx_unlock(&fp->tx_mtx); - goto qlnx_fp_taskqueue_exit; - } + if(mtx_trylock(&fp->tx_mtx)) { - mp = drbr_peek(ifp, fp->tx_br); +#ifdef QLNX_TRACE_PERF_DATA + tx_pkts = fp->tx_pkts_transmitted; + tx_compl = fp->tx_pkts_completed; +#endif - while (mp != NULL) { + qlnx_transmit_locked(ifp, fp, NULL); - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { - ret = qlnx_send(ha, fp, &mp); - } else { - ret = -1; - } - - if (ret) { - - if (mp != NULL) { - drbr_putback(ifp, fp->tx_br, mp); - } else { - fp->tx_pkts_processed++; - drbr_advance(ifp, fp->tx_br); +#ifdef QLNX_TRACE_PERF_DATA + fp->tx_pkts_trans_fp += + (fp->tx_pkts_transmitted - tx_pkts); + fp->tx_pkts_compl_fp += + (fp->tx_pkts_completed - tx_compl); +#endif + mtx_unlock(&fp->tx_mtx); } - - mtx_unlock(&fp->tx_mtx); - - goto qlnx_fp_taskqueue_exit; - - } else { - drbr_advance(ifp, fp->tx_br); - fp->tx_pkts_transmitted++; - fp->tx_pkts_processed++; } - - if (fp->tx_ring_full) - break; - - mp = drbr_peek(ifp, fp->tx_br); } - mtx_unlock(&fp->tx_mtx); - -qlnx_fp_taskqueue_exit: - #ifdef QLNX_RCV_IN_TASKQ if (rx_int) { if (fp->fp_taskqueue != NULL) @@ -537,7 +538,7 @@ qlnx_fp_taskqueue_exit: } #endif /* #ifdef QLNX_RCV_IN_TASKQ */ - QL_DPRINT2(ha, "exit ret = %d\n", ret); + QL_DPRINT2(ha, "exit \n"); return; } @@ -611,6 +612,17 @@ qlnx_drain_fp_taskqueues(qlnx_host_t *ha) return; } +static void +qlnx_get_params(qlnx_host_t *ha) +{ + if ((qlnxe_queue_count < 0) || (qlnxe_queue_count > QLNX_MAX_RSS)) { + device_printf(ha->pci_dev, "invalid queue_count value (%d)\n", + qlnxe_queue_count); + qlnxe_queue_count = 0; + } + return; +} + /* * Name: qlnx_pci_attach * Function: attaches the device to the operating system @@ -706,10 +718,21 @@ qlnx_pci_attach(device_t dev) if (qlnx_init_hw(ha) != 0) goto qlnx_pci_attach_err; + qlnx_get_params(ha); + + if((pci_get_device(dev) == QLOGIC_PCI_DEVICE_ID_1644) && + (qlnxe_queue_count == QLNX_DEFAULT_RSS)) { + qlnxe_queue_count = QLNX_MAX_RSS; + } + /* * Allocate MSI-x vectors */ - ha->num_rss = QLNX_MAX_RSS; + if(qlnxe_queue_count == 0) + ha->num_rss = QLNX_DEFAULT_RSS; + else + ha->num_rss = qlnxe_queue_count; + ha->num_tc = QLNX_MAX_TC; ha->msix_count = pci_msix_count(dev); @@ -1236,6 +1259,44 @@ qlnx_add_fp_stats_sysctls(qlnx_host_t *ha) CTLFLAG_RD, &ha->fp_array[i].tx_pkts_completed, "No. of transmit completions"); + SYSCTL_ADD_QUAD(ctx, node_children, + OID_AUTO, "tx_non_tso_pkts", + CTLFLAG_RD, &ha->fp_array[i].tx_non_tso_pkts, + "No. of non LSO transmited packets"); + +#ifdef QLNX_TRACE_PERF_DATA + + SYSCTL_ADD_QUAD(ctx, node_children, + OID_AUTO, "tx_pkts_trans_ctx", + CTLFLAG_RD, &ha->fp_array[i].tx_pkts_trans_ctx, + "No. of transmitted packets in transmit context"); + + SYSCTL_ADD_QUAD(ctx, node_children, + OID_AUTO, "tx_pkts_compl_ctx", + CTLFLAG_RD, &ha->fp_array[i].tx_pkts_compl_ctx, + "No. of transmit completions in transmit context"); + + SYSCTL_ADD_QUAD(ctx, node_children, + OID_AUTO, "tx_pkts_trans_fp", + CTLFLAG_RD, &ha->fp_array[i].tx_pkts_trans_fp, + "No. of transmitted packets in taskqueue"); + + SYSCTL_ADD_QUAD(ctx, node_children, + OID_AUTO, "tx_pkts_compl_fp", + CTLFLAG_RD, &ha->fp_array[i].tx_pkts_compl_fp, + "No. of transmit completions in taskqueue"); + + SYSCTL_ADD_QUAD(ctx, node_children, + OID_AUTO, "tx_pkts_compl_intr", + CTLFLAG_RD, &ha->fp_array[i].tx_pkts_compl_intr, + "No. of transmit completions in interrupt ctx"); +#endif + + SYSCTL_ADD_QUAD(ctx, node_children, + OID_AUTO, "tx_tso_pkts", + CTLFLAG_RD, &ha->fp_array[i].tx_tso_pkts, + "No. of LSO transmited packets"); + SYSCTL_ADD_QUAD(ctx, node_children, OID_AUTO, "tx_lso_wnd_min_len", CTLFLAG_RD, &ha->fp_array[i].tx_lso_wnd_min_len, @@ -1284,6 +1345,39 @@ qlnx_add_fp_stats_sysctls(qlnx_host_t *ha) &ha->fp_array[i].tx_pkts[j], name_str); } +#ifdef QLNX_TRACE_PERF_DATA + for (j = 0; j < 18; j++) { + + bzero(name_str, (sizeof(uint8_t) * sizeof(name_str))); + snprintf(name_str, sizeof(name_str), + "tx_pkts_hist_%02d", (j+1)); + + SYSCTL_ADD_QUAD(ctx, node_children, + OID_AUTO, name_str, CTLFLAG_RD, + &ha->fp_array[i].tx_pkts_hist[j], name_str); + } + for (j = 0; j < 5; j++) { + + bzero(name_str, (sizeof(uint8_t) * sizeof(name_str))); + snprintf(name_str, sizeof(name_str), + "tx_comInt_%02d", (j+1)); + + SYSCTL_ADD_QUAD(ctx, node_children, + OID_AUTO, name_str, CTLFLAG_RD, + &ha->fp_array[i].tx_comInt[j], name_str); + } + for (j = 0; j < 18; j++) { + + bzero(name_str, (sizeof(uint8_t) * sizeof(name_str))); + snprintf(name_str, sizeof(name_str), + "tx_pkts_q_%02d", (j+1)); + + SYSCTL_ADD_QUAD(ctx, node_children, + OID_AUTO, name_str, CTLFLAG_RD, + &ha->fp_array[i].tx_pkts_q[j], name_str); + } +#endif + SYSCTL_ADD_QUAD(ctx, node_children, OID_AUTO, "err_tx_nsegs_gt_elem_left", CTLFLAG_RD, &ha->fp_array[i].err_tx_nsegs_gt_elem_left, @@ -1979,6 +2073,12 @@ qlnx_init_ifnet(device_t dev, qlnx_host_t *ha) ifp->if_capabilities |= IFCAP_TSO6; ifp->if_capabilities |= IFCAP_LRO; + ifp->if_hw_tsomax = QLNX_MAX_TSO_FRAME_SIZE - + (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); + ifp->if_hw_tsomaxsegcount = QLNX_MAX_SEGMENTS - 1 /* hdr */; + ifp->if_hw_tsomaxsegsize = QLNX_MAX_TX_MBUF_SIZE; + + ifp->if_capenable = ifp->if_capabilities; ifp->if_hwassist = CSUM_IP; @@ -2543,6 +2643,7 @@ qlnx_tx_int(qlnx_host_t *ha, struct qlnx_fastpath *fp, u16 hw_bd_cons; u16 ecore_cons_idx; uint16_t diff; + uint16_t idx, idx2; hw_bd_cons = le16toh(*txq->hw_cons_ptr); @@ -2580,6 +2681,11 @@ qlnx_tx_int(qlnx_host_t *ha, struct qlnx_fastpath *fp, qlnx_trigger_dump(ha); } + idx = (txq->sw_tx_cons + 1) & (TX_RING_SIZE - 1); + idx2 = (txq->sw_tx_cons + 2) & (TX_RING_SIZE - 1); + prefetch(txq->sw_tx_ring[idx].mp); + prefetch(txq->sw_tx_ring[idx2].mp); + qlnx_free_tx_pkt(ha, fp, txq); txq->sw_tx_cons = (txq->sw_tx_cons + 1) & (TX_RING_SIZE - 1); @@ -2588,12 +2694,71 @@ qlnx_tx_int(qlnx_host_t *ha, struct qlnx_fastpath *fp, } static int +qlnx_transmit_locked(struct ifnet *ifp,struct qlnx_fastpath *fp, struct mbuf *mp) +{ + int ret = 0; + struct qlnx_tx_queue *txq; + qlnx_host_t * ha; + uint16_t elem_left; + + txq = fp->txq[0]; + ha = (qlnx_host_t *)fp->edev; + + + if ((!(ifp->if_drv_flags & IFF_DRV_RUNNING)) || (!ha->link_up)) { + if(mp != NULL) + ret = drbr_enqueue(ifp, fp->tx_br, mp); + return (ret); + } + + if(mp != NULL) + ret = drbr_enqueue(ifp, fp->tx_br, mp); + + mp = drbr_peek(ifp, fp->tx_br); + + while (mp != NULL) { + + if (qlnx_send(ha, fp, &mp)) { + + if (mp != NULL) { + drbr_putback(ifp, fp->tx_br, mp); + } else { + fp->tx_pkts_processed++; + drbr_advance(ifp, fp->tx_br); + } + goto qlnx_transmit_locked_exit; + + } else { + drbr_advance(ifp, fp->tx_br); + fp->tx_pkts_transmitted++; + fp->tx_pkts_processed++; + } + + mp = drbr_peek(ifp, fp->tx_br); + } + +qlnx_transmit_locked_exit: + if((qlnx_num_tx_compl(ha,fp, fp->txq[0]) > QLNX_TX_COMPL_THRESH) || + ((int)(elem_left = ecore_chain_get_elem_left(&txq->tx_pbl)) + < QLNX_TX_ELEM_MAX_THRESH)) + (void)qlnx_tx_int(ha, fp, fp->txq[0]); + + QL_DPRINT2(ha, "%s: exit ret = %d\n", __func__, ret); + return ret; +} + + +static int qlnx_transmit(struct ifnet *ifp, struct mbuf *mp) { qlnx_host_t *ha = (qlnx_host_t *)ifp->if_softc; struct qlnx_fastpath *fp; int rss_id = 0, ret = 0; +#ifdef QLNX_TRACEPERF_DATA + uint64_t tx_pkts = 0, tx_compl = 0; +#endif + QL_DPRINT2(ha, "enter\n"); #if __FreeBSD_version >= 1100000 @@ -2611,15 +2776,27 @@ qlnx_transmit(struct ifnet *ifp, struct mbuf *mp) goto qlnx_transmit_exit; } - if (mp != NULL) { - ret = drbr_enqueue(ifp, fp->tx_br, mp); - } + if (mtx_trylock(&fp->tx_mtx)) { - if (fp->fp_taskqueue != NULL) - taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task); +#ifdef QLNX_TRACEPERF_DATA + tx_pkts = fp->tx_pkts_transmitted; + tx_compl = fp->tx_pkts_completed; +#endif - ret = 0; + ret = qlnx_transmit_locked(ifp, fp, mp); +#ifdef QLNX_TRACEPERF_DATA + fp->tx_pkts_trans_ctx += (fp->tx_pkts_transmitted - tx_pkts); + fp->tx_pkts_compl_ctx += (fp->tx_pkts_completed - tx_compl); +#endif + mtx_unlock(&fp->tx_mtx); + } else { + if (mp != NULL && (fp->fp_taskqueue != NULL)) { + ret = drbr_enqueue(ifp, fp->tx_br, mp); + taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task); + } + } + qlnx_transmit_exit: QL_DPRINT2(ha, "exit ret = %d\n", ret); @@ -2799,6 +2976,10 @@ qlnx_send(qlnx_host_t *ha, struct qlnx_fastpath *fp, s uint32_t nbds_in_hdr = 0; uint32_t offset = 0; +#ifdef QLNX_TRACE_PERF_DATA + uint16_t bd_used; +#endif + QL_DPRINT8(ha, "enter\n"); if (!ha->link_up) @@ -2811,15 +2992,15 @@ qlnx_send(qlnx_host_t *ha, struct qlnx_fastpath *fp, s txq = fp->txq[0]; - if (fp->tx_ring_full) { - elem_left = ecore_chain_get_elem_left(&txq->tx_pbl); + if ((int)(elem_left = ecore_chain_get_elem_left(&txq->tx_pbl)) < + QLNX_TX_ELEM_MIN_THRESH) { - if (elem_left < (TX_RING_SIZE >> 4)) - return (-1); - else - fp->tx_ring_full = 0; - } + fp->tx_nsegs_gt_elem_left++; + fp->err_tx_nsegs_gt_elem_left++; + return (ENOBUFS); + } + idx = txq->sw_tx_prod; map = txq->sw_tx_ring[idx].map; @@ -2829,14 +3010,18 @@ qlnx_send(qlnx_host_t *ha, struct qlnx_fastpath *fp, s BUS_DMA_NOWAIT); if (ha->dbg_trace_tso_pkt_len) { - if (!fp->tx_tso_min_pkt_len) { - fp->tx_tso_min_pkt_len = m_head->m_pkthdr.len; - fp->tx_tso_min_pkt_len = m_head->m_pkthdr.len; - } else { - if (fp->tx_tso_min_pkt_len > m_head->m_pkthdr.len) + if (m_head->m_pkthdr.csum_flags & CSUM_TSO) { + if (!fp->tx_tso_min_pkt_len) { fp->tx_tso_min_pkt_len = m_head->m_pkthdr.len; - if (fp->tx_tso_max_pkt_len < m_head->m_pkthdr.len) - fp->tx_tso_max_pkt_len = m_head->m_pkthdr.len; + fp->tx_tso_min_pkt_len = m_head->m_pkthdr.len; + } else { + if (fp->tx_tso_min_pkt_len > m_head->m_pkthdr.len) + fp->tx_tso_min_pkt_len = + m_head->m_pkthdr.len; + if (fp->tx_tso_max_pkt_len < m_head->m_pkthdr.len) + fp->tx_tso_max_pkt_len = + m_head->m_pkthdr.len; + } } } @@ -2923,6 +3108,105 @@ qlnx_send(qlnx_host_t *ha, struct qlnx_fastpath *fp, s fp->tx_pkts[(QLNX_FP_MAX_SEGS - 1)]++; } +#ifdef QLNX_TRACE_PERF_DATA + if (m_head->m_pkthdr.csum_flags & CSUM_TSO) { + if(m_head->m_pkthdr.len <= 2048) + fp->tx_pkts_hist[0]++; + else if((m_head->m_pkthdr.len > 2048) && + (m_head->m_pkthdr.len <= 4096)) + fp->tx_pkts_hist[1]++; + else if((m_head->m_pkthdr.len > 4096) && + (m_head->m_pkthdr.len <= 8192)) + fp->tx_pkts_hist[2]++; + else if((m_head->m_pkthdr.len > 8192) && + (m_head->m_pkthdr.len <= 12288 )) + fp->tx_pkts_hist[3]++; + else if((m_head->m_pkthdr.len > 11288) && + (m_head->m_pkthdr.len <= 16394)) + fp->tx_pkts_hist[4]++; + else if((m_head->m_pkthdr.len > 16384) && + (m_head->m_pkthdr.len <= 20480)) + fp->tx_pkts_hist[5]++; + else if((m_head->m_pkthdr.len > 20480) && + (m_head->m_pkthdr.len <= 24576)) + fp->tx_pkts_hist[6]++; + else if((m_head->m_pkthdr.len > 24576) && + (m_head->m_pkthdr.len <= 28672)) + fp->tx_pkts_hist[7]++; + else if((m_head->m_pkthdr.len > 28762) && + (m_head->m_pkthdr.len <= 32768)) + fp->tx_pkts_hist[8]++; + else if((m_head->m_pkthdr.len > 32768) && + (m_head->m_pkthdr.len <= 36864)) + fp->tx_pkts_hist[9]++; + else if((m_head->m_pkthdr.len > 36864) && + (m_head->m_pkthdr.len <= 40960)) + fp->tx_pkts_hist[10]++; + else if((m_head->m_pkthdr.len > 40960) && + (m_head->m_pkthdr.len <= 45056)) + fp->tx_pkts_hist[11]++; + else if((m_head->m_pkthdr.len > 45056) && + (m_head->m_pkthdr.len <= 49152)) + fp->tx_pkts_hist[12]++; + else if((m_head->m_pkthdr.len > 49512) && + m_head->m_pkthdr.len <= 53248)) + fp->tx_pkts_hist[13]++; + else if((m_head->m_pkthdr.len > 53248) && + (m_head->m_pkthdr.len <= 57344)) + fp->tx_pkts_hist[14]++; + else if((m_head->m_pkthdr.len > 53248) && + (m_head->m_pkthdr.len <= 57344)) + fp->tx_pkts_hist[15]++; + else if((m_head->m_pkthdr.len > 57344) && + (m_head->m_pkthdr.len <= 61440)) + fp->tx_pkts_hist[16]++; + else + fp->tx_pkts_hist[17]++; + } + + if (m_head->m_pkthdr.csum_flags & CSUM_TSO) { + + elem_left = ecore_chain_get_elem_left(&txq->tx_pbl); + bd_used = TX_RING_SIZE - elem_left; + + if(bd_used <= 100) + fp->tx_pkts_q[0]++; + else if((bd_used > 100) && (bd_used <= 500)) + fp->tx_pkts_q[1]++; + else if((bd_used > 500) && (bd_used <= 1000)) + fp->tx_pkts_q[2]++; + else if((bd_used > 1000) && (bd_used <= 2000)) + fp->tx_pkts_q[3]++; + else if((bd_used > 3000) && (bd_used <= 4000)) + fp->tx_pkts_q[4]++; + else if((bd_used > 4000) && (bd_used <= 5000)) + fp->tx_pkts_q[5]++; + else if((bd_used > 6000) && (bd_used <= 7000)) + fp->tx_pkts_q[6]++; + else if((bd_used > 7000) && (bd_used <= 8000)) + fp->tx_pkts_q[7]++; + else if((bd_used > 8000) && (bd_used <= 9000)) + fp->tx_pkts_q[8]++; + else if((bd_used > 9000) && (bd_used <= 10000)) + fp->tx_pkts_q[9]++; + else if((bd_used > 10000) && (bd_used <= 11000)) + fp->tx_pkts_q[10]++; + else if((bd_used > 11000) && (bd_used <= 12000)) + fp->tx_pkts_q[11]++; + else if((bd_used > 12000) && (bd_used <= 13000)) + fp->tx_pkts_q[12]++; + else if((bd_used > 13000) && (bd_used <= 14000)) + fp->tx_pkts_q[13]++; + else if((bd_used > 14000) && (bd_used <= 15000)) + fp->tx_pkts_q[14]++; + else if((bd_used > 15000) && (bd_used <= 16000)) + fp->tx_pkts_q[15]++; + else + fp->tx_pkts_q[16]++; + } + +#endif /* end of QLNX_TRACE_PERF_DATA */ + if ((nsegs + QLNX_TX_ELEM_RESERVE) > (int)(elem_left = ecore_chain_get_elem_left(&txq->tx_pbl))) { @@ -2943,7 +3227,8 @@ qlnx_send(qlnx_host_t *ha, struct qlnx_fastpath *fp, s fp->err_tx_nsegs_gt_elem_left++; fp->tx_ring_full = 1; - ha->storm_stats_enable = 1; + if (ha->storm_stats_enable) + ha->storm_stats_gather = 1; return (ENOBUFS); } } @@ -3131,6 +3416,7 @@ qlnx_send(qlnx_host_t *ha, struct qlnx_fastpath *fp, s third_bd->data.bitfields |= (nbds_in_hdr<tx_tso_pkts++; } else { segs++; for (seg_idx = 1; seg_idx < nsegs; seg_idx++) { @@ -3147,6 +3433,7 @@ qlnx_send(qlnx_host_t *ha, struct qlnx_fastpath *fp, s << ETH_TX_DATA_1ST_BD_PKT_LEN_SHIFT; first_bd->data.bitfields = htole16(first_bd->data.bitfields); + fp->tx_non_tso_pkts++; } @@ -4303,8 +4590,10 @@ qlnx_fp_isr(void *arg) if (fp->fp_taskqueue != NULL) taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task); #else - int rx_int = 0, total_rx_count = 0; - int lro_enable, tc; + int rx_int = 0, total_rx_count = 0; + int lro_enable, tc; + struct qlnx_tx_queue *txq; + uint16_t elem_left; lro_enable = ha->ifp->if_capenable & IFCAP_LRO; @@ -4312,10 +4601,36 @@ qlnx_fp_isr(void *arg) do { for (tc = 0; tc < ha->num_tc; tc++) { - if (mtx_trylock(&fp->tx_mtx)) { - qlnx_tx_int(ha, fp, fp->txq[tc]); - mtx_unlock(&fp->tx_mtx); - } + + txq = fp->txq[tc]; + + if((int)(elem_left = + ecore_chain_get_elem_left(&txq->tx_pbl)) < + QLNX_TX_ELEM_THRESH) { + + if (mtx_trylock(&fp->tx_mtx)) { +#ifdef QLNX_TRACE_PERF_DATA + tx_compl = fp->tx_pkts_completed; +#endif + + qlnx_tx_int(ha, fp, fp->txq[tc]); +#ifdef QLNX_TRACE_PERF_DATA + fp->tx_pkts_compl_intr += + (fp->tx_pkts_completed - tx_compl); + if ((fp->tx_pkts_completed - tx_compl) <= 32) + fp->tx_comInt[0]++; + else if (((fp->tx_pkts_completed - tx_compl) > 32) && + ((fp->tx_pkts_completed - tx_compl) <= 64)) + fp->tx_comInt[1]++; + else if(((fp->tx_pkts_completed - tx_compl) > 64) && + ((fp->tx_pkts_completed - tx_compl) <= 128)) + fp->tx_comInt[2]++; + else if(((fp->tx_pkts_completed - tx_compl) > 128)) + fp->tx_comInt[3]++; +#endif + mtx_unlock(&fp->tx_mtx); + } + } } rx_int = qlnx_rx_int(ha, fp, ha->rx_pkt_threshold, @@ -4328,7 +4643,6 @@ qlnx_fp_isr(void *arg) } while (rx_int); - #ifdef QLNX_SOFT_LRO { struct lro_ctrl *lro; @@ -4608,8 +4922,8 @@ qlnx_alloc_tx_dma_tag(qlnx_host_t *ha) NULL, NULL, /* filter, filterarg */ QLNX_MAX_TSO_FRAME_SIZE, /* maxsize */ QLNX_MAX_SEGMENTS, /* nsegments */ - (PAGE_SIZE * 4), /* maxsegsize */ - BUS_DMA_ALLOCNOW, /* flags */ + QLNX_MAX_TX_MBUF_SIZE, /* maxsegsize */ + 0, /* flags */ NULL, /* lockfunc */ NULL, /* lockfuncarg */ &ha->tx_tag)) { @@ -4642,7 +4956,7 @@ qlnx_alloc_rx_dma_tag(qlnx_host_t *ha) MJUM9BYTES, /* maxsize */ 1, /* nsegments */ MJUM9BYTES, /* maxsegsize */ - BUS_DMA_ALLOCNOW, /* flags */ + 0, /* flags */ NULL, /* lockfunc */ NULL, /* lockfuncarg */ &ha->rx_tag)) { @@ -5255,6 +5569,14 @@ qlnx_init_fp(qlnx_host_t *ha) fp->tx_pkts_freed = 0; fp->tx_pkts_transmitted = 0; fp->tx_pkts_completed = 0; + +#ifdef QLNX_TRACE_PERF_DATA + fp->tx_pkts_trans_ctx = 0; + fp->tx_pkts_compl_ctx = 0; + fp->tx_pkts_trans_fp = 0; + fp->tx_pkts_compl_fp = 0; + fp->tx_pkts_compl_intr = 0; +#endif fp->tx_lso_wnd_min_len = 0; fp->tx_defrag = 0; fp->tx_nsegs_gt_elem_left = 0; @@ -6606,7 +6928,7 @@ qlnx_timer(void *arg) ecore_get_vport_stats(&ha->cdev, &ha->hw_stats); - if (ha->storm_stats_enable) + if (ha->storm_stats_gather) qlnx_sample_storm_stats(ha); callout_reset(&ha->qlnx_callout, hz, qlnx_timer, ha); @@ -6855,7 +7177,7 @@ qlnx_sample_storm_stats(qlnx_host_t *ha) struct ecore_hwfn *hwfn; if (ha->storm_stats_index >= QLNX_STORM_STATS_SAMPLES_PER_HWFN) { - ha->storm_stats_enable = 0; + ha->storm_stats_gather = 0; return; } Modified: stable/10/sys/dev/qlnx/qlnxe/qlnx_ver.h ============================================================================== --- stable/10/sys/dev/qlnx/qlnxe/qlnx_ver.h Thu Aug 24 22:11:10 2017 (r322863) +++ stable/10/sys/dev/qlnx/qlnxe/qlnx_ver.h Thu Aug 24 22:33:42 2017 (r322864) @@ -39,5 +39,5 @@ #define QLNX_VERSION_MAJOR 1 #define QLNX_VERSION_MINOR 4 -#define QLNX_VERSION_BUILD 6 +#define QLNX_VERSION_BUILD 7 Modified: stable/10/sys/modules/qlnx/qlnxe/Makefile ============================================================================== --- stable/10/sys/modules/qlnx/qlnxe/Makefile Thu Aug 24 22:11:10 2017 (r322863) +++ stable/10/sys/modules/qlnx/qlnxe/Makefile Thu Aug 24 22:33:42 2017 (r322864) @@ -52,7 +52,7 @@ SRCS+= pci_if.h CWARNEXTRA += -Wno-cast-qual -CFLAGS += -DQLNX_DEBUG +#CFLAGS += -DQLNX_DEBUG CFLAGS += -DECORE_PACKAGE CFLAGS += -DCONFIG_ECORE_L2 CFLAGS += -DECORE_CONFIG_DIRECT_HWFN From owner-svn-src-stable@freebsd.org Fri Aug 25 00:11:30 2017 Return-Path: Delivered-To: svn-src-stable@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 3F455DEB349; Fri, 25 Aug 2017 00:11:30 +0000 (UTC) (envelope-from marius@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 0BC136B7B1; Fri, 25 Aug 2017 00:11:29 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7P0BTMo061948; Fri, 25 Aug 2017 00:11:29 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7P0BTHr061947; Fri, 25 Aug 2017 00:11:29 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201708250011.v7P0BTHr061947@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Fri, 25 Aug 2017 00:11:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r322867 - stable/10/sys/conf X-SVN-Group: stable-10 X-SVN-Commit-Author: marius X-SVN-Commit-Paths: stable/10/sys/conf X-SVN-Commit-Revision: 322867 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2017 00:11:30 -0000 Author: marius Date: Fri Aug 25 00:11:29 2017 New Revision: 322867 URL: https://svnweb.freebsd.org/changeset/base/322867 Log: Update stable/10 to BETA2 in preparation for 10.4-BETA2 builds. Approved by: re (implicit) Modified: stable/10/sys/conf/newvers.sh Modified: stable/10/sys/conf/newvers.sh ============================================================================== --- stable/10/sys/conf/newvers.sh Thu Aug 24 23:08:12 2017 (r322866) +++ stable/10/sys/conf/newvers.sh Fri Aug 25 00:11:29 2017 (r322867) @@ -32,7 +32,7 @@ TYPE="FreeBSD" REVISION="10.4" -BRANCH="BETA1" +BRANCH="BETA2" if [ "X${BRANCH_OVERRIDE}" != "X" ]; then BRANCH=${BRANCH_OVERRIDE} fi From owner-svn-src-stable@freebsd.org Fri Aug 25 04:00:14 2017 Return-Path: Delivered-To: svn-src-stable@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 8552ADEEB20; Fri, 25 Aug 2017 04:00:14 +0000 (UTC) (envelope-from asomers@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 519DF71A02; Fri, 25 Aug 2017 04:00:14 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7P40DFn052371; Fri, 25 Aug 2017 04:00:13 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7P40DnW052370; Fri, 25 Aug 2017 04:00:13 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201708250400.v7P40DnW052370@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 25 Aug 2017 04:00: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: r322873 - stable/11/bin/echo/tests X-SVN-Group: stable-11 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: stable/11/bin/echo/tests X-SVN-Commit-Revision: 322873 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2017 04:00:14 -0000 Author: asomers Date: Fri Aug 25 04:00:13 2017 New Revision: 322873 URL: https://svnweb.freebsd.org/changeset/base/322873 Log: MFC r320269: style fixes in bin/echo/tests Submitted by: shivansh Reviewed by: asomers X-MFC-With: 319626 Sponsored by: Google, Inc (GSoC 2017) Differential Revision: https://reviews.freebsd.org/D11318 Modified: stable/11/bin/echo/tests/echo_test.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/bin/echo/tests/echo_test.sh ============================================================================== --- stable/11/bin/echo/tests/echo_test.sh Fri Aug 25 03:15:18 2017 (r322872) +++ stable/11/bin/echo/tests/echo_test.sh Fri Aug 25 04:00:13 2017 (r322873) @@ -27,29 +27,33 @@ # atf_test_case n_output -n_output_head() { - atf_set "descr" "Verify that echo(1) does not print the trailing " \ - "newline character with option '-n'" +n_output_head() +{ + atf_set "descr" "Verify that echo(1) does not print the trailing " \ + "newline character with option '-n'" } -n_output_body() { - atf_check -s ignore -o inline:"Hello world" \ - /bin/echo -n "Hello world" +n_output_body() +{ + atf_check -s ignore -o inline:"Hello world" \ + /bin/echo -n "Hello world" } atf_test_case append_c_output -append_c_output_head() { - atf_set "descr" "Verify that echo(1) does not print the trailing newline " \ - "character when '\c' is appended to the end of the string" +append_c_output_head() +{ + atf_set "descr" "Verify that echo(1) does not print the trailing newline " \ + "character when '\c' is appended to the end of the string" } -append_c_output_body() { - atf_check -s ignore -o inline:"Hello world" \ - /bin/echo "Hello world\c" +append_c_output_body() +{ + atf_check -s ignore -o inline:"Hello world" \ + /bin/echo "Hello world\c" } atf_init_test_cases() { - atf_add_test_case n_output - atf_add_test_case append_c_output + atf_add_test_case n_output + atf_add_test_case append_c_output } From owner-svn-src-stable@freebsd.org Fri Aug 25 05:41:29 2017 Return-Path: Delivered-To: svn-src-stable@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 A4DD1DF02E0; Fri, 25 Aug 2017 05:41:29 +0000 (UTC) (envelope-from jkim@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 6E8A673E07; Fri, 25 Aug 2017 05:41:29 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7P5fSx6094236; Fri, 25 Aug 2017 05:41:28 GMT (envelope-from jkim@FreeBSD.org) Received: (from jkim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7P5fSCV094235; Fri, 25 Aug 2017 05:41:28 GMT (envelope-from jkim@FreeBSD.org) Message-Id: <201708250541.v7P5fSCV094235@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jkim set sender to jkim@FreeBSD.org using -f From: Jung-uk Kim Date: Fri, 25 Aug 2017 05:41: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: r322876 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: jkim X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 322876 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2017 05:41:29 -0000 Author: jkim Date: Fri Aug 25 05:41:28 2017 New Revision: 322876 URL: https://svnweb.freebsd.org/changeset/base/322876 Log: MFC: r322803 Fix size to copyout(9) for cpuset_getid(2). Modified: stable/11/sys/kern/kern_cpuset.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_cpuset.c ============================================================================== --- stable/11/sys/kern/kern_cpuset.c Fri Aug 25 04:33:06 2017 (r322875) +++ stable/11/sys/kern/kern_cpuset.c Fri Aug 25 05:41:28 2017 (r322876) @@ -1063,7 +1063,7 @@ kern_cpuset_getid(struct thread *td, cpulevel_t level, tmpid = set->cs_id; cpuset_rel(set); if (error == 0) - error = copyout(&tmpid, setid, sizeof(id)); + error = copyout(&tmpid, setid, sizeof(tmpid)); return (error); } From owner-svn-src-stable@freebsd.org Fri Aug 25 05:49:39 2017 Return-Path: Delivered-To: svn-src-stable@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 EAF2ADF0394; Fri, 25 Aug 2017 05:49:39 +0000 (UTC) (envelope-from jkim@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 93368740EE; Fri, 25 Aug 2017 05:49:39 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7P5ncDX096892; Fri, 25 Aug 2017 05:49:38 GMT (envelope-from jkim@FreeBSD.org) Received: (from jkim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7P5nb2P096879; Fri, 25 Aug 2017 05:49:37 GMT (envelope-from jkim@FreeBSD.org) Message-Id: <201708250549.v7P5nb2P096879@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jkim set sender to jkim@FreeBSD.org using -f From: Jung-uk Kim Date: Fri, 25 Aug 2017 05: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: r322877 - in stable/11: sys/conf sys/contrib/dev/acpica sys/contrib/dev/acpica/common sys/contrib/dev/acpica/compiler sys/contrib/dev/acpica/components/debugger sys/contrib/dev/acpica/c... X-SVN-Group: stable-11 X-SVN-Commit-Author: jkim X-SVN-Commit-Paths: in stable/11: sys/conf sys/contrib/dev/acpica sys/contrib/dev/acpica/common sys/contrib/dev/acpica/compiler sys/contrib/dev/acpica/components/debugger sys/contrib/dev/acpica/components/disassembler sy... X-SVN-Commit-Revision: 322877 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2017 05:49:40 -0000 Author: jkim Date: Fri Aug 25 05:49:37 2017 New Revision: 322877 URL: https://svnweb.freebsd.org/changeset/base/322877 Log: MFC: r319365, r321670 Merge ACPICA 20170728. Added: stable/11/sys/contrib/dev/acpica/common/dmswitch.c - copied unchanged from r319365, head/sys/contrib/dev/acpica/common/dmswitch.c stable/11/sys/contrib/dev/acpica/compiler/aslparseop.c - copied unchanged from r321670, head/sys/contrib/dev/acpica/compiler/aslparseop.c stable/11/sys/contrib/dev/acpica/components/dispatcher/dspkginit.c - copied unchanged from r321670, head/sys/contrib/dev/acpica/components/dispatcher/dspkginit.c stable/11/sys/contrib/dev/acpica/components/utilities/utresdecode.c - copied unchanged from r319365, head/sys/contrib/dev/acpica/components/utilities/utresdecode.c Modified: stable/11/sys/conf/files stable/11/sys/contrib/dev/acpica/changes.txt stable/11/sys/contrib/dev/acpica/common/acfileio.c stable/11/sys/contrib/dev/acpica/common/adfile.c stable/11/sys/contrib/dev/acpica/common/adisasm.c stable/11/sys/contrib/dev/acpica/common/adwalk.c stable/11/sys/contrib/dev/acpica/common/ahids.c stable/11/sys/contrib/dev/acpica/common/ahpredef.c stable/11/sys/contrib/dev/acpica/common/ahtable.c stable/11/sys/contrib/dev/acpica/common/ahuuids.c stable/11/sys/contrib/dev/acpica/common/dmextern.c stable/11/sys/contrib/dev/acpica/common/dmrestag.c stable/11/sys/contrib/dev/acpica/common/dmtable.c stable/11/sys/contrib/dev/acpica/common/dmtbdump.c stable/11/sys/contrib/dev/acpica/common/dmtbinfo.c stable/11/sys/contrib/dev/acpica/compiler/aslanalyze.c stable/11/sys/contrib/dev/acpica/compiler/aslascii.c stable/11/sys/contrib/dev/acpica/compiler/aslbtypes.c stable/11/sys/contrib/dev/acpica/compiler/aslcodegen.c stable/11/sys/contrib/dev/acpica/compiler/aslcompile.c stable/11/sys/contrib/dev/acpica/compiler/aslcompiler.h stable/11/sys/contrib/dev/acpica/compiler/aslcompiler.l stable/11/sys/contrib/dev/acpica/compiler/aslcstyle.y stable/11/sys/contrib/dev/acpica/compiler/asldefine.h stable/11/sys/contrib/dev/acpica/compiler/aslerror.c stable/11/sys/contrib/dev/acpica/compiler/aslexternal.c stable/11/sys/contrib/dev/acpica/compiler/aslfold.c stable/11/sys/contrib/dev/acpica/compiler/aslglobal.h stable/11/sys/contrib/dev/acpica/compiler/aslhelp.c stable/11/sys/contrib/dev/acpica/compiler/aslhelpers.y stable/11/sys/contrib/dev/acpica/compiler/aslkeywords.y stable/11/sys/contrib/dev/acpica/compiler/asllength.c stable/11/sys/contrib/dev/acpica/compiler/asllisting.c stable/11/sys/contrib/dev/acpica/compiler/aslload.c stable/11/sys/contrib/dev/acpica/compiler/asllookup.c stable/11/sys/contrib/dev/acpica/compiler/aslmain.c stable/11/sys/contrib/dev/acpica/compiler/aslmap.c stable/11/sys/contrib/dev/acpica/compiler/aslmapoutput.c stable/11/sys/contrib/dev/acpica/compiler/aslmessages.c stable/11/sys/contrib/dev/acpica/compiler/aslmessages.h stable/11/sys/contrib/dev/acpica/compiler/aslmethod.c stable/11/sys/contrib/dev/acpica/compiler/asloffset.c stable/11/sys/contrib/dev/acpica/compiler/aslopcodes.c stable/11/sys/contrib/dev/acpica/compiler/aslopt.c stable/11/sys/contrib/dev/acpica/compiler/asloptions.c stable/11/sys/contrib/dev/acpica/compiler/aslparser.y stable/11/sys/contrib/dev/acpica/compiler/aslpld.c stable/11/sys/contrib/dev/acpica/compiler/aslpredef.c stable/11/sys/contrib/dev/acpica/compiler/aslprimaries.y stable/11/sys/contrib/dev/acpica/compiler/aslprintf.c stable/11/sys/contrib/dev/acpica/compiler/aslresource.c stable/11/sys/contrib/dev/acpica/compiler/aslresources.y stable/11/sys/contrib/dev/acpica/compiler/aslrestype2s.c stable/11/sys/contrib/dev/acpica/compiler/aslrules.y stable/11/sys/contrib/dev/acpica/compiler/aslstartup.c stable/11/sys/contrib/dev/acpica/compiler/aslsupport.l stable/11/sys/contrib/dev/acpica/compiler/aslsupport.y stable/11/sys/contrib/dev/acpica/compiler/asltokens.y stable/11/sys/contrib/dev/acpica/compiler/asltransform.c stable/11/sys/contrib/dev/acpica/compiler/asltree.c stable/11/sys/contrib/dev/acpica/compiler/asltypes.h stable/11/sys/contrib/dev/acpica/compiler/asltypes.y stable/11/sys/contrib/dev/acpica/compiler/aslutils.c stable/11/sys/contrib/dev/acpica/compiler/aslwalks.c stable/11/sys/contrib/dev/acpica/compiler/aslxref.c stable/11/sys/contrib/dev/acpica/compiler/cvcompiler.c stable/11/sys/contrib/dev/acpica/compiler/cvdisasm.c stable/11/sys/contrib/dev/acpica/compiler/cvparser.c stable/11/sys/contrib/dev/acpica/compiler/dtcompile.c stable/11/sys/contrib/dev/acpica/compiler/dtcompiler.h stable/11/sys/contrib/dev/acpica/compiler/dtfield.c stable/11/sys/contrib/dev/acpica/compiler/dttable1.c stable/11/sys/contrib/dev/acpica/compiler/dttable2.c stable/11/sys/contrib/dev/acpica/compiler/dttemplate.h stable/11/sys/contrib/dev/acpica/compiler/dtutils.c stable/11/sys/contrib/dev/acpica/compiler/prmacros.c stable/11/sys/contrib/dev/acpica/components/debugger/dbdisply.c stable/11/sys/contrib/dev/acpica/components/debugger/dbexec.c stable/11/sys/contrib/dev/acpica/components/debugger/dbobject.c stable/11/sys/contrib/dev/acpica/components/debugger/dbxface.c stable/11/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c stable/11/sys/contrib/dev/acpica/components/disassembler/dmdeferred.c stable/11/sys/contrib/dev/acpica/components/disassembler/dmopcode.c stable/11/sys/contrib/dev/acpica/components/disassembler/dmresrc.c stable/11/sys/contrib/dev/acpica/components/disassembler/dmresrcl2.c stable/11/sys/contrib/dev/acpica/components/disassembler/dmwalk.c stable/11/sys/contrib/dev/acpica/components/dispatcher/dsargs.c stable/11/sys/contrib/dev/acpica/components/dispatcher/dsdebug.c stable/11/sys/contrib/dev/acpica/components/dispatcher/dsfield.c stable/11/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c stable/11/sys/contrib/dev/acpica/components/dispatcher/dsobject.c stable/11/sys/contrib/dev/acpica/components/dispatcher/dsopcode.c stable/11/sys/contrib/dev/acpica/components/dispatcher/dsutils.c stable/11/sys/contrib/dev/acpica/components/dispatcher/dswexec.c stable/11/sys/contrib/dev/acpica/components/dispatcher/dswload.c stable/11/sys/contrib/dev/acpica/components/dispatcher/dswload2.c stable/11/sys/contrib/dev/acpica/components/events/evxfevnt.c stable/11/sys/contrib/dev/acpica/components/executer/excreate.c stable/11/sys/contrib/dev/acpica/components/executer/exdebug.c stable/11/sys/contrib/dev/acpica/components/executer/exdump.c stable/11/sys/contrib/dev/acpica/components/executer/exmisc.c stable/11/sys/contrib/dev/acpica/components/executer/exoparg1.c stable/11/sys/contrib/dev/acpica/components/executer/exoparg2.c stable/11/sys/contrib/dev/acpica/components/executer/exresolv.c stable/11/sys/contrib/dev/acpica/components/hardware/hwregs.c stable/11/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c stable/11/sys/contrib/dev/acpica/components/namespace/nsaccess.c stable/11/sys/contrib/dev/acpica/components/namespace/nsarguments.c stable/11/sys/contrib/dev/acpica/components/namespace/nsinit.c stable/11/sys/contrib/dev/acpica/components/namespace/nsnames.c stable/11/sys/contrib/dev/acpica/components/namespace/nsprepkg.c stable/11/sys/contrib/dev/acpica/components/namespace/nsutils.c stable/11/sys/contrib/dev/acpica/components/namespace/nsxfeval.c stable/11/sys/contrib/dev/acpica/components/parser/psloop.c stable/11/sys/contrib/dev/acpica/components/parser/psobject.c stable/11/sys/contrib/dev/acpica/components/parser/psopcode.c stable/11/sys/contrib/dev/acpica/components/parser/psparse.c stable/11/sys/contrib/dev/acpica/components/resources/rscalc.c stable/11/sys/contrib/dev/acpica/components/resources/rsdump.c stable/11/sys/contrib/dev/acpica/components/resources/rsdumpinfo.c stable/11/sys/contrib/dev/acpica/components/resources/rsinfo.c stable/11/sys/contrib/dev/acpica/components/resources/rsmisc.c stable/11/sys/contrib/dev/acpica/components/resources/rsserial.c stable/11/sys/contrib/dev/acpica/components/resources/rsxface.c stable/11/sys/contrib/dev/acpica/components/tables/tbdata.c stable/11/sys/contrib/dev/acpica/components/tables/tbfadt.c stable/11/sys/contrib/dev/acpica/components/tables/tbinstal.c stable/11/sys/contrib/dev/acpica/components/tables/tbutils.c stable/11/sys/contrib/dev/acpica/components/tables/tbxface.c stable/11/sys/contrib/dev/acpica/components/tables/tbxfload.c stable/11/sys/contrib/dev/acpica/components/utilities/utdecode.c stable/11/sys/contrib/dev/acpica/components/utilities/uthex.c stable/11/sys/contrib/dev/acpica/components/utilities/utmath.c stable/11/sys/contrib/dev/acpica/components/utilities/utmisc.c stable/11/sys/contrib/dev/acpica/components/utilities/utobject.c stable/11/sys/contrib/dev/acpica/components/utilities/utownerid.c stable/11/sys/contrib/dev/acpica/components/utilities/utresrc.c stable/11/sys/contrib/dev/acpica/components/utilities/utstate.c stable/11/sys/contrib/dev/acpica/components/utilities/utstrtoul64.c stable/11/sys/contrib/dev/acpica/components/utilities/uttrack.c stable/11/sys/contrib/dev/acpica/components/utilities/utxfmutex.c stable/11/sys/contrib/dev/acpica/include/acapps.h stable/11/sys/contrib/dev/acpica/include/acdisasm.h stable/11/sys/contrib/dev/acpica/include/acdispat.h stable/11/sys/contrib/dev/acpica/include/acglobal.h stable/11/sys/contrib/dev/acpica/include/aclocal.h stable/11/sys/contrib/dev/acpica/include/acnames.h stable/11/sys/contrib/dev/acpica/include/acobject.h stable/11/sys/contrib/dev/acpica/include/acopcode.h stable/11/sys/contrib/dev/acpica/include/acpi.h stable/11/sys/contrib/dev/acpica/include/acpixf.h stable/11/sys/contrib/dev/acpica/include/acpredef.h stable/11/sys/contrib/dev/acpica/include/acresrc.h stable/11/sys/contrib/dev/acpica/include/acrestyp.h stable/11/sys/contrib/dev/acpica/include/actables.h stable/11/sys/contrib/dev/acpica/include/actbl.h stable/11/sys/contrib/dev/acpica/include/actbl1.h stable/11/sys/contrib/dev/acpica/include/actbl2.h stable/11/sys/contrib/dev/acpica/include/actbl3.h stable/11/sys/contrib/dev/acpica/include/actypes.h stable/11/sys/contrib/dev/acpica/include/acutils.h stable/11/sys/contrib/dev/acpica/include/acuuid.h stable/11/sys/contrib/dev/acpica/include/amlcode.h stable/11/sys/contrib/dev/acpica/include/amlresrc.h stable/11/sys/contrib/dev/acpica/include/platform/acenv.h stable/11/sys/contrib/dev/acpica/include/platform/acfreebsd.h stable/11/sys/contrib/dev/acpica/include/platform/acgcc.h stable/11/sys/contrib/dev/acpica/os_specific/service_layers/osunixxf.c stable/11/sys/dev/acpica/acpi.c stable/11/usr.sbin/acpi/acpidb/Makefile stable/11/usr.sbin/acpi/iasl/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/conf/files ============================================================================== --- stable/11/sys/conf/files Fri Aug 25 05:41:28 2017 (r322876) +++ stable/11/sys/conf/files Fri Aug 25 05:49:37 2017 (r322877) @@ -340,6 +340,7 @@ contrib/dev/acpica/components/dispatcher/dsmethod.c op contrib/dev/acpica/components/dispatcher/dsmthdat.c optional acpi contrib/dev/acpica/components/dispatcher/dsobject.c optional acpi contrib/dev/acpica/components/dispatcher/dsopcode.c optional acpi +contrib/dev/acpica/components/dispatcher/dspkginit.c optional acpi contrib/dev/acpica/components/dispatcher/dsutils.c optional acpi contrib/dev/acpica/components/dispatcher/dswexec.c optional acpi contrib/dev/acpica/components/dispatcher/dswload.c optional acpi @@ -477,6 +478,7 @@ contrib/dev/acpica/components/utilities/utobject.c opt contrib/dev/acpica/components/utilities/utosi.c optional acpi contrib/dev/acpica/components/utilities/utownerid.c optional acpi contrib/dev/acpica/components/utilities/utpredef.c optional acpi +contrib/dev/acpica/components/utilities/utresdecode.c optional acpi acpi_debug contrib/dev/acpica/components/utilities/utresrc.c optional acpi contrib/dev/acpica/components/utilities/utstate.c optional acpi contrib/dev/acpica/components/utilities/utstring.c optional acpi Modified: stable/11/sys/contrib/dev/acpica/changes.txt ============================================================================== --- stable/11/sys/contrib/dev/acpica/changes.txt Fri Aug 25 05:41:28 2017 (r322876) +++ stable/11/sys/contrib/dev/acpica/changes.txt Fri Aug 25 05:49:37 2017 (r322877) @@ -1,4 +1,286 @@ ---------------------------------------- +28 July 2017. Summary of changes for version 20170728: + + +1) ACPICA kernel-resident subsystem: + +Fixed a regression seen with small resource descriptors that could cause +an inadvertent AE_AML_NO_RESOURCE_END_TAG exception. + +AML interpreter: Implemented a new feature that allows forward references +from individual named references within package objects that are +contained within blocks of "module-level code". This provides +compatibility with other ACPI implementations and supports existing +firmware that depends on this feature. Example: + + Name (ABCD, 1) + If (ABCD) /* An If() at module-level */ + { + Name (PKG1, Package() + { + INT1 /* Forward reference to object INT1 +*/ + }) + Name (INT1, 0x1234) + } + +AML Interpreter: Fixed a problem with the Alias() operator where aliases +to some ASL objects were not handled properly. Objects affected are: +Mutex, Event, and OperationRegion. + +AML Debugger: Enhanced to properly handle AML Alias objects. These +objects have one level of indirection which was not fully supported by +the debugger. + +Table Manager: Added support to detect and ignore duplicate SSDTs within +the XSDT/RSDT. This error in the XSDT has been seen in the field. + +EFI and EDK2 support: + Enabled /WX flag for MSVC builds + Added support for AcpiOsStall, AcpiOsSleep, and AcpiOsGetTimer + Added local support for 64-bit multiply and shift operations + Added support to compile acpidump.efi on Windows + Added OSL function stubs for interfaces not used under EFI + +Added additional support for the _DMA predefined name. _DMA returns a +buffer containing a resource template. This change add support within the +resource manager (AcpiWalkResourceBuffer) to walk and parse this list of +resource descriptors. Lorenzo Pieralisi + + +2) iASL Compiler/Disassembler and Tools: + +iASL: Fixed a problem where the internal input line buffer(s) could +overflow if there are very long lines in the input ASL source code file. +Implemented buffer management that automatically increases the size of +the buffers as necessary. + +iASL: Added an option (-vx) to "expect" particular remarks, warnings and +errors. If the specified exception is not raised during compilation, the +compiler emits an error. This is intended to support the ASL test suite, +but may be useful in other contexts. + +iASL: Implemented a new predefined macro, __METHOD__, which returns a +string containing the name of the current control method that is being +compiled. + +iASL: Implemented debugger and table compiler support for the SDEI ACPI +table (Software Delegated Exception Interface). James Morse + + +Unix/Linux makefiles: Added an option to disable compile optimizations. +The disable occurs when the NOOPT flag is set to TRUE. +theracermaster@gmail.com + +Acpidump: Added support for multiple DSDT and FACS tables. This can occur +when there are different tables for 32-bit versus 64-bit. + +Enhanced error reporting for the ASL test suite (ASLTS) by removing +unnecessary/verbose text, and emit the actual line number where an error +has occurred. These changes are intended to improve the usefulness of the +test suite. + +---------------------------------------- +29 June 2017. Summary of changes for version 20170629: + + +1) ACPICA kernel-resident subsystem: + +Tables: Implemented a deferred ACPI table verification. This is useful +for operating systems where the tables cannot be verified in the early +initialization stage due to early memory mapping limitations on some +architectures. Lv Zheng. + +Tables: Removed the signature validation for dynamically loaded tables. +Provides compatibility with other ACPI implementations. Previously, only +SSDT tables were allowed, as per the ACPI specification. Now, any table +signature can be used via the Load() operator. Lv Zheng. + +Tables: Fixed several mutex issues that could cause errors during table +acquisition. Lv Zheng. + +Tables: Fixed a problem where an ACPI warning could be generated if a +null pointer was passed to the AcpiPutTable interface. Lv Zheng. + +Tables: Added a mechanism to handle imbalances for the AcpiGetTable and +AcpiPutTable interfaces. This applies to the "late stage" table loading +when the use of AcpiPutTable is no longer required (since the system +memory manager is fully running and available). Lv Zheng. + +Fixed/Reverted a regression during processing of resource descriptors +that contain only a single EndTag. Fixes an AE_AML_NO_RESOURCE_END_TAG +exception in this case. + +Headers: IORT/SMMU support: Updated the SMMU models for Revision C of the +I/O Remapping specification. Robin Murphy + +Interpreter: Fixed a possible fault if an Alias operator with an invalid +or duplicate target is encountered during Alias creation in +AcpiExCreateAlias. Alex James + +Added an option to use designated initializers for function pointers. +Kees Cook + + +2) iASL Compiler/Disassembler and Tools: + +iASL: Allow compilation of External declarations with target pathnames +that refer to existing named objects within the table. Erik Schmauss. + +iASL: Fixed a regression when compiling FieldUnits. Fixes an error if a +FieldUnit name also is declared via External in the same table. Erik +Schmauss. + +iASL: Allow existing scope names within pathnames used in External +statements. For example: + External (ABCD.EFGH) // ABCD exists, but EFGH is truly external + Device (ABCD) + +iASL: IORT ACPI table: Implemented changes required to decode the new +Proximity Domain for the SMMUv3 IORT. Disassembler and Data Table +compiler. Ganapatrao Kulkarni + +Disassembler: Don't abort disassembly on errors from External() +statements. Erik Schmauss. + +Disassembler: fixed a possible fault when one of the Create*Field +operators references a Resource Template. ACPICA Bugzilla 1396. + +iASL: In the source code, resolved some naming inconsistences across the +parsing support. Fixes confusion between "Parse Op" and "Parse Node". +Adds a new file, aslparseop.c + +---------------------------------------- +31 May 2017. Summary of changes for version 20170531: + + +0) ACPI 6.2 support: + +The ACPI specification version 6.2 has been released and is available at +http://uefi.org/specifications + +This version of ACPICA fully supports the ACPI 6.2 specification. Changes +are summarized below. + +New ACPI tables (Table Compiler/Disassembler/Templates): + HMAT (Heterogeneous Memory Attributes Table) + WSMT (Windows SMM Security Mitigation Table) + PPTT (Processor Properties Topology Table) + +New subtables for existing ACPI tables: + HEST (New subtable, Arch-deferred machine check) + SRAT (New subtable, Arch-specific affinity structure) + PCCT (New subtables, Extended PCC subspaces (types 3 and 4)) + +Simple updates for existing ACPI tables: + BGRT (two new flag bits) + HEST (New bit defined for several subtables, GHES_ASSIST) + +New Resource Descriptors and Resource macros (Compiler/Disassembler): + PinConfig() + PinFunction() + PinGroup() + PinGroupConfig() + PinGroupFunction() + New type for hardware error notification (section 18.3.2.9) + +New predefined names/methods (Compiler/Interpreter): + _HMA (Heterogeneous Memory Attributes) + _LSI (Label Storage Information) + _LSR (Label Storage Read) + _LSW (Label Storage Write) + +ASL grammar/macro changes (Compiler): + For() ASL macro, implemented with the AML while operator + Extensions to Concatenate operator + Support for multiple definition blocks in same ASL file + Clarification for Buffer operator + Allow executable AML code underneath all scopes (Devices, etc.) + Clarification/change for the _OSI return value + ASL grammar update for reference operators + Allow a zero-length string for AML filename in DefinitionBlock + +Miscellaneous: + New device object notification value + Remove a notify value (0x0C) for graceful shutdown + New UUIDs for processor/cache properties and + physical package property + New _HID, ACPI0014 (Wireless Power Calibration Device) + + +1) ACPICA kernel-resident subsystem: + +Added support to disable ACPI events on hardware-reduced platforms. +Eliminates error messages of the form "Could not enable fixed event". Lv +Zheng + +Fixed a problem using Device/Thermal objects with the ObjectType and +DerefOf ASL operators. This support had not been fully/properly +implemented. + +Fixed a problem where if a Buffer object containing a resource template +was longer than the actual resource template, an error was generated -- +even though the AML is legal. This case has been seen in the field. + +Fixed a problem with the header definition of the MADT PCAT_COMPAT flag. +The values for DUAL_PIC and MULTIPLE_APIC were reversed. + +Added header file changes for the TPM2 ACPI table. Update to new version +of the TCG specification. Adds a new TPM2 subtable for ARM SMC. + +Exported the external interfaces AcpiAcquireMutex and AcpiReleaseMutex. +These interfaces are intended to be used only in conjunction with the +predefined _DLM method (Device Lock Method). "This object appears in a +device scope when AML access to the device must be synchronized with the +OS environment". + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and +has a much larger code and data size. + + Current Release: + Non-Debug Version: 143.1K Code, 60.0K Data, 203.1K Total + Debug Version: 204.0K Code, 84.3K Data, 288.3K Total + Previous Release: + Non-Debug Version: 141.7K Code, 58.5K Data, 200.2K Total + Debug Version: 207.5K Code, 82.7K Data, 290.2K Total + + +2) iASL Compiler/Disassembler and Tools: + +iASL: Fixed a problem where an External() declaration could not refer to +a Field Unit. Erik Schmauss. + +Disassembler: Improved support for the Switch/Case operators. This +feature will disassemble AML code back to the original Switch operators +when possible, instead of an If..Else sequence. David Box + +iASL and disassembler: Improved the handling of multiple extraneous +parentheses for both ASL input and disassembled ASL output. + +Improved the behavior of the iASL compiler and disassembler to detect +improper use of external declarations + +Disassembler: Now aborts immediately upon detection of an unknown AML +opcode. The AML parser has no real way to recover from this, and can +result in the creation of an ill-formed parse tree that causes errors +later during the disassembly. + +All tools: Fixed a problem where the Unix application OSL did not handle +control-c correctly. For example, a control-c could incorrectly wake the +debugger. + +AcpiExec: Improved the Control-C handling and added a handler for +segmentation faults (SIGSEGV). Supports both Windows and Unix-like +environments. + +Reduced the verbosity of the generic unix makefiles. Previously, each +compilation displayed the full set of compiler options. This has been +eliminated as the options are easily inspected within the makefiles. Each +compilation now results in a single line of output. + +---------------------------------------- 03 March 2017. Summary of changes for version 20170303: Modified: stable/11/sys/contrib/dev/acpica/common/acfileio.c ============================================================================== --- stable/11/sys/contrib/dev/acpica/common/acfileio.c Fri Aug 25 05:41:28 2017 (r322876) +++ stable/11/sys/contrib/dev/acpica/common/acfileio.c Fri Aug 25 05:49:37 2017 (r322877) @@ -175,6 +175,36 @@ AcCheckTextModeCorruption ( /******************************************************************************* * + * FUNCTION: AcDeleteTableList + * + * PARAMETERS: ListHead - List to delete + * + * RETURN: Status + * + * DESCRIPTION: Delete a list of tables. This is useful for removing memory + * allocated by AcGetAllTablesFromFile + * + ******************************************************************************/ + +void +AcDeleteTableList ( + ACPI_NEW_TABLE_DESC *ListHead) +{ + ACPI_NEW_TABLE_DESC *Current = ListHead; + ACPI_NEW_TABLE_DESC *Previous = Current; + + + while (Current) + { + Current = Current->Next; + AcpiOsFree (Previous); + Previous = Current; + } +} + + +/******************************************************************************* + * * FUNCTION: AcGetAllTablesFromFile * * PARAMETERS: Filename - Table filename @@ -531,8 +561,6 @@ AcValidateTableHeader ( if (!AcpiUtValidNameseg (TableHeader.Signature)) { - fprintf (stderr, "Invalid table signature: 0x%8.8X\n", - *ACPI_CAST_PTR (UINT32, TableHeader.Signature)); return (AE_BAD_SIGNATURE); } Modified: stable/11/sys/contrib/dev/acpica/common/adfile.c ============================================================================== --- stable/11/sys/contrib/dev/acpica/common/adfile.c Fri Aug 25 05:41:28 2017 (r322876) +++ stable/11/sys/contrib/dev/acpica/common/adfile.c Fri Aug 25 05:49:37 2017 (r322877) @@ -316,11 +316,6 @@ FlGenerateFilename ( */ NewFilename = UtStringCacheCalloc ((ACPI_SIZE) strlen (InputFilename) + strlen (Suffix) + 2); - if (!NewFilename) - { - return (NULL); - } - strcpy (NewFilename, InputFilename); /* Try to find the last dot in the filename */ @@ -364,11 +359,6 @@ FlStrdup ( NewString = UtStringCacheCalloc ((ACPI_SIZE) strlen (String) + 1); - if (!NewString) - { - return (NULL); - } - strcpy (NewString, String); return (NewString); } Modified: stable/11/sys/contrib/dev/acpica/common/adisasm.c ============================================================================== --- stable/11/sys/contrib/dev/acpica/common/adisasm.c Fri Aug 25 05:41:28 2017 (r322876) +++ stable/11/sys/contrib/dev/acpica/common/adisasm.c Fri Aug 25 05:49:37 2017 (r322877) @@ -408,6 +408,8 @@ Cleanup: ACPI_FREE (Table); } + AcDeleteTableList (ListHead); + if (File) { fclose (File); @@ -537,7 +539,7 @@ AdDisassembleOneTable ( * the entire tree with the new information (namely, the * number of arguments per method) */ - if (AcpiDmGetExternalMethodCount ()) + if (AcpiDmGetUnresolvedExternalMethodCount ()) { Status = AdReparseOneTable (Table, File, OwnerId); if (ACPI_FAILURE (Status)) @@ -553,7 +555,7 @@ AdDisassembleOneTable ( * 1) Convert fixed-offset references to resource descriptors * to symbolic references (Note: modifies namespace) */ - AcpiDmConvertResourceIndexes (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode); + AcpiDmConvertParseObjects (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode); /* Optional displays */ @@ -616,7 +618,7 @@ AdReparseOneTable ( fprintf (stderr, "\nFound %u external control methods, " "reparsing with new information\n", - AcpiDmGetExternalMethodCount ()); + AcpiDmGetUnresolvedExternalMethodCount ()); /* Reparse, rebuild namespace */ @@ -642,7 +644,7 @@ AdReparseOneTable ( /* New namespace, add the external definitions first */ - AcpiDmAddExternalsToNamespace (); + AcpiDmAddExternalListToNamespace (); /* For -ca option: clear the list of comment addresses. */ @@ -748,6 +750,7 @@ AdDoExternalFileList ( continue; } + AcDeleteTableList (ExternalListHead); return (Status); } @@ -761,6 +764,7 @@ AdDoExternalFileList ( { AcpiOsPrintf ("Could not parse external ACPI tables, %s\n", AcpiFormatException (Status)); + AcDeleteTableList (ExternalListHead); return (Status); } @@ -779,6 +783,8 @@ AdDoExternalFileList ( ExternalFileList = ExternalFileList->Next; } + + AcDeleteTableList (ExternalListHead); if (ACPI_FAILURE (GlobalStatus)) { Modified: stable/11/sys/contrib/dev/acpica/common/adwalk.c ============================================================================== --- stable/11/sys/contrib/dev/acpica/common/adwalk.c Fri Aug 25 05:41:28 2017 (r322876) +++ stable/11/sys/contrib/dev/acpica/common/adwalk.c Fri Aug 25 05:49:37 2017 (r322877) @@ -208,11 +208,16 @@ AcpiDmInspectPossibleArgs ( ACPI_PARSE_OBJECT *Op); static ACPI_STATUS -AcpiDmResourceDescendingOp ( +AcpiDmCommonDescendingOp ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context); +static ACPI_STATUS +AcpiDmProcessResourceDescriptors ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); /******************************************************************************* * @@ -395,21 +400,21 @@ AcpiDmCrossReferenceNamespace ( /******************************************************************************* * - * FUNCTION: AcpiDmConvertResourceIndexes + * FUNCTION: AcpiDmConvertParseObjects * * PARAMETERS: ParseTreeRoot - Root of the parse tree * NamespaceRoot - Root of the internal namespace * * RETURN: None * - * DESCRIPTION: Convert fixed-offset references to resource descriptors to - * symbolic references. Should only be called after namespace has - * been cross referenced. + * DESCRIPTION: Begin parse tree walk to perform conversions needed for + * disassembly. These include resource descriptors and switch/case + * operations. * ******************************************************************************/ void -AcpiDmConvertResourceIndexes ( +AcpiDmConvertParseObjects ( ACPI_PARSE_OBJECT *ParseTreeRoot, ACPI_NAMESPACE_NODE *NamespaceRoot) { @@ -443,9 +448,14 @@ AcpiDmConvertResourceIndexes ( Info.Level = 0; Info.WalkState = WalkState; - AcpiDmWalkParseTree (ParseTreeRoot, AcpiDmResourceDescendingOp, + AcpiDmWalkParseTree (ParseTreeRoot, AcpiDmCommonDescendingOp, AcpiDmCommonAscendingOp, &Info); ACPI_FREE (WalkState); + + if (AcpiGbl_TempListHead) { + AcpiDmClearTempList(); + } + return; } @@ -526,11 +536,20 @@ AcpiDmDumpDescending ( case AML_NAME_OP: case AML_METHOD_OP: case AML_DEVICE_OP: + + AcpiOsPrintf ("%4.4s", + ACPI_CAST_PTR (char, &Op->Named.Name)); + break; + case AML_INT_NAMEDFIELD_OP: - AcpiOsPrintf ("%4.4s", ACPI_CAST_PTR (char, &Op->Named.Name)); + AcpiOsPrintf ("%4.4s Length: (bits) %8.8X%8.8X (bytes) %8.8X%8.8X", + ACPI_CAST_PTR (char, &Op->Named.Name), + ACPI_FORMAT_UINT64 (Op->Common.Value.Integer), + ACPI_FORMAT_UINT64 (Op->Common.Value.Integer / 8)); break; + default: break; @@ -737,7 +756,6 @@ AcpiDmLoadDescendingOp ( WalkState = Info->WalkState; OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); - ObjectType = OpInfo->ObjectType; ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); /* Only interested in operators that create new names */ @@ -754,7 +772,7 @@ AcpiDmLoadDescendingOp ( { /* For all named operators, get the new name */ - Path = (char *) Op->Named.Path; + Path = Op->Named.Path; if (!Path && Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP) { @@ -875,7 +893,6 @@ AcpiDmXrefDescendingOp ( WalkState = Info->WalkState; OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); - ObjectType = OpInfo->ObjectType; ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); if ((!(OpInfo->Flags & AML_NAMED)) && @@ -885,26 +902,7 @@ AcpiDmXrefDescendingOp ( { goto Exit; } - else if (Op->Common.Parent && - Op->Common.Parent->Common.AmlOpcode == AML_EXTERNAL_OP) - { - /* External() NamePath */ - Path = Op->Common.Value.String; - ObjectType = (ACPI_OBJECT_TYPE) Op->Common.Next->Common.Value.Integer; - if (ObjectType == ACPI_TYPE_METHOD) - { - ParamCount = (UINT32) - Op->Common.Next->Common.Next->Common.Value.Integer; - } - - Flags |= ACPI_EXT_RESOLVED_REFERENCE | ACPI_EXT_ORIGIN_FROM_OPCODE; - AcpiDmAddOpToExternalList (Op, Path, - (UINT8) ObjectType, ParamCount, Flags); - - goto Exit; - } - /* Get the NamePath from the appropriate place */ if (OpInfo->Flags & AML_NAMED) @@ -924,9 +922,10 @@ AcpiDmXrefDescendingOp ( Path = NextOp->Common.Value.String; } } - else if (Op->Common.AmlOpcode == AML_SCOPE_OP) + else if (Op->Common.AmlOpcode == AML_SCOPE_OP || + Op->Common.AmlOpcode == AML_EXTERNAL_OP) { - Path = (char *) Op->Named.Path; + Path = Op->Named.Path; } } else if (OpInfo->Flags & AML_CREATE) @@ -1060,21 +1059,58 @@ Exit: return (AE_OK); } +/******************************************************************************* + * + * FUNCTION: AcpiDmCommonDescendingOp + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: ACPI_STATUS + * + * DESCRIPTION: Perform parse tree preprocessing before main disassembly walk. + * + ******************************************************************************/ +static ACPI_STATUS +AcpiDmCommonDescendingOp ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + ACPI_STATUS Status; + + + /* Resource descriptor conversion */ + + Status = AcpiDmProcessResourceDescriptors (Op, Level, Context); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Switch/Case conversion */ + + Status = AcpiDmProcessSwitch (Op); + return (AE_OK); +} + + /******************************************************************************* * - * FUNCTION: AcpiDmResourceDescendingOp + * FUNCTION: AcpiDmProcessResourceDescriptors * * PARAMETERS: ASL_WALK_CALLBACK * - * RETURN: None + * RETURN: ACPI_STATUS * - * DESCRIPTION: Process one parse op during symbolic resource index conversion. + * DESCRIPTION: Convert fixed-offset references to resource descriptors to + * symbolic references. Should only be called after namespace has + * been cross referenced. * ******************************************************************************/ static ACPI_STATUS -AcpiDmResourceDescendingOp ( +AcpiDmProcessResourceDescriptors ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context) @@ -1114,7 +1150,6 @@ AcpiDmResourceDescendingOp ( return (AE_OK); } - /******************************************************************************* * * FUNCTION: AcpiDmCommonAscendingOp @@ -1135,14 +1170,11 @@ AcpiDmCommonAscendingOp ( void *Context) { ACPI_OP_WALK_INFO *Info = Context; - const ACPI_OPCODE_INFO *OpInfo; ACPI_OBJECT_TYPE ObjectType; /* Close scope if necessary */ - OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); - ObjectType = OpInfo->ObjectType; ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); if (AcpiNsOpensScope (ObjectType)) @@ -1152,7 +1184,6 @@ AcpiDmCommonAscendingOp ( return (AE_OK); } - /******************************************************************************* * Modified: stable/11/sys/contrib/dev/acpica/common/ahids.c ============================================================================== --- stable/11/sys/contrib/dev/acpica/common/ahids.c Fri Aug 25 05:41:28 2017 (r322876) +++ stable/11/sys/contrib/dev/acpica/common/ahids.c Fri Aug 25 05:49:37 2017 (r322877) @@ -187,6 +187,7 @@ const AH_DEVICE_ID AslDeviceIds[] = {"ACPI0011", "Generic Buttons Device"}, {"ACPI0012", "NVDIMM Root Device"}, {"ACPI0013", "Generic Event Device"}, + {"ACPI0014", "Wireless Power Calibration Device"}, {"ADMA0F28", "Intel Audio DMA"}, {"AMCR0F28", "Intel Audio Machine Driver"}, {"ATK4001", "Asus Radio Control Button"}, Modified: stable/11/sys/contrib/dev/acpica/common/ahpredef.c ============================================================================== --- stable/11/sys/contrib/dev/acpica/common/ahpredef.c Fri Aug 25 05:41:28 2017 (r322876) +++ stable/11/sys/contrib/dev/acpica/common/ahpredef.c Fri Aug 25 05:49:37 2017 (r322877) @@ -254,6 +254,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] = AH_PREDEF ("_FPS", "Fan Performance States", "Returns a list of supported fan performance states"), AH_PREDEF ("_FSL", "Fan Set Level", "Control method that sets the fan device's speed level (performance state)"), AH_PREDEF ("_FST", "Fan Status", "Returns current status information for a fan device"), + AH_PREDEF ("_FUN", "Function Number", "Resource descriptor field"), AH_PREDEF ("_GAI", "Get Averaging Interval", "Returns the power meter averaging interval"), AH_PREDEF ("_GCP", "Get Capabilities", "Get device time capabilities"), AH_PREDEF ("_GHL", "Get Hardware Limit", "Returns the hardware limit enforced by the power meter"), @@ -270,6 +271,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] = AH_PREDEF ("_GWS", "Get Wake Status", "Return status of wake alarms"), AH_PREDEF ("_HE_", "High-Edge", "Interrupt triggering, Resource Descriptor field"), AH_PREDEF ("_HID", "Hardware ID", "Returns a device's Plug and Play Hardware ID"), + AH_PREDEF ("_HMA", "Heterogeneous Memory Attributes", "Returns a list of HMAT structures."), AH_PREDEF ("_HOT", "Hot Temperature", "Returns the critical temperature for sleep (entry to S4)"), AH_PREDEF ("_HPP", "Hot Plug Parameters", "Returns a list of hot-plug information for a PCI device"), AH_PREDEF ("_HPX", "Hot Plug Parameter Extensions", "Returns a list of hot-plug information for a PCI device. Supersedes _HPP"), @@ -287,6 +289,9 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] = AH_PREDEF ("_LL_", "Low Level", "Interrupt polarity, Resource Descriptor field"), AH_PREDEF ("_LPD", "Low Power Dependencies", "Returns a list of dependencies for low power idle entry"), AH_PREDEF ("_LPI", "Low Power Idle States", "Returns a list of supported low power idle states"), + AH_PREDEF ("_LSI", "Label Storage Information", "Returns information about the Label Storage Area associated with the NVDIMM object."), + AH_PREDEF ("_LSR", "Label Storage Read", "Returns label data from the Label Storage Area of the NVDIMM object."), + AH_PREDEF ("_LSW", "Label Storage Write", "Writes label data in to the Label Storage Area of the NVDIMM object."), AH_PREDEF ("_MAF", "Maximum Address Fixed", "Resource Descriptor field"), AH_PREDEF ("_MAT", "Multiple APIC Table Entry", "Returns a list of MADT APIC structure entries"), AH_PREDEF ("_MAX", "Maximum Base Address", "Resource Descriptor field"), @@ -439,6 +444,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] = AH_PREDEF ("_UPC", "USB Port Capabilities", "Returns a list of USB port capabilities"), AH_PREDEF ("_UPD", "User Presence Detect", "Returns user detection information"), AH_PREDEF ("_UPP", "User Presence Polling", "Returns the recommended user presence polling interval"), + AH_PREDEF ("_VAL", "Pin Configuration Value", "Resource Descriptor field"), AH_PREDEF ("_VEN", "Vendor Data", "Resource Descriptor field"), AH_PREDEF ("_VPO", "Video Post Options", "Returns the implemented video post options"), AH_PREDEF ("_Wxx", "Wake Event", "Method executed as a result of a wake event"), @@ -467,6 +473,15 @@ AcpiAhMatchPredefinedName ( { const AH_PREDEFINED_NAME *Info; + + /* Nameseg must start with an underscore */ + + if (*Nameseg != '_') + { + return (NULL); + } + + /* Search for a match in the predefined name table */ for (Info = AslPredefinedInfo; Info->Name; Info++) { Modified: stable/11/sys/contrib/dev/acpica/common/ahtable.c ============================================================================== --- stable/11/sys/contrib/dev/acpica/common/ahtable.c Fri Aug 25 05:41:28 2017 (r322876) +++ stable/11/sys/contrib/dev/acpica/common/ahtable.c Fri Aug 25 05:49:37 2017 (r322877) @@ -218,6 +218,7 @@ const AH_TABLE Gbl_AcpiSupportedTables[] = {ACPI_SIG_FPDT, "Firmware Performance Data Table"}, {ACPI_SIG_GTDT, "Generic Timer Description Table"}, {ACPI_SIG_HEST, "Hardware Error Source Table"}, + {ACPI_SIG_HMAT, "Heterogeneous Memory Attributes Table"}, {ACPI_SIG_HPET, "High Precision Event Timer table"}, {ACPI_SIG_IORT, "IO Remapping Table"}, {ACPI_SIG_IVRS, "I/O Virtualization Reporting Structure"}, @@ -232,11 +233,13 @@ const AH_TABLE Gbl_AcpiSupportedTables[] = {ACPI_SIG_NFIT, "NVDIMM Firmware Interface Table"}, {ACPI_SIG_PCCT, "Platform Communications Channel Table"}, {ACPI_SIG_PMTT, "Platform Memory Topology Table"}, + {ACPI_SIG_PPTT, "Processor Properties Topology Table"}, {ACPI_SIG_RASF, "RAS Features Table"}, {ACPI_RSDP_NAME,"Root System Description Pointer"}, {ACPI_SIG_RSDT, "Root System Description Table"}, {ACPI_SIG_S3PT, "S3 Performance Table"}, {ACPI_SIG_SBST, "Smart Battery Specification Table"}, + {ACPI_SIG_SDEI, "Software Delegated Exception Interface Table"}, {ACPI_SIG_SLIC, "Software Licensing Description Table"}, {ACPI_SIG_SLIT, "System Locality Information Table"}, {ACPI_SIG_SPCR, "Serial Port Console Redirection table"}, @@ -253,6 +256,7 @@ const AH_TABLE Gbl_AcpiSupportedTables[] = {ACPI_SIG_WDDT, "Watchdog Description Table"}, {ACPI_SIG_WDRT, "Watchdog Resource Table"}, {ACPI_SIG_WPBT, "Windows Platform Binary Table"}, + {ACPI_SIG_WSMT, "Windows SMM Security Migrations Table"}, {ACPI_SIG_XENV, "Xen Environment table"}, {ACPI_SIG_XSDT, "Extended System Description Table"}, {NULL, NULL} Modified: stable/11/sys/contrib/dev/acpica/common/ahuuids.c ============================================================================== --- stable/11/sys/contrib/dev/acpica/common/ahuuids.c Fri Aug 25 05:41:28 2017 (r322876) +++ stable/11/sys/contrib/dev/acpica/common/ahuuids.c Fri Aug 25 05:49:37 2017 (r322877) @@ -186,6 +186,10 @@ const AH_UUID Gbl_AcpiUuids[] = {"Persistent Virtual Disk", UUID_PERSISTENT_VIRTUAL_DISK}, {"Persistent Virtual CD", UUID_PERSISTENT_VIRTUAL_CD}, + {"[Processor Properties]", NULL}, + {"Cache Properties", UUID_CACHE_PROPERTIES}, + {"Physical Package Property", UUID_PHYSICAL_PROPERTY}, + {"[Miscellaneous]", NULL}, {"Platform-wide Capabilities", UUID_PLATFORM_CAPABILITIES}, {"Dynamic Enumeration", UUID_DYNAMIC_ENUMERATION}, Modified: stable/11/sys/contrib/dev/acpica/common/dmextern.c ============================================================================== --- stable/11/sys/contrib/dev/acpica/common/dmextern.c Fri Aug 25 05:41:28 2017 (r322876) +++ stable/11/sys/contrib/dev/acpica/common/dmextern.c Fri Aug 25 05:49:37 2017 (r322877) @@ -199,7 +199,10 @@ static const char *AcpiGbl_DmTypeNames[] = #define METHOD_SEPARATORS " \t,()\n" +static const char *ExternalConflictMessage = + " // Conflicts with a later declaration"; + /* Local prototypes */ static const char * @@ -211,6 +214,16 @@ AcpiDmNormalizeParentPrefix ( ACPI_PARSE_OBJECT *Op, char *Path); +static ACPI_STATUS +AcpiDmGetExternalAndInternalPath ( + ACPI_NAMESPACE_NODE *Node, + char **ExternalPath, + char **InternalPath); + +static ACPI_STATUS +AcpiDmRemoveRootPrefix ( + char **Path); + static void AcpiDmAddPathToExternalList ( char *Path, @@ -226,7 +239,22 @@ AcpiDmCreateNewExternal ( UINT32 Value, UINT16 Flags); +static void +AcpiDmCheckForExternalConflict ( + char *Path); +static ACPI_STATUS +AcpiDmResolveExternal ( + char *Path, + UINT8 Type, + ACPI_NAMESPACE_NODE **Node); + + +static void +AcpiDmConflictingDeclaration ( + char *Path); + + /******************************************************************************* * * FUNCTION: AcpiDmGetObjectTypeName @@ -582,7 +610,7 @@ AcpiDmGetExternalsFromFile ( { /* Add the external(s) to the namespace */ - AcpiDmAddExternalsToNamespace (); + AcpiDmAddExternalListToNamespace (); AcpiOsPrintf ("%s: Imported %u external method definitions\n", Gbl_ExternalRefFilename, ImportCount); @@ -698,6 +726,86 @@ AcpiDmAddOpToExternalList ( /******************************************************************************* * + * FUNCTION: AcpiDmGetExternalAndInternalPath + * + * PARAMETERS: Node - Namespace node for object to be added + * ExternalPath - Will contain the external path of the node + * InternalPath - Will contain the internal path of the node + * + * RETURN: None + * + * DESCRIPTION: Get the External and Internal path from the given node. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDmGetExternalAndInternalPath ( + ACPI_NAMESPACE_NODE *Node, + char **ExternalPath, + char **InternalPath) +{ + ACPI_STATUS Status; + + + if (!Node) + { + return (AE_BAD_PARAMETER); + } + + /* Get the full external and internal pathnames to the node */ + + *ExternalPath = AcpiNsGetExternalPathname (Node); + if (!*ExternalPath) + { + return (AE_BAD_PATHNAME); + } + + Status = AcpiNsInternalizeName (*ExternalPath, InternalPath); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (*ExternalPath); + return (Status); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmRemoveRootPrefix + * + * PARAMETERS: Path - Remove Root prefix from this Path + * + * RETURN: None + * + * DESCRIPTION: Remove the root prefix character '\' from Path. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDmRemoveRootPrefix ( + char **Path) +{ + char *InputPath = *Path; + + + if ((*InputPath == AML_ROOT_PREFIX) && (InputPath[1])) + { + if (!memmove(InputPath, InputPath+1, strlen(InputPath))) + { + return (AE_ERROR); + } + + *Path = InputPath; + } + + return (AE_OK); +} + + +/******************************************************************************* + * * FUNCTION: AcpiDmAddNodeToExternalList * * PARAMETERS: Node - Namespace node for object to be added @@ -727,46 +835,27 @@ AcpiDmAddNodeToExternalList ( { char *ExternalPath; char *InternalPath; - char *Temp; ACPI_STATUS Status; ACPI_FUNCTION_TRACE (DmAddNodeToExternalList); - - if (!Node) - { - return_VOID; - } - /* Get the full external and internal pathnames to the node */ - ExternalPath = AcpiNsGetExternalPathname (Node); - if (!ExternalPath) - { - return_VOID; - } - - Status = AcpiNsInternalizeName (ExternalPath, &InternalPath); + Status = AcpiDmGetExternalAndInternalPath (Node, &ExternalPath, &InternalPath); if (ACPI_FAILURE (Status)) { - ACPI_FREE (ExternalPath); return_VOID; } /* Remove the root backslash */ - if ((*ExternalPath == AML_ROOT_PREFIX) && (ExternalPath[1])) + Status = AcpiDmRemoveRootPrefix (&ExternalPath); + if (ACPI_FAILURE (Status)) { - Temp = ACPI_ALLOCATE_ZEROED (strlen (ExternalPath) + 1); - if (!Temp) - { - return_VOID; - } - - strcpy (Temp, &ExternalPath[1]); ACPI_FREE (ExternalPath); - ExternalPath = Temp; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Fri Aug 25 07:42:50 2017 Return-Path: Delivered-To: svn-src-stable@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 282CBDF2267; Fri, 25 Aug 2017 07:42:50 +0000 (UTC) (envelope-from jkim@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 DDF2277423; Fri, 25 Aug 2017 07:42:49 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7P7gm1V044850; Fri, 25 Aug 2017 07:42:48 GMT (envelope-from jkim@FreeBSD.org) Received: (from jkim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7P7gmsT044849; Fri, 25 Aug 2017 07:42:48 GMT (envelope-from jkim@FreeBSD.org) Message-Id: <201708250742.v7P7gmsT044849@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jkim set sender to jkim@FreeBSD.org using -f From: Jung-uk Kim Date: Fri, 25 Aug 2017 07:42: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: r322879 - stable/11/usr.sbin/acpi/acpidump X-SVN-Group: stable-11 X-SVN-Commit-Author: jkim X-SVN-Commit-Paths: stable/11/usr.sbin/acpi/acpidump X-SVN-Commit-Revision: 322879 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2017 07:42:50 -0000 Author: jkim Date: Fri Aug 25 07:42:48 2017 New Revision: 322879 URL: https://svnweb.freebsd.org/changeset/base/322879 Log: MFC: r321601 (emaste) acpidump: add GIC ITS srat type Modified: stable/11/usr.sbin/acpi/acpidump/acpi.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/acpi/acpidump/acpi.c ============================================================================== --- stable/11/usr.sbin/acpi/acpidump/acpi.c Fri Aug 25 07:04:41 2017 (r322878) +++ stable/11/usr.sbin/acpi/acpidump/acpi.c Fri Aug 25 07:42:48 2017 (r322879) @@ -1115,7 +1115,8 @@ static const char *srat_types[] = { [ACPI_SRAT_TYPE_CPU_AFFINITY] = "CPU", [ACPI_SRAT_TYPE_MEMORY_AFFINITY] = "Memory", [ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY] = "X2APIC", - [ACPI_SRAT_TYPE_GICC_AFFINITY] = "GICC" + [ACPI_SRAT_TYPE_GICC_AFFINITY] = "GICC", + [ACPI_SRAT_TYPE_GIC_ITS_AFFINITY] = "GIC ITS", }; static void From owner-svn-src-stable@freebsd.org Fri Aug 25 07:49:53 2017 Return-Path: Delivered-To: svn-src-stable@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 17F2BDF25CE; Fri, 25 Aug 2017 07:49:53 +0000 (UTC) (envelope-from jkim@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 D8FDE77956; Fri, 25 Aug 2017 07:49:52 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7P7nqDS045189; Fri, 25 Aug 2017 07:49:52 GMT (envelope-from jkim@FreeBSD.org) Received: (from jkim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7P7nqpj045188; Fri, 25 Aug 2017 07:49:52 GMT (envelope-from jkim@FreeBSD.org) Message-Id: <201708250749.v7P7nqpj045188@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jkim set sender to jkim@FreeBSD.org using -f From: Jung-uk Kim Date: Fri, 25 Aug 2017 07:49: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: r322880 - stable/11/usr.sbin/acpi/acpiconf X-SVN-Group: stable-11 X-SVN-Commit-Author: jkim X-SVN-Commit-Paths: stable/11/usr.sbin/acpi/acpiconf X-SVN-Commit-Revision: 322880 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2017 07:49:53 -0000 Author: jkim Date: Fri Aug 25 07:49:51 2017 New Revision: 322880 URL: https://svnweb.freebsd.org/changeset/base/322880 Log: MFC: r316627 (kan) Use int to receive the return value of getopt function. Modified: stable/11/usr.sbin/acpi/acpiconf/acpiconf.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/acpi/acpiconf/acpiconf.c ============================================================================== --- stable/11/usr.sbin/acpi/acpiconf/acpiconf.c Fri Aug 25 07:42:48 2017 (r322879) +++ stable/11/usr.sbin/acpi/acpiconf/acpiconf.c Fri Aug 25 07:49:51 2017 (r322880) @@ -203,8 +203,8 @@ usage(const char* prog) int main(int argc, char *argv[]) { - char c, *prog; - int sleep_type; + char *prog; + int c, sleep_type; prog = argv[0]; if (argc < 2) From owner-svn-src-stable@freebsd.org Fri Aug 25 08:24:30 2017 Return-Path: Delivered-To: svn-src-stable@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 5AD72DCD10E; Fri, 25 Aug 2017 08:24:30 +0000 (UTC) (envelope-from araujo@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 280597CB16; Fri, 25 Aug 2017 08:24:30 +0000 (UTC) (envelope-from araujo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7P8OTXY061409; Fri, 25 Aug 2017 08:24:29 GMT (envelope-from araujo@FreeBSD.org) Received: (from araujo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7P8OT7j061408; Fri, 25 Aug 2017 08:24:29 GMT (envelope-from araujo@FreeBSD.org) Message-Id: <201708250824.v7P8OT7j061408@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: araujo set sender to araujo@FreeBSD.org using -f From: Marcelo Araujo Date: Fri, 25 Aug 2017 08:24: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: r322882 - stable/11/usr.sbin/ypldap X-SVN-Group: stable-11 X-SVN-Commit-Author: araujo X-SVN-Commit-Paths: stable/11/usr.sbin/ypldap X-SVN-Commit-Revision: 322882 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2017 08:24:30 -0000 Author: araujo Date: Fri Aug 25 08:24:29 2017 New Revision: 322882 URL: https://svnweb.freebsd.org/changeset/base/322882 Log: MFC r321846: Log when we have finished pushing users and groups. Obtained from: OpenBSD (rev 1.4) Modified: stable/11/usr.sbin/ypldap/entries.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/ypldap/entries.c ============================================================================== --- stable/11/usr.sbin/ypldap/entries.c Fri Aug 25 08:21:02 2017 (r322881) +++ stable/11/usr.sbin/ypldap/entries.c Fri Aug 25 08:24:29 2017 (r322882) @@ -92,6 +92,7 @@ flatten_entries(struct env *env) free(tmp); } env->sc_user_lines = linep; + log_debug("done pushing users"); wrlen = env->sc_group_line_len; if ((linep = calloc(1, env->sc_group_line_len + 1)) == NULL) { @@ -117,6 +118,7 @@ flatten_entries(struct env *env) wrlen -= len; } env->sc_group_lines = linep; + log_debug("done pushing groups"); } int From owner-svn-src-stable@freebsd.org Fri Aug 25 12:16:05 2017 Return-Path: Delivered-To: svn-src-stable@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 5ED3CDD7284; Fri, 25 Aug 2017 12:16:05 +0000 (UTC) (envelope-from asomers@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 3AF988326F; Fri, 25 Aug 2017 12:16:05 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7PCG4ES056782; Fri, 25 Aug 2017 12:16:04 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7PCG4lC056780; Fri, 25 Aug 2017 12:16:04 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201708251216.v7PCG4lC056780@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 25 Aug 2017 12:16:04 +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: r322887 - in stable/11: contrib/netbsd-tests/lib/libc/gen lib/libc/tests/gen X-SVN-Group: stable-11 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in stable/11: contrib/netbsd-tests/lib/libc/gen lib/libc/tests/gen X-SVN-Commit-Revision: 322887 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2017 12:16:05 -0000 Author: asomers Date: Fri Aug 25 12:16:03 2017 New Revision: 322887 URL: https://svnweb.freebsd.org/changeset/base/322887 Log: MFC r320737, r320914 r320737: Fix cleanup in lib/libc/gen/setdomainname_test ATF cleanup routines run in separate processes from the tests themselves, so they can't share global variables. Also, setdomainname_test needs to be is_exclusive because the test cases access a global resource. PR: 219967 Reviewed by: ngie Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D11188 r320914: Remove an extraneous strlen from t_setdomainname.c Reported by: Coverity CID: 1377568 X-MFC-With: 320737 Sponsored by: Spectra Logic Corp Modified: stable/11/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c stable/11/lib/libc/tests/gen/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c ============================================================================== --- stable/11/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c Fri Aug 25 11:24:45 2017 (r322886) +++ stable/11/contrib/netbsd-tests/lib/libc/gen/t_setdomainname.c Fri Aug 25 12:16:03 2017 (r322887) @@ -34,11 +34,13 @@ __RCSID("$NetBSD: t_setdomainname.c,v 1.2 2012/03/25 0 #include #include +#include #include +#include #include #include -static char domain[MAXHOSTNAMELEN]; +#define DOMAIN_BACKUP_FILE "domain.bak" static const char domains[][MAXHOSTNAMELEN] = { "1234567890", @@ -47,6 +49,45 @@ static const char domains[][MAXHOSTNAMELEN] = { "--------------------------------------------------------------------" }; +static void +backup_domain(void) +{ + char domain[MAXHOSTNAMELEN]; + int fd; + size_t l; + ssize_t r,n = 0; + + memset(domain, 0, sizeof(domain)); + + ATF_REQUIRE_EQ(0, getdomainname(domain, sizeof(domain))); + l = strnlen(domain, MAXHOSTNAMELEN); + fd = open(DOMAIN_BACKUP_FILE, O_WRONLY | O_CREAT | O_EXCL, 0644); + ATF_REQUIRE(fd >= 0); + while ((r = write(fd, domain + n, l - n)) > 0) + n += r; + ATF_REQUIRE_EQ(0, r); + close(fd); +} + +static void +restore_domain(void) +{ + char domain[MAXHOSTNAMELEN]; + int fd; + ssize_t r, n = 0; + + memset(domain, 0, sizeof(domain)); + if ((fd = open(DOMAIN_BACKUP_FILE, O_RDONLY)) < 0) + err(1, "open"); + while ((r = read(fd, domain + n, sizeof(domain) - n)) > 0) + n += r; + if (r < 0) + err(1, "read"); + if (setdomainname(domain, n) != 0) + err(1, "setdomainname"); + close(fd); +} + ATF_TC_WITH_CLEANUP(setdomainname_basic); ATF_TC_HEAD(setdomainname_basic, tc) { @@ -59,6 +100,7 @@ ATF_TC_BODY(setdomainname_basic, tc) char name[MAXHOSTNAMELEN]; size_t i; + backup_domain(); for (i = 0; i < __arraycount(domains); i++) { (void)memset(name, 0, sizeof(name)); @@ -80,12 +122,11 @@ ATF_TC_BODY(setdomainname_basic, tc) ATF_REQUIRE(strcmp(domains[i], name) == 0); } - (void)setdomainname(domain, sizeof(domain)); } ATF_TC_CLEANUP(setdomainname_basic, tc) { - (void)setdomainname(domain, sizeof(domain)); + restore_domain(); } ATF_TC_WITH_CLEANUP(setdomainname_limit); @@ -100,6 +141,7 @@ ATF_TC_BODY(setdomainname_limit, tc) char name[MAXHOSTNAMELEN + 1]; (void)memset(name, 0, sizeof(name)); + backup_domain(); #ifdef __FreeBSD__ ATF_REQUIRE(setdomainname(name, MAXHOSTNAMELEN - 1 ) == 0); @@ -110,10 +152,10 @@ ATF_TC_BODY(setdomainname_limit, tc) ATF_TC_CLEANUP(setdomainname_limit, tc) { - (void)setdomainname(domain, sizeof(domain)); + restore_domain(); } -ATF_TC_WITH_CLEANUP(setdomainname_perm); +ATF_TC(setdomainname_perm); ATF_TC_HEAD(setdomainname_perm, tc) { atf_tc_set_md_var(tc, "descr", "Can normal user set the domain name?"); @@ -122,24 +164,16 @@ ATF_TC_HEAD(setdomainname_perm, tc) ATF_TC_BODY(setdomainname_perm, tc) { + char domain[MAXHOSTNAMELEN]; - errno = 0; + memset(domain, 0, sizeof(domain)); + errno = 0; ATF_REQUIRE_ERRNO(EPERM, setdomainname(domain, sizeof(domain)) == -1); } -ATF_TC_CLEANUP(setdomainname_perm, tc) -{ - (void)setdomainname(domain, sizeof(domain)); -} - ATF_TP_ADD_TCS(tp) { - - (void)memset(domain, 0, sizeof(domain)); - - ATF_REQUIRE(getdomainname(domain, sizeof(domain)) == 0); - ATF_TP_ADD_TC(tp, setdomainname_basic); ATF_TP_ADD_TC(tp, setdomainname_limit); ATF_TP_ADD_TC(tp, setdomainname_perm); Modified: stable/11/lib/libc/tests/gen/Makefile ============================================================================== --- stable/11/lib/libc/tests/gen/Makefile Fri Aug 25 11:24:45 2017 (r322886) +++ stable/11/lib/libc/tests/gen/Makefile Fri Aug 25 12:16:03 2017 (r322887) @@ -71,6 +71,7 @@ CFLAGS+= -I${.CURDIR} SRCS.fmtcheck2_test= fmtcheck_test.c SRCS.fnmatch2_test= fnmatch_test.c +TEST_METADATA.setdomainname_test+= is_exclusive=true TESTS_SUBDIRS= execve TESTS_SUBDIRS+= posix_spawn From owner-svn-src-stable@freebsd.org Fri Aug 25 14:28:37 2017 Return-Path: Delivered-To: svn-src-stable@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 72C92DD99D1; Fri, 25 Aug 2017 14:28:37 +0000 (UTC) (envelope-from asomers@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 3E0BC31F1; Fri, 25 Aug 2017 14:28:37 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7PESaXD010921; Fri, 25 Aug 2017 14:28:36 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7PESao7010919; Fri, 25 Aug 2017 14:28:36 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201708251428.v7PESao7010919@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 25 Aug 2017 14:28:36 +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: r322889 - in stable/11: share/man/man4 usr.bin/stdbuf X-SVN-Group: stable-11 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in stable/11: share/man/man4 usr.bin/stdbuf X-SVN-Commit-Revision: 322889 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2017 14:28:37 -0000 Author: asomers Date: Fri Aug 25 14:28:36 2017 New Revision: 322889 URL: https://svnweb.freebsd.org/changeset/base/322889 Log: MFC r320807: stdbuf(1): Add buffer definition "B" to the usage message This option has been missing from the usage message ever since the program was first imported. Submitted by: shivansh Reviewed by: asomers Sponsored by: Google, Inc (GSoC 2017) Differential Revision: https://reviews.freebsd.org/D11529 Modified: stable/11/share/man/man4/aio.4 stable/11/usr.bin/stdbuf/stdbuf.c Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man4/aio.4 ============================================================================== --- stable/11/share/man/man4/aio.4 Fri Aug 25 12:28:34 2017 (r322888) +++ stable/11/share/man/man4/aio.4 Fri Aug 25 14:28:36 2017 (r322889) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 21, 2016 +.Dd June 22, 2017 .Dt AIO 4 .Os .Sh NAME @@ -161,11 +161,27 @@ field which can be used to request notification when a For .Dv SIGEV_KEVENT notifications, -the posted kevent will contain: +the +.Va sigevent +.Ap +s +.Va sigev_notify_kqueue +field should contain the descriptor of the kqueue that the event should be attached +to, its +.Va sigev_notify_kevent_flags +field may contain +.Dv EV_ONESHOT , +.Dv EV_CLEAR , and/or +.Dv EV_DISPATCH , and its +.Va sigev_notify +field should be set to +.Dv SIGEV_KEVENT . +The posted kevent will contain: .Bl -column ".Va filter" .It Sy Member Ta Sy Value .It Va ident Ta asynchronous I/O control buffer pointer .It Va filter Ta Dv EVFILT_AIO +.It Va flags Ta Dv EV_EOF .It Va udata Ta value stored in .Va aio_sigevent.sigev_value Modified: stable/11/usr.bin/stdbuf/stdbuf.c ============================================================================== --- stable/11/usr.bin/stdbuf/stdbuf.c Fri Aug 25 12:28:34 2017 (r322888) +++ stable/11/usr.bin/stdbuf/stdbuf.c Fri Aug 25 14:28:36 2017 (r322889) @@ -40,7 +40,7 @@ static void usage(int s) { - fprintf(stderr, "Usage: %s [-e 0|L|] [-i 0|L|] [-o 0|L|] " + fprintf(stderr, "Usage: %s [-e 0|L|B|] [-i 0|L|B|] [-o 0|L|B|] " " [args ...]\n", __progname); exit(s); } From owner-svn-src-stable@freebsd.org Fri Aug 25 14:32:04 2017 Return-Path: Delivered-To: svn-src-stable@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 985CFDD9BC5; Fri, 25 Aug 2017 14:32:04 +0000 (UTC) (envelope-from asomers@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 31405342F; Fri, 25 Aug 2017 14:32:04 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7PEW3OC014730; Fri, 25 Aug 2017 14:32:03 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7PEW3ca014728; Fri, 25 Aug 2017 14:32:03 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201708251432.v7PEW3ca014728@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 25 Aug 2017 14:32: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: r322890 - stable/11/tests/sys/aio X-SVN-Group: stable-11 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: stable/11/tests/sys/aio X-SVN-Commit-Revision: 322890 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2017 14:32:04 -0000 Author: asomers Date: Fri Aug 25 14:32:03 2017 New Revision: 322890 URL: https://svnweb.freebsd.org/changeset/base/322890 Log: MFC r320974-r320975, r321001, r321206 r320974: Use ATF cleanup routines in aio_test.c Remove aio_test's legacy timeout handling and cleanup routines. Instead, use ATF's builtin capabilities. ATF automatically cleans up newly created files, too, so we don't have to explicitly unlink them. The only tests than need a cleanup routine are the md(4) tests, which must destroy their md device. Reviewed by: jhb Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D11468 r320975: Add tests for aio(4) completion notification via signals and threads Reviewed by: jhb Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D11468 r321001: Fix the build with GCC after r320975 Reported by: pfg X-MFC-With: 320975 Sponsored by: Spectra Logic Corp r321206: Remove dead code that was killed by r320975 Reported by: Coverity CID: 1377977 X-MFC-With: 320975 Sponsored by: Spectra Logic Corp Modified: stable/11/tests/sys/aio/Makefile stable/11/tests/sys/aio/aio_test.c Directory Properties: stable/11/ (props changed) Modified: stable/11/tests/sys/aio/Makefile ============================================================================== --- stable/11/tests/sys/aio/Makefile Fri Aug 25 14:28:36 2017 (r322889) +++ stable/11/tests/sys/aio/Makefile Fri Aug 25 14:32:03 2017 (r322890) @@ -3,11 +3,12 @@ TESTSDIR= ${TESTSBASE}/sys/aio ATF_TESTS_C+= aio_test +TEST_METADATA.aio_test+= timeout="30" PLAIN_TESTS_C+= aio_kqueue_test PLAIN_TESTS_C+= lio_kqueue_test -LIBADD.aio_test+= util +LIBADD.aio_test+= util rt CFLAGS+= -I${.CURDIR:H:H} Modified: stable/11/tests/sys/aio/aio_test.c ============================================================================== --- stable/11/tests/sys/aio/aio_test.c Fri Aug 25 14:28:36 2017 (r322889) +++ stable/11/tests/sys/aio/aio_test.c Fri Aug 25 14:32:03 2017 (r322890) @@ -32,10 +32,11 @@ * size buffer with pseudo-random data, writing it to one fd using AIO, then * reading it from a second descriptor using AIO. For some targets, the same * fd is used for write and read (i.e., file, md device), but for others the - * operation is performed on a peer (pty, socket, fifo, etc). A timeout is - * initiated to detect undue blocking. This test does not attempt to exercise - * error cases or more subtle asynchronous behavior, just make sure that the - * basic operations work on some basic object types. + * operation is performed on a peer (pty, socket, fifo, etc). For each file + * descriptor type, several completion methods are tested. This test program + * does not attempt to exercise error cases or more subtle asynchronous + * behavior, just make sure that the basic operations work on some basic object + * types. */ #include @@ -51,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -85,42 +87,11 @@ struct aio_context { char ac_buffer[GLOBAL_MAX]; int ac_buflen; int ac_seconds; - void (*ac_cleanup)(void *arg); - void *ac_cleanup_arg; }; -static int aio_timedout; +static sem_t completions; -/* - * Each test run specifies a timeout in seconds. Use the somewhat obsoleted - * signal(3) and alarm(3) APIs to set this up. - */ -static void -aio_timeout_signal(int sig __unused) -{ - aio_timedout = 1; -} - -static void -aio_timeout_start(int seconds) -{ - - aio_timedout = 0; - ATF_REQUIRE_MSG(signal(SIGALRM, aio_timeout_signal) != SIG_ERR, - "failed to set SIGALRM handler: %s", strerror(errno)); - alarm(seconds); -} - -static void -aio_timeout_stop(void) -{ - - ATF_REQUIRE_MSG(signal(SIGALRM, NULL) != SIG_ERR, - "failed to reset SIGALRM handler to default: %s", strerror(errno)); - alarm(0); -} - /* * Fill a buffer given a seed that can be fed into srandom() to initialize * the PRNG in a repeatable manner. @@ -163,8 +134,7 @@ aio_test_buffer(char *buffer, int len, long seed) */ static void aio_context_init(struct aio_context *ac, int read_fd, - int write_fd, int buflen, int seconds, void (*cleanup)(void *), - void *cleanup_arg) + int write_fd, int buflen) { ATF_REQUIRE_MSG(buflen <= BUFFER_MAX, @@ -179,9 +149,6 @@ aio_context_init(struct aio_context *ac, int read_fd, aio_fill_buffer(ac->ac_buffer, buflen, ac->ac_seed); ATF_REQUIRE_MSG(aio_test_buffer(ac->ac_buffer, buflen, ac->ac_seed) != 0, "aio_test_buffer: internal error"); - ac->ac_seconds = seconds; - ac->ac_cleanup = cleanup; - ac->ac_cleanup_arg = cleanup_arg; } static ssize_t @@ -189,8 +156,33 @@ poll(struct aiocb *aio) { int error; - while ((error = aio_error(aio)) == EINPROGRESS && !aio_timedout) + while ((error = aio_error(aio)) == EINPROGRESS) usleep(25000); + if (error) + return (error); + else + return (aio_return(aio)); +} + +static void +sigusr1_handler(int sig __unused) +{ + ATF_REQUIRE_EQ(0, sem_post(&completions)); +} + +static void +thr_handler(union sigval sv __unused) +{ + ATF_REQUIRE_EQ(0, sem_post(&completions)); +} + +static ssize_t +poll_signaled(struct aiocb *aio) +{ + int error; + + ATF_REQUIRE_EQ(0, sem_wait(&completions)); + error = aio_error(aio); switch (error) { case EINPROGRESS: errno = EINTR; @@ -202,6 +194,40 @@ poll(struct aiocb *aio) } } +/* + * Setup a signal handler for signal delivery tests + * This isn't thread safe, but it's ok since ATF runs each testcase in a + * separate process + */ +static struct sigevent* +setup_signal(void) +{ + static struct sigevent sev; + + ATF_REQUIRE_EQ(0, sem_init(&completions, false, 0)); + sev.sigev_notify = SIGEV_SIGNAL; + sev.sigev_signo = SIGUSR1; + ATF_REQUIRE(SIG_ERR != signal(SIGUSR1, sigusr1_handler)); + return (&sev); +} + +/* + * Setup a thread for thread delivery tests + * This isn't thread safe, but it's ok since ATF runs each testcase in a + * separate process + */ +static struct sigevent* +setup_thread(void) +{ + static struct sigevent sev; + + ATF_REQUIRE_EQ(0, sem_init(&completions, false, 0)); + sev.sigev_notify = SIGEV_THREAD; + sev.sigev_notify_function = thr_handler; + sev.sigev_notify_attributes = NULL; + return (&sev); +} + static ssize_t suspend(struct aiocb *aio) { @@ -227,28 +253,11 @@ waitcomplete(struct aiocb *aio) } /* - * Each tester can register a callback to clean up in the event the test - * fails. Preserve the value of errno so that subsequent calls to errx() - * work properly. - */ -static void -aio_cleanup(struct aio_context *ac) -{ - int error; - - if (ac->ac_cleanup == NULL) - return; - error = errno; - (ac->ac_cleanup)(ac->ac_cleanup_arg); - errno = error; -} - -/* * Perform a simple write test of our initialized data buffer to the provided * file descriptor. */ static void -aio_write_test(struct aio_context *ac, completion comp) +aio_write_test(struct aio_context *ac, completion comp, struct sigevent *sev) { struct aiocb aio; ssize_t len; @@ -258,38 +267,18 @@ aio_write_test(struct aio_context *ac, completion comp aio.aio_nbytes = ac->ac_buflen; aio.aio_fildes = ac->ac_write_fd; aio.aio_offset = 0; + if (sev) + aio.aio_sigevent = *sev; - aio_timeout_start(ac->ac_seconds); - - if (aio_write(&aio) < 0) { - if (errno == EINTR) { - if (aio_timedout) { - aio_cleanup(ac); - atf_tc_fail("aio_write timed out"); - } - } - aio_cleanup(ac); + if (aio_write(&aio) < 0) atf_tc_fail("aio_write failed: %s", strerror(errno)); - } len = comp(&aio); - if (len < 0) { - if (errno == EINTR) { - if (aio_timedout) { - aio_cleanup(ac); - atf_tc_fail("aio timed out"); - } - } - aio_cleanup(ac); + if (len < 0) atf_tc_fail("aio failed: %s", strerror(errno)); - } - aio_timeout_stop(); - - if (len != ac->ac_buflen) { - aio_cleanup(ac); + if (len != ac->ac_buflen) atf_tc_fail("aio short write (%jd)", (intmax_t)len); - } } /* @@ -297,7 +286,7 @@ aio_write_test(struct aio_context *ac, completion comp * provided file descriptor. */ static void -aio_read_test(struct aio_context *ac, completion comp) +aio_read_test(struct aio_context *ac, completion comp, struct sigevent *sev) { struct aiocb aio; ssize_t len; @@ -308,44 +297,21 @@ aio_read_test(struct aio_context *ac, completion comp) aio.aio_nbytes = ac->ac_buflen; aio.aio_fildes = ac->ac_read_fd; aio.aio_offset = 0; + if (sev) + aio.aio_sigevent = *sev; - aio_timeout_start(ac->ac_seconds); - - if (aio_read(&aio) < 0) { - if (errno == EINTR) { - if (aio_timedout) { - aio_cleanup(ac); - atf_tc_fail("aio_read timed out"); - } - } - aio_cleanup(ac); + if (aio_read(&aio) < 0) atf_tc_fail("aio_read failed: %s", strerror(errno)); - } len = comp(&aio); - if (len < 0) { - if (errno == EINTR) { - if (aio_timedout) { - aio_cleanup(ac); - atf_tc_fail("aio timed out"); - } - } - aio_cleanup(ac); + if (len < 0) atf_tc_fail("aio failed: %s", strerror(errno)); - } - aio_timeout_stop(); + ATF_REQUIRE_EQ_MSG(len, ac->ac_buflen, + "aio short read (%jd)", (intmax_t)len); - if (len != ac->ac_buflen) { - aio_cleanup(ac); - atf_tc_fail("aio short read (%jd)", - (intmax_t)len); - } - - if (aio_test_buffer(ac->ac_buffer, ac->ac_buflen, ac->ac_seed) == 0) { - aio_cleanup(ac); + if (aio_test_buffer(ac->ac_buffer, ac->ac_buflen, ac->ac_seed) == 0) atf_tc_fail("buffer mismatched"); - } } /* @@ -360,25 +326,10 @@ aio_read_test(struct aio_context *ac, completion comp) */ #define FILE_LEN GLOBAL_MAX #define FILE_PATHNAME "testfile" -#define FILE_TIMEOUT 30 -struct aio_file_arg { - int afa_fd; -}; static void -aio_file_cleanup(void *arg) +aio_file_test(completion comp, struct sigevent *sev) { - struct aio_file_arg *afa; - - afa = arg; - close(afa->afa_fd); - unlink(FILE_PATHNAME); -} - -static void -aio_file_test(completion comp) -{ - struct aio_file_arg arg; struct aio_context ac; int fd; @@ -388,60 +339,49 @@ aio_file_test(completion comp) fd = open(FILE_PATHNAME, O_RDWR | O_CREAT); ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno)); - arg.afa_fd = fd; - - aio_context_init(&ac, fd, fd, FILE_LEN, - FILE_TIMEOUT, aio_file_cleanup, &arg); - aio_write_test(&ac, comp); - aio_read_test(&ac, comp); - - aio_file_cleanup(&arg); + aio_context_init(&ac, fd, fd, FILE_LEN); + aio_write_test(&ac, comp, sev); + aio_read_test(&ac, comp, sev); + close(fd); } ATF_TC_WITHOUT_HEAD(file_poll); ATF_TC_BODY(file_poll, tc) { - aio_file_test(poll); + aio_file_test(poll, NULL); } +ATF_TC_WITHOUT_HEAD(file_signal); +ATF_TC_BODY(file_signal, tc) +{ + aio_file_test(poll_signaled, setup_signal()); +} + ATF_TC_WITHOUT_HEAD(file_suspend); ATF_TC_BODY(file_suspend, tc) { - aio_file_test(suspend); + aio_file_test(suspend, NULL); } +ATF_TC_WITHOUT_HEAD(file_thread); +ATF_TC_BODY(file_thread, tc) +{ + aio_file_test(poll_signaled, setup_thread()); +} + ATF_TC_WITHOUT_HEAD(file_waitcomplete); ATF_TC_BODY(file_waitcomplete, tc) { - aio_file_test(waitcomplete); + aio_file_test(waitcomplete, NULL); } #define FIFO_LEN 256 #define FIFO_PATHNAME "testfifo" -#define FIFO_TIMEOUT 30 -struct aio_fifo_arg { - int afa_read_fd; - int afa_write_fd; -}; static void -aio_fifo_cleanup(void *arg) +aio_fifo_test(completion comp, struct sigevent *sev) { - struct aio_fifo_arg *afa; - - afa = arg; - if (afa->afa_read_fd != -1) - close(afa->afa_read_fd); - if (afa->afa_write_fd != -1) - close(afa->afa_write_fd); - unlink(FIFO_PATHNAME); -} - -static void -aio_fifo_test(completion comp) -{ int error, read_fd = -1, write_fd = -1; - struct aio_fifo_arg arg; struct aio_context ac; ATF_REQUIRE_KERNEL_MODULE("aio"); @@ -449,75 +389,65 @@ aio_fifo_test(completion comp) ATF_REQUIRE_MSG(mkfifo(FIFO_PATHNAME, 0600) != -1, "mkfifo failed: %s", strerror(errno)); - arg.afa_read_fd = -1; - arg.afa_write_fd = -1; read_fd = open(FIFO_PATHNAME, O_RDONLY | O_NONBLOCK); if (read_fd == -1) { error = errno; - aio_fifo_cleanup(&arg); errno = error; atf_tc_fail("read_fd open failed: %s", strerror(errno)); } - arg.afa_read_fd = read_fd; write_fd = open(FIFO_PATHNAME, O_WRONLY); if (write_fd == -1) { error = errno; - aio_fifo_cleanup(&arg); errno = error; atf_tc_fail("write_fd open failed: %s", strerror(errno)); } - arg.afa_write_fd = write_fd; - aio_context_init(&ac, read_fd, write_fd, FIFO_LEN, - FIFO_TIMEOUT, aio_fifo_cleanup, &arg); - aio_write_test(&ac, comp); - aio_read_test(&ac, comp); + aio_context_init(&ac, read_fd, write_fd, FIFO_LEN); + aio_write_test(&ac, comp, sev); + aio_read_test(&ac, comp, sev); - aio_fifo_cleanup(&arg); + close(read_fd); + close(write_fd); } ATF_TC_WITHOUT_HEAD(fifo_poll); ATF_TC_BODY(fifo_poll, tc) { - aio_fifo_test(poll); + aio_fifo_test(poll, NULL); } +ATF_TC_WITHOUT_HEAD(fifo_signal); +ATF_TC_BODY(fifo_signal, tc) +{ + aio_fifo_test(poll_signaled, setup_signal()); +} + ATF_TC_WITHOUT_HEAD(fifo_suspend); ATF_TC_BODY(fifo_suspend, tc) { - aio_fifo_test(waitcomplete); + aio_fifo_test(suspend, NULL); } -ATF_TC_WITHOUT_HEAD(fifo_waitcomplete); -ATF_TC_BODY(fifo_waitcomplete, tc) +ATF_TC_WITHOUT_HEAD(fifo_thread); +ATF_TC_BODY(fifo_thread, tc) { - aio_fifo_test(waitcomplete); + aio_fifo_test(poll_signaled, setup_thread()); } -struct aio_unix_socketpair_arg { - int asa_sockets[2]; -}; - -static void -aio_unix_socketpair_cleanup(void *arg) +ATF_TC_WITHOUT_HEAD(fifo_waitcomplete); +ATF_TC_BODY(fifo_waitcomplete, tc) { - struct aio_unix_socketpair_arg *asa; - - asa = arg; - close(asa->asa_sockets[0]); - close(asa->asa_sockets[1]); + aio_fifo_test(waitcomplete, NULL); } #define UNIX_SOCKETPAIR_LEN 256 -#define UNIX_SOCKETPAIR_TIMEOUT 30 static void -aio_unix_socketpair_test(completion comp) +aio_unix_socketpair_test(completion comp, struct sigevent *sev) { - struct aio_unix_socketpair_arg arg; struct aio_context ac; struct rusage ru_before, ru_after; int sockets[2]; @@ -527,42 +457,51 @@ aio_unix_socketpair_test(completion comp) ATF_REQUIRE_MSG(socketpair(PF_UNIX, SOCK_STREAM, 0, sockets) != -1, "socketpair failed: %s", strerror(errno)); - arg.asa_sockets[0] = sockets[0]; - arg.asa_sockets[1] = sockets[1]; - aio_context_init(&ac, sockets[0], - sockets[1], UNIX_SOCKETPAIR_LEN, UNIX_SOCKETPAIR_TIMEOUT, - aio_unix_socketpair_cleanup, &arg); + aio_context_init(&ac, sockets[0], sockets[1], UNIX_SOCKETPAIR_LEN); ATF_REQUIRE_MSG(getrusage(RUSAGE_SELF, &ru_before) != -1, "getrusage failed: %s", strerror(errno)); - aio_write_test(&ac, comp); + aio_write_test(&ac, comp, sev); ATF_REQUIRE_MSG(getrusage(RUSAGE_SELF, &ru_after) != -1, "getrusage failed: %s", strerror(errno)); ATF_REQUIRE(ru_after.ru_msgsnd == ru_before.ru_msgsnd + 1); ru_before = ru_after; - aio_read_test(&ac, comp); + aio_read_test(&ac, comp, sev); ATF_REQUIRE_MSG(getrusage(RUSAGE_SELF, &ru_after) != -1, "getrusage failed: %s", strerror(errno)); ATF_REQUIRE(ru_after.ru_msgrcv == ru_before.ru_msgrcv + 1); - aio_unix_socketpair_cleanup(&arg); + close(sockets[0]); + close(sockets[1]); } ATF_TC_WITHOUT_HEAD(socket_poll); ATF_TC_BODY(socket_poll, tc) { - aio_unix_socketpair_test(poll); + aio_unix_socketpair_test(poll, NULL); } +ATF_TC_WITHOUT_HEAD(socket_signal); +ATF_TC_BODY(socket_signal, tc) +{ + aio_unix_socketpair_test(poll_signaled, setup_signal()); +} + ATF_TC_WITHOUT_HEAD(socket_suspend); ATF_TC_BODY(socket_suspend, tc) { - aio_unix_socketpair_test(suspend); + aio_unix_socketpair_test(suspend, NULL); } +ATF_TC_WITHOUT_HEAD(socket_thread); +ATF_TC_BODY(socket_thread, tc) +{ + aio_unix_socketpair_test(poll_signaled, setup_thread()); +} + ATF_TC_WITHOUT_HEAD(socket_waitcomplete); ATF_TC_BODY(socket_waitcomplete, tc) { - aio_unix_socketpair_test(waitcomplete); + aio_unix_socketpair_test(waitcomplete, NULL); } struct aio_pty_arg { @@ -570,22 +509,10 @@ struct aio_pty_arg { int apa_write_fd; }; -static void -aio_pty_cleanup(void *arg) -{ - struct aio_pty_arg *apa; - - apa = arg; - close(apa->apa_read_fd); - close(apa->apa_write_fd); -}; - #define PTY_LEN 256 -#define PTY_TIMEOUT 30 static void -aio_pty_test(completion comp) +aio_pty_test(completion comp, struct sigevent *sev) { - struct aio_pty_arg arg; struct aio_context ac; int read_fd, write_fd; struct termios ts; @@ -597,62 +524,60 @@ aio_pty_test(completion comp) ATF_REQUIRE_MSG(openpty(&read_fd, &write_fd, NULL, NULL, NULL) == 0, "openpty failed: %s", strerror(errno)); - arg.apa_read_fd = read_fd; - arg.apa_write_fd = write_fd; if (tcgetattr(write_fd, &ts) < 0) { error = errno; - aio_pty_cleanup(&arg); errno = error; atf_tc_fail("tcgetattr failed: %s", strerror(errno)); } cfmakeraw(&ts); if (tcsetattr(write_fd, TCSANOW, &ts) < 0) { error = errno; - aio_pty_cleanup(&arg); errno = error; atf_tc_fail("tcsetattr failed: %s", strerror(errno)); } - aio_context_init(&ac, read_fd, write_fd, PTY_LEN, - PTY_TIMEOUT, aio_pty_cleanup, &arg); + aio_context_init(&ac, read_fd, write_fd, PTY_LEN); - aio_write_test(&ac, comp); - aio_read_test(&ac, comp); + aio_write_test(&ac, comp, sev); + aio_read_test(&ac, comp, sev); - aio_pty_cleanup(&arg); + close(read_fd); + close(write_fd); } ATF_TC_WITHOUT_HEAD(pty_poll); ATF_TC_BODY(pty_poll, tc) { - aio_pty_test(poll); + aio_pty_test(poll, NULL); } +ATF_TC_WITHOUT_HEAD(pty_signal); +ATF_TC_BODY(pty_signal, tc) +{ + aio_pty_test(poll_signaled, setup_signal()); +} + ATF_TC_WITHOUT_HEAD(pty_suspend); ATF_TC_BODY(pty_suspend, tc) { - aio_pty_test(suspend); + aio_pty_test(suspend, NULL); } -ATF_TC_WITHOUT_HEAD(pty_waitcomplete); -ATF_TC_BODY(pty_waitcomplete, tc) +ATF_TC_WITHOUT_HEAD(pty_thread); +ATF_TC_BODY(pty_thread, tc) { - aio_pty_test(waitcomplete); + aio_pty_test(poll_signaled, setup_thread()); } -static void -aio_pipe_cleanup(void *arg) +ATF_TC_WITHOUT_HEAD(pty_waitcomplete); +ATF_TC_BODY(pty_waitcomplete, tc) { - int *pipes = arg; - - close(pipes[0]); - close(pipes[1]); + aio_pty_test(waitcomplete, NULL); } #define PIPE_LEN 256 -#define PIPE_TIMEOUT 30 static void -aio_pipe_test(completion comp) +aio_pipe_test(completion comp, struct sigevent *sev) { struct aio_context ac; int pipes[2]; @@ -663,76 +588,83 @@ aio_pipe_test(completion comp) ATF_REQUIRE_MSG(pipe(pipes) != -1, "pipe failed: %s", strerror(errno)); - aio_context_init(&ac, pipes[0], pipes[1], PIPE_LEN, - PIPE_TIMEOUT, aio_pipe_cleanup, pipes); - aio_write_test(&ac, comp); - aio_read_test(&ac, comp); + aio_context_init(&ac, pipes[0], pipes[1], PIPE_LEN); + aio_write_test(&ac, comp, sev); + aio_read_test(&ac, comp, sev); - aio_pipe_cleanup(pipes); + close(pipes[0]); + close(pipes[1]); } ATF_TC_WITHOUT_HEAD(pipe_poll); ATF_TC_BODY(pipe_poll, tc) { - aio_pipe_test(poll); + aio_pipe_test(poll, NULL); } +ATF_TC_WITHOUT_HEAD(pipe_signal); +ATF_TC_BODY(pipe_signal, tc) +{ + aio_pipe_test(poll_signaled, setup_signal()); +} + ATF_TC_WITHOUT_HEAD(pipe_suspend); ATF_TC_BODY(pipe_suspend, tc) { - aio_pipe_test(suspend); + aio_pipe_test(suspend, NULL); } +ATF_TC_WITHOUT_HEAD(pipe_thread); +ATF_TC_BODY(pipe_thread, tc) +{ + aio_pipe_test(poll_signaled, setup_thread()); +} + ATF_TC_WITHOUT_HEAD(pipe_waitcomplete); ATF_TC_BODY(pipe_waitcomplete, tc) { - aio_pipe_test(waitcomplete); + aio_pipe_test(waitcomplete, NULL); } -struct aio_md_arg { - int ama_mdctl_fd; - int ama_unit; - int ama_fd; -}; +#define MD_LEN GLOBAL_MAX +#define MDUNIT_LINK "mdunit_link" static void -aio_md_cleanup(void *arg) +aio_md_cleanup(void) { - struct aio_md_arg *ama; struct md_ioctl mdio; - int error; + int mdctl_fd, error, n, unit; + char buf[80]; - ama = arg; - - if (ama->ama_fd != -1) - close(ama->ama_fd); - - if (ama->ama_unit != -1) { - bzero(&mdio, sizeof(mdio)); - mdio.md_version = MDIOVERSION; - mdio.md_unit = ama->ama_unit; - if (ioctl(ama->ama_mdctl_fd, MDIOCDETACH, &mdio) == -1) { - error = errno; - close(ama->ama_mdctl_fd); - errno = error; - atf_tc_fail("ioctl MDIOCDETACH failed: %s", - strerror(errno)); + mdctl_fd = open("/dev/" MDCTL_NAME, O_RDWR, 0); + ATF_REQUIRE(mdctl_fd >= 0); + n = readlink(MDUNIT_LINK, buf, sizeof(buf)); + if (n > 0) { + if (sscanf(buf, "%d", &unit) == 1 && unit >= 0) { + bzero(&mdio, sizeof(mdio)); + mdio.md_version = MDIOVERSION; + mdio.md_unit = unit; + if (ioctl(mdctl_fd, MDIOCDETACH, &mdio) == -1) { + error = errno; + close(mdctl_fd); + errno = error; + atf_tc_fail("ioctl MDIOCDETACH failed: %s", + strerror(errno)); + } } } - - close(ama->ama_mdctl_fd); + + close(mdctl_fd); } -#define MD_LEN GLOBAL_MAX -#define MD_TIMEOUT 30 static void -aio_md_test(completion comp) +aio_md_test(completion comp, struct sigevent *sev) { int error, fd, mdctl_fd, unit; char pathname[PATH_MAX]; - struct aio_md_arg arg; struct aio_context ac; struct md_ioctl mdio; + char buf[80]; ATF_REQUIRE_KERNEL_MODULE("aio"); ATF_REQUIRE_UNSAFE_AIO(); @@ -748,32 +680,30 @@ aio_md_test(completion comp) mdio.md_mediasize = GLOBAL_MAX; mdio.md_sectorsize = 512; - arg.ama_mdctl_fd = mdctl_fd; - arg.ama_unit = -1; - arg.ama_fd = -1; if (ioctl(mdctl_fd, MDIOCATTACH, &mdio) < 0) { error = errno; - aio_md_cleanup(&arg); errno = error; atf_tc_fail("ioctl MDIOCATTACH failed: %s", strerror(errno)); } + close(mdctl_fd); - arg.ama_unit = unit = mdio.md_unit; + /* Store the md unit number in a symlink for future cleanup */ + unit = mdio.md_unit; + snprintf(buf, sizeof(buf), "%d", unit); + ATF_REQUIRE_EQ(0, symlink(buf, MDUNIT_LINK)); snprintf(pathname, PATH_MAX, "/dev/md%d", unit); fd = open(pathname, O_RDWR); ATF_REQUIRE_MSG(fd != -1, "opening %s failed: %s", pathname, strerror(errno)); - arg.ama_fd = fd; - aio_context_init(&ac, fd, fd, MD_LEN, MD_TIMEOUT, - aio_md_cleanup, &arg); - aio_write_test(&ac, comp); - aio_read_test(&ac, comp); - - aio_md_cleanup(&arg); + aio_context_init(&ac, fd, fd, MD_LEN); + aio_write_test(&ac, comp, sev); + aio_read_test(&ac, comp, sev); + + close(fd); } -ATF_TC(md_poll); +ATF_TC_WITH_CLEANUP(md_poll); ATF_TC_HEAD(md_poll, tc) { @@ -781,10 +711,29 @@ ATF_TC_HEAD(md_poll, tc) } ATF_TC_BODY(md_poll, tc) { - aio_md_test(poll); + aio_md_test(poll, NULL); } +ATF_TC_CLEANUP(md_poll, tc) +{ + aio_md_cleanup(); +} -ATF_TC(md_suspend); +ATF_TC_WITH_CLEANUP(md_signal); +ATF_TC_HEAD(md_signal, tc) +{ + + atf_tc_set_md_var(tc, "require.user", "root"); +} +ATF_TC_BODY(md_signal, tc) +{ + aio_md_test(poll_signaled, setup_signal()); +} +ATF_TC_CLEANUP(md_signal, tc) +{ + aio_md_cleanup(); +} + +ATF_TC_WITH_CLEANUP(md_suspend); ATF_TC_HEAD(md_suspend, tc) { @@ -792,10 +741,29 @@ ATF_TC_HEAD(md_suspend, tc) } ATF_TC_BODY(md_suspend, tc) { - aio_md_test(suspend); + aio_md_test(suspend, NULL); } +ATF_TC_CLEANUP(md_suspend, tc) +{ + aio_md_cleanup(); +} -ATF_TC(md_waitcomplete); +ATF_TC_WITH_CLEANUP(md_thread); +ATF_TC_HEAD(md_thread, tc) +{ + + atf_tc_set_md_var(tc, "require.user", "root"); +} +ATF_TC_BODY(md_thread, tc) +{ + aio_md_test(poll_signaled, setup_thread()); +} +ATF_TC_CLEANUP(md_thread, tc) +{ + aio_md_cleanup(); +} + +ATF_TC_WITH_CLEANUP(md_waitcomplete); ATF_TC_HEAD(md_waitcomplete, tc) { @@ -803,8 +771,12 @@ ATF_TC_HEAD(md_waitcomplete, tc) } ATF_TC_BODY(md_waitcomplete, tc) { - aio_md_test(waitcomplete); + aio_md_test(waitcomplete, NULL); } +ATF_TC_CLEANUP(md_waitcomplete, tc) +{ + aio_md_cleanup(); +} ATF_TC_WITHOUT_HEAD(aio_large_read_test); ATF_TC_BODY(aio_large_read_test, tc) @@ -1152,28 +1124,40 @@ ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, file_poll); + ATF_TP_ADD_TC(tp, file_signal); ATF_TP_ADD_TC(tp, file_suspend); + ATF_TP_ADD_TC(tp, file_thread); ATF_TP_ADD_TC(tp, file_waitcomplete); ATF_TP_ADD_TC(tp, fifo_poll); + ATF_TP_ADD_TC(tp, fifo_signal); ATF_TP_ADD_TC(tp, fifo_suspend); + ATF_TP_ADD_TC(tp, fifo_thread); ATF_TP_ADD_TC(tp, fifo_waitcomplete); ATF_TP_ADD_TC(tp, socket_poll); + ATF_TP_ADD_TC(tp, socket_signal); ATF_TP_ADD_TC(tp, socket_suspend); + ATF_TP_ADD_TC(tp, socket_thread); ATF_TP_ADD_TC(tp, socket_waitcomplete); ATF_TP_ADD_TC(tp, pty_poll); + ATF_TP_ADD_TC(tp, pty_signal); ATF_TP_ADD_TC(tp, pty_suspend); + ATF_TP_ADD_TC(tp, pty_thread); ATF_TP_ADD_TC(tp, pty_waitcomplete); ATF_TP_ADD_TC(tp, pipe_poll); + ATF_TP_ADD_TC(tp, pipe_signal); ATF_TP_ADD_TC(tp, pipe_suspend); + ATF_TP_ADD_TC(tp, pipe_thread); ATF_TP_ADD_TC(tp, pipe_waitcomplete); ATF_TP_ADD_TC(tp, md_poll); + ATF_TP_ADD_TC(tp, md_signal); ATF_TP_ADD_TC(tp, md_suspend); + ATF_TP_ADD_TC(tp, md_thread); ATF_TP_ADD_TC(tp, md_waitcomplete); + ATF_TP_ADD_TC(tp, aio_fsync_test); ATF_TP_ADD_TC(tp, aio_large_read_test); ATF_TP_ADD_TC(tp, aio_socket_two_reads); ATF_TP_ADD_TC(tp, aio_socket_blocking_short_write); ATF_TP_ADD_TC(tp, aio_socket_short_write_cancel); - ATF_TP_ADD_TC(tp, aio_fsync_test); return (atf_no_error()); } From owner-svn-src-stable@freebsd.org Fri Aug 25 14:37:24 2017 Return-Path: Delivered-To: svn-src-stable@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 954F5DD9CC2; Fri, 25 Aug 2017 14:37:24 +0000 (UTC) (envelope-from asomers@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 71B9A3869; Fri, 25 Aug 2017 14:37:24 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7PEbNQH014980; Fri, 25 Aug 2017 14:37:23 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7PEbNQ3014978; Fri, 25 Aug 2017 14:37:23 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201708251437.v7PEbNQ3014978@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 25 Aug 2017 14:37: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: r322891 - stable/11/tests/sys/aio X-SVN-Group: stable-11 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: stable/11/tests/sys/aio X-SVN-Commit-Revision: 322891 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2017 14:37:24 -0000 Author: asomers Date: Fri Aug 25 14:37:23 2017 New Revision: 322891 URL: https://svnweb.freebsd.org/changeset/base/322891 Log: MFC r321082: Add regression tests for bugs 220459 and 220398 Bug 220398 - lio_listio(2) never sends asynchronous notification if nent==0 Bug 220459 - lio_listio(2) doesn't support SIGEV_THREAD PR: 220459 PR: 220398 Reviewed by: cem, jhb Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D11470 Added: stable/11/tests/sys/aio/lio_test.c - copied unchanged from r321082, head/tests/sys/aio/lio_test.c Modified: stable/11/tests/sys/aio/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/tests/sys/aio/Makefile ============================================================================== --- stable/11/tests/sys/aio/Makefile Fri Aug 25 14:32:03 2017 (r322890) +++ stable/11/tests/sys/aio/Makefile Fri Aug 25 14:37:23 2017 (r322891) @@ -3,12 +3,15 @@ TESTSDIR= ${TESTSBASE}/sys/aio ATF_TESTS_C+= aio_test +ATF_TESTS_C+= lio_test TEST_METADATA.aio_test+= timeout="30" +TEST_METADATA.lio_test+= timeout="10" PLAIN_TESTS_C+= aio_kqueue_test PLAIN_TESTS_C+= lio_kqueue_test LIBADD.aio_test+= util rt +LIBADD.lio_test+= rt CFLAGS+= -I${.CURDIR:H:H} Copied: stable/11/tests/sys/aio/lio_test.c (from r321082, head/tests/sys/aio/lio_test.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/tests/sys/aio/lio_test.c Fri Aug 25 14:37:23 2017 (r322891, copy of r321082, head/tests/sys/aio/lio_test.c) @@ -0,0 +1,145 @@ +/*- + * Copyright (c) 2017 Spectra Logic Corp + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include + +#include +#include + +#include + +#include "freebsd_test_suite/macros.h" + +static sem_t completions; + + +static void +handler(int sig __unused) +{ + ATF_REQUIRE_EQ(0, sem_post(&completions)); +} + +static void +thr_handler(union sigval sv __unused) +{ + ATF_REQUIRE_EQ(0, sem_post(&completions)); +} + +/* With LIO_WAIT, an empty lio_listio should return immediately */ +ATF_TC_WITHOUT_HEAD(lio_listio_empty_wait); +ATF_TC_BODY(lio_listio_empty_wait, tc) +{ + struct aiocb *list = NULL; + + ATF_REQUIRE_EQ(0, lio_listio(LIO_WAIT, &list, 0, NULL)); +} + +/* + * With LIO_NOWAIT, an empty lio_listio should send completion notification + * immediately + */ +ATF_TC_WITHOUT_HEAD(lio_listio_empty_nowait_kevent); +ATF_TC_BODY(lio_listio_empty_nowait_kevent, tc) +{ + struct aiocb *list = NULL; + struct sigevent sev; + struct kevent kq_returned; + int kq, result; + void *udata = (void*)0xdeadbeefdeadbeef; + + atf_tc_expect_timeout("Bug 220398 - lio_listio(2) never sends" + " asynchronous notification if nent==0"); + kq = kqueue(); + ATF_REQUIRE(kq > 0); + sev.sigev_notify = SIGEV_KEVENT; + sev.sigev_notify_kqueue = kq; + sev.sigev_value.sival_ptr = udata; + ATF_REQUIRE_EQ(0, lio_listio(LIO_NOWAIT, &list, 0, &sev)); + result = kevent(kq, NULL, 0, &kq_returned, 1, NULL); + ATF_REQUIRE_MSG(result == 1, "Never got completion notification"); + ATF_REQUIRE_EQ((uintptr_t)list, kq_returned.ident); + ATF_REQUIRE_EQ(EVFILT_LIO, kq_returned.filter); + ATF_REQUIRE_EQ(udata, kq_returned.udata); +} + +/* + * With LIO_NOWAIT, an empty lio_listio should send completion notification + * immediately + */ +ATF_TC_WITHOUT_HEAD(lio_listio_empty_nowait_signal); +ATF_TC_BODY(lio_listio_empty_nowait_signal, tc) +{ + struct aiocb *list = NULL; + struct sigevent sev; + + atf_tc_expect_timeout("Bug 220398 - lio_listio(2) never sends" + "asynchronous notification if nent==0"); + ATF_REQUIRE_EQ(0, sem_init(&completions, false, 0)); + sev.sigev_notify = SIGEV_SIGNAL; + sev.sigev_signo = SIGUSR1; + ATF_REQUIRE(SIG_ERR != signal(SIGUSR1, handler)); + ATF_REQUIRE_EQ(0, lio_listio(LIO_NOWAIT, &list, 0, &sev)); + ATF_REQUIRE_EQ(0, sem_wait(&completions)); + ATF_REQUIRE_EQ(0, sem_destroy(&completions)); +} + +/* + * With LIO_NOWAIT, an empty lio_listio should send completion notification + * immediately + */ +ATF_TC_WITHOUT_HEAD(lio_listio_empty_nowait_thread); +ATF_TC_BODY(lio_listio_empty_nowait_thread, tc) +{ + struct aiocb *list = NULL; + struct sigevent sev; + + atf_tc_expect_fail("Bug 220459 - lio_listio(2) doesn't support" + " SIGEV_THREAD"); + ATF_REQUIRE_EQ(0, sem_init(&completions, false, 0)); + bzero(&sev, sizeof(sev)); + sev.sigev_notify = SIGEV_THREAD; + sev.sigev_notify_function = thr_handler; + sev.sigev_notify_attributes = NULL; + ATF_REQUIRE_MSG(0 == lio_listio(LIO_NOWAIT, &list, 0, &sev), + "lio_listio: %s", strerror(errno)); + ATF_REQUIRE_EQ(0, sem_wait(&completions)); + ATF_REQUIRE_EQ(0, sem_destroy(&completions)); +} + + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, lio_listio_empty_nowait_kevent); + ATF_TP_ADD_TC(tp, lio_listio_empty_nowait_signal); + ATF_TP_ADD_TC(tp, lio_listio_empty_nowait_thread); + ATF_TP_ADD_TC(tp, lio_listio_empty_wait); + + return (atf_no_error()); +} From owner-svn-src-stable@freebsd.org Fri Aug 25 14:42:12 2017 Return-Path: Delivered-To: svn-src-stable@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 C0760DD9FB2; Fri, 25 Aug 2017 14:42:12 +0000 (UTC) (envelope-from asomers@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 9CF9C3E63; Fri, 25 Aug 2017 14:42:12 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7PEgBNG017739; Fri, 25 Aug 2017 14:42:11 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7PEgBvj017364; Fri, 25 Aug 2017 14:42:11 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201708251442.v7PEgBvj017364@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 25 Aug 2017 14:42: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: r322892 - in stable/11: lib/librt tests/sys/aio X-SVN-Group: stable-11 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in stable/11: lib/librt tests/sys/aio X-SVN-Commit-Revision: 322892 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2017 14:42:12 -0000 Author: asomers Date: Fri Aug 25 14:42:11 2017 New Revision: 322892 URL: https://svnweb.freebsd.org/changeset/base/322892 Log: MFC r321332: Implement SIGEV_THREAD notifications for lio_listio(2) Our man pages have always indicated that this was supported, but in fact the feature was never implemented for lio_listio(2). Reviewed by: jhb, kib (earlier version) Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D11680 Modified: stable/11/lib/librt/Symbol.map stable/11/lib/librt/aio.c stable/11/tests/sys/aio/lio_test.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/librt/Symbol.map ============================================================================== --- stable/11/lib/librt/Symbol.map Fri Aug 25 14:37:23 2017 (r322891) +++ stable/11/lib/librt/Symbol.map Fri Aug 25 14:42:11 2017 (r322892) @@ -26,6 +26,7 @@ FBSD_1.0 { }; FBSD_1.5 { + lio_listio; mq_getfd_np; timer_oshandle_np; }; Modified: stable/11/lib/librt/aio.c ============================================================================== --- stable/11/lib/librt/aio.c Fri Aug 25 14:37:23 2017 (r322891) +++ stable/11/lib/librt/aio.c Fri Aug 25 14:42:11 2017 (r322892) @@ -49,6 +49,7 @@ __weak_reference(__aio_waitcomplete, _aio_waitcomplete __weak_reference(__aio_waitcomplete, aio_waitcomplete); __weak_reference(__aio_fsync, _aio_fsync); __weak_reference(__aio_fsync, aio_fsync); +__weak_reference(__lio_listio, lio_listio); typedef void (*aio_func)(union sigval val, struct aiocb *iocb); @@ -58,6 +59,8 @@ extern ssize_t __sys_aio_waitcomplete(struct aiocb **i extern ssize_t __sys_aio_return(struct aiocb *iocb); extern int __sys_aio_error(struct aiocb *iocb); extern int __sys_aio_fsync(int op, struct aiocb *iocb); +extern int __sys_lio_listio(int mode, struct aiocb * const list[], int nent, + struct sigevent *sig); static void aio_dispatch(struct sigev_node *sn) @@ -68,8 +71,8 @@ aio_dispatch(struct sigev_node *sn) } static int -aio_sigev_alloc(struct aiocb *iocb, struct sigev_node **sn, - struct sigevent *saved_ev) +aio_sigev_alloc(sigev_id_t id, struct sigevent *sigevent, + struct sigev_node **sn, struct sigevent *saved_ev) { if (__sigev_check_init()) { /* This might be that thread library is not enabled. */ @@ -77,15 +80,15 @@ aio_sigev_alloc(struct aiocb *iocb, struct sigev_node return (-1); } - *sn = __sigev_alloc(SI_ASYNCIO, &iocb->aio_sigevent, NULL, 1); + *sn = __sigev_alloc(SI_ASYNCIO, sigevent, NULL, 1); if (*sn == NULL) { errno = EAGAIN; return (-1); } - *saved_ev = iocb->aio_sigevent; - (*sn)->sn_id = (sigev_id_t)iocb; - __sigev_get_sigevent(*sn, &iocb->aio_sigevent, (*sn)->sn_id); + *saved_ev = *sigevent; + (*sn)->sn_id = id; + __sigev_get_sigevent(*sn, sigevent, (*sn)->sn_id); (*sn)->sn_dispatch = aio_dispatch; __sigev_list_lock(); @@ -107,7 +110,8 @@ aio_io(struct aiocb *iocb, int (*sysfunc)(struct aiocb return (ret); } - ret = aio_sigev_alloc(iocb, &sn, &saved_ev); + ret = aio_sigev_alloc((sigev_id_t)iocb, &iocb->aio_sigevent, &sn, + &saved_ev); if (ret) return (ret); ret = sysfunc(iocb); @@ -188,11 +192,38 @@ __aio_fsync(int op, struct aiocb *iocb) if (iocb->aio_sigevent.sigev_notify != SIGEV_THREAD) return __sys_aio_fsync(op, iocb); - ret = aio_sigev_alloc(iocb, &sn, &saved_ev); + ret = aio_sigev_alloc((sigev_id_t)iocb, &iocb->aio_sigevent, &sn, + &saved_ev); if (ret) return (ret); ret = __sys_aio_fsync(op, iocb); iocb->aio_sigevent = saved_ev; + if (ret != 0) { + err = errno; + __sigev_list_lock(); + __sigev_delete_node(sn); + __sigev_list_unlock(); + errno = err; + } + return (ret); +} + +int +__lio_listio(int mode, struct aiocb * const list[], int nent, + struct sigevent *sig) +{ + struct sigev_node *sn; + struct sigevent saved_ev; + int ret, err; + + if (sig == NULL || sig->sigev_notify != SIGEV_THREAD) + return (__sys_lio_listio(mode, list, nent, sig)); + + ret = aio_sigev_alloc((sigev_id_t)list, sig, &sn, &saved_ev); + if (ret) + return (ret); + ret = __sys_lio_listio(mode, list, nent, sig); + *sig = saved_ev; if (ret != 0) { err = errno; __sigev_list_lock(); Modified: stable/11/tests/sys/aio/lio_test.c ============================================================================== --- stable/11/tests/sys/aio/lio_test.c Fri Aug 25 14:37:23 2017 (r322891) +++ stable/11/tests/sys/aio/lio_test.c Fri Aug 25 14:42:11 2017 (r322892) @@ -119,8 +119,8 @@ ATF_TC_BODY(lio_listio_empty_nowait_thread, tc) struct aiocb *list = NULL; struct sigevent sev; - atf_tc_expect_fail("Bug 220459 - lio_listio(2) doesn't support" - " SIGEV_THREAD"); + atf_tc_expect_timeout("Bug 220398 - lio_listio(2) never sends" + "asynchronous notification if nent==0"); ATF_REQUIRE_EQ(0, sem_init(&completions, false, 0)); bzero(&sev, sizeof(sev)); sev.sigev_notify = SIGEV_THREAD; From owner-svn-src-stable@freebsd.org Fri Aug 25 22:39:50 2017 Return-Path: Delivered-To: svn-src-stable@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 D75FBDE2E57; Fri, 25 Aug 2017 22:39:50 +0000 (UTC) (envelope-from rmacklem@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 B2F7273459; Fri, 25 Aug 2017 22:39:50 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7PMdnuo012763; Fri, 25 Aug 2017 22:39:49 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7PMdnbS012755; Fri, 25 Aug 2017 22:39:49 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201708252239.v7PMdnbS012755@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Fri, 25 Aug 2017 22:39: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: r322907 - in stable/11/sys/fs: nfs nfsclient X-SVN-Group: stable-11 X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: in stable/11/sys/fs: nfs nfsclient X-SVN-Commit-Revision: 322907 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2017 22:39:51 -0000 Author: rmacklem Date: Fri Aug 25 22:39:49 2017 New Revision: 322907 URL: https://svnweb.freebsd.org/changeset/base/322907 Log: MFC: r321628 Replace the checks for MNTK_UNMOUNTF with a macro that does the same thing. This patch defines a macro that checks for MNTK_UNMOUNTF and replaces explicit checks with this macro. It has no effect on semantics, but prepares the code for a future patch where there will also be a NFS specific flag for "forced dismount about to occur". Modified: stable/11/sys/fs/nfs/nfs_commonkrpc.c stable/11/sys/fs/nfs/nfs_commonsubs.c stable/11/sys/fs/nfs/nfscl.h stable/11/sys/fs/nfsclient/nfs_clbio.c stable/11/sys/fs/nfsclient/nfs_clport.c stable/11/sys/fs/nfsclient/nfs_clstate.c stable/11/sys/fs/nfsclient/nfs_clvfsops.c stable/11/sys/fs/nfsclient/nfs_clvnops.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/nfs/nfs_commonkrpc.c ============================================================================== --- stable/11/sys/fs/nfs/nfs_commonkrpc.c Fri Aug 25 22:38:55 2017 (r322906) +++ stable/11/sys/fs/nfs/nfs_commonkrpc.c Fri Aug 25 22:39:49 2017 (r322907) @@ -509,7 +509,7 @@ newnfs_request(struct nfsrv_descript *nd, struct nfsmo if (xidp != NULL) *xidp = 0; /* Reject requests while attempting a forced unmount. */ - if (nmp != NULL && (nmp->nm_mountp->mnt_kern_flag & MNTK_UNMOUNTF)) { + if (nmp != NULL && NFSCL_FORCEDISM(nmp->nm_mountp)) { m_freem(nd->nd_mreq); return (ESTALE); } @@ -1229,7 +1229,7 @@ newnfs_sigintr(struct nfsmount *nmp, struct thread *td sigset_t tmpset; /* Terminate all requests while attempting a forced unmount. */ - if (nmp->nm_mountp->mnt_kern_flag & MNTK_UNMOUNTF) + if (NFSCL_FORCEDISM(nmp->nm_mountp)) return (EIO); if (!(nmp->nm_flag & NFSMNT_INT)) return (0); Modified: stable/11/sys/fs/nfs/nfs_commonsubs.c ============================================================================== --- stable/11/sys/fs/nfs/nfs_commonsubs.c Fri Aug 25 22:38:55 2017 (r322906) +++ stable/11/sys/fs/nfs/nfs_commonsubs.c Fri Aug 25 22:39:49 2017 (r322907) @@ -1866,7 +1866,7 @@ nfsv4_lock(struct nfsv4lock *lp, int iwantlock, int *i lp->nfslock_lock |= NFSV4LOCK_LOCKWANTED; } while (lp->nfslock_lock & (NFSV4LOCK_LOCK | NFSV4LOCK_LOCKWANTED)) { - if (mp != NULL && (mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) { + if (mp != NULL && NFSCL_FORCEDISM(mp)) { lp->nfslock_lock &= ~NFSV4LOCK_LOCKWANTED; return (0); } @@ -1920,7 +1920,7 @@ nfsv4_relref(struct nfsv4lock *lp) * not wait for threads that want the exclusive lock. If priority needs * to be given to threads that need the exclusive lock, a call to nfsv4_lock() * with the 2nd argument == 0 should be done before calling nfsv4_getref(). - * If the mp argument is not NULL, check for MNTK_UNMOUNTF being set and + * If the mp argument is not NULL, check for NFSCL_FORCEDISM() being set and * return without getting a refcnt for that case. */ APPLESTATIC void @@ -1935,7 +1935,7 @@ nfsv4_getref(struct nfsv4lock *lp, int *isleptp, void * Wait for a lock held. */ while (lp->nfslock_lock & NFSV4LOCK_LOCK) { - if (mp != NULL && (mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) + if (mp != NULL && NFSCL_FORCEDISM(mp)) return; lp->nfslock_lock |= NFSV4LOCK_WANTED; if (isleptp) @@ -1943,7 +1943,7 @@ nfsv4_getref(struct nfsv4lock *lp, int *isleptp, void (void) nfsmsleep(&lp->nfslock_lock, mutex, PZERO - 1, "nfsv4gr", NULL); } - if (mp != NULL && (mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) + if (mp != NULL && NFSCL_FORCEDISM(mp)) return; lp->nfslock_usecnt++; @@ -4215,9 +4215,7 @@ nfsv4_sequencelookup(struct nfsmount *nmp, struct nfsc * This RPC attempt will fail when it calls * newnfs_request(). */ - if (nmp != NULL && - (nmp->nm_mountp->mnt_kern_flag & MNTK_UNMOUNTF) - != 0) { + if (nmp != NULL && NFSCL_FORCEDISM(nmp->nm_mountp)) { mtx_unlock(&sep->nfsess_mtx); return (ESTALE); } Modified: stable/11/sys/fs/nfs/nfscl.h ============================================================================== --- stable/11/sys/fs/nfs/nfscl.h Fri Aug 25 22:38:55 2017 (r322906) +++ stable/11/sys/fs/nfs/nfscl.h Fri Aug 25 22:39:49 2017 (r322907) @@ -59,6 +59,9 @@ struct nfsv4node { #define NFSCL_RENEW(l) (((l) < 2) ? 1 : ((l) / 2)) #define NFSCL_LEASE(r) ((r) * 2) +/* This macro checks to see if a forced dismount is about to occur. */ +#define NFSCL_FORCEDISM(m) (((m)->mnt_kern_flag & MNTK_UNMOUNTF) != 0) + /* * These flag bits are used for the argument to nfscl_fillsattr() to * indicate special handling of the attributes. Modified: stable/11/sys/fs/nfsclient/nfs_clbio.c ============================================================================== --- stable/11/sys/fs/nfsclient/nfs_clbio.c Fri Aug 25 22:38:55 2017 (r322906) +++ stable/11/sys/fs/nfsclient/nfs_clbio.c Fri Aug 25 22:39:49 2017 (r322907) @@ -1342,7 +1342,7 @@ ncl_vinvalbuf(struct vnode *vp, int flags, struct thre if ((nmp->nm_flag & NFSMNT_INT) == 0) intrflg = 0; - if ((nmp->nm_mountp->mnt_kern_flag & MNTK_UNMOUNTF)) + if (NFSCL_FORCEDISM(nmp->nm_mountp)) intrflg = 1; if (intrflg) { slpflag = PCATCH; Modified: stable/11/sys/fs/nfsclient/nfs_clport.c ============================================================================== --- stable/11/sys/fs/nfsclient/nfs_clport.c Fri Aug 25 22:38:55 2017 (r322906) +++ stable/11/sys/fs/nfsclient/nfs_clport.c Fri Aug 25 22:39:49 2017 (r322907) @@ -313,7 +313,7 @@ nfscl_ngetreopen(struct mount *mntp, u_int8_t *fhp, in *npp = NULL; /* For forced dismounts, just return error. */ - if ((mntp->mnt_kern_flag & MNTK_UNMOUNTF)) + if (NFSCL_FORCEDISM(mntp)) return (EINTR); MALLOC(nfhp, struct nfsfh *, sizeof (struct nfsfh) + fhsize, M_NFSFH, M_WAITOK); @@ -336,7 +336,7 @@ nfscl_ngetreopen(struct mount *mntp, u_int8_t *fhp, in * stopped and the MNTK_UNMOUNTF flag is set before doing * a vflush() with FORCECLOSE, we should be ok here. */ - if ((mntp->mnt_kern_flag & MNTK_UNMOUNTF)) + if (NFSCL_FORCEDISM(mntp)) error = EINTR; else { vfs_hash_ref(mntp, hash, td, &nvp, newnfs_vncmpf, nfhp); Modified: stable/11/sys/fs/nfsclient/nfs_clstate.c ============================================================================== --- stable/11/sys/fs/nfsclient/nfs_clstate.c Fri Aug 25 22:38:55 2017 (r322906) +++ stable/11/sys/fs/nfsclient/nfs_clstate.c Fri Aug 25 22:39:49 2017 (r322907) @@ -803,7 +803,7 @@ nfscl_getcl(struct mount *mp, struct ucred *cred, NFSP * allocate a new clientid and get out now. For the case where * clp != NULL, this is a harmless optimization. */ - if ((mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) { + if (NFSCL_FORCEDISM(mp)) { NFSUNLOCKCLSTATE(); if (newclp != NULL) free(newclp, M_NFSCLCLIENT); @@ -843,7 +843,7 @@ nfscl_getcl(struct mount *mp, struct ucred *cred, NFSP } NFSLOCKCLSTATE(); while ((clp->nfsc_flags & NFSCLFLAGS_HASCLIENTID) == 0 && !igotlock && - (mp->mnt_kern_flag & MNTK_UNMOUNTF) == 0) + !NFSCL_FORCEDISM(mp)) igotlock = nfsv4_lock(&clp->nfsc_lock, 1, NULL, NFSCLSTATEMUTEXPTR, mp); if (igotlock == 0) { @@ -858,10 +858,10 @@ nfscl_getcl(struct mount *mp, struct ucred *cred, NFSP nfsv4_lock(&clp->nfsc_lock, 0, NULL, NFSCLSTATEMUTEXPTR, mp); nfsv4_getref(&clp->nfsc_lock, NULL, NFSCLSTATEMUTEXPTR, mp); } - if (igotlock == 0 && (mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) { + if (igotlock == 0 && NFSCL_FORCEDISM(mp)) { /* * Both nfsv4_lock() and nfsv4_getref() know to check - * for MNTK_UNMOUNTF and return without sleeping to + * for NFSCL_FORCEDISM() and return without sleeping to * wait for the exclusive lock to be released, since it * might be held by nfscl_umount() and we need to get out * now for that case and not wait until nfscl_umount() @@ -4844,7 +4844,7 @@ nfscl_layout(struct nfsmount *nmp, vnode_t vp, u_int8_ lyp->nfsly_timestamp = NFSD_MONOSEC + 120; } nfsv4_getref(&lyp->nfsly_lock, NULL, NFSCLSTATEMUTEXPTR, mp); - if ((mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) { + if (NFSCL_FORCEDISM(mp)) { NFSUNLOCKCLSTATE(); if (tlyp != NULL) free(tlyp, M_NFSLAYOUT); @@ -4903,11 +4903,10 @@ nfscl_getlayout(struct nfsclclient *clp, uint8_t *fhp, do { igotlock = nfsv4_lock(&lyp->nfsly_lock, 1, NULL, NFSCLSTATEMUTEXPTR, mp); - } while (igotlock == 0 && - (mp->mnt_kern_flag & MNTK_UNMOUNTF) == 0); + } while (igotlock == 0 && !NFSCL_FORCEDISM(mp)); *retflpp = NULL; } - if ((mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) { + if (NFSCL_FORCEDISM(mp)) { lyp = NULL; *recalledp = 1; } @@ -5298,7 +5297,7 @@ nfscl_layoutcommit(vnode_t vp, NFSPROC_T *p) return (EPERM); } nfsv4_getref(&lyp->nfsly_lock, NULL, NFSCLSTATEMUTEXPTR, mp); - if ((mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) { + if (NFSCL_FORCEDISM(mp)) { NFSUNLOCKCLSTATE(); return (EPERM); } Modified: stable/11/sys/fs/nfsclient/nfs_clvfsops.c ============================================================================== --- stable/11/sys/fs/nfsclient/nfs_clvfsops.c Fri Aug 25 22:38:55 2017 (r322906) +++ stable/11/sys/fs/nfsclient/nfs_clvfsops.c Fri Aug 25 22:39:49 2017 (r322907) @@ -1775,7 +1775,7 @@ nfs_sync(struct mount *mp, int waitfor) * the umount(2) syscall doesn't get stuck in VFS_SYNC() before * calling VFS_UNMOUNT(). */ - if ((mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) { + if (NFSCL_FORCEDISM(mp)) { MNT_IUNLOCK(mp); return (EBADF); } Modified: stable/11/sys/fs/nfsclient/nfs_clvnops.c ============================================================================== --- stable/11/sys/fs/nfsclient/nfs_clvnops.c Fri Aug 25 22:38:55 2017 (r322906) +++ stable/11/sys/fs/nfsclient/nfs_clvnops.c Fri Aug 25 22:39:49 2017 (r322907) @@ -665,7 +665,7 @@ nfs_close(struct vop_close_args *ap) int error = 0, ret, localcred = 0; int fmode = ap->a_fflag; - if ((vp->v_mount->mnt_kern_flag & MNTK_UNMOUNTF)) + if (NFSCL_FORCEDISM(vp->v_mount)) return (0); /* * During shutdown, a_cred isn't valid, so just use root. From owner-svn-src-stable@freebsd.org Fri Aug 25 22:44:56 2017 Return-Path: Delivered-To: svn-src-stable@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 68BE9DE3078; Fri, 25 Aug 2017 22:44:56 +0000 (UTC) (envelope-from rmacklem@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 34F8C73813; Fri, 25 Aug 2017 22:44:56 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7PMit71016638; Fri, 25 Aug 2017 22:44:55 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7PMitD7016636; Fri, 25 Aug 2017 22:44:55 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201708252244.v7PMitD7016636@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Fri, 25 Aug 2017 22:44: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: r322908 - stable/11/sys/fs/nfsclient X-SVN-Group: stable-11 X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: stable/11/sys/fs/nfsclient X-SVN-Commit-Revision: 322908 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2017 22:44:56 -0000 Author: rmacklem Date: Fri Aug 25 22:44:55 2017 New Revision: 322908 URL: https://svnweb.freebsd.org/changeset/base/322908 Log: MFC: r321675 Fix possible crash for the NFSv4.1 pNFS client. If the nfsrpc_createlayoutrpc() call in nfsrpc_getcreatelayout() fails, the code used nfhpp when it might be set NULL. This patch checks for the error cases (laystat != 0) and avoids using nfhpp for the failure case. This would only affect NFSv4.1 mounts with the "pnfs" option. Found while testing the "umount -N" patch not yet in head. Modified: stable/11/sys/fs/nfsclient/nfs_clrpcops.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/nfsclient/nfs_clrpcops.c ============================================================================== --- stable/11/sys/fs/nfsclient/nfs_clrpcops.c Fri Aug 25 22:39:49 2017 (r322907) +++ stable/11/sys/fs/nfsclient/nfs_clrpcops.c Fri Aug 25 22:44:55 2017 (r322908) @@ -6633,9 +6633,14 @@ nfsrpc_getcreatelayout(vnode_t dvp, char *name, int na NFSCL_DEBUG(4, "aft nfsrpc_createlayoutrpc laystat=%d err=%d\n", laystat, error); lyp = NULL; - nfhp = *nfhpp; - laystat = nfsrpc_layoutgetres(nmp, dvp, nfhp->nfh_fh, nfhp->nfh_len, - &stateid, retonclose, NULL, &lyp, &flh, laystat, NULL, cred, p); + if (laystat == 0) { + nfhp = *nfhpp; + laystat = nfsrpc_layoutgetres(nmp, dvp, nfhp->nfh_fh, + nfhp->nfh_len, &stateid, retonclose, NULL, &lyp, &flh, + laystat, NULL, cred, p); + } else + laystat = nfsrpc_layoutgetres(nmp, dvp, NULL, 0, &stateid, + retonclose, NULL, &lyp, &flh, laystat, NULL, cred, p); if (laystat == 0) nfscl_rellayout(lyp, 0); return (error); From owner-svn-src-stable@freebsd.org Fri Aug 25 22:52:42 2017 Return-Path: Delivered-To: svn-src-stable@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 8124CDE32E0; Fri, 25 Aug 2017 22:52:42 +0000 (UTC) (envelope-from rmacklem@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 5B99E73CA1; Fri, 25 Aug 2017 22:52:42 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7PMqfre020869; Fri, 25 Aug 2017 22:52:41 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7PMqerH020862; Fri, 25 Aug 2017 22:52:40 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201708252252.v7PMqerH020862@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Fri, 25 Aug 2017 22:52: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: r322909 - in stable/11/sys: fs/nfs fs/nfsclient nfs sys X-SVN-Group: stable-11 X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: in stable/11/sys: fs/nfs fs/nfsclient nfs sys X-SVN-Commit-Revision: 322909 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2017 22:52:42 -0000 Author: rmacklem Date: Fri Aug 25 22:52:40 2017 New Revision: 322909 URL: https://svnweb.freebsd.org/changeset/base/322909 Log: MFC: r321688 Add kernel support for the NFS client forced dismount "umount -N" option. When an NFS mount is hung against an unresponsive NFS server, the "umount -f" option can be used to dismount the mount. Unfortunately, "umount -f" gets hung as well if a "umount" without "-f" has already been done. Usually, this is because of a vnode lock being held by the "umount" for the mounted-on vnode. This patch adds kernel code so that a new "-N" option can be added to "umount", allowing it to avoid getting hung for this case. It adds two flags. One indicates that a forced dismount is about to happen and the other is used, along with setting mnt_data == NULL, to handshake with the nfs_unmount() VFS call. It includes a slight change to the interface used between the client and common NFS modules, so I bumped __FreeBSD_version to ensure both modules are rebuilt. Modified: stable/11/sys/fs/nfs/nfscl.h stable/11/sys/fs/nfsclient/nfs_clport.c stable/11/sys/fs/nfsclient/nfs_clvfsops.c stable/11/sys/fs/nfsclient/nfsmount.h stable/11/sys/nfs/nfs_nfssvc.c stable/11/sys/nfs/nfssvc.h stable/11/sys/sys/param.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/nfs/nfscl.h ============================================================================== --- stable/11/sys/fs/nfs/nfscl.h Fri Aug 25 22:44:55 2017 (r322908) +++ stable/11/sys/fs/nfs/nfscl.h Fri Aug 25 22:52:40 2017 (r322909) @@ -60,7 +60,8 @@ struct nfsv4node { #define NFSCL_LEASE(r) ((r) * 2) /* This macro checks to see if a forced dismount is about to occur. */ -#define NFSCL_FORCEDISM(m) (((m)->mnt_kern_flag & MNTK_UNMOUNTF) != 0) +#define NFSCL_FORCEDISM(m) (((m)->mnt_kern_flag & MNTK_UNMOUNTF) != 0 || \ + (VFSTONFS(m)->nm_privflag & NFSMNTP_FORCEDISM) != 0) /* * These flag bits are used for the argument to nfscl_fillsattr() to Modified: stable/11/sys/fs/nfsclient/nfs_clport.c ============================================================================== --- stable/11/sys/fs/nfsclient/nfs_clport.c Fri Aug 25 22:44:55 2017 (r322908) +++ stable/11/sys/fs/nfsclient/nfs_clport.c Fri Aug 25 22:52:40 2017 (r322909) @@ -1313,6 +1313,8 @@ nfssvc_nfscl(struct thread *td, struct nfssvc_args *ua cap_rights_t rights; char *buf; int error; + struct mount *mp; + struct nfsmount *nmp; if (uap->flag & NFSSVC_CBADDSOCK) { error = copyin(uap->argp, (caddr_t)&nfscbdarg, sizeof(nfscbdarg)); @@ -1367,6 +1369,56 @@ nfssvc_nfscl(struct thread *td, struct nfssvc_args *ua dumpmntopts.ndmnt_blen); free(buf, M_TEMP); } + } else if (uap->flag & NFSSVC_FORCEDISM) { + buf = malloc(MNAMELEN + 1, M_TEMP, M_WAITOK); + error = copyinstr(uap->argp, buf, MNAMELEN + 1, NULL); + if (error == 0) { + nmp = NULL; + mtx_lock(&mountlist_mtx); + TAILQ_FOREACH(mp, &mountlist, mnt_list) { + if (strcmp(mp->mnt_stat.f_mntonname, buf) == + 0 && strcmp(mp->mnt_stat.f_fstypename, + "nfs") == 0 && mp->mnt_data != NULL) { + nmp = VFSTONFS(mp); + mtx_lock(&nmp->nm_mtx); + if ((nmp->nm_privflag & + NFSMNTP_FORCEDISM) == 0) { + nmp->nm_privflag |= + (NFSMNTP_FORCEDISM | + NFSMNTP_CANCELRPCS); + mtx_unlock(&nmp->nm_mtx); + } else { + nmp = NULL; + mtx_unlock(&nmp->nm_mtx); + } + break; + } + } + mtx_unlock(&mountlist_mtx); + + if (nmp != NULL) { + /* + * Call newnfs_nmcancelreqs() to cause + * any RPCs in progress on the mount point to + * fail. + * This will cause any process waiting for an + * RPC to complete while holding a vnode lock + * on the mounted-on vnode (such as "df" or + * a non-forced "umount") to fail. + * This will unlock the mounted-on vnode so + * a forced dismount can succeed. + * Then clear NFSMNTP_CANCELRPCS and wakeup(), + * so that nfs_unmount() can complete. + */ + newnfs_nmcancelreqs(nmp); + mtx_lock(&nmp->nm_mtx); + nmp->nm_privflag &= ~NFSMNTP_CANCELRPCS; + wakeup(nmp); + mtx_unlock(&nmp->nm_mtx); + } else + error = EINVAL; + } + free(buf, M_TEMP); } else { error = EINVAL; } Modified: stable/11/sys/fs/nfsclient/nfs_clvfsops.c ============================================================================== --- stable/11/sys/fs/nfsclient/nfs_clvfsops.c Fri Aug 25 22:44:55 2017 (r322908) +++ stable/11/sys/fs/nfsclient/nfs_clvfsops.c Fri Aug 25 22:52:40 2017 (r322909) @@ -1698,6 +1698,11 @@ nfs_unmount(struct mount *mp, int mntflags) */ if ((mntflags & MNT_FORCE) == 0) nfscl_umount(nmp, td); + else { + mtx_lock(&nmp->nm_mtx); + nmp->nm_privflag |= NFSMNTP_FORCEDISM; + mtx_unlock(&nmp->nm_mtx); + } /* Make sure no nfsiods are assigned to this mount. */ mtx_lock(&ncl_iod_mutex); for (i = 0; i < NFS_MAXASYNCDAEMON; i++) @@ -1706,6 +1711,19 @@ nfs_unmount(struct mount *mp, int mntflags) ncl_iodmount[i] = NULL; } mtx_unlock(&ncl_iod_mutex); + + /* + * We can now set mnt_data to NULL and wait for + * nfssvc(NFSSVC_FORCEDISM) to complete. + */ + mtx_lock(&mountlist_mtx); + mtx_lock(&nmp->nm_mtx); + mp->mnt_data = NULL; + mtx_unlock(&mountlist_mtx); + while ((nmp->nm_privflag & NFSMNTP_CANCELRPCS) != 0) + msleep(nmp, &nmp->nm_mtx, PVFS, "nfsfdism", 0); + mtx_unlock(&nmp->nm_mtx); + newnfs_disconnect(&nmp->nm_sockreq); crfree(nmp->nm_sockreq.nr_cred); FREE(nmp->nm_nam, M_SONAME); Modified: stable/11/sys/fs/nfsclient/nfsmount.h ============================================================================== --- stable/11/sys/fs/nfsclient/nfsmount.h Fri Aug 25 22:44:55 2017 (r322908) +++ stable/11/sys/fs/nfsclient/nfsmount.h Fri Aug 25 22:52:40 2017 (r322909) @@ -44,6 +44,7 @@ */ struct nfsmount { struct nfsmount_common nm_com; /* Common fields for nlm */ + uint32_t nm_privflag; /* Private flags */ int nm_numgrps; /* Max. size of groupslist */ u_char nm_fh[NFSX_FHMAX]; /* File handle of root dir */ int nm_fhsize; /* Size of root file handle */ @@ -98,6 +99,10 @@ struct nfsmount { #define nm_hostname nm_com.nmcom_hostname #define nm_getinfo nm_com.nmcom_getinfo #define nm_vinvalbuf nm_com.nmcom_vinvalbuf + +/* Private flags. */ +#define NFSMNTP_FORCEDISM 0x00000001 +#define NFSMNTP_CANCELRPCS 0x00000002 #define NFSMNT_DIRPATH(m) (&((m)->nm_name[(m)->nm_krbnamelen + 1])) #define NFSMNT_SRVKRBNAME(m) \ Modified: stable/11/sys/nfs/nfs_nfssvc.c ============================================================================== --- stable/11/sys/nfs/nfs_nfssvc.c Fri Aug 25 22:44:55 2017 (r322908) +++ stable/11/sys/nfs/nfs_nfssvc.c Fri Aug 25 22:52:40 2017 (r322909) @@ -92,7 +92,7 @@ sys_nfssvc(struct thread *td, struct nfssvc_args *uap) nfsd_call_nfsserver != NULL) error = (*nfsd_call_nfsserver)(td, uap); else if ((uap->flag & (NFSSVC_CBADDSOCK | NFSSVC_NFSCBD | - NFSSVC_DUMPMNTOPTS)) && nfsd_call_nfscl != NULL) + NFSSVC_DUMPMNTOPTS | NFSSVC_FORCEDISM)) && nfsd_call_nfscl != NULL) error = (*nfsd_call_nfscl)(td, uap); else if ((uap->flag & (NFSSVC_IDNAME | NFSSVC_GETSTATS | NFSSVC_GSSDADDPORT | NFSSVC_GSSDADDFIRST | NFSSVC_GSSDDELETEALL | Modified: stable/11/sys/nfs/nfssvc.h ============================================================================== --- stable/11/sys/nfs/nfssvc.h Fri Aug 25 22:44:55 2017 (r322908) +++ stable/11/sys/nfs/nfssvc.h Fri Aug 25 22:52:40 2017 (r322909) @@ -70,6 +70,7 @@ #define NFSSVC_RESUMENFSD 0x08000000 #define NFSSVC_DUMPMNTOPTS 0x10000000 #define NFSSVC_NEWSTRUCT 0x20000000 +#define NFSSVC_FORCEDISM 0x40000000 /* Argument structure for NFSSVC_DUMPMNTOPTS. */ struct nfscl_dumpmntopts { Modified: stable/11/sys/sys/param.h ============================================================================== --- stable/11/sys/sys/param.h Fri Aug 25 22:44:55 2017 (r322908) +++ stable/11/sys/sys/param.h Fri Aug 25 22:52:40 2017 (r322909) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1101501 /* Master, propagated to newvers */ +#define __FreeBSD_version 1101502 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-stable@freebsd.org Fri Aug 25 22:58:55 2017 Return-Path: Delivered-To: svn-src-stable@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 45D45DE33D8; Fri, 25 Aug 2017 22:58:55 +0000 (UTC) (envelope-from rmacklem@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 1FF4F73F3E; Fri, 25 Aug 2017 22:58:55 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7PMwsIc021292; Fri, 25 Aug 2017 22:58:54 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7PMwsRb021290; Fri, 25 Aug 2017 22:58:54 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201708252258.v7PMwsRb021290@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Fri, 25 Aug 2017 22:58:54 +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: r322910 - stable/11/sbin/umount X-SVN-Group: stable-11 X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: stable/11/sbin/umount X-SVN-Commit-Revision: 322910 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2017 22:58:55 -0000 Author: rmacklem Date: Fri Aug 25 22:58:54 2017 New Revision: 322910 URL: https://svnweb.freebsd.org/changeset/base/322910 Log: MFC: r321689 Add a new "-N" option to umount(8), that does a forced dismount of an NFS mount point. The new "-N" option does a forced dismount of an NFS mount point, but avoids doing any checking of the mounted-on path, so that it will not get hung when a vnode lock is held by another hung process on the mounted-on vnode. The most common case of this is a "umount" with the "-f" option. Other than avoiding checking the mounted-on path, it performs the same forced dismount as a successful "umount -f" would do. This commit includes a content change to the man page. Modified: stable/11/sbin/umount/umount.8 stable/11/sbin/umount/umount.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/umount/umount.8 ============================================================================== --- stable/11/sbin/umount/umount.8 Fri Aug 25 22:52:40 2017 (r322909) +++ stable/11/sbin/umount/umount.8 Fri Aug 25 22:58:54 2017 (r322910) @@ -28,7 +28,7 @@ .\" @(#)umount.8 8.2 (Berkeley) 5/8/95 .\" $FreeBSD$ .\" -.Dd July 7, 2016 +.Dd July 25, 2017 .Dt UMOUNT 8 .Os .Sh NAME @@ -36,7 +36,7 @@ .Nd unmount file systems .Sh SYNOPSIS .Nm -.Op Fl fnv +.Op Fl fNnv .Ar special ... | node ... | fsid ... .Nm .Fl a | A @@ -81,6 +81,15 @@ The root file system cannot be forcibly unmounted. For NFS, a forced dismount can take up to 1 minute or more to complete against an unresponsive server and may throw away data not yet written to the server for this case. +If a process, such as +.Nm +without the +.Fl f +flag is hung on an +.Tn NFS +mount point, use the +.Fl N +flag instead. Also, doing a forced dismount of an NFSv3 mount when .Xr rpc.lockd 8 is running is unsafe and can result in a crash. @@ -94,6 +103,24 @@ option and, unless otherwise specified with the option, will only unmount .Tn NFS file systems. +.It Fl N +Do a forced dismount of an +.Tn NFS +mount point without checking the mount path. +This option can only be used with the path to the mount point +.Ar node +and the path must be specified exactly as it was at mount time. +This option is useful when a process is hung waiting for an unresponsive +.Tn NFS +server while holding a vnode lock on the mounted-on vnode, such that +.Nm +with the +.Fl f +flag can't complete. +Using this option can result in a loss of file updates that have not been +flushed to the +.Tn NFS +server. .It Fl n Unless the .Fl f Modified: stable/11/sbin/umount/umount.c ============================================================================== --- stable/11/sbin/umount/umount.c Fri Aug 25 22:52:40 2017 (r322909) +++ stable/11/sbin/umount/umount.c Fri Aug 25 22:58:54 2017 (r322910) @@ -86,13 +86,13 @@ int xdr_dir (XDR *, char *); int main(int argc, char *argv[]) { - int all, errs, ch, mntsize, error; + int all, errs, ch, mntsize, error, nfsforce, ret; char **typelist = NULL; struct statfs *mntbuf, *sfs; struct addrinfo hints; - all = errs = 0; - while ((ch = getopt(argc, argv, "AaF:fh:nt:v")) != -1) + nfsforce = all = errs = 0; + while ((ch = getopt(argc, argv, "AaF:fh:Nnt:v")) != -1) switch (ch) { case 'A': all = 2; @@ -110,6 +110,9 @@ main(int argc, char *argv[]) all = 2; nfshost = optarg; break; + case 'N': + nfsforce = 1; + break; case 'n': fflag |= MNT_NONBUSY; break; @@ -132,12 +135,15 @@ main(int argc, char *argv[]) err(1, "-f and -n are mutually exclusive"); /* Start disks transferring immediately. */ - if ((fflag & (MNT_FORCE | MNT_NONBUSY)) == 0) + if ((fflag & (MNT_FORCE | MNT_NONBUSY)) == 0 && nfsforce == 0) sync(); if ((argc == 0 && !all) || (argc != 0 && all)) usage(); + if (nfsforce != 0 && (argc == 0 || nfshost != NULL || typelist != NULL)) + usage(); + /* -h implies "-t nfs" if no -t flag. */ if ((nfshost != NULL) && (typelist == NULL)) typelist = makevfslist("nfs"); @@ -175,7 +181,20 @@ main(int argc, char *argv[]) break; case 0: for (errs = 0; *argv != NULL; ++argv) - if (checkname(*argv, typelist) != 0) + if (nfsforce != 0) { + /* + * First do the nfssvc() syscall to shut down + * the mount point and then do the forced + * dismount. + */ + ret = nfssvc(NFSSVC_FORCEDISM, *argv); + if (ret >= 0) + ret = unmount(*argv, MNT_FORCE); + if (ret < 0) { + warn("%s", *argv); + errs = 1; + } + } else if (checkname(*argv, typelist) != 0) errs = 1; break; } @@ -635,7 +654,7 @@ usage(void) { (void)fprintf(stderr, "%s\n%s\n", - "usage: umount [-fnv] special ... | node ... | fsid ...", + "usage: umount [-fNnv] special ... | node ... | fsid ...", " umount -a | -A [-F fstab] [-fnv] [-h host] [-t type]"); exit(1); } From owner-svn-src-stable@freebsd.org Sat Aug 26 00:29:08 2017 Return-Path: Delivered-To: svn-src-stable@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 B3D38DE4E67; Sat, 26 Aug 2017 00:29:08 +0000 (UTC) (envelope-from emaste@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 8120B76ADC; Sat, 26 Aug 2017 00:29:08 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7Q0T7dW058081; Sat, 26 Aug 2017 00:29:07 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7Q0T7RI058080; Sat, 26 Aug 2017 00:29:07 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201708260029.v7Q0T7RI058080@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Sat, 26 Aug 2017 00:29: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: r322916 - stable/11/sys/modules X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/sys/modules X-SVN-Commit-Revision: 322916 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Aug 2017 00:29:08 -0000 Author: emaste Date: Sat Aug 26 00:29:07 2017 New Revision: 322916 URL: https://svnweb.freebsd.org/changeset/base/322916 Log: sys/modules: don't build bxe,qlxgbe if the user objects to sourceless ucode MFC of r322682 and r322684 Sponsored by: The FreeBSD Foundation Modified: stable/11/sys/modules/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/modules/Makefile ============================================================================== --- stable/11/sys/modules/Makefile Sat Aug 26 00:17:57 2017 (r322915) +++ stable/11/sys/modules/Makefile Sat Aug 26 00:29:07 2017 (r322916) @@ -565,7 +565,9 @@ _an= an _aout= aout _bios= bios _bktr= bktr +.if ${MK_SOURCELESS_UCODE} != "no" _bxe= bxe +.endif _cardbus= cardbus _cbb= cbb _cpuctl= cpuctl @@ -708,7 +710,9 @@ _ntb= ntb _pms= pms _qlxge= qlxge _qlxgb= qlxgb +.if ${MK_SOURCELESS_UCODE} != "no" _qlxgbe= qlxgbe +.endif _qlnx= qlnx _sfxge= sfxge From owner-svn-src-stable@freebsd.org Sat Aug 26 00:30:15 2017 Return-Path: Delivered-To: svn-src-stable@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 252C6DE5016; Sat, 26 Aug 2017 00:30:15 +0000 (UTC) (envelope-from emaste@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 E235D76C57; Sat, 26 Aug 2017 00:30:14 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7Q0UDMY058191; Sat, 26 Aug 2017 00:30:13 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7Q0UD1k058190; Sat, 26 Aug 2017 00:30:13 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201708260030.v7Q0UD1k058190@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Sat, 26 Aug 2017 00:30: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: r322917 - stable/11/share/man/man4 X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/share/man/man4 X-SVN-Commit-Revision: 322917 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Aug 2017 00:30:15 -0000 Author: emaste Date: Sat Aug 26 00:30:13 2017 New Revision: 322917 URL: https://svnweb.freebsd.org/changeset/base/322917 Log: MFC r322680: sa.4: fix spelling of 'suppresses' PR: 221302 Modified: stable/11/share/man/man4/sa.4 Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man4/sa.4 ============================================================================== --- stable/11/share/man/man4/sa.4 Sat Aug 26 00:29:07 2017 (r322916) +++ stable/11/share/man/man4/sa.4 Sat Aug 26 00:30:13 2017 (r322917) @@ -270,7 +270,7 @@ on tape reads. Tape drives normally return sense data (which contains the residual) when the application reads a block that is not the same length as the amount of data requested. -The SILI bit supresses that notification in most cases. +The SILI bit suppresses that notification in most cases. See the SSC-5 spec (available at t10.org), specifically the section on the READ(6) command, for more information. .It eot_warn From owner-svn-src-stable@freebsd.org Sat Aug 26 00:31:00 2017 Return-Path: Delivered-To: svn-src-stable@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 7CFE5DE50A1; Sat, 26 Aug 2017 00:31:00 +0000 (UTC) (envelope-from emaste@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 5777576EBC; Sat, 26 Aug 2017 00:31:00 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7Q0Ux5G060399; Sat, 26 Aug 2017 00:30:59 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7Q0Uxq7060398; Sat, 26 Aug 2017 00:30:59 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201708260030.v7Q0Uxq7060398@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Sat, 26 Aug 2017 00:30: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: r322918 - stable/11/share/man/man4 X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/share/man/man4 X-SVN-Commit-Revision: 322918 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Aug 2017 00:31:00 -0000 Author: emaste Date: Sat Aug 26 00:30:59 2017 New Revision: 322918 URL: https://svnweb.freebsd.org/changeset/base/322918 Log: MFC r322683: ena.4: fix spelling of 'occurred' PR: 331298 Modified: stable/11/share/man/man4/ena.4 Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man4/ena.4 ============================================================================== --- stable/11/share/man/man4/ena.4 Sat Aug 26 00:30:13 2017 (r322917) +++ stable/11/share/man/man4/ena.4 Sat Aug 26 00:30:59 2017 (r322918) @@ -102,7 +102,7 @@ Supported PCI vendor ID/device IDs: .Bl -diag .It ena%d: failed to init mmio read less .Pp -Error occured during initialization of the mmio register read request. +Error occurred during initialization of the mmio register read request. .It ena%d: Can not reset device .Pp Device could not be reset; device may not be responding or is already @@ -123,7 +123,7 @@ was a problem with initialization of the resources. Failed to get attributes of the device from the controller. .It ena%d: Cannot configure aenq groups rc: %d .Pp -Errors occured when trying to configure AENQ groups. +Errors occurred when trying to configure AENQ groups. .El .Ss Driver initialisation/shutdown phase: .Bl -diag @@ -148,13 +148,13 @@ be attached. Device initialization failed; driver will not be attached. .It ena%d: could not activate irq vector: %d .Pp -Error occured when trying to activate interrupt vectors for Admin Queue. +Error occurred when trying to activate interrupt vectors for Admin Queue. .It ena%d: failed to register interrupt handler for irq %ju: %d .Pp -Error occured when trying to register Admin Queue interrupt handler. +Error occurred when trying to register Admin Queue interrupt handler. .It ena%d: Cannot setup mgmnt queue intr .Pp -Error occured during configuration of the Admin Queue interrupts. +Error occurred during configuration of the Admin Queue interrupts. .It ena%d: Enable MSI-X failed .Pp Configuration of the MSI-X for Admin Queue failed; there could be lack @@ -167,7 +167,7 @@ first and then detach routine should be called again. .It ena%d: Unmapped RX DMA tag associations .It ena%d: Unmapped TX DMA tag associations .Pp -Error occured when trying to destroy RX/TX DMA tag. +Error occurred when trying to destroy RX/TX DMA tag. .It ena%d: Cannot init RSS .It ena%d: Cannot fill indirect table .It ena%d: Cannot fill indirect table @@ -175,7 +175,7 @@ Error occured when trying to destroy RX/TX DMA tag. .It ena%d: Cannot fill hash control .It ena%d: WARNING: RSS was not properly initialized, it will affect bandwidth .Pp -Error occured during initialization of one of RSS resources; device is still +Error occurred during initialization of one of RSS resources; device is still going to work but it will affect performance because all RX packets will be passed to queue 0 and there will be no hash information. .It ena%d: failed to tear down irq: %d From owner-svn-src-stable@freebsd.org Sat Aug 26 00:35:51 2017 Return-Path: Delivered-To: svn-src-stable@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 45BACDE52B4; Sat, 26 Aug 2017 00:35:51 +0000 (UTC) (envelope-from emaste@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 0F55877125; Sat, 26 Aug 2017 00:35:50 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7Q0ZowI062264; Sat, 26 Aug 2017 00:35:50 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7Q0ZnST062262; Sat, 26 Aug 2017 00:35:49 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201708260035.v7Q0ZnST062262@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Sat, 26 Aug 2017 00:35: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: r322919 - in stable/11/usr.sbin/pw: . tests X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: in stable/11/usr.sbin/pw: . tests X-SVN-Commit-Revision: 322919 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Aug 2017 00:35:51 -0000 Author: emaste Date: Sat Aug 26 00:35:49 2017 New Revision: 322919 URL: https://svnweb.freebsd.org/changeset/base/322919 Log: MFC r322677: pw usermod: Properly deal with empty secondary group lists (-G '') PR: 221417 Relnotes: Yes Modified: stable/11/usr.sbin/pw/pw_user.c stable/11/usr.sbin/pw/tests/pw_usermod_test.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/pw/pw_user.c ============================================================================== --- stable/11/usr.sbin/pw/pw_user.c Sat Aug 26 00:30:59 2017 (r322918) +++ stable/11/usr.sbin/pw/pw_user.c Sat Aug 26 00:35:49 2017 (r322919) @@ -1087,10 +1087,10 @@ split_groups(StringList **groups, char *groupsstr) char *p; char tok[] = ", \t"; + if (*groups == NULL) + *groups = sl_init(); for (p = strtok(groupsstr, tok); p != NULL; p = strtok(NULL, tok)) { grp = group_from_name_or_id(p); - if (*groups == NULL) - *groups = sl_init(); sl_add(*groups, newstr(grp->gr_name)); } } Modified: stable/11/usr.sbin/pw/tests/pw_usermod_test.sh ============================================================================== --- stable/11/usr.sbin/pw/tests/pw_usermod_test.sh Sat Aug 26 00:30:59 2017 (r322918) +++ stable/11/usr.sbin/pw/tests/pw_usermod_test.sh Sat Aug 26 00:35:49 2017 (r322919) @@ -128,6 +128,9 @@ user_mod_nogroups_body() { atf_check -s exit:0 ${PW} usermod foo -G test3,test4 atf_check -s exit:0 -o inline:"test3\ntest4\n" \ awk -F\: '$4 == "foo" { print $1 }' ${HOME}/group + atf_check -s exit:0 ${PW} usermod foo -G "" + atf_check -s exit:0 -o empty \ + awk -F\: '$4 == "foo" { print $1 }' ${HOME}/group } atf_test_case user_mod_rename