From owner-svn-src-stable@freebsd.org Sun Nov 3 02:52:42 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 343461A2A3B; Sun, 3 Nov 2019 02:52:42 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 475L7t0dKTz4XRC; Sun, 3 Nov 2019 02:52:42 +0000 (UTC) (envelope-from markj@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EDB6954A7; Sun, 3 Nov 2019 02:52:41 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA32qf7F004840; Sun, 3 Nov 2019 02:52:41 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA32qfHU004839; Sun, 3 Nov 2019 02:52:41 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201911030252.xA32qfHU004839@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Sun, 3 Nov 2019 02:52:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354273 - stable/12/sys/arm64/arm64 X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/arm64/arm64 X-SVN-Commit-Revision: 354273 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.29 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, 03 Nov 2019 02:52:42 -0000 Author: markj Date: Sun Nov 3 02:52:41 2019 New Revision: 354273 URL: https://svnweb.freebsd.org/changeset/base/354273 Log: MFC r354215: Fix a typo in r353895. Modified: stable/12/sys/arm64/arm64/machdep.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm64/arm64/machdep.c ============================================================================== --- stable/12/sys/arm64/arm64/machdep.c Sun Nov 3 02:18:45 2019 (r354272) +++ stable/12/sys/arm64/arm64/machdep.c Sun Nov 3 02:52:41 2019 (r354273) @@ -704,7 +704,7 @@ init_proc0(vm_offset_t kstack) thread0.td_kstack = kstack; thread0.td_kstack_pages = KSTACK_PAGES; thread0.td_pcb = (struct pcb *)(thread0.td_kstack + - thread0.td_kstack_pages * KSTACK_PAGES) - 1; + thread0.td_kstack_pages * PAGE_SIZE) - 1; thread0.td_pcb->pcb_fpflags = 0; thread0.td_pcb->pcb_fpusaved = &thread0.td_pcb->pcb_fpustate; thread0.td_pcb->pcb_vfpcpu = UINT_MAX; From owner-svn-src-stable@freebsd.org Sun Nov 3 07:11:09 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DD8F81A98D3; Sun, 3 Nov 2019 07:11:09 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 475Rt55T7cz3GXZ; Sun, 3 Nov 2019 07:11:09 +0000 (UTC) (envelope-from tsoome@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9F10481FC; Sun, 3 Nov 2019 07:11:09 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA37B9bT053602; Sun, 3 Nov 2019 07:11:09 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA37B9Ob053599; Sun, 3 Nov 2019 07:11:09 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201911030711.xA37B9Ob053599@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Sun, 3 Nov 2019 07:11:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354277 - stable/12/sys/cddl/boot/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: stable/12/sys/cddl/boot/zfs X-SVN-Commit-Revision: 354277 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.29 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, 03 Nov 2019 07:11:09 -0000 Author: tsoome Date: Sun Nov 3 07:11:09 2019 New Revision: 354277 URL: https://svnweb.freebsd.org/changeset/base/354277 Log: MFC: r354127 loader: zio_checksum_verify should check byteswap We do have both native and byteswap checksum callbacks in place but the selection is not wired. Modified: stable/12/sys/cddl/boot/zfs/zfsimpl.h stable/12/sys/cddl/boot/zfs/zfssubr.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cddl/boot/zfs/zfsimpl.h ============================================================================== --- stable/12/sys/cddl/boot/zfs/zfsimpl.h Sun Nov 3 03:23:27 2019 (r354276) +++ stable/12/sys/cddl/boot/zfs/zfsimpl.h Sun Nov 3 07:11:09 2019 (r354277) @@ -442,6 +442,13 @@ _NOTE(CONSTCOND) } while (0) ZIO_SET_CHECKSUM(&(bp)->blk_cksum, 0, 0, 0, 0); \ } +#if BYTE_ORDER == _BIG_ENDIAN +#define ZFS_HOST_BYTEORDER (0ULL) +#else +#define ZFS_HOST_BYTEORDER (1ULL) +#endif + +#define BP_SHOULD_BYTESWAP(bp) (BP_GET_BYTEORDER(bp) != ZFS_HOST_BYTEORDER) #define BPE_NUM_WORDS 14 #define BPE_PAYLOAD_SIZE (BPE_NUM_WORDS * sizeof (uint64_t)) #define BPE_IS_PAYLOADWORD(bp, wp) \ Modified: stable/12/sys/cddl/boot/zfs/zfssubr.c ============================================================================== --- stable/12/sys/cddl/boot/zfs/zfssubr.c Sun Nov 3 03:23:27 2019 (r354276) +++ stable/12/sys/cddl/boot/zfs/zfssubr.c Sun Nov 3 07:11:09 2019 (r354277) @@ -318,8 +318,9 @@ zio_checksum_verify(const spa_t *spa, const blkptr_t * byteswap_uint64_array(&expected_cksum, sizeof (zio_cksum_t)); } else { + byteswap = BP_SHOULD_BYTESWAP(bp); expected_cksum = bp->blk_cksum; - ci->ci_func[0](data, size, ctx, &actual_cksum); + ci->ci_func[byteswap](data, size, ctx, &actual_cksum); } if (!ZIO_CHECKSUM_EQUAL(actual_cksum, expected_cksum)) { From owner-svn-src-stable@freebsd.org Mon Nov 4 06:35:49 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2F42D1B466E; Mon, 4 Nov 2019 06:35:49 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47632s0Rp0z421J; Mon, 4 Nov 2019 06:35:49 +0000 (UTC) (envelope-from tsoome@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E726820124; Mon, 4 Nov 2019 06:35:48 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA46ZmxB014861; Mon, 4 Nov 2019 06:35:48 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA46ZmZq014860; Mon, 4 Nov 2019 06:35:48 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201911040635.xA46ZmZq014860@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Mon, 4 Nov 2019 06:35:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354330 - stable/12/stand/libsa X-SVN-Group: stable-12 X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: stable/12/stand/libsa X-SVN-Commit-Revision: 354330 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.29 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, 04 Nov 2019 06:35:49 -0000 Author: tsoome Date: Mon Nov 4 06:35:48 2019 New Revision: 354330 URL: https://svnweb.freebsd.org/changeset/base/354330 Log: MFC r354237: loader: asprinf does crash arm64 due to missing NULL pointer check PCHAR macro needs to check if d is NULL. Modified: stable/12/stand/libsa/printf.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/libsa/printf.c ============================================================================== --- stable/12/stand/libsa/printf.c Mon Nov 4 06:16:00 2019 (r354329) +++ stable/12/stand/libsa/printf.c Mon Nov 4 06:35:48 2019 (r354330) @@ -247,7 +247,17 @@ ksprintn(char *nbuf, uintmax_t num, int base, int *len static int kvprintf(char const *fmt, kvprintf_fn_t *func, void *arg, int radix, va_list ap) { -#define PCHAR(c) {int cc=(c); if (func) (*func)(cc, arg); else *d++ = cc; retval++; } +#define PCHAR(c) { \ + int cc = (c); \ + \ + if (func) { \ + (*func)(cc, arg); \ + } else if (d != NULL) { \ + *d++ = cc; \ + } \ + retval++; \ + } + char nbuf[MAXNBUF]; char *d; const char *p, *percent, *q; From owner-svn-src-stable@freebsd.org Mon Nov 4 09:50:01 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 07760179EE1; Mon, 4 Nov 2019 09:50:01 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4767Lw5ykgz4CYk; Mon, 4 Nov 2019 09:50:00 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AB38D2232A; Mon, 4 Nov 2019 09:50:00 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA49o0jS029235; Mon, 4 Nov 2019 09:50:00 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA49nwG7029183; Mon, 4 Nov 2019 09:49:58 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911040949.xA49nwG7029183@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Mon, 4 Nov 2019 09:49:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354331 - in stable/12: share/man/man4 share/man/man9 sys/amd64/conf sys/conf sys/dev/superio sys/i386/conf sys/modules sys/modules/superio X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in stable/12: share/man/man4 share/man/man9 sys/amd64/conf sys/conf sys/dev/superio sys/i386/conf sys/modules sys/modules/superio X-SVN-Commit-Revision: 354331 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.29 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, 04 Nov 2019 09:50:01 -0000 Author: avg Date: Mon Nov 4 09:49:58 2019 New Revision: 354331 URL: https://svnweb.freebsd.org/changeset/base/354331 Log: MFC r349580,r351740,r353432,r353433,r354079,r354080: add superio driver The goal of this driver is consolidate information about SuperIO chips and to provide for peaceful coexistence of drivers that need to access SuperIO configuration registers. While SuperIO chips can host various functions most of them are discoverable and accessible without any knowledge of the SuperIO. Examples are: keyboard and mouse controllers, UARTs, floppy disk controllers. SuperIO-s also provide non-standard functions such as GPIO, watchdog timers and hardware monitoring. Such functions do require drivers with a knowledge of a specific SuperIO. At this time the driver supports a number of ITE and Nuvoton (fka Winbond) SuperIO chips. There is a single driver for all devices. So, I have not done the usual split between the hardware driver and the bus functionality. Although, superio does act as a bus for devices that represent known non-standard functions of a SuperIO chip. The bus provides enumeration of child devices based on the hardcoded knowledge of such functions. The knowledge as extracted from datasheets and other drivers. As there is a single driver, I have not defined a kobj interface for it. So, its interface is currently made of simple functions. I think that we can the flexibility (and complications) when we actually need it. Added: stable/12/share/man/man4/superio.4 - copied, changed from r353432, head/share/man/man4/superio.4 stable/12/share/man/man9/superio.9 - copied unchanged from r353432, head/share/man/man9/superio.9 stable/12/sys/dev/superio/ - copied from r349580, head/sys/dev/superio/ stable/12/sys/dev/superio/superio_io.h - copied, changed from r354079, head/sys/dev/superio/superio_io.h stable/12/sys/modules/superio/ - copied from r349580, head/sys/modules/superio/ Modified: stable/12/share/man/man4/Makefile stable/12/share/man/man9/Makefile stable/12/sys/amd64/conf/NOTES stable/12/sys/conf/files.amd64 stable/12/sys/conf/files.i386 stable/12/sys/dev/superio/superio.c stable/12/sys/dev/superio/superio.h stable/12/sys/i386/conf/NOTES stable/12/sys/modules/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/Makefile ============================================================================== --- stable/12/share/man/man4/Makefile Mon Nov 4 06:35:48 2019 (r354330) +++ stable/12/share/man/man4/Makefile Mon Nov 4 09:49:58 2019 (r354331) @@ -521,6 +521,7 @@ MAN= aac.4 \ stf.4 \ stg.4 \ stge.4 \ + ${_superio.4} \ sym.4 \ syncache.4 \ syncer.4 \ @@ -830,6 +831,7 @@ _padlock.4= padlock.4 _rr232x.4= rr232x.4 _speaker.4= speaker.4 _spkr.4= spkr.4 +_superio.4= superio.4 _tpm.4= tpm.4 _urtw.4= urtw.4 _viawd.4= viawd.4 Copied and modified: stable/12/share/man/man4/superio.4 (from r353432, head/share/man/man4/superio.4) ============================================================================== --- head/share/man/man4/superio.4 Fri Oct 11 11:13:47 2019 (r353432, copy source) +++ stable/12/share/man/man4/superio.4 Mon Nov 4 09:49:58 2019 (r354331) @@ -74,7 +74,7 @@ that can only be accessed or discovered using the cont Some of the Super I/O devices have standardized interfaces. Such devices either use well-known legacy resources or they are advertised via ACPI or both. -They can be configured either using ISA bus hints or they are auto-aconfigured by +They can be configured either using ISA bus hints or they are auto-configured by .Xr acpi 4 . The .Nm Modified: stable/12/share/man/man9/Makefile ============================================================================== --- stable/12/share/man/man9/Makefile Mon Nov 4 06:35:48 2019 (r354330) +++ stable/12/share/man/man9/Makefile Mon Nov 4 09:49:58 2019 (r354331) @@ -301,6 +301,7 @@ MAN= accept_filter.9 \ store.9 \ style.9 \ style.lua.9 \ + ${_superio.9} \ swi.9 \ sx.9 \ syscall_helper_register.9 \ @@ -2295,5 +2296,24 @@ MLINKS+=zone.9 uma.9 \ zone.9 uma_zone_set_maxcache.9 \ zone.9 uma_zone_set_warning.9 \ zone.9 uma_zsecond_create.9 + +.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" +_superio.9= superio.9 +MLINKS+=superio.9 superio_devid.9 \ + superio.9 superio_dev_disable.9 \ + superio.9 superio_dev_enable.9 \ + superio.9 superio_dev_enabled.9 \ + superio.9 superio_find_dev.9 \ + superio.9 superio_find_dev.9 \ + superio.9 superio_get_dma.9 \ + superio.9 superio_get_iobase.9 \ + superio.9 superio_get_irq.9 \ + superio.9 superio_get_ldn.9 \ + superio.9 superio_get_type.9 \ + superio.9 superio_read.9 \ + superio.9 superio_revid.9 \ + superio.9 superio_vendor.9 \ + superio.9 superio_write.9 +.endif .include Copied: stable/12/share/man/man9/superio.9 (from r353432, head/share/man/man9/superio.9) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/share/man/man9/superio.9 Mon Nov 4 09:49:58 2019 (r354331, copy of r353432, head/share/man/man9/superio.9) @@ -0,0 +1,189 @@ +.\" +.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD +.\" +.\" Copyright (c) 2019 Andriy Gapon +.\" +.\" 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$ +.\" +.Dd October 11, 2019 +.Dt SUPERIO 9 +.Os +.Sh NAME +.Nm superio , +.Nm superio_devid , +.Nm superio_dev_disable , +.Nm superio_dev_enable , +.Nm superio_dev_enabled , +.Nm superio_find_dev , +.Nm superio_get_dma , +.Nm superio_get_iobase , +.Nm superio_get_irq , +.Nm superio_get_ldn , +.Nm superio_get_type , +.Nm superio_read , +.Nm superio_revid , +.Nm superio_vendor , +.Nm superio_write +.Nd Super I/O bus interface +.Sh SYNOPSIS +.In sys/bus.h +.In dev/superio/superio.h +.Ft uint16_t +.Fn superio_devid "device_t dev" +.Ft void +.Fn superio_dev_disable "device_t dev" "uint8_t mask" +.Ft void +.Fn superio_dev_enable "device_t dev" "uint8_t mask" +.Ft bool +.Fn superio_dev_enabled "device_t dev" "uint8_t mask" +.Ft device_t +.Fn superio_find_dev "device_t dev" "superio_dev_type_t type" "int ldn" +.Ft uint8_t +.Fn superio_get_dma "device_t dev" +.Ft uint16_t +.Fn superio_get_iobase "device_t dev" +.Ft uint8_t +.Fn superio_get_irq "device_t dev" +.Ft uint8_t +.Fn superio_get_ldn "device_t dev" +.Ft superio_dev_type_t +.Fn superio_get_type "device_t dev" +.Ft uint8_t +.Fn superio_read "device_t dev" "uint8_t reg" +.Ft uint8_t +.Fn superio_revid "device_t dev" +.Ft superio_vendor_t +.Fn superio_vendor "device_t dev" +.Ft void +.Fn superio_write "device_t dev" "uint8_t reg" "uint8_t val" +.Sh DESCRIPTION +The +.Nm +set of functions are used for managing Super I/O devices. +The functions provide support for +raw configuration access, +locating devices, +device information, +and +device configuration. +.Ss The controller interface +The +.Fn superio_vendor +function is used to get a vendor of the Super I/O controller +.Fa dev . +Possible return values are +.Dv SUPERIO_VENDOR_ITE +and +.Dv SUPERIO_VENDOR_NUVOTON . +.Pp +The +.Fn superio_devid +function is used to get a device ID of the Super I/O controller +.Fa dev . +.Pp +The +.Fn superio_revid +function is used to get a revision ID of the Super I/O controller +.Fa dev . +.Pp +The +.Fn superio_find_dev +function is used to find a device on the +.Xr superio 4 +bus, specified by +.Fa dev , +that has the requested type and logical device number. +Either of those, but not both, can be a wildcard. +Supported types are +.Dv SUPERIO_DEV_GPIO , +.Dv SUPERIO_DEV_HWM , +and +.Dv SUPERIO_DEV_WDT . +The wildcard value for +.Fa type +is +.Dv SUPERIO_DEV_NONE . +The wildcard value for +.Fa ldn +is -1. +.Ss The device interface +The +.Fn superio_read +function is used to read data from the Super I/O configuration register +of the device +.Fa dev . +.Pp +The +.Fn superio_write +function is used to write data to the Super I/O configuration register +of the device +.Fa dev . +.Pp +The +.Fn superio_dev_enable , +.Fn superio_dev_disable , +and +.Fn superio_dev_enabled +functions are used to enable, disable, or check status of the device +.Fa dev . +The +.Fa mask +parameter selects sub-functions of a device that supports them. +For devices that do not have sub-functions, +.Fa mask +should be set to 1. +.Ss The accessor interface +The +.Fn superio_get_dma +is used to get a DMA channel number configured for the device +.Fa dev . +.Pp +The +.Fn superio_get_iobase +is used to get a base I/O port configured for the device +.Fa dev . +The device may expose additional or alternative configuration access via +the I/O ports. +.Pp +The +.Fn superio_get_irq +is used to get an interrupt number configured for the device +.Fa dev . +.Pp +The +.Fn superio_get_ldn +is used to get a Logical Device Number of the device +.Fa dev . +.Pp +The +.Fn superio_get_type +is used to get a type of the device +.Fa dev . +.Sh SEE ALSO +.Xr superio 4 , +.Xr device 9 , +.Xr driver 9 +.Sh AUTHORS +This manual page was written by +.An Andriy Gapon Mt avg@FreeBSD.org Modified: stable/12/sys/amd64/conf/NOTES ============================================================================== --- stable/12/sys/amd64/conf/NOTES Mon Nov 4 06:35:48 2019 (r354330) +++ stable/12/sys/amd64/conf/NOTES Mon Nov 4 09:49:58 2019 (r354331) @@ -594,6 +594,11 @@ device amdtemp device cpuctl # +# SuperIO driver. +# +device superio + +# # System Management Bus (SMB) # options ENABLE_ALART # Control alarm on Intel intpm driver Modified: stable/12/sys/conf/files.amd64 ============================================================================== --- stable/12/sys/conf/files.amd64 Mon Nov 4 06:35:48 2019 (r354330) +++ stable/12/sys/conf/files.amd64 Mon Nov 4 09:49:58 2019 (r354331) @@ -491,6 +491,7 @@ dev/smartpqi/smartpqi_response.c optional smartpqi dev/smartpqi/smartpqi_sis.c optional smartpqi dev/smartpqi/smartpqi_tag.c optional smartpqi dev/speaker/spkr.c optional speaker +dev/superio/superio.c optional superio isa dev/syscons/apm/apm_saver.c optional apm_saver apm dev/syscons/scterm-teken.c optional sc dev/syscons/scvesactl.c optional sc vga vesa Modified: stable/12/sys/conf/files.i386 ============================================================================== --- stable/12/sys/conf/files.i386 Mon Nov 4 06:35:48 2019 (r354330) +++ stable/12/sys/conf/files.i386 Mon Nov 4 09:49:58 2019 (r354331) @@ -318,6 +318,7 @@ dev/sio/sio_pccard.c optional sio pccard dev/sio/sio_pci.c optional sio pci dev/sio/sio_puc.c optional sio puc dev/speaker/spkr.c optional speaker +dev/superio/superio.c optional superio isa dev/syscons/apm/apm_saver.c optional apm_saver apm dev/syscons/scterm-teken.c optional sc dev/syscons/scvesactl.c optional sc vga vesa Modified: stable/12/sys/dev/superio/superio.c ============================================================================== --- head/sys/dev/superio/superio.c Mon Jul 1 17:05:41 2019 (r349580) +++ stable/12/sys/dev/superio/superio.c Mon Nov 4 09:49:58 2019 (r354331) @@ -1,7 +1,8 @@ -/* - * Copyright (c) 2016 Andriy Gapon - * All rights reserved. +/*- + * SPDX-License-Identifier: BSD-2-Clause * + * Copyright (c) 2019 Andriy Gapon + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -11,7 +12,7 @@ * 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 + * 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 @@ -22,6 +23,8 @@ * 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 @@ -47,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include "isa_if.h" @@ -81,6 +85,7 @@ struct siosc { struct mtx conf_lock; STAILQ_HEAD(, superio_devinfo) devlist; struct resource* io_res; + struct cdev *chardev; int io_rid; uint16_t io_port; const struct sio_conf_methods *methods; @@ -93,6 +98,14 @@ struct siosc { uint8_t enable_reg; }; +static d_ioctl_t superio_ioctl; + +static struct cdevsw superio_cdevsw = { + .d_version = D_VERSION, + .d_ioctl = superio_ioctl, + .d_name = "superio", +}; + #define NUMPORTS 2 static uint8_t @@ -617,6 +630,13 @@ superio_attach(device_t dev) bus_generic_probe(dev); bus_generic_attach(dev); + + sc->chardev = make_dev(&superio_cdevsw, device_get_unit(dev), + UID_ROOT, GID_WHEEL, 0600, "superio%d", device_get_unit(dev)); + if (sc->chardev == NULL) + device_printf(dev, "failed to create character device\n"); + else + sc->chardev->si_drv1 = sc; return (0); } @@ -629,6 +649,8 @@ superio_detach(device_t dev) error = bus_generic_detach(dev); if (error != 0) return (error); + if (sc->chardev != NULL) + destroy_dev(sc->chardev); device_delete_children(dev); bus_release_resource(dev, SYS_RES_IOPORT, sc->io_rid, sc->io_res); mtx_destroy(&sc->conf_lock); @@ -909,6 +931,31 @@ superio_find_dev(device_t superio, superio_dev_type_t return (dinfo->dev); } return (NULL); +} + +static int +superio_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, + struct thread *td) +{ + struct siosc *sc; + struct superiocmd *s; + + sc = dev->si_drv1; + s = (struct superiocmd *)data; + switch (cmd) { + case SUPERIO_CR_READ: + sio_conf_enter(sc); + s->val = sio_ldn_read(sc, s->ldn, s->cr); + sio_conf_exit(sc); + return (0); + case SUPERIO_CR_WRITE: + sio_conf_enter(sc); + sio_ldn_write(sc, s->ldn, s->cr, s->val); + sio_conf_exit(sc); + return (0); + default: + return (ENOTTY); + } } static devclass_t superio_devclass; Modified: stable/12/sys/dev/superio/superio.h ============================================================================== --- head/sys/dev/superio/superio.h Mon Jul 1 17:05:41 2019 (r349580) +++ stable/12/sys/dev/superio/superio.h Mon Nov 4 09:49:58 2019 (r354331) @@ -1,6 +1,8 @@ -/* - * Copyright (c) 2016 Andriy Gapon +/*- + * SPDX-License-Identifier: BSD-2-Clause * + * Copyright (c) 2019 Andriy Gapon + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -10,7 +12,7 @@ * 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 + * 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 Copied and modified: stable/12/sys/dev/superio/superio_io.h (from r354079, head/sys/dev/superio/superio_io.h) ============================================================================== --- head/sys/dev/superio/superio_io.h Fri Oct 25 16:07:24 2019 (r354079, copy source) +++ stable/12/sys/dev/superio/superio_io.h Mon Nov 4 09:49:58 2019 (r354331) @@ -1,4 +1,6 @@ -/* + /*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 2019 Andriy Gapon * * Redistribution and use in source and binary forms, with or without @@ -10,7 +12,7 @@ * 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 + * 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 Modified: stable/12/sys/i386/conf/NOTES ============================================================================== --- stable/12/sys/i386/conf/NOTES Mon Nov 4 06:35:48 2019 (r354330) +++ stable/12/sys/i386/conf/NOTES Mon Nov 4 09:49:58 2019 (r354331) @@ -878,6 +878,11 @@ device amdtemp device cpuctl # +# SuperIO driver. +# +device superio + +# # System Management Bus (SMB) # options ENABLE_ALART # Control alarm on Intel intpm driver Modified: stable/12/sys/modules/Makefile ============================================================================== --- stable/12/sys/modules/Makefile Mon Nov 4 06:35:48 2019 (r354330) +++ stable/12/sys/modules/Makefile Mon Nov 4 09:49:58 2019 (r354331) @@ -368,6 +368,7 @@ SUBDIR= \ ste \ ${_stg} \ stge \ + ${_superio} \ ${_sym} \ ${_syscons} \ sysvipc \ @@ -716,6 +717,7 @@ _rdrand_rng= rdrand_rng .endif _s3= s3 _sdhci_acpi= sdhci_acpi +_superio= superio _tpm= tpm _twa= twa _vesa= vesa From owner-svn-src-stable@freebsd.org Tue Nov 5 06:55:11 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3E1A4178A21; Tue, 5 Nov 2019 06:55:11 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 476gQl0vrqz3QMD; Tue, 5 Nov 2019 06:55:11 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 026E38DE0; Tue, 5 Nov 2019 06:55:11 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA56tAS7001740; Tue, 5 Nov 2019 06:55:10 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA56t92j001734; Tue, 5 Nov 2019 06:55:09 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911050655.xA56t92j001734@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Tue, 5 Nov 2019 06:55:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354350 - in stable/12: share/man/man4 sys/amd64/conf sys/conf sys/dev/itwd sys/i386/conf sys/modules/itwd X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in stable/12: share/man/man4 sys/amd64/conf sys/conf sys/dev/itwd sys/i386/conf sys/modules/itwd X-SVN-Commit-Revision: 354350 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.29 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, 05 Nov 2019 06:55:11 -0000 Author: avg Date: Tue Nov 5 06:55:09 2019 New Revision: 354350 URL: https://svnweb.freebsd.org/changeset/base/354350 Log: MFC r353647: itwd(4): driver for watchdog function in ITE Super I/O chips This branch does not have files.x86, so the driver is added to files.{amd64,i386}. Added: stable/12/share/man/man4/itwd.4 - copied unchanged from r353647, head/share/man/man4/itwd.4 stable/12/sys/dev/itwd/ - copied from r353647, head/sys/dev/itwd/ stable/12/sys/modules/itwd/ - copied from r353647, head/sys/modules/itwd/ Modified: stable/12/share/man/man4/Makefile stable/12/sys/amd64/conf/NOTES stable/12/sys/conf/files.amd64 stable/12/sys/conf/files.i386 stable/12/sys/i386/conf/NOTES Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/Makefile ============================================================================== --- stable/12/share/man/man4/Makefile Tue Nov 5 06:34:20 2019 (r354349) +++ stable/12/share/man/man4/Makefile Tue Nov 5 06:55:09 2019 (r354350) @@ -236,6 +236,7 @@ MAN= aac.4 \ ismt.4 \ isp.4 \ ispfw.4 \ + ${_itwd.4} \ iwi.4 \ iwifw.4 \ iwm.4 \ @@ -819,6 +820,7 @@ _if_wpi.4= if_wpi.4 _imcsmb.4= imcsmb.4 _ipmi.4= ipmi.4 _io.4= io.4 +_itwd.4= itwd.4 _linux.4= linux.4 _nda.4= nda.4 _ndis.4= ndis.4 Copied: stable/12/share/man/man4/itwd.4 (from r353647, head/share/man/man4/itwd.4) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/share/man/man4/itwd.4 Tue Nov 5 06:55:09 2019 (r354350, copy of r353647, head/share/man/man4/itwd.4) @@ -0,0 +1,75 @@ +.\" +.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD +.\" +.\" Copyright (c) 2012 Bjoern A. Zeeb +.\" Copyright (c) 2019 Andriy Gapon +.\" +.\" 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$ +.\" +.Dd October 16, 2019 +.Dt ITWD 4 +.Os +.Sh NAME +.Nm itwd +.Nd device driver for ITE Super I/O chips watchdog timer +.Sh SYNOPSIS +To compile this driver into the kernel, place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device superio" +.Cd "device itwd" +.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 +itwd_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver provides +.Xr watchdog 4 +support for the watchdog timer present on at least the following +Super I/O chips: +.Bl -bullet -compact +.It +IT8721F +.It +IT8728F +.It +IT8771F +.El +.Sh SEE ALSO +.Xr superio 4 +.Xr watchdog 4 , +.Xr device.hints 5 , +.Xr watchdog 8 , +.Xr watchdogd 8 , +.Xr watchdog 9 +.Sh AUTHORS +.An -nosplit +This manual page was written by +.An Andriy Gapon Aq Mt avg@FreeBSD.org . Modified: stable/12/sys/amd64/conf/NOTES ============================================================================== --- stable/12/sys/amd64/conf/NOTES Tue Nov 5 06:34:20 2019 (r354349) +++ stable/12/sys/amd64/conf/NOTES Tue Nov 5 06:55:09 2019 (r354350) @@ -572,11 +572,13 @@ device ioat # Intel I/OAT DMA engine # amdsbwd: AMD SB7xx watchdog timer # viawd: VIA south bridge watchdog timer # wbwd: Winbond watchdog timer +# itwd: ITE Super I/O watchdog timer # device ichwd device amdsbwd device viawd device wbwd +device itwd # # Temperature sensors: Modified: stable/12/sys/conf/files.amd64 ============================================================================== --- stable/12/sys/conf/files.amd64 Tue Nov 5 06:34:20 2019 (r354349) +++ stable/12/sys/conf/files.amd64 Tue Nov 5 06:55:09 2019 (r354350) @@ -268,6 +268,7 @@ dev/ipmi/ipmi_smbios.c optional ipmi dev/ipmi/ipmi_ssif.c optional ipmi smbus dev/ipmi/ipmi_pci.c optional ipmi pci dev/ipmi/ipmi_linux.c optional ipmi compat_linux32 +dev/itwd/itwd.c optional itwd dev/ixl/if_ixl.c optional ixl pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/ixl_pf_main.c optional ixl pci \ Modified: stable/12/sys/conf/files.i386 ============================================================================== --- stable/12/sys/conf/files.i386 Tue Nov 5 06:34:20 2019 (r354349) +++ stable/12/sys/conf/files.i386 Tue Nov 5 06:55:09 2019 (r354350) @@ -282,6 +282,7 @@ dev/ipmi/ipmi_smbios.c optional ipmi dev/ipmi/ipmi_ssif.c optional ipmi smbus dev/ipmi/ipmi_pci.c optional ipmi pci dev/ipmi/ipmi_linux.c optional ipmi compat_linux +dev/itwd/itwd.c optional itwd dev/le/if_le_isa.c optional le isa dev/mse/mse.c optional mse dev/mse/mse_isa.c optional mse isa Modified: stable/12/sys/i386/conf/NOTES ============================================================================== --- stable/12/sys/i386/conf/NOTES Tue Nov 5 06:34:20 2019 (r354349) +++ stable/12/sys/i386/conf/NOTES Tue Nov 5 06:55:09 2019 (r354350) @@ -856,11 +856,13 @@ hint.pcf.0.irq="5" # amdsbwd: AMD SB7xx watchdog timer # viawd: VIA south bridge watchdog timer # wbwd: Winbond watchdog timer +# itwd: ITE Super I/O watchdog timer # device ichwd device amdsbwd device viawd device wbwd +device itwd # # Temperature sensors: From owner-svn-src-stable@freebsd.org Tue Nov 5 07:00:11 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8CB6B178C19; Tue, 5 Nov 2019 07:00:11 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 476gXW3BDfz3QXN; Tue, 5 Nov 2019 07:00:11 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 515A78DE9; Tue, 5 Nov 2019 07:00:11 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA570BlD002162; Tue, 5 Nov 2019 07:00:11 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA570BEn002161; Tue, 5 Nov 2019 07:00:11 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911050700.xA570BEn002161@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Tue, 5 Nov 2019 07:00:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354351 - stable/12/sys/dev/ow X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/sys/dev/ow X-SVN-Commit-Revision: 354351 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.29 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, 05 Nov 2019 07:00:11 -0000 Author: avg Date: Tue Nov 5 07:00:10 2019 New Revision: 354351 URL: https://svnweb.freebsd.org/changeset/base/354351 Log: MFC r354067,r354068: ow_temp: drop the lock around a call that can sleep And use better scopes for the lock. Modified: stable/12/sys/dev/ow/ow_temp.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/ow/ow_temp.c ============================================================================== --- stable/12/sys/dev/ow/ow_temp.c Tue Nov 5 06:55:09 2019 (r354350) +++ stable/12/sys/dev/ow/ow_temp.c Tue Nov 5 07:00:10 2019 (r354351) @@ -143,9 +143,11 @@ ow_temp_event_thread(void *arg) pause("owtstart", device_get_unit(sc->dev) * hz / 100); // 10ms stagger mtx_lock(&sc->temp_lock); sc->flags |= OW_TEMP_RUNNING; + mtx_unlock(&sc->temp_lock); ow_temp_read_power_supply(sc->dev, &sc->parasite); if (sc->parasite) device_printf(sc->dev, "Running in parasitic mode unsupported\n"); + mtx_lock(&sc->temp_lock); while ((sc->flags & OW_TEMP_DONE) == 0) { mtx_unlock(&sc->temp_lock); ow_temp_convert_t(sc->dev); @@ -153,10 +155,9 @@ ow_temp_event_thread(void *arg) msleep(sc, &sc->temp_lock, 0, "owtcvt", hz); if (sc->flags & OW_TEMP_DONE) break; + mtx_unlock(&sc->temp_lock); for (retries = 5; retries > 0; retries--) { - mtx_unlock(&sc->temp_lock); rv = ow_temp_read_scratchpad(sc->dev, scratch, sizeof(scratch)); - mtx_lock(&sc->temp_lock); if (rv == 0) { crc = own_crc(sc->dev, scratch, sizeof(scratch) - 1); if (crc == scratch[8]) { @@ -180,6 +181,7 @@ ow_temp_event_thread(void *arg) } else sc->bad_reads++; } + mtx_lock(&sc->temp_lock); msleep(sc, &sc->temp_lock, 0, "owtcvt", sc->reading_interval); } sc->flags &= ~OW_TEMP_RUNNING; From owner-svn-src-stable@freebsd.org Tue Nov 5 07:02:36 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 628FA178E74; Tue, 5 Nov 2019 07:02:36 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 476gbJ21HZz3Qtf; Tue, 5 Nov 2019 07:02:36 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 295A78FAE; Tue, 5 Nov 2019 07:02:36 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA572aL2007968; Tue, 5 Nov 2019 07:02:36 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA572a4D007967; Tue, 5 Nov 2019 07:02:36 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911050702.xA572a4D007967@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Tue, 5 Nov 2019 07:02:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354352 - stable/12 X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12 X-SVN-Commit-Revision: 354352 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.29 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, 05 Nov 2019 07:02:36 -0000 Author: avg Date: Tue Nov 5 07:02:35 2019 New Revision: 354352 URL: https://svnweb.freebsd.org/changeset/base/354352 Log: MFC r353749: buildkernel: always add standard kernel configuration include path Modified: stable/12/Makefile.inc1 Directory Properties: stable/12/ (props changed) Modified: stable/12/Makefile.inc1 ============================================================================== --- stable/12/Makefile.inc1 Tue Nov 5 07:00:10 2019 (r354351) +++ stable/12/Makefile.inc1 Tue Nov 5 07:02:35 2019 (r354352) @@ -1581,7 +1581,8 @@ buildkernel: .MAKE .PHONY cd ${KRNLCONFDIR}; \ PATH=${TMPPATH} \ config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \ - -I '${KERNCONFDIR}' '${KERNCONFDIR}/${_kernel}' + -I '${KERNCONFDIR}' -I '${KRNLCONFDIR}' \ + '${KERNCONFDIR}/${_kernel}' .endif .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN) @echo From owner-svn-src-stable@freebsd.org Tue Nov 5 07:06:46 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 141DF178FC7; Tue, 5 Nov 2019 07:06:46 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 476gh56tXWz3R3K; Tue, 5 Nov 2019 07:06:45 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CC6838FB2; Tue, 5 Nov 2019 07:06:45 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA576jSp008216; Tue, 5 Nov 2019 07:06:45 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA576jOS008214; Tue, 5 Nov 2019 07:06:45 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911050706.xA576jOS008214@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Tue, 5 Nov 2019 07:06:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354353 - in stable/12: sbin/ddb share/man/man4 X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in stable/12: sbin/ddb share/man/man4 X-SVN-Commit-Revision: 354353 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.29 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, 05 Nov 2019 07:06:46 -0000 Author: avg Date: Tue Nov 5 07:06:45 2019 New Revision: 354353 URL: https://svnweb.freebsd.org/changeset/base/354353 Log: MFC r353726: ddb: use 'textdump dump' instead of 'call doadump' The change is for the example in textdump.4 and the default ddb.conf. Modified: stable/12/sbin/ddb/ddb.conf stable/12/share/man/man4/textdump.4 Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/ddb/ddb.conf ============================================================================== --- stable/12/sbin/ddb/ddb.conf Tue Nov 5 07:02:35 2019 (r354352) +++ stable/12/sbin/ddb/ddb.conf Tue Nov 5 07:06:45 2019 (r354353) @@ -9,7 +9,7 @@ script lockinfo=show locks; show alllocks; show lockedvnods # kdb.enter.panic panic(9) was called. -script kdb.enter.panic=textdump set; capture on; run lockinfo; show pcpu; bt; ps; alltrace; capture off; call doadump; reset +script kdb.enter.panic=textdump set; capture on; run lockinfo; show pcpu; bt; ps; alltrace; capture off; textdump dump; reset # kdb.enter.witness witness(4) detected a locking error. script kdb.enter.witness=run lockinfo Modified: stable/12/share/man/man4/textdump.4 ============================================================================== --- stable/12/share/man/man4/textdump.4 Tue Nov 5 07:02:35 2019 (r354352) +++ stable/12/share/man/man4/textdump.4 Tue Nov 5 07:06:45 2019 (r354353) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 24, 2008 +.Dd October 18, 2019 .Dt TEXTDUMP 4 .Os .Sh NAME @@ -162,7 +162,7 @@ invoke panic in order to force a kernel dump to be wri reboot: .Bd -literal -offset indent script kdb.enter.panic=textdump set; capture on; show allpcpu; bt; - ps; alltrace; show alllocks; call doadump; reset + ps; alltrace; show alllocks; textdump dump; reset .Ed .Pp In the following example, the script From owner-svn-src-stable@freebsd.org Tue Nov 5 07:11:13 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 84CA5179146; Tue, 5 Nov 2019 07:11:13 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 476gnF3hDHz3RDn; Tue, 5 Nov 2019 07:11:13 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 61A948FF6; Tue, 5 Nov 2019 07:11:13 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA57BDBW009189; Tue, 5 Nov 2019 07:11:13 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA57BCg7009185; Tue, 5 Nov 2019 07:11:12 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911050711.xA57BCg7009185@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Tue, 5 Nov 2019 07:11:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354354 - in stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys X-SVN-Commit-Revision: 354354 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.29 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, 05 Nov 2019 07:11:13 -0000 Author: avg Date: Tue Nov 5 07:11:12 2019 New Revision: 354354 URL: https://svnweb.freebsd.org/changeset/base/354354 Log: MFC r353565,r353568: MFV r353561: 10343 ZoL: Prefix all refcount functions with zfs_ Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/abd.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf_stats.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode_sync.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_destroy.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/abd.h stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/arc.h stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dbuf.h stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_tx.h stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab_impl.h stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/refcount.h stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/rrwlock.h stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/sa_impl.h stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/abd.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/abd.c Tue Nov 5 07:06:45 2019 (r354353) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/abd.c Tue Nov 5 07:11:12 2019 (r354354) @@ -304,7 +304,7 @@ abd_alloc(size_t size, boolean_t is_metadata) } abd->abd_size = size; abd->abd_parent = NULL; - refcount_create(&abd->abd_children); + zfs_refcount_create(&abd->abd_children); abd->abd_u.abd_scatter.abd_offset = 0; abd->abd_u.abd_scatter.abd_chunk_size = zfs_abd_chunk_size; @@ -331,7 +331,7 @@ abd_free_scatter(abd_t *abd) abd_free_chunk(abd->abd_u.abd_scatter.abd_chunks[i]); } - refcount_destroy(&abd->abd_children); + zfs_refcount_destroy(&abd->abd_children); ABDSTAT_BUMPDOWN(abdstat_scatter_cnt); ABDSTAT_INCR(abdstat_scatter_data_size, -(int)abd->abd_size); ABDSTAT_INCR(abdstat_scatter_chunk_waste, @@ -358,7 +358,7 @@ abd_alloc_linear(size_t size, boolean_t is_metadata) } abd->abd_size = size; abd->abd_parent = NULL; - refcount_create(&abd->abd_children); + zfs_refcount_create(&abd->abd_children); if (is_metadata) { abd->abd_u.abd_linear.abd_buf = zio_buf_alloc(size); @@ -381,7 +381,7 @@ abd_free_linear(abd_t *abd) zio_data_buf_free(abd->abd_u.abd_linear.abd_buf, abd->abd_size); } - refcount_destroy(&abd->abd_children); + zfs_refcount_destroy(&abd->abd_children); ABDSTAT_BUMPDOWN(abdstat_linear_cnt); ABDSTAT_INCR(abdstat_linear_data_size, -(int)abd->abd_size); @@ -487,8 +487,8 @@ abd_get_offset(abd_t *sabd, size_t off) abd->abd_size = sabd->abd_size - off; abd->abd_parent = sabd; - refcount_create(&abd->abd_children); - (void) refcount_add_many(&sabd->abd_children, abd->abd_size, abd); + zfs_refcount_create(&abd->abd_children); + (void) zfs_refcount_add_many(&sabd->abd_children, abd->abd_size, abd); return (abd); } @@ -512,7 +512,7 @@ abd_get_from_buf(void *buf, size_t size) abd->abd_flags = ABD_FLAG_LINEAR; abd->abd_size = size; abd->abd_parent = NULL; - refcount_create(&abd->abd_children); + zfs_refcount_create(&abd->abd_children); abd->abd_u.abd_linear.abd_buf = buf; @@ -530,11 +530,11 @@ abd_put(abd_t *abd) ASSERT(!(abd->abd_flags & ABD_FLAG_OWNER)); if (abd->abd_parent != NULL) { - (void) refcount_remove_many(&abd->abd_parent->abd_children, + (void) zfs_refcount_remove_many(&abd->abd_parent->abd_children, abd->abd_size, abd); } - refcount_destroy(&abd->abd_children); + zfs_refcount_destroy(&abd->abd_children); abd_free_struct(abd); } @@ -566,7 +566,7 @@ abd_borrow_buf(abd_t *abd, size_t n) } else { buf = zio_buf_alloc(n); } - (void) refcount_add_many(&abd->abd_children, n, buf); + (void) zfs_refcount_add_many(&abd->abd_children, n, buf); return (buf); } @@ -598,7 +598,7 @@ abd_return_buf(abd_t *abd, void *buf, size_t n) ASSERT0(abd_cmp_buf(abd, buf, n)); zio_buf_free(buf, n); } - (void) refcount_remove_many(&abd->abd_children, n, buf); + (void) zfs_refcount_remove_many(&abd->abd_children, n, buf); } void Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Tue Nov 5 07:06:45 2019 (r354353) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Tue Nov 5 07:11:12 2019 (r354354) @@ -538,12 +538,12 @@ typedef struct arc_state { /* * total amount of evictable data in this state */ - refcount_t arcs_esize[ARC_BUFC_NUMTYPES]; + zfs_refcount_t arcs_esize[ARC_BUFC_NUMTYPES]; /* * total amount of data in this state; this includes: evictable, * non-evictable, ARC_BUFC_DATA, and ARC_BUFC_METADATA. */ - refcount_t arcs_size; + zfs_refcount_t arcs_size; /* * supports the "dbufs" kstat */ @@ -1158,7 +1158,7 @@ typedef struct l1arc_buf_hdr { uint32_t b_l2_hits; /* self protecting */ - refcount_t b_refcnt; + zfs_refcount_t b_refcnt; arc_callback_t *b_acb; abd_t *b_pabd; @@ -1534,7 +1534,7 @@ struct l2arc_dev { kmutex_t l2ad_mtx; /* lock for buffer list */ list_t l2ad_buflist; /* buffer list */ list_node_t l2ad_node; /* device list node */ - refcount_t l2ad_alloc; /* allocated bytes */ + zfs_refcount_t l2ad_alloc; /* allocated bytes */ }; static list_t L2ARC_dev_list; /* device list */ @@ -1765,7 +1765,7 @@ hdr_full_cons(void *vbuf, void *unused, int kmflag) bzero(hdr, HDR_FULL_SIZE); cv_init(&hdr->b_l1hdr.b_cv, NULL, CV_DEFAULT, NULL); - refcount_create(&hdr->b_l1hdr.b_refcnt); + zfs_refcount_create(&hdr->b_l1hdr.b_refcnt); mutex_init(&hdr->b_l1hdr.b_freeze_lock, NULL, MUTEX_DEFAULT, NULL); multilist_link_init(&hdr->b_l1hdr.b_arc_node); arc_space_consume(HDR_FULL_SIZE, ARC_SPACE_HDRS); @@ -1810,7 +1810,7 @@ hdr_full_dest(void *vbuf, void *unused) ASSERT(HDR_EMPTY(hdr)); cv_destroy(&hdr->b_l1hdr.b_cv); - refcount_destroy(&hdr->b_l1hdr.b_refcnt); + zfs_refcount_destroy(&hdr->b_l1hdr.b_refcnt); mutex_destroy(&hdr->b_l1hdr.b_freeze_lock); ASSERT(!multilist_link_active(&hdr->b_l1hdr.b_arc_node)); arc_space_return(HDR_FULL_SIZE, ARC_SPACE_HDRS); @@ -2495,21 +2495,21 @@ arc_evictable_space_increment(arc_buf_hdr_t *hdr, arc_ ASSERT0(hdr->b_l1hdr.b_bufcnt); ASSERT3P(hdr->b_l1hdr.b_buf, ==, NULL); ASSERT3P(hdr->b_l1hdr.b_pabd, ==, NULL); - (void) refcount_add_many(&state->arcs_esize[type], + (void) zfs_refcount_add_many(&state->arcs_esize[type], HDR_GET_LSIZE(hdr), hdr); return; } ASSERT(!GHOST_STATE(state)); if (hdr->b_l1hdr.b_pabd != NULL) { - (void) refcount_add_many(&state->arcs_esize[type], + (void) zfs_refcount_add_many(&state->arcs_esize[type], arc_hdr_size(hdr), hdr); } for (arc_buf_t *buf = hdr->b_l1hdr.b_buf; buf != NULL; buf = buf->b_next) { if (arc_buf_is_shared(buf)) continue; - (void) refcount_add_many(&state->arcs_esize[type], + (void) zfs_refcount_add_many(&state->arcs_esize[type], arc_buf_size(buf), buf); } } @@ -2530,21 +2530,21 @@ arc_evictable_space_decrement(arc_buf_hdr_t *hdr, arc_ ASSERT0(hdr->b_l1hdr.b_bufcnt); ASSERT3P(hdr->b_l1hdr.b_buf, ==, NULL); ASSERT3P(hdr->b_l1hdr.b_pabd, ==, NULL); - (void) refcount_remove_many(&state->arcs_esize[type], + (void) zfs_refcount_remove_many(&state->arcs_esize[type], HDR_GET_LSIZE(hdr), hdr); return; } ASSERT(!GHOST_STATE(state)); if (hdr->b_l1hdr.b_pabd != NULL) { - (void) refcount_remove_many(&state->arcs_esize[type], + (void) zfs_refcount_remove_many(&state->arcs_esize[type], arc_hdr_size(hdr), hdr); } for (arc_buf_t *buf = hdr->b_l1hdr.b_buf; buf != NULL; buf = buf->b_next) { if (arc_buf_is_shared(buf)) continue; - (void) refcount_remove_many(&state->arcs_esize[type], + (void) zfs_refcount_remove_many(&state->arcs_esize[type], arc_buf_size(buf), buf); } } @@ -2561,13 +2561,13 @@ add_reference(arc_buf_hdr_t *hdr, void *tag) ASSERT(HDR_HAS_L1HDR(hdr)); if (!MUTEX_HELD(HDR_LOCK(hdr))) { ASSERT(hdr->b_l1hdr.b_state == arc_anon); - ASSERT(refcount_is_zero(&hdr->b_l1hdr.b_refcnt)); + ASSERT(zfs_refcount_is_zero(&hdr->b_l1hdr.b_refcnt)); ASSERT3P(hdr->b_l1hdr.b_buf, ==, NULL); } arc_state_t *state = hdr->b_l1hdr.b_state; - if ((refcount_add(&hdr->b_l1hdr.b_refcnt, tag) == 1) && + if ((zfs_refcount_add(&hdr->b_l1hdr.b_refcnt, tag) == 1) && (state != arc_anon)) { /* We don't use the L2-only state list. */ if (state != arc_l2c_only) { @@ -2599,7 +2599,7 @@ remove_reference(arc_buf_hdr_t *hdr, kmutex_t *hash_lo * arc_l2c_only counts as a ghost state so we don't need to explicitly * check to prevent usage of the arc_l2c_only list. */ - if (((cnt = refcount_remove(&hdr->b_l1hdr.b_refcnt, tag)) == 0) && + if (((cnt = zfs_refcount_remove(&hdr->b_l1hdr.b_refcnt, tag)) == 0) && (state != arc_anon)) { multilist_insert(state->arcs_list[arc_buf_type(hdr)], hdr); ASSERT3U(hdr->b_l1hdr.b_bufcnt, >, 0); @@ -2644,7 +2644,7 @@ arc_buf_info(arc_buf_t *ab, arc_buf_info_t *abi, int s abi->abi_mru_ghost_hits = l1hdr->b_mru_ghost_hits; abi->abi_mfu_hits = l1hdr->b_mfu_hits; abi->abi_mfu_ghost_hits = l1hdr->b_mfu_ghost_hits; - abi->abi_holds = refcount_count(&l1hdr->b_refcnt); + abi->abi_holds = zfs_refcount_count(&l1hdr->b_refcnt); } if (l2hdr) { @@ -2680,7 +2680,7 @@ arc_change_state(arc_state_t *new_state, arc_buf_hdr_t */ if (HDR_HAS_L1HDR(hdr)) { old_state = hdr->b_l1hdr.b_state; - refcnt = refcount_count(&hdr->b_l1hdr.b_refcnt); + refcnt = zfs_refcount_count(&hdr->b_l1hdr.b_refcnt); bufcnt = hdr->b_l1hdr.b_bufcnt; update_old = (bufcnt > 0 || hdr->b_l1hdr.b_pabd != NULL); } else { @@ -2750,7 +2750,7 @@ arc_change_state(arc_state_t *new_state, arc_buf_hdr_t * the reference. As a result, we use the arc * header pointer for the reference. */ - (void) refcount_add_many(&new_state->arcs_size, + (void) zfs_refcount_add_many(&new_state->arcs_size, HDR_GET_LSIZE(hdr), hdr); ASSERT3P(hdr->b_l1hdr.b_pabd, ==, NULL); } else { @@ -2776,13 +2776,15 @@ arc_change_state(arc_state_t *new_state, arc_buf_hdr_t if (arc_buf_is_shared(buf)) continue; - (void) refcount_add_many(&new_state->arcs_size, + (void) zfs_refcount_add_many( + &new_state->arcs_size, arc_buf_size(buf), buf); } ASSERT3U(bufcnt, ==, buffers); if (hdr->b_l1hdr.b_pabd != NULL) { - (void) refcount_add_many(&new_state->arcs_size, + (void) zfs_refcount_add_many( + &new_state->arcs_size, arc_hdr_size(hdr), hdr); } else { ASSERT(GHOST_STATE(old_state)); @@ -2804,7 +2806,7 @@ arc_change_state(arc_state_t *new_state, arc_buf_hdr_t * header on the ghost state. */ - (void) refcount_remove_many(&old_state->arcs_size, + (void) zfs_refcount_remove_many(&old_state->arcs_size, HDR_GET_LSIZE(hdr), hdr); } else { uint32_t buffers = 0; @@ -2829,13 +2831,13 @@ arc_change_state(arc_state_t *new_state, arc_buf_hdr_t if (arc_buf_is_shared(buf)) continue; - (void) refcount_remove_many( + (void) zfs_refcount_remove_many( &old_state->arcs_size, arc_buf_size(buf), buf); } ASSERT3U(bufcnt, ==, buffers); ASSERT3P(hdr->b_l1hdr.b_pabd, !=, NULL); - (void) refcount_remove_many( + (void) zfs_refcount_remove_many( &old_state->arcs_size, arc_hdr_size(hdr), hdr); } } @@ -3101,8 +3103,8 @@ arc_return_buf(arc_buf_t *buf, void *tag) ASSERT3P(buf->b_data, !=, NULL); ASSERT(HDR_HAS_L1HDR(hdr)); - (void) refcount_add(&hdr->b_l1hdr.b_refcnt, tag); - (void) refcount_remove(&hdr->b_l1hdr.b_refcnt, arc_onloan_tag); + (void) zfs_refcount_add(&hdr->b_l1hdr.b_refcnt, tag); + (void) zfs_refcount_remove(&hdr->b_l1hdr.b_refcnt, arc_onloan_tag); arc_loaned_bytes_update(-arc_buf_size(buf)); } @@ -3115,8 +3117,8 @@ arc_loan_inuse_buf(arc_buf_t *buf, void *tag) ASSERT3P(buf->b_data, !=, NULL); ASSERT(HDR_HAS_L1HDR(hdr)); - (void) refcount_add(&hdr->b_l1hdr.b_refcnt, arc_onloan_tag); - (void) refcount_remove(&hdr->b_l1hdr.b_refcnt, tag); + (void) zfs_refcount_add(&hdr->b_l1hdr.b_refcnt, arc_onloan_tag); + (void) zfs_refcount_remove(&hdr->b_l1hdr.b_refcnt, tag); arc_loaned_bytes_update(arc_buf_size(buf)); } @@ -3143,13 +3145,13 @@ arc_hdr_free_on_write(arc_buf_hdr_t *hdr) /* protected by hash lock, if in the hash table */ if (multilist_link_active(&hdr->b_l1hdr.b_arc_node)) { - ASSERT(refcount_is_zero(&hdr->b_l1hdr.b_refcnt)); + ASSERT(zfs_refcount_is_zero(&hdr->b_l1hdr.b_refcnt)); ASSERT(state != arc_anon && state != arc_l2c_only); - (void) refcount_remove_many(&state->arcs_esize[type], + (void) zfs_refcount_remove_many(&state->arcs_esize[type], size, hdr); } - (void) refcount_remove_many(&state->arcs_size, size, hdr); + (void) zfs_refcount_remove_many(&state->arcs_size, size, hdr); if (type == ARC_BUFC_METADATA) { arc_space_return(size, ARC_SPACE_META); } else { @@ -3179,7 +3181,7 @@ arc_share_buf(arc_buf_hdr_t *hdr, arc_buf_t *buf) * refcount ownership to the hdr since it always owns * the refcount whenever an arc_buf_t is shared. */ - refcount_transfer_ownership(&state->arcs_size, buf, hdr); + zfs_refcount_transfer_ownership(&state->arcs_size, buf, hdr); hdr->b_l1hdr.b_pabd = abd_get_from_buf(buf->b_data, arc_buf_size(buf)); abd_take_ownership_of_buf(hdr->b_l1hdr.b_pabd, HDR_ISTYPE_METADATA(hdr)); @@ -3209,7 +3211,7 @@ arc_unshare_buf(arc_buf_hdr_t *hdr, arc_buf_t *buf) * We are no longer sharing this buffer so we need * to transfer its ownership to the rightful owner. */ - refcount_transfer_ownership(&state->arcs_size, hdr, buf); + zfs_refcount_transfer_ownership(&state->arcs_size, hdr, buf); arc_hdr_clear_flags(hdr, ARC_FLAG_SHARED_DATA); abd_release_ownership_of_buf(hdr->b_l1hdr.b_pabd); abd_put(hdr->b_l1hdr.b_pabd); @@ -3436,7 +3438,7 @@ arc_hdr_alloc(uint64_t spa, int32_t psize, int32_t lsi * it references and compressed arc enablement. */ arc_hdr_alloc_pabd(hdr, B_TRUE); - ASSERT(refcount_is_zero(&hdr->b_l1hdr.b_refcnt)); + ASSERT(zfs_refcount_is_zero(&hdr->b_l1hdr.b_refcnt)); return (hdr); } @@ -3538,8 +3540,10 @@ arc_hdr_realloc(arc_buf_hdr_t *hdr, kmem_cache_t *old, * the wrong pointer address when calling arc_hdr_destroy() later. */ - (void) refcount_remove_many(&dev->l2ad_alloc, arc_hdr_size(hdr), hdr); - (void) refcount_add_many(&dev->l2ad_alloc, arc_hdr_size(nhdr), nhdr); + (void) zfs_refcount_remove_many(&dev->l2ad_alloc, arc_hdr_size(hdr), + hdr); + (void) zfs_refcount_add_many(&dev->l2ad_alloc, arc_hdr_size(nhdr), + nhdr); buf_discard_identity(hdr); kmem_cache_free(old, hdr); @@ -3619,7 +3623,7 @@ arc_hdr_l2hdr_destroy(arc_buf_hdr_t *hdr) vdev_space_update(dev->l2ad_vdev, -psize, 0, 0); - (void) refcount_remove_many(&dev->l2ad_alloc, psize, hdr); + (void) zfs_refcount_remove_many(&dev->l2ad_alloc, psize, hdr); arc_hdr_clear_flags(hdr, ARC_FLAG_HAS_L2HDR); } @@ -3629,7 +3633,7 @@ arc_hdr_destroy(arc_buf_hdr_t *hdr) if (HDR_HAS_L1HDR(hdr)) { ASSERT(hdr->b_l1hdr.b_buf == NULL || hdr->b_l1hdr.b_bufcnt > 0); - ASSERT(refcount_is_zero(&hdr->b_l1hdr.b_refcnt)); + ASSERT(zfs_refcount_is_zero(&hdr->b_l1hdr.b_refcnt)); ASSERT3P(hdr->b_l1hdr.b_state, ==, arc_anon); } ASSERT(!HDR_IO_IN_PROGRESS(hdr)); @@ -3793,7 +3797,7 @@ arc_evict_hdr(arc_buf_hdr_t *hdr, kmutex_t *hash_lock) return (bytes_evicted); } - ASSERT0(refcount_count(&hdr->b_l1hdr.b_refcnt)); + ASSERT0(zfs_refcount_count(&hdr->b_l1hdr.b_refcnt)); while (hdr->b_l1hdr.b_buf) { arc_buf_t *buf = hdr->b_l1hdr.b_buf; if (!mutex_tryenter(&buf->b_evict_lock)) { @@ -4107,7 +4111,7 @@ arc_flush_state(arc_state_t *state, uint64_t spa, arc_ { uint64_t evicted = 0; - while (refcount_count(&state->arcs_esize[type]) != 0) { + while (zfs_refcount_count(&state->arcs_esize[type]) != 0) { evicted += arc_evict_state(state, spa, ARC_EVICT_ALL, type); if (!retry) @@ -4130,7 +4134,7 @@ arc_prune_task(void *ptr) if (func != NULL) func(ap->p_adjust, ap->p_private); - refcount_remove(&ap->p_refcnt, func); + zfs_refcount_remove(&ap->p_refcnt, func); } /* @@ -4153,14 +4157,14 @@ arc_prune_async(int64_t adjust) for (ap = list_head(&arc_prune_list); ap != NULL; ap = list_next(&arc_prune_list, ap)) { - if (refcount_count(&ap->p_refcnt) >= 2) + if (zfs_refcount_count(&ap->p_refcnt) >= 2) continue; - refcount_add(&ap->p_refcnt, ap->p_pfunc); + zfs_refcount_add(&ap->p_refcnt, ap->p_pfunc); ap->p_adjust = adjust; if (taskq_dispatch(arc_prune_taskq, arc_prune_task, ap, TQ_SLEEP) == TASKQID_INVALID) { - refcount_remove(&ap->p_refcnt, ap->p_pfunc); + zfs_refcount_remove(&ap->p_refcnt, ap->p_pfunc); continue; } ARCSTAT_BUMP(arcstat_prune); @@ -4182,8 +4186,9 @@ arc_adjust_impl(arc_state_t *state, uint64_t spa, int6 { int64_t delta; - if (bytes > 0 && refcount_count(&state->arcs_esize[type]) > 0) { - delta = MIN(refcount_count(&state->arcs_esize[type]), bytes); + if (bytes > 0 && zfs_refcount_count(&state->arcs_esize[type]) > 0) { + delta = MIN(zfs_refcount_count(&state->arcs_esize[type]), + bytes); return (arc_evict_state(state, spa, delta, type)); } @@ -4226,8 +4231,9 @@ restart: */ adjustmnt = meta_used - arc_meta_limit; - if (adjustmnt > 0 && refcount_count(&arc_mru->arcs_esize[type]) > 0) { - delta = MIN(refcount_count(&arc_mru->arcs_esize[type]), + if (adjustmnt > 0 && + zfs_refcount_count(&arc_mru->arcs_esize[type]) > 0) { + delta = MIN(zfs_refcount_count(&arc_mru->arcs_esize[type]), adjustmnt); total_evicted += arc_adjust_impl(arc_mru, 0, delta, type); adjustmnt -= delta; @@ -4243,8 +4249,9 @@ restart: * simply decrement the amount of data evicted from the MRU. */ - if (adjustmnt > 0 && refcount_count(&arc_mfu->arcs_esize[type]) > 0) { - delta = MIN(refcount_count(&arc_mfu->arcs_esize[type]), + if (adjustmnt > 0 && + zfs_refcount_count(&arc_mfu->arcs_esize[type]) > 0) { + delta = MIN(zfs_refcount_count(&arc_mfu->arcs_esize[type]), adjustmnt); total_evicted += arc_adjust_impl(arc_mfu, 0, delta, type); } @@ -4252,17 +4259,17 @@ restart: adjustmnt = meta_used - arc_meta_limit; if (adjustmnt > 0 && - refcount_count(&arc_mru_ghost->arcs_esize[type]) > 0) { + zfs_refcount_count(&arc_mru_ghost->arcs_esize[type]) > 0) { delta = MIN(adjustmnt, - refcount_count(&arc_mru_ghost->arcs_esize[type])); + zfs_refcount_count(&arc_mru_ghost->arcs_esize[type])); total_evicted += arc_adjust_impl(arc_mru_ghost, 0, delta, type); adjustmnt -= delta; } if (adjustmnt > 0 && - refcount_count(&arc_mfu_ghost->arcs_esize[type]) > 0) { + zfs_refcount_count(&arc_mfu_ghost->arcs_esize[type]) > 0) { delta = MIN(adjustmnt, - refcount_count(&arc_mfu_ghost->arcs_esize[type])); + zfs_refcount_count(&arc_mfu_ghost->arcs_esize[type])); total_evicted += arc_adjust_impl(arc_mfu_ghost, 0, delta, type); } @@ -4311,8 +4318,8 @@ arc_adjust_meta_only(uint64_t meta_used) * evict some from the MRU here, and some from the MFU below. */ target = MIN((int64_t)(meta_used - arc_meta_limit), - (int64_t)(refcount_count(&arc_anon->arcs_size) + - refcount_count(&arc_mru->arcs_size) - arc_p)); + (int64_t)(zfs_refcount_count(&arc_anon->arcs_size) + + zfs_refcount_count(&arc_mru->arcs_size) - arc_p)); total_evicted += arc_adjust_impl(arc_mru, 0, target, ARC_BUFC_METADATA); @@ -4322,7 +4329,7 @@ arc_adjust_meta_only(uint64_t meta_used) * space allotted to the MFU (which is defined as arc_c - arc_p). */ target = MIN((int64_t)(meta_used - arc_meta_limit), - (int64_t)(refcount_count(&arc_mfu->arcs_size) - + (int64_t)(zfs_refcount_count(&arc_mfu->arcs_size) - (arc_c - arc_p))); total_evicted += arc_adjust_impl(arc_mfu, 0, target, ARC_BUFC_METADATA); @@ -4443,8 +4450,8 @@ arc_adjust(void) * arc_p here, and then evict more from the MFU below. */ target = MIN((int64_t)(asize - arc_c), - (int64_t)(refcount_count(&arc_anon->arcs_size) + - refcount_count(&arc_mru->arcs_size) + ameta - arc_p)); + (int64_t)(zfs_refcount_count(&arc_anon->arcs_size) + + zfs_refcount_count(&arc_mru->arcs_size) + ameta - arc_p)); /* * If we're below arc_meta_min, always prefer to evict data. @@ -4534,8 +4541,8 @@ arc_adjust(void) * cache. The following logic enforces these limits on the ghost * caches, and evicts from them as needed. */ - target = refcount_count(&arc_mru->arcs_size) + - refcount_count(&arc_mru_ghost->arcs_size) - arc_c; + target = zfs_refcount_count(&arc_mru->arcs_size) + + zfs_refcount_count(&arc_mru_ghost->arcs_size) - arc_c; bytes = arc_adjust_impl(arc_mru_ghost, 0, target, ARC_BUFC_DATA); total_evicted += bytes; @@ -4553,8 +4560,8 @@ arc_adjust(void) * mru + mfu + mru ghost + mfu ghost <= 2 * arc_c * mru ghost + mfu ghost <= arc_c */ - target = refcount_count(&arc_mru_ghost->arcs_size) + - refcount_count(&arc_mfu_ghost->arcs_size) - arc_c; + target = zfs_refcount_count(&arc_mru_ghost->arcs_size) + + zfs_refcount_count(&arc_mfu_ghost->arcs_size) - arc_c; bytes = arc_adjust_impl(arc_mfu_ghost, 0, target, ARC_BUFC_DATA); total_evicted += bytes; @@ -5069,8 +5076,8 @@ arc_adapt(int bytes, arc_state_t *state) { int mult; uint64_t arc_p_min = (arc_c >> arc_p_min_shift); - int64_t mrug_size = refcount_count(&arc_mru_ghost->arcs_size); - int64_t mfug_size = refcount_count(&arc_mfu_ghost->arcs_size); + int64_t mrug_size = zfs_refcount_count(&arc_mru_ghost->arcs_size); + int64_t mfug_size = zfs_refcount_count(&arc_mfu_ghost->arcs_size); if (state == arc_l2c_only) return; @@ -5248,7 +5255,7 @@ arc_get_data_impl(arc_buf_hdr_t *hdr, uint64_t size, v */ if (!GHOST_STATE(state)) { - (void) refcount_add_many(&state->arcs_size, size, tag); + (void) zfs_refcount_add_many(&state->arcs_size, size, tag); /* * If this is reached via arc_read, the link is @@ -5260,8 +5267,8 @@ arc_get_data_impl(arc_buf_hdr_t *hdr, uint64_t size, v * trying to [add|remove]_reference it. */ if (multilist_link_active(&hdr->b_l1hdr.b_arc_node)) { - ASSERT(refcount_is_zero(&hdr->b_l1hdr.b_refcnt)); - (void) refcount_add_many(&state->arcs_esize[type], + ASSERT(zfs_refcount_is_zero(&hdr->b_l1hdr.b_refcnt)); + (void) zfs_refcount_add_many(&state->arcs_esize[type], size, tag); } @@ -5271,8 +5278,8 @@ arc_get_data_impl(arc_buf_hdr_t *hdr, uint64_t size, v */ if (aggsum_upper_bound(&arc_size) < arc_c && hdr->b_l1hdr.b_state == arc_anon && - (refcount_count(&arc_anon->arcs_size) + - refcount_count(&arc_mru->arcs_size) > arc_p)) + (zfs_refcount_count(&arc_anon->arcs_size) + + zfs_refcount_count(&arc_mru->arcs_size) > arc_p)) arc_p = MIN(arc_c, arc_p + size); } ARCSTAT_BUMP(arcstat_allocated); @@ -5310,13 +5317,13 @@ arc_free_data_impl(arc_buf_hdr_t *hdr, uint64_t size, /* protected by hash lock, if in the hash table */ if (multilist_link_active(&hdr->b_l1hdr.b_arc_node)) { - ASSERT(refcount_is_zero(&hdr->b_l1hdr.b_refcnt)); + ASSERT(zfs_refcount_is_zero(&hdr->b_l1hdr.b_refcnt)); ASSERT(state != arc_anon && state != arc_l2c_only); - (void) refcount_remove_many(&state->arcs_esize[type], + (void) zfs_refcount_remove_many(&state->arcs_esize[type], size, tag); } - (void) refcount_remove_many(&state->arcs_size, size, tag); + (void) zfs_refcount_remove_many(&state->arcs_size, size, tag); VERIFY3U(hdr->b_type, ==, type); if (type == ARC_BUFC_METADATA) { @@ -5363,7 +5370,7 @@ arc_access(arc_buf_hdr_t *hdr, kmutex_t *hash_lock) * another prefetch (to make it less likely to be evicted). */ if (HDR_PREFETCH(hdr) || HDR_PRESCIENT_PREFETCH(hdr)) { - if (refcount_count(&hdr->b_l1hdr.b_refcnt) == 0) { + if (zfs_refcount_count(&hdr->b_l1hdr.b_refcnt) == 0) { /* link protected by hash lock */ ASSERT(multilist_link_active( &hdr->b_l1hdr.b_arc_node)); @@ -5404,7 +5411,7 @@ arc_access(arc_buf_hdr_t *hdr, kmutex_t *hash_lock) if (HDR_PREFETCH(hdr) || HDR_PRESCIENT_PREFETCH(hdr)) { new_state = arc_mru; - if (refcount_count(&hdr->b_l1hdr.b_refcnt) > 0) { + if (zfs_refcount_count(&hdr->b_l1hdr.b_refcnt) > 0) { arc_hdr_clear_flags(hdr, ARC_FLAG_PREFETCH | ARC_FLAG_PRESCIENT_PREFETCH); @@ -5678,7 +5685,7 @@ arc_read_done(zio_t *zio) ASSERT3P(hdr->b_l1hdr.b_pabd, !=, NULL); } - ASSERT(refcount_is_zero(&hdr->b_l1hdr.b_refcnt) || + ASSERT(zfs_refcount_is_zero(&hdr->b_l1hdr.b_refcnt) || callback_list != NULL); if (no_zio_error) { @@ -5689,7 +5696,7 @@ arc_read_done(zio_t *zio) arc_change_state(arc_anon, hdr, hash_lock); if (HDR_IN_HASH_TABLE(hdr)) buf_hash_remove(hdr); - freeable = refcount_is_zero(&hdr->b_l1hdr.b_refcnt); + freeable = zfs_refcount_is_zero(&hdr->b_l1hdr.b_refcnt); } /* @@ -5709,7 +5716,7 @@ arc_read_done(zio_t *zio) * in the cache). */ ASSERT3P(hdr->b_l1hdr.b_state, ==, arc_anon); - freeable = refcount_is_zero(&hdr->b_l1hdr.b_refcnt); + freeable = zfs_refcount_is_zero(&hdr->b_l1hdr.b_refcnt); } /* execute each callback and free its structure */ @@ -5875,7 +5882,7 @@ top: ASSERT((zio_flags & ZIO_FLAG_SPECULATIVE) || rc == 0 || rc != ENOENT); } else if (*arc_flags & ARC_FLAG_PREFETCH && - refcount_count(&hdr->b_l1hdr.b_refcnt) == 0) { + zfs_refcount_count(&hdr->b_l1hdr.b_refcnt) == 0) { arc_hdr_set_flags(hdr, ARC_FLAG_PREFETCH); } DTRACE_PROBE1(arc__hit, arc_buf_hdr_t *, hdr); @@ -5933,7 +5940,7 @@ top: ASSERT3P(hdr->b_l1hdr.b_pabd, ==, NULL); ASSERT(GHOST_STATE(hdr->b_l1hdr.b_state)); ASSERT(!HDR_IO_IN_PROGRESS(hdr)); - ASSERT(refcount_is_zero(&hdr->b_l1hdr.b_refcnt)); + ASSERT(zfs_refcount_is_zero(&hdr->b_l1hdr.b_refcnt)); ASSERT3P(hdr->b_l1hdr.b_buf, ==, NULL); ASSERT3P(hdr->b_l1hdr.b_freeze_cksum, ==, NULL); @@ -6154,10 +6161,10 @@ arc_add_prune_callback(arc_prune_func_t *func, void *p p->p_pfunc = func; p->p_private = private; list_link_init(&p->p_node); - refcount_create(&p->p_refcnt); + zfs_refcount_create(&p->p_refcnt); mutex_enter(&arc_prune_mtx); - refcount_add(&p->p_refcnt, &arc_prune_list); + zfs_refcount_add(&p->p_refcnt, &arc_prune_list); list_insert_head(&arc_prune_list, p); mutex_exit(&arc_prune_mtx); @@ -6170,15 +6177,15 @@ arc_remove_prune_callback(arc_prune_t *p) boolean_t wait = B_FALSE; mutex_enter(&arc_prune_mtx); list_remove(&arc_prune_list, p); - if (refcount_remove(&p->p_refcnt, &arc_prune_list) > 0) + if (zfs_refcount_remove(&p->p_refcnt, &arc_prune_list) > 0) wait = B_TRUE; mutex_exit(&arc_prune_mtx); /* wait for arc_prune_task to finish */ if (wait) taskq_wait(arc_prune_taskq); - ASSERT0(refcount_count(&p->p_refcnt)); - refcount_destroy(&p->p_refcnt); + ASSERT0(zfs_refcount_count(&p->p_refcnt)); + zfs_refcount_destroy(&p->p_refcnt); kmem_free(p, sizeof (*p)); } @@ -6221,7 +6228,7 @@ arc_freed(spa_t *spa, const blkptr_t *bp) * this hdr, then we don't destroy the hdr. */ if (!HDR_HAS_L1HDR(hdr) || (!HDR_IO_IN_PROGRESS(hdr) && - refcount_is_zero(&hdr->b_l1hdr.b_refcnt))) { + zfs_refcount_is_zero(&hdr->b_l1hdr.b_refcnt))) { arc_change_state(arc_anon, hdr, hash_lock); arc_hdr_destroy(hdr); mutex_exit(hash_lock); @@ -6264,7 +6271,7 @@ arc_release(arc_buf_t *buf, void *tag) ASSERT(!HDR_HAS_L2HDR(hdr)); ASSERT(HDR_EMPTY(hdr)); ASSERT3U(hdr->b_l1hdr.b_bufcnt, ==, 1); - ASSERT3S(refcount_count(&hdr->b_l1hdr.b_refcnt), ==, 1); + ASSERT3S(zfs_refcount_count(&hdr->b_l1hdr.b_refcnt), ==, 1); ASSERT(!list_link_active(&hdr->b_l1hdr.b_arc_node)); hdr->b_l1hdr.b_arc_access = 0; @@ -6292,7 +6299,7 @@ arc_release(arc_buf_t *buf, void *tag) ASSERT3P(state, !=, arc_anon); /* this buffer is not on any list */ - ASSERT3S(refcount_count(&hdr->b_l1hdr.b_refcnt), >, 0); + ASSERT3S(zfs_refcount_count(&hdr->b_l1hdr.b_refcnt), >, 0); if (HDR_HAS_L2HDR(hdr)) { mutex_enter(&hdr->b_l2hdr.b_dev->l2ad_mtx); @@ -6384,12 +6391,13 @@ arc_release(arc_buf_t *buf, void *tag) ASSERT3P(hdr->b_l1hdr.b_pabd, !=, NULL); ASSERT3P(state, !=, arc_l2c_only); - (void) refcount_remove_many(&state->arcs_size, + (void) zfs_refcount_remove_many(&state->arcs_size, arc_buf_size(buf), buf); - if (refcount_is_zero(&hdr->b_l1hdr.b_refcnt)) { + if (zfs_refcount_is_zero(&hdr->b_l1hdr.b_refcnt)) { ASSERT3P(state, !=, arc_l2c_only); - (void) refcount_remove_many(&state->arcs_esize[type], + (void) zfs_refcount_remove_many( + &state->arcs_esize[type], arc_buf_size(buf), buf); } @@ -6408,21 +6416,21 @@ arc_release(arc_buf_t *buf, void *tag) nhdr = arc_hdr_alloc(spa, psize, lsize, compress, type); ASSERT3P(nhdr->b_l1hdr.b_buf, ==, NULL); ASSERT0(nhdr->b_l1hdr.b_bufcnt); - ASSERT0(refcount_count(&nhdr->b_l1hdr.b_refcnt)); + ASSERT0(zfs_refcount_count(&nhdr->b_l1hdr.b_refcnt)); VERIFY3U(nhdr->b_type, ==, type); ASSERT(!HDR_SHARED_DATA(nhdr)); nhdr->b_l1hdr.b_buf = buf; nhdr->b_l1hdr.b_bufcnt = 1; - (void) refcount_add(&nhdr->b_l1hdr.b_refcnt, tag); + (void) zfs_refcount_add(&nhdr->b_l1hdr.b_refcnt, tag); buf->b_hdr = nhdr; mutex_exit(&buf->b_evict_lock); - (void) refcount_add_many(&arc_anon->arcs_size, + (void) zfs_refcount_add_many(&arc_anon->arcs_size, arc_buf_size(buf), buf); } else { mutex_exit(&buf->b_evict_lock); - ASSERT(refcount_count(&hdr->b_l1hdr.b_refcnt) == 1); + ASSERT(zfs_refcount_count(&hdr->b_l1hdr.b_refcnt) == 1); /* protected by hash lock, or hdr is on arc_anon */ ASSERT(!multilist_link_active(&hdr->b_l1hdr.b_arc_node)); ASSERT(!HDR_IO_IN_PROGRESS(hdr)); @@ -6454,7 +6462,7 @@ arc_referenced(arc_buf_t *buf) int referenced; mutex_enter(&buf->b_evict_lock); - referenced = (refcount_count(&buf->b_hdr->b_l1hdr.b_refcnt)); + referenced = (zfs_refcount_count(&buf->b_hdr->b_l1hdr.b_refcnt)); mutex_exit(&buf->b_evict_lock); return (referenced); } @@ -6469,7 +6477,7 @@ arc_write_ready(zio_t *zio) uint64_t psize = BP_IS_HOLE(zio->io_bp) ? 0 : BP_GET_PSIZE(zio->io_bp); ASSERT(HDR_HAS_L1HDR(hdr)); - ASSERT(!refcount_is_zero(&buf->b_hdr->b_l1hdr.b_refcnt)); + ASSERT(!zfs_refcount_is_zero(&buf->b_hdr->b_l1hdr.b_refcnt)); ASSERT(hdr->b_l1hdr.b_bufcnt > 0); /* @@ -6624,7 +6632,7 @@ arc_write_done(zio_t *zio) if (!BP_EQUAL(&zio->io_bp_orig, zio->io_bp)) panic("bad overwrite, hdr=%p exists=%p", (void *)hdr, (void *)exists); - ASSERT(refcount_is_zero( + ASSERT(zfs_refcount_is_zero( &exists->b_l1hdr.b_refcnt)); arc_change_state(arc_anon, exists, hash_lock); mutex_exit(hash_lock); @@ -6654,7 +6662,7 @@ arc_write_done(zio_t *zio) arc_hdr_clear_flags(hdr, ARC_FLAG_IO_IN_PROGRESS); } - ASSERT(!refcount_is_zero(&hdr->b_l1hdr.b_refcnt)); + ASSERT(!zfs_refcount_is_zero(&hdr->b_l1hdr.b_refcnt)); callback->awcb_done(zio, buf, callback->awcb_private); abd_put(zio->io_abd); @@ -6800,7 +6808,7 @@ arc_tempreserve_space(spa_t *spa, uint64_t reserve, ui /* assert that it has not wrapped around */ ASSERT3S(atomic_add_64_nv(&arc_loaned_bytes, 0), >=, 0); - anon_size = MAX((int64_t)(refcount_count(&arc_anon->arcs_size) - + anon_size = MAX((int64_t)(zfs_refcount_count(&arc_anon->arcs_size) - arc_loaned_bytes), 0); /* @@ -6835,9 +6843,10 @@ arc_tempreserve_space(spa_t *spa, uint64_t reserve, ui anon_size > arc_c * zfs_arc_anon_limit_percent / 100 && spa_dirty_anon > anon_size * zfs_arc_pool_dirty_percent / 100) { uint64_t meta_esize = - refcount_count(&arc_anon->arcs_esize[ARC_BUFC_METADATA]); + zfs_refcount_count( + &arc_anon->arcs_esize[ARC_BUFC_METADATA]); uint64_t data_esize = - refcount_count(&arc_anon->arcs_esize[ARC_BUFC_DATA]); + zfs_refcount_count(&arc_anon->arcs_esize[ARC_BUFC_DATA]); dprintf("failing, arc_tempreserve=%lluK anon_meta=%lluK " "anon_data=%lluK tempreserve=%lluK arc_c=%lluK\n", arc_tempreserve >> 10, meta_esize >> 10, @@ -6852,11 +6861,11 @@ static void arc_kstat_update_state(arc_state_t *state, kstat_named_t *size, kstat_named_t *evict_data, kstat_named_t *evict_metadata) { - size->value.ui64 = refcount_count(&state->arcs_size); + size->value.ui64 = zfs_refcount_count(&state->arcs_size); evict_data->value.ui64 = - refcount_count(&state->arcs_esize[ARC_BUFC_DATA]); + zfs_refcount_count(&state->arcs_esize[ARC_BUFC_DATA]); evict_metadata->value.ui64 = - refcount_count(&state->arcs_esize[ARC_BUFC_METADATA]); + zfs_refcount_count(&state->arcs_esize[ARC_BUFC_METADATA]); } static int @@ -7025,25 +7034,25 @@ arc_state_init(void) offsetof(arc_buf_hdr_t, b_l1hdr.b_arc_node), arc_state_multilist_index_func); - refcount_create(&arc_anon->arcs_esize[ARC_BUFC_METADATA]); - refcount_create(&arc_anon->arcs_esize[ARC_BUFC_DATA]); - refcount_create(&arc_mru->arcs_esize[ARC_BUFC_METADATA]); - refcount_create(&arc_mru->arcs_esize[ARC_BUFC_DATA]); - refcount_create(&arc_mru_ghost->arcs_esize[ARC_BUFC_METADATA]); - refcount_create(&arc_mru_ghost->arcs_esize[ARC_BUFC_DATA]); - refcount_create(&arc_mfu->arcs_esize[ARC_BUFC_METADATA]); - refcount_create(&arc_mfu->arcs_esize[ARC_BUFC_DATA]); - refcount_create(&arc_mfu_ghost->arcs_esize[ARC_BUFC_METADATA]); - refcount_create(&arc_mfu_ghost->arcs_esize[ARC_BUFC_DATA]); - refcount_create(&arc_l2c_only->arcs_esize[ARC_BUFC_METADATA]); - refcount_create(&arc_l2c_only->arcs_esize[ARC_BUFC_DATA]); + zfs_refcount_create(&arc_anon->arcs_esize[ARC_BUFC_METADATA]); + zfs_refcount_create(&arc_anon->arcs_esize[ARC_BUFC_DATA]); + zfs_refcount_create(&arc_mru->arcs_esize[ARC_BUFC_METADATA]); + zfs_refcount_create(&arc_mru->arcs_esize[ARC_BUFC_DATA]); + zfs_refcount_create(&arc_mru_ghost->arcs_esize[ARC_BUFC_METADATA]); + zfs_refcount_create(&arc_mru_ghost->arcs_esize[ARC_BUFC_DATA]); + zfs_refcount_create(&arc_mfu->arcs_esize[ARC_BUFC_METADATA]); + zfs_refcount_create(&arc_mfu->arcs_esize[ARC_BUFC_DATA]); + zfs_refcount_create(&arc_mfu_ghost->arcs_esize[ARC_BUFC_METADATA]); + zfs_refcount_create(&arc_mfu_ghost->arcs_esize[ARC_BUFC_DATA]); + zfs_refcount_create(&arc_l2c_only->arcs_esize[ARC_BUFC_METADATA]); + zfs_refcount_create(&arc_l2c_only->arcs_esize[ARC_BUFC_DATA]); - refcount_create(&arc_anon->arcs_size); - refcount_create(&arc_mru->arcs_size); - refcount_create(&arc_mru_ghost->arcs_size); - refcount_create(&arc_mfu->arcs_size); - refcount_create(&arc_mfu_ghost->arcs_size); - refcount_create(&arc_l2c_only->arcs_size); + zfs_refcount_create(&arc_anon->arcs_size); + zfs_refcount_create(&arc_mru->arcs_size); + zfs_refcount_create(&arc_mru_ghost->arcs_size); + zfs_refcount_create(&arc_mfu->arcs_size); + zfs_refcount_create(&arc_mfu_ghost->arcs_size); + zfs_refcount_create(&arc_l2c_only->arcs_size); aggsum_init(&arc_meta_used, 0); aggsum_init(&arc_size, 0); @@ -7059,25 +7068,25 @@ arc_state_init(void) static void arc_state_fini(void) { - refcount_destroy(&arc_anon->arcs_esize[ARC_BUFC_METADATA]); - refcount_destroy(&arc_anon->arcs_esize[ARC_BUFC_DATA]); - refcount_destroy(&arc_mru->arcs_esize[ARC_BUFC_METADATA]); - refcount_destroy(&arc_mru->arcs_esize[ARC_BUFC_DATA]); - refcount_destroy(&arc_mru_ghost->arcs_esize[ARC_BUFC_METADATA]); - refcount_destroy(&arc_mru_ghost->arcs_esize[ARC_BUFC_DATA]); - refcount_destroy(&arc_mfu->arcs_esize[ARC_BUFC_METADATA]); - refcount_destroy(&arc_mfu->arcs_esize[ARC_BUFC_DATA]); - refcount_destroy(&arc_mfu_ghost->arcs_esize[ARC_BUFC_METADATA]); - refcount_destroy(&arc_mfu_ghost->arcs_esize[ARC_BUFC_DATA]); - refcount_destroy(&arc_l2c_only->arcs_esize[ARC_BUFC_METADATA]); - refcount_destroy(&arc_l2c_only->arcs_esize[ARC_BUFC_DATA]); + zfs_refcount_destroy(&arc_anon->arcs_esize[ARC_BUFC_METADATA]); + zfs_refcount_destroy(&arc_anon->arcs_esize[ARC_BUFC_DATA]); + zfs_refcount_destroy(&arc_mru->arcs_esize[ARC_BUFC_METADATA]); + zfs_refcount_destroy(&arc_mru->arcs_esize[ARC_BUFC_DATA]); + zfs_refcount_destroy(&arc_mru_ghost->arcs_esize[ARC_BUFC_METADATA]); + zfs_refcount_destroy(&arc_mru_ghost->arcs_esize[ARC_BUFC_DATA]); + zfs_refcount_destroy(&arc_mfu->arcs_esize[ARC_BUFC_METADATA]); + zfs_refcount_destroy(&arc_mfu->arcs_esize[ARC_BUFC_DATA]); + zfs_refcount_destroy(&arc_mfu_ghost->arcs_esize[ARC_BUFC_METADATA]); + zfs_refcount_destroy(&arc_mfu_ghost->arcs_esize[ARC_BUFC_DATA]); + zfs_refcount_destroy(&arc_l2c_only->arcs_esize[ARC_BUFC_METADATA]); + zfs_refcount_destroy(&arc_l2c_only->arcs_esize[ARC_BUFC_DATA]); - refcount_destroy(&arc_anon->arcs_size); - refcount_destroy(&arc_mru->arcs_size); - refcount_destroy(&arc_mru_ghost->arcs_size); - refcount_destroy(&arc_mfu->arcs_size); - refcount_destroy(&arc_mfu_ghost->arcs_size); - refcount_destroy(&arc_l2c_only->arcs_size); + zfs_refcount_destroy(&arc_anon->arcs_size); + zfs_refcount_destroy(&arc_mru->arcs_size); + zfs_refcount_destroy(&arc_mru_ghost->arcs_size); + zfs_refcount_destroy(&arc_mfu->arcs_size); + zfs_refcount_destroy(&arc_mfu_ghost->arcs_size); + zfs_refcount_destroy(&arc_l2c_only->arcs_size); multilist_destroy(arc_mru->arcs_list[ARC_BUFC_METADATA]); multilist_destroy(arc_mru_ghost->arcs_list[ARC_BUFC_METADATA]); @@ -7359,8 +7368,8 @@ arc_fini(void) mutex_enter(&arc_prune_mtx); while ((p = list_head(&arc_prune_list)) != NULL) { list_remove(&arc_prune_list, p); - refcount_remove(&p->p_refcnt, &arc_prune_list); - refcount_destroy(&p->p_refcnt); + zfs_refcount_remove(&p->p_refcnt, &arc_prune_list); + zfs_refcount_destroy(&p->p_refcnt); kmem_free(p, sizeof (*p)); } mutex_exit(&arc_prune_mtx); @@ -7787,7 +7796,7 @@ top: ARCSTAT_INCR(arcstat_l2_lsize, -HDR_GET_LSIZE(hdr)); bytes_dropped += arc_hdr_size(hdr); - (void) refcount_remove_many(&dev->l2ad_alloc, + (void) zfs_refcount_remove_many(&dev->l2ad_alloc, arc_hdr_size(hdr), hdr); } @@ -8205,7 +8214,8 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint list_insert_head(&dev->l2ad_buflist, hdr); mutex_exit(&dev->l2ad_mtx); - (void) refcount_add_many(&dev->l2ad_alloc, psize, hdr); + (void) zfs_refcount_add_many(&dev->l2ad_alloc, psize, + hdr); /* * Normally the L2ARC can use the hdr's data, but if @@ -8439,7 +8449,7 @@ l2arc_add_vdev(spa_t *spa, vdev_t *vd) offsetof(arc_buf_hdr_t, b_l2hdr.b_l2node)); vdev_space_update(vd, 0, 0, adddev->l2ad_end - adddev->l2ad_hand); - refcount_create(&adddev->l2ad_alloc); + zfs_refcount_create(&adddev->l2ad_alloc); /* * Add device to global list @@ -8485,7 +8495,7 @@ l2arc_remove_vdev(vdev_t *vd) l2arc_evict(remdev, 0, B_TRUE); list_destroy(&remdev->l2ad_buflist); mutex_destroy(&remdev->l2ad_mtx); - refcount_destroy(&remdev->l2ad_alloc); + zfs_refcount_destroy(&remdev->l2ad_alloc); kmem_free(remdev, sizeof (l2arc_dev_t)); } Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Tue Nov 5 07:06:45 2019 (r354353) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Tue Nov 5 07:11:12 2019 (r354354) @@ -226,7 +226,7 @@ static boolean_t dbuf_evict_thread_exit; */ typedef struct dbuf_cache { multilist_t *cache; - refcount_t size; + zfs_refcount_t size; } dbuf_cache_t; dbuf_cache_t dbuf_caches[DB_CACHE_MAX]; @@ -316,7 +316,7 @@ dbuf_cons(void *vdb, void *unused, int kmflag) mutex_init(&db->db_mtx, NULL, MUTEX_DEFAULT, NULL); cv_init(&db->db_changed, NULL, CV_DEFAULT, NULL); multilist_link_init(&db->db_cache_link); - refcount_create(&db->db_holds); + zfs_refcount_create(&db->db_holds); return (0); } @@ -329,7 +329,7 @@ dbuf_dest(void *vdb, void *unused) mutex_destroy(&db->db_mtx); cv_destroy(&db->db_changed); ASSERT(!multilist_link_active(&db->db_cache_link)); - refcount_destroy(&db->db_holds); + zfs_refcount_destroy(&db->db_holds); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Tue Nov 5 07:13:08 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7919D179374; Tue, 5 Nov 2019 07:13:08 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 476gqS2jd3z3wkJ; Tue, 5 Nov 2019 07:13:08 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 40DEC916A; Tue, 5 Nov 2019 07:13:08 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA57D8up013794; Tue, 5 Nov 2019 07:13:08 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA57D8ri013793; Tue, 5 Nov 2019 07:13:08 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911050713.xA57D8ri013793@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Tue, 5 Nov 2019 07:13:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354355 - stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Commit-Revision: 354355 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.29 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, 05 Nov 2019 07:13:08 -0000 Author: avg Date: Tue Nov 5 07:13:07 2019 New Revision: 354355 URL: https://svnweb.freebsd.org/changeset/base/354355 Log: MFC r353629: MFV r353628: 10842 Mutex leak in dsl_dataset_hold_obj() Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Tue Nov 5 07:11:12 2019 (r354354) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Tue Nov 5 07:13:07 2019 (r354355) @@ -573,10 +573,14 @@ dsl_dataset_hold_obj(dsl_pool_t *dp, uint64_t dsobj, v if (ds->ds_prev) dsl_dataset_rele(ds->ds_prev, ds); dsl_dir_rele(ds->ds_dir, ds); + list_destroy(&ds->ds_prop_cbs); + list_destroy(&ds->ds_sendstreams); mutex_destroy(&ds->ds_lock); mutex_destroy(&ds->ds_opening_lock); mutex_destroy(&ds->ds_sendstream_lock); + mutex_destroy(&ds->ds_remap_deadlist_lock); zfs_refcount_destroy(&ds->ds_longholds); + rrw_destroy(&ds->ds_bp_rwlock); kmem_free(ds, sizeof (dsl_dataset_t)); if (err != 0) { dmu_buf_rele(dbuf, tag); From owner-svn-src-stable@freebsd.org Tue Nov 5 19:14:18 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 83DD31B1846; Tue, 5 Nov 2019 19:14:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 476zqZ2zJJz3QqW; Tue, 5 Nov 2019 19:14:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4A35D195F0; Tue, 5 Nov 2019 19:14:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA5JEI6a044269; Tue, 5 Nov 2019 19:14:18 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA5JEIC5044268; Tue, 5 Nov 2019 19:14:18 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201911051914.xA5JEIC5044268@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 5 Nov 2019 19:14:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354365 - stable/12/sys/cddl/contrib/opensolaris/uts/common/zmod X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/cddl/contrib/opensolaris/uts/common/zmod X-SVN-Commit-Revision: 354365 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.29 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, 05 Nov 2019 19:14:18 -0000 Author: mav Date: Tue Nov 5 19:14:17 2019 New Revision: 354365 URL: https://svnweb.freebsd.org/changeset/base/354365 Log: MFC r354159: FreeBSD'fy ZFS zlib zalloc/zfree callbacks. The previous code came from OpenSolaris, which in my understanding require allocation size to be known to free memory. To store that size previous code allocated additional 8 byte header. But I have noticed that zlib with present settings allocates 64KB context buffers for each call, that could be efficiently cached by UMA, but addition of those 8 bytes makes them fall back to physical RAM allocations, that cause huge overhead and lock congestion on small blocks. Since FreeBSD's free() does not have the size argument, switching to it solves the problem, increasing write speed to ZVOLs with 4KB block size and GZIP compression on my 40-threads test system from ~60MB/s to ~600MB/s. Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/zmod/zmod_subr.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/zmod/zmod_subr.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/zmod/zmod_subr.c Tue Nov 5 18:35:13 2019 (r354364) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/zmod/zmod_subr.c Tue Nov 5 19:14:17 2019 (r354365) @@ -28,41 +28,23 @@ #include #include -#include +#include -struct zchdr { - uint_t zch_magic; - uint_t zch_size; -}; - -#define ZCH_MAGIC 0x3cc13cc1 - /*ARGSUSED*/ void * zcalloc(void *opaque, uint_t items, uint_t size) { - size_t nbytes = sizeof (struct zchdr) + items * size; - struct zchdr *z = kobj_zalloc(nbytes, KM_NOWAIT|KM_TMP); + void *ptr; - if (z == NULL) - return (NULL); - - z->zch_magic = ZCH_MAGIC; - z->zch_size = nbytes; - - return (z + 1); + ptr = malloc((size_t)items * size, M_SOLARIS, M_NOWAIT); + return ptr; } /*ARGSUSED*/ void zcfree(void *opaque, void *ptr) { - struct zchdr *z = ((struct zchdr *)ptr) - 1; - - if (z->zch_magic != ZCH_MAGIC) - panic("zcfree region corrupt: hdr=%p ptr=%p", (void *)z, ptr); - - kobj_free(z, z->zch_size); + free(ptr, M_SOLARIS); } void From owner-svn-src-stable@freebsd.org Tue Nov 5 19:15:43 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D98091B1920; Tue, 5 Nov 2019 19:15:43 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 476zsC5WMwz3R1B; Tue, 5 Nov 2019 19:15:43 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A147A195F2; Tue, 5 Nov 2019 19:15:43 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA5JFh9m044400; Tue, 5 Nov 2019 19:15:43 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA5JFhvo044399; Tue, 5 Nov 2019 19:15:43 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201911051915.xA5JFhvo044399@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 5 Nov 2019 19:15: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: r354366 - stable/11/sys/cddl/contrib/opensolaris/uts/common/zmod X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cddl/contrib/opensolaris/uts/common/zmod X-SVN-Commit-Revision: 354366 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.29 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, 05 Nov 2019 19:15:43 -0000 Author: mav Date: Tue Nov 5 19:15:43 2019 New Revision: 354366 URL: https://svnweb.freebsd.org/changeset/base/354366 Log: MFC r354159: FreeBSD'fy ZFS zlib zalloc/zfree callbacks. The previous code came from OpenSolaris, which in my understanding require allocation size to be known to free memory. To store that size previous code allocated additional 8 byte header. But I have noticed that zlib with present settings allocates 64KB context buffers for each call, that could be efficiently cached by UMA, but addition of those 8 bytes makes them fall back to physical RAM allocations, that cause huge overhead and lock congestion on small blocks. Since FreeBSD's free() does not have the size argument, switching to it solves the problem, increasing write speed to ZVOLs with 4KB block size and GZIP compression on my 40-threads test system from ~60MB/s to ~600MB/s. Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/zmod/zmod_subr.c Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/zmod/zmod_subr.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/zmod/zmod_subr.c Tue Nov 5 19:14:17 2019 (r354365) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/zmod/zmod_subr.c Tue Nov 5 19:15:43 2019 (r354366) @@ -28,41 +28,23 @@ #include #include -#include +#include -struct zchdr { - uint_t zch_magic; - uint_t zch_size; -}; - -#define ZCH_MAGIC 0x3cc13cc1 - /*ARGSUSED*/ void * zcalloc(void *opaque, uint_t items, uint_t size) { - size_t nbytes = sizeof (struct zchdr) + items * size; - struct zchdr *z = kobj_zalloc(nbytes, KM_NOWAIT|KM_TMP); + void *ptr; - if (z == NULL) - return (NULL); - - z->zch_magic = ZCH_MAGIC; - z->zch_size = nbytes; - - return (z + 1); + ptr = malloc((size_t)items * size, M_SOLARIS, M_NOWAIT); + return ptr; } /*ARGSUSED*/ void zcfree(void *opaque, void *ptr) { - struct zchdr *z = ((struct zchdr *)ptr) - 1; - - if (z->zch_magic != ZCH_MAGIC) - panic("zcfree region corrupt: hdr=%p ptr=%p", (void *)z, ptr); - - kobj_free(z, z->zch_size); + free(ptr, M_SOLARIS); } void From owner-svn-src-stable@freebsd.org Wed Nov 6 08:33:57 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 850B81AE067; Wed, 6 Nov 2019 08:33:57 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 477KZF3kWpz3Gky; Wed, 6 Nov 2019 08:33:57 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6478B22637; Wed, 6 Nov 2019 08:33:57 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA68XvbW034361; Wed, 6 Nov 2019 08:33:57 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA68Xvpf034359; Wed, 6 Nov 2019 08:33:57 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911060833.xA68Xvpf034359@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 6 Nov 2019 08:33:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354374 - in stable/12: cddl/contrib/opensolaris/cmd/ztest sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in stable/12: cddl/contrib/opensolaris/cmd/ztest sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Commit-Revision: 354374 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.29 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, 06 Nov 2019 08:33:57 -0000 Author: avg Date: Wed Nov 6 08:33:56 2019 New Revision: 354374 URL: https://svnweb.freebsd.org/changeset/base/354374 Log: MFC r353616: MFV r353615: 9485 Optimize possible split block search space Modified: stable/12/cddl/contrib/opensolaris/cmd/ztest/ztest.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_indirect.c Directory Properties: stable/12/ (props changed) Modified: stable/12/cddl/contrib/opensolaris/cmd/ztest/ztest.c ============================================================================== --- stable/12/cddl/contrib/opensolaris/cmd/ztest/ztest.c Wed Nov 6 06:50:02 2019 (r354373) +++ stable/12/cddl/contrib/opensolaris/cmd/ztest/ztest.c Wed Nov 6 08:33:56 2019 (r354374) @@ -198,6 +198,7 @@ extern boolean_t zfs_compressed_arc_enabled; extern boolean_t zfs_abd_scatter_enabled; extern int dmu_object_alloc_chunk_shift; extern boolean_t zfs_force_some_double_word_sm_entries; +extern unsigned long zfs_reconstruct_indirect_damage_fraction; static ztest_shared_opts_t *ztest_shared_opts; static ztest_shared_opts_t ztest_opts; @@ -5696,7 +5697,8 @@ ztest_run_zdb(char *pool) isa = strdup(isa); /* LINTED */ (void) sprintf(bin, - "/usr/sbin%.*s/zdb -bcc%s%s -G -d -U %s %s", + "/usr/sbin%.*s/zdb -bcc%s%s -G -d -U %s " + "-o zfs_reconstruct_indirect_combinations_max=65536 %s", isalen, isa, ztest_opts.zo_verbose >= 3 ? "s" : "", @@ -6652,6 +6654,13 @@ main(int argc, char **argv) * of them so the feature get tested. */ zfs_force_some_double_word_sm_entries = B_TRUE; + + /* + * Verify that even extensively damaged split blocks with many + * segments can be reconstructed in a reasonable amount of time + * when reconstruction is known to be possible. + */ + zfs_reconstruct_indirect_damage_fraction = 4; ztest_fd_rand = open("/dev/urandom", O_RDONLY); ASSERT3S(ztest_fd_rand, >=, 0); Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_indirect.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_indirect.c Wed Nov 6 06:50:02 2019 (r354373) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_indirect.c Wed Nov 6 08:33:56 2019 (r354374) @@ -206,19 +206,23 @@ uint64_t zfs_condense_min_mapping_bytes = 128 * 1024; int zfs_condense_indirect_commit_entry_delay_ticks = 0; /* - * If a split block contains more than this many segments, consider it too - * computationally expensive to check all (2^num_segments) possible - * combinations. Instead, try at most 2^_segments_max randomly-selected - * combinations. - * - * This is reasonable if only a few segment copies are damaged and the - * majority of segment copies are good. This allows all the segment copies to - * participate fairly in the reconstruction and prevents the repeated use of - * one bad copy. + * If an indirect split block contains more than this many possible unique + * combinations when being reconstructed, consider it too computationally + * expensive to check them all. Instead, try at most 100 randomly-selected + * combinations each time the block is accessed. This allows all segment + * copies to participate fairly in the reconstruction when all combinations + * cannot be checked and prevents repeated use of one bad copy. */ -int zfs_reconstruct_indirect_segments_max = 10; +int zfs_reconstruct_indirect_combinations_max = 256; + /* + * Enable to simulate damaged segments and validate reconstruction. + * Used by ztest + */ +unsigned long zfs_reconstruct_indirect_damage_fraction = 0; + +/* * The indirect_child_t represents the vdev that we will read from, when we * need to read all copies of the data (e.g. for scrub or reconstruction). * For plain (non-mirror) top-level vdevs (i.e. is_vdev is not a mirror), @@ -228,6 +232,13 @@ int zfs_reconstruct_indirect_segments_max = 10; typedef struct indirect_child { abd_t *ic_data; vdev_t *ic_vdev; + + /* + * ic_duplicate is NULL when the ic_data contents are unique, when it + * is determined to be a duplicate it references the primary child. + */ + struct indirect_child *ic_duplicate; + list_node_t ic_node; /* node on is_unique_child */ } indirect_child_t; /* @@ -249,12 +260,14 @@ typedef struct indirect_split { uint64_t is_target_offset; /* offset on is_vdev */ uint64_t is_size; int is_children; /* number of entries in is_child[] */ + int is_unique_children; /* number of entries in is_unique_child */ + list_t is_unique_child; /* * is_good_child is the child that we are currently using to * attempt reconstruction. */ - int is_good_child; + indirect_child_t *is_good_child; indirect_child_t is_child[1]; /* variable-length */ } indirect_split_t; @@ -266,6 +279,9 @@ typedef struct indirect_split { typedef struct indirect_vsd { boolean_t iv_split_block; boolean_t iv_reconstruct; + uint64_t iv_unique_combinations; + uint64_t iv_attempts; + uint64_t iv_attempts_max; list_t iv_splits; /* list of indirect_split_t's */ } indirect_vsd_t; @@ -283,6 +299,13 @@ vdev_indirect_map_free(zio_t *zio) abd_free(ic->ic_data); } list_remove(&iv->iv_splits, is); + + indirect_child_t *ic; + while ((ic = list_head(&is->is_unique_child)) != NULL) + list_remove(&is->is_unique_child, ic); + + list_destroy(&is->is_unique_child); + kmem_free(is, offsetof(indirect_split_t, is_child[is->is_children])); } @@ -1181,6 +1204,8 @@ vdev_indirect_gather_splits(uint64_t split_offset, vde is->is_split_offset = split_offset; is->is_target_offset = offset; is->is_vdev = vd; + list_create(&is->is_unique_child, sizeof (indirect_child_t), + offsetof(indirect_child_t, ic_node)); /* * Note that we only consider multiple copies of the data for @@ -1191,6 +1216,7 @@ vdev_indirect_gather_splits(uint64_t split_offset, vde if (vd->vdev_ops == &vdev_mirror_ops) { for (int i = 0; i < n; i++) { is->is_child[i].ic_vdev = vd->vdev_child[i]; + list_link_init(&is->is_child[i].ic_node); } } else { is->is_child[0].ic_vdev = vd; @@ -1243,6 +1269,7 @@ vdev_indirect_read_all(zio_t *zio) ic->ic_data = abd_alloc_sametype(zio->io_abd, is->is_size); + ic->ic_duplicate = NULL; zio_nowait(zio_vdev_child_io(zio, NULL, ic->ic_vdev, is->is_target_offset, ic->ic_data, @@ -1364,7 +1391,7 @@ vdev_indirect_checksum_error(zio_t *zio, zio_bad_cksum_t zbc = { 0 }; void *bad_buf = abd_borrow_buf_copy(ic->ic_data, is->is_size); - abd_t *good_abd = is->is_child[is->is_good_child].ic_data; + abd_t *good_abd = is->is_good_child->ic_data; void *good_buf = abd_borrow_buf_copy(good_abd, is->is_size); zfs_ereport_post_checksum(zio->io_spa, vd, zio, is->is_target_offset, is->is_size, good_buf, bad_buf, &zbc); @@ -1397,21 +1424,18 @@ vdev_indirect_repair(zio_t *zio) for (indirect_split_t *is = list_head(&iv->iv_splits); is != NULL; is = list_next(&iv->iv_splits, is)) { - indirect_child_t *good_child = &is->is_child[is->is_good_child]; - for (int c = 0; c < is->is_children; c++) { indirect_child_t *ic = &is->is_child[c]; - if (ic == good_child) + if (ic == is->is_good_child) continue; if (ic->ic_data == NULL) continue; - if (abd_cmp(good_child->ic_data, ic->ic_data, - is->is_size) == 0) + if (ic->ic_duplicate == is->is_good_child) continue; zio_nowait(zio_vdev_child_io(zio, NULL, ic->ic_vdev, is->is_target_offset, - good_child->ic_data, is->is_size, + is->is_good_child->ic_data, is->is_size, ZIO_TYPE_WRITE, ZIO_PRIORITY_ASYNC_WRITE, ZIO_FLAG_IO_REPAIR | ZIO_FLAG_SELF_HEAL, NULL, NULL)); @@ -1454,21 +1478,194 @@ vdev_indirect_all_checksum_errors(zio_t *zio) } /* + * Copy data from all the splits to a main zio then validate the checksum. + * If then checksum is successfully validated return success. + */ +static int +vdev_indirect_splits_checksum_validate(indirect_vsd_t *iv, zio_t *zio) +{ + zio_bad_cksum_t zbc; + + for (indirect_split_t *is = list_head(&iv->iv_splits); + is != NULL; is = list_next(&iv->iv_splits, is)) { + + ASSERT3P(is->is_good_child->ic_data, !=, NULL); + ASSERT3P(is->is_good_child->ic_duplicate, ==, NULL); + + abd_copy_off(zio->io_abd, is->is_good_child->ic_data, + is->is_split_offset, 0, is->is_size); + } + + return (zio_checksum_error(zio, &zbc)); +} + +/* + * There are relatively few possible combinations making it feasible to + * deterministically check them all. We do this by setting the good_child + * to the next unique split version. If we reach the end of the list then + * "carry over" to the next unique split version (like counting in base + * is_unique_children, but each digit can have a different base). + */ +static int +vdev_indirect_splits_enumerate_all(indirect_vsd_t *iv, zio_t *zio) +{ + boolean_t more = B_TRUE; + + iv->iv_attempts = 0; + + for (indirect_split_t *is = list_head(&iv->iv_splits); + is != NULL; is = list_next(&iv->iv_splits, is)) + is->is_good_child = list_head(&is->is_unique_child); + + while (more == B_TRUE) { + iv->iv_attempts++; + more = B_FALSE; + + if (vdev_indirect_splits_checksum_validate(iv, zio) == 0) + return (0); + + for (indirect_split_t *is = list_head(&iv->iv_splits); + is != NULL; is = list_next(&iv->iv_splits, is)) { + is->is_good_child = list_next(&is->is_unique_child, + is->is_good_child); + if (is->is_good_child != NULL) { + more = B_TRUE; + break; + } + + is->is_good_child = list_head(&is->is_unique_child); + } + } + + ASSERT3S(iv->iv_attempts, <=, iv->iv_unique_combinations); + + return (SET_ERROR(ECKSUM)); +} + +/* + * There are too many combinations to try all of them in a reasonable amount + * of time. So try a fixed number of random combinations from the unique + * split versions, after which we'll consider the block unrecoverable. + */ +static int +vdev_indirect_splits_enumerate_randomly(indirect_vsd_t *iv, zio_t *zio) +{ + iv->iv_attempts = 0; + + while (iv->iv_attempts < iv->iv_attempts_max) { + iv->iv_attempts++; + + for (indirect_split_t *is = list_head(&iv->iv_splits); + is != NULL; is = list_next(&iv->iv_splits, is)) { + indirect_child_t *ic = list_head(&is->is_unique_child); + int children = is->is_unique_children; + + for (int i = spa_get_random(children); i > 0; i--) + ic = list_next(&is->is_unique_child, ic); + + ASSERT3P(ic, !=, NULL); + is->is_good_child = ic; + } + + if (vdev_indirect_splits_checksum_validate(iv, zio) == 0) + return (0); + } + + return (SET_ERROR(ECKSUM)); +} + +/* + * This is a validation function for reconstruction. It randomly selects + * a good combination, if one can be found, and then it intentionally + * damages all other segment copes by zeroing them. This forces the + * reconstruction algorithm to locate the one remaining known good copy. + */ +static int +vdev_indirect_splits_damage(indirect_vsd_t *iv, zio_t *zio) +{ + /* Presume all the copies are unique for initial selection. */ + for (indirect_split_t *is = list_head(&iv->iv_splits); + is != NULL; is = list_next(&iv->iv_splits, is)) { + is->is_unique_children = 0; + + for (int i = 0; i < is->is_children; i++) { + indirect_child_t *ic = &is->is_child[i]; + if (ic->ic_data != NULL) { + is->is_unique_children++; + list_insert_tail(&is->is_unique_child, ic); + } + } + } + + /* + * Set each is_good_child to a randomly-selected child which + * is known to contain validated data. + */ + int error = vdev_indirect_splits_enumerate_randomly(iv, zio); + if (error) + goto out; + + /* + * Damage all but the known good copy by zeroing it. This will + * result in two or less unique copies per indirect_child_t. + * Both may need to be checked in order to reconstruct the block. + * Set iv->iv_attempts_max such that all unique combinations will + * enumerated, but limit the damage to at most 16 indirect splits. + */ + iv->iv_attempts_max = 1; + + for (indirect_split_t *is = list_head(&iv->iv_splits); + is != NULL; is = list_next(&iv->iv_splits, is)) { + for (int c = 0; c < is->is_children; c++) { + indirect_child_t *ic = &is->is_child[c]; + + if (ic == is->is_good_child) + continue; + if (ic->ic_data == NULL) + continue; + + abd_zero(ic->ic_data, ic->ic_data->abd_size); + } + + iv->iv_attempts_max *= 2; + if (iv->iv_attempts_max > (1ULL << 16)) { + iv->iv_attempts_max = UINT64_MAX; + break; + } + } + +out: + /* Empty the unique children lists so they can be reconstructed. */ + for (indirect_split_t *is = list_head(&iv->iv_splits); + is != NULL; is = list_next(&iv->iv_splits, is)) { + indirect_child_t *ic; + while ((ic = list_head(&is->is_unique_child)) != NULL) + list_remove(&is->is_unique_child, ic); + + is->is_unique_children = 0; + } + + return (error); +} + +/* * This function is called when we have read all copies of the data and need * to try to find a combination of copies that gives us the right checksum. * * If we pointed to any mirror vdevs, this effectively does the job of the * mirror. The mirror vdev code can't do its own job because we don't know - * the checksum of each split segment individually. We have to try every - * combination of copies of split segments, until we find one that checksums - * correctly. (Or until we have tried all combinations, or have tried - * 2^zfs_reconstruct_indirect_segments_max combinations. In these cases we - * set io_error to ECKSUM to propagate the error up to the user.) + * the checksum of each split segment individually. * - * For example, if we have 3 segments in the split, - * and each points to a 2-way mirror, we will have the following pieces of - * data: + * We have to try every unique combination of copies of split segments, until + * we find one that checksums correctly. Duplicate segment copies are first + * identified and latter skipped during reconstruction. This optimization + * reduces the search space and ensures that of the remaining combinations + * at most one is correct. * + * When the total number of combinations is small they can all be checked. + * For example, if we have 3 segments in the split, and each points to a + * 2-way mirror with unique copies, we will have the following pieces of data: + * * | mirror child * split | [0] [1] * ======|===================== @@ -1494,10 +1691,10 @@ vdev_indirect_all_checksum_errors(zio_t *zio) * data_A_1 data_B_1 data_C_1 * * Note that the split segments may be on the same or different top-level - * vdevs. In either case, we try lots of combinations (see - * zfs_reconstruct_indirect_segments_max). This ensures that if a mirror has - * small silent errors on all of its children, we can still reconstruct the - * correct data, as long as those errors are at sufficiently-separated + * vdevs. In either case, we may need to try lots of combinations (see + * zfs_reconstruct_indirect_combinations_max). This ensures that if a mirror + * has small silent errors on all of its children, we can still reconstruct + * the correct data, as long as those errors are at sufficiently-separated * offsets (specifically, separated by the largest block size - default of * 128KB, but up to 16MB). */ @@ -1505,90 +1702,91 @@ static void vdev_indirect_reconstruct_io_done(zio_t *zio) { indirect_vsd_t *iv = zio->io_vsd; - uint64_t attempts = 0; - uint64_t attempts_max = 1ULL << zfs_reconstruct_indirect_segments_max; - int segments = 0; + boolean_t known_good = B_FALSE; + int error; + iv->iv_unique_combinations = 1; + iv->iv_attempts_max = UINT64_MAX; + + if (zfs_reconstruct_indirect_combinations_max > 0) + iv->iv_attempts_max = zfs_reconstruct_indirect_combinations_max; + + /* + * If nonzero, every 1/x blocks will be damaged, in order to validate + * reconstruction when there are split segments with damaged copies. + * Known_good will TRUE when reconstruction is known to be possible. + */ + if (zfs_reconstruct_indirect_damage_fraction != 0 && + spa_get_random(zfs_reconstruct_indirect_damage_fraction) == 0) + known_good = (vdev_indirect_splits_damage(iv, zio) == 0); + + /* + * Determine the unique children for a split segment and add them + * to the is_unique_child list. By restricting reconstruction + * to these children, only unique combinations will be considered. + * This can vastly reduce the search space when there are a large + * number of indirect splits. + */ for (indirect_split_t *is = list_head(&iv->iv_splits); - is != NULL; is = list_next(&iv->iv_splits, is)) - segments++; + is != NULL; is = list_next(&iv->iv_splits, is)) { + is->is_unique_children = 0; - for (;;) { - /* copy data from splits to main zio */ - int ret; - for (indirect_split_t *is = list_head(&iv->iv_splits); - is != NULL; is = list_next(&iv->iv_splits, is)) { + for (int i = 0; i < is->is_children; i++) { + indirect_child_t *ic_i = &is->is_child[i]; - /* - * If this child failed, its ic_data will be NULL. - * Skip this combination. - */ - if (is->is_child[is->is_good_child].ic_data == NULL) { - ret = EIO; - goto next; - } + if (ic_i->ic_data == NULL || + ic_i->ic_duplicate != NULL) + continue; - abd_copy_off(zio->io_abd, - is->is_child[is->is_good_child].ic_data, - is->is_split_offset, 0, is->is_size); - } + for (int j = i + 1; j < is->is_children; j++) { + indirect_child_t *ic_j = &is->is_child[j]; - /* See if this checksum matches. */ - zio_bad_cksum_t zbc; - ret = zio_checksum_error(zio, &zbc); - if (ret == 0) { - /* Found a matching checksum. Issue repair i/os. */ - vdev_indirect_repair(zio); - zio_checksum_verified(zio); - return; - } + if (ic_j->ic_data == NULL || + ic_j->ic_duplicate != NULL) + continue; - /* - * Checksum failed; try a different combination of split - * children. - */ - boolean_t more; -next: - more = B_FALSE; - if (segments <= zfs_reconstruct_indirect_segments_max) { - /* - * There are relatively few segments, so - * deterministically check all combinations. We do - * this by by adding one to the first split's - * good_child. If it overflows, then "carry over" to - * the next split (like counting in base is_children, - * but each digit can have a different base). - */ - for (indirect_split_t *is = list_head(&iv->iv_splits); - is != NULL; is = list_next(&iv->iv_splits, is)) { - is->is_good_child++; - if (is->is_good_child < is->is_children) { - more = B_TRUE; - break; + if (abd_cmp(ic_i->ic_data, ic_j->ic_data, + is->is_size) == 0) { + ic_j->ic_duplicate = ic_i; } - is->is_good_child = 0; } - } else if (++attempts < attempts_max) { - /* - * There are too many combinations to try all of them - * in a reasonable amount of time, so try a fixed - * number of random combinations, after which we'll - * consider the block unrecoverable. - */ - for (indirect_split_t *is = list_head(&iv->iv_splits); - is != NULL; is = list_next(&iv->iv_splits, is)) { - is->is_good_child = - spa_get_random(is->is_children); - } - more = B_TRUE; + + is->is_unique_children++; + list_insert_tail(&is->is_unique_child, ic_i); } - if (!more) { - /* All combinations failed. */ - zio->io_error = ret; + + /* Reconstruction is impossible, no valid children */ + EQUIV(list_is_empty(&is->is_unique_child), + is->is_unique_children == 0); + if (list_is_empty(&is->is_unique_child)) { + zio->io_error = EIO; vdev_indirect_all_checksum_errors(zio); zio_checksum_verified(zio); return; } + + iv->iv_unique_combinations *= is->is_unique_children; + } + + if (iv->iv_unique_combinations <= iv->iv_attempts_max) + error = vdev_indirect_splits_enumerate_all(iv, zio); + else + error = vdev_indirect_splits_enumerate_randomly(iv, zio); + + if (error != 0) { + /* All attempted combinations failed. */ + ASSERT3B(known_good, ==, B_FALSE); + zio->io_error = error; + vdev_indirect_all_checksum_errors(zio); + } else { + /* + * The checksum has been successfully validated. Issue + * repair I/Os to any copies of splits which don't match + * the validated version. + */ + ASSERT0(vdev_indirect_splits_checksum_validate(iv, zio)); + vdev_indirect_repair(zio); + zio_checksum_verified(zio); } } From owner-svn-src-stable@freebsd.org Wed Nov 6 08:36:13 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B3DA81AE10A; Wed, 6 Nov 2019 08:36:13 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 477Kcs550pz3Gsx; Wed, 6 Nov 2019 08:36:13 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9193722639; Wed, 6 Nov 2019 08:36:13 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA68aDOg034540; Wed, 6 Nov 2019 08:36:13 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA68aCAp034534; Wed, 6 Nov 2019 08:36:12 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911060836.xA68aCAp034534@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 6 Nov 2019 08:36:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354375 - in stable/12: cddl/contrib/opensolaris/cmd/ztest sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in stable/12: cddl/contrib/opensolaris/cmd/ztest sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys X-SVN-Commit-Revision: 354375 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.29 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, 06 Nov 2019 08:36:13 -0000 Author: avg Date: Wed Nov 6 08:36:12 2019 New Revision: 354375 URL: https://svnweb.freebsd.org/changeset/base/354375 Log: MFC r353634: MFV r348596: 9689 zfs range lock code should not be zpl-specific Modified: stable/12/cddl/contrib/opensolaris/cmd/ztest/ztest.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_rlock.h stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_rlock.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Directory Properties: stable/12/ (props changed) Modified: stable/12/cddl/contrib/opensolaris/cmd/ztest/ztest.c ============================================================================== --- stable/12/cddl/contrib/opensolaris/cmd/ztest/ztest.c Wed Nov 6 08:33:56 2019 (r354374) +++ stable/12/cddl/contrib/opensolaris/cmd/ztest/ztest.c Wed Nov 6 08:36:12 2019 (r354375) @@ -242,7 +242,9 @@ typedef struct bufwad { } bufwad_t; /* - * XXX -- fix zfs range locks to be generic so we can use them here. + * It would be better to use a rangelock_t per object. Unfortunately + * the rangelock_t is not a drop-in replacement for rl_t, because we + * still need to map from object ID to rangelock_t. */ typedef enum { RL_READER, @@ -1943,12 +1945,12 @@ static void ztest_get_done(zgd_t *zgd, int error) { ztest_ds_t *zd = zgd->zgd_private; - uint64_t object = zgd->zgd_rl->rl_object; + uint64_t object = ((rl_t *)zgd->zgd_lr)->rl_object; if (zgd->zgd_db) dmu_buf_rele(zgd->zgd_db, zgd); - ztest_range_unlock(zgd->zgd_rl); + ztest_range_unlock((rl_t *)zgd->zgd_lr); ztest_object_unlock(zd, object); umem_free(zgd, sizeof (*zgd)); @@ -1998,8 +2000,8 @@ ztest_get_data(void *arg, lr_write_t *lr, char *buf, s zgd->zgd_private = zd; if (buf != NULL) { /* immediate write */ - zgd->zgd_rl = ztest_range_lock(zd, object, offset, size, - RL_READER); + zgd->zgd_lr = (struct locked_range *)ztest_range_lock(zd, + object, offset, size, RL_READER); error = dmu_read(os, object, offset, size, buf, DMU_READ_NO_PREFETCH); @@ -2013,8 +2015,8 @@ ztest_get_data(void *arg, lr_write_t *lr, char *buf, s offset = 0; } - zgd->zgd_rl = ztest_range_lock(zd, object, offset, size, - RL_READER); + zgd->zgd_lr = (struct locked_range *)ztest_range_lock(zd, + object, offset, size, RL_READER); error = dmu_buf_hold(os, object, offset, zgd, &db, DMU_READ_NO_PREFETCH); Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h Wed Nov 6 08:33:56 2019 (r354374) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h Wed Nov 6 08:36:12 2019 (r354375) @@ -75,6 +75,7 @@ struct arc_buf; struct zio_prop; struct sa_handle; struct file; +struct locked_range; typedef struct objset objset_t; typedef struct dmu_tx dmu_tx_t; @@ -966,7 +967,7 @@ typedef struct zgd { struct lwb *zgd_lwb; struct blkptr *zgd_bp; dmu_buf_t *zgd_db; - struct rl *zgd_rl; + struct locked_range *zgd_lr; void *zgd_private; } zgd_t; Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_rlock.h ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_rlock.h Wed Nov 6 08:33:56 2019 (r354374) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_rlock.h Wed Nov 6 08:36:12 2019 (r354375) @@ -22,6 +22,9 @@ * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright (c) 2018 by Delphix. All rights reserved. + */ #ifndef _SYS_FS_ZFS_RLOCK_H #define _SYS_FS_ZFS_RLOCK_H @@ -30,54 +33,53 @@ extern "C" { #endif -#ifdef _KERNEL +#ifdef __FreeBSD__ +#define rangelock_init zfs_rangelock_init +#define rangelock_fini zfs_rangelock_fini +#endif -#include - typedef enum { RL_READER, RL_WRITER, RL_APPEND -} rl_type_t; +} rangelock_type_t; -typedef struct rl { - znode_t *r_zp; /* znode this lock applies to */ - avl_node_t r_node; /* avl node link */ - uint64_t r_off; /* file range offset */ - uint64_t r_len; /* file range length */ - uint_t r_cnt; /* range reference count in tree */ - rl_type_t r_type; /* range type */ - kcondvar_t r_wr_cv; /* cv for waiting writers */ - kcondvar_t r_rd_cv; /* cv for waiting readers */ - uint8_t r_proxy; /* acting for original range */ - uint8_t r_write_wanted; /* writer wants to lock this range */ - uint8_t r_read_wanted; /* reader wants to lock this range */ -} rl_t; +struct locked_range; -/* - * Lock a range (offset, length) as either shared (RL_READER) - * or exclusive (RL_WRITER or RL_APPEND). RL_APPEND is a special type that - * is converted to RL_WRITER that specified to lock from the start of the - * end of file. Returns the range lock structure. - */ -rl_t *zfs_range_lock(znode_t *zp, uint64_t off, uint64_t len, rl_type_t type); +typedef void (rangelock_cb_t)(struct locked_range *, void *); -/* Unlock range and destroy range lock structure. */ -void zfs_range_unlock(rl_t *rl); +#ifdef __FreeBSD__ +typedef struct zfs_rangelock { +#else +typedef struct rangelock { +#endif + avl_tree_t rl_tree; /* contains locked_range_t */ + kmutex_t rl_lock; + rangelock_cb_t *rl_cb; + void *rl_arg; +} rangelock_t; -/* - * Reduce range locked as RW_WRITER from whole file to specified range. - * Asserts the whole file was previously locked. - */ -void zfs_range_reduce(rl_t *rl, uint64_t off, uint64_t len); +typedef struct locked_range { + rangelock_t *lr_rangelock; /* rangelock that this lock applies to */ + avl_node_t lr_node; /* avl node link */ + uint64_t lr_offset; /* file range offset */ + uint64_t lr_length; /* file range length */ + uint_t lr_count; /* range reference count in tree */ + rangelock_type_t lr_type; /* range type */ + kcondvar_t lr_write_cv; /* cv for waiting writers */ + kcondvar_t lr_read_cv; /* cv for waiting readers */ + uint8_t lr_proxy; /* acting for original range */ + uint8_t lr_write_wanted; /* writer wants to lock this range */ + uint8_t lr_read_wanted; /* reader wants to lock this range */ +} locked_range_t; -/* - * AVL comparison function used to order range locks - * Locks are ordered on the start offset of the range. - */ -int zfs_range_compare(const void *arg1, const void *arg2); +void rangelock_init(rangelock_t *, rangelock_cb_t *, void *); +void rangelock_fini(rangelock_t *); -#endif /* _KERNEL */ +locked_range_t *rangelock_enter(rangelock_t *, + uint64_t, uint64_t, rangelock_type_t); +void rangelock_exit(locked_range_t *); +void rangelock_reduce(locked_range_t *, uint64_t, uint64_t); #ifdef __cplusplus } Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h Wed Nov 6 08:33:56 2019 (r354374) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h Wed Nov 6 08:36:12 2019 (r354375) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2015 by Delphix. All rights reserved. + * Copyright (c) 2012, 2018 by Delphix. All rights reserved. * Copyright (c) 2014 Integros [integros.com] * Copyright 2016 Nexenta Systems, Inc. All rights reserved. */ @@ -36,6 +36,7 @@ #include #include #include +#include #endif #include #include @@ -57,8 +58,8 @@ extern "C" { #define ZFS_APPENDONLY 0x0000004000000000 #define ZFS_NODUMP 0x0000008000000000 #define ZFS_OPAQUE 0x0000010000000000 -#define ZFS_AV_QUARANTINED 0x0000020000000000 -#define ZFS_AV_MODIFIED 0x0000040000000000 +#define ZFS_AV_QUARANTINED 0x0000020000000000 +#define ZFS_AV_MODIFIED 0x0000040000000000 #define ZFS_REPARSE 0x0000080000000000 #define ZFS_OFFLINE 0x0000100000000000 #define ZFS_SPARSE 0x0000200000000000 @@ -78,8 +79,8 @@ extern "C" { */ #define ZFS_XATTR 0x1 /* is an extended attribute */ #define ZFS_INHERIT_ACE 0x2 /* ace has inheritable ACEs */ -#define ZFS_ACL_TRIVIAL 0x4 /* files ACL is trivial */ -#define ZFS_ACL_OBJ_ACE 0x8 /* ACL has CMPLX Object ACE */ +#define ZFS_ACL_TRIVIAL 0x4 /* files ACL is trivial */ +#define ZFS_ACL_OBJ_ACE 0x8 /* ACL has CMPLX Object ACE */ #define ZFS_ACL_PROTECTED 0x10 /* ACL protected */ #define ZFS_ACL_DEFAULTED 0x20 /* ACL should be defaulted */ #define ZFS_ACL_AUTO_INHERIT 0x40 /* ACL should be inherited */ @@ -177,8 +178,7 @@ typedef struct znode { krwlock_t z_name_lock; /* "master" lock for dirent locks */ zfs_dirlock_t *z_dirlocks; /* directory entry lock list */ #endif - kmutex_t z_range_lock; /* protects changes to z_range_avl */ - avl_tree_t z_range_avl; /* avl tree of file range locks */ + rangelock_t z_rangelock; /* file range locks */ uint8_t z_unlinked; /* file has been unlinked */ uint8_t z_atime_dirty; /* atime needs to be synced */ uint8_t z_zn_prefetch; /* Prefetch znodes? */ Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_rlock.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_rlock.c Wed Nov 6 08:33:56 2019 (r354374) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_rlock.c Wed Nov 6 08:36:12 2019 (r354375) @@ -23,7 +23,7 @@ * Use is subject to license terms. */ /* - * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright (c) 2012, 2018 by Delphix. All rights reserved. */ /* @@ -34,9 +34,9 @@ * Interface * --------- * Defined in zfs_rlock.h but essentially: - * rl = zfs_range_lock(zp, off, len, lock_type); - * zfs_range_unlock(rl); - * zfs_range_reduce(rl, off, len); + * lr = rangelock_enter(zp, off, len, lock_type); + * rangelock_reduce(lr, off, len); // optional + * rangelock_exit(lr); * * AVL tree * -------- @@ -46,9 +46,10 @@ * * Common case * ----------- - * The (hopefully) usual case is of no overlaps or contention for - * locks. On entry to zfs_lock_range() a rl_t is allocated; the tree - * searched that finds no overlap, and *this* rl_t is placed in the tree. + * The (hopefully) usual case is of no overlaps or contention for locks. On + * entry to rangelock_enter(), a locked_range_t is allocated; the tree + * searched that finds no overlap, and *this* locked_range_t is placed in the + * tree. * * Overlaps/Reference counting/Proxy locks * --------------------------------------- @@ -87,67 +88,90 @@ * * Grow block handling * ------------------- - * ZFS supports multiple block sizes currently upto 128K. The smallest + * ZFS supports multiple block sizes, up to 16MB. The smallest * block size is used for the file which is grown as needed. During this * growth all other writers and readers must be excluded. * So if the block size needs to be grown then the whole file is * exclusively locked, then later the caller will reduce the lock - * range to just the range to be written using zfs_reduce_range. + * range to just the range to be written using rangelock_reduce(). */ +#include +#include #include /* + * AVL comparison function used to order range locks + * Locks are ordered on the start offset of the range. + */ +static int +rangelock_compare(const void *arg1, const void *arg2) +{ + const locked_range_t *rl1 = arg1; + const locked_range_t *rl2 = arg2; + + if (rl1->lr_offset > rl2->lr_offset) + return (1); + if (rl1->lr_offset < rl2->lr_offset) + return (-1); + return (0); +} + +/* + * The callback is invoked when acquiring a RL_WRITER or RL_APPEND lock. + * It must convert RL_APPEND to RL_WRITER (starting at the end of the file), + * and may increase the range that's locked for RL_WRITER. + */ +void +rangelock_init(rangelock_t *rl, rangelock_cb_t *cb, void *arg) +{ + mutex_init(&rl->rl_lock, NULL, MUTEX_DEFAULT, NULL); + avl_create(&rl->rl_tree, rangelock_compare, + sizeof (locked_range_t), offsetof(locked_range_t, lr_node)); + rl->rl_cb = cb; + rl->rl_arg = arg; +} + +void +rangelock_fini(rangelock_t *rl) +{ + mutex_destroy(&rl->rl_lock); + avl_destroy(&rl->rl_tree); +} + +/* * Check if a write lock can be grabbed, or wait and recheck until available. */ static void -zfs_range_lock_writer(znode_t *zp, rl_t *new) +rangelock_enter_writer(rangelock_t *rl, locked_range_t *new) { - avl_tree_t *tree = &zp->z_range_avl; - rl_t *rl; + avl_tree_t *tree = &rl->rl_tree; + locked_range_t *lr; avl_index_t where; - uint64_t end_size; - uint64_t off = new->r_off; - uint64_t len = new->r_len; + uint64_t orig_off = new->lr_offset; + uint64_t orig_len = new->lr_length; + rangelock_type_t orig_type = new->lr_type; for (;;) { /* - * Range locking is also used by zvol and uses a - * dummied up znode. However, for zvol, we don't need to - * append or grow blocksize, and besides we don't have - * a "sa" data or z_zfsvfs - so skip that processing. - * - * Yes, this is ugly, and would be solved by not handling - * grow or append in range lock code. If that was done then - * we could make the range locking code generically available - * to other non-zfs consumers. + * Call callback which can modify new->r_off,len,type. + * Note, the callback is used by the ZPL to handle appending + * and changing blocksizes. It isn't needed for zvols. */ - if (zp->z_vnode) { /* caller is ZPL */ - /* - * If in append mode pick up the current end of file. - * This is done under z_range_lock to avoid races. - */ - if (new->r_type == RL_APPEND) - new->r_off = zp->z_size; - - /* - * If we need to grow the block size then grab the whole - * file range. This is also done under z_range_lock to - * avoid races. - */ - end_size = MAX(zp->z_size, new->r_off + len); - if (end_size > zp->z_blksz && (!ISP2(zp->z_blksz) || - zp->z_blksz < zp->z_zfsvfs->z_max_blksz)) { - new->r_off = 0; - new->r_len = UINT64_MAX; - } + if (rl->rl_cb != NULL) { + rl->rl_cb(new, rl->rl_arg); } /* + * If the type was APPEND, the callback must convert it to + * WRITER. + */ + ASSERT3U(new->lr_type, ==, RL_WRITER); + + /* * First check for the usual case of no locks */ if (avl_numnodes(tree) == 0) { - new->r_type = RL_WRITER; /* convert to writer */ avl_add(tree, new); return; } @@ -155,31 +179,33 @@ zfs_range_lock_writer(znode_t *zp, rl_t *new) /* * Look for any locks in the range. */ - rl = avl_find(tree, new, &where); - if (rl) + lr = avl_find(tree, new, &where); + if (lr != NULL) goto wait; /* already locked at same offset */ - rl = (rl_t *)avl_nearest(tree, where, AVL_AFTER); - if (rl && (rl->r_off < new->r_off + new->r_len)) + lr = (locked_range_t *)avl_nearest(tree, where, AVL_AFTER); + if (lr != NULL && + lr->lr_offset < new->lr_offset + new->lr_length) goto wait; - rl = (rl_t *)avl_nearest(tree, where, AVL_BEFORE); - if (rl && rl->r_off + rl->r_len > new->r_off) + lr = (locked_range_t *)avl_nearest(tree, where, AVL_BEFORE); + if (lr != NULL && + lr->lr_offset + lr->lr_length > new->lr_offset) goto wait; - new->r_type = RL_WRITER; /* convert possible RL_APPEND */ avl_insert(tree, new, where); return; wait: - if (!rl->r_write_wanted) { - cv_init(&rl->r_wr_cv, NULL, CV_DEFAULT, NULL); - rl->r_write_wanted = B_TRUE; + if (!lr->lr_write_wanted) { + cv_init(&lr->lr_write_cv, NULL, CV_DEFAULT, NULL); + lr->lr_write_wanted = B_TRUE; } - cv_wait(&rl->r_wr_cv, &zp->z_range_lock); + cv_wait(&lr->lr_write_cv, &rl->rl_lock); /* reset to original */ - new->r_off = off; - new->r_len = len; + new->lr_offset = orig_off; + new->lr_length = orig_len; + new->lr_type = orig_type; } } @@ -187,29 +213,29 @@ wait: * If this is an original (non-proxy) lock then replace it by * a proxy and return the proxy. */ -static rl_t * -zfs_range_proxify(avl_tree_t *tree, rl_t *rl) +static locked_range_t * +rangelock_proxify(avl_tree_t *tree, locked_range_t *lr) { - rl_t *proxy; + locked_range_t *proxy; - if (rl->r_proxy) - return (rl); /* already a proxy */ + if (lr->lr_proxy) + return (lr); /* already a proxy */ - ASSERT3U(rl->r_cnt, ==, 1); - ASSERT(rl->r_write_wanted == B_FALSE); - ASSERT(rl->r_read_wanted == B_FALSE); - avl_remove(tree, rl); - rl->r_cnt = 0; + ASSERT3U(lr->lr_count, ==, 1); + ASSERT(lr->lr_write_wanted == B_FALSE); + ASSERT(lr->lr_read_wanted == B_FALSE); + avl_remove(tree, lr); + lr->lr_count = 0; /* create a proxy range lock */ - proxy = kmem_alloc(sizeof (rl_t), KM_SLEEP); - proxy->r_off = rl->r_off; - proxy->r_len = rl->r_len; - proxy->r_cnt = 1; - proxy->r_type = RL_READER; - proxy->r_proxy = B_TRUE; - proxy->r_write_wanted = B_FALSE; - proxy->r_read_wanted = B_FALSE; + proxy = kmem_alloc(sizeof (locked_range_t), KM_SLEEP); + proxy->lr_offset = lr->lr_offset; + proxy->lr_length = lr->lr_length; + proxy->lr_count = 1; + proxy->lr_type = RL_READER; + proxy->lr_proxy = B_TRUE; + proxy->lr_write_wanted = B_FALSE; + proxy->lr_read_wanted = B_FALSE; avl_add(tree, proxy); return (proxy); @@ -219,29 +245,27 @@ zfs_range_proxify(avl_tree_t *tree, rl_t *rl) * Split the range lock at the supplied offset * returning the *front* proxy. */ -static rl_t * -zfs_range_split(avl_tree_t *tree, rl_t *rl, uint64_t off) +static locked_range_t * +rangelock_split(avl_tree_t *tree, locked_range_t *lr, uint64_t off) { - rl_t *front, *rear; + ASSERT3U(lr->lr_length, >, 1); + ASSERT3U(off, >, lr->lr_offset); + ASSERT3U(off, <, lr->lr_offset + lr->lr_length); + ASSERT(lr->lr_write_wanted == B_FALSE); + ASSERT(lr->lr_read_wanted == B_FALSE); - ASSERT3U(rl->r_len, >, 1); - ASSERT3U(off, >, rl->r_off); - ASSERT3U(off, <, rl->r_off + rl->r_len); - ASSERT(rl->r_write_wanted == B_FALSE); - ASSERT(rl->r_read_wanted == B_FALSE); - /* create the rear proxy range lock */ - rear = kmem_alloc(sizeof (rl_t), KM_SLEEP); - rear->r_off = off; - rear->r_len = rl->r_off + rl->r_len - off; - rear->r_cnt = rl->r_cnt; - rear->r_type = RL_READER; - rear->r_proxy = B_TRUE; - rear->r_write_wanted = B_FALSE; - rear->r_read_wanted = B_FALSE; + locked_range_t *rear = kmem_alloc(sizeof (locked_range_t), KM_SLEEP); + rear->lr_offset = off; + rear->lr_length = lr->lr_offset + lr->lr_length - off; + rear->lr_count = lr->lr_count; + rear->lr_type = RL_READER; + rear->lr_proxy = B_TRUE; + rear->lr_write_wanted = B_FALSE; + rear->lr_read_wanted = B_FALSE; - front = zfs_range_proxify(tree, rl); - front->r_len = off - rl->r_off; + locked_range_t *front = rangelock_proxify(tree, lr); + front->lr_length = off - lr->lr_offset; avl_insert_here(tree, rear, front, AVL_AFTER); return (front); @@ -251,28 +275,27 @@ zfs_range_split(avl_tree_t *tree, rl_t *rl, uint64_t o * Create and add a new proxy range lock for the supplied range. */ static void -zfs_range_new_proxy(avl_tree_t *tree, uint64_t off, uint64_t len) +rangelock_new_proxy(avl_tree_t *tree, uint64_t off, uint64_t len) { - rl_t *rl; - - ASSERT(len); - rl = kmem_alloc(sizeof (rl_t), KM_SLEEP); - rl->r_off = off; - rl->r_len = len; - rl->r_cnt = 1; - rl->r_type = RL_READER; - rl->r_proxy = B_TRUE; - rl->r_write_wanted = B_FALSE; - rl->r_read_wanted = B_FALSE; - avl_add(tree, rl); + ASSERT(len != 0); + locked_range_t *lr = kmem_alloc(sizeof (locked_range_t), KM_SLEEP); + lr->lr_offset = off; + lr->lr_length = len; + lr->lr_count = 1; + lr->lr_type = RL_READER; + lr->lr_proxy = B_TRUE; + lr->lr_write_wanted = B_FALSE; + lr->lr_read_wanted = B_FALSE; + avl_add(tree, lr); } static void -zfs_range_add_reader(avl_tree_t *tree, rl_t *new, rl_t *prev, avl_index_t where) +rangelock_add_reader(avl_tree_t *tree, locked_range_t *new, + locked_range_t *prev, avl_index_t where) { - rl_t *next; - uint64_t off = new->r_off; - uint64_t len = new->r_len; + locked_range_t *next; + uint64_t off = new->lr_offset; + uint64_t len = new->lr_length; /* * prev arrives either: @@ -281,37 +304,37 @@ zfs_range_add_reader(avl_tree_t *tree, rl_t *new, rl_t * range may overlap with the new range * - null, if there were no ranges starting before the new one */ - if (prev) { - if (prev->r_off + prev->r_len <= off) { + if (prev != NULL) { + if (prev->lr_offset + prev->lr_length <= off) { prev = NULL; - } else if (prev->r_off != off) { + } else if (prev->lr_offset != off) { /* * convert to proxy if needed then * split this entry and bump ref count */ - prev = zfs_range_split(tree, prev, off); + prev = rangelock_split(tree, prev, off); prev = AVL_NEXT(tree, prev); /* move to rear range */ } } - ASSERT((prev == NULL) || (prev->r_off == off)); + ASSERT((prev == NULL) || (prev->lr_offset == off)); - if (prev) + if (prev != NULL) next = prev; else - next = (rl_t *)avl_nearest(tree, where, AVL_AFTER); + next = avl_nearest(tree, where, AVL_AFTER); - if (next == NULL || off + len <= next->r_off) { + if (next == NULL || off + len <= next->lr_offset) { /* no overlaps, use the original new rl_t in the tree */ avl_insert(tree, new, where); return; } - if (off < next->r_off) { + if (off < next->lr_offset) { /* Add a proxy for initial range before the overlap */ - zfs_range_new_proxy(tree, off, next->r_off - off); + rangelock_new_proxy(tree, off, next->lr_offset - off); } - new->r_cnt = 0; /* will use proxies in tree */ + new->lr_count = 0; /* will use proxies in tree */ /* * We now search forward through the ranges, until we go past the end * of the new range. For each entry we make it a proxy if it @@ -319,47 +342,51 @@ zfs_range_add_reader(avl_tree_t *tree, rl_t *new, rl_t * gaps between the ranges then we create a new proxy range. */ for (prev = NULL; next; prev = next, next = AVL_NEXT(tree, next)) { - if (off + len <= next->r_off) + if (off + len <= next->lr_offset) break; - if (prev && prev->r_off + prev->r_len < next->r_off) { + if (prev != NULL && prev->lr_offset + prev->lr_length < + next->lr_offset) { /* there's a gap */ - ASSERT3U(next->r_off, >, prev->r_off + prev->r_len); - zfs_range_new_proxy(tree, prev->r_off + prev->r_len, - next->r_off - (prev->r_off + prev->r_len)); + ASSERT3U(next->lr_offset, >, + prev->lr_offset + prev->lr_length); + rangelock_new_proxy(tree, + prev->lr_offset + prev->lr_length, + next->lr_offset - + (prev->lr_offset + prev->lr_length)); } - if (off + len == next->r_off + next->r_len) { + if (off + len == next->lr_offset + next->lr_length) { /* exact overlap with end */ - next = zfs_range_proxify(tree, next); - next->r_cnt++; + next = rangelock_proxify(tree, next); + next->lr_count++; return; } - if (off + len < next->r_off + next->r_len) { + if (off + len < next->lr_offset + next->lr_length) { /* new range ends in the middle of this block */ - next = zfs_range_split(tree, next, off + len); - next->r_cnt++; + next = rangelock_split(tree, next, off + len); + next->lr_count++; return; } - ASSERT3U(off + len, >, next->r_off + next->r_len); - next = zfs_range_proxify(tree, next); - next->r_cnt++; + ASSERT3U(off + len, >, next->lr_offset + next->lr_length); + next = rangelock_proxify(tree, next); + next->lr_count++; } /* Add the remaining end range. */ - zfs_range_new_proxy(tree, prev->r_off + prev->r_len, - (off + len) - (prev->r_off + prev->r_len)); + rangelock_new_proxy(tree, prev->lr_offset + prev->lr_length, + (off + len) - (prev->lr_offset + prev->lr_length)); } /* * Check if a reader lock can be grabbed, or wait and recheck until available. */ static void -zfs_range_lock_reader(znode_t *zp, rl_t *new) +rangelock_enter_reader(rangelock_t *rl, locked_range_t *new) { - avl_tree_t *tree = &zp->z_range_avl; - rl_t *prev, *next; + avl_tree_t *tree = &rl->rl_tree; + locked_range_t *prev, *next; avl_index_t where; - uint64_t off = new->r_off; - uint64_t len = new->r_len; + uint64_t off = new->lr_offset; + uint64_t len = new->lr_length; /* * Look for any writer locks in the range. @@ -367,21 +394,22 @@ zfs_range_lock_reader(znode_t *zp, rl_t *new) retry: prev = avl_find(tree, new, &where); if (prev == NULL) - prev = (rl_t *)avl_nearest(tree, where, AVL_BEFORE); + prev = (locked_range_t *)avl_nearest(tree, where, AVL_BEFORE); /* * Check the previous range for a writer lock overlap. */ - if (prev && (off < prev->r_off + prev->r_len)) { - if ((prev->r_type == RL_WRITER) || (prev->r_write_wanted)) { - if (!prev->r_read_wanted) { - cv_init(&prev->r_rd_cv, NULL, CV_DEFAULT, NULL); - prev->r_read_wanted = B_TRUE; + if (prev && (off < prev->lr_offset + prev->lr_length)) { + if ((prev->lr_type == RL_WRITER) || (prev->lr_write_wanted)) { + if (!prev->lr_read_wanted) { + cv_init(&prev->lr_read_cv, + NULL, CV_DEFAULT, NULL); + prev->lr_read_wanted = B_TRUE; } - cv_wait(&prev->r_rd_cv, &zp->z_range_lock); + cv_wait(&prev->lr_read_cv, &rl->rl_lock); goto retry; } - if (off + len < prev->r_off + prev->r_len) + if (off + len < prev->lr_offset + prev->lr_length) goto got_lock; } @@ -389,70 +417,71 @@ retry: * Search through the following ranges to see if there's * write lock any overlap. */ - if (prev) + if (prev != NULL) next = AVL_NEXT(tree, prev); else - next = (rl_t *)avl_nearest(tree, where, AVL_AFTER); - for (; next; next = AVL_NEXT(tree, next)) { - if (off + len <= next->r_off) + next = (locked_range_t *)avl_nearest(tree, where, AVL_AFTER); + for (; next != NULL; next = AVL_NEXT(tree, next)) { + if (off + len <= next->lr_offset) goto got_lock; - if ((next->r_type == RL_WRITER) || (next->r_write_wanted)) { - if (!next->r_read_wanted) { - cv_init(&next->r_rd_cv, NULL, CV_DEFAULT, NULL); - next->r_read_wanted = B_TRUE; + if ((next->lr_type == RL_WRITER) || (next->lr_write_wanted)) { + if (!next->lr_read_wanted) { + cv_init(&next->lr_read_cv, + NULL, CV_DEFAULT, NULL); + next->lr_read_wanted = B_TRUE; } - cv_wait(&next->r_rd_cv, &zp->z_range_lock); + cv_wait(&next->lr_read_cv, &rl->rl_lock); goto retry; } - if (off + len <= next->r_off + next->r_len) + if (off + len <= next->lr_offset + next->lr_length) goto got_lock; } got_lock: /* * Add the read lock, which may involve splitting existing - * locks and bumping ref counts (r_cnt). + * locks and bumping ref counts (r_count). */ - zfs_range_add_reader(tree, new, prev, where); + rangelock_add_reader(tree, new, prev, where); } /* - * Lock a range (offset, length) as either shared (RL_READER) - * or exclusive (RL_WRITER). Returns the range lock structure - * for later unlocking or reduce range (if entire file - * previously locked as RL_WRITER). + * Lock a range (offset, length) as either shared (RL_READER) or exclusive + * (RL_WRITER or RL_APPEND). If RL_APPEND is specified, rl_cb() will convert + * it to a RL_WRITER lock (with the offset at the end of the file). Returns + * the range lock structure for later unlocking (or reduce range if the + * entire file is locked as RL_WRITER). */ -rl_t * -zfs_range_lock(znode_t *zp, uint64_t off, uint64_t len, rl_type_t type) +locked_range_t * +rangelock_enter(rangelock_t *rl, uint64_t off, uint64_t len, + rangelock_type_t type) { - rl_t *new; - ASSERT(type == RL_READER || type == RL_WRITER || type == RL_APPEND); - new = kmem_alloc(sizeof (rl_t), KM_SLEEP); - new->r_zp = zp; - new->r_off = off; + locked_range_t *new = kmem_alloc(sizeof (locked_range_t), KM_SLEEP); + new->lr_rangelock = rl; + new->lr_offset = off; if (len + off < off) /* overflow */ len = UINT64_MAX - off; - new->r_len = len; - new->r_cnt = 1; /* assume it's going to be in the tree */ - new->r_type = type; - new->r_proxy = B_FALSE; - new->r_write_wanted = B_FALSE; - new->r_read_wanted = B_FALSE; + new->lr_length = len; + new->lr_count = 1; /* assume it's going to be in the tree */ + new->lr_type = type; + new->lr_proxy = B_FALSE; + new->lr_write_wanted = B_FALSE; + new->lr_read_wanted = B_FALSE; - mutex_enter(&zp->z_range_lock); + mutex_enter(&rl->rl_lock); if (type == RL_READER) { /* * First check for the usual case of no locks */ - if (avl_numnodes(&zp->z_range_avl) == 0) - avl_add(&zp->z_range_avl, new); + if (avl_numnodes(&rl->rl_tree) == 0) + avl_add(&rl->rl_tree, new); else - zfs_range_lock_reader(zp, new); + rangelock_enter_reader(rl, new); } else - zfs_range_lock_writer(zp, new); /* RL_WRITER or RL_APPEND */ - mutex_exit(&zp->z_range_lock); + rangelock_enter_writer(rl, new); /* RL_WRITER or RL_APPEND */ + mutex_exit(&rl->rl_lock); return (new); } @@ -460,10 +489,9 @@ zfs_range_lock(znode_t *zp, uint64_t off, uint64_t len * Unlock a reader lock */ static void -zfs_range_unlock_reader(znode_t *zp, rl_t *remove) +rangelock_exit_reader(rangelock_t *rl, locked_range_t *remove) { - avl_tree_t *tree = &zp->z_range_avl; - rl_t *rl, *next = NULL; + avl_tree_t *tree = &rl->rl_tree; uint64_t len; /* @@ -473,129 +501,118 @@ zfs_range_unlock_reader(znode_t *zp, rl_t *remove) * removed from the tree and replaced by proxies (one or * more ranges mapping to the entire range). */ - if (remove->r_cnt == 1) { + if (remove->lr_count == 1) { avl_remove(tree, remove); - if (remove->r_write_wanted) { - cv_broadcast(&remove->r_wr_cv); - cv_destroy(&remove->r_wr_cv); + if (remove->lr_write_wanted) { + cv_broadcast(&remove->lr_write_cv); + cv_destroy(&remove->lr_write_cv); } - if (remove->r_read_wanted) { - cv_broadcast(&remove->r_rd_cv); - cv_destroy(&remove->r_rd_cv); + if (remove->lr_read_wanted) { + cv_broadcast(&remove->lr_read_cv); + cv_destroy(&remove->lr_read_cv); } } else { - ASSERT0(remove->r_cnt); - ASSERT0(remove->r_write_wanted); - ASSERT0(remove->r_read_wanted); + ASSERT0(remove->lr_count); + ASSERT0(remove->lr_write_wanted); + ASSERT0(remove->lr_read_wanted); /* * Find start proxy representing this reader lock, * then decrement ref count on all proxies * that make up this range, freeing them as needed. */ - rl = avl_find(tree, remove, NULL); - ASSERT(rl); - ASSERT(rl->r_cnt); - ASSERT(rl->r_type == RL_READER); - for (len = remove->r_len; len != 0; rl = next) { - len -= rl->r_len; - if (len) { - next = AVL_NEXT(tree, rl); - ASSERT(next); - ASSERT(rl->r_off + rl->r_len == next->r_off); - ASSERT(next->r_cnt); - ASSERT(next->r_type == RL_READER); + locked_range_t *lr = avl_find(tree, remove, NULL); + ASSERT3P(lr, !=, NULL); + ASSERT3U(lr->lr_count, !=, 0); + ASSERT3U(lr->lr_type, ==, RL_READER); + locked_range_t *next = NULL; + for (len = remove->lr_length; len != 0; lr = next) { + len -= lr->lr_length; + if (len != 0) { + next = AVL_NEXT(tree, lr); + ASSERT3P(next, !=, NULL); + ASSERT3U(lr->lr_offset + lr->lr_length, ==, + next->lr_offset); + ASSERT3U(next->lr_count, !=, 0); + ASSERT3U(next->lr_type, ==, RL_READER); } - rl->r_cnt--; - if (rl->r_cnt == 0) { - avl_remove(tree, rl); - if (rl->r_write_wanted) { - cv_broadcast(&rl->r_wr_cv); - cv_destroy(&rl->r_wr_cv); + lr->lr_count--; + if (lr->lr_count == 0) { + avl_remove(tree, lr); + if (lr->lr_write_wanted) { + cv_broadcast(&lr->lr_write_cv); + cv_destroy(&lr->lr_write_cv); } - if (rl->r_read_wanted) { - cv_broadcast(&rl->r_rd_cv); - cv_destroy(&rl->r_rd_cv); + if (lr->lr_read_wanted) { + cv_broadcast(&lr->lr_read_cv); + cv_destroy(&lr->lr_read_cv); } - kmem_free(rl, sizeof (rl_t)); + kmem_free(lr, sizeof (locked_range_t)); } } } - kmem_free(remove, sizeof (rl_t)); + kmem_free(remove, sizeof (locked_range_t)); } /* * Unlock range and destroy range lock structure. */ void -zfs_range_unlock(rl_t *rl) +rangelock_exit(locked_range_t *lr) { - znode_t *zp = rl->r_zp; + rangelock_t *rl = lr->lr_rangelock; - ASSERT(rl->r_type == RL_WRITER || rl->r_type == RL_READER); - ASSERT(rl->r_cnt == 1 || rl->r_cnt == 0); - ASSERT(!rl->r_proxy); + ASSERT(lr->lr_type == RL_WRITER || lr->lr_type == RL_READER); + ASSERT(lr->lr_count == 1 || lr->lr_count == 0); + ASSERT(!lr->lr_proxy); - mutex_enter(&zp->z_range_lock); - if (rl->r_type == RL_WRITER) { + mutex_enter(&rl->rl_lock); + if (lr->lr_type == RL_WRITER) { /* writer locks can't be shared or split */ - avl_remove(&zp->z_range_avl, rl); - mutex_exit(&zp->z_range_lock); - if (rl->r_write_wanted) { - cv_broadcast(&rl->r_wr_cv); - cv_destroy(&rl->r_wr_cv); + avl_remove(&rl->rl_tree, lr); + mutex_exit(&rl->rl_lock); + if (lr->lr_write_wanted) { + cv_broadcast(&lr->lr_write_cv); + cv_destroy(&lr->lr_write_cv); } - if (rl->r_read_wanted) { - cv_broadcast(&rl->r_rd_cv); - cv_destroy(&rl->r_rd_cv); + if (lr->lr_read_wanted) { + cv_broadcast(&lr->lr_read_cv); + cv_destroy(&lr->lr_read_cv); } - kmem_free(rl, sizeof (rl_t)); + kmem_free(lr, sizeof (locked_range_t)); } else { /* - * lock may be shared, let zfs_range_unlock_reader() + * lock may be shared, let rangelock_exit_reader() * release the lock and free the rl_t */ - zfs_range_unlock_reader(zp, rl); - mutex_exit(&zp->z_range_lock); + rangelock_exit_reader(rl, lr); + mutex_exit(&rl->rl_lock); } } /* * Reduce range locked as RL_WRITER from whole file to specified range. - * Asserts the whole file is exclusivly locked and so there's only one + * Asserts the whole file is exclusively locked and so there's only one * entry in the tree. */ void *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Wed Nov 6 08:37:57 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2BB961AE4D0; Wed, 6 Nov 2019 08:37:57 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 477Kfs18Mfz3HBR; Wed, 6 Nov 2019 08:37:57 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0B0F02263C; Wed, 6 Nov 2019 08:37:57 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA68bvLO034803; Wed, 6 Nov 2019 08:37:57 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA68btcT034796; Wed, 6 Nov 2019 08:37:55 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911060837.xA68btcT034796@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 6 Nov 2019 08:37:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354376 - in stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys X-SVN-Commit-Revision: 354376 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.29 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, 06 Nov 2019 08:37:57 -0000 Author: avg Date: Wed Nov 6 08:37:55 2019 New Revision: 354376 URL: https://svnweb.freebsd.org/changeset/base/354376 Log: MFC r353638: MFV r353637: 10844 Serialize ZTHR operations to eliminate races Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_checkpoint.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_checkpoint.h stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zthr.h stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_indirect.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zthr.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Wed Nov 6 08:36:12 2019 (r354375) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Wed Nov 6 08:37:55 2019 (r354376) @@ -4896,7 +4896,7 @@ arc_adjust_cb_check(void *arg, zthr_t *zthr) * Keep arc_size under arc_c by running arc_adjust which evicts data * from the ARC. */ /* ARGSUSED */ -static int +static void arc_adjust_cb(void *arg, zthr_t *zthr) { uint64_t evicted = 0; @@ -4927,8 +4927,6 @@ arc_adjust_cb(void *arg, zthr_t *zthr) cv_broadcast(&arc_adjust_waiters_cv); } mutex_exit(&arc_adjust_lock); - - return (0); } /* ARGSUSED */ @@ -4970,7 +4968,7 @@ arc_reap_cb_check(void *arg, zthr_t *zthr) * to free more buffers. */ /* ARGSUSED */ -static int +static void arc_reap_cb(void *arg, zthr_t *zthr) { int64_t free_memory; @@ -5011,8 +5009,6 @@ arc_reap_cb(void *arg, zthr_t *zthr) #endif arc_reduce_target_size(to_free); } - - return (0); } static u_int arc_dnlc_evicts_arg; Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Wed Nov 6 08:36:12 2019 (r354375) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Wed Nov 6 08:37:55 2019 (r354376) @@ -1438,13 +1438,11 @@ spa_unload(spa_t *spa) } if (spa->spa_condense_zthr != NULL) { - ASSERT(!zthr_isrunning(spa->spa_condense_zthr)); zthr_destroy(spa->spa_condense_zthr); spa->spa_condense_zthr = NULL; } if (spa->spa_checkpoint_discard_zthr != NULL) { - ASSERT(!zthr_isrunning(spa->spa_checkpoint_discard_zthr)); zthr_destroy(spa->spa_checkpoint_discard_zthr); spa->spa_checkpoint_discard_zthr = NULL; } @@ -7310,12 +7308,12 @@ spa_async_suspend(spa_t *spa) spa_vdev_remove_suspend(spa); zthr_t *condense_thread = spa->spa_condense_zthr; - if (condense_thread != NULL && zthr_isrunning(condense_thread)) - VERIFY0(zthr_cancel(condense_thread)); + if (condense_thread != NULL) + zthr_cancel(condense_thread); zthr_t *discard_thread = spa->spa_checkpoint_discard_zthr; - if (discard_thread != NULL && zthr_isrunning(discard_thread)) - VERIFY0(zthr_cancel(discard_thread)); + if (discard_thread != NULL) + zthr_cancel(discard_thread); } void @@ -7328,11 +7326,11 @@ spa_async_resume(spa_t *spa) spa_restart_removal(spa); zthr_t *condense_thread = spa->spa_condense_zthr; - if (condense_thread != NULL && !zthr_isrunning(condense_thread)) + if (condense_thread != NULL) zthr_resume(condense_thread); zthr_t *discard_thread = spa->spa_checkpoint_discard_zthr; - if (discard_thread != NULL && !zthr_isrunning(discard_thread)) + if (discard_thread != NULL) zthr_resume(discard_thread); } Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_checkpoint.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_checkpoint.c Wed Nov 6 08:36:12 2019 (r354375) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_checkpoint.c Wed Nov 6 08:37:55 2019 (r354376) @@ -391,7 +391,7 @@ spa_checkpoint_discard_thread_check(void *arg, zthr_t return (B_TRUE); } -int +void spa_checkpoint_discard_thread(void *arg, zthr_t *zthr) { spa_t *spa = arg; @@ -406,7 +406,7 @@ spa_checkpoint_discard_thread(void *arg, zthr_t *zthr) dmu_buf_t **dbp; if (zthr_iscancelled(zthr)) - return (0); + return; ASSERT3P(vd->vdev_ops, !=, &vdev_indirect_ops); @@ -443,8 +443,6 @@ spa_checkpoint_discard_thread(void *arg, zthr_t *zthr) VERIFY0(dsl_sync_task(spa->spa_name, NULL, spa_checkpoint_discard_complete_sync, spa, 0, ZFS_SPACE_CHECK_NONE)); - - return (0); } Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_checkpoint.h ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_checkpoint.h Wed Nov 6 08:36:12 2019 (r354375) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_checkpoint.h Wed Nov 6 08:37:55 2019 (r354376) @@ -37,7 +37,7 @@ int spa_checkpoint(const char *); int spa_checkpoint_discard(const char *); boolean_t spa_checkpoint_discard_thread_check(void *, zthr_t *); -int spa_checkpoint_discard_thread(void *, zthr_t *); +void spa_checkpoint_discard_thread(void *, zthr_t *); int spa_checkpoint_get_stats(spa_t *, pool_checkpoint_stat_t *); Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zthr.h ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zthr.h Wed Nov 6 08:36:12 2019 (r354375) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zthr.h Wed Nov 6 08:37:55 2019 (r354376) @@ -14,42 +14,26 @@ */ /* - * Copyright (c) 2017 by Delphix. All rights reserved. + * Copyright (c) 2017, 2018 by Delphix. All rights reserved. */ #ifndef _SYS_ZTHR_H #define _SYS_ZTHR_H typedef struct zthr zthr_t; -typedef int (zthr_func_t)(void *, zthr_t *); +typedef void (zthr_func_t)(void *, zthr_t *); typedef boolean_t (zthr_checkfunc_t)(void *, zthr_t *); -struct zthr { - kthread_t *zthr_thread; - kmutex_t zthr_lock; - kcondvar_t zthr_cv; - boolean_t zthr_cancel; - hrtime_t zthr_wait_time; - - zthr_checkfunc_t *zthr_checkfunc; - zthr_func_t *zthr_func; - void *zthr_arg; - int zthr_rc; -}; - extern zthr_t *zthr_create(zthr_checkfunc_t checkfunc, zthr_func_t *func, void *arg); extern zthr_t *zthr_create_timer(zthr_checkfunc_t *checkfunc, zthr_func_t *func, void *arg, hrtime_t nano_wait); - -extern void zthr_exit(zthr_t *t, int rc); extern void zthr_destroy(zthr_t *t); extern void zthr_wakeup(zthr_t *t); -extern int zthr_cancel(zthr_t *t); +extern void zthr_cancel(zthr_t *t); extern void zthr_resume(zthr_t *t); extern boolean_t zthr_iscancelled(zthr_t *t); -extern boolean_t zthr_isrunning(zthr_t *t); #endif /* _SYS_ZTHR_H */ Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_indirect.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_indirect.c Wed Nov 6 08:36:12 2019 (r354375) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_indirect.c Wed Nov 6 08:37:55 2019 (r354376) @@ -642,7 +642,7 @@ spa_condense_indirect_thread_check(void *arg, zthr_t * } /* ARGSUSED */ -static int +static void spa_condense_indirect_thread(void *arg, zthr_t *zthr) { spa_t *spa = arg; @@ -739,13 +739,11 @@ spa_condense_indirect_thread(void *arg, zthr_t *zthr) * shutting down. */ if (zthr_iscancelled(zthr)) - return (0); + return; VERIFY0(dsl_sync_task(spa_name(spa), NULL, spa_condense_indirect_complete_sync, sci, 0, ZFS_SPACE_CHECK_EXTRA_RESERVED)); - - return (0); } /* Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zthr.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zthr.c Wed Nov 6 08:36:12 2019 (r354375) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zthr.c Wed Nov 6 08:37:55 2019 (r354376) @@ -14,7 +14,7 @@ */ /* - * Copyright (c) 2017 by Delphix. All rights reserved. + * Copyright (c) 2017, 2019 by Delphix. All rights reserved. */ /* @@ -28,7 +28,7 @@ * * 1] The operation needs to run over multiple txgs. * 2] There is be a single point of reference in memory or on disk that - * indicates whether the operation should run/is running or is + * indicates whether the operation should run/is running or has * stopped. * * If the operation satisfies the above then the following rules guarantee @@ -51,6 +51,9 @@ * during creation to wakeup on it's own after a specified interval * [see zthr_create_timer()]. * + * Note: ZTHR threads are NOT a replacement for generic threads! Please + * ensure that they fit your use-case well before using them. + * * == ZTHR creation * * Every zthr needs three inputs to start running: @@ -64,17 +67,17 @@ * 2] A user-defined ZTHR function (func) which the zthr executes when * it is not sleeping. The function should adhere to the following * signature type: - * int func_name(void *args, zthr_t *t); + * void func_name(void *args, zthr_t *t); * * 3] A void args pointer that will be passed to checkfunc and func * implicitly by the infrastructure. * * The reason why the above API needs two different functions, * instead of one that both checks and does the work, has to do with - * the zthr's internal lock (zthr_lock) and the allowed cancellation - * windows. We want to hold the zthr_lock while running checkfunc - * but not while running func. This way the zthr can be cancelled - * while doing work and not while checking for work. + * the zthr's internal state lock (zthr_state_lock) and the allowed + * cancellation windows. We want to hold the zthr_state_lock while + * running checkfunc but not while running func. This way the zthr + * can be cancelled while doing work and not while checking for work. * * To start a zthr: * zthr_t *zthr_pointer = zthr_create(checkfunc, func, args); @@ -83,7 +86,7 @@ * args, max_sleep); * * After that you should be able to wakeup, cancel, and resume the - * zthr from another thread using zthr_pointer. + * zthr from another thread using the zthr_pointer. * * NOTE: ZTHR threads could potentially wake up spuriously and the * user should take this into account when writing a checkfunc. @@ -102,8 +105,8 @@ * zthr_resume(zthr_pointer); * * A zthr will implicitly check if it has received a cancellation - * signal every time func returns and everytime it wakes up [see ZTHR - * state transitions below]. + * signal every time func returns and every time it wakes up [see + * ZTHR state transitions below]. * * At times, waiting for the zthr's func to finish its job may take * time. This may be very time-consuming for some operations that @@ -119,17 +122,8 @@ * while (!work_done && !zthr_iscancelled(t)) { * ... ... * } - * return (0); * } * - * == ZTHR exit - * - * For the rare cases where the zthr wants to stop running voluntarily - * while running its ZTHR function (func), we provide zthr_exit(). - * When a zthr has voluntarily stopped running, it can be resumed with - * zthr_resume(), just like it would if it was cancelled by some other - * thread. - * * == ZTHR cleanup * * Cancelling a zthr doesn't clean up its metadata (internal locks, @@ -165,49 +159,86 @@ * v * zthr stopped running * + * == Implementation of ZTHR requests + * + * ZTHR wakeup, cancel, and resume are requests on a zthr to + * change its internal state. Requests on a zthr are serialized + * using the zthr_request_lock, while changes in its internal + * state are protected by the zthr_state_lock. A request will + * first acquire the zthr_request_lock and then immediately + * acquire the zthr_state_lock. We do this so that incoming + * requests are serialized using the request lock, while still + * allowing us to use the state lock for thread communication + * via zthr_cv. */ #include #include -void -zthr_exit(zthr_t *t, int rc) -{ - ASSERT3P(t->zthr_thread, ==, curthread); - mutex_enter(&t->zthr_lock); - t->zthr_thread = NULL; - t->zthr_rc = rc; - cv_broadcast(&t->zthr_cv); - mutex_exit(&t->zthr_lock); - thread_exit(); -} +struct zthr { + /* running thread doing the work */ + kthread_t *zthr_thread; + /* lock protecting internal data & invariants */ + kmutex_t zthr_state_lock; + + /* mutex that serializes external requests */ + kmutex_t zthr_request_lock; + + /* notification mechanism for requests */ + kcondvar_t zthr_cv; + + /* flag set to true if we are canceling the zthr */ + boolean_t zthr_cancel; + + /* + * maximum amount of time that the zthr is spent sleeping; + * if this is 0, the thread doesn't wake up until it gets + * signaled. + */ + hrtime_t zthr_wait_time; + + /* consumer-provided callbacks & data */ + zthr_checkfunc_t *zthr_checkfunc; + zthr_func_t *zthr_func; + void *zthr_arg; +}; + static void zthr_procedure(void *arg) { zthr_t *t = arg; - int rc = 0; - mutex_enter(&t->zthr_lock); + mutex_enter(&t->zthr_state_lock); + ASSERT3P(t->zthr_thread, ==, curthread); + while (!t->zthr_cancel) { if (t->zthr_checkfunc(t->zthr_arg, t)) { - mutex_exit(&t->zthr_lock); - rc = t->zthr_func(t->zthr_arg, t); - mutex_enter(&t->zthr_lock); + mutex_exit(&t->zthr_state_lock); + t->zthr_func(t->zthr_arg, t); + mutex_enter(&t->zthr_state_lock); } else { /* go to sleep */ if (t->zthr_wait_time == 0) { - cv_wait(&t->zthr_cv, &t->zthr_lock); + cv_wait(&t->zthr_cv, &t->zthr_state_lock); } else { (void) cv_timedwait_hires(&t->zthr_cv, - &t->zthr_lock, t->zthr_wait_time, + &t->zthr_state_lock, t->zthr_wait_time, MSEC2NSEC(1), 0); } } } - mutex_exit(&t->zthr_lock); - zthr_exit(t, rc); + /* + * Clear out the kernel thread metadata and notify the + * zthr_cancel() thread that we've stopped running. + */ + t->zthr_thread = NULL; + t->zthr_cancel = B_FALSE; + cv_broadcast(&t->zthr_cv); + + mutex_exit(&t->zthr_state_lock); + thread_exit(); } zthr_t * @@ -226,10 +257,11 @@ zthr_create_timer(zthr_checkfunc_t *checkfunc, zthr_fu void *arg, hrtime_t max_sleep) { zthr_t *t = kmem_zalloc(sizeof (*t), KM_SLEEP); - mutex_init(&t->zthr_lock, NULL, MUTEX_DEFAULT, NULL); + mutex_init(&t->zthr_state_lock, NULL, MUTEX_DEFAULT, NULL); + mutex_init(&t->zthr_request_lock, NULL, MUTEX_DEFAULT, NULL); cv_init(&t->zthr_cv, NULL, CV_DEFAULT, NULL); - mutex_enter(&t->zthr_lock); + mutex_enter(&t->zthr_state_lock); t->zthr_checkfunc = checkfunc; t->zthr_func = func; t->zthr_arg = arg; @@ -237,7 +269,7 @@ zthr_create_timer(zthr_checkfunc_t *checkfunc, zthr_fu t->zthr_thread = thread_create(NULL, 0, zthr_procedure, t, 0, &p0, TS_RUN, minclsyspri); - mutex_exit(&t->zthr_lock); + mutex_exit(&t->zthr_state_lock); return (t); } @@ -245,71 +277,130 @@ zthr_create_timer(zthr_checkfunc_t *checkfunc, zthr_fu void zthr_destroy(zthr_t *t) { + ASSERT(!MUTEX_HELD(&t->zthr_state_lock)); + ASSERT(!MUTEX_HELD(&t->zthr_request_lock)); VERIFY3P(t->zthr_thread, ==, NULL); - mutex_destroy(&t->zthr_lock); + mutex_destroy(&t->zthr_request_lock); + mutex_destroy(&t->zthr_state_lock); cv_destroy(&t->zthr_cv); kmem_free(t, sizeof (*t)); } /* - * Note: If the zthr is not sleeping and misses the wakeup - * (e.g it is running its ZTHR function), it will check if - * there is work to do before going to sleep using its checker - * function [see ZTHR state transition in ZTHR block comment]. - * Thus, missing the wakeup still yields the expected behavior. + * Wake up the zthr if it is sleeping. If the thread has been + * cancelled that does nothing. */ void zthr_wakeup(zthr_t *t) { - mutex_enter(&t->zthr_lock); + mutex_enter(&t->zthr_request_lock); + mutex_enter(&t->zthr_state_lock); + + /* + * There are 4 states that we can find the zthr when issuing + * this broadcast: + * + * [1] The common case of the thread being asleep, at which + * point the broadcast will wake it up. + * [2] The thread has been cancelled. Waking up a cancelled + * thread is a no-op. Any work that is still left to be + * done should be handled the next time the thread is + * resumed. + * [3] The thread is doing work and is already up, so this + * is basically a no-op. + * [4] The thread was just created/resumed, in which case the + * behavior is similar to [3]. + */ cv_broadcast(&t->zthr_cv); - mutex_exit(&t->zthr_lock); + + mutex_exit(&t->zthr_state_lock); + mutex_exit(&t->zthr_request_lock); } /* - * Note: If the zthr is not running (e.g. has been cancelled + * Sends a cancel request to the zthr and blocks until the zthr is + * cancelled. If the zthr is not running (e.g. has been cancelled * already), this is a no-op. */ -int +void zthr_cancel(zthr_t *t) { - int rc = 0; + mutex_enter(&t->zthr_request_lock); + mutex_enter(&t->zthr_state_lock); - mutex_enter(&t->zthr_lock); + /* + * Since we are holding the zthr_state_lock at this point + * we can find the state in one of the following 4 states: + * + * [1] The thread has already been cancelled, therefore + * there is nothing for us to do. + * [2] The thread is sleeping, so we broadcast the CV first + * to wake it up and then we set the flag and we are + * waiting for it to exit. + * [3] The thread is doing work, in which case we just set + * the flag and wait for it to finish. + * [4] The thread was just created/resumed, in which case + * the behavior is similar to [3]. + * + * Since requests are serialized, by the time that we get + * control back we expect that the zthr is cancelled and + * not running anymore. + */ + if (t->zthr_thread != NULL) { + t->zthr_cancel = B_TRUE; - /* broadcast in case the zthr is sleeping */ - cv_broadcast(&t->zthr_cv); + /* broadcast in case the zthr is sleeping */ + cv_broadcast(&t->zthr_cv); - t->zthr_cancel = B_TRUE; - while (t->zthr_thread != NULL) - cv_wait(&t->zthr_cv, &t->zthr_lock); - t->zthr_cancel = B_FALSE; - rc = t->zthr_rc; - mutex_exit(&t->zthr_lock); + while (t->zthr_thread != NULL) + cv_wait(&t->zthr_cv, &t->zthr_state_lock); - return (rc); + ASSERT(!t->zthr_cancel); + } + + mutex_exit(&t->zthr_state_lock); + mutex_exit(&t->zthr_request_lock); } +/* + * Sends a resume request to the supplied zthr. If the zthr is + * already running this is a no-op. + */ void zthr_resume(zthr_t *t) { - ASSERT3P(t->zthr_thread, ==, NULL); + mutex_enter(&t->zthr_request_lock); + mutex_enter(&t->zthr_state_lock); - mutex_enter(&t->zthr_lock); - ASSERT3P(&t->zthr_checkfunc, !=, NULL); ASSERT3P(&t->zthr_func, !=, NULL); ASSERT(!t->zthr_cancel); - t->zthr_thread = thread_create(NULL, 0, zthr_procedure, t, - 0, &p0, TS_RUN, minclsyspri); + /* + * There are 4 states that we find the zthr in at this point + * given the locks that we hold: + * + * [1] The zthr was cancelled, so we spawn a new thread for + * the zthr (common case). + * [2] The zthr is running at which point this is a no-op. + * [3] The zthr is sleeping at which point this is a no-op. + * [4] The zthr was just spawned at which point this is a + * no-op. + */ + if (t->zthr_thread == NULL) { + t->zthr_thread = thread_create(NULL, 0, zthr_procedure, t, + 0, &p0, TS_RUN, minclsyspri); + } - mutex_exit(&t->zthr_lock); + mutex_exit(&t->zthr_state_lock); + mutex_exit(&t->zthr_request_lock); } /* * This function is intended to be used by the zthr itself - * to check if another thread has signal it to stop running. + * (specifically the zthr_func callback provided) to check + * if another thread has signaled it to stop running before + * doing some expensive operation. * * returns TRUE if we are in the middle of trying to cancel * this thread. @@ -319,25 +410,22 @@ zthr_resume(zthr_t *t) boolean_t zthr_iscancelled(zthr_t *t) { - boolean_t cancelled; - ASSERT3P(t->zthr_thread, ==, curthread); - mutex_enter(&t->zthr_lock); - cancelled = t->zthr_cancel; - mutex_exit(&t->zthr_lock); - + /* + * The majority of the functions here grab zthr_request_lock + * first and then zthr_state_lock. This function only grabs + * the zthr_state_lock. That is because this function should + * only be called from the zthr_func to check if someone has + * issued a zthr_cancel() on the thread. If there is a zthr_cancel() + * happening concurrently, attempting to grab the request lock + * here would result in a deadlock. + * + * By grabbing only the zthr_state_lock this function is allowed + * to run concurrently with a zthr_cancel() request. + */ + mutex_enter(&t->zthr_state_lock); + boolean_t cancelled = t->zthr_cancel; + mutex_exit(&t->zthr_state_lock); return (cancelled); -} - -boolean_t -zthr_isrunning(zthr_t *t) -{ - boolean_t running; - - mutex_enter(&t->zthr_lock); - running = (t->zthr_thread != NULL); - mutex_exit(&t->zthr_lock); - - return (running); } From owner-svn-src-stable@freebsd.org Wed Nov 6 13:45:24 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E6E111B6644; Wed, 6 Nov 2019 13:45:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 477STc5r4Hz47Cb; Wed, 6 Nov 2019 13:45:24 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AC04125E11; Wed, 6 Nov 2019 13:45:24 +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 xA6DjOFo024660; Wed, 6 Nov 2019 13:45:24 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA6DjOkT024659; Wed, 6 Nov 2019 13:45:24 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201911061345.xA6DjOkT024659@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 6 Nov 2019 13:45:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354387 - stable/12/sys/vm X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/vm X-SVN-Commit-Revision: 354387 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.29 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, 06 Nov 2019 13:45:25 -0000 Author: kib Date: Wed Nov 6 13:45:24 2019 New Revision: 354387 URL: https://svnweb.freebsd.org/changeset/base/354387 Log: MFC r353888, r353916, r353964 (by markj): vm_fault(): extract code to lock the vnode into a helper vm_fault_lock_vnode(). Modified: stable/12/sys/vm/vm_fault.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/vm/vm_fault.c ============================================================================== --- stable/12/sys/vm/vm_fault.c Wed Nov 6 09:09:03 2019 (r354386) +++ stable/12/sys/vm/vm_fault.c Wed Nov 6 13:45:24 2019 (r354387) @@ -152,11 +152,13 @@ static inline void release_page(struct faultstate *fs) { - vm_page_xunbusy(fs->m); - vm_page_lock(fs->m); - vm_page_deactivate(fs->m); - vm_page_unlock(fs->m); - fs->m = NULL; + if (fs->m != NULL) { + vm_page_xunbusy(fs->m); + vm_page_lock(fs->m); + vm_page_deactivate(fs->m); + vm_page_unlock(fs->m); + fs->m = NULL; + } } static inline void @@ -630,19 +632,64 @@ vm_fault_trap(vm_map_t map, vm_offset_t vaddr, vm_prot return (result); } +static int +vm_fault_lock_vnode(struct faultstate *fs) +{ + struct vnode *vp; + int error, locked; + + if (fs->object->type != OBJT_VNODE) + return (KERN_SUCCESS); + vp = fs->object->handle; + if (vp == fs->vp) { + ASSERT_VOP_LOCKED(vp, "saved vnode is not locked"); + return (KERN_SUCCESS); + } + + /* + * Perform an unlock in case the desired vnode changed while + * the map was unlocked during a retry. + */ + unlock_vp(fs); + + locked = VOP_ISLOCKED(vp); + if (locked != LK_EXCLUSIVE) + locked = LK_SHARED; + + /* + * We must not sleep acquiring the vnode lock while we have + * the page exclusive busied or the object's + * paging-in-progress count incremented. Otherwise, we could + * deadlock. + */ + error = vget(vp, locked | LK_CANRECURSE | LK_NOWAIT, curthread); + if (error == 0) { + fs->vp = vp; + return (KERN_SUCCESS); + } + + vhold(vp); + release_page(fs); + unlock_and_deallocate(fs); + error = vget(vp, locked | LK_RETRY | LK_CANRECURSE, curthread); + vdrop(vp); + fs->vp = vp; + KASSERT(error == 0, ("vm_fault: vget failed %d", error)); + return (KERN_RESOURCE_SHORTAGE); +} + int vm_fault(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type, int fault_flags, vm_page_t *m_hold) { struct faultstate fs; - struct vnode *vp; struct domainset *dset; vm_object_t next_object, retry_object; vm_offset_t e_end, e_start; vm_pindex_t retry_pindex; vm_prot_t prot, retry_prot; - int ahead, alloc_req, behind, cluster_offset, error, era, faultcount; - int locked, nera, oom, result, rv; + int ahead, alloc_req, behind, cluster_offset, era, faultcount; + int nera, oom, result, rv; u_char behavior; boolean_t wired; /* Passed by reference. */ bool dead, hardfault, is_first_object_locked; @@ -1006,41 +1053,11 @@ readrest: */ unlock_map(&fs); - if (fs.object->type == OBJT_VNODE && - (vp = fs.object->handle) != fs.vp) { - /* - * Perform an unlock in case the desired vnode - * changed while the map was unlocked during a - * retry. - */ - unlock_vp(&fs); - - locked = VOP_ISLOCKED(vp); - if (locked != LK_EXCLUSIVE) - locked = LK_SHARED; - - /* - * We must not sleep acquiring the vnode lock - * while we have the page exclusive busied or - * the object's paging-in-progress count - * incremented. Otherwise, we could deadlock. - */ - error = vget(vp, locked | LK_CANRECURSE | - LK_NOWAIT, curthread); - if (error != 0) { - vhold(vp); - release_page(&fs); - unlock_and_deallocate(&fs); - error = vget(vp, locked | LK_RETRY | - LK_CANRECURSE, curthread); - vdrop(vp); - fs.vp = vp; - KASSERT(error == 0, - ("vm_fault: vget failed")); - goto RetryFault; - } - fs.vp = vp; - } + rv = vm_fault_lock_vnode(&fs); + MPASS(rv == KERN_SUCCESS || + rv == KERN_RESOURCE_SHORTAGE); + if (rv == KERN_RESOURCE_SHORTAGE) + goto RetryFault; KASSERT(fs.vp == NULL || !fs.map->system_map, ("vm_fault: vnode-backed object mapped by system map")); From owner-svn-src-stable@freebsd.org Wed Nov 6 14:32:00 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C77841B75F1; Wed, 6 Nov 2019 14:32:00 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 477TWN4xcMz4BdK; Wed, 6 Nov 2019 14:32:00 +0000 (UTC) (envelope-from imp@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8CEAA266EC; Wed, 6 Nov 2019 14:32:00 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA6EW0AT054986; Wed, 6 Nov 2019 14:32:00 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA6EW07V054985; Wed, 6 Nov 2019 14:32:00 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201911061432.xA6EW07V054985@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Wed, 6 Nov 2019 14:32:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354391 - stable/12 X-SVN-Group: stable-12 X-SVN-Commit-Author: imp X-SVN-Commit-Paths: stable/12 X-SVN-Commit-Revision: 354391 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.29 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, 06 Nov 2019 14:32:00 -0000 Author: imp Date: Wed Nov 6 14:32:00 2019 New Revision: 354391 URL: https://svnweb.freebsd.org/changeset/base/354391 Log: Change current to stable/12. Direct commit because this change isn't relevant to -current Reported by: Jamie Landeg-Jones Modified: stable/12/UPDATING Modified: stable/12/UPDATING ============================================================================== --- stable/12/UPDATING Wed Nov 6 14:30:56 2019 (r354390) +++ stable/12/UPDATING Wed Nov 6 14:32:00 2019 (r354391) @@ -1,4 +1,4 @@ - Updating Information for FreeBSD current users. + Updating Information for FreeBSD stable/12 users. This file is maintained and copyrighted by M. Warner Losh . See end of file for further details. For commonly done items, please see the From owner-svn-src-stable@freebsd.org Wed Nov 6 14:33:16 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 594E21B77C4; Wed, 6 Nov 2019 14:33:16 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 477TXr1ctYz4BnC; Wed, 6 Nov 2019 14:33:16 +0000 (UTC) (envelope-from imp@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1AF612671B; Wed, 6 Nov 2019 14:33:16 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA6EXFr8058504; Wed, 6 Nov 2019 14:33:15 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA6EXFt5058503; Wed, 6 Nov 2019 14:33:15 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201911061433.xA6EXFt5058503@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Wed, 6 Nov 2019 14:33: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: r354392 - stable/11 X-SVN-Group: stable-11 X-SVN-Commit-Author: imp X-SVN-Commit-Paths: stable/11 X-SVN-Commit-Revision: 354392 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.29 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, 06 Nov 2019 14:33:16 -0000 Author: imp Date: Wed Nov 6 14:33:15 2019 New Revision: 354392 URL: https://svnweb.freebsd.org/changeset/base/354392 Log: Update to indicate this is for stable/11, not current. Direct commit because it's not relevant to any other branch. Reported by: Jamie Landeg-Jones Modified: stable/11/UPDATING Modified: stable/11/UPDATING ============================================================================== --- stable/11/UPDATING Wed Nov 6 14:32:00 2019 (r354391) +++ stable/11/UPDATING Wed Nov 6 14:33:15 2019 (r354392) @@ -1,4 +1,4 @@ -Updating Information for FreeBSD current users. +Updating Information for FreeBSD stable/11 users. This file is maintained and copyrighted by M. Warner Losh . See end of file for further details. For commonly done items, please see the From owner-svn-src-stable@freebsd.org Wed Nov 6 14:34:15 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8A1C11B783E; Wed, 6 Nov 2019 14:34:15 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 477TYz378Hz4Bvw; Wed, 6 Nov 2019 14:34:15 +0000 (UTC) (envelope-from imp@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4E7EC2671C; Wed, 6 Nov 2019 14:34:15 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA6EYFTm058594; Wed, 6 Nov 2019 14:34:15 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA6EYFBF058593; Wed, 6 Nov 2019 14:34:15 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201911061434.xA6EYFBF058593@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Wed, 6 Nov 2019 14:34:15 +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: r354393 - stable/10 X-SVN-Group: stable-10 X-SVN-Commit-Author: imp X-SVN-Commit-Paths: stable/10 X-SVN-Commit-Revision: 354393 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.29 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, 06 Nov 2019 14:34:15 -0000 Author: imp Date: Wed Nov 6 14:34:14 2019 New Revision: 354393 URL: https://svnweb.freebsd.org/changeset/base/354393 Log: Replace current with stable/10 Direct commit because not relevant to other branches Reported by: Jamie Landeg-Jones Modified: stable/10/UPDATING Modified: stable/10/UPDATING ============================================================================== --- stable/10/UPDATING Wed Nov 6 14:33:15 2019 (r354392) +++ stable/10/UPDATING Wed Nov 6 14:34:14 2019 (r354393) @@ -1,4 +1,4 @@ -Updating Information for FreeBSD current users +Updating Information for FreeBSD stable/10 users This file is maintained and copyrighted by M. Warner Losh . See end of file for further details. For commonly done items, please see the From owner-svn-src-stable@freebsd.org Wed Nov 6 14:41:08 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BE7071B7B63; Wed, 6 Nov 2019 14:41:08 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 477Tjw4SM4z4CCg; Wed, 6 Nov 2019 14:41:08 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7C38C2675C; Wed, 6 Nov 2019 14:41:08 +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 xA6Ef8gh059698; Wed, 6 Nov 2019 14:41:08 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA6Ef7gs059694; Wed, 6 Nov 2019 14:41:07 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201911061441.xA6Ef7gs059694@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 6 Nov 2019 14:41:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354394 - in stable/12/sys: sys vm X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/12/sys: sys vm X-SVN-Commit-Revision: 354394 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.29 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, 06 Nov 2019 14:41:08 -0000 Author: kib Date: Wed Nov 6 14:41:07 2019 New Revision: 354394 URL: https://svnweb.freebsd.org/changeset/base/354394 Log: MFC r353890: Add VV_VMSIZEVNLOCK flag. MFC note: OBJ_SIZEVNLOCK value was changed due to differences between stable/12 and HEAD. Modified: stable/12/sys/sys/vnode.h stable/12/sys/vm/vm_fault.c stable/12/sys/vm/vm_object.h stable/12/sys/vm/vnode_pager.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/sys/vnode.h ============================================================================== --- stable/12/sys/sys/vnode.h Wed Nov 6 14:34:14 2019 (r354393) +++ stable/12/sys/sys/vnode.h Wed Nov 6 14:41:07 2019 (r354394) @@ -246,6 +246,7 @@ struct xvnode { #define VV_NOSYNC 0x0004 /* unlinked, stop syncing */ #define VV_ETERNALDEV 0x0008 /* device that is never destroyed */ #define VV_CACHEDLABEL 0x0010 /* Vnode has valid cached MAC label */ +#define VV_VMSIZEVNLOCK 0x0020 /* object size check requires vnode lock */ #define VV_COPYONWRITE 0x0040 /* vnode is doing copy-on-write */ #define VV_SYSTEM 0x0080 /* vnode being used by kernel */ #define VV_PROCDEP 0x0100 /* vnode is process dependent */ Modified: stable/12/sys/vm/vm_fault.c ============================================================================== --- stable/12/sys/vm/vm_fault.c Wed Nov 6 14:34:14 2019 (r354393) +++ stable/12/sys/vm/vm_fault.c Wed Nov 6 14:41:07 2019 (r354394) @@ -896,6 +896,13 @@ RetryFault_oom: */ if (fs.object->type != OBJT_DEFAULT || fs.object == fs.first_object) { + if ((fs.object->flags & OBJ_SIZEVNLOCK) != 0) { + rv = vm_fault_lock_vnode(&fs); + MPASS(rv == KERN_SUCCESS || + rv == KERN_RESOURCE_SHORTAGE); + if (rv == KERN_RESOURCE_SHORTAGE) + goto RetryFault; + } if (fs.pindex >= fs.object->size) { unlock_and_deallocate(&fs); return (KERN_OUT_OF_BOUNDS); Modified: stable/12/sys/vm/vm_object.h ============================================================================== --- stable/12/sys/vm/vm_object.h Wed Nov 6 14:34:14 2019 (r354393) +++ stable/12/sys/vm/vm_object.h Wed Nov 6 14:41:07 2019 (r354394) @@ -189,6 +189,7 @@ struct vm_object { #define OBJ_MIGHTBEDIRTY 0x0100 /* object might be dirty, only for vnode */ #define OBJ_TMPFS_NODE 0x0200 /* object belongs to tmpfs VREG node */ #define OBJ_TMPFS_DIRTY 0x0400 /* dirty tmpfs obj */ +#define OBJ_SIZEVNLOCK 0x0800 /* lock vnode to check obj size */ #define OBJ_COLORED 0x1000 /* pg_color is defined */ #define OBJ_ONEMAPPING 0x2000 /* One USE (a single, non-forked) mapping flag */ #define OBJ_DISCONNECTWNT 0x4000 /* disconnect from vnode wanted */ Modified: stable/12/sys/vm/vnode_pager.c ============================================================================== --- stable/12/sys/vm/vnode_pager.c Wed Nov 6 14:34:14 2019 (r354393) +++ stable/12/sys/vm/vnode_pager.c Wed Nov 6 14:41:07 2019 (r354394) @@ -256,8 +256,12 @@ retry: object->un_pager.vnp.vnp_size = size; object->un_pager.vnp.writemappings = 0; object->domain.dr_policy = vnode_domainset; - object->handle = handle; + if ((vp->v_vflag & VV_VMSIZEVNLOCK) != 0) { + VM_OBJECT_WLOCK(object); + vm_object_set_flag(object, OBJ_SIZEVNLOCK); + VM_OBJECT_WUNLOCK(object); + } VI_LOCK(vp); if (vp->v_object != NULL) { /* From owner-svn-src-stable@freebsd.org Wed Nov 6 15:11:53 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 764771B8595; Wed, 6 Nov 2019 15:11:53 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 477VPP2XWJz4FKF; Wed, 6 Nov 2019 15:11:53 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3A45C26E51; Wed, 6 Nov 2019 15:11:53 +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 xA6FBrrR078553; Wed, 6 Nov 2019 15:11:53 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA6FBqJt078546; Wed, 6 Nov 2019 15:11:52 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201911061511.xA6FBqJt078546@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 6 Nov 2019 15:11:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354398 - in stable/12/sys/fs: nfs nfsclient X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/12/sys/fs: nfs nfsclient X-SVN-Commit-Revision: 354398 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.29 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, 06 Nov 2019 15:11:53 -0000 Author: kib Date: Wed Nov 6 15:11:51 2019 New Revision: 354398 URL: https://svnweb.freebsd.org/changeset/base/354398 Log: MFC r353891: Fix interface between nfsclient and vnode pager. Modified: stable/12/sys/fs/nfs/nfsport.h stable/12/sys/fs/nfsclient/nfs_clnode.c stable/12/sys/fs/nfsclient/nfs_clport.c stable/12/sys/fs/nfsclient/nfs_clsubs.c stable/12/sys/fs/nfsclient/nfs_clvnops.c stable/12/sys/fs/nfsclient/nfsnode.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/fs/nfs/nfsport.h ============================================================================== --- stable/12/sys/fs/nfs/nfsport.h Wed Nov 6 14:58:25 2019 (r354397) +++ stable/12/sys/fs/nfs/nfsport.h Wed Nov 6 15:11:51 2019 (r354398) @@ -880,6 +880,7 @@ MALLOC_DECLARE(M_NEWNFSDSESSION); int nfscl_loadattrcache(struct vnode **, struct nfsvattr *, void *, void *, int, int); int newnfs_realign(struct mbuf **, int); +bool ncl_pager_setsize(struct vnode *vp, u_quad_t *nsizep); /* * If the port runs on an SMP box that can enforce Atomic ops with low Modified: stable/12/sys/fs/nfsclient/nfs_clnode.c ============================================================================== --- stable/12/sys/fs/nfsclient/nfs_clnode.c Wed Nov 6 14:58:25 2019 (r354397) +++ stable/12/sys/fs/nfsclient/nfs_clnode.c Wed Nov 6 15:11:51 2019 (r354398) @@ -162,6 +162,8 @@ ncl_nget(struct mount *mntp, u_int8_t *fhp, int fhsize vp->v_type = VDIR; vp->v_vflag |= VV_ROOT; } + + vp->v_vflag |= VV_VMSIZEVNLOCK; np->n_fhp = malloc(sizeof (struct nfsfh) + fhsize, M_NFSFH, M_WAITOK); Modified: stable/12/sys/fs/nfsclient/nfs_clport.c ============================================================================== --- stable/12/sys/fs/nfsclient/nfs_clport.c Wed Nov 6 14:58:25 2019 (r354397) +++ stable/12/sys/fs/nfsclient/nfs_clport.c Wed Nov 6 15:11:51 2019 (r354398) @@ -246,6 +246,8 @@ nfscl_nget(struct mount *mntp, struct vnode *dvp, stru vp->v_type = VDIR; vp->v_vflag |= VV_ROOT; } + + vp->v_vflag |= VV_VMSIZEVNLOCK; np->n_fhp = nfhp; /* @@ -414,10 +416,7 @@ nfscl_loadattrcache(struct vnode **vpp, struct nfsvatt struct nfsnode *np; struct nfsmount *nmp; struct timespec mtime_save; - vm_object_t object; - u_quad_t nsize; int error, force_fid_err; - bool setnsize; error = 0; @@ -565,27 +564,53 @@ out: if (np->n_attrstamp != 0) KDTRACE_NFS_ATTRCACHE_LOAD_DONE(vp, vap, error); #endif + (void)ncl_pager_setsize(vp, NULL); + return (error); +} + +/* + * Call vnode_pager_setsize() if the size of the node changed, as + * recorded in nfsnode vs. v_object, or delay the call if notifying + * the pager is not possible at the moment. + * + * If nsizep is non-NULL, the call is delayed and the new node size is + * provided. Caller should itself call vnode_pager_setsize() if + * function returned true. If nsizep is NULL, function tries to call + * vnode_pager_setsize() itself if needed and possible, and the nfs + * node is unlocked unconditionally, the return value is not useful. + */ +bool +ncl_pager_setsize(struct vnode *vp, u_quad_t *nsizep) +{ + struct nfsnode *np; + vm_object_t object; + struct vattr *vap; + u_quad_t nsize; + bool setnsize; + + np = VTONFS(vp); + NFSASSERTNODE(np); + + vap = &np->n_vattr.na_vattr; nsize = vap->va_size; object = vp->v_object; setnsize = false; - if (object != NULL) { - if (OFF_TO_IDX(nsize + PAGE_MASK) < object->size) { - /* - * When shrinking the size, the call to - * vnode_pager_setsize() cannot be done with - * the mutex held, because we might need to - * wait for a busy page. Delay it until after - * the node is unlocked. - */ + + if (object != NULL && nsize != object->un_pager.vnp.vnp_size) { + if (VOP_ISLOCKED(vp) == LK_EXCLUSIVE) setnsize = true; - } else { + else + np->n_flag |= NVNSETSZSKIP; + } + if (nsizep == NULL) { + NFSUNLOCKNODE(np); + if (setnsize) vnode_pager_setsize(vp, nsize); - } + setnsize = false; + } else { + *nsizep = nsize; } - NFSUNLOCKNODE(np); - if (setnsize) - vnode_pager_setsize(vp, nsize); - return (error); + return (setnsize); } /* Modified: stable/12/sys/fs/nfsclient/nfs_clsubs.c ============================================================================== --- stable/12/sys/fs/nfsclient/nfs_clsubs.c Wed Nov 6 14:58:25 2019 (r354397) +++ stable/12/sys/fs/nfsclient/nfs_clsubs.c Wed Nov 6 15:11:51 2019 (r354398) @@ -185,6 +185,8 @@ ncl_getattrcache(struct vnode *vp, struct vattr *vaper struct vattr *vap; struct nfsmount *nmp; int timeo, mustflush; + u_quad_t nsize; + bool setnsize; np = VTONFS(vp); vap = &np->n_vattr.na_vattr; @@ -230,6 +232,7 @@ ncl_getattrcache(struct vnode *vp, struct vattr *vaper return( ENOENT); } nfsstatsv1.attrcache_hits++; + setnsize = false; if (vap->va_size != np->n_size) { if (vap->va_type == VREG) { if (np->n_flag & NMODIFIED) { @@ -240,7 +243,7 @@ ncl_getattrcache(struct vnode *vp, struct vattr *vaper } else { np->n_size = vap->va_size; } - vnode_pager_setsize(vp, np->n_size); + setnsize = ncl_pager_setsize(vp, &nsize); } else { np->n_size = vap->va_size; } @@ -253,6 +256,8 @@ ncl_getattrcache(struct vnode *vp, struct vattr *vaper vaper->va_mtime = np->n_mtim; } NFSUNLOCKNODE(np); + if (setnsize) + vnode_pager_setsize(vp, nsize); KDTRACE_NFS_ATTRCACHE_GET_HIT(vp, vap); return (0); } Modified: stable/12/sys/fs/nfsclient/nfs_clvnops.c ============================================================================== --- stable/12/sys/fs/nfsclient/nfs_clvnops.c Wed Nov 6 14:58:25 2019 (r354397) +++ stable/12/sys/fs/nfsclient/nfs_clvnops.c Wed Nov 6 15:11:51 2019 (r354398) @@ -142,6 +142,7 @@ static vop_advlock_t nfs_advlock; static vop_advlockasync_t nfs_advlockasync; static vop_getacl_t nfs_getacl; static vop_setacl_t nfs_setacl; +static vop_lock1_t nfs_lock; /* * Global vfs data structures for nfs @@ -159,6 +160,7 @@ struct vop_vector newnfs_vnodeops = { .vop_putpages = ncl_putpages, .vop_inactive = ncl_inactive, .vop_link = nfs_link, + .vop_lock1 = nfs_lock, .vop_lookup = nfs_lookup, .vop_mkdir = nfs_mkdir, .vop_mknod = nfs_mknod, @@ -269,6 +271,73 @@ SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs_directio_allow_mmap rep->r_mtx * rep->r_mtx : Protects the fields in an nfsreq. */ + +static int +nfs_lock(struct vop_lock1_args *ap) +{ + struct vnode *vp; + struct nfsnode *np; + u_quad_t nsize; + int error, lktype; + bool onfault; + + vp = ap->a_vp; + lktype = ap->a_flags & LK_TYPE_MASK; + error = VOP_LOCK1_APV(&default_vnodeops, ap); + if (error != 0 || vp->v_op != &newnfs_vnodeops) + return (error); + np = VTONFS(vp); + NFSLOCKNODE(np); + if ((np->n_flag & NVNSETSZSKIP) == 0 || (lktype != LK_SHARED && + lktype != LK_EXCLUSIVE && lktype != LK_UPGRADE && + lktype != LK_TRYUPGRADE)) { + NFSUNLOCKNODE(np); + return (0); + } + onfault = (ap->a_flags & LK_EATTR_MASK) == LK_NOWAIT && + (ap->a_flags & LK_INIT_MASK) == LK_CANRECURSE && + (lktype == LK_SHARED || lktype == LK_EXCLUSIVE); + if (onfault && vp->v_vnlock->lk_recurse == 0) { + /* + * Force retry in vm_fault(), to make the lock request + * sleepable, which allows us to piggy-back the + * sleepable call to vnode_pager_setsize(). + */ + NFSUNLOCKNODE(np); + VOP_UNLOCK(vp, 0); + return (EBUSY); + } + if ((ap->a_flags & LK_NOWAIT) != 0 || + (lktype == LK_SHARED && vp->v_vnlock->lk_recurse > 0)) { + NFSUNLOCKNODE(np); + return (0); + } + if (lktype == LK_SHARED) { + NFSUNLOCKNODE(np); + VOP_UNLOCK(vp, 0); + ap->a_flags &= ~(LK_TYPE_MASK | LK_INTERLOCK); + ap->a_flags |= LK_EXCLUSIVE; + error = VOP_LOCK1_APV(&default_vnodeops, ap); + if (error != 0 || vp->v_op != &newnfs_vnodeops) + return (error); + NFSLOCKNODE(np); + if ((np->n_flag & NVNSETSZSKIP) == 0) { + NFSUNLOCKNODE(np); + goto downgrade; + } + } + np->n_flag &= ~NVNSETSZSKIP; + nsize = np->n_size; + NFSUNLOCKNODE(np); + vnode_pager_setsize(vp, nsize); +downgrade: + if (lktype == LK_SHARED) { + ap->a_flags &= ~(LK_TYPE_MASK | LK_INTERLOCK); + ap->a_flags |= LK_DOWNGRADE; + (void)VOP_LOCK1_APV(&default_vnodeops, ap); + } + return (0); +} static int nfs34_access_otw(struct vnode *vp, int wmode, struct thread *td, Modified: stable/12/sys/fs/nfsclient/nfsnode.h ============================================================================== --- stable/12/sys/fs/nfsclient/nfsnode.h Wed Nov 6 14:58:25 2019 (r354397) +++ stable/12/sys/fs/nfsclient/nfsnode.h Wed Nov 6 15:11:51 2019 (r354398) @@ -163,6 +163,7 @@ struct nfsnode { #define NWRITEOPENED 0x00040000 /* Has been opened for writing */ #define NHASBEENLOCKED 0x00080000 /* Has been file locked. */ #define NDSCOMMIT 0x00100000 /* Commit is done via the DS. */ +#define NVNSETSZSKIP 0x00200000 /* Skipped vnode_pager_setsize() */ /* * Convert between nfsnode pointers and vnode pointers From owner-svn-src-stable@freebsd.org Wed Nov 6 17:06:35 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C2AE81BABB2; Wed, 6 Nov 2019 17:06:35 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 477Xxl3hZBz4MZR; Wed, 6 Nov 2019 17:06:34 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id xA6H6OSX010909; Wed, 6 Nov 2019 09:06:24 -0800 (PST) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: (from freebsd@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id xA6H6OSW010908; Wed, 6 Nov 2019 09:06:24 -0800 (PST) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201911061706.xA6H6OSW010908@gndrsh.dnsmgr.net> Subject: Re: svn commit: r354393 - stable/10 In-Reply-To: <201911061434.xA6EYFBF058593@repo.freebsd.org> To: Warner Losh Date: Wed, 6 Nov 2019 09:06:24 -0800 (PST) CC: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org, re@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 477Xxl3hZBz4MZR X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-5.98 / 15.00]; NEURAL_HAM_MEDIUM(-0.98)[-0.981,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 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, 06 Nov 2019 17:06:35 -0000 > Author: imp > Date: Wed Nov 6 14:34:14 2019 > New Revision: 354393 > URL: https://svnweb.freebsd.org/changeset/base/354393 > > Log: > Replace current with stable/10 > > Direct commit because not relevant to other branches Glen, Would you add this to the list of RE@ things to do when a new branch is created? Thanks, Rod > > Reported by: Jamie Landeg-Jones > > Modified: > stable/10/UPDATING > > Modified: stable/10/UPDATING > ============================================================================== > --- stable/10/UPDATING Wed Nov 6 14:33:15 2019 (r354392) > +++ stable/10/UPDATING Wed Nov 6 14:34:14 2019 (r354393) > @@ -1,4 +1,4 @@ > -Updating Information for FreeBSD current users > +Updating Information for FreeBSD stable/10 users > > This file is maintained and copyrighted by M. Warner Losh . > See end of file for further details. For commonly done items, please see the > -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-stable@freebsd.org Wed Nov 6 17:23:19 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 85EDA1BB0BF; Wed, 6 Nov 2019 17:23:19 +0000 (UTC) (envelope-from gjb@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [96.47.72.132]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 477YK32yjNz4NWM; Wed, 6 Nov 2019 17:23:19 +0000 (UTC) (envelope-from gjb@freebsd.org) Received: from FreeBSD.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by freefall.freebsd.org (Postfix) with ESMTPS id B1DD815736; Wed, 6 Nov 2019 17:23:18 +0000 (UTC) (envelope-from gjb@freebsd.org) Date: Wed, 6 Nov 2019 17:23:15 +0000 From: Glen Barber To: rgrimes@freebsd.org Cc: Warner Losh , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org, re@freebsd.org Subject: Re: svn commit: r354393 - stable/10 Message-ID: <20191106172315.GI1424@FreeBSD.org> References: <201911061434.xA6EYFBF058593@repo.freebsd.org> <201911061706.xA6H6OSW010908@gndrsh.dnsmgr.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="MD+Ffo4VJSI0Ass3" Content-Disposition: inline In-Reply-To: <201911061706.xA6H6OSW010908@gndrsh.dnsmgr.net> User-Agent: Mutt/1.12.1 (2019-06-15) X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 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, 06 Nov 2019 17:23:19 -0000 --MD+Ffo4VJSI0Ass3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 06, 2019 at 09:06:24AM -0800, Rodney W. Grimes wrote: > > Author: imp > > Date: Wed Nov 6 14:34:14 2019 > > New Revision: 354393 > > URL: https://svnweb.freebsd.org/changeset/base/354393 > >=20 > > Log: > > Replace current with stable/10 > > =20 > > Direct commit because not relevant to other branches >=20 > Glen, >=20 > Would you add this to the list of RE@ things to do when a > new branch is created? >=20 It is in the document already, but I still somehow missed it. Glen --MD+Ffo4VJSI0Ass3 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEjRJAPC5sqwhs9k2jAxRYpUeP4pMFAl3DAX8ACgkQAxRYpUeP 4pNUaBAAjMju8TQhMWE0LjhD8qXHCq0htuKF7jmWXWV1I0JYpolVfP6CSG1OV8BE IswDoN/x9UhrEbRV0UeedO0dTtLTOwSWKqVV3fb5iukPkXscyBAwlZaMlZB42k80 6cNKZCN6O12lIAyKz5yyX9D146ySnqkS2xxLpA5L6xGfoErmjuRZ81DD9JIPPc9F qjrd1wSymM3O8kpY1jaI+0bQVOrAX+9uxD4NrdSAbQ5lWNqz4fXfqqNjZq/GOCj7 1pAkkMtAnOoaLecivTA7UsZQq35ncj6fSE59MvE7WbfoprEz1KeGIatACAQ/Pnaq t8paCzaluaWNTJfI9HcPK2FRmuO1o4qlVQ5ji91y3VSc7ATbiitA71xm6VKnZYBn 9/lL0HLuYx8X0fhf1rY9zS1ywo+14hd9F/tYvye04hbAHqJ8jFjv9Ad6k2XKsuRS KuRDrhck2j1k4J2YH3j84VNowFWqlhLoXXfU/bLUAVo8IK4Y8ambE7yTLKvTK0x/ ZvyK5D1o3FMj0JTfMfnEqZrSIUv4rowxN4CiGuYYmPPDzFV+go49X/1Vq16gyNIT /Nuqjxk5VZ31iS9FjDW9j+0NHf/oFbFpqKuCocO5OlByXVpYqgmk06zpyaIezQan lDR7gD0Pe0/NTUx2tZhJ2nEDXRj60LE+RB7LpiQrQU/kqZMUml8= =wdfZ -----END PGP SIGNATURE----- --MD+Ffo4VJSI0Ass3-- From owner-svn-src-stable@freebsd.org Wed Nov 6 17:30:13 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 515891BB1EA for ; Wed, 6 Nov 2019 17:30:13 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 477YT02b07z4Nhr for ; Wed, 6 Nov 2019 17:30:12 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qv1-xf2d.google.com with SMTP id v16so1752264qvq.6 for ; Wed, 06 Nov 2019 09:30:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CQCNMEzmumHCCUZdTh2+7qPBdDUYUjiKU9G/lIOytp8=; b=kbj16etG84Z5DwbQWvGsJDIH2lgLrjH0fKEEu0djF20lrXVQFpMgG3zojuqujxZbNI zNe6G6AWBwCObhqzbRsL6mTXVaQTLUoto9lOEJtOdymj9EHuHJr2g1FnkuzifH3IWF0G WoLlBD/l/2mIeeWo/sHBNXln/OOQk48qQus6GQnhcQoQ4Oym/uFCMxElWErcaT0/KZKV C6xY6n0o71SgOdrfz9hlFCjUg2QsiVtigmk6dV+G3rfsO+HXz7o7x47NuoOGY4ZWmygh TCXAnU7uDsPMwNzUkD871DoZS4MBXc/4GNoPiQ/1YBGjhIv1cvId4BOAP1PiNUg9LpeM oh7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CQCNMEzmumHCCUZdTh2+7qPBdDUYUjiKU9G/lIOytp8=; b=Vu1WzWqOppK5RtI/hZ3cBhFgUwpZ3mD2+gQ7tNodDoFDZ9C+VQV+yme/QevEoaY210 tlcKevmnQH7GRSVb58loiY1/UiShNMlMrpWfdoHxE63S5ooB6WXQ5EIB1AzHa8oWNqk/ tCQN5/IiXW5ENOdYLcuhApp1GdQfV26lPd86zo8Q6wZ1hbfbUJ8NgqczBnGQ+SHGHbUm JTsnnXc6OlPn3A16ucQOVpDag99Q1Dg8C6w55QWw+NiG3FgCfJlHOf8QyfS6EXhdleTJ bzJ+ypl7XBDxMn2aVDRISyZKQZgtKzJ7/hmQrYmCWGdtMP1uV3OiZai3KPXVVZ7+lIYj 3hnA== X-Gm-Message-State: APjAAAWOrlqXz7/FWUai742s8W2sYjQhnVB+mhZAC+y17oEPAETzrtRr cvK2ecdReUihyrs+NmUztlLxx76X9yzGc2SB76lX+A== X-Google-Smtp-Source: APXvYqwXU//1cb3p9i4u4QWo8mU4Gz8orkiziC9Ul9gX8LEepgYl95uD4q6OINCpnHMmi0TeSkwDIJM7xEC3uqCxGws= X-Received: by 2002:a0c:c125:: with SMTP id f34mr3303974qvh.22.1573061405505; Wed, 06 Nov 2019 09:30:05 -0800 (PST) MIME-Version: 1.0 References: <201911061434.xA6EYFBF058593@repo.freebsd.org> <201911061706.xA6H6OSW010908@gndrsh.dnsmgr.net> <20191106172315.GI1424@FreeBSD.org> In-Reply-To: <20191106172315.GI1424@FreeBSD.org> From: Warner Losh Date: Wed, 6 Nov 2019 10:29:54 -0700 Message-ID: Subject: Re: svn commit: r354393 - stable/10 To: Glen Barber Cc: "Rodney W. Grimes" , Warner Losh , src-committers , svn-src-all , svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org, FreeBSD Release Engineering Team X-Rspamd-Queue-Id: 477YT02b07z4Nhr X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20150623.gappssmtp.com header.s=20150623 header.b=kbj16etG; dmarc=none; spf=none (mx1.freebsd.org: domain of wlosh@bsdimp.com has no SPF policy when checking 2607:f8b0:4864:20::f2d) smtp.mailfrom=wlosh@bsdimp.com X-Spamd-Result: default: False [-1.88 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20150623.gappssmtp.com:s=20150623]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[svn-src-stable@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; URI_COUNT_ODD(1.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20150623.gappssmtp.com:+]; RCPT_COUNT_SEVEN(0.00)[8]; R_SPF_NA(0.00)[]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; MIME_TRACE(0.00)[0:+,1:+,2:~]; IP_SCORE(-0.88)[ipnet: 2607:f8b0::/32(-2.35), asn: 15169(-2.01), country: US(-0.05)]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 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, 06 Nov 2019 17:30:13 -0000 On Wed, Nov 6, 2019 at 10:23 AM Glen Barber wrote: > On Wed, Nov 06, 2019 at 09:06:24AM -0800, Rodney W. Grimes wrote: > > > Author: imp > > > Date: Wed Nov 6 14:34:14 2019 > > > New Revision: 354393 > > > URL: https://svnweb.freebsd.org/changeset/base/354393 > > > > > > Log: > > > Replace current with stable/10 > > > > > > Direct commit because not relevant to other branches > > > > Glen, > > > > Would you add this to the list of RE@ things to do when a > > new branch is created? > That's a great idea... Thanks Rod. It is in the document already, but I still somehow missed it. > There's a lot on this list, so that's understandable... Maybe it's something we should enshrine in a shell script? Warner From owner-svn-src-stable@freebsd.org Wed Nov 6 17:49:38 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E80361BB8EC; Wed, 6 Nov 2019 17:49:38 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 477YvQ6bc1z4Ppn; Wed, 6 Nov 2019 17:49:38 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A6F72AAB; Wed, 6 Nov 2019 17:49:38 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA6HncqE078739; Wed, 6 Nov 2019 17:49:38 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA6Hncgc078737; Wed, 6 Nov 2019 17:49:38 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201911061749.xA6Hncgc078737@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 6 Nov 2019 17:49:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354403 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 354403 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.29 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, 06 Nov 2019 17:49:39 -0000 Author: mav Date: Wed Nov 6 17:49:38 2019 New Revision: 354403 URL: https://svnweb.freebsd.org/changeset/base/354403 Log: MFC r354241: Some more taskqueue optimizations. - Optimize enqueue for two task priority values by adding new tq_hint field, pointing to the last task inserted into the middle of the list. In case of more then two priority values it should halve average search. - Move tq_active insert/remove out of the taskqueue_run_locked loop. Instead of dirtying few shared cache lines per task introduce different mechanism to drain active tasks, based on task sequence number counter, that uses only cache lines already present in cache. Since the new mechanism does not need ordering, switch tq_active from TAILQ to LIST. - Move static and dynamic struct taskqueue fields into different cache lines. Move lock into its own cache line, so that heavy lock spinning by multiple waiting threads would not affect the running thread. - While there, correct some TQ_SLEEP() wait messages. This change fixes certain ZFS write workloads, causing huge congestion on taskqueue lock. Those workloads combine some large block writes to saturate the pool and trigger allocation throttling, which uses higher priority tasks to requeue the delayed I/Os, with many small blocks to generate deep queue of small tasks for taskqueue to sort. Sponsored by: iXsystems, Inc. Modified: stable/12/sys/kern/subr_gtaskqueue.c stable/12/sys/kern/subr_taskqueue.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/subr_gtaskqueue.c ============================================================================== --- stable/12/sys/kern/subr_gtaskqueue.c Wed Nov 6 17:03:06 2019 (r354402) +++ stable/12/sys/kern/subr_gtaskqueue.c Wed Nov 6 17:49:38 2019 (r354403) @@ -58,26 +58,26 @@ TASKQGROUP_DEFINE(softirq, mp_ncpus, 1); TASKQGROUP_DEFINE(config, 1, 1); struct gtaskqueue_busy { - struct gtask *tb_running; - TAILQ_ENTRY(gtaskqueue_busy) tb_link; + struct gtask *tb_running; + u_int tb_seq; + LIST_ENTRY(gtaskqueue_busy) tb_link; }; -static struct gtask * const TB_DRAIN_WAITER = (struct gtask *)0x1; - typedef void (*gtaskqueue_enqueue_fn)(void *context); struct gtaskqueue { STAILQ_HEAD(, gtask) tq_queue; + LIST_HEAD(, gtaskqueue_busy) tq_active; + u_int tq_seq; + int tq_callouts; + struct mtx_padalign tq_mutex; gtaskqueue_enqueue_fn tq_enqueue; void *tq_context; char *tq_name; - TAILQ_HEAD(, gtaskqueue_busy) tq_active; - struct mtx tq_mutex; struct thread **tq_threads; int tq_tcount; int tq_spin; int tq_flags; - int tq_callouts; taskqueue_callback_fn tq_callbacks[TASKQUEUE_NUM_CALLBACKS]; void *tq_cb_contexts[TASKQUEUE_NUM_CALLBACKS]; }; @@ -116,12 +116,11 @@ gtask_dump(struct gtask *gtask) #endif static __inline int -TQ_SLEEP(struct gtaskqueue *tq, void *p, struct mtx *m, int pri, const char *wm, - int t) +TQ_SLEEP(struct gtaskqueue *tq, void *p, const char *wm) { if (tq->tq_spin) - return (msleep_spin(p, m, wm, t)); - return (msleep(p, m, pri, wm, t)); + return (msleep_spin(p, (struct mtx *)&tq->tq_mutex, wm, 0)); + return (msleep(p, &tq->tq_mutex, 0, wm, 0)); } static struct gtaskqueue * @@ -145,7 +144,7 @@ _gtaskqueue_create(const char *name, int mflags, } STAILQ_INIT(&queue->tq_queue); - TAILQ_INIT(&queue->tq_active); + LIST_INIT(&queue->tq_active); queue->tq_enqueue = enqueue; queue->tq_context = context; queue->tq_name = tq_name; @@ -168,7 +167,7 @@ gtaskqueue_terminate(struct thread **pp, struct gtaskq while (tq->tq_tcount > 0 || tq->tq_callouts > 0) { wakeup(tq); - TQ_SLEEP(tq, pp, &tq->tq_mutex, PWAIT, "taskqueue_destroy", 0); + TQ_SLEEP(tq, pp, "gtq_destroy"); } } @@ -179,7 +178,7 @@ gtaskqueue_free(struct gtaskqueue *queue) TQ_LOCK(queue); queue->tq_flags &= ~TQ_FLAGS_ACTIVE; gtaskqueue_terminate(queue->tq_threads, queue); - KASSERT(TAILQ_EMPTY(&queue->tq_active), ("Tasks still running?")); + KASSERT(LIST_EMPTY(&queue->tq_active), ("Tasks still running?")); KASSERT(queue->tq_callouts == 0, ("Armed timeout tasks")); mtx_destroy(&queue->tq_mutex); free(queue->tq_threads, M_GTASKQUEUE); @@ -286,7 +285,7 @@ gtaskqueue_drain_tq_queue(struct gtaskqueue *queue) * have completed or are currently executing. */ while (t_barrier.ta_flags & TASK_ENQUEUED) - TQ_SLEEP(queue, &t_barrier, &queue->tq_mutex, PWAIT, "-", 0); + TQ_SLEEP(queue, &t_barrier, "gtq_qdrain"); } /* @@ -297,32 +296,25 @@ gtaskqueue_drain_tq_queue(struct gtaskqueue *queue) static void gtaskqueue_drain_tq_active(struct gtaskqueue *queue) { - struct gtaskqueue_busy tb_marker, *tb_first; + struct gtaskqueue_busy *tb; + u_int seq; - if (TAILQ_EMPTY(&queue->tq_active)) + if (LIST_EMPTY(&queue->tq_active)) return; /* Block taskq_terminate().*/ queue->tq_callouts++; - /* - * Wait for all currently executing taskqueue threads - * to go idle. - */ - tb_marker.tb_running = TB_DRAIN_WAITER; - TAILQ_INSERT_TAIL(&queue->tq_active, &tb_marker, tb_link); - while (TAILQ_FIRST(&queue->tq_active) != &tb_marker) - TQ_SLEEP(queue, &tb_marker, &queue->tq_mutex, PWAIT, "-", 0); - TAILQ_REMOVE(&queue->tq_active, &tb_marker, tb_link); + /* Wait for any active task with sequence from the past. */ + seq = queue->tq_seq; +restart: + LIST_FOREACH(tb, &queue->tq_active, tb_link) { + if ((int)(tb->tb_seq - seq) <= 0) { + TQ_SLEEP(queue, tb->tb_running, "gtq_adrain"); + goto restart; + } + } - /* - * Wakeup any other drain waiter that happened to queue up - * without any intervening active thread. - */ - tb_first = TAILQ_FIRST(&queue->tq_active); - if (tb_first != NULL && tb_first->tb_running == TB_DRAIN_WAITER) - wakeup(tb_first); - /* Release taskqueue_terminate(). */ queue->tq_callouts--; if ((queue->tq_flags & TQ_FLAGS_ACTIVE) == 0) @@ -353,40 +345,27 @@ static void gtaskqueue_run_locked(struct gtaskqueue *queue) { struct gtaskqueue_busy tb; - struct gtaskqueue_busy *tb_first; struct gtask *gtask; KASSERT(queue != NULL, ("tq is NULL")); TQ_ASSERT_LOCKED(queue); tb.tb_running = NULL; + LIST_INSERT_HEAD(&queue->tq_active, &tb, tb_link); - while (STAILQ_FIRST(&queue->tq_queue)) { - TAILQ_INSERT_TAIL(&queue->tq_active, &tb, tb_link); - - /* - * Carefully remove the first task from the queue and - * clear its TASK_ENQUEUED flag - */ - gtask = STAILQ_FIRST(&queue->tq_queue); - KASSERT(gtask != NULL, ("task is NULL")); + while ((gtask = STAILQ_FIRST(&queue->tq_queue)) != NULL) { STAILQ_REMOVE_HEAD(&queue->tq_queue, ta_link); gtask->ta_flags &= ~TASK_ENQUEUED; tb.tb_running = gtask; + tb.tb_seq = ++queue->tq_seq; TQ_UNLOCK(queue); KASSERT(gtask->ta_func != NULL, ("task->ta_func is NULL")); gtask->ta_func(gtask->ta_context); TQ_LOCK(queue); - tb.tb_running = NULL; wakeup(gtask); - - TAILQ_REMOVE(&queue->tq_active, &tb, tb_link); - tb_first = TAILQ_FIRST(&queue->tq_active); - if (tb_first != NULL && - tb_first->tb_running == TB_DRAIN_WAITER) - wakeup(tb_first); } + LIST_REMOVE(&tb, tb_link); } static int @@ -395,7 +374,7 @@ task_is_running(struct gtaskqueue *queue, struct gtask struct gtaskqueue_busy *tb; TQ_ASSERT_LOCKED(queue); - TAILQ_FOREACH(tb, &queue->tq_active, tb_link) { + LIST_FOREACH(tb, &queue->tq_active, tb_link) { if (tb->tb_running == gtask) return (1); } @@ -428,7 +407,7 @@ static void gtaskqueue_drain_locked(struct gtaskqueue *queue, struct gtask *gtask) { while ((gtask->ta_flags & TASK_ENQUEUED) || task_is_running(queue, gtask)) - TQ_SLEEP(queue, gtask, &queue->tq_mutex, PWAIT, "-", 0); + TQ_SLEEP(queue, gtask, "gtq_drain"); } void @@ -564,7 +543,7 @@ gtaskqueue_thread_loop(void *arg) */ if ((tq->tq_flags & TQ_FLAGS_ACTIVE) == 0) break; - TQ_SLEEP(tq, tq, &tq->tq_mutex, 0, "-", 0); + TQ_SLEEP(tq, tq, "-"); } gtaskqueue_run_locked(tq); /* @@ -590,7 +569,7 @@ gtaskqueue_thread_enqueue(void *context) tqp = context; tq = *tqp; - wakeup_one(tq); + wakeup_any(tq); } Modified: stable/12/sys/kern/subr_taskqueue.c ============================================================================== --- stable/12/sys/kern/subr_taskqueue.c Wed Nov 6 17:03:06 2019 (r354402) +++ stable/12/sys/kern/subr_taskqueue.c Wed Nov 6 17:49:38 2019 (r354403) @@ -56,24 +56,25 @@ static void taskqueue_swi_enqueue(void *); static void taskqueue_swi_giant_enqueue(void *); struct taskqueue_busy { - struct task *tb_running; - TAILQ_ENTRY(taskqueue_busy) tb_link; + struct task *tb_running; + u_int tb_seq; + LIST_ENTRY(taskqueue_busy) tb_link; }; -struct task * const TB_DRAIN_WAITER = (struct task *)0x1; - struct taskqueue { STAILQ_HEAD(, task) tq_queue; + LIST_HEAD(, taskqueue_busy) tq_active; + struct task *tq_hint; + u_int tq_seq; + int tq_callouts; + struct mtx_padalign tq_mutex; taskqueue_enqueue_fn tq_enqueue; void *tq_context; char *tq_name; - TAILQ_HEAD(, taskqueue_busy) tq_active; - struct mtx tq_mutex; struct thread **tq_threads; int tq_tcount; int tq_spin; int tq_flags; - int tq_callouts; taskqueue_callback_fn tq_callbacks[TASKQUEUE_NUM_CALLBACKS]; void *tq_cb_contexts[TASKQUEUE_NUM_CALLBACKS]; }; @@ -116,12 +117,11 @@ _timeout_task_init(struct taskqueue *queue, struct tim } static __inline int -TQ_SLEEP(struct taskqueue *tq, void *p, struct mtx *m, int pri, const char *wm, - int t) +TQ_SLEEP(struct taskqueue *tq, void *p, const char *wm) { if (tq->tq_spin) - return (msleep_spin(p, m, wm, t)); - return (msleep(p, m, pri, wm, t)); + return (msleep_spin(p, (struct mtx *)&tq->tq_mutex, wm, 0)); + return (msleep(p, &tq->tq_mutex, 0, wm, 0)); } static struct taskqueue * @@ -145,7 +145,7 @@ _taskqueue_create(const char *name, int mflags, snprintf(tq_name, TASKQUEUE_NAMELEN, "%s", (name) ? name : "taskqueue"); STAILQ_INIT(&queue->tq_queue); - TAILQ_INIT(&queue->tq_active); + LIST_INIT(&queue->tq_active); queue->tq_enqueue = enqueue; queue->tq_context = context; queue->tq_name = tq_name; @@ -196,7 +196,7 @@ taskqueue_terminate(struct thread **pp, struct taskque while (tq->tq_tcount > 0 || tq->tq_callouts > 0) { wakeup(tq); - TQ_SLEEP(tq, pp, &tq->tq_mutex, PWAIT, "taskqueue_destroy", 0); + TQ_SLEEP(tq, pp, "tq_destroy"); } } @@ -207,7 +207,7 @@ taskqueue_free(struct taskqueue *queue) TQ_LOCK(queue); queue->tq_flags &= ~TQ_FLAGS_ACTIVE; taskqueue_terminate(queue->tq_threads, queue); - KASSERT(TAILQ_EMPTY(&queue->tq_active), ("Tasks still running?")); + KASSERT(LIST_EMPTY(&queue->tq_active), ("Tasks still running?")); KASSERT(queue->tq_callouts == 0, ("Armed timeout tasks")); mtx_destroy(&queue->tq_mutex); free(queue->tq_threads, M_TASKQUEUE); @@ -233,21 +233,30 @@ taskqueue_enqueue_locked(struct taskqueue *queue, stru } /* - * Optimise the case when all tasks have the same priority. + * Optimise cases when all tasks use small set of priorities. + * In case of only one priority we always insert at the end. + * In case of two tq_hint typically gives the insertion point. + * In case of more then two tq_hint should halve the search. */ prev = STAILQ_LAST(&queue->tq_queue, task, ta_link); if (!prev || prev->ta_priority >= task->ta_priority) { STAILQ_INSERT_TAIL(&queue->tq_queue, task, ta_link); } else { - prev = NULL; - for (ins = STAILQ_FIRST(&queue->tq_queue); ins; - prev = ins, ins = STAILQ_NEXT(ins, ta_link)) + prev = queue->tq_hint; + if (prev && prev->ta_priority >= task->ta_priority) { + ins = STAILQ_NEXT(prev, ta_link); + } else { + prev = NULL; + ins = STAILQ_FIRST(&queue->tq_queue); + } + for (; ins; prev = ins, ins = STAILQ_NEXT(ins, ta_link)) if (ins->ta_priority < task->ta_priority) break; - if (prev) + if (prev) { STAILQ_INSERT_AFTER(&queue->tq_queue, prev, task, ta_link); - else + queue->tq_hint = task; + } else STAILQ_INSERT_HEAD(&queue->tq_queue, task, ta_link); } @@ -364,6 +373,7 @@ taskqueue_drain_tq_queue(struct taskqueue *queue) */ TASK_INIT(&t_barrier, USHRT_MAX, taskqueue_task_nop_fn, &t_barrier); STAILQ_INSERT_TAIL(&queue->tq_queue, &t_barrier, ta_link); + queue->tq_hint = &t_barrier; t_barrier.ta_pending = 1; /* @@ -371,7 +381,7 @@ taskqueue_drain_tq_queue(struct taskqueue *queue) * have completed or are currently executing. */ while (t_barrier.ta_pending != 0) - TQ_SLEEP(queue, &t_barrier, &queue->tq_mutex, PWAIT, "-", 0); + TQ_SLEEP(queue, &t_barrier, "tq_qdrain"); return (1); } @@ -383,32 +393,25 @@ taskqueue_drain_tq_queue(struct taskqueue *queue) static int taskqueue_drain_tq_active(struct taskqueue *queue) { - struct taskqueue_busy tb_marker, *tb_first; + struct taskqueue_busy *tb; + u_int seq; - if (TAILQ_EMPTY(&queue->tq_active)) + if (LIST_EMPTY(&queue->tq_active)) return (0); /* Block taskq_terminate().*/ queue->tq_callouts++; - /* - * Wait for all currently executing taskqueue threads - * to go idle. - */ - tb_marker.tb_running = TB_DRAIN_WAITER; - TAILQ_INSERT_TAIL(&queue->tq_active, &tb_marker, tb_link); - while (TAILQ_FIRST(&queue->tq_active) != &tb_marker) - TQ_SLEEP(queue, &tb_marker, &queue->tq_mutex, PWAIT, "-", 0); - TAILQ_REMOVE(&queue->tq_active, &tb_marker, tb_link); + /* Wait for any active task with sequence from the past. */ + seq = queue->tq_seq; +restart: + LIST_FOREACH(tb, &queue->tq_active, tb_link) { + if ((int)(tb->tb_seq - seq) <= 0) { + TQ_SLEEP(queue, tb->tb_running, "tq_adrain"); + goto restart; + } + } - /* - * Wakeup any other drain waiter that happened to queue up - * without any intervening active thread. - */ - tb_first = TAILQ_FIRST(&queue->tq_active); - if (tb_first != NULL && tb_first->tb_running == TB_DRAIN_WAITER) - wakeup(tb_first); - /* Release taskqueue_terminate(). */ queue->tq_callouts--; if ((queue->tq_flags & TQ_FLAGS_ACTIVE) == 0) @@ -440,42 +443,31 @@ static void taskqueue_run_locked(struct taskqueue *queue) { struct taskqueue_busy tb; - struct taskqueue_busy *tb_first; struct task *task; int pending; KASSERT(queue != NULL, ("tq is NULL")); TQ_ASSERT_LOCKED(queue); tb.tb_running = NULL; + LIST_INSERT_HEAD(&queue->tq_active, &tb, tb_link); - while (STAILQ_FIRST(&queue->tq_queue)) { - TAILQ_INSERT_TAIL(&queue->tq_active, &tb, tb_link); - - /* - * Carefully remove the first task from the queue and - * zero its pending count. - */ - task = STAILQ_FIRST(&queue->tq_queue); - KASSERT(task != NULL, ("task is NULL")); + while ((task = STAILQ_FIRST(&queue->tq_queue)) != NULL) { STAILQ_REMOVE_HEAD(&queue->tq_queue, ta_link); + if (queue->tq_hint == task) + queue->tq_hint = NULL; pending = task->ta_pending; task->ta_pending = 0; tb.tb_running = task; + tb.tb_seq = ++queue->tq_seq; TQ_UNLOCK(queue); KASSERT(task->ta_func != NULL, ("task->ta_func is NULL")); task->ta_func(task->ta_context, pending); TQ_LOCK(queue); - tb.tb_running = NULL; wakeup(task); - - TAILQ_REMOVE(&queue->tq_active, &tb, tb_link); - tb_first = TAILQ_FIRST(&queue->tq_active); - if (tb_first != NULL && - tb_first->tb_running == TB_DRAIN_WAITER) - wakeup(tb_first); } + LIST_REMOVE(&tb, tb_link); } void @@ -493,7 +485,7 @@ task_is_running(struct taskqueue *queue, struct task * struct taskqueue_busy *tb; TQ_ASSERT_LOCKED(queue); - TAILQ_FOREACH(tb, &queue->tq_active, tb_link) { + LIST_FOREACH(tb, &queue->tq_active, tb_link) { if (tb->tb_running == task) return (1); } @@ -522,8 +514,11 @@ taskqueue_cancel_locked(struct taskqueue *queue, struc u_int *pendp) { - if (task->ta_pending > 0) + if (task->ta_pending > 0) { STAILQ_REMOVE(&queue->tq_queue, task, task, ta_link); + if (queue->tq_hint == task) + queue->tq_hint = NULL; + } if (pendp != NULL) *pendp = task->ta_pending; task->ta_pending = 0; @@ -572,7 +567,7 @@ taskqueue_drain(struct taskqueue *queue, struct task * TQ_LOCK(queue); while (task->ta_pending != 0 || task_is_running(queue, task)) - TQ_SLEEP(queue, task, &queue->tq_mutex, PWAIT, "-", 0); + TQ_SLEEP(queue, task, "tq_drain"); TQ_UNLOCK(queue); } @@ -778,7 +773,7 @@ taskqueue_thread_loop(void *arg) */ if ((tq->tq_flags & TQ_FLAGS_ACTIVE) == 0) break; - TQ_SLEEP(tq, tq, &tq->tq_mutex, 0, "-", 0); + TQ_SLEEP(tq, tq, "-"); } taskqueue_run_locked(tq); /* From owner-svn-src-stable@freebsd.org Wed Nov 6 17:59:19 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 12CEF1BBDE3; Wed, 6 Nov 2019 17:59:19 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 477Z6Z6nKSz4QZb; Wed, 6 Nov 2019 17:59:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CC3C4C8D; Wed, 6 Nov 2019 17:59:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA6HxIKi085065; Wed, 6 Nov 2019 17:59:18 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA6HxISr085064; Wed, 6 Nov 2019 17:59:18 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201911061759.xA6HxISr085064@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 6 Nov 2019 17:59:18 +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: r354404 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 354404 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.29 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, 06 Nov 2019 17:59:19 -0000 Author: mav Date: Wed Nov 6 17:59:18 2019 New Revision: 354404 URL: https://svnweb.freebsd.org/changeset/base/354404 Log: MFC r305368 (by markj): Micro-optimize sleepq_signal(). Lift a comparison out of the loop that finds the highest-priority thread on the queue. Modified: stable/11/sys/kern/subr_sleepqueue.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/subr_sleepqueue.c ============================================================================== --- stable/11/sys/kern/subr_sleepqueue.c Wed Nov 6 17:49:38 2019 (r354403) +++ stable/11/sys/kern/subr_sleepqueue.c Wed Nov 6 17:59:18 2019 (r354404) @@ -909,9 +909,9 @@ sleepq_signal(void *wchan, int flags, int pri, int que * been sleeping the longest since threads are always added to * the tail of sleep queues. */ - besttd = NULL; + besttd = TAILQ_FIRST(&sq->sq_blocked[queue]); TAILQ_FOREACH(td, &sq->sq_blocked[queue], td_slpq) { - if (besttd == NULL || td->td_priority < besttd->td_priority) + if (td->td_priority < besttd->td_priority) besttd = td; } MPASS(besttd != NULL); From owner-svn-src-stable@freebsd.org Wed Nov 6 18:02:21 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 26E941BC017; Wed, 6 Nov 2019 18:02:21 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 477ZB50FzRz4R0V; Wed, 6 Nov 2019 18:02:21 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E01B9E48; Wed, 6 Nov 2019 18:02:20 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA6I2KFX089725; Wed, 6 Nov 2019 18:02:20 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA6I2Jva089715; Wed, 6 Nov 2019 18:02:19 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201911061802.xA6I2Jva089715@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 6 Nov 2019 18:02: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: r354405 - in stable/11: share/man/man9 sys/kern sys/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/11: share/man/man9 sys/kern sys/sys X-SVN-Commit-Revision: 354405 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.29 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, 06 Nov 2019 18:02:21 -0000 Author: mav Date: Wed Nov 6 18:02:18 2019 New Revision: 354405 URL: https://svnweb.freebsd.org/changeset/base/354405 Log: MFC r349220: Add wakeup_any(), cheaper wakeup_one() for taskqueue(9). wakeup_one() and underlying sleepq_signal() spend additional time trying to be fair, waking thread with highest priority, sleeping longest time. But in case of taskqueue there are many absolutely identical threads, and any fairness between them is quite pointless. It makes even worse, since round-robin wakeups not only make previous CPU affinity in scheduler quite useless, but also hide from user chance to see CPU bottlenecks, when sequential workload with one request at a time looks evenly distributed between multiple threads. This change adds new SLEEPQ_UNFAIR flag to sleepq_signal(), making it wakeup thread that went to sleep last, but no longer in context switch (to avoid immediate spinning on the thread lock). On top of that new wakeup_any() function is added, equivalent to wakeup_one(), but setting the flag. On top of that taskqueue(9) is switchied to wakeup_any() to wakeup its threads. As result, on 72-core Xeon v4 machine sequential ZFS write to 12 ZVOLs with 16KB block size spend 34% less time in wakeup_any() and descendants then it was spending in wakeup_one(), and total write throughput increased by ~10% with the same as before CPU usage. Modified: stable/11/share/man/man9/Makefile stable/11/share/man/man9/sleep.9 stable/11/share/man/man9/sleepqueue.9 stable/11/sys/kern/kern_synch.c stable/11/sys/kern/subr_sleepqueue.c stable/11/sys/kern/subr_taskqueue.c stable/11/sys/sys/queue.h stable/11/sys/sys/sleepqueue.h stable/11/sys/sys/systm.h Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man9/Makefile ============================================================================== --- stable/11/share/man/man9/Makefile Wed Nov 6 17:59:18 2019 (r354404) +++ stable/11/share/man/man9/Makefile Wed Nov 6 18:02:18 2019 (r354405) @@ -1648,7 +1648,8 @@ MLINKS+=sleep.9 msleep.9 \ sleep.9 tsleep.9 \ sleep.9 tsleep_sbt.9 \ sleep.9 wakeup.9 \ - sleep.9 wakeup_one.9 + sleep.9 wakeup_one.9 \ + sleep.9 wakeup_any.9 MLINKS+=sleepqueue.9 init_sleepqueues.9 \ sleepqueue.9 sleepq_abort.9 \ sleepqueue.9 sleepq_add.9 \ Modified: stable/11/share/man/man9/sleep.9 ============================================================================== --- stable/11/share/man/man9/sleep.9 Wed Nov 6 17:59:18 2019 (r354404) +++ stable/11/share/man/man9/sleep.9 Wed Nov 6 18:02:18 2019 (r354405) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 4, 2018 +.Dd June 19, 2019 .Dt SLEEP 9 .Os .Sh NAME @@ -38,7 +38,9 @@ .Nm pause_sbt , .Nm tsleep , .Nm tsleep_sbt , -.Nm wakeup +.Nm wakeup , +.Nm wakeup_one , +.Nm wakeup_any .Nd wait for events .Sh SYNOPSIS .In sys/param.h @@ -70,6 +72,8 @@ .Fn wakeup "void *chan" .Ft void .Fn wakeup_one "void *chan" +.Ft void +.Fn wakeup_any "void *chan" .Sh DESCRIPTION The functions .Fn tsleep , @@ -79,8 +83,9 @@ The functions .Fn pause_sig , .Fn pause_sbt , .Fn wakeup , +.Fn wakeup_one , and -.Fn wakeup_one +.Fn wakeup_any handle event-based thread blocking. If a thread must wait for an external event, it is put to sleep by @@ -252,9 +257,10 @@ function is a wrapper around .Fn tsleep that suspends execution of the current thread for the indicated timeout. The thread can not be awakened early by signals or calls to -.Fn wakeup +.Fn wakeup , +.Fn wakeup_one or -.Fn wakeup_one . +.Fn wakeup_any . The .Fn pause_sig function is a variant of @@ -263,8 +269,8 @@ which can be awakened early by signals. .Pp The .Fn wakeup_one -function makes the first thread in the queue that is sleeping on the -parameter +function makes the first highest priority thread in the queue that is +sleeping on the parameter .Fa chan runnable. This reduces the load when a large number of threads are sleeping on @@ -292,6 +298,16 @@ to pay particular attention to ensure that no other threads wait on the same .Fa chan . +.Pp +The +.Fn wakeup_any +function is similar to +.Fn wakeup_one , +except that it makes runnable last thread on the queue (sleeping less), +ignoring fairness. +It can be used when threads sleeping on the +.Fa chan +are known to be identical and there is no reason to be fair. .Pp If the timeout given by .Fa timo Modified: stable/11/share/man/man9/sleepqueue.9 ============================================================================== --- stable/11/share/man/man9/sleepqueue.9 Wed Nov 6 17:59:18 2019 (r354404) +++ stable/11/share/man/man9/sleepqueue.9 Wed Nov 6 18:02:18 2019 (r354405) @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 22, 2014 +.Dd June 19, 2019 .Dt SLEEPQUEUE 9 .Os .Sh NAME @@ -291,7 +291,8 @@ and functions. The .Fn sleepq_signal -function awakens the highest priority thread sleeping on a wait channel while +function awakens the highest priority thread sleeping on a wait channel +(if SLEEPQ_UNFAIR flag is set, thread that went to sleep recently) while .Fn sleepq_broadcast awakens all of the threads sleeping on a wait channel. The Modified: stable/11/sys/kern/kern_synch.c ============================================================================== --- stable/11/sys/kern/kern_synch.c Wed Nov 6 17:59:18 2019 (r354404) +++ stable/11/sys/kern/kern_synch.c Wed Nov 6 18:02:18 2019 (r354405) @@ -369,6 +369,19 @@ wakeup_one(void *ident) kick_proc0(); } +void +wakeup_any(void *ident) +{ + int wakeup_swapper; + + sleepq_lock(ident); + wakeup_swapper = sleepq_signal(ident, SLEEPQ_SLEEP | SLEEPQ_UNFAIR, + 0, 0); + sleepq_release(ident); + if (wakeup_swapper) + kick_proc0(); +} + static void kdb_switch(void) { Modified: stable/11/sys/kern/subr_sleepqueue.c ============================================================================== --- stable/11/sys/kern/subr_sleepqueue.c Wed Nov 6 17:59:18 2019 (r354404) +++ stable/11/sys/kern/subr_sleepqueue.c Wed Nov 6 18:02:18 2019 (r354405) @@ -119,7 +119,7 @@ __FBSDID("$FreeBSD$"); * c - sleep queue chain lock */ struct sleepqueue { - TAILQ_HEAD(, thread) sq_blocked[NR_SLEEPQS]; /* (c) Blocked threads. */ + struct threadqueue sq_blocked[NR_SLEEPQS]; /* (c) Blocked threads. */ u_int sq_blockedcnt[NR_SLEEPQS]; /* (c) N. of blocked threads. */ LIST_ENTRY(sleepqueue) sq_hash; /* (c) Chain and free list. */ LIST_HEAD(, sleepqueue) sq_free; /* (c) Free queues. */ @@ -885,12 +885,14 @@ sleepq_init(void *mem, int size, int flags) } /* - * Find the highest priority thread sleeping on a wait channel and resume it. + * Find thread sleeping on a wait channel and resume it. */ int sleepq_signal(void *wchan, int flags, int pri, int queue) { + struct sleepqueue_chain *sc; struct sleepqueue *sq; + struct threadqueue *head; struct thread *td, *besttd; int wakeup_swapper; @@ -903,16 +905,33 @@ sleepq_signal(void *wchan, int flags, int pri, int que KASSERT(sq->sq_type == (flags & SLEEPQ_TYPE), ("%s: mismatch between sleep/wakeup and cv_*", __func__)); - /* - * Find the highest priority thread on the queue. If there is a - * tie, use the thread that first appears in the queue as it has - * been sleeping the longest since threads are always added to - * the tail of sleep queues. - */ - besttd = TAILQ_FIRST(&sq->sq_blocked[queue]); - TAILQ_FOREACH(td, &sq->sq_blocked[queue], td_slpq) { - if (td->td_priority < besttd->td_priority) + head = &sq->sq_blocked[queue]; + if (flags & SLEEPQ_UNFAIR) { + /* + * Find the most recently sleeping thread, but try to + * skip threads still in process of context switch to + * avoid spinning on the thread lock. + */ + sc = SC_LOOKUP(wchan); + besttd = TAILQ_LAST_FAST(head, thread, td_slpq); + while (besttd->td_lock != &sc->sc_lock) { + td = TAILQ_PREV_FAST(besttd, head, thread, td_slpq); + if (td == NULL) + break; besttd = td; + } + } else { + /* + * Find the highest priority thread on the queue. If there + * is a tie, use the thread that first appears in the queue + * as it has been sleeping the longest since threads are + * always added to the tail of sleep queues. + */ + besttd = td = TAILQ_FIRST(head); + while ((td = TAILQ_NEXT(td, td_slpq)) != NULL) { + if (td->td_priority < besttd->td_priority) + besttd = td; + } } MPASS(besttd != NULL); thread_lock(besttd); Modified: stable/11/sys/kern/subr_taskqueue.c ============================================================================== --- stable/11/sys/kern/subr_taskqueue.c Wed Nov 6 17:59:18 2019 (r354404) +++ stable/11/sys/kern/subr_taskqueue.c Wed Nov 6 18:02:18 2019 (r354405) @@ -802,7 +802,7 @@ taskqueue_thread_enqueue(void *context) tqp = context; tq = *tqp; - wakeup_one(tq); + wakeup_any(tq); } TASKQUEUE_DEFINE(swi, taskqueue_swi_enqueue, NULL, Modified: stable/11/sys/sys/queue.h ============================================================================== --- stable/11/sys/sys/queue.h Wed Nov 6 17:59:18 2019 (r354404) +++ stable/11/sys/sys/queue.h Wed Nov 6 18:02:18 2019 (r354405) @@ -760,6 +760,10 @@ struct { \ #define TAILQ_PREV(elm, headname, field) \ (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) +#define TAILQ_PREV_FAST(elm, head, type, field) \ + ((elm)->field.tqe_prev == &(head)->tqh_first ? NULL : \ + __containerof((elm)->field.tqe_prev, QUEUE_TYPEOF(type), field.tqe_next)) + #define TAILQ_REMOVE(head, elm, field) do { \ QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \ QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \ Modified: stable/11/sys/sys/sleepqueue.h ============================================================================== --- stable/11/sys/sys/sleepqueue.h Wed Nov 6 17:59:18 2019 (r354404) +++ stable/11/sys/sys/sleepqueue.h Wed Nov 6 18:02:18 2019 (r354405) @@ -83,6 +83,7 @@ struct thread; #define SLEEPQ_SX 0x03 /* Used by an sx lock. */ #define SLEEPQ_LK 0x04 /* Used by a lockmgr. */ #define SLEEPQ_INTERRUPTIBLE 0x100 /* Sleep is interruptible. */ +#define SLEEPQ_UNFAIR 0x200 /* Unfair wakeup order. */ void init_sleepqueues(void); int sleepq_abort(struct thread *td, int intrval); Modified: stable/11/sys/sys/systm.h ============================================================================== --- stable/11/sys/sys/systm.h Wed Nov 6 17:59:18 2019 (r354404) +++ stable/11/sys/sys/systm.h Wed Nov 6 18:02:18 2019 (r354405) @@ -422,6 +422,7 @@ int pause_sbt(const char *wmesg, sbintime_t sbt, sbint _sleep((chan), NULL, (pri), (wmesg), (bt), (pr), (flags)) void wakeup(void * chan); void wakeup_one(void * chan); +void wakeup_any(void * chan); /* * Common `struct cdev *' stuff are declared here to avoid #include poisoning From owner-svn-src-stable@freebsd.org Wed Nov 6 18:15:20 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BF9211BC668; Wed, 6 Nov 2019 18:15:20 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 477ZT45RtLz4SG0; Wed, 6 Nov 2019 18:15:20 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9E20C1076; Wed, 6 Nov 2019 18:15:20 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA6IFKZh001023; Wed, 6 Nov 2019 18:15:20 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA6IFKER001021; Wed, 6 Nov 2019 18:15:20 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201911061815.xA6IFKER001021@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 6 Nov 2019 18:15: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: r354406 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 354406 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.29 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, 06 Nov 2019 18:15:20 -0000 Author: mav Date: Wed Nov 6 18:15:20 2019 New Revision: 354406 URL: https://svnweb.freebsd.org/changeset/base/354406 Log: MFC r354241: Some more taskqueue optimizations. - Optimize enqueue for two task priority values by adding new tq_hint field, pointing to the last task inserted into the middle of the list. In case of more then two priority values it should halve average search. - Move tq_active insert/remove out of the taskqueue_run_locked loop. Instead of dirtying few shared cache lines per task introduce different mechanism to drain active tasks, based on task sequence number counter, that uses only cache lines already present in cache. Since the new mechanism does not need ordering, switch tq_active from TAILQ to LIST. - Move static and dynamic struct taskqueue fields into different cache lines. Move lock into its own cache line, so that heavy lock spinning by multiple waiting threads would not affect the running thread. - While there, correct some TQ_SLEEP() wait messages. This change fixes certain ZFS write workloads, causing huge congestion on taskqueue lock. Those workloads combine some large block writes to saturate the pool and trigger allocation throttling, which uses higher priority tasks to requeue the delayed I/Os, with many small blocks to generate deep queue of small tasks for taskqueue to sort. Sponsored by: iXsystems, Inc. Modified: stable/11/sys/kern/subr_gtaskqueue.c stable/11/sys/kern/subr_taskqueue.c Modified: stable/11/sys/kern/subr_gtaskqueue.c ============================================================================== --- stable/11/sys/kern/subr_gtaskqueue.c Wed Nov 6 18:02:18 2019 (r354405) +++ stable/11/sys/kern/subr_gtaskqueue.c Wed Nov 6 18:15:20 2019 (r354406) @@ -55,24 +55,24 @@ static void gtaskqueue_thread_loop(void *arg); TASKQGROUP_DEFINE(softirq, mp_ncpus, 1); struct gtaskqueue_busy { - struct gtask *tb_running; - TAILQ_ENTRY(gtaskqueue_busy) tb_link; + struct gtask *tb_running; + u_int tb_seq; + LIST_ENTRY(gtaskqueue_busy) tb_link; }; -static struct gtask * const TB_DRAIN_WAITER = (struct gtask *)0x1; - struct gtaskqueue { STAILQ_HEAD(, gtask) tq_queue; + LIST_HEAD(, gtaskqueue_busy) tq_active; + u_int tq_seq; + int tq_callouts; + struct mtx_padalign tq_mutex; gtaskqueue_enqueue_fn tq_enqueue; void *tq_context; char *tq_name; - TAILQ_HEAD(, gtaskqueue_busy) tq_active; - struct mtx tq_mutex; struct thread **tq_threads; int tq_tcount; int tq_spin; int tq_flags; - int tq_callouts; taskqueue_callback_fn tq_callbacks[TASKQUEUE_NUM_CALLBACKS]; void *tq_cb_contexts[TASKQUEUE_NUM_CALLBACKS]; }; @@ -111,12 +111,11 @@ gtask_dump(struct gtask *gtask) #endif static __inline int -TQ_SLEEP(struct gtaskqueue *tq, void *p, struct mtx *m, int pri, const char *wm, - int t) +TQ_SLEEP(struct gtaskqueue *tq, void *p, const char *wm) { if (tq->tq_spin) - return (msleep_spin(p, m, wm, t)); - return (msleep(p, m, pri, wm, t)); + return (msleep_spin(p, (struct mtx *)&tq->tq_mutex, wm, 0)); + return (msleep(p, &tq->tq_mutex, 0, wm, 0)); } static struct gtaskqueue * @@ -140,7 +139,7 @@ _gtaskqueue_create(const char *name, int mflags, } STAILQ_INIT(&queue->tq_queue); - TAILQ_INIT(&queue->tq_active); + LIST_INIT(&queue->tq_active); queue->tq_enqueue = enqueue; queue->tq_context = context; queue->tq_name = tq_name; @@ -163,7 +162,7 @@ gtaskqueue_terminate(struct thread **pp, struct gtaskq while (tq->tq_tcount > 0 || tq->tq_callouts > 0) { wakeup(tq); - TQ_SLEEP(tq, pp, &tq->tq_mutex, PWAIT, "taskqueue_destroy", 0); + TQ_SLEEP(tq, pp, "gtq_destroy"); } } @@ -174,7 +173,7 @@ gtaskqueue_free(struct gtaskqueue *queue) TQ_LOCK(queue); queue->tq_flags &= ~TQ_FLAGS_ACTIVE; gtaskqueue_terminate(queue->tq_threads, queue); - KASSERT(TAILQ_EMPTY(&queue->tq_active), ("Tasks still running?")); + KASSERT(LIST_EMPTY(&queue->tq_active), ("Tasks still running?")); KASSERT(queue->tq_callouts == 0, ("Armed timeout tasks")); mtx_destroy(&queue->tq_mutex); free(queue->tq_threads, M_GTASKQUEUE); @@ -239,7 +238,7 @@ gtaskqueue_drain_tq_queue(struct gtaskqueue *queue) * have completed or are currently executing. */ while (t_barrier.ta_flags & TASK_ENQUEUED) - TQ_SLEEP(queue, &t_barrier, &queue->tq_mutex, PWAIT, "-", 0); + TQ_SLEEP(queue, &t_barrier, "gtq_qdrain"); } /* @@ -250,32 +249,25 @@ gtaskqueue_drain_tq_queue(struct gtaskqueue *queue) static void gtaskqueue_drain_tq_active(struct gtaskqueue *queue) { - struct gtaskqueue_busy tb_marker, *tb_first; + struct gtaskqueue_busy *tb; + u_int seq; - if (TAILQ_EMPTY(&queue->tq_active)) + if (LIST_EMPTY(&queue->tq_active)) return; /* Block taskq_terminate().*/ queue->tq_callouts++; - /* - * Wait for all currently executing taskqueue threads - * to go idle. - */ - tb_marker.tb_running = TB_DRAIN_WAITER; - TAILQ_INSERT_TAIL(&queue->tq_active, &tb_marker, tb_link); - while (TAILQ_FIRST(&queue->tq_active) != &tb_marker) - TQ_SLEEP(queue, &tb_marker, &queue->tq_mutex, PWAIT, "-", 0); - TAILQ_REMOVE(&queue->tq_active, &tb_marker, tb_link); + /* Wait for any active task with sequence from the past. */ + seq = queue->tq_seq; +restart: + LIST_FOREACH(tb, &queue->tq_active, tb_link) { + if ((int)(tb->tb_seq - seq) <= 0) { + TQ_SLEEP(queue, tb->tb_running, "gtq_adrain"); + goto restart; + } + } - /* - * Wakeup any other drain waiter that happened to queue up - * without any intervening active thread. - */ - tb_first = TAILQ_FIRST(&queue->tq_active); - if (tb_first != NULL && tb_first->tb_running == TB_DRAIN_WAITER) - wakeup(tb_first); - /* Release taskqueue_terminate(). */ queue->tq_callouts--; if ((queue->tq_flags & TQ_FLAGS_ACTIVE) == 0) @@ -306,40 +298,27 @@ static void gtaskqueue_run_locked(struct gtaskqueue *queue) { struct gtaskqueue_busy tb; - struct gtaskqueue_busy *tb_first; struct gtask *gtask; KASSERT(queue != NULL, ("tq is NULL")); TQ_ASSERT_LOCKED(queue); tb.tb_running = NULL; + LIST_INSERT_HEAD(&queue->tq_active, &tb, tb_link); - while (STAILQ_FIRST(&queue->tq_queue)) { - TAILQ_INSERT_TAIL(&queue->tq_active, &tb, tb_link); - - /* - * Carefully remove the first task from the queue and - * clear its TASK_ENQUEUED flag - */ - gtask = STAILQ_FIRST(&queue->tq_queue); - KASSERT(gtask != NULL, ("task is NULL")); + while ((gtask = STAILQ_FIRST(&queue->tq_queue)) != NULL) { STAILQ_REMOVE_HEAD(&queue->tq_queue, ta_link); gtask->ta_flags &= ~TASK_ENQUEUED; tb.tb_running = gtask; + tb.tb_seq = ++queue->tq_seq; TQ_UNLOCK(queue); KASSERT(gtask->ta_func != NULL, ("task->ta_func is NULL")); gtask->ta_func(gtask->ta_context); TQ_LOCK(queue); - tb.tb_running = NULL; wakeup(gtask); - - TAILQ_REMOVE(&queue->tq_active, &tb, tb_link); - tb_first = TAILQ_FIRST(&queue->tq_active); - if (tb_first != NULL && - tb_first->tb_running == TB_DRAIN_WAITER) - wakeup(tb_first); } + LIST_REMOVE(&tb, tb_link); } static int @@ -348,7 +327,7 @@ task_is_running(struct gtaskqueue *queue, struct gtask struct gtaskqueue_busy *tb; TQ_ASSERT_LOCKED(queue); - TAILQ_FOREACH(tb, &queue->tq_active, tb_link) { + LIST_FOREACH(tb, &queue->tq_active, tb_link) { if (tb->tb_running == gtask) return (1); } @@ -386,7 +365,7 @@ gtaskqueue_drain(struct gtaskqueue *queue, struct gtas TQ_LOCK(queue); while ((gtask->ta_flags & TASK_ENQUEUED) || task_is_running(queue, gtask)) - TQ_SLEEP(queue, gtask, &queue->tq_mutex, PWAIT, "-", 0); + TQ_SLEEP(queue, gtask, "gtq_drain"); TQ_UNLOCK(queue); } @@ -511,7 +490,7 @@ gtaskqueue_thread_loop(void *arg) */ if ((tq->tq_flags & TQ_FLAGS_ACTIVE) == 0) break; - TQ_SLEEP(tq, tq, &tq->tq_mutex, 0, "-", 0); + TQ_SLEEP(tq, tq, "-"); } gtaskqueue_run_locked(tq); /* @@ -537,7 +516,7 @@ gtaskqueue_thread_enqueue(void *context) tqp = context; tq = *tqp; - wakeup_one(tq); + wakeup_any(tq); } Modified: stable/11/sys/kern/subr_taskqueue.c ============================================================================== --- stable/11/sys/kern/subr_taskqueue.c Wed Nov 6 18:02:18 2019 (r354405) +++ stable/11/sys/kern/subr_taskqueue.c Wed Nov 6 18:15:20 2019 (r354406) @@ -54,24 +54,25 @@ static void taskqueue_swi_enqueue(void *); static void taskqueue_swi_giant_enqueue(void *); struct taskqueue_busy { - struct task *tb_running; - TAILQ_ENTRY(taskqueue_busy) tb_link; + struct task *tb_running; + u_int tb_seq; + LIST_ENTRY(taskqueue_busy) tb_link; }; -struct task * const TB_DRAIN_WAITER = (struct task *)0x1; - struct taskqueue { STAILQ_HEAD(, task) tq_queue; + LIST_HEAD(, taskqueue_busy) tq_active; + struct task *tq_hint; + u_int tq_seq; + int tq_callouts; + struct mtx_padalign tq_mutex; taskqueue_enqueue_fn tq_enqueue; void *tq_context; char *tq_name; - TAILQ_HEAD(, taskqueue_busy) tq_active; - struct mtx tq_mutex; struct thread **tq_threads; int tq_tcount; int tq_spin; int tq_flags; - int tq_callouts; taskqueue_callback_fn tq_callbacks[TASKQUEUE_NUM_CALLBACKS]; void *tq_cb_contexts[TASKQUEUE_NUM_CALLBACKS]; }; @@ -114,12 +115,11 @@ _timeout_task_init(struct taskqueue *queue, struct tim } static __inline int -TQ_SLEEP(struct taskqueue *tq, void *p, struct mtx *m, int pri, const char *wm, - int t) +TQ_SLEEP(struct taskqueue *tq, void *p, const char *wm) { if (tq->tq_spin) - return (msleep_spin(p, m, wm, t)); - return (msleep(p, m, pri, wm, t)); + return (msleep_spin(p, (struct mtx *)&tq->tq_mutex, wm, 0)); + return (msleep(p, &tq->tq_mutex, 0, wm, 0)); } static struct taskqueue * @@ -143,7 +143,7 @@ _taskqueue_create(const char *name, int mflags, snprintf(tq_name, TASKQUEUE_NAMELEN, "%s", (name) ? name : "taskqueue"); STAILQ_INIT(&queue->tq_queue); - TAILQ_INIT(&queue->tq_active); + LIST_INIT(&queue->tq_active); queue->tq_enqueue = enqueue; queue->tq_context = context; queue->tq_name = tq_name; @@ -194,7 +194,7 @@ taskqueue_terminate(struct thread **pp, struct taskque while (tq->tq_tcount > 0 || tq->tq_callouts > 0) { wakeup(tq); - TQ_SLEEP(tq, pp, &tq->tq_mutex, PWAIT, "taskqueue_destroy", 0); + TQ_SLEEP(tq, pp, "tq_destroy"); } } @@ -205,7 +205,7 @@ taskqueue_free(struct taskqueue *queue) TQ_LOCK(queue); queue->tq_flags &= ~TQ_FLAGS_ACTIVE; taskqueue_terminate(queue->tq_threads, queue); - KASSERT(TAILQ_EMPTY(&queue->tq_active), ("Tasks still running?")); + KASSERT(LIST_EMPTY(&queue->tq_active), ("Tasks still running?")); KASSERT(queue->tq_callouts == 0, ("Armed timeout tasks")); mtx_destroy(&queue->tq_mutex); free(queue->tq_threads, M_TASKQUEUE); @@ -231,21 +231,30 @@ taskqueue_enqueue_locked(struct taskqueue *queue, stru } /* - * Optimise the case when all tasks have the same priority. + * Optimise cases when all tasks use small set of priorities. + * In case of only one priority we always insert at the end. + * In case of two tq_hint typically gives the insertion point. + * In case of more then two tq_hint should halve the search. */ prev = STAILQ_LAST(&queue->tq_queue, task, ta_link); if (!prev || prev->ta_priority >= task->ta_priority) { STAILQ_INSERT_TAIL(&queue->tq_queue, task, ta_link); } else { - prev = NULL; - for (ins = STAILQ_FIRST(&queue->tq_queue); ins; - prev = ins, ins = STAILQ_NEXT(ins, ta_link)) + prev = queue->tq_hint; + if (prev && prev->ta_priority >= task->ta_priority) { + ins = STAILQ_NEXT(prev, ta_link); + } else { + prev = NULL; + ins = STAILQ_FIRST(&queue->tq_queue); + } + for (; ins; prev = ins, ins = STAILQ_NEXT(ins, ta_link)) if (ins->ta_priority < task->ta_priority) break; - if (prev) + if (prev) { STAILQ_INSERT_AFTER(&queue->tq_queue, prev, task, ta_link); - else + queue->tq_hint = task; + } else STAILQ_INSERT_HEAD(&queue->tq_queue, task, ta_link); } @@ -362,6 +371,7 @@ taskqueue_drain_tq_queue(struct taskqueue *queue) */ TASK_INIT(&t_barrier, USHRT_MAX, taskqueue_task_nop_fn, &t_barrier); STAILQ_INSERT_TAIL(&queue->tq_queue, &t_barrier, ta_link); + queue->tq_hint = &t_barrier; t_barrier.ta_pending = 1; /* @@ -369,7 +379,7 @@ taskqueue_drain_tq_queue(struct taskqueue *queue) * have completed or are currently executing. */ while (t_barrier.ta_pending != 0) - TQ_SLEEP(queue, &t_barrier, &queue->tq_mutex, PWAIT, "-", 0); + TQ_SLEEP(queue, &t_barrier, "tq_qdrain"); return (1); } @@ -381,32 +391,25 @@ taskqueue_drain_tq_queue(struct taskqueue *queue) static int taskqueue_drain_tq_active(struct taskqueue *queue) { - struct taskqueue_busy tb_marker, *tb_first; + struct taskqueue_busy *tb; + u_int seq; - if (TAILQ_EMPTY(&queue->tq_active)) + if (LIST_EMPTY(&queue->tq_active)) return (0); /* Block taskq_terminate().*/ queue->tq_callouts++; - /* - * Wait for all currently executing taskqueue threads - * to go idle. - */ - tb_marker.tb_running = TB_DRAIN_WAITER; - TAILQ_INSERT_TAIL(&queue->tq_active, &tb_marker, tb_link); - while (TAILQ_FIRST(&queue->tq_active) != &tb_marker) - TQ_SLEEP(queue, &tb_marker, &queue->tq_mutex, PWAIT, "-", 0); - TAILQ_REMOVE(&queue->tq_active, &tb_marker, tb_link); + /* Wait for any active task with sequence from the past. */ + seq = queue->tq_seq; +restart: + LIST_FOREACH(tb, &queue->tq_active, tb_link) { + if ((int)(tb->tb_seq - seq) <= 0) { + TQ_SLEEP(queue, tb->tb_running, "tq_adrain"); + goto restart; + } + } - /* - * Wakeup any other drain waiter that happened to queue up - * without any intervening active thread. - */ - tb_first = TAILQ_FIRST(&queue->tq_active); - if (tb_first != NULL && tb_first->tb_running == TB_DRAIN_WAITER) - wakeup(tb_first); - /* Release taskqueue_terminate(). */ queue->tq_callouts--; if ((queue->tq_flags & TQ_FLAGS_ACTIVE) == 0) @@ -438,42 +441,31 @@ static void taskqueue_run_locked(struct taskqueue *queue) { struct taskqueue_busy tb; - struct taskqueue_busy *tb_first; struct task *task; int pending; KASSERT(queue != NULL, ("tq is NULL")); TQ_ASSERT_LOCKED(queue); tb.tb_running = NULL; + LIST_INSERT_HEAD(&queue->tq_active, &tb, tb_link); - while (STAILQ_FIRST(&queue->tq_queue)) { - TAILQ_INSERT_TAIL(&queue->tq_active, &tb, tb_link); - - /* - * Carefully remove the first task from the queue and - * zero its pending count. - */ - task = STAILQ_FIRST(&queue->tq_queue); - KASSERT(task != NULL, ("task is NULL")); + while ((task = STAILQ_FIRST(&queue->tq_queue)) != NULL) { STAILQ_REMOVE_HEAD(&queue->tq_queue, ta_link); + if (queue->tq_hint == task) + queue->tq_hint = NULL; pending = task->ta_pending; task->ta_pending = 0; tb.tb_running = task; + tb.tb_seq = ++queue->tq_seq; TQ_UNLOCK(queue); KASSERT(task->ta_func != NULL, ("task->ta_func is NULL")); task->ta_func(task->ta_context, pending); TQ_LOCK(queue); - tb.tb_running = NULL; wakeup(task); - - TAILQ_REMOVE(&queue->tq_active, &tb, tb_link); - tb_first = TAILQ_FIRST(&queue->tq_active); - if (tb_first != NULL && - tb_first->tb_running == TB_DRAIN_WAITER) - wakeup(tb_first); } + LIST_REMOVE(&tb, tb_link); } void @@ -491,7 +483,7 @@ task_is_running(struct taskqueue *queue, struct task * struct taskqueue_busy *tb; TQ_ASSERT_LOCKED(queue); - TAILQ_FOREACH(tb, &queue->tq_active, tb_link) { + LIST_FOREACH(tb, &queue->tq_active, tb_link) { if (tb->tb_running == task) return (1); } @@ -520,8 +512,11 @@ taskqueue_cancel_locked(struct taskqueue *queue, struc u_int *pendp) { - if (task->ta_pending > 0) + if (task->ta_pending > 0) { STAILQ_REMOVE(&queue->tq_queue, task, task, ta_link); + if (queue->tq_hint == task) + queue->tq_hint = NULL; + } if (pendp != NULL) *pendp = task->ta_pending; task->ta_pending = 0; @@ -570,7 +565,7 @@ taskqueue_drain(struct taskqueue *queue, struct task * TQ_LOCK(queue); while (task->ta_pending != 0 || task_is_running(queue, task)) - TQ_SLEEP(queue, task, &queue->tq_mutex, PWAIT, "-", 0); + TQ_SLEEP(queue, task, "tq_drain"); TQ_UNLOCK(queue); } @@ -776,7 +771,7 @@ taskqueue_thread_loop(void *arg) */ if ((tq->tq_flags & TQ_FLAGS_ACTIVE) == 0) break; - TQ_SLEEP(tq, tq, &tq->tq_mutex, 0, "-", 0); + TQ_SLEEP(tq, tq, "-"); } taskqueue_run_locked(tq); /* From owner-svn-src-stable@freebsd.org Thu Nov 7 00:14:26 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DBBF517D633; Thu, 7 Nov 2019 00:14:26 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "vps1.elischer.org", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 477kRQ5NYKz3LJ1; Thu, 7 Nov 2019 00:14:26 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from Julian-MBP3.local (c-73-225-95-104.hsd1.wa.comcast.net [73.225.95.104]) (authenticated bits=0) by vps1.elischer.org (8.15.2/8.15.2) with ESMTPSA id xA70EMe8083790 (version=TLSv1.2 cipher=AES128-SHA bits=128 verify=NO); Wed, 6 Nov 2019 16:14:24 -0800 (PST) (envelope-from julian@freebsd.org) Subject: Re: svn commit: r354393 - stable/10 To: Warner Losh , Glen Barber Cc: "Rodney W. Grimes" , Warner Losh , src-committers , svn-src-all , svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org, FreeBSD Release Engineering Team References: <201911061434.xA6EYFBF058593@repo.freebsd.org> <201911061706.xA6H6OSW010908@gndrsh.dnsmgr.net> <20191106172315.GI1424@FreeBSD.org> From: Julian Elischer Message-ID: Date: Wed, 6 Nov 2019 16:14:14 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Rspamd-Queue-Id: 477kRQ5NYKz3LJ1 X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-1.93 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-0.93)[-0.931,0]; ASN(0.00)[asn:36236, ipnet:204.109.60.0/22, country:US]; NEURAL_HAM_LONG(-1.00)[-0.999,0] Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 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, 07 Nov 2019 00:14:26 -0000 On 11/6/19 9:29 AM, Warner Losh wrote: > > > On Wed, Nov 6, 2019 at 10:23 AM Glen Barber > wrote: > > On Wed, Nov 06, 2019 at 09:06:24AM -0800, Rodney W. Grimes wrote: > > > Author: imp > > > Date: Wed Nov  6 14:34:14 2019 > > > New Revision: 354393 > > > URL: https://svnweb.freebsd.org/changeset/base/354393 > > > > > > Log: > > >   Replace current with stable/10 > > > > > >   Direct commit because not relevant to other branches > > > > Glen, > > > > Would you add this to the list of RE@ things to do when a > > new branch is created? > > > That's a great idea... Thanks Rod. > > It is in the document already, but I still somehow missed it. > > > There's a lot on this list, so that's understandable... > > Maybe it's something we should enshrine in a shell script? > > Warner I am a tremendous believer of such scripts. Firstly it can save time, but more importantly it embodies learned procedures and is authoritative. If a shell script worked prviously and doesn't work now, you know something changed. From owner-svn-src-stable@freebsd.org Thu Nov 7 00:28:50 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C281617DDFB; Thu, 7 Nov 2019 00:28:50 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 477km24lQcz3MBQ; Thu, 7 Nov 2019 00:28:50 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 860BF56B1; Thu, 7 Nov 2019 00:28:50 +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 xA70SoSG023940; Thu, 7 Nov 2019 00:28:50 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA70So0i023939; Thu, 7 Nov 2019 00:28:50 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201911070028.xA70So0i023939@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Thu, 7 Nov 2019 00:28:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354424 - stable/12/sys/netgraph X-SVN-Group: stable-12 X-SVN-Commit-Author: glebius X-SVN-Commit-Paths: stable/12/sys/netgraph X-SVN-Commit-Revision: 354424 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.29 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, 07 Nov 2019 00:28:50 -0000 Author: glebius Date: Thu Nov 7 00:28:50 2019 New Revision: 354424 URL: https://svnweb.freebsd.org/changeset/base/354424 Log: Merge r353027: Protect access to seq->xwin[] with the seq mutex. Modified: stable/12/sys/netgraph/ng_l2tp.c Modified: stable/12/sys/netgraph/ng_l2tp.c ============================================================================== --- stable/12/sys/netgraph/ng_l2tp.c Thu Nov 7 00:27:23 2019 (r354423) +++ stable/12/sys/netgraph/ng_l2tp.c Thu Nov 7 00:28:50 2019 (r354424) @@ -1462,6 +1462,7 @@ ng_l2tp_seq_rack_timeout(node_p node, hook_p hook, voi /* Sanity check */ L2TP_SEQ_CHECK(seq); + mtx_lock(&seq->mtx); priv->stats.xmitRetransmits++; /* Have we reached the retransmit limit? If so, notify owner. */ @@ -1482,7 +1483,9 @@ ng_l2tp_seq_rack_timeout(node_p node, hook_p hook, voi seq->acks = 0; /* Retransmit oldest unack'd packet */ - if ((m = L2TP_COPY_MBUF(seq->xwin[0], M_NOWAIT)) == NULL) + m = L2TP_COPY_MBUF(seq->xwin[0], M_NOWAIT); + mtx_unlock(&seq->mtx); + if (m == NULL) priv->stats.memoryFailures++; else ng_l2tp_xmit_ctrl(priv, m, seq->ns++); From owner-svn-src-stable@freebsd.org Thu Nov 7 07:09:11 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 931971A9B76; Thu, 7 Nov 2019 07:09:11 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 477vdz3JmCz4CLv; Thu, 7 Nov 2019 07:09:11 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3C1279F71; Thu, 7 Nov 2019 07:09:11 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA779BYd059979; Thu, 7 Nov 2019 07:09:11 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA779BC2059978; Thu, 7 Nov 2019 07:09:11 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911070709.xA779BC2059978@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 7 Nov 2019 07:09:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354430 - stable/12/sys/dev/nctgpio X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/sys/dev/nctgpio X-SVN-Commit-Revision: 354430 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.29 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, 07 Nov 2019 07:09:11 -0000 Author: avg Date: Thu Nov 7 07:09:10 2019 New Revision: 354430 URL: https://svnweb.freebsd.org/changeset/base/354430 Log: MFC r353643: move nctgpio to superio(4) bus Modified: stable/12/sys/dev/nctgpio/nctgpio.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/nctgpio/nctgpio.c ============================================================================== --- stable/12/sys/dev/nctgpio/nctgpio.c Thu Nov 7 06:59:09 2019 (r354429) +++ stable/12/sys/dev/nctgpio/nctgpio.c Thu Nov 7 07:09:10 2019 (r354430) @@ -42,34 +42,20 @@ #include #include -#include #include -#include - #include -#include #include +#include #include "gpio_if.h" -/* - * Global configuration registers (CR). - */ -#define NCT_CR_LDN 0x07 /* Logical Device Number */ -#define NCT_CR_CHIP_ID 0x20 /* Chip ID */ -#define NCT_CR_CHIP_ID_H 0x20 /* Chip ID (high byte) */ -#define NCT_CR_CHIP_ID_L 0x21 /* Chip ID (low byte) */ -#define NCT_CR_OPT_1 0x26 /* Global Options (1) */ - /* Logical Device Numbers. */ #define NCT_LDN_GPIO 0x07 -#define NCT_LDN_GPIO_CFG 0x08 #define NCT_LDN_GPIO_MODE 0x0f /* Logical Device 7 */ -#define NCT_LD7_GPIO_ENABLE 0x30 #define NCT_LD7_GPIO0_IOR 0xe0 #define NCT_LD7_GPIO0_DAT 0xe1 #define NCT_LD7_GPIO0_INV 0xe2 @@ -83,8 +69,6 @@ #define NCT_LDF_GPIO0_OUTCFG 0xe0 #define NCT_LDF_GPIO1_OUTCFG 0xe1 -#define NCT_EXTFUNC_ENTER 0x87 -#define NCT_EXTFUNC_EXIT 0xaa #define NCT_MAX_PIN 15 #define NCT_IS_VALID_PIN(_p) ((_p) >= 0 && (_p) <= NCT_MAX_PIN) @@ -97,10 +81,9 @@ struct nct_softc { device_t dev; + device_t dev_f; device_t busdev; struct mtx mtx; - struct resource *portres; - int rid; struct gpio_pin pins[NCT_MAX_PIN + 1]; }; @@ -112,22 +95,6 @@ struct nct_softc { #define GPIO_ASSERT_LOCKED(_sc) mtx_assert(&(_sc)->mtx, MA_OWNED) #define GPIO_ASSERT_UNLOCKED(_sc) mtx_assert(&(_sc)->mtx, MA_NOTOWNED) -#define NCT_BARRIER_WRITE(_sc) \ - bus_barrier((_sc)->portres, 0, 2, BUS_SPACE_BARRIER_WRITE) - -#define NCT_BARRIER_READ_WRITE(_sc) \ - bus_barrier((_sc)->portres, 0, 2, \ - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE) - -static void ext_cfg_enter(struct nct_softc *); -static void ext_cfg_exit(struct nct_softc *); - -/* - * Potential Extended Function Enable Register addresses. - * Same address as EFIR. - */ -uint8_t probe_addrs[] = {0x2e, 0x4e}; - struct nuvoton_vendor_device_id { uint16_t chip_id; const char * descr; @@ -146,77 +113,7 @@ struct nuvoton_vendor_device_id { }, }; -static void -write_cfg_reg_1(struct nct_softc *sc, uint8_t reg, uint8_t value) -{ - GPIO_ASSERT_LOCKED(sc); - bus_write_1(sc->portres, 0, reg); - NCT_BARRIER_WRITE(sc); - bus_write_1(sc->portres, 1, value); - NCT_BARRIER_WRITE(sc); -} - -static uint8_t -read_cfg_reg_1(struct nct_softc *sc, uint8_t reg) -{ - uint8_t value; - - GPIO_ASSERT_LOCKED(sc); - bus_write_1(sc->portres, 0, reg); - NCT_BARRIER_READ_WRITE(sc); - value = bus_read_1(sc->portres, 1); - NCT_BARRIER_READ_WRITE(sc); - - return (value); -} - -static uint16_t -read_cfg_reg_2(struct nct_softc *sc, uint8_t reg) -{ - uint16_t value; - - value = read_cfg_reg_1(sc, reg) << 8; - value |= read_cfg_reg_1(sc, reg + 1); - - return (value); -} - /* - * Enable extended function mode. - * - */ -static void -ext_cfg_enter(struct nct_softc *sc) -{ - GPIO_ASSERT_LOCKED(sc); - bus_write_1(sc->portres, 0, NCT_EXTFUNC_ENTER); - NCT_BARRIER_WRITE(sc); - bus_write_1(sc->portres, 0, NCT_EXTFUNC_ENTER); - NCT_BARRIER_WRITE(sc); -} - -/* - * Disable extended function mode. - * - */ -static void -ext_cfg_exit(struct nct_softc *sc) -{ - GPIO_ASSERT_LOCKED(sc); - bus_write_1(sc->portres, 0, NCT_EXTFUNC_EXIT); - NCT_BARRIER_WRITE(sc); -} - -/* - * Select a Logical Device. - */ -static void -select_ldn(struct nct_softc *sc, uint8_t ldn) -{ - write_cfg_reg_1(sc, NCT_CR_LDN, ldn); -} - -/* * Get the GPIO Input/Output register address * for a pin. */ @@ -289,10 +186,9 @@ nct_set_pin_is_output(struct nct_softc *sc, uint32_t p uint8_t ior; reg = nct_ior_addr(pin_num); - select_ldn(sc, NCT_LDN_GPIO); - ior = read_cfg_reg_1(sc, reg); + ior = superio_read(sc->dev, reg); ior &= ~(NCT_PIN_BIT(pin_num)); - write_cfg_reg_1(sc, reg, ior); + superio_write(sc->dev, reg, ior); } /* @@ -305,10 +201,9 @@ nct_set_pin_is_input(struct nct_softc *sc, uint32_t pi uint8_t ior; reg = nct_ior_addr(pin_num); - select_ldn(sc, NCT_LDN_GPIO); - ior = read_cfg_reg_1(sc, reg); + ior = superio_read(sc->dev, reg); ior |= NCT_PIN_BIT(pin_num); - write_cfg_reg_1(sc, reg, ior); + superio_write(sc->dev, reg, ior); } /* @@ -321,8 +216,7 @@ nct_pin_is_input(struct nct_softc *sc, uint32_t pin_nu uint8_t ior; reg = nct_ior_addr(pin_num); - select_ldn(sc, NCT_LDN_GPIO); - ior = read_cfg_reg_1(sc, reg); + ior = superio_read(sc->dev, reg); return (ior & NCT_PIN_BIT(pin_num)); } @@ -337,14 +231,13 @@ nct_write_pin(struct nct_softc *sc, uint32_t pin_num, uint8_t value; reg = nct_dat_addr(pin_num); - select_ldn(sc, NCT_LDN_GPIO); - value = read_cfg_reg_1(sc, reg); + value = superio_read(sc->dev, reg); if (data) value |= NCT_PIN_BIT(pin_num); else value &= ~(NCT_PIN_BIT(pin_num)); - write_cfg_reg_1(sc, reg, value); + superio_write(sc->dev, reg, value); } static bool @@ -353,9 +246,8 @@ nct_read_pin(struct nct_softc *sc, uint32_t pin_num) uint8_t reg; reg = nct_dat_addr(pin_num); - select_ldn(sc, NCT_LDN_GPIO); - return (read_cfg_reg_1(sc, reg) & NCT_PIN_BIT(pin_num)); + return (superio_read(sc->dev, reg) & NCT_PIN_BIT(pin_num)); } static void @@ -365,10 +257,9 @@ nct_set_pin_is_inverted(struct nct_softc *sc, uint32_t uint8_t inv; reg = nct_inv_addr(pin_num); - select_ldn(sc, NCT_LDN_GPIO); - inv = read_cfg_reg_1(sc, reg); + inv = superio_read(sc->dev, reg); inv |= (NCT_PIN_BIT(pin_num)); - write_cfg_reg_1(sc, reg, inv); + superio_write(sc->dev, reg, inv); } static void @@ -378,10 +269,9 @@ nct_set_pin_not_inverted(struct nct_softc *sc, uint32_ uint8_t inv; reg = nct_inv_addr(pin_num); - select_ldn(sc, NCT_LDN_GPIO); - inv = read_cfg_reg_1(sc, reg); + inv = superio_read(sc->dev, reg); inv &= ~(NCT_PIN_BIT(pin_num)); - write_cfg_reg_1(sc, reg, inv); + superio_write(sc->dev, reg, inv); } static bool @@ -391,8 +281,7 @@ nct_pin_is_inverted(struct nct_softc *sc, uint32_t pin uint8_t inv; reg = nct_inv_addr(pin_num); - select_ldn(sc, NCT_LDN_GPIO); - inv = read_cfg_reg_1(sc, reg); + inv = superio_read(sc->dev, reg); return (inv & NCT_PIN_BIT(pin_num)); } @@ -404,10 +293,9 @@ nct_set_pin_opendrain(struct nct_softc *sc, uint32_t p uint8_t outcfg; reg = nct_outcfg_addr(pin_num); - select_ldn(sc, NCT_LDN_GPIO_MODE); - outcfg = read_cfg_reg_1(sc, reg); - outcfg |= (NCT_PIN_BIT(pin_num)); - write_cfg_reg_1(sc, reg, outcfg); + outcfg = superio_read(sc->dev_f, reg); + outcfg |= NCT_PIN_BIT(pin_num); + superio_write(sc->dev_f, reg, outcfg); } static void @@ -417,10 +305,9 @@ nct_set_pin_pushpull(struct nct_softc *sc, uint32_t pi uint8_t outcfg; reg = nct_outcfg_addr(pin_num); - select_ldn(sc, NCT_LDN_GPIO_MODE); - outcfg = read_cfg_reg_1(sc, reg); - outcfg &= ~(NCT_PIN_BIT(pin_num)); - write_cfg_reg_1(sc, reg, outcfg); + outcfg = superio_read(sc->dev_f, reg); + outcfg &= ~NCT_PIN_BIT(pin_num); + superio_write(sc->dev_f, reg, outcfg); } static bool @@ -430,66 +317,33 @@ nct_pin_is_opendrain(struct nct_softc *sc, uint32_t pi uint8_t outcfg; reg = nct_outcfg_addr(pin_num); - select_ldn(sc, NCT_LDN_GPIO_MODE); - outcfg = read_cfg_reg_1(sc, reg); - + outcfg = superio_read(sc->dev_f, reg); return (outcfg & NCT_PIN_BIT(pin_num)); } -static void -nct_identify(driver_t *driver, device_t parent) -{ - if (device_find_child(parent, driver->name, 0) != NULL) - return; - - BUS_ADD_CHILD(parent, 0, driver->name, 0); -} - static int nct_probe(device_t dev) { - int i, j; - int rc; - struct nct_softc *sc; + int j; uint16_t chipid; - /* Make sure we do not claim some ISA PNP device. */ - if (isa_get_logicalid(dev) != 0) + if (superio_vendor(dev) != SUPERIO_VENDOR_NUVOTON) return (ENXIO); + if (superio_get_type(dev) != SUPERIO_DEV_GPIO) + return (ENXIO); - sc = device_get_softc(dev); + /* + * There are several GPIO devices, we attach only to one of them + * and use the rest without attaching. + */ + if (superio_get_ldn(dev) != NCT_LDN_GPIO) + return (ENXIO); - for (i = 0; i < nitems(probe_addrs); i++) { - sc->rid = 0; - sc->portres = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->rid, - probe_addrs[i], probe_addrs[i] + 1, 2, RF_ACTIVE); - if (sc->portres == NULL) - continue; - - GPIO_LOCK_INIT(sc); - - GPIO_ASSERT_UNLOCKED(sc); - GPIO_LOCK(sc); - ext_cfg_enter(sc); - chipid = read_cfg_reg_2(sc, NCT_CR_CHIP_ID); - ext_cfg_exit(sc); - GPIO_UNLOCK(sc); - - GPIO_LOCK_DESTROY(sc); - - bus_release_resource(dev, SYS_RES_IOPORT, sc->rid, sc->portres); - bus_delete_resource(dev, SYS_RES_IOPORT, sc->rid); - - for (j = 0; j < nitems(nct_devs); j++) { - if (chipid == nct_devs[j].chip_id) { - rc = bus_set_resource(dev, SYS_RES_IOPORT, 0, probe_addrs[i], 2); - if (rc != 0) { - device_printf(dev, "bus_set_resource failed for address 0x%02X\n", probe_addrs[i]); - continue; - } - device_set_desc(dev, nct_devs[j].descr); - return (BUS_PROBE_DEFAULT); - } + chipid = superio_devid(dev); + for (j = 0; j < nitems(nct_devs); j++) { + if (chipid == nct_devs[j].chip_id) { + device_set_desc(dev, "Nuvoton GPIO controller"); + return (BUS_PROBE_DEFAULT); } } return (ENXIO); @@ -502,24 +356,19 @@ nct_attach(device_t dev) int i; sc = device_get_softc(dev); - - sc->rid = 0; - sc->portres = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->rid, - 0ul, ~0ul, 2, RF_ACTIVE); - if (sc->portres == NULL) { - device_printf(dev, "cannot allocate ioport\n"); + sc->dev = dev; + sc->dev_f = superio_find_dev(device_get_parent(dev), SUPERIO_DEV_GPIO, + NCT_LDN_GPIO_MODE); + if (sc->dev_f == NULL) { + device_printf(dev, "failed to find LDN F\n"); return (ENXIO); } - GPIO_LOCK_INIT(sc); + /* Enable gpio0 and gpio1. */ + superio_dev_enable(dev, 0x03); - GPIO_ASSERT_UNLOCKED(sc); + GPIO_LOCK_INIT(sc); GPIO_LOCK(sc); - ext_cfg_enter(sc); - select_ldn(sc, NCT_LDN_GPIO); - /* Enable gpio0 and gpio1. */ - write_cfg_reg_1(sc, NCT_LD7_GPIO_ENABLE, - read_cfg_reg_1(sc, NCT_LD7_GPIO_ENABLE) | 0x03); for (i = 0; i <= NCT_MAX_PIN; i++) { struct gpio_pin *pin; @@ -550,12 +399,7 @@ nct_attach(device_t dev) sc->busdev = gpiobus_attach_bus(dev); if (sc->busdev == NULL) { GPIO_ASSERT_UNLOCKED(sc); - GPIO_LOCK(sc); - ext_cfg_exit(sc); - GPIO_UNLOCK(sc); - bus_release_resource(dev, SYS_RES_IOPORT, sc->rid, sc->portres); GPIO_LOCK_DESTROY(sc); - return (ENXIO); } @@ -571,13 +415,6 @@ nct_detach(device_t dev) gpiobus_detach_bus(dev); GPIO_ASSERT_UNLOCKED(sc); - GPIO_LOCK(sc); - ext_cfg_exit(sc); - GPIO_UNLOCK(sc); - - /* Cleanup resources. */ - bus_release_resource(dev, SYS_RES_IOPORT, sc->rid, sc->portres); - GPIO_LOCK_DESTROY(sc); return (0); @@ -775,26 +612,25 @@ nct_gpio_pin_setflags(device_t dev, uint32_t pin_num, static device_method_t nct_methods[] = { /* Device interface */ - DEVMETHOD(device_identify, nct_identify), DEVMETHOD(device_probe, nct_probe), DEVMETHOD(device_attach, nct_attach), DEVMETHOD(device_detach, nct_detach), /* GPIO */ - DEVMETHOD(gpio_get_bus, nct_gpio_get_bus), - DEVMETHOD(gpio_pin_max, nct_gpio_pin_max), - DEVMETHOD(gpio_pin_get, nct_gpio_pin_get), - DEVMETHOD(gpio_pin_set, nct_gpio_pin_set), - DEVMETHOD(gpio_pin_toggle, nct_gpio_pin_toggle), - DEVMETHOD(gpio_pin_getname, nct_gpio_pin_getname), - DEVMETHOD(gpio_pin_getcaps, nct_gpio_pin_getcaps), + DEVMETHOD(gpio_get_bus, nct_gpio_get_bus), + DEVMETHOD(gpio_pin_max, nct_gpio_pin_max), + DEVMETHOD(gpio_pin_get, nct_gpio_pin_get), + DEVMETHOD(gpio_pin_set, nct_gpio_pin_set), + DEVMETHOD(gpio_pin_toggle, nct_gpio_pin_toggle), + DEVMETHOD(gpio_pin_getname, nct_gpio_pin_getname), + DEVMETHOD(gpio_pin_getcaps, nct_gpio_pin_getcaps), DEVMETHOD(gpio_pin_getflags, nct_gpio_pin_getflags), DEVMETHOD(gpio_pin_setflags, nct_gpio_pin_setflags), DEVMETHOD_END }; -static driver_t nct_isa_driver = { +static driver_t nct_driver = { "gpio", nct_methods, sizeof(struct nct_softc) @@ -802,5 +638,8 @@ static driver_t nct_isa_driver = { static devclass_t nct_devclass; -DRIVER_MODULE(nctgpio, isa, nct_isa_driver, nct_devclass, NULL, NULL); +DRIVER_MODULE(nctgpio, superio, nct_driver, nct_devclass, NULL, NULL); MODULE_DEPEND(nctgpio, gpiobus, 1, 1, 1); +MODULE_DEPEND(nctgpio, superio, 1, 1, 1); +MODULE_VERSION(nctgpio, 1); + From owner-svn-src-stable@freebsd.org Thu Nov 7 07:15:02 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B61481A9ED6; Thu, 7 Nov 2019 07:15:02 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 477vmk55t5z4Cxy; Thu, 7 Nov 2019 07:15:02 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 783F1A145; Thu, 7 Nov 2019 07:15:02 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA77F2hP066149; Thu, 7 Nov 2019 07:15:02 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA77F2Uo066148; Thu, 7 Nov 2019 07:15:02 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911070715.xA77F2Uo066148@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 7 Nov 2019 07:15:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354432 - in stable/12: share/man/man4 sys/dev/wbwd X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in stable/12: share/man/man4 sys/dev/wbwd X-SVN-Commit-Revision: 354432 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.29 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, 07 Nov 2019 07:15:02 -0000 Author: avg Date: Thu Nov 7 07:15:01 2019 New Revision: 354432 URL: https://svnweb.freebsd.org/changeset/base/354432 Log: MFC r353645,r353677: wbwd: move to superio(4) bus Plus related small clean-ups and improvements. Modified: stable/12/share/man/man4/wbwd.4 stable/12/sys/dev/wbwd/wbwd.c Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/wbwd.4 ============================================================================== --- stable/12/share/man/man4/wbwd.4 Thu Nov 7 07:09:28 2019 (r354431) +++ stable/12/share/man/man4/wbwd.4 Thu Nov 7 07:15:01 2019 (r354432) @@ -25,16 +25,17 @@ .\" .\" $FreeBSD$ .\" -.Dd March 24, 2016 +.Dd October 16, 2019 .Dt WBWD 4 .Os .Sh NAME .Nm wbwd .Nd device driver for Winbond/Nuvoton Super I/O chips watchdog timer .Sh SYNOPSIS -To compile this driver into the kernel, place the following line in your +To compile this driver into the kernel, place the following lines in your kernel configuration file: .Bd -ragged -offset indent +.Cd "device superio" .Cd "device wbwd" .Ed .Pp @@ -91,10 +92,6 @@ Nuvoton NCT6791 .It Nuvoton NCT6792 .El -.Pp -Driver may be forced to attach to unknown chips by adding to -.Pa /boot/device.hints : -.Cd hint.wbwd.0.at="isa" .Sh SYSCTL VARIABLES The .Nm @@ -130,6 +127,7 @@ The driver also provides further sysctl options that are hidden by default. See the source code for more information. .Sh SEE ALSO +.Xr superio 4 .Xr watchdog 4 , .Xr device.hints 5 , .Xr watchdog 8 , Modified: stable/12/sys/dev/wbwd/wbwd.c ============================================================================== --- stable/12/sys/dev/wbwd/wbwd.c Thu Nov 7 07:09:28 2019 (r354431) +++ stable/12/sys/dev/wbwd/wbwd.c Thu Nov 7 07:15:01 2019 (r354432) @@ -47,14 +47,12 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include -#include #include #include #include -#include +#include #include #include @@ -101,13 +99,7 @@ enum chips { w83627hf, w83627s, w83697hf, w83697ug, w8 struct wb_softc { device_t dev; - struct resource *portres; - bus_space_tag_t bst; - bus_space_handle_t bsh; - int rid; eventhandler_tag ev_tag; - int (*ext_cfg_enter_f)(struct wb_softc *, u_short); - void (*ext_cfg_exit_f)(struct wb_softc *, u_short); enum chips chip; uint8_t ctl_reg; uint8_t time_reg; @@ -132,26 +124,6 @@ struct wb_softc { uint8_t reg_2; }; -static int ext_cfg_enter_0x87_0x87(struct wb_softc *, u_short); -static void ext_cfg_exit_0xaa(struct wb_softc *, u_short); - -struct winbond_superio_cfg { - uint8_t efer; /* and efir */ - int (*ext_cfg_enter_f)(struct wb_softc *, u_short); - void (*ext_cfg_exit_f)(struct wb_softc *, u_short); -} probe_addrs[] = { - { - .efer = 0x2e, - .ext_cfg_enter_f = ext_cfg_enter_0x87_0x87, - .ext_cfg_exit_f = ext_cfg_exit_0xaa, - }, - { - .efer = 0x4e, - .ext_cfg_enter_f = ext_cfg_enter_0x87_0x87, - .ext_cfg_exit_f = ext_cfg_exit_0xaa, - }, -}; - struct winbond_vendor_device_id { uint8_t device_id; enum chips chip; @@ -264,66 +236,7 @@ struct winbond_vendor_device_id { }, }; -static void -write_efir_1(struct wb_softc *sc, u_short baseport, uint8_t value) -{ - MPASS(sc != NULL || baseport != 0); - if (sc != NULL) - bus_space_write_1((sc)->bst, (sc)->bsh, 0, (value)); - else - outb(baseport, value); -} - -static uint8_t __unused -read_efir_1(struct wb_softc *sc, u_short baseport) -{ - - MPASS(sc != NULL || baseport != 0); - if (sc != NULL) - return (bus_space_read_1((sc)->bst, (sc)->bsh, 0)); - else - return (inb(baseport)); -} - -static void -write_efdr_1(struct wb_softc *sc, u_short baseport, uint8_t value) -{ - - MPASS(sc != NULL || baseport != 0); - if (sc != NULL) - bus_space_write_1((sc)->bst, (sc)->bsh, 1, (value)); - else - outb(baseport + 1, value); -} - -static uint8_t -read_efdr_1(struct wb_softc *sc, u_short baseport) -{ - - MPASS(sc != NULL || baseport != 0); - if (sc != NULL) - return (bus_space_read_1((sc)->bst, (sc)->bsh, 1)); - else - return (inb(baseport + 1)); -} - -static void -write_reg(struct wb_softc *sc, uint8_t reg, uint8_t value) -{ - - write_efir_1(sc, 0, reg); - write_efdr_1(sc, 0, value); -} - -static uint8_t -read_reg(struct wb_softc *sc, uint8_t reg) -{ - - write_efir_1(sc, 0, reg); - return (read_efdr_1(sc, 0)); -} - /* * Return the watchdog related registers as we last read them. This will * usually not give the current timeout or state on whether the watchdog @@ -362,18 +275,10 @@ sysctl_wb_debug_current(SYSCTL_HANDLER_ARGS) sc = arg1; - if ((*sc->ext_cfg_enter_f)(sc, 0) != 0) - return (ENXIO); + sc->reg_1 = superio_read(sc->dev, sc->ctl_reg); + sc->reg_timeout = superio_read(sc->dev, sc->time_reg); + sc->reg_2 = superio_read(sc->dev, sc->csr_reg); - /* Watchdog is configured as part of LDN 8 (GPIO Port2, Watchdog). */ - write_reg(sc, WB_LDN_REG, WB_LDN_REG_LDN8); - - sc->reg_1 = read_reg(sc, sc->ctl_reg); - sc->reg_timeout = read_reg(sc, sc->time_reg); - sc->reg_2 = read_reg(sc, sc->csr_reg); - - (*sc->ext_cfg_exit_f)(sc, 0); - return (sysctl_wb_debug(oidp, arg1, arg2, req)); } @@ -411,12 +316,7 @@ sysctl_wb_force_test_nmi(SYSCTL_HANDLER_ARGS) sc->test_nmi = 0; return (0); } -#endif - if ((*sc->ext_cfg_enter_f)(sc, 0) != 0) - return (ENXIO); - -#ifdef notyet /* * If we are testing the NMI functionality, set the flag before * forcing the timeout. @@ -425,16 +325,11 @@ sysctl_wb_force_test_nmi(SYSCTL_HANDLER_ARGS) sc->test_nmi = 1; #endif - /* Watchdog is configured as part of LDN 8 (GPIO Port2, Watchdog). */ - write_reg(sc, WB_LDN_REG, WB_LDN_REG_LDN8); - /* Force watchdog to fire. */ - sc->reg_2 = read_reg(sc, sc->csr_reg); + sc->reg_2 = superio_read(sc->dev, sc->csr_reg); sc->reg_2 |= WB_LDN8_CRF7_FORCE; - write_reg(sc, sc->csr_reg, sc->reg_2); + superio_write(sc->dev, sc->csr_reg, sc->reg_2); - (*sc->ext_cfg_exit_f)(sc, 0); - return (0); } @@ -450,7 +345,7 @@ wb_print_state(struct wb_softc *sc, const char *msg) device_printf(sc->dev, "%s%sWatchdog %sabled. %s" "Scaling by %ds, timer at %d (%s=%ds%s). " - "CRF5 0x%02x CRF7 0x%02x\n", + "CR%02X 0x%02x CR%02X 0x%02x\n", (msg != NULL) ? msg : "", (msg != NULL) ? ": " : "", (sc->reg_timeout > 0x00) ? "en" : "dis", (sc->reg_2 & WB_LDN8_CRF7_TS) ? "Watchdog fired. " : "", @@ -459,35 +354,10 @@ wb_print_state(struct wb_softc *sc, const char *msg) (sc->reg_timeout > 0x00) ? "<" : "", sc->reg_timeout * ((sc->reg_1 & WB_LDN8_CRF5_SCALE) ? 60 : 1), (sc->reg_timeout > 0x00) ? " left" : "", - sc->reg_1, sc->reg_2); + sc->ctl_reg, sc->reg_1, sc->csr_reg, sc->reg_2); } /* - * Functions to enter and exit extended function mode. Possibly shared - * between different chips. - */ -static int -ext_cfg_enter_0x87_0x87(struct wb_softc *sc, u_short baseport) -{ - - /* - * Enable extended function mode. - * Winbond does not allow us to validate so always return success. - */ - write_efir_1(sc, baseport, 0x87); - write_efir_1(sc, baseport, 0x87); - - return (0); -} - -static void -ext_cfg_exit_0xaa(struct wb_softc *sc, u_short baseport) -{ - - write_efir_1(sc, baseport, 0xaa); -} - -/* * (Re)load the watchdog counter depending on timeout. A timeout of 0 will * disable the watchdog. */ @@ -511,20 +381,14 @@ wb_set_watchdog(struct wb_softc *sc, unsigned int time if (sc->debug_verbose) wb_print_state(sc, "Before watchdog counter (re)load"); - if ((*sc->ext_cfg_enter_f)(sc, 0) != 0) - return (ENXIO); - - /* Watchdog is configured as part of LDN 8 (GPIO Port2, Watchdog) */ - write_reg(sc, WB_LDN_REG, WB_LDN_REG_LDN8); - if (timeout == 0) { /* Disable watchdog. */ sc->reg_timeout = 0; - write_reg(sc, sc->time_reg, sc->reg_timeout); + superio_write(sc->dev, sc->time_reg, sc->reg_timeout); } else { /* Read current scaling factor. */ - sc->reg_1 = read_reg(sc, sc->ctl_reg); + sc->reg_1 = superio_read(sc->dev, sc->ctl_reg); if (timeout > 255) { /* Set scaling factor to 60s. */ @@ -539,21 +403,19 @@ wb_set_watchdog(struct wb_softc *sc, unsigned int time } /* In case we fired before we need to clear to fire again. */ - sc->reg_2 = read_reg(sc, sc->csr_reg); + sc->reg_2 = superio_read(sc->dev, sc->csr_reg); if (sc->reg_2 & WB_LDN8_CRF7_TS) { sc->reg_2 &= ~WB_LDN8_CRF7_TS; - write_reg(sc, sc->csr_reg, sc->reg_2); + superio_write(sc->dev, sc->csr_reg, sc->reg_2); } /* Write back scaling factor. */ - write_reg(sc, sc->ctl_reg, sc->reg_1); + superio_write(sc->dev, sc->ctl_reg, sc->reg_1); /* Set timer and arm/reset the watchdog. */ - write_reg(sc, sc->time_reg, sc->reg_timeout); + superio_write(sc->dev, sc->time_reg, sc->reg_timeout); } - (*sc->ext_cfg_exit_f)(sc, 0); - if (sc->debug_verbose) wb_print_state(sc, "After watchdog counter (re)load"); return (0); @@ -599,217 +461,110 @@ wb_watchdog_fn(void *private, u_int cmd, int *error) } } -/* - * Probe/attach the Winbond Super I/O chip. - * - * Initial abstraction to possibly support more chips: - * - Iterate over the well known base ports, try to enable extended function - * mode and read and match the device ID and device revision. Unfortunately - * the Vendor ID is in the hardware monitoring section accessible by different - * base ports only. - * - Also HEFRAS, which would tell use the base port, is only accessible after - * entering extended function mode, for which the base port is needed. - * At least check HEFRAS to match the current base port we are probing. - * - On match set the description, remember functions to enter/exit extended - * function mode as well as the base port. - */ static int -wb_probe_enable(device_t dev, int probe) +wb_probe(device_t dev) { - struct wb_softc *sc; - int error, found, i, j; - uint8_t dev_id, dev_rev, cr26; char buf[128]; + struct wb_softc *sc; + int j; + uint8_t devid; + uint8_t revid; - if (dev == NULL) - sc = NULL; - else { - sc = device_get_softc(dev); - bzero(sc, sizeof(*sc)); - sc->dev = dev; - } + if (superio_vendor(dev) != SUPERIO_VENDOR_NUVOTON) + return (ENXIO); + if (superio_get_type(dev) != SUPERIO_DEV_WDT) + return (ENXIO); - error = ENXIO; - found = 0; - for (i = 0; i < nitems(probe_addrs); i++) { - - if (sc != NULL) { - /* Allocate bus resources for IO index/data register access. */ - sc->portres = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->rid, - probe_addrs[i].efer, probe_addrs[i].efer + 1, 2, RF_ACTIVE); - if (sc->portres == NULL) - continue; - sc->bst = rman_get_bustag(sc->portres); - sc->bsh = rman_get_bushandle(sc->portres); - } - - error = (*probe_addrs[i].ext_cfg_enter_f)(sc, probe_addrs[i].efer); - if (error != 0) - goto cleanup; - - /* Identify the SuperIO chip. */ - write_efir_1(sc, probe_addrs[i].efer, WB_DEVICE_ID_REG); - dev_id = read_efdr_1(sc, probe_addrs[i].efer); - write_efir_1(sc, probe_addrs[i].efer, WB_DEVICE_REV_REG); - dev_rev = read_efdr_1(sc, probe_addrs[i].efer); - write_efir_1(sc, probe_addrs[i].efer, WB_CR26); - cr26 = read_efdr_1(sc, probe_addrs[i].efer); - - if (dev_id == 0xff && dev_rev == 0xff) - goto cleanup; - - /* HEFRAS of 0 means EFER at 0x2e, 1 means EFER at 0x4e. */ - if (((cr26 & 0x40) == 0x00 && probe_addrs[i].efer != 0x2e) || - ((cr26 & 0x40) == 0x40 && probe_addrs[i].efer != 0x4e)) { - if (dev != NULL) - device_printf(dev, "HEFRAS and EFER do not " - "align: EFER 0x%02x DevID 0x%02x DevRev " - "0x%02x CR26 0x%02x\n", - probe_addrs[i].efer, dev_id, dev_rev, cr26); - goto cleanup; - } - - for (j = 0; j < nitems(wb_devs); j++) { - if (wb_devs[j].device_id == dev_id) { - found = 1; - break; - } - } - - if (probe && dev != NULL) { + sc = device_get_softc(dev); + devid = superio_devid(dev) >> 8; + revid = superio_revid(dev); + for (j = 0; j < nitems(wb_devs); j++) { + if (wb_devs[j].device_id == devid) { + sc->chip = wb_devs[j].chip; snprintf(buf, sizeof(buf), "%s (0x%02x/0x%02x) Watchdog Timer", - found ? wb_devs[j].descr : - "Unknown Winbond/Nuvoton", dev_id, dev_rev); + wb_devs[j].descr, devid, revid); device_set_desc_copy(dev, buf); - } - - /* If this is hinted attach, try to guess the model. */ - if (dev != NULL && !found) { - found = 1; - j = 0; - } - -cleanup: - if (probe || !found) { - (*probe_addrs[i].ext_cfg_exit_f)(sc, probe_addrs[i].efer); - if (sc != NULL) - (void) bus_release_resource(dev, SYS_RES_IOPORT, - sc->rid, sc->portres); - } - - /* - * Stop probing if have successfully identified the SuperIO. - * Remember the extended function mode enter/exit functions - * for operations. - */ - if (found) { - if (sc != NULL) { - sc->ext_cfg_enter_f = probe_addrs[i].ext_cfg_enter_f; - sc->ext_cfg_exit_f = probe_addrs[i].ext_cfg_exit_f; - sc->chip = wb_devs[j].chip; - sc->ctl_reg = 0xf5; - sc->time_reg = 0xf6; - sc->csr_reg = 0xf7; - if (sc->chip == w83697hf || - sc->chip == w83697ug) { - sc->ctl_reg = 0xf3; - sc->time_reg = 0xf4; - } else if (sc->chip == nct6102) { - sc->ctl_reg = 0xf0; - sc->time_reg = 0xf1; - sc->csr_reg = 0xf2; - } - } return (BUS_PROBE_SPECIFIC); - } else - error = ENXIO; + } } - - return (error); -} - -static void -wb_identify(driver_t *driver, device_t parent) -{ - - if (device_find_child(parent, driver->name, 0) == NULL) { - if (wb_probe_enable(NULL, 1) <= 0) - BUS_ADD_CHILD(parent, 0, driver->name, 0); + if (bootverbose) { + device_printf(dev, + "unrecognized chip: devid 0x%02x, revid 0x%02x\n", + devid, revid); } + return (ENXIO); } static int -wb_probe(device_t dev) -{ - - /* Make sure we do not claim some ISA PNP device. */ - if (isa_get_logicalid(dev) != 0) - return (ENXIO); - - return (wb_probe_enable(dev, 1)); -} - -static int wb_attach(device_t dev) { struct wb_softc *sc; struct sysctl_ctx_list *sctx; struct sysctl_oid *soid; unsigned long timeout; - int error; uint8_t t; - error = wb_probe_enable(dev, 0); - if (error > 0) - return (ENXIO); - sc = device_get_softc(dev); - KASSERT(sc->ext_cfg_enter_f != NULL && sc->ext_cfg_exit_f != NULL, - ("%s: successful probe result but not setup correctly", __func__)); + sc->dev = dev; - /* Watchdog is configured as part of LDN 8 (GPIO Port2, Watchdog). */ - write_reg(sc, WB_LDN_REG, WB_LDN_REG_LDN8); - /* Make sure WDT is enabled. */ - write_reg(sc, WB_LDN8_CR30, - read_reg(sc, WB_LDN8_CR30) | WB_LDN8_CR30_ACTIVE); + superio_dev_enable(dev, WB_LDN8_CR30_ACTIVE); switch (sc->chip) { + case w83697hf: + case w83697ug: + sc->ctl_reg = 0xf3; + sc->time_reg = 0xf4; + sc->csr_reg = 0xf7; + break; + case nct6102: + sc->ctl_reg = 0xf0; + sc->time_reg = 0xf1; + sc->csr_reg = 0xf2; + break; + default: + sc->ctl_reg = 0xf5; + sc->time_reg = 0xf6; + sc->csr_reg = 0xf7; + break; + } + + switch (sc->chip) { case w83627hf: case w83627s: - t = read_reg(sc, 0x2B) & ~0x10; - write_reg(sc, 0x2B, t); /* set GPIO24 to WDT0 */ + t = superio_read(dev, 0x2B) & ~0x10; + superio_write(dev, 0x2B, t); /* set GPIO24 to WDT0 */ break; case w83697hf: /* Set pin 119 to WDTO# mode (= CR29, WDT0) */ - t = read_reg(sc, 0x29) & ~0x60; + t = superio_read(dev, 0x29) & ~0x60; t |= 0x20; - write_reg(sc, 0x29, t); + superio_write(dev, 0x29, t); break; case w83697ug: /* Set pin 118 to WDTO# mode */ - t = read_reg(sc, 0x2b) & ~0x04; - write_reg(sc, 0x2b, t); + t = superio_read(dev, 0x2b) & ~0x04; + superio_write(dev, 0x2b, t); break; case w83627thf: - t = (read_reg(sc, 0x2B) & ~0x08) | 0x04; - write_reg(sc, 0x2B, t); /* set GPIO3 to WDT0 */ + t = (superio_read(dev, 0x2B) & ~0x08) | 0x04; + superio_write(dev, 0x2B, t); /* set GPIO3 to WDT0 */ break; case w83627dhg: case w83627dhg_p: - t = read_reg(sc, 0x2D) & ~0x01; /* PIN77 -> WDT0# */ - write_reg(sc, 0x2D, t); /* set GPIO5 to WDT0 */ - t = read_reg(sc, sc->ctl_reg); + t = superio_read(dev, 0x2D) & ~0x01; /* PIN77 -> WDT0# */ + superio_write(dev, 0x2D, t); /* set GPIO5 to WDT0 */ + t = superio_read(dev, sc->ctl_reg); t |= 0x02; /* enable the WDTO# output low pulse * to the KBRST# pin */ - write_reg(sc, sc->ctl_reg, t); + superio_write(dev, sc->ctl_reg, t); break; case w83637hf: break; case w83687thf: - t = read_reg(sc, 0x2C) & ~0x80; /* PIN47 -> WDT0# */ - write_reg(sc, 0x2C, t); + t = superio_read(dev, 0x2C) & ~0x80; /* PIN47 -> WDT0# */ + superio_write(dev, 0x2C, t); break; case w83627ehf: case w83627uhg: @@ -829,19 +584,19 @@ wb_attach(device_t dev) * Don't touch its configuration, and hope the BIOS * does the right thing. */ - t = read_reg(sc, sc->ctl_reg); + t = superio_read(dev, sc->ctl_reg); t |= 0x02; /* enable the WDTO# output low pulse * to the KBRST# pin */ - write_reg(sc, sc->ctl_reg, t); + superio_write(dev, sc->ctl_reg, t); break; default: break; } /* Read the current watchdog configuration. */ - sc->reg_1 = read_reg(sc, sc->ctl_reg); - sc->reg_timeout = read_reg(sc, sc->time_reg); - sc->reg_2 = read_reg(sc, sc->csr_reg); + sc->reg_1 = superio_read(dev, sc->ctl_reg); + sc->reg_timeout = superio_read(dev, sc->time_reg); + sc->reg_2 = superio_read(dev, sc->csr_reg); /* Print current state if bootverbose or watchdog already enabled. */ if (bootverbose || (sc->reg_timeout > 0x00)) @@ -849,7 +604,7 @@ wb_attach(device_t dev) sc->reg_1 &= ~WB_LDN8_CRF5_KEYB_P20; sc->reg_1 |= WB_LDN8_CRF5_KBRST; - write_reg(sc, sc->ctl_reg, sc->reg_1); + superio_write(dev, sc->ctl_reg, sc->reg_1); /* * Clear a previous watchdog timeout event (if still set). @@ -857,10 +612,8 @@ wb_attach(device_t dev) * since one of my boards is getting stuck in reboot without it. */ sc->reg_2 &= ~(WB_LDN8_CRF7_MOUSE|WB_LDN8_CRF7_TS); - write_reg(sc, sc->csr_reg, sc->reg_2); + superio_write(dev, sc->csr_reg, sc->reg_2); - (*sc->ext_cfg_exit_f)(sc, 0); - /* Read global timeout override tunable, Add per device sysctls. */ if (TUNABLE_ULONG_FETCH("hw.wbwd.timeout_override", &timeout)) { if (timeout > 0) @@ -907,12 +660,6 @@ wb_detach(device_t dev) EVENTHANDLER_DEREGISTER(watchdog_list, sc->ev_tag); wb_set_watchdog(sc, 0); - /* Disable extended function mode. */ - (*sc->ext_cfg_exit_f)(sc, 0); - - /* Cleanup resources. */ - (void) bus_release_resource(dev, SYS_RES_IOPORT, sc->rid, sc->portres); - /* Bus subroutines take care of sysctls already. */ return (0); @@ -920,7 +667,6 @@ wb_detach(device_t dev) static device_method_t wb_methods[] = { /* Device interface */ - DEVMETHOD(device_identify, wb_identify), DEVMETHOD(device_probe, wb_probe), DEVMETHOD(device_attach, wb_attach), DEVMETHOD(device_detach, wb_detach), @@ -928,7 +674,7 @@ static device_method_t wb_methods[] = { DEVMETHOD_END }; -static driver_t wb_isa_driver = { +static driver_t wb_driver = { "wbwd", wb_methods, sizeof(struct wb_softc) @@ -936,4 +682,6 @@ static driver_t wb_isa_driver = { static devclass_t wb_devclass; -DRIVER_MODULE(wb, isa, wb_isa_driver, wb_devclass, NULL, NULL); +DRIVER_MODULE(wb, superio, wb_driver, wb_devclass, NULL, NULL); +MODULE_DEPEND(wb, superio, 1, 1, 1); +MODULE_VERSION(wb, 1); From owner-svn-src-stable@freebsd.org Thu Nov 7 07:21:46 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 402A71AA0AB; Thu, 7 Nov 2019 07:21:46 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 477vwV0wglz4Dgl; Thu, 7 Nov 2019 07:21:46 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 039F0A2CA; Thu, 7 Nov 2019 07:21:46 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA77Ljxk068836; Thu, 7 Nov 2019 07:21:45 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA77LjoB068835; Thu, 7 Nov 2019 07:21:45 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911070721.xA77LjoB068835@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 7 Nov 2019 07:21:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354434 - stable/12 X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12 X-SVN-Commit-Revision: 354434 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.29 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, 07 Nov 2019 07:21:46 -0000 Author: avg Date: Thu Nov 7 07:21:45 2019 New Revision: 354434 URL: https://svnweb.freebsd.org/changeset/base/354434 Log: add a note about nctgpio and wbwd move to superio Modified: stable/12/UPDATING Modified: stable/12/UPDATING ============================================================================== --- stable/12/UPDATING Thu Nov 7 07:21:23 2019 (r354433) +++ stable/12/UPDATING Thu Nov 7 07:21:45 2019 (r354434) @@ -16,6 +16,13 @@ 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. +20191107: + The nctgpio and wbwd drivers have been moved to the superio bus. + If you have one of these drivers in a kernel configuration, then + you should add device superio to it. If you use one of these drivers + as a module and you compile a custom set of modules, then you should + add superio to the set. + 20191024: The tap(4) driver has been folded into tun(4), and the module has been renamed to tuntap. You should update any kld_list="if_tap" or From owner-svn-src-stable@freebsd.org Thu Nov 7 12:58:16 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2EF891B3412; Thu, 7 Nov 2019 12:58:16 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4783Nm0FgHz4c2K; Thu, 7 Nov 2019 12:58:16 +0000 (UTC) (envelope-from hselasky@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DFDF2E028; Thu, 7 Nov 2019 12:58:15 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA7CwFRs071655; Thu, 7 Nov 2019 12:58:15 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA7CwFRW071651; Thu, 7 Nov 2019 12:58:15 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201911071258.xA7CwFRW071651@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 7 Nov 2019 12:58:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354438 - in stable/12/sys: amd64/conf netinet netinet6 sys X-SVN-Group: stable-12 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/12/sys: amd64/conf netinet netinet6 sys X-SVN-Commit-Revision: 354438 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.29 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, 07 Nov 2019 12:58:16 -0000 Author: hselasky Date: Thu Nov 7 12:58:14 2019 New Revision: 354438 URL: https://svnweb.freebsd.org/changeset/base/354438 Log: Partial MFC of CSUM_SND_TAG flag from r348254. Add CSUM_SND_TAG flag and set this flag for outgoing ratelimited mbufs. This is a direct commit. Sponsored by: Mellanox Technologies Modified: stable/12/sys/amd64/conf/GENERIC stable/12/sys/netinet/ip_output.c stable/12/sys/netinet6/ip6_output.c stable/12/sys/sys/mbuf.h Modified: stable/12/sys/amd64/conf/GENERIC ============================================================================== --- stable/12/sys/amd64/conf/GENERIC Thu Nov 7 11:50:53 2019 (r354437) +++ stable/12/sys/amd64/conf/GENERIC Thu Nov 7 12:58:14 2019 (r354438) @@ -366,3 +366,5 @@ device netmap # netmap(4) support options EVDEV_SUPPORT # evdev support in legacy drivers device evdev # input event device support device uinput # install /dev/uinput cdev + +options RATELIMIT Modified: stable/12/sys/netinet/ip_output.c ============================================================================== --- stable/12/sys/netinet/ip_output.c Thu Nov 7 11:50:53 2019 (r354437) +++ stable/12/sys/netinet/ip_output.c Thu Nov 7 12:58:14 2019 (r354438) @@ -653,6 +653,7 @@ sendit: in_pcboutput_txrtlmt(inp, ifp, m); /* stamp send tag on mbuf */ m->m_pkthdr.snd_tag = inp->inp_snd_tag; + m->m_pkthdr.csum_flags |= CSUM_SND_TAG; } else { m->m_pkthdr.snd_tag = NULL; } @@ -705,6 +706,7 @@ sendit: in_pcboutput_txrtlmt(inp, ifp, m); /* stamp send tag on mbuf */ m->m_pkthdr.snd_tag = inp->inp_snd_tag; + m->m_pkthdr.csum_flags |= CSUM_SND_TAG; } else { m->m_pkthdr.snd_tag = NULL; } Modified: stable/12/sys/netinet6/ip6_output.c ============================================================================== --- stable/12/sys/netinet6/ip6_output.c Thu Nov 7 11:50:53 2019 (r354437) +++ stable/12/sys/netinet6/ip6_output.c Thu Nov 7 12:58:14 2019 (r354438) @@ -966,6 +966,7 @@ passout: in_pcboutput_txrtlmt(inp, ifp, m); /* stamp send tag on mbuf */ m->m_pkthdr.snd_tag = inp->inp_snd_tag; + m->m_pkthdr.csum_flags |= CSUM_SND_TAG; } else { m->m_pkthdr.snd_tag = NULL; } @@ -1081,6 +1082,7 @@ sendorfree: in_pcboutput_txrtlmt(inp, ifp, m); /* stamp send tag on mbuf */ m->m_pkthdr.snd_tag = inp->inp_snd_tag; + m->m_pkthdr.csum_flags |= CSUM_SND_TAG; } else { m->m_pkthdr.snd_tag = NULL; } Modified: stable/12/sys/sys/mbuf.h ============================================================================== --- stable/12/sys/sys/mbuf.h Thu Nov 7 11:50:53 2019 (r354437) +++ stable/12/sys/sys/mbuf.h Thu Nov 7 12:58:14 2019 (r354438) @@ -519,6 +519,8 @@ struct mbuf { #define CSUM_L5_VALID 0x20000000 /* checksum is correct */ #define CSUM_COALESCED 0x40000000 /* contains merged segments */ +#define CSUM_SND_TAG 0x80000000 /* Packet header has send tag */ + /* * CSUM flag description for use with printf(9) %b identifier. */ @@ -528,7 +530,7 @@ struct mbuf { "\12CSUM_IP6_UDP\13CSUM_IP6_TCP\14CSUM_IP6_SCTP\15CSUM_IP6_TSO" \ "\16CSUM_IP6_ISCSI" \ "\31CSUM_L3_CALC\32CSUM_L3_VALID\33CSUM_L4_CALC\34CSUM_L4_VALID" \ - "\35CSUM_L5_CALC\36CSUM_L5_VALID\37CSUM_COALESCED" + "\35CSUM_L5_CALC\36CSUM_L5_VALID\37CSUM_COALESCED\40CSUM_SND_TAG" /* CSUM flags compatibility mappings. */ #define CSUM_IP_CHECKED CSUM_L3_CALC From owner-svn-src-stable@freebsd.org Thu Nov 7 13:01:10 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8E5381B3547; Thu, 7 Nov 2019 13:01:10 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4783S63G77z4cKR; Thu, 7 Nov 2019 13:01:10 +0000 (UTC) (envelope-from hselasky@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 535DAE067; Thu, 7 Nov 2019 13:01:10 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA7D1ALM073943; Thu, 7 Nov 2019 13:01:10 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA7D1AOA073942; Thu, 7 Nov 2019 13:01:10 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201911071301.xA7D1AOA073942@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 7 Nov 2019 13:01:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354439 - stable/12/sys/amd64/conf X-SVN-Group: stable-12 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/12/sys/amd64/conf X-SVN-Commit-Revision: 354439 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.29 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, 07 Nov 2019 13:01:10 -0000 Author: hselasky Date: Thu Nov 7 13:01:09 2019 New Revision: 354439 URL: https://svnweb.freebsd.org/changeset/base/354439 Log: Revert accidential chunk added to GENERIC from previous commit. This is a direct commit. Sponsored by: Mellanox Technologies Modified: stable/12/sys/amd64/conf/GENERIC Modified: stable/12/sys/amd64/conf/GENERIC ============================================================================== --- stable/12/sys/amd64/conf/GENERIC Thu Nov 7 12:58:14 2019 (r354438) +++ stable/12/sys/amd64/conf/GENERIC Thu Nov 7 13:01:09 2019 (r354439) @@ -366,5 +366,3 @@ device netmap # netmap(4) support options EVDEV_SUPPORT # evdev support in legacy drivers device evdev # input event device support device uinput # install /dev/uinput cdev - -options RATELIMIT From owner-svn-src-stable@freebsd.org Thu Nov 7 13:12:39 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3F5B91B3A21; Thu, 7 Nov 2019 13:12:39 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4783jM0s1Tz4d1Y; Thu, 7 Nov 2019 13:12:39 +0000 (UTC) (envelope-from hselasky@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 00948E3B9; Thu, 7 Nov 2019 13:12:39 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA7DCcOi086236; Thu, 7 Nov 2019 13:12:38 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA7DCcRw086235; Thu, 7 Nov 2019 13:12:38 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201911071312.xA7DCcRw086235@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 7 Nov 2019 13:12:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354440 - stable/12/sys/dev/mlx5/mlx5_en X-SVN-Group: stable-12 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/12/sys/dev/mlx5/mlx5_en X-SVN-Commit-Revision: 354440 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.29 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, 07 Nov 2019 13:12:39 -0000 Author: hselasky Date: Thu Nov 7 13:12:38 2019 New Revision: 354440 URL: https://svnweb.freebsd.org/changeset/base/354440 Log: Check CSUM_SND_TAG flag before classifying packet has having a send tag in mlx5en(4). This fixes an issue with packets being dropped when doing packet forwarding, because the rcvif field is still set. The send tag pointer and rcvif field share the same memory location. This is a direct commit. Reported by: olivier@ Sponsored by: Mellanox Technologies Modified: stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Modified: stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c ============================================================================== --- stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Thu Nov 7 13:01:09 2019 (r354439) +++ stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Thu Nov 7 13:12:38 2019 (r354440) @@ -609,7 +609,8 @@ mlx5e_xmit(struct ifnet *ifp, struct mbuf *mb) struct mlx5e_sq *sq; int ret; - if (mb->m_pkthdr.snd_tag != NULL) { + if ((mb->m_pkthdr.csum_flags & CSUM_SND_TAG) != 0 && + (mb->m_pkthdr.snd_tag != NULL)) { sq = mlx5e_select_queue_by_send_tag(ifp, mb); if (unlikely(sq == NULL)) { /* Check for route change */ From owner-svn-src-stable@freebsd.org Thu Nov 7 15:33:00 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EB13C1B7CA2; Thu, 7 Nov 2019 15:33:00 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4786qJ5vtXz3Lf5; Thu, 7 Nov 2019 15:33:00 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AE2EBFDEB; Thu, 7 Nov 2019 15:33:00 +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 xA7FX0kD068466; Thu, 7 Nov 2019 15:33:00 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA7FX0cP068464; Thu, 7 Nov 2019 15:33:00 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201911071533.xA7FX0cP068464@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 7 Nov 2019 15:33:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354444 - in stable/12/sys: cddl/contrib/opensolaris/uts/common/fs/zfs sys vm X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/12/sys: cddl/contrib/opensolaris/uts/common/fs/zfs sys vm X-SVN-Commit-Revision: 354444 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.29 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, 07 Nov 2019 15:33:01 -0000 Author: kib Date: Thu Nov 7 15:32:59 2019 New Revision: 354444 URL: https://svnweb.freebsd.org/changeset/base/354444 Log: MFC r353892: Assert that vnode_pager_setsize() is called with the vnode exclusively locked. Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c stable/12/sys/sys/mount.h stable/12/sys/vm/vnode_pager.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Thu Nov 7 15:00:37 2019 (r354443) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Thu Nov 7 15:32:59 2019 (r354444) @@ -1400,6 +1400,7 @@ zfs_domount(vfs_t *vfsp, char *osname) vfsp->mnt_kern_flag |= MNTK_SHARED_WRITES; vfsp->mnt_kern_flag |= MNTK_EXTENDED_SHARED; vfsp->mnt_kern_flag |= MNTK_NO_IOPF; /* vn_io_fault can be used */ + vfsp->mnt_kern_flag |= MNTK_VMSETSIZE_BUG; /* * The fsid is 64 bits, composed of an 8-bit fs type, which Modified: stable/12/sys/sys/mount.h ============================================================================== --- stable/12/sys/sys/mount.h Thu Nov 7 15:00:37 2019 (r354443) +++ stable/12/sys/sys/mount.h Thu Nov 7 15:32:59 2019 (r354444) @@ -396,6 +396,7 @@ void __mnt_vnode_markerfree_active(struct vno #define MNTK_UNMAPPED_BUFS 0x00002000 #define MNTK_USES_BCACHE 0x00004000 /* FS uses the buffer cache. */ #define MNTK_TEXT_REFS 0x00008000 /* Keep use ref for text */ +#define MNTK_VMSETSIZE_BUG 0x00010000 #define MNTK_NOASYNC 0x00800000 /* disable async */ #define MNTK_UNMOUNT 0x01000000 /* unmount in progress */ #define MNTK_MWAIT 0x02000000 /* waiting for unmount to finish */ Modified: stable/12/sys/vm/vnode_pager.c ============================================================================== --- stable/12/sys/vm/vnode_pager.c Thu Nov 7 15:00:37 2019 (r354443) +++ stable/12/sys/vm/vnode_pager.c Thu Nov 7 15:32:59 2019 (r354444) @@ -433,7 +433,16 @@ vnode_pager_setsize(struct vnode *vp, vm_ooffset_t nsi if ((object = vp->v_object) == NULL) return; -/* ASSERT_VOP_ELOCKED(vp, "vnode_pager_setsize and not locked vnode"); */ +#ifdef DEBUG_VFS_LOCKS + { + struct mount *mp; + + mp = vp->v_mount; + if (mp != NULL && (mp->mnt_kern_flag & MNTK_VMSETSIZE_BUG) == 0) + assert_vop_elocked(vp, + "vnode_pager_setsize and not locked vnode"); + } +#endif VM_OBJECT_WLOCK(object); if (object->type == OBJT_DEAD) { VM_OBJECT_WUNLOCK(object); From owner-svn-src-stable@freebsd.org Thu Nov 7 18:14:59 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 004D51BBE7B; Thu, 7 Nov 2019 18:14:59 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 478BQB6CJbz44YW; Thu, 7 Nov 2019 18:14:58 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B987819C8A; Thu, 7 Nov 2019 18:14:58 +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 xA7IEwZT069970; Thu, 7 Nov 2019 18:14:58 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA7IEwF4069969; Thu, 7 Nov 2019 18:14:58 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201911071814.xA7IEwF4069969@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 7 Nov 2019 18:14:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354457 - stable/12/lib/libpmc/pmu-events X-SVN-Group: stable-12 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/12/lib/libpmc/pmu-events X-SVN-Commit-Revision: 354457 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.29 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, 07 Nov 2019 18:14:59 -0000 Author: emaste Date: Thu Nov 7 18:14:58 2019 New Revision: 354457 URL: https://svnweb.freebsd.org/changeset/base/354457 Log: MFC r354342: libpmc: jevents: handle empty description PR: 241258 Reported by: sigsys @ gmail.com Obtained from: github.com/andikleen/pmu-tools commit bb3c77ed61 Modified: stable/12/lib/libpmc/pmu-events/jevents.c Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libpmc/pmu-events/jevents.c ============================================================================== --- stable/12/lib/libpmc/pmu-events/jevents.c Thu Nov 7 18:07:34 2019 (r354456) +++ stable/12/lib/libpmc/pmu-events/jevents.c Thu Nov 7 18:14:58 2019 (r354457) @@ -122,7 +122,7 @@ static void fixdesc(char *s) --e; while (e >= s && isspace(*e)) --e; - if (*e == '.') + if (e >= s && *e == '.') *e = 0; } From owner-svn-src-stable@freebsd.org Thu Nov 7 20:09:43 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 242E91BF666; Thu, 7 Nov 2019 20:09:43 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 478Dyb06N2z4G5Q; Thu, 7 Nov 2019 20:09:43 +0000 (UTC) (envelope-from vmaffione@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DC7B71B153; Thu, 7 Nov 2019 20:09:42 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA7K9gPx046771; Thu, 7 Nov 2019 20:09:42 GMT (envelope-from vmaffione@FreeBSD.org) Received: (from vmaffione@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA7K9fpb046764; Thu, 7 Nov 2019 20:09:41 GMT (envelope-from vmaffione@FreeBSD.org) Message-Id: <201911072009.xA7K9fpb046764@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vmaffione set sender to vmaffione@FreeBSD.org using -f From: Vincenzo Maffione Date: Thu, 7 Nov 2019 20:09:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354471 - in stable/12: share/man/man4 sys/dev/netmap sys/net tools/tools/netmap usr.sbin usr.sbin/valectl X-SVN-Group: stable-12 X-SVN-Commit-Author: vmaffione X-SVN-Commit-Paths: in stable/12: share/man/man4 sys/dev/netmap sys/net tools/tools/netmap usr.sbin usr.sbin/valectl X-SVN-Commit-Revision: 354471 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.29 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, 07 Nov 2019 20:09:43 -0000 Author: vmaffione Date: Thu Nov 7 20:09:41 2019 New Revision: 354471 URL: https://svnweb.freebsd.org/changeset/base/354471 Log: MFC r354229 add valectl to the system commands The valectl(4) program is used to manage vale(4) switches. Add it to the system commands so that it can be used right away. This program was previously called vale-ctl, and stored in tools/tools/netmap Reviewed by: hrs, bcr, lwhsu, kevans Differential Revision: https://reviews.freebsd.org/D22146 Added: stable/12/usr.sbin/valectl/ - copied from r354229, head/usr.sbin/valectl/ Deleted: stable/12/tools/tools/netmap/vale-ctl.4 stable/12/tools/tools/netmap/vale-ctl.c Modified: stable/12/share/man/man4/netmap.4 stable/12/sys/dev/netmap/netmap_bdg.c stable/12/sys/net/netmap_legacy.h stable/12/tools/tools/netmap/Makefile stable/12/tools/tools/netmap/README stable/12/tools/tools/netmap/lb.8 stable/12/usr.sbin/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/netmap.4 ============================================================================== --- stable/12/share/man/man4/netmap.4 Thu Nov 7 19:54:24 2019 (r354470) +++ stable/12/share/man/man4/netmap.4 Thu Nov 7 20:09:41 2019 (r354471) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 20, 2018 +.Dd October 26, 2019 .Dt NETMAP 4 .Os .Sh NAME @@ -1087,14 +1087,14 @@ changing port names, e.g., .Pp The following command attaches an interface and the host stack to a switch: -.Dl vale-ctl -h vale2:em0 +.Dl valectl -h vale2:em0 Other .Nm clients attached to the same switch can now communicate with the network card or the host. .Sh SEE ALSO .Xr vale 4 , -.Xr vale-ctl 4 , +.Xr valectl 8 , .Xr bridge 8 , .Xr lb 8 , .Xr nmreplay 8 , Modified: stable/12/sys/dev/netmap/netmap_bdg.c ============================================================================== --- stable/12/sys/dev/netmap/netmap_bdg.c Thu Nov 7 19:54:24 2019 (r354470) +++ stable/12/sys/dev/netmap/netmap_bdg.c Thu Nov 7 20:09:41 2019 (r354471) @@ -1442,7 +1442,7 @@ put_out: /* nm_bdg_ctl callback for the bwrap. - * Called on bridge-attach and detach, as an effect of vale-ctl -[ahd]. + * Called on bridge-attach and detach, as an effect of valectl -[ahd]. * On attach, it needs to provide a fake netmap_priv_d structure and * perform a netmap_do_regif() on the bwrap. This will put both the * bwrap and the hwna in netmap mode, with the netmap rings shared Modified: stable/12/sys/net/netmap_legacy.h ============================================================================== --- stable/12/sys/net/netmap_legacy.h Thu Nov 7 19:54:24 2019 (r354470) +++ stable/12/sys/net/netmap_legacy.h Thu Nov 7 20:09:41 2019 (r354471) @@ -116,13 +116,13 @@ * nr_cmd (in) if non-zero indicates a special command: * NETMAP_BDG_ATTACH and nr_name = vale*:ifname * attaches the NIC to the switch; nr_ringid specifies - * which rings to use. Used by vale-ctl -a ... + * which rings to use. Used by valectl -a ... * nr_arg1 = NETMAP_BDG_HOST also attaches the host port - * as in vale-ctl -h ... + * as in valectl -h ... * * NETMAP_BDG_DETACH and nr_name = vale*:ifname * disconnects a previously attached NIC. - * Used by vale-ctl -d ... + * Used by valectl -d ... * * NETMAP_BDG_LIST * list the configuration of VALE switches. @@ -133,10 +133,10 @@ * * NETMAP_BDG_NEWIF * create a persistent VALE port with name nr_name. - * Used by vale-ctl -n ... + * Used by valectl -n ... * * NETMAP_BDG_DELIF - * delete a persistent VALE port. Used by vale-ctl -d ... + * delete a persistent VALE port. Used by valectl -d ... * * nr_arg1, nr_arg2, nr_arg3 (in/out) command specific * Modified: stable/12/tools/tools/netmap/Makefile ============================================================================== --- stable/12/tools/tools/netmap/Makefile Thu Nov 7 19:54:24 2019 (r354470) +++ stable/12/tools/tools/netmap/Makefile Thu Nov 7 20:09:41 2019 (r354471) @@ -3,7 +3,7 @@ # # For multiple programs using a single source file each, # we can just define 'progs' and create custom targets. -PROGS = pkt-gen nmreplay bridge vale-ctl lb +PROGS = pkt-gen nmreplay bridge lb CLEANFILES = $(PROGS) *.o MAN= @@ -31,9 +31,6 @@ bridge: bridge.o nmreplay: nmreplay.o $(CC) $(CFLAGS) -o nmreplay nmreplay.o $(LDFLAGS) - -vale-ctl: vale-ctl.o - $(CC) $(CFLAGS) -o vale-ctl vale-ctl.o lb: lb.o pkt_hash.o $(CC) $(CFLAGS) -o lb lb.o pkt_hash.o $(LDFLAGS) Modified: stable/12/tools/tools/netmap/README ============================================================================== --- stable/12/tools/tools/netmap/README Thu Nov 7 19:54:24 2019 (r354470) +++ stable/12/tools/tools/netmap/README Thu Nov 7 20:09:41 2019 (r354471) @@ -6,8 +6,6 @@ This directory contains applications that use the netm bridge a two-port jumper wire, also using the netmap API - vale-ctl the program to control and inspect VALE switches - lb an L3/L4 load balancer nmreplay a tool to playback a pcap file to a netmap port Modified: stable/12/tools/tools/netmap/lb.8 ============================================================================== --- stable/12/tools/tools/netmap/lb.8 Thu Nov 7 19:54:24 2019 (r354470) +++ stable/12/tools/tools/netmap/lb.8 Thu Nov 7 20:09:41 2019 (r354471) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 28, 2018 +.Dd October 26, 2019 .Dt LB 8 .Os .Sh NAME @@ -111,7 +111,7 @@ If .Nm does not exit cleanly the ports will not be removed. Please use -.Xr vale-ctl 4 +.Xr valectl 8 to remove any stale persistent VALE port. .Sh SEE ALSO .Xr netmap 4 , Modified: stable/12/usr.sbin/Makefile ============================================================================== --- stable/12/usr.sbin/Makefile Thu Nov 7 19:54:24 2019 (r354470) +++ stable/12/usr.sbin/Makefile Thu Nov 7 20:09:41 2019 (r354471) @@ -96,6 +96,7 @@ SUBDIR= adduser \ trpt \ tzsetup \ ugidfw \ + valectl \ vigr \ vipw \ wake \ From owner-svn-src-stable@freebsd.org Thu Nov 7 20:11:54 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 950961BF80D; Thu, 7 Nov 2019 20:11:54 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 478F163TRYz4GPk; Thu, 7 Nov 2019 20:11:54 +0000 (UTC) (envelope-from vmaffione@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5AE4F1B2E6; Thu, 7 Nov 2019 20:11:54 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA7KBs9B048389; Thu, 7 Nov 2019 20:11:54 GMT (envelope-from vmaffione@FreeBSD.org) Received: (from vmaffione@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA7KBs1d048388; Thu, 7 Nov 2019 20:11:54 GMT (envelope-from vmaffione@FreeBSD.org) Message-Id: <201911072011.xA7KBs1d048388@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vmaffione set sender to vmaffione@FreeBSD.org using -f From: Vincenzo Maffione Date: Thu, 7 Nov 2019 20:11:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354472 - stable/12/sys/net X-SVN-Group: stable-12 X-SVN-Commit-Author: vmaffione X-SVN-Commit-Paths: stable/12/sys/net X-SVN-Commit-Revision: 354472 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.29 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, 07 Nov 2019 20:11:54 -0000 Author: vmaffione Date: Thu Nov 7 20:11:53 2019 New Revision: 354472 URL: https://svnweb.freebsd.org/changeset/base/354472 Log: MFC r354231 netmap: fix build issue in netmap_user.h The issue was a comparison of integers of different signs on 32 bit architectures. Reported by: jenkins MFC after: 1 week Modified: stable/12/sys/net/netmap_user.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/net/netmap_user.h ============================================================================== --- stable/12/sys/net/netmap_user.h Thu Nov 7 20:09:41 2019 (r354471) +++ stable/12/sys/net/netmap_user.h Thu Nov 7 20:11:53 2019 (r354472) @@ -1116,7 +1116,7 @@ nm_dispatch(struct nm_desc *d, int cnt, nm_cb_t cb, u_ slot = &ring->slot[i]; d->hdr.len += slot->len; nbuf = (u_char *)NETMAP_BUF(ring, slot->buf_idx); - if (oldbuf != NULL && nbuf - oldbuf == ring->nr_buf_size && + if (oldbuf != NULL && nbuf - oldbuf == (int)ring->nr_buf_size && oldlen == ring->nr_buf_size) { d->hdr.caplen += slot->len; oldbuf = nbuf; From owner-svn-src-stable@freebsd.org Fri Nov 8 07:35:33 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 468291A9CE0; Fri, 8 Nov 2019 07:35:33 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 478X9x14jPz40WW; Fri, 8 Nov 2019 07:35:33 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 08DEE22C9B; Fri, 8 Nov 2019 07:35:33 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA87ZWpE057290; Fri, 8 Nov 2019 07:35:32 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA87ZW8G057289; Fri, 8 Nov 2019 07:35:32 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911080735.xA87ZW8G057289@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Fri, 8 Nov 2019 07:35:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354529 - stable/12/sys/dev/ow X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/sys/dev/ow X-SVN-Commit-Revision: 354529 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.29 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, 08 Nov 2019 07:35:33 -0000 Author: avg Date: Fri Nov 8 07:35:32 2019 New Revision: 354529 URL: https://svnweb.freebsd.org/changeset/base/354529 Log: MFC r354069: owc_gpiobus_read_data: disable preemption earlier Modified: stable/12/sys/dev/ow/owc_gpiobus.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/ow/owc_gpiobus.c ============================================================================== --- stable/12/sys/dev/ow/owc_gpiobus.c Fri Nov 8 06:40:17 2019 (r354528) +++ stable/12/sys/dev/ow/owc_gpiobus.c Fri Nov 8 07:35:32 2019 (r354529) @@ -279,6 +279,8 @@ owc_gpiobus_read_data(device_t dev, struct ow_timing * if (error != 0) return (error); + critical_enter(); + /* Force low for t_lowr microseconds */ then = sbinuptime(); OUTPIN(sc); @@ -291,7 +293,6 @@ owc_gpiobus_read_data(device_t dev, struct ow_timing * * master's pushing the line low. */ INPIN(sc); - critical_enter(); do { now = sbinuptime(); GETPIN(sc, &sample); From owner-svn-src-stable@freebsd.org Fri Nov 8 07:36:51 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B9F091A9DA8; Fri, 8 Nov 2019 07:36:51 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 478XCR4XxMz40fL; Fri, 8 Nov 2019 07:36:51 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 806D722C9D; Fri, 8 Nov 2019 07:36:51 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA87ap8d057409; Fri, 8 Nov 2019 07:36:51 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA87apnD057408; Fri, 8 Nov 2019 07:36:51 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911080736.xA87apnD057408@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Fri, 8 Nov 2019 07:36:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354530 - stable/12/sys/dev/ow X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/sys/dev/ow X-SVN-Commit-Revision: 354530 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.29 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, 08 Nov 2019 07:36:51 -0000 Author: avg Date: Fri Nov 8 07:36:51 2019 New Revision: 354530 URL: https://svnweb.freebsd.org/changeset/base/354530 Log: MFC r354076: owc_gpiobus_read_data: compare times in sbintime_t units Modified: stable/12/sys/dev/ow/owc_gpiobus.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/ow/owc_gpiobus.c ============================================================================== --- stable/12/sys/dev/ow/owc_gpiobus.c Fri Nov 8 07:35:32 2019 (r354529) +++ stable/12/sys/dev/ow/owc_gpiobus.c Fri Nov 8 07:36:51 2019 (r354530) @@ -296,10 +296,10 @@ owc_gpiobus_read_data(device_t dev, struct ow_timing * do { now = sbinuptime(); GETPIN(sc, &sample); - } while (sbttous(now - then) < t->t_rdv + 2 && sample == 0); + } while (now - then < (t->t_rdv + 2) * SBT_1US && sample == 0); critical_exit(); - if (sbttons(now - then) < t->t_rdv * 1000) + if (now - then < t->t_rdv * SBT_1US) *bit = 1; else *bit = 0; @@ -307,7 +307,7 @@ owc_gpiobus_read_data(device_t dev, struct ow_timing * /* Wait out the rest of t_slot */ do { now = sbinuptime(); - } while ((now - then) / SBT_1US < t->t_slot); + } while (now - then < t->t_slot * SBT_1US); RELBUS(sc); From owner-svn-src-stable@freebsd.org Fri Nov 8 07:38:35 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 244021A9E97; Fri, 8 Nov 2019 07:38:35 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 478XFR09Krz40pD; Fri, 8 Nov 2019 07:38:35 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DDAC622C9F; Fri, 8 Nov 2019 07:38:34 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA87cY1N057565; Fri, 8 Nov 2019 07:38:34 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA87cYqk057564; Fri, 8 Nov 2019 07:38:34 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911080738.xA87cYqk057564@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Fri, 8 Nov 2019 07:38:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354531 - stable/12/sys/dev/ow X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/sys/dev/ow X-SVN-Commit-Revision: 354531 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.29 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, 08 Nov 2019 07:38:35 -0000 Author: avg Date: Fri Nov 8 07:38:34 2019 New Revision: 354531 URL: https://svnweb.freebsd.org/changeset/base/354531 Log: MFC r354077,r354078: owc_gpiobus_read_data: add recovery time to the read slot Modified: stable/12/sys/dev/ow/owc_gpiobus.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/ow/owc_gpiobus.c ============================================================================== --- stable/12/sys/dev/ow/owc_gpiobus.c Fri Nov 8 07:36:51 2019 (r354530) +++ stable/12/sys/dev/ow/owc_gpiobus.c Fri Nov 8 07:38:34 2019 (r354531) @@ -307,7 +307,7 @@ owc_gpiobus_read_data(device_t dev, struct ow_timing * /* Wait out the rest of t_slot */ do { now = sbinuptime(); - } while (now - then < t->t_slot * SBT_1US); + } while (now - then < (t->t_slot + t->t_rec) * SBT_1US); RELBUS(sc); From owner-svn-src-stable@freebsd.org Fri Nov 8 07:56:15 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9A1E51AA55E; Fri, 8 Nov 2019 07:56:15 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 478Xdq3SfYz41Yx; Fri, 8 Nov 2019 07:56:15 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3BB492304C; Fri, 8 Nov 2019 07:56:15 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA87uEmY069408; Fri, 8 Nov 2019 07:56:14 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA87uEVg069407; Fri, 8 Nov 2019 07:56:14 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911080756.xA87uEVg069407@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Fri, 8 Nov 2019 07:56:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354532 - stable/12/sys/dev/gpio X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/sys/dev/gpio X-SVN-Commit-Revision: 354532 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.29 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, 08 Nov 2019 07:56:15 -0000 Author: avg Date: Fri Nov 8 07:56:14 2019 New Revision: 354532 URL: https://svnweb.freebsd.org/changeset/base/354532 Log: MFC r354065: gpioiic: set output after switching to output mode... if presetting it failed. Modified: stable/12/sys/dev/gpio/gpioiic.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/gpio/gpioiic.c ============================================================================== --- stable/12/sys/dev/gpio/gpioiic.c Fri Nov 8 07:38:34 2019 (r354531) +++ stable/12/sys/dev/gpio/gpioiic.c Fri Nov 8 07:56:14 2019 (r354532) @@ -168,59 +168,67 @@ gpioiic_reset_bus(device_t dev) } static void -gpioiic_setsda(device_t dev, int val) +gpioiic_setpin(struct gpioiic_softc *sc, int pin, int val) { - struct gpioiic_softc *sc = device_get_softc(dev); + int err; if (val == 0) { - GPIOBUS_PIN_SET(sc->sc_busdev, sc->sc_dev, sc->sda_pin, 0); - GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, sc->sda_pin, + err = GPIOBUS_PIN_SET(sc->sc_busdev, sc->sc_dev, pin, 0); + GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, pin, GPIO_PIN_OUTPUT); + + /* + * Some controllers cannot set output value while a pin is in + * input mode. + */ + if (err != 0) + GPIOBUS_PIN_SET(sc->sc_busdev, sc->sc_dev, pin, 0); } else { - GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, sc->sda_pin, + GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, pin, GPIO_PIN_INPUT); } } static void +gpioiic_setsda(device_t dev, int val) +{ + struct gpioiic_softc *sc = device_get_softc(dev); + + gpioiic_setpin(sc, sc->sda_pin, val); +} + +static void gpioiic_setscl(device_t dev, int val) { struct gpioiic_softc *sc = device_get_softc(dev); - if (val == 0) { - GPIOBUS_PIN_SET(sc->sc_busdev, sc->sc_dev, sc->scl_pin, 0); - GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, sc->scl_pin, - GPIO_PIN_OUTPUT); - } else { - GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, sc->scl_pin, - GPIO_PIN_INPUT); - } + gpioiic_setpin(sc, sc->scl_pin, val); } static int -gpioiic_getscl(device_t dev) +gpioiic_getpin(struct gpioiic_softc *sc, int pin) { - struct gpioiic_softc *sc = device_get_softc(dev); unsigned int val; - GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, sc->scl_pin, - GPIO_PIN_INPUT); - GPIOBUS_PIN_GET(sc->sc_busdev, sc->sc_dev, sc->scl_pin, &val); - + GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, pin, GPIO_PIN_INPUT); + GPIOBUS_PIN_GET(sc->sc_busdev, sc->sc_dev, pin, &val); return ((int)val); } static int -gpioiic_getsda(device_t dev) +gpioiic_getscl(device_t dev) { struct gpioiic_softc *sc = device_get_softc(dev); - unsigned int val; - GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, sc->sda_pin, - GPIO_PIN_INPUT); - GPIOBUS_PIN_GET(sc->sc_busdev, sc->sc_dev, sc->sda_pin, &val); + return (gpioiic_getpin(sc, sc->scl_pin)); +} - return ((int)val); +static int +gpioiic_getsda(device_t dev) +{ + struct gpioiic_softc *sc = device_get_softc(dev); + + return (gpioiic_getpin(sc, sc->sda_pin)); } static int From owner-svn-src-stable@freebsd.org Fri Nov 8 12:06:05 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 98B351B05F7; Fri, 8 Nov 2019 12:06:05 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 478fB54KvKz4GW7; Fri, 8 Nov 2019 12:06:05 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5E80325CAB; Fri, 8 Nov 2019 12:06:05 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA8C65qU035368; Fri, 8 Nov 2019 12:06:05 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA8C63OI035360; Fri, 8 Nov 2019 12:06:03 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911081206.xA8C63OI035360@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Fri, 8 Nov 2019 12:06:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354534 - in stable/12/sys/cddl: compat/opensolaris/kern compat/opensolaris/sys contrib/opensolaris/common/atomic/aarch64 contrib/opensolaris/common/atomic/amd64 contrib/opensolaris/com... X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in stable/12/sys/cddl: compat/opensolaris/kern compat/opensolaris/sys contrib/opensolaris/common/atomic/aarch64 contrib/opensolaris/common/atomic/amd64 contrib/opensolaris/common/atomic/i386 contrib/o... X-SVN-Commit-Revision: 354534 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.29 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, 08 Nov 2019 12:06:05 -0000 Author: avg Date: Fri Nov 8 12:06:03 2019 New Revision: 354534 URL: https://svnweb.freebsd.org/changeset/base/354534 Log: MFC r353340,r353340: cleanup of illumos compatibility atomics Modified: stable/12/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c stable/12/sys/cddl/compat/opensolaris/sys/atomic.h stable/12/sys/cddl/contrib/opensolaris/common/atomic/aarch64/opensolaris_atomic.S stable/12/sys/cddl/contrib/opensolaris/common/atomic/amd64/opensolaris_atomic.S stable/12/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S stable/12/sys/cddl/contrib/opensolaris/common/atomic/powerpc64/opensolaris_atomic.S stable/12/sys/cddl/contrib/opensolaris/common/atomic/sparc64/opensolaris_atomic.S Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c ============================================================================== --- stable/12/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c Fri Nov 8 11:09:50 2019 (r354533) +++ stable/12/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c Fri Nov 8 12:06:03 2019 (r354534) @@ -32,6 +32,9 @@ __FBSDID("$FreeBSD$"); #include #include +#if !defined(__LP64__) && !defined(__mips_n32) && \ + !defined(ARM_HAVE_ATOMIC64) && !defined(I386_HAVE_ATOMIC64) + #ifdef _KERNEL #include @@ -52,8 +55,6 @@ atomic_init(void) } #endif -#if !defined(__LP64__) && !defined(__mips_n32) && \ - !defined(ARM_HAVE_ATOMIC64) && !defined(I386_HAVE_ATOMIC64) void atomic_add_64(volatile uint64_t *target, int64_t delta) { @@ -94,7 +95,6 @@ atomic_load_64(volatile uint64_t *a) mtx_unlock(&atomic_mtx); return (ret); } -#endif uint64_t atomic_add_64_nv(volatile uint64_t *target, int64_t delta) @@ -107,27 +107,6 @@ atomic_add_64_nv(volatile uint64_t *target, int64_t de return (newval); } -#if defined(__powerpc__) || defined(__arm__) || defined(__mips__) -void -atomic_or_8(volatile uint8_t *target, uint8_t value) -{ - mtx_lock(&atomic_mtx); - *target |= value; - mtx_unlock(&atomic_mtx); -} -#endif - -uint8_t -atomic_or_8_nv(volatile uint8_t *target, uint8_t value) -{ - uint8_t newval; - - mtx_lock(&atomic_mtx); - newval = (*target |= value); - mtx_unlock(&atomic_mtx); - return (newval); -} - uint64_t atomic_cas_64(volatile uint64_t *target, uint64_t cmp, uint64_t newval) { @@ -140,19 +119,7 @@ atomic_cas_64(volatile uint64_t *target, uint64_t cmp, mtx_unlock(&atomic_mtx); return (oldval); } - -uint32_t -atomic_cas_32(volatile uint32_t *target, uint32_t cmp, uint32_t newval) -{ - uint32_t oldval; - - mtx_lock(&atomic_mtx); - oldval = *target; - if (oldval == cmp) - *target = newval; - mtx_unlock(&atomic_mtx); - return (oldval); -} +#endif void membar_producer(void) Modified: stable/12/sys/cddl/compat/opensolaris/sys/atomic.h ============================================================================== --- stable/12/sys/cddl/compat/opensolaris/sys/atomic.h Fri Nov 8 11:09:50 2019 (r354533) +++ stable/12/sys/cddl/compat/opensolaris/sys/atomic.h Fri Nov 8 12:06:03 2019 (r354534) @@ -32,42 +32,28 @@ #include #include -#define casptr(_a, _b, _c) \ - atomic_cmpset_ptr((volatile uintptr_t *)(_a), (uintptr_t)(_b), (uintptr_t) (_c)) -#define cas32 atomic_cmpset_32 - #if defined(__i386__) && (defined(_KERNEL) || defined(KLD_MODULE)) #define I386_HAVE_ATOMIC64 #endif +#if defined(__i386__) || defined(__amd64__) || defined(__arm__) +/* No spurious failures from fcmpset. */ +#define STRONG_FCMPSET +#endif + #if !defined(__LP64__) && !defined(__mips_n32) && \ !defined(ARM_HAVE_ATOMIC64) && !defined(I386_HAVE_ATOMIC64) extern void atomic_add_64(volatile uint64_t *target, int64_t delta); extern void atomic_dec_64(volatile uint64_t *target); extern uint64_t atomic_swap_64(volatile uint64_t *a, uint64_t value); extern uint64_t atomic_load_64(volatile uint64_t *a); -#endif -#ifndef __sparc64__ -extern uint32_t atomic_cas_32(volatile uint32_t *target, uint32_t cmp, - uint32_t newval); +extern uint64_t atomic_add_64_nv(volatile uint64_t *target, int64_t delta); extern uint64_t atomic_cas_64(volatile uint64_t *target, uint64_t cmp, uint64_t newval); #endif -extern uint64_t atomic_add_64_nv(volatile uint64_t *target, int64_t delta); -extern uint8_t atomic_or_8_nv(volatile uint8_t *target, uint8_t value); + extern void membar_producer(void); -#if defined(__sparc64__) || defined(__powerpc__) || defined(__arm__) || \ - defined(__mips__) || defined(__aarch64__) || defined(__riscv) -extern void atomic_or_8(volatile uint8_t *target, uint8_t value); -#else -static __inline void -atomic_or_8(volatile uint8_t *target, uint8_t value) -{ - atomic_set_8(target, value); -} -#endif - static __inline uint32_t atomic_add_32_nv(volatile uint32_t *target, int32_t delta) { @@ -81,6 +67,18 @@ atomic_add_int_nv(volatile u_int *target, int delta) } static __inline void +atomic_inc_32(volatile uint32_t *target) +{ + atomic_add_32(target, 1); +} + +static __inline uint32_t +atomic_inc_32_nv(volatile uint32_t *target) +{ + return (atomic_add_32_nv(target, 1)); +} + +static __inline void atomic_dec_32(volatile uint32_t *target) { atomic_subtract_32(target, 1); @@ -89,9 +87,27 @@ atomic_dec_32(volatile uint32_t *target) static __inline uint32_t atomic_dec_32_nv(volatile uint32_t *target) { - return (atomic_fetchadd_32(target, -1) - 1); + return (atomic_add_32_nv(target, -1)); } +#ifndef __sparc64__ +static inline uint32_t +atomic_cas_32(volatile uint32_t *target, uint32_t cmp, uint32_t newval) +{ +#ifdef STRONG_FCMPSET + (void)atomic_fcmpset_32(target, &cmp, newval); +#else + uint32_t expected = cmp; + + do { + if (atomic_fcmpset_32(target, &cmp, newval)) + break; + } while (cmp == expected); +#endif + return (cmp); +} +#endif + #if defined(__LP64__) || defined(__mips_n32) || \ defined(ARM_HAVE_ATOMIC64) || defined(I386_HAVE_ATOMIC64) static __inline void @@ -99,19 +115,31 @@ atomic_dec_64(volatile uint64_t *target) { atomic_subtract_64(target, 1); } -#endif -static __inline void -atomic_inc_32(volatile uint32_t *target) +static inline uint64_t +atomic_add_64_nv(volatile uint64_t *target, int64_t delta) { - atomic_add_32(target, 1); + return (atomic_fetchadd_64(target, delta) + delta); } -static __inline uint32_t -atomic_inc_32_nv(volatile uint32_t *target) +#ifndef __sparc64__ +static inline uint64_t +atomic_cas_64(volatile uint64_t *target, uint64_t cmp, uint64_t newval) { - return (atomic_add_32_nv(target, 1)); +#ifdef STRONG_FCMPSET + (void)atomic_fcmpset_64(target, &cmp, newval); +#else + uint64_t expected = cmp; + + do { + if (atomic_fcmpset_64(target, &cmp, newval)) + break; + } while (cmp == expected); +#endif + return (cmp); } +#endif +#endif static __inline void atomic_inc_64(volatile uint64_t *target) Modified: stable/12/sys/cddl/contrib/opensolaris/common/atomic/aarch64/opensolaris_atomic.S ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/common/atomic/aarch64/opensolaris_atomic.S Fri Nov 8 11:09:50 2019 (r354533) +++ stable/12/sys/cddl/contrib/opensolaris/common/atomic/aarch64/opensolaris_atomic.S Fri Nov 8 12:06:03 2019 (r354534) @@ -28,58 +28,6 @@ #include -/* - * uint64_t atomic_add_64_nv(volatile uint64_t *target, int64_t delta) - */ -ENTRY(atomic_add_64_nv) -1: ldxr x2, [x0] /* Load *target */ - add x2, x2, x1 /* x2 = x2 + delta */ - stxr w3, x2, [x0] /* Store *target */ - cbnz w3, 1b /* Check if the store succeeded */ - mov x0, x2 /* Return the new value */ - ret -END(atomic_add_64_nv) - -/* - * uint32_t - * atomic_cas_32(volatile uint32_t *target, uint32_t cmp, uint32_t newval) - */ -ENTRY(atomic_cas_32) -1: ldxr w3, [x0] /* Load *target */ - cmp w3, w1 /* Does *targe == cmp? */ - b.ne 2f /* If not exit */ - stxr w4, w2, [x0] /* Store newval to *target */ - cbnz w4, 1b /* Check if the store succeeded */ -2: mov w0, w3 /* Return the old value */ - ret -END(atomic_cas_32) - -/* - * uint64_t - * atomic_cas_64(volatile uint64_t *target, uint64_t cmp, uint64_t newval) - */ -ENTRY(atomic_cas_64) -1: ldxr x3, [x0] /* Load *target */ - cmp x3, x1 /* Does *targe == cmp? */ - b.ne 2f /* If not exit */ - stxr w4, x2, [x0] /* Store newval to *target */ - cbnz w4, 1b /* Check if the store succeeded */ -2: mov x0, x3 /* Return the old value */ - ret -END(atomic_cas_64) - -/* - * uint8_t atomic_or_8_nv(volatile uint8_t *target, uint8_t value) - */ -ENTRY(atomic_or_8_nv) -1: ldxrb w2, [x0] /* Load *target */ - orr w2, w2, w1 /* x2 = x2 | delta */ - stxrb w3, w2, [x0] /* Store *target */ - cbnz w3, 1b /* Check if the store succeeded */ - mov w0, w2 /* Return the new value */ - ret -END(atomic_or_8_nv) - ENTRY(membar_producer) dmb ish ret Modified: stable/12/sys/cddl/contrib/opensolaris/common/atomic/amd64/opensolaris_atomic.S ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/common/atomic/amd64/opensolaris_atomic.S Fri Nov 8 11:09:50 2019 (r354533) +++ stable/12/sys/cddl/contrib/opensolaris/common/atomic/amd64/opensolaris_atomic.S Fri Nov 8 12:06:03 2019 (r354534) @@ -28,40 +28,6 @@ #define _ASM #include - ENTRY(atomic_add_64_nv) - mov %rsi, %rax // %rax = delta addend - lock - xaddq %rsi, (%rdi) // %rsi = old value, (%rdi) = sum - addq %rsi, %rax // new value = original value + delta - ret - SET_SIZE(atomic_add_64_nv) - - ENTRY(atomic_or_8_nv) - movb (%rdi), %al // %al = old value -1: - movb %sil, %cl - orb %al, %cl // %cl = new value - lock - cmpxchgb %cl, (%rdi) // try to stick it in - jne 1b - movzbl %cl, %eax // return new value - ret - SET_SIZE(atomic_or_8_nv) - - ENTRY(atomic_cas_32) - movl %esi, %eax - lock - cmpxchgl %edx, (%rdi) - ret - SET_SIZE(atomic_cas_32) - - ENTRY(atomic_cas_64) - movq %rsi, %rax - lock - cmpxchgq %rdx, (%rdi) - ret - SET_SIZE(atomic_cas_64) - ENTRY(membar_producer) sfence ret Modified: stable/12/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S Fri Nov 8 11:09:50 2019 (r354533) +++ stable/12/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S Fri Nov 8 12:06:03 2019 (r354534) @@ -89,28 +89,6 @@ SET_SIZE(atomic_add_64_nv) SET_SIZE(atomic_add_64) - ENTRY(atomic_or_8_nv) - movl 4(%esp), %edx // %edx = target address - movb (%edx), %al // %al = old value -1: - movl 8(%esp), %ecx // %ecx = delta - orb %al, %cl // %cl = new value - lock - cmpxchgb %cl, (%edx) // try to stick it in - jne 1b - movzbl %cl, %eax // return new value - ret - SET_SIZE(atomic_or_8_nv) - - ENTRY(atomic_cas_32) - movl 4(%esp), %edx - movl 8(%esp), %eax - movl 12(%esp), %ecx - lock - cmpxchgl %ecx, (%edx) - ret - SET_SIZE(atomic_cas_32) - ENTRY(atomic_cas_64) pushl %ebx pushl %esi Modified: stable/12/sys/cddl/contrib/opensolaris/common/atomic/powerpc64/opensolaris_atomic.S ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/common/atomic/powerpc64/opensolaris_atomic.S Fri Nov 8 11:09:50 2019 (r354533) +++ stable/12/sys/cddl/contrib/opensolaris/common/atomic/powerpc64/opensolaris_atomic.S Fri Nov 8 12:06:03 2019 (r354534) @@ -27,61 +27,6 @@ #include -ENTRY(atomic_add_64_nv) - 1: ldarx %r5,0,%r3 - add %r5,%r4,%r5 - stdcx. %r5,0,%r3 - bne- 1b - - mr %r3,%r5 - blr - -ENTRY(atomic_cas_32) - 1: lwarx %r6,0,%r3 - cmplw %r6,%r4 - bne 2f - stwcx. %r5,0,%r3 - bne- 1b - b 3f - - 2: stwcx. %r6,0,%r3 /* clear reservation */ - - 3: mr %r3,%r6 - blr - -ENTRY(atomic_cas_64) - 1: ldarx %r6,0,%r3 - cmpld %r6,%r4 - bne 2f - stdcx. %r5,0,%r3 - bne- 1b - b 3f - - 2: stdcx. %r6,0,%r3 /* clear reservation */ - - 3: mr %r3,%r6 - blr - -ENTRY(atomic_or_8_nv) - li %r6,3 - andc. %r6,%r3,%r6 /* r6 = r3 & ~4 */ - addi %r7,%r6,3 - sub %r7,%r7,%r3 /* offset in r7 */ - sldi %r7,%r7,3 /* bits to shift in r7 */ - - rlwinm %r4,%r4,0,24,31 /* mask and rotate the argument */ - slw %r4,%r4,%r7 - - 1: lwarx %r5,0,%r6 - or %r5,%r4,%r5 - stwcx. %r5,0,%r6 - bne- 1b - - srw %r3,%r5,%r7 - rlwinm %r3,%r3,0,24,31 /* mask return value */ - - blr - ENTRY(membar_producer) eieio blr Modified: stable/12/sys/cddl/contrib/opensolaris/common/atomic/sparc64/opensolaris_atomic.S ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/common/atomic/sparc64/opensolaris_atomic.S Fri Nov 8 11:09:50 2019 (r354533) +++ stable/12/sys/cddl/contrib/opensolaris/common/atomic/sparc64/opensolaris_atomic.S Fri Nov 8 12:06:03 2019 (r354534) @@ -40,67 +40,6 @@ #endif /* - * NOTE: If atomic_add_64 and atomic_add_64_nv are ever - * separated, you need to also edit the libc sparcv9 platform - * specific mapfile and remove the NODYNSORT attribute - * from atomic_add_64_nv. - */ - ENTRY(atomic_add_64) - ALTENTRY(atomic_add_64_nv) - ALTENTRY(atomic_add_ptr) - ALTENTRY(atomic_add_ptr_nv) - ALTENTRY(atomic_add_long) - ALTENTRY(atomic_add_long_nv) -add_64: - ldx [%o0], %o2 -1: - add %o2, %o1, %o3 - casxa [%o0] __ASI_ATOMIC, %o2, %o3 - cmp %o2, %o3 - bne,a,pn %xcc, 1b - mov %o3, %o2 - retl - add %o2, %o1, %o0 ! return new value - SET_SIZE(atomic_add_long_nv) - SET_SIZE(atomic_add_long) - SET_SIZE(atomic_add_ptr_nv) - SET_SIZE(atomic_add_ptr) - SET_SIZE(atomic_add_64_nv) - SET_SIZE(atomic_add_64) - - /* - * NOTE: If atomic_or_8 and atomic_or_8_nv are ever - * separated, you need to also edit the libc sparcv9 platform - * specific mapfile and remove the NODYNSORT attribute - * from atomic_or_8_nv. - */ - ENTRY(atomic_or_8) - ALTENTRY(atomic_or_8_nv) - ALTENTRY(atomic_or_uchar) - and %o0, 0x3, %o4 ! %o4 = byte offset, left-to-right - xor %o4, 0x3, %g1 ! %g1 = byte offset, right-to-left - sll %g1, 3, %g1 ! %g1 = bit offset, right-to-left - set 0xff, %o3 ! %o3 = mask - sll %o3, %g1, %o3 ! %o3 = shifted to bit offset - sll %o1, %g1, %o1 ! %o1 = shifted to bit offset - and %o1, %o3, %o1 ! %o1 = single byte value - andn %o0, 0x3, %o0 ! %o0 = word address - ld [%o0], %o2 ! read old value -1: - or %o2, %o1, %o5 ! or in the new value - casa [%o0] __ASI_ATOMIC, %o2, %o5 - cmp %o2, %o5 - bne,a,pn %icc, 1b - mov %o5, %o2 ! %o2 = old value - or %o2, %o1, %o5 - and %o5, %o3, %o5 - retl - srl %o5, %g1, %o0 ! %o0 = new value - SET_SIZE(atomic_or_uchar) - SET_SIZE(atomic_or_8_nv) - SET_SIZE(atomic_or_8) - - /* * Spitfires and Blackbirds have a problem with membars in the * delay slot (SF_ERRATA_51). For safety's sake, we assume * that the whole world needs the workaround. From owner-svn-src-stable@freebsd.org Fri Nov 8 16:10:46 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8E0221B68FE; Fri, 8 Nov 2019 16:10:46 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 478lcQ3Cdvz4Y4N; Fri, 8 Nov 2019 16:10:46 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 516AD88D; Fri, 8 Nov 2019 16:10:46 +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 xA8GAkw9091116; Fri, 8 Nov 2019 16:10:46 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA8GAkwr091115; Fri, 8 Nov 2019 16:10:46 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201911081610.xA8GAkwr091115@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 8 Nov 2019 16:10:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354547 - stable/12/contrib/blacklist/bin X-SVN-Group: stable-12 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/12/contrib/blacklist/bin X-SVN-Commit-Revision: 354547 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.29 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, 08 Nov 2019 16:10:46 -0000 Author: emaste Date: Fri Nov 8 16:10:45 2019 New Revision: 354547 URL: https://svnweb.freebsd.org/changeset/base/354547 Log: MFC r353898: blacklistd: remove reference to NetBSD npfctl Xr pfctl instead PR: 221069 Submitted by: "fml" Modified: stable/12/contrib/blacklist/bin/blacklistd.8 Directory Properties: stable/12/ (props changed) Modified: stable/12/contrib/blacklist/bin/blacklistd.8 ============================================================================== --- stable/12/contrib/blacklist/bin/blacklistd.8 Fri Nov 8 15:26:23 2019 (r354546) +++ stable/12/contrib/blacklist/bin/blacklistd.8 Fri Nov 8 16:10:45 2019 (r354547) @@ -233,7 +233,7 @@ Socket to receive connection notifications. .Sh SEE ALSO .Xr blacklistd.conf 5 , .Xr blacklistctl 8 , -.Xr npfctl 8 , +.Xr pfctl 8 , .Xr syslogd 8 .Sh HISTORY .Nm From owner-svn-src-stable@freebsd.org Sat Nov 9 02:26:04 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 085C717A642; Sat, 9 Nov 2019 02:26:04 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4791GM71b2z4DYM; Sat, 9 Nov 2019 02:26:03 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D10687D24; Sat, 9 Nov 2019 02:26:03 +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 xA92Q3rG057016; Sat, 9 Nov 2019 02:26:03 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA92Q2SH057008; Sat, 9 Nov 2019 02:26:02 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201911090226.xA92Q2SH057008@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Sat, 9 Nov 2019 02:26:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354568 - in stable/12: cddl/contrib/opensolaris/cmd/zfs cddl/contrib/opensolaris/lib/libzfs/common lib/libbe sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris... X-SVN-Group: stable-12 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in stable/12: cddl/contrib/opensolaris/cmd/zfs cddl/contrib/opensolaris/lib/libzfs/common lib/libbe sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris/uts/common/sys/fs X-SVN-Commit-Revision: 354568 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.29 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, 09 Nov 2019 02:26:04 -0000 Author: asomers Date: Sat Nov 9 02:26:01 2019 New Revision: 354568 URL: https://svnweb.freebsd.org/changeset/base/354568 Log: MFC r354116, r354120 r354116: MFZoL: Avoid retrieving unused snapshot props This patch modifies the zfs_ioc_snapshot_list_next() ioctl to enable it to take input parameters that alter the way looping through the list of snapshots is performed. The idea here is to restrict functions that throw away some of the snapshots returned by the ioctl to a range of snapshots that these functions actually use. This improves efficiency and execution speed for some rollback and send operations. Reviewed-by: Tom Caputi Reviewed-by: Brian Behlendorf Reviewed by: Matt Ahrens Signed-off-by: Alek Pinchuk Closes #8077 zfsonlinux/zfs@4c0883fb4af0d5565459099b98fcf90ecbfa1ca1 r354120: Commit missing file from r354116 Pointy-hat-to: Me Reported by: Dan Mack MFC-With: 354116 Modified: stable/12/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c stable/12/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c stable/12/lib/libbe/be_info.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c stable/12/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h Directory Properties: stable/12/ (props changed) Modified: stable/12/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c ============================================================================== --- stable/12/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c Sat Nov 9 00:14:42 2019 (r354567) +++ stable/12/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c Sat Nov 9 02:26:01 2019 (r354568) @@ -139,7 +139,7 @@ zfs_callback(zfs_handle_t *zhp, void *data) ZFS_TYPE_BOOKMARK)) == 0) && include_snaps) (void) zfs_iter_snapshots(zhp, (cb->cb_flags & ZFS_ITER_SIMPLE) != 0, zfs_callback, - data); + data, 0, 0); if (((zfs_get_type(zhp) & (ZFS_TYPE_SNAPSHOT | ZFS_TYPE_BOOKMARK)) == 0) && include_bmarks) (void) zfs_iter_bookmarks(zhp, zfs_callback, data); Modified: stable/12/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c ============================================================================== --- stable/12/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Sat Nov 9 00:14:42 2019 (r354567) +++ stable/12/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Sat Nov 9 02:26:01 2019 (r354568) @@ -30,7 +30,7 @@ * Copyright (c) 2014 Integros [integros.com] * Copyright 2016 Igor Kozhukhov . * Copyright 2016 Nexenta Systems, Inc. - * Copyright (c) 2018 Datto Inc. + * Copyright (c) 2019 Datto Inc. */ #include @@ -1174,7 +1174,7 @@ destroy_print_snapshots(zfs_handle_t *fs_zhp, destroy_ int err = 0; assert(cb->cb_firstsnap == NULL); assert(cb->cb_prevsnap == NULL); - err = zfs_iter_snapshots_sorted(fs_zhp, destroy_print_cb, cb); + err = zfs_iter_snapshots_sorted(fs_zhp, destroy_print_cb, cb, 0, 0); if (cb->cb_firstsnap != NULL) { uint64_t used = 0; if (err == 0) { @@ -3437,6 +3437,7 @@ zfs_do_promote(int argc, char **argv) */ typedef struct rollback_cbdata { uint64_t cb_create; + uint8_t cb_younger_ds_printed; boolean_t cb_first; int cb_doclones; char *cb_target; @@ -3467,15 +3468,20 @@ rollback_check_dependent(zfs_handle_t *zhp, void *data } /* - * Report any snapshots more recent than the one specified. Used when '-r' is - * not specified. We reuse this same callback for the snapshot dependents - if - * 'cb_dependent' is set, then this is a dependent and we should report it - * without checking the transaction group. + * Report some snapshots/bookmarks more recent than the one specified. + * Used when '-r' is not specified. We reuse this same callback for the + * snapshot dependents - if 'cb_dependent' is set, then this is a + * dependent and we should report it without checking the transaction group. */ static int rollback_check(zfs_handle_t *zhp, void *data) { rollback_cbdata_t *cbp = data; + /* + * Max number of younger snapshots and/or bookmarks to display before + * we stop the iteration. + */ + const uint8_t max_younger = 32; if (cbp->cb_doclones) { zfs_close(zhp); @@ -3504,9 +3510,24 @@ rollback_check(zfs_handle_t *zhp, void *data) } else { (void) fprintf(stderr, "%s\n", zfs_get_name(zhp)); + cbp->cb_younger_ds_printed++; } } zfs_close(zhp); + + if (cbp->cb_younger_ds_printed == max_younger) { + /* + * This non-recursive rollback is going to fail due to the + * presence of snapshots and/or bookmarks that are younger than + * the rollback target. + * We printed some of the offending objects, now we stop + * zfs_iter_snapshot/bookmark iteration so we can fail fast and + * avoid iterating over the rest of the younger objects + */ + (void) fprintf(stderr, gettext("Output limited to %d " + "snapshots/bookmarks\n"), max_younger); + return (-1); + } return (0); } @@ -3520,6 +3541,7 @@ zfs_do_rollback(int argc, char **argv) zfs_handle_t *zhp, *snap; char parentname[ZFS_MAX_DATASET_NAME_LEN]; char *delim; + uint64_t min_txg = 0; /* check options */ while ((c = getopt(argc, argv, "rRf")) != -1) { @@ -3575,7 +3597,12 @@ zfs_do_rollback(int argc, char **argv) cb.cb_create = zfs_prop_get_int(snap, ZFS_PROP_CREATETXG); cb.cb_first = B_TRUE; cb.cb_error = 0; - if ((ret = zfs_iter_snapshots(zhp, B_FALSE, rollback_check, &cb)) != 0) + + if (cb.cb_create > 0) + min_txg = cb.cb_create; + + if ((ret = zfs_iter_snapshots(zhp, B_FALSE, rollback_check, &cb, + min_txg, 0)) != 0) goto out; if ((ret = zfs_iter_bookmarks(zhp, rollback_check, &cb)) != 0) goto out; Modified: stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h ============================================================================== --- stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Sat Nov 9 00:14:42 2019 (r354567) +++ stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Sat Nov 9 02:26:01 2019 (r354568) @@ -28,7 +28,7 @@ * Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright (c) 2014 Integros [integros.com] * Copyright 2016 Nexenta Systems, Inc. - * Copyright (c) 2017 Datto Inc. + * Copyright (c) 2019 Datto Inc. */ #ifndef _LIBZFS_H @@ -570,8 +570,10 @@ extern int zfs_iter_root(libzfs_handle_t *, zfs_iter_f extern int zfs_iter_children(zfs_handle_t *, zfs_iter_f, void *); extern int zfs_iter_dependents(zfs_handle_t *, boolean_t, zfs_iter_f, void *); extern int zfs_iter_filesystems(zfs_handle_t *, zfs_iter_f, void *); -extern int zfs_iter_snapshots(zfs_handle_t *, boolean_t, zfs_iter_f, void *); -extern int zfs_iter_snapshots_sorted(zfs_handle_t *, zfs_iter_f, void *); +extern int zfs_iter_snapshots(zfs_handle_t *, boolean_t, zfs_iter_f, void *, + uint64_t, uint64_t); +extern int zfs_iter_snapshots_sorted(zfs_handle_t *, zfs_iter_f, void *, + uint64_t, uint64_t); extern int zfs_iter_snapspec(zfs_handle_t *, const char *, zfs_iter_f, void *); extern int zfs_iter_bookmarks(zfs_handle_t *, zfs_iter_f, void *); Modified: stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c ============================================================================== --- stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Sat Nov 9 00:14:42 2019 (r354567) +++ stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Sat Nov 9 02:26:01 2019 (r354568) @@ -31,6 +31,7 @@ * Copyright 2017 Nexenta Systems, Inc. * Copyright 2016 Igor Kozhukhov * Copyright 2017-2018 RackTop Systems. + * Copyright (c) 2019 Datto Inc. */ #include @@ -4163,7 +4164,7 @@ zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, bo rollback_data_t cb = { 0 }; int err; boolean_t restore_resv = 0; - uint64_t old_volsize = 0, new_volsize; + uint64_t min_txg = 0, old_volsize = 0, new_volsize; zfs_prop_t resv_prop; assert(zhp->zfs_type == ZFS_TYPE_FILESYSTEM || @@ -4175,7 +4176,13 @@ zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, bo cb.cb_force = force; cb.cb_target = snap->zfs_name; cb.cb_create = zfs_prop_get_int(snap, ZFS_PROP_CREATETXG); - (void) zfs_iter_snapshots(zhp, B_FALSE, rollback_destroy, &cb); + + if (cb.cb_create > 0) + min_txg = cb.cb_create; + + (void) zfs_iter_snapshots(zhp, B_FALSE, rollback_destroy, &cb, + min_txg, 0); + (void) zfs_iter_bookmarks(zhp, rollback_destroy, &cb); if (cb.cb_error) Modified: stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c ============================================================================== --- stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c Sat Nov 9 00:14:42 2019 (r354567) +++ stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c Sat Nov 9 02:26:01 2019 (r354568) @@ -24,6 +24,7 @@ * Copyright (c) 2013, 2015 by Delphix. All rights reserved. * Copyright (c) 2012 Pawel Jakub Dawidek. All rights reserved. * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2019 Datto Inc. */ #include @@ -139,11 +140,12 @@ zfs_iter_filesystems(zfs_handle_t *zhp, zfs_iter_f fun */ int zfs_iter_snapshots(zfs_handle_t *zhp, boolean_t simple, zfs_iter_f func, - void *data) + void *data, uint64_t min_txg, uint64_t max_txg) { zfs_cmd_t zc = { 0 }; zfs_handle_t *nzhp; int ret; + nvlist_t *range_nvl = NULL; if (zhp->zfs_type == ZFS_TYPE_SNAPSHOT || zhp->zfs_type == ZFS_TYPE_BOOKMARK) @@ -153,6 +155,24 @@ zfs_iter_snapshots(zfs_handle_t *zhp, boolean_t simple if (zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0) != 0) return (-1); + + if (min_txg != 0) { + range_nvl = fnvlist_alloc(); + fnvlist_add_uint64(range_nvl, SNAP_ITER_MIN_TXG, min_txg); + } + if (max_txg != 0) { + if (range_nvl == NULL) + range_nvl = fnvlist_alloc(); + fnvlist_add_uint64(range_nvl, SNAP_ITER_MAX_TXG, max_txg); + } + + if (range_nvl != NULL && + zcmd_write_src_nvlist(zhp->zfs_hdl, &zc, range_nvl) != 0) { + zcmd_free_nvlists(&zc); + fnvlist_free(range_nvl); + return (-1); + } + while ((ret = zfs_do_list_ioctl(zhp, ZFS_IOC_SNAPSHOT_LIST_NEXT, &zc)) == 0) { @@ -165,10 +185,12 @@ zfs_iter_snapshots(zfs_handle_t *zhp, boolean_t simple if ((ret = func(nzhp, data)) != 0) { zcmd_free_nvlists(&zc); + fnvlist_free(range_nvl); return (ret); } } zcmd_free_nvlists(&zc); + fnvlist_free(range_nvl); return ((ret < 0) ? ret : 0); } @@ -276,7 +298,8 @@ zfs_snapshot_compare(const void *larg, const void *rar } int -zfs_iter_snapshots_sorted(zfs_handle_t *zhp, zfs_iter_f callback, void *data) +zfs_iter_snapshots_sorted(zfs_handle_t *zhp, zfs_iter_f callback, void *data, + uint64_t min_txg, uint64_t max_txg) { int ret = 0; zfs_node_t *node; @@ -286,7 +309,8 @@ zfs_iter_snapshots_sorted(zfs_handle_t *zhp, zfs_iter_ avl_create(&avl, zfs_snapshot_compare, sizeof (zfs_node_t), offsetof(zfs_node_t, zn_avlnode)); - ret = zfs_iter_snapshots(zhp, B_FALSE, zfs_sort_snaps, &avl); + ret = zfs_iter_snapshots(zhp, B_FALSE, zfs_sort_snaps, &avl, min_txg, + max_txg); for (node = avl_first(&avl); node != NULL; node = AVL_NEXT(&avl, node)) ret |= callback(node->zn_handle, data); @@ -389,7 +413,7 @@ zfs_iter_snapspec(zfs_handle_t *fs_zhp, const char *sp } err = zfs_iter_snapshots_sorted(fs_zhp, - snapspec_cb, &ssa); + snapspec_cb, &ssa, 0, 0); if (ret == 0) ret = err; if (ret == 0 && (!ssa.ssa_seenfirst || @@ -429,7 +453,7 @@ zfs_iter_children(zfs_handle_t *zhp, zfs_iter_f func, { int ret; - if ((ret = zfs_iter_snapshots(zhp, B_FALSE, func, data)) != 0) + if ((ret = zfs_iter_snapshots(zhp, B_FALSE, func, data, 0, 0)) != 0) return (ret); return (zfs_iter_filesystems(zhp, func, data)); @@ -495,7 +519,7 @@ iter_dependents_cb(zfs_handle_t *zhp, void *arg) err = zfs_iter_filesystems(zhp, iter_dependents_cb, ida); if (err == 0) { err = zfs_iter_snapshots(zhp, B_FALSE, - iter_dependents_cb, ida); + iter_dependents_cb, ida, 0, 0); } ida->stack = isf.next; } Modified: stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c ============================================================================== --- stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Sat Nov 9 00:14:42 2019 (r354567) +++ stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Sat Nov 9 02:26:01 2019 (r354568) @@ -28,6 +28,7 @@ * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved. * Copyright (c) 2014 Integros [integros.com] * Copyright 2016 Igor Kozhukhov + * Copyright (c) 2019 Datto Inc. */ #include @@ -612,6 +613,7 @@ typedef struct send_data { const char *tosnap; boolean_t recursive; boolean_t verbose; + boolean_t replicate; /* * The header nvlist is of the following format: @@ -789,6 +791,7 @@ send_iterate_fs(zfs_handle_t *zhp, void *arg) send_data_t *sd = arg; nvlist_t *nvfs, *nv; int rv = 0; + uint64_t min_txg = 0, max_txg = 0; uint64_t parent_fromsnap_guid_save = sd->parent_fromsnap_guid; uint64_t fromsnap_txg_save = sd->fromsnap_txg; uint64_t tosnap_txg_save = sd->tosnap_txg; @@ -832,10 +835,10 @@ send_iterate_fs(zfs_handle_t *zhp, void *arg) goto out; } - VERIFY(0 == nvlist_alloc(&nvfs, NV_UNIQUE_NAME, 0)); - VERIFY(0 == nvlist_add_string(nvfs, "name", zhp->zfs_name)); - VERIFY(0 == nvlist_add_uint64(nvfs, "parentfromsnap", - sd->parent_fromsnap_guid)); + nvfs = fnvlist_alloc(); + fnvlist_add_string(nvfs, "name", zhp->zfs_name); + fnvlist_add_uint64(nvfs, "parentfromsnap", + sd->parent_fromsnap_guid); if (zhp->zfs_dmustats.dds_origin[0]) { zfs_handle_t *origin = zfs_open(zhp->zfs_hdl, @@ -855,14 +858,19 @@ send_iterate_fs(zfs_handle_t *zhp, void *arg) nvlist_free(nv); /* iterate over snaps, and set sd->parent_fromsnap_guid */ + if (!sd->replicate && fromsnap_txg != 0) + min_txg = fromsnap_txg; + if (!sd->replicate && tosnap_txg != 0) + max_txg = tosnap_txg; sd->parent_fromsnap_guid = 0; VERIFY(0 == nvlist_alloc(&sd->parent_snaps, NV_UNIQUE_NAME, 0)); VERIFY(0 == nvlist_alloc(&sd->snapprops, NV_UNIQUE_NAME, 0)); - (void) zfs_iter_snapshots_sorted(zhp, send_iterate_snap, sd); + (void) zfs_iter_snapshots_sorted(zhp, send_iterate_snap, sd, + min_txg, max_txg); VERIFY(0 == nvlist_add_nvlist(nvfs, "snaps", sd->parent_snaps)); VERIFY(0 == nvlist_add_nvlist(nvfs, "snapprops", sd->snapprops)); - nvlist_free(sd->parent_snaps); - nvlist_free(sd->snapprops); + fnvlist_free(sd->parent_snaps); + fnvlist_free(sd->snapprops); /* add this fs to nvlist */ (void) snprintf(guidstring, sizeof (guidstring), @@ -886,11 +894,12 @@ out: static int gather_nvlist(libzfs_handle_t *hdl, const char *fsname, const char *fromsnap, const char *tosnap, boolean_t recursive, boolean_t verbose, - nvlist_t **nvlp, avl_tree_t **avlp) + boolean_t replicate, nvlist_t **nvlp, avl_tree_t **avlp) { zfs_handle_t *zhp; - send_data_t sd = { 0 }; int error; + uint64_t min_txg = 0, max_txg = 0; + send_data_t sd = { 0 }; zhp = zfs_open(hdl, fsname, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME); if (zhp == NULL) @@ -902,6 +911,7 @@ gather_nvlist(libzfs_handle_t *hdl, const char *fsname sd.tosnap = tosnap; sd.recursive = recursive; sd.verbose = verbose; + sd.replicate = replicate; if ((error = send_iterate_fs(zhp, &sd)) != 0) { nvlist_free(sd.fss); @@ -1338,6 +1348,7 @@ static int dump_filesystem(zfs_handle_t *zhp, void *arg) { int rv = 0; + uint64_t min_txg = 0, max_txg = 0; send_dump_data_t *sdd = arg; boolean_t missingfrom = B_FALSE; zfs_cmd_t zc = { 0 }; @@ -1373,7 +1384,15 @@ dump_filesystem(zfs_handle_t *zhp, void *arg) if (sdd->fromsnap == NULL || missingfrom) sdd->seenfrom = B_TRUE; - rv = zfs_iter_snapshots_sorted(zhp, dump_snapshot, arg); + if (!sdd->replicate && sdd->fromsnap != NULL) + min_txg = get_snap_txg(zhp->zfs_hdl, zhp->zfs_name, + sdd->fromsnap); + if (!sdd->replicate && sdd->tosnap != NULL) + max_txg = get_snap_txg(zhp->zfs_hdl, zhp->zfs_name, + sdd->tosnap); + + rv = zfs_iter_snapshots_sorted(zhp, dump_snapshot, arg, + min_txg, max_txg); if (!sdd->seenfrom) { (void) fprintf(stderr, dgettext(TEXT_DOMAIN, "WARNING: could not send %s@%s:\n" @@ -1834,7 +1853,7 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, cons err = gather_nvlist(zhp->zfs_hdl, zhp->zfs_name, fromsnap, tosnap, flags->replicate, flags->verbose, - &fss, &fsavl); + flags->replicate, &fss, &fsavl); if (err) goto err_out; VERIFY(0 == nvlist_add_nvlist(hdrnv, "fss", fss)); @@ -2477,7 +2496,7 @@ again: VERIFY(0 == nvlist_alloc(&deleted, NV_UNIQUE_NAME, 0)); if ((error = gather_nvlist(hdl, tofs, fromsnap, NULL, - recursive, B_FALSE, &local_nv, &local_avl)) != 0) + recursive, B_FALSE, B_FALSE, &local_nv, &local_avl)) != 0) return (error); /* @@ -3554,7 +3573,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const */ *cp = '\0'; if (gather_nvlist(hdl, zc.zc_value, NULL, NULL, B_FALSE, - B_FALSE, &local_nv, &local_avl) == 0) { + B_FALSE, B_FALSE, &local_nv, &local_avl) == 0) { *cp = '@'; fs = fsavl_find(local_avl, drrb->drr_toguid, NULL); fsavl_destroy(local_avl); Modified: stable/12/lib/libbe/be_info.c ============================================================================== --- stable/12/lib/libbe/be_info.c Sat Nov 9 00:14:42 2019 (r354567) +++ stable/12/lib/libbe/be_info.c Sat Nov 9 02:26:01 2019 (r354568) @@ -257,7 +257,8 @@ static int snapshot_proplist_update(zfs_handle_t *hdl, prop_data_t *data) { - return (zfs_iter_snapshots_sorted(hdl, prop_list_builder_cb, data)); + return (zfs_iter_snapshots_sorted(hdl, prop_list_builder_cb, data, + 0, 0)); } Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Sat Nov 9 00:14:42 2019 (r354567) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Sat Nov 9 02:26:01 2019 (r354568) @@ -33,7 +33,7 @@ * Copyright (c) 2014 Integros [integros.com] * Copyright 2016 Toomas Soome * Copyright 2017 RackTop Systems. - * Copyright (c) 2017 Datto Inc. + * Copyright (c) 2019 Datto Inc. */ /* @@ -2345,7 +2345,8 @@ dataset_name_hidden(const char *name) * inputs: * zc_name name of filesystem * zc_cookie zap cursor - * zc_nvlist_dst_size size of buffer for property nvlist + * zc_nvlist_src iteration range nvlist + * zc_nvlist_src_size size of iteration range nvlist * * outputs: * zc_name name of next filesystem @@ -2414,9 +2415,24 @@ top: static int zfs_ioc_snapshot_list_next(zfs_cmd_t *zc) { - objset_t *os; int error; + objset_t *os, *ossnap; + dsl_dataset_t *ds; + uint64_t min_txg = 0, max_txg = 0; + if (zc->zc_nvlist_src_size != 0) { + nvlist_t *props = NULL; + error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, + zc->zc_iflags, &props); + if (error != 0) + return (error); + (void) nvlist_lookup_uint64(props, SNAP_ITER_MIN_TXG, + &min_txg); + (void) nvlist_lookup_uint64(props, SNAP_ITER_MAX_TXG, + &max_txg); + nvlist_free(props); + } + error = dmu_objset_hold(zc->zc_name, FTAG, &os); if (error != 0) { return (error == ENOENT ? ESRCH : error); @@ -2432,26 +2448,52 @@ zfs_ioc_snapshot_list_next(zfs_cmd_t *zc) return (SET_ERROR(ESRCH)); } - error = dmu_snapshot_list_next(os, - sizeof (zc->zc_name) - strlen(zc->zc_name), - zc->zc_name + strlen(zc->zc_name), &zc->zc_obj, &zc->zc_cookie, - NULL); + while (error == 0) { + if (issig(JUSTLOOKING) && issig(FORREAL)) { + error = SET_ERROR(EINTR); + break; + } - if (error == 0 && !zc->zc_simple) { - dsl_dataset_t *ds; - dsl_pool_t *dp = os->os_dsl_dataset->ds_dir->dd_pool; + error = dmu_snapshot_list_next(os, + sizeof (zc->zc_name) - strlen(zc->zc_name), + zc->zc_name + strlen(zc->zc_name), &zc->zc_obj, + &zc->zc_cookie, NULL); + if (error == ENOENT) { + error = SET_ERROR(ESRCH); + break; + } else if (error != 0) { + break; + } - error = dsl_dataset_hold_obj(dp, zc->zc_obj, FTAG, &ds); - if (error == 0) { - objset_t *ossnap; + error = dsl_dataset_hold_obj(dmu_objset_pool(os), zc->zc_obj, + FTAG, &ds); + if (error != 0) + break; - error = dmu_objset_from_ds(ds, &ossnap); - if (error == 0) - error = zfs_ioc_objset_stats_impl(zc, ossnap); + if ((min_txg != 0 && dsl_get_creationtxg(ds) < min_txg) || + (max_txg != 0 && dsl_get_creationtxg(ds) > max_txg)) { dsl_dataset_rele(ds, FTAG); + /* undo snapshot name append */ + *(strchr(zc->zc_name, '@') + 1) = '\0'; + /* skip snapshot */ + continue; } - } else if (error == ENOENT) { - error = SET_ERROR(ESRCH); + + if (zc->zc_simple) { + dsl_dataset_rele(ds, FTAG); + break; + } + + if ((error = dmu_objset_from_ds(ds, &ossnap)) != 0) { + dsl_dataset_rele(ds, FTAG); + break; + } + if ((error = zfs_ioc_objset_stats_impl(zc, ossnap)) != 0) { + dsl_dataset_rele(ds, FTAG); + break; + } + dsl_dataset_rele(ds, FTAG); + break; } dmu_objset_rele(os, FTAG); Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h Sat Nov 9 00:14:42 2019 (r354567) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h Sat Nov 9 02:26:01 2019 (r354568) @@ -26,7 +26,7 @@ * Copyright (c) 2012, Martin Matuska . All rights reserved. * Copyright (c) 2014 Integros [integros.com] * Copyright 2017 Joyent, Inc. - * Copyright (c) 2017 Datto Inc. + * Copyright (c) 2019 Datto Inc. */ /* Portions Copyright 2010 Robert Milkowski */ @@ -1122,6 +1122,13 @@ typedef enum { #define ZCP_MAX_INSTRLIMIT (10 * ZCP_DEFAULT_INSTRLIMIT) #define ZCP_DEFAULT_MEMLIMIT (10 * 1024 * 1024) #define ZCP_MAX_MEMLIMIT (10 * ZCP_DEFAULT_MEMLIMIT) + +/* + * nvlist name constants. Facilitate restricting snapshot iteration range for + * the "list next snapshot" ioctl + */ +#define SNAP_ITER_MIN_TXG "snap_iter_min_txg" +#define SNAP_ITER_MAX_TXG "snap_iter_max_txg" /* * Sysevent payload members. ZFS will generate the following sysevents with the From owner-svn-src-stable@freebsd.org Sat Nov 9 11:55:03 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D4D381A71CC; Sat, 9 Nov 2019 11:55:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 479Ftv5Jvjz4fTX; Sat, 9 Nov 2019 11:55:03 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 97BE9E51B; Sat, 9 Nov 2019 11:55:03 +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 xA9Bt3N0097581; Sat, 9 Nov 2019 11:55:03 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA9Bt1Wv097573; Sat, 9 Nov 2019 11:55:01 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201911091155.xA9Bt1Wv097573@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 9 Nov 2019 11:55:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354569 - in stable/12/sys/amd64: amd64 include X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/12/sys/amd64: amd64 include X-SVN-Commit-Revision: 354569 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.29 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, 09 Nov 2019 11:55:03 -0000 Author: kib Date: Sat Nov 9 11:55:01 2019 New Revision: 354569 URL: https://svnweb.freebsd.org/changeset/base/354569 Log: MFC r354095, r354118, r354132: amd64: move pcb out of kstack to struct thread. Modified: stable/12/sys/amd64/amd64/cpu_switch.S stable/12/sys/amd64/amd64/genassym.c stable/12/sys/amd64/amd64/machdep.c stable/12/sys/amd64/amd64/pmap.c stable/12/sys/amd64/amd64/vm_machdep.c stable/12/sys/amd64/include/md_var.h stable/12/sys/amd64/include/pcb.h stable/12/sys/amd64/include/pcpu_aux.h stable/12/sys/amd64/include/proc.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/amd64/cpu_switch.S ============================================================================== --- stable/12/sys/amd64/amd64/cpu_switch.S Sat Nov 9 02:26:01 2019 (r354568) +++ stable/12/sys/amd64/amd64/cpu_switch.S Sat Nov 9 11:55:01 2019 (r354569) @@ -86,7 +86,7 @@ END(cpu_throw) */ ENTRY(cpu_switch) /* Switch to new thread. First, save context. */ - movq TD_PCB(%rdi),%r8 + leaq TD_MD_PCB(%rdi),%r8 movq (%rsp),%rax /* Hardware registers */ movq %r15,PCB_R15(%r8) @@ -152,7 +152,7 @@ ctx_switch_xsave: callq pmap_activate_sw SETLK %r15,TD_LOCK(%r13) /* Release the old thread */ sw1: - movq TD_PCB(%r12),%r8 + leaq TD_MD_PCB(%r12),%r8 #if defined(SCHED_ULE) && defined(SMP) /* Wait for the new thread to become unblocked */ movq $blocked_lock, %rdx @@ -207,11 +207,12 @@ do_kthread: cmpq %rax,%rdx jne do_tss done_tss: - movq %r8,PCPU(RSP0) + movq TD_MD_STACK_BASE(%r12),%r9 + movq %r9,PCPU(RSP0) movq %r8,PCPU(CURPCB) movq PCPU(PTI_RSP0),%rax cmpq $~0,PCPU(UCR3) - cmove %r8,%rax + cmove %r9,%rax movq %rax,TSS_RSP0(%rdx) movq %r12,PCPU(CURTHREAD) /* into next thread */ Modified: stable/12/sys/amd64/amd64/genassym.c ============================================================================== --- stable/12/sys/amd64/amd64/genassym.c Sat Nov 9 02:26:01 2019 (r354568) +++ stable/12/sys/amd64/amd64/genassym.c Sat Nov 9 11:55:01 2019 (r354569) @@ -87,6 +87,8 @@ ASSYM(TD_PFLAGS, offsetof(struct thread, td_pflags)); ASSYM(TD_PROC, offsetof(struct thread, td_proc)); ASSYM(TD_FRAME, offsetof(struct thread, td_frame)); ASSYM(TD_MD, offsetof(struct thread, td_md)); +ASSYM(TD_MD_PCB, offsetof(struct thread, td_md.md_pcb)); +ASSYM(TD_MD_STACK_BASE, offsetof(struct thread, td_md.md_stack_base)); ASSYM(TDF_ASTPENDING, TDF_ASTPENDING); ASSYM(TDF_NEEDRESCHED, TDF_NEEDRESCHED); Modified: stable/12/sys/amd64/amd64/machdep.c ============================================================================== --- stable/12/sys/amd64/amd64/machdep.c Sat Nov 9 02:26:01 2019 (r354568) +++ stable/12/sys/amd64/amd64/machdep.c Sat Nov 9 11:55:01 2019 (r354569) @@ -1805,12 +1805,12 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) amd64_conf_fast_syscall(); /* - * Temporary forge some valid pointer to PCB, for exception - * handlers. It is reinitialized properly below after FPU is - * set up. Also set up td_critnest to short-cut the page - * fault handler. + * We initialize the PCB pointer early so that exception + * handlers will work. Also set up td_critnest to short-cut + * the page fault handler. */ cpu_max_ext_state_size = sizeof(struct savefpu); + set_top_of_stack_td(&thread0); thread0.td_pcb = get_pcb_td(&thread0); thread0.td_critnest = 1; @@ -1866,11 +1866,10 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) fpuinit(); /* - * Set up thread0 pcb after fpuinit calculated pcb + fpu save + * Set up thread0 pcb save area after fpuinit calculated fpu save * area size. Zero out the extended state header in fpu save * area. */ - thread0.td_pcb = get_pcb_td(&thread0); thread0.td_pcb->pcb_save = get_pcb_user_save_td(&thread0); bzero(get_pcb_user_save_td(&thread0), cpu_max_ext_state_size); if (use_xsave) { @@ -1879,7 +1878,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) xhdr->xstate_bv = xsave_mask; } /* make an initial tss so cpu can get interrupt stack on syscall! */ - rsp0 = (vm_offset_t)thread0.td_pcb; + rsp0 = thread0.td_md.md_stack_base; /* Ensure the stack is aligned to 16 bytes */ rsp0 &= ~0xFul; common_tss[0].tss_rsp0 = rsp0; @@ -1915,7 +1914,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) TSEXIT(); /* Location of kernel stack for locore */ - return ((u_int64_t)thread0.td_pcb); + return (thread0.td_md.md_stack_base); } void Modified: stable/12/sys/amd64/amd64/pmap.c ============================================================================== --- stable/12/sys/amd64/amd64/pmap.c Sat Nov 9 02:26:01 2019 (r354568) +++ stable/12/sys/amd64/amd64/pmap.c Sat Nov 9 11:55:01 2019 (r354569) @@ -8370,7 +8370,7 @@ pmap_activate_sw_pti_post(struct thread *td, pmap_t pm { PCPU_GET(tssp)->tss_rsp0 = pmap->pm_ucr3 != PMAP_NO_CR3 ? - PCPU_GET(pti_rsp0) : (uintptr_t)td->td_pcb; + PCPU_GET(pti_rsp0) : (uintptr_t)td->td_md.md_stack_base; } static void inline Modified: stable/12/sys/amd64/amd64/vm_machdep.c ============================================================================== --- stable/12/sys/amd64/amd64/vm_machdep.c Sat Nov 9 02:26:01 2019 (r354568) +++ stable/12/sys/amd64/amd64/vm_machdep.c Sat Nov 9 11:55:01 2019 (r354569) @@ -87,37 +87,41 @@ __FBSDID("$FreeBSD$"); _Static_assert(OFFSETOF_MONITORBUF == offsetof(struct pcpu, pc_monitorbuf), "OFFSETOF_MONITORBUF does not correspond with offset of pc_monitorbuf."); -struct savefpu * -get_pcb_user_save_td(struct thread *td) +void +set_top_of_stack_td(struct thread *td) { - vm_offset_t p; - - p = td->td_kstack + td->td_kstack_pages * PAGE_SIZE - + td->td_md.md_stack_base = td->td_kstack + + td->td_kstack_pages * PAGE_SIZE - roundup2(cpu_max_ext_state_size, XSAVE_AREA_ALIGN); - KASSERT((p % XSAVE_AREA_ALIGN) == 0, ("Unaligned pcb_user_save area")); - return ((struct savefpu *)p); } struct savefpu * -get_pcb_user_save_pcb(struct pcb *pcb) +get_pcb_user_save_td(struct thread *td) { vm_offset_t p; - p = (vm_offset_t)(pcb + 1); + p = td->td_md.md_stack_base; + KASSERT((p % XSAVE_AREA_ALIGN) == 0, + ("Unaligned pcb_user_save area ptr %#lx td %p", p, td)); return ((struct savefpu *)p); } struct pcb * get_pcb_td(struct thread *td) { - vm_offset_t p; - p = td->td_kstack + td->td_kstack_pages * PAGE_SIZE - - roundup2(cpu_max_ext_state_size, XSAVE_AREA_ALIGN) - - sizeof(struct pcb); - return ((struct pcb *)p); + return (&td->td_md.md_pcb); } +struct savefpu * +get_pcb_user_save_pcb(struct pcb *pcb) +{ + struct thread *td; + + td = __containerof(pcb, struct thread, td_md.md_pcb); + return (get_pcb_user_save_td(td)); +} + void * alloc_fpusave(int flags) { @@ -165,9 +169,9 @@ cpu_fork(struct thread *td1, struct proc *p2, struct t fpuexit(td1); update_pcb_bases(td1->td_pcb); - /* Point the pcb to the top of the stack */ - pcb2 = get_pcb_td(td2); - td2->td_pcb = pcb2; + /* Point the stack and pcb to the actual location */ + set_top_of_stack_td(td2); + td2->td_pcb = pcb2 = get_pcb_td(td2); /* Copy td1's pcb */ bcopy(td1->td_pcb, pcb2, sizeof(*pcb2)); @@ -187,7 +191,7 @@ cpu_fork(struct thread *td1, struct proc *p2, struct t * Copy the trap frame for the return to user mode as if from a * syscall. This copies most of the user mode register values. */ - td2->td_frame = (struct trapframe *)td2->td_pcb - 1; + td2->td_frame = (struct trapframe *)td2->td_md.md_stack_base - 1; bcopy(td1->td_frame, td2->td_frame, sizeof(struct trapframe)); td2->td_frame->tf_rax = 0; /* Child returns zero */ @@ -352,8 +356,9 @@ cpu_thread_alloc(struct thread *td) struct pcb *pcb; struct xstate_hdr *xhdr; + set_top_of_stack_td(td); td->td_pcb = pcb = get_pcb_td(td); - td->td_frame = (struct trapframe *)pcb - 1; + td->td_frame = (struct trapframe *)td->td_md.md_stack_base - 1; pcb->pcb_save = get_pcb_user_save_pcb(pcb); if (use_xsave) { xhdr = (struct xstate_hdr *)(pcb->pcb_save + 1); @@ -491,7 +496,6 @@ cpu_copy_thread(struct thread *td, struct thread *td0) { struct pcb *pcb2; - /* Point the pcb to the top of the stack. */ pcb2 = td->td_pcb; /* Modified: stable/12/sys/amd64/include/md_var.h ============================================================================== --- stable/12/sys/amd64/include/md_var.h Sat Nov 9 02:26:01 2019 (r354568) +++ stable/12/sys/amd64/include/md_var.h Sat Nov 9 11:55:01 2019 (r354569) @@ -83,6 +83,7 @@ void fpstate_drop(struct thread *td); void pagezero(void *addr); void setidt(int idx, alias_for_inthand_t *func, int typ, int dpl, int ist); void sse2_pagezero(void *addr); +void set_top_of_stack_td(struct thread *td); struct savefpu *get_pcb_user_save_td(struct thread *td); struct savefpu *get_pcb_user_save_pcb(struct pcb *pcb); void pci_early_quirks(void); Modified: stable/12/sys/amd64/include/pcb.h ============================================================================== --- stable/12/sys/amd64/include/pcb.h Sat Nov 9 02:26:01 2019 (r354568) +++ stable/12/sys/amd64/include/pcb.h Sat Nov 9 11:55:01 2019 (r354569) @@ -116,6 +116,10 @@ struct susppcb { /* fpu context for suspend/resume */ void *sp_fpususpend; }; +#else /* 32bit */ +struct pcb { + uint64_t pcb_dummy[40]; +}; #endif #ifdef _KERNEL Modified: stable/12/sys/amd64/include/pcpu_aux.h ============================================================================== --- stable/12/sys/amd64/include/pcpu_aux.h Sat Nov 9 02:26:01 2019 (r354568) +++ stable/12/sys/amd64/include/pcpu_aux.h Sat Nov 9 11:55:01 2019 (r354569) @@ -57,16 +57,6 @@ __curthread(void) return (td); } #define curthread (__curthread()) - -static __inline __pure2 struct pcb * -__curpcb(void) -{ - struct pcb *pcb; - - __asm("movq %%gs:%P1,%0" : "=r" (pcb) : "n" (offsetof(struct pcpu, - pc_curpcb))); - return (pcb); -} -#define curpcb (__curpcb()) +#define curpcb (&curthread->td_md.md_pcb) #endif /* _MACHINE_PCPU_AUX_H_ */ Modified: stable/12/sys/amd64/include/proc.h ============================================================================== --- stable/12/sys/amd64/include/proc.h Sat Nov 9 02:26:01 2019 (r354568) +++ stable/12/sys/amd64/include/proc.h Sat Nov 9 11:55:01 2019 (r354569) @@ -36,6 +36,7 @@ #define _MACHINE_PROC_H_ #include +#include #include /* @@ -72,6 +73,8 @@ struct mdthread { struct pmap_invl_gen md_invl_gen; register_t md_efirt_tmp; /* (k) */ int md_efirt_dis_pf; /* (k) */ + struct pcb md_pcb; + vm_offset_t md_stack_base; }; struct mdproc {