From owner-svn-src-stable-9@FreeBSD.ORG Sun Jan 19 11:51:20 2014 Return-Path: Delivered-To: svn-src-stable-9@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 35A8945E; Sun, 19 Jan 2014 11:51:20 +0000 (UTC) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 9EF30165C; Sun, 19 Jan 2014 11:51:15 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id NAA17330; Sun, 19 Jan 2014 13:51:13 +0200 (EET) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1W4quH-0008KY-HO; Sun, 19 Jan 2014 13:51:13 +0200 Message-ID: <52DBBBF9.7050108@FreeBSD.org> Date: Sun, 19 Jan 2014 13:50:17 +0200 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Sergey Kandaurov , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-stable@FreeBSD.org, svn-src-stable-9@FreeBSD.org Subject: Re: svn commit: r260862 - stable/9/sys/sys References: <201401182121.s0ILLjkW048120@svn.freebsd.org> In-Reply-To: <201401182121.s0ILLjkW048120@svn.freebsd.org> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Jan 2014 11:51:20 -0000 on 18/01/2014 23:21 Sergey Kandaurov said the following: > Author: pluknet > Date: Sat Jan 18 21:21:44 2014 > New Revision: 260862 > URL: http://svnweb.freebsd.org/changeset/base/260862 > > Log: > MFC r250816: > > Protect SDT_PROBE() with do { } while (0) loop. Thanks a lot! > Modified: > stable/9/sys/sys/sdt.h > Directory Properties: > stable/9/sys/ (props changed) > stable/9/sys/sys/ (props changed) > > Modified: stable/9/sys/sys/sdt.h > ============================================================================== > --- stable/9/sys/sys/sdt.h Sat Jan 18 20:54:55 2014 (r260861) > +++ stable/9/sys/sys/sdt.h Sat Jan 18 21:21:44 2014 (r260862) > @@ -136,11 +136,12 @@ SET_DECLARE(sdt_argtypes_set, struct sdt > #define SDT_PROBE_DECLARE(prov, mod, func, name) \ > extern struct sdt_probe sdt_##prov##_##mod##_##func##_##name[1] > > -#define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) \ > +#define SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) do { \ > if (sdt_##prov##_##mod##_##func##_##name->id) \ > (*sdt_probe_func)(sdt_##prov##_##mod##_##func##_##name->id, \ > (uintptr_t) arg0, (uintptr_t) arg1, (uintptr_t) arg2, \ > - (uintptr_t) arg3, (uintptr_t) arg4) > + (uintptr_t) arg3, (uintptr_t) arg4); \ > +} while (0) > > #define SDT_PROBE_ARGTYPE(prov, mod, func, name, num, type) \ > static struct sdt_argtype sdt_##prov##_##mod##_##func##_##name##num[1] \ > -- Andriy Gapon From owner-svn-src-stable-9@FreeBSD.ORG Sun Jan 19 13:51:47 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 64413411; Sun, 19 Jan 2014 13:51:47 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4501B1EEB; Sun, 19 Jan 2014 13:51:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0JDplt3032210; Sun, 19 Jan 2014 13:51:47 GMT (envelope-from dumbbell@svn.freebsd.org) Received: (from dumbbell@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0JDplE2032209; Sun, 19 Jan 2014 13:51:47 GMT (envelope-from dumbbell@svn.freebsd.org) Message-Id: <201401191351.s0JDplE2032209@svn.freebsd.org> From: Jean-Sebastien Pedron Date: Sun, 19 Jan 2014 13:51:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r260881 - stable/9/sys/dev/acpica X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Jan 2014 13:51:47 -0000 Author: dumbbell Date: Sun Jan 19 13:51:46 2014 New Revision: 260881 URL: http://svnweb.freebsd.org/changeset/base/260881 Log: MFC r255077: acpi_thermal: Warn about insane _TMP temperature only once A warning is emitted again if the temperature became briefly valid meanwhile. This avoids spamming the user when the sensor is broken. Other values (ie. not _TMP) always raise a warning. Modified: stable/9/sys/dev/acpica/acpi_thermal.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/acpica/acpi_thermal.c ============================================================================== --- stable/9/sys/dev/acpica/acpi_thermal.c Sun Jan 19 13:48:02 2014 (r260880) +++ stable/9/sys/dev/acpica/acpi_thermal.c Sun Jan 19 13:51:46 2014 (r260881) @@ -111,6 +111,7 @@ struct acpi_tz_softc { struct acpi_tz_zone tz_zone; /*Thermal zone parameters*/ int tz_validchecks; + int tz_insane_tmp_notified; /* passive cooling */ struct proc *tz_cooling_proc; @@ -161,6 +162,8 @@ static driver_t acpi_tz_driver = { sizeof(struct acpi_tz_softc), }; +static char *acpi_tz_tmp_name = "_TMP"; + static devclass_t acpi_tz_devclass; DRIVER_MODULE(acpi_tz, acpi, acpi_tz_driver, acpi_tz_devclass, 0, 0); MODULE_DEPEND(acpi_tz, acpi, 1, 1, 1); @@ -456,12 +459,11 @@ acpi_tz_get_temperature(struct acpi_tz_s { int temp; ACPI_STATUS status; - static char *tmp_name = "_TMP"; ACPI_FUNCTION_NAME ("acpi_tz_get_temperature"); /* Evaluate the thermal zone's _TMP method. */ - status = acpi_GetInteger(sc->tz_handle, tmp_name, &temp); + status = acpi_GetInteger(sc->tz_handle, acpi_tz_tmp_name, &temp); if (ACPI_FAILURE(status)) { ACPI_VPRINT(sc->tz_dev, acpi_device_get_parent_softc(sc->tz_dev), "error fetching current temperature -- %s\n", @@ -470,7 +472,7 @@ acpi_tz_get_temperature(struct acpi_tz_s } /* Check it for validity. */ - acpi_tz_sanity(sc, &temp, tmp_name); + acpi_tz_sanity(sc, &temp, acpi_tz_tmp_name); if (temp == -1) return (FALSE); @@ -696,10 +698,29 @@ static void acpi_tz_sanity(struct acpi_tz_softc *sc, int *val, char *what) { if (*val != -1 && (*val < TZ_ZEROC || *val > TZ_ZEROC + 2000)) { - device_printf(sc->tz_dev, "%s value is absurd, ignored (%d.%dC)\n", - what, TZ_KELVTOC(*val)); + /* + * If the value we are checking is _TMP, warn the user only + * once. This avoids spamming messages if, for instance, the + * sensor is broken and always returns an invalid temperature. + * + * This is only done for _TMP; other values always emit a + * warning. + */ + if (what != acpi_tz_tmp_name || !sc->tz_insane_tmp_notified) { + device_printf(sc->tz_dev, "%s value is absurd, ignored (%d.%dC)\n", + what, TZ_KELVTOC(*val)); + + /* Don't warn the user again if the read value doesn't improve. */ + if (what == acpi_tz_tmp_name) + sc->tz_insane_tmp_notified = 1; + } *val = -1; + return; } + + /* This value is correct. Warn if it's incorrect again. */ + if (what == acpi_tz_tmp_name) + sc->tz_insane_tmp_notified = 0; } /* From owner-svn-src-stable-9@FreeBSD.ORG Sun Jan 19 19:49:25 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4ABF4776; Sun, 19 Jan 2014 19:49:25 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 366EA1762; Sun, 19 Jan 2014 19:49:25 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0JJnPR3069963; Sun, 19 Jan 2014 19:49:25 GMT (envelope-from gjb@svn.freebsd.org) Received: (from gjb@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0JJnPJi069962; Sun, 19 Jan 2014 19:49:25 GMT (envelope-from gjb@svn.freebsd.org) Message-Id: <201401191949.s0JJnPJi069962@svn.freebsd.org> From: Glen Barber Date: Sun, 19 Jan 2014 19:49:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r260891 - stable/9/release X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Jan 2014 19:49:25 -0000 Author: gjb Date: Sun Jan 19 19:49:24 2014 New Revision: 260891 URL: http://svnweb.freebsd.org/changeset/base/260891 Log: MFC r259729: Bootstrap etcupdate(8) as part of the release build, similar to what is done for mergemaster(8). This allows etcupdate(8) to work out-of-box after the first upgrade of a system. Sponsored by: The FreeBSD Foundation Modified: stable/9/release/Makefile Directory Properties: stable/9/release/ (props changed) Modified: stable/9/release/Makefile ============================================================================== --- stable/9/release/Makefile Sun Jan 19 19:39:13 2014 (r260890) +++ stable/9/release/Makefile Sun Jan 19 19:49:24 2014 (r260891) @@ -103,6 +103,8 @@ base.txz: # Set up mergemaster root database sh ${.CURDIR}/scripts/mm-mtree.sh -m ${WORLDDIR} -F \ "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" -D "${.OBJDIR}/${DISTDIR}/base" + etcupdate extract -B -M "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" \ + -d "${.OBJDIR}/${DISTDIR}/base/var/db/etcupdate" # Package all components cd ${WORLDDIR} && ${IMAKE} packageworld DISTDIR=${.OBJDIR}/${DISTDIR} mv ${DISTDIR}/*.txz . From owner-svn-src-stable-9@FreeBSD.ORG Mon Jan 20 15:33:32 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CEE8B151; Mon, 20 Jan 2014 15:33:32 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A068A1B04; Mon, 20 Jan 2014 15:33:32 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0KFXW94037233; Mon, 20 Jan 2014 15:33:32 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0KFXWh6037228; Mon, 20 Jan 2014 15:33:32 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201401201533.s0KFXWh6037228@svn.freebsd.org> From: Baptiste Daroussin Date: Mon, 20 Jan 2014 15:33:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r260909 - in stable/9: sbin/kldload share/man/man4 X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jan 2014 15:33:32 -0000 Author: bapt Date: Mon Jan 20 15:33:31 2014 New Revision: 260909 URL: http://svnweb.freebsd.org/changeset/base/260909 Log: MFH: r260483, r260484, r260594, r260595, r260596, r260597 Improve error message shown to the user when trying to load a module that is already loaded or compiled withing the kernel Point the user to dmesg(1) to get informations about why loading a module did fail instead of printing the cryptic "Exec format error" Update the BUGS section of kld(4) according the recent changes in kldload(8) Modified: stable/9/sbin/kldload/kldload.c stable/9/share/man/man4/kld.4 Directory Properties: stable/9/sbin/ (props changed) stable/9/sbin/kldload/ (props changed) stable/9/share/ (props changed) stable/9/share/man/ (props changed) stable/9/share/man/man4/ (props changed) Modified: stable/9/sbin/kldload/kldload.c ============================================================================== --- stable/9/sbin/kldload/kldload.c Mon Jan 20 15:00:21 2014 (r260908) +++ stable/9/sbin/kldload/kldload.c Mon Jan 20 15:33:31 2014 (r260909) @@ -181,7 +181,22 @@ main(int argc, char** argv) printf("%s is already " "loaded\n", argv[0]); } else { - warn("can't load %s", argv[0]); + switch (errno) { + case EEXIST: + warnx("can't load %s: module " + "already loaded or " + "in kernel", argv[0]); + break; + case ENOEXEC: + warnx("an error occurred while " + "loading the module. " + "Please check dmesg(8) for " + "more details."); + break; + default: + warn("can't load %s", argv[0]); + break; + } errors++; } } else { Modified: stable/9/share/man/man4/kld.4 ============================================================================== --- stable/9/share/man/man4/kld.4 Mon Jan 20 15:00:21 2014 (r260908) +++ stable/9/share/man/man4/kld.4 Mon Jan 20 15:33:31 2014 (r260909) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 8, 1998 +.Dd January 13, 2014 .Dt KLD 4 .Os .Sh NAME @@ -166,8 +166,8 @@ binary, then fails to execute the entry point. .Pp .Xr kldload 8 -returns the cryptic message -.Sq Li "ENOEXEC (Exec format error)" +points the user to read +.Xr dmesg 8 for any error encountered while loading a module. .Pp When system internal interfaces change, old modules often cannot From owner-svn-src-stable-9@FreeBSD.ORG Mon Jan 20 19:38:21 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1E778162; Mon, 20 Jan 2014 19:38:21 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 079B212FA; Mon, 20 Jan 2014 19:38:21 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0KJcKYF037038; Mon, 20 Jan 2014 19:38:20 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0KJcHpk037015; Mon, 20 Jan 2014 19:38:17 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201401201938.s0KJcHpk037015@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Mon, 20 Jan 2014 19:38:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r260919 - in stable/9/contrib/gcc: . cp doc X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jan 2014 19:38:21 -0000 Author: pfg Date: Mon Jan 20 19:38:16 2014 New Revision: 260919 URL: http://svnweb.freebsd.org/changeset/base/260919 Log: MFC r260014, r260099: gcc: Add support for label attributes and "unavailable" attribute. Apple GCC has extensions to support for both label attributes and an "unavailable" attribute. These are critical for objc but are also useful in regular C/C++. Obtained from: Apple GCC 4.2 - 5531 Added: stable/9/contrib/gcc/ChangeLog.apple - copied unchanged from r260014, head/contrib/gcc/ChangeLog.apple stable/9/contrib/gcc/cp/ChangeLog.apple - copied unchanged from r260014, head/contrib/gcc/cp/ChangeLog.apple Modified: stable/9/contrib/gcc/c-common.c stable/9/contrib/gcc/c-decl.c stable/9/contrib/gcc/c-parser.c stable/9/contrib/gcc/c-tree.h stable/9/contrib/gcc/c-typeck.c stable/9/contrib/gcc/cp/cp-gimplify.c stable/9/contrib/gcc/cp/cp-tree.def stable/9/contrib/gcc/cp/cp-tree.h stable/9/contrib/gcc/cp/decl.c stable/9/contrib/gcc/cp/dump.c stable/9/contrib/gcc/cp/init.c stable/9/contrib/gcc/cp/parser.c stable/9/contrib/gcc/cp/pt.c stable/9/contrib/gcc/cp/semantics.c stable/9/contrib/gcc/doc/extend.texi stable/9/contrib/gcc/dwarf2out.c stable/9/contrib/gcc/emit-rtl.c stable/9/contrib/gcc/final.c stable/9/contrib/gcc/print-rtl.c stable/9/contrib/gcc/print-tree.c stable/9/contrib/gcc/rtl.def stable/9/contrib/gcc/rtl.h stable/9/contrib/gcc/stmt.c stable/9/contrib/gcc/toplev.c stable/9/contrib/gcc/toplev.h stable/9/contrib/gcc/tree-cfg.c stable/9/contrib/gcc/tree.h Directory Properties: stable/9/ (props changed) stable/9/contrib/gcc/ (props changed) Copied: stable/9/contrib/gcc/ChangeLog.apple (from r260014, head/contrib/gcc/ChangeLog.apple) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/contrib/gcc/ChangeLog.apple Mon Jan 20 19:38:16 2014 (r260919, copy of r260014, head/contrib/gcc/ChangeLog.apple) @@ -0,0 +1,51 @@ +006-02-15 Fariborz Jahanian + + Radar 4445586 + * c-common.def (DO_STMT): Takes an extra argument. + +/* APPLE LOCAL merge marger */ +/* Stuff under is in fsf mainline, but not in the 4.2 branch */ + +2007-08-02 Geoffrey Keating + + Radar 3274130, 5295549 + * c-parser.c (c_parser_while_statement): Handle attributes. + (c_parser_do_statement): Handle attributes. + (c_parser_for_statement): Handle attributes. + * c-common.c (handle_unused_attribute): Warn if a statement + is marked as unused. + * c-tree.h (c_finish_loop): Add extra parameter. + * c-typeck.c (c_finish_loop): Handle attributes. + * doc/extend.texi (Attribute Syntax): Document statement attributes. + (Label Attributes): Explain how they apply to statements. + * tree-cfg.c (cleanup_dead_labels): Preserve labels with + user-specified alignment or attributes. + * stmt.c (expand_label): Update and correct documentation. + + * c-common.c (handle_aligned_attribute): Handle LABEL_DECL. + * rtl.def (CODE_LABEL): Add 8th operand. + * rtl.h (LABEL_ALIGN_LOG): New. + (LABEL_MAX_SKIP): New. + (SET_LABEL_ALIGN): New. + * emit-rtl.c (gen_label_rtx): Adjust. + * print-rtl.c (print_rtx): Print LABEL_ALIGN_LOG. + * stmt.c (label_rtx): Set CODE_LABEL's alignment from DECL_ALIGN. + (expand_label): Update documentation. + * final.c (struct label_alignment): Delete. + (label_align): Delete. + (min_labelno): Delete. + (max_labelno): Delete. + (LABEL_TO_ALIGNMENT): Delete. + (LABEL_TO_MAX_SKIP): Delete. + (label_to_alignment): Adjust for LABEL_ALIGN_LOG. + (align_fuzz): Likewise. + (compute_alignments): Likewise. + (shorten_branches): Remove code to set up label_align. + Adjust for LABEL_ALIGN_LOG. + (final_scan_insn): Adjust for LABEL_ALIGN_LOG. + * doc/extend.texi (C Extensions): Add 'Label Attributes' to menu. + (Attribute Syntax): Move label content to Label Attributes. + (Function Attributes): Mention label attributes. + (Variable Attributes): Mention label attributes. + (Type Attributes): Mention label attributes. + (Label Attributes): New. Modified: stable/9/contrib/gcc/c-common.c ============================================================================== --- stable/9/contrib/gcc/c-common.c Mon Jan 20 19:37:38 2014 (r260918) +++ stable/9/contrib/gcc/c-common.c Mon Jan 20 19:38:16 2014 (r260919) @@ -541,6 +541,9 @@ static tree handle_pure_attribute (tree static tree handle_novops_attribute (tree *, tree, tree, int, bool *); static tree handle_deprecated_attribute (tree *, tree, tree, int, bool *); +/* APPLE LOCAL begin "unavailable" attribute (Radar 2809697) --ilr */ +static tree handle_unavailable_attribute (tree *, tree, tree, int, bool *); +/* APPLE LOCAL end "unavailable" attribute --ilr */ static tree handle_vector_size_attribute (tree *, tree, tree, int, bool *); static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *); @@ -626,6 +629,10 @@ const struct attribute_spec c_common_att handle_novops_attribute }, { "deprecated", 0, 0, false, false, false, handle_deprecated_attribute }, + /* APPLE LOCAL begin "unavailable" attribute (Radar 2809697) --ilr */ + { "unavailable", 0, 0, false, false, false, + handle_unavailable_attribute }, + /* APPLE LOCAL end "unavailable" attribute --ilr */ { "vector_size", 1, 1, false, true, false, handle_vector_size_attribute }, { "visibility", 1, 1, false, false, false, @@ -4394,7 +4401,10 @@ handle_unused_attribute (tree *node, tre if (TREE_CODE (decl) == PARM_DECL || TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL - || TREE_CODE (decl) == LABEL_DECL +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + || (TREE_CODE (decl) == LABEL_DECL + && ! DECL_ARTIFICIAL (decl)) +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ || TREE_CODE (decl) == TYPE_DECL) TREE_USED (decl) = 1; else @@ -4842,7 +4852,10 @@ handle_aligned_attribute (tree *node, tr TYPE_USER_ALIGN (*type) = 1; } else if (! VAR_OR_FUNCTION_DECL_P (decl) - && TREE_CODE (decl) != FIELD_DECL) +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + && TREE_CODE (decl) != FIELD_DECL + && TREE_CODE (decl) != LABEL_DECL) +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ { error ("alignment may not be specified for %q+D", decl); *no_add_attrs = true; @@ -5345,6 +5358,69 @@ handle_deprecated_attribute (tree *node, return NULL_TREE; } +/* APPLE LOCAL begin "unavailable" attribute (Radar 2809697) --ilr */ +/* Handle a "unavailable" attribute; arguments as in + struct attribute_spec.handler. */ + +static tree +handle_unavailable_attribute (tree *node, tree name, + tree args ATTRIBUTE_UNUSED, + int flags ATTRIBUTE_UNUSED, + bool *no_add_attrs) +{ + tree type = NULL_TREE; + int warn = 0; + const char *what = NULL; + + if (DECL_P (*node)) + { + tree decl = *node; + type = TREE_TYPE (decl); + + if (TREE_CODE (decl) == TYPE_DECL + || TREE_CODE (decl) == PARM_DECL + || TREE_CODE (decl) == VAR_DECL + || TREE_CODE (decl) == FUNCTION_DECL + || TREE_CODE (decl) == FIELD_DECL) + /* Removed radar 3803157 - objc attribute */ + { + TREE_UNAVAILABLE (decl) = 1; + } + else + warn = 1; + } + else if (TYPE_P (*node)) + { + if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE)) + *node = build_variant_type_copy (*node); + TREE_UNAVAILABLE (*node) = 1; + type = *node; + } + else + warn = 1; + + if (warn) + { + *no_add_attrs = true; + if (type && TYPE_NAME (type)) + { + if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE) + what = IDENTIFIER_POINTER (TYPE_NAME (*node)); + else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL + && DECL_NAME (TYPE_NAME (type))) + what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))); + } + if (what) + warning (0, "`%s' attribute ignored for `%s'", + IDENTIFIER_POINTER (name), what); + else + warning (0, "`%s' attribute ignored", IDENTIFIER_POINTER (name)); + } + + return NULL_TREE; +} +/* APPLE LOCAL end "unavailable" attribute --ilr */ + /* Handle a "vector_size" attribute; arguments as in struct attribute_spec.handler. */ Modified: stable/9/contrib/gcc/c-decl.c ============================================================================== --- stable/9/contrib/gcc/c-decl.c Mon Jan 20 19:37:38 2014 (r260918) +++ stable/9/contrib/gcc/c-decl.c Mon Jan 20 19:38:16 2014 (r260919) @@ -453,10 +453,17 @@ add_stmt (tree t) with __attribute__((deprecated)). An object declared as __attribute__((deprecated)) suppresses warnings of uses of other deprecated items. */ +/* APPLE LOCAL begin "unavailable" attribute (radar 2809697) */ +/* Also add an __attribute__((unavailable)). An object declared as + __attribute__((unavailable)) suppresses any reports of being + declared with unavailable or deprecated items. */ +/* APPLE LOCAL end "unavailable" attribute (radar 2809697) */ enum deprecated_states { DEPRECATED_NORMAL, DEPRECATED_SUPPRESS + /* APPLE LOCAL "unavailable" attribute (radar 2809697) */ + , DEPRECATED_UNAVAILABLE_SUPPRESS }; static enum deprecated_states deprecated_state = DEPRECATED_NORMAL; @@ -1709,6 +1716,12 @@ merge_decls (tree newdecl, tree olddecl, if (TREE_DEPRECATED (newdecl)) TREE_DEPRECATED (olddecl) = 1; + /* APPLE LOCAL begin "unavailable" attribute (radar 2809697) */ + /* Merge unavailableness. */ + if (TREE_UNAVAILABLE (newdecl)) + TREE_UNAVAILABLE (olddecl) = 1; + /* APPLE LOCAL end "unavailable" attribute (radar 2809697) */ + /* Keep source location of definition rather than declaration and of prototype rather than non-prototype unless that prototype is built-in. */ @@ -3222,8 +3235,36 @@ start_decl (struct c_declarator *declara /* An object declared as __attribute__((deprecated)) suppresses warnings of uses of other deprecated items. */ + /* APPLE LOCAL begin "unavailable" attribute (radar 2809697) */ + /* An object declared as __attribute__((unavailable)) suppresses + any reports of being declared with unavailable or deprecated + items. An object declared as __attribute__((deprecated)) + suppresses warnings of uses of other deprecated items. */ +#ifdef A_LESS_INEFFICENT_WAY /* which I really don't want to do! */ if (lookup_attribute ("deprecated", attributes)) deprecated_state = DEPRECATED_SUPPRESS; + else if (lookup_attribute ("unavailable", attributes)) + deprecated_state = DEPRECATED_UNAVAILABLE_SUPPRESS; +#else /* a more efficient way doing what lookup_attribute would do */ + tree a; + + for (a = attributes; a; a = TREE_CHAIN (a)) + { + tree name = TREE_PURPOSE (a); + if (TREE_CODE (name) == IDENTIFIER_NODE) + if (is_attribute_p ("deprecated", name)) + { + deprecated_state = DEPRECATED_SUPPRESS; + break; + } + if (is_attribute_p ("unavailable", name)) + { + deprecated_state = DEPRECATED_UNAVAILABLE_SUPPRESS; + break; + } + } +#endif + /* APPLE LOCAL end "unavailable" attribute (radar 2809697) */ decl = grokdeclarator (declarator, declspecs, NORMAL, initialized, NULL); @@ -4087,6 +4128,11 @@ grokdeclarator (const struct c_declarato /* If this looks like a function definition, make it one, even if it occurs where parms are expected. Then store_parm_decls will reject it and not use it as a parm. */ + /* APPLE LOCAL begin "unavailable" attribute (radar 2809697) */ + if (declspecs->unavailable_p) + error_unavailable_use (declspecs->type); + else + /* APPLE LOCAL end "unavailable" attribute (radar 2809697) */ if (decl_context == NORMAL && !funcdef_flag && current_scope->parm_flag) decl_context = PARM; @@ -7267,6 +7313,8 @@ build_null_declspecs (void) ret->tag_defined_p = false; ret->explicit_signed_p = false; ret->deprecated_p = false; + /* APPLE LOCAL "unavailable" attribute (radar 2809697) */ + ret->unavailable_p = false; ret->default_int_p = false; ret->long_p = false; ret->long_long_p = false; @@ -7330,6 +7378,11 @@ declspecs_add_type (struct c_declspecs * if (TREE_DEPRECATED (type)) specs->deprecated_p = true; + /* APPLE LOCAL begin "unavailable" attribute (radar 2809697) */ + if (TREE_UNAVAILABLE (type)) + specs->unavailable_p = true; + /* APPLE LOCAL end "unavailable" attribute (radar 2809697) */ + /* Handle type specifier keywords. */ if (TREE_CODE (type) == IDENTIFIER_NODE && C_IS_RESERVED_WORD (type)) { Modified: stable/9/contrib/gcc/c-parser.c ============================================================================== --- stable/9/contrib/gcc/c-parser.c Mon Jan 20 19:37:38 2014 (r260918) +++ stable/9/contrib/gcc/c-parser.c Mon Jan 20 19:38:16 2014 (r260919) @@ -3940,16 +3940,25 @@ c_parser_switch_statement (c_parser *par /* Parse a while statement (C90 6.6.5, C99 6.8.5). while-statement: - while (expression) statement + APPLE LOCAL begin for-fsf-4_4 3274130 5295549 + while attributes (expression) statement + + The use of attributes is a GNU extension. + APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ static void c_parser_while_statement (c_parser *parser) { - tree block, cond, body, save_break, save_cont; +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + tree block, cond, body, save_break, save_cont, attrs; +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ location_t loc; gcc_assert (c_parser_next_token_is_keyword (parser, RID_WHILE)); c_parser_consume_token (parser); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + attrs = c_parser_attributes (parser); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ block = c_begin_compound_stmt (flag_isoc99); loc = c_parser_peek_token (parser)->location; cond = c_parser_paren_condition (parser); @@ -3958,7 +3967,10 @@ c_parser_while_statement (c_parser *pars save_cont = c_cont_label; c_cont_label = NULL_TREE; body = c_parser_c99_block_statement (parser); - c_finish_loop (loc, cond, NULL, body, c_break_label, c_cont_label, true); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + c_finish_loop (loc, cond, NULL, body, c_break_label, c_cont_label, attrs, + true); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ add_stmt (c_end_compound_stmt (block, flag_isoc99)); c_break_label = save_break; c_cont_label = save_cont; @@ -3967,16 +3979,25 @@ c_parser_while_statement (c_parser *pars /* Parse a do statement (C90 6.6.5, C99 6.8.5). do-statement: - do statement while ( expression ) ; + APPLE LOCAL begin for-fsf-4_4 3274130 5295549 + do attributes statement while ( expression ) ; + + The use of attributes is a GNU extension. + APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ static void c_parser_do_statement (c_parser *parser) { - tree block, cond, body, save_break, save_cont, new_break, new_cont; +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + tree block, cond, body, save_break, save_cont, new_break, new_cont, attrs; +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ location_t loc; gcc_assert (c_parser_next_token_is_keyword (parser, RID_DO)); c_parser_consume_token (parser); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + attrs = c_parser_attributes (parser); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ block = c_begin_compound_stmt (flag_isoc99); loc = c_parser_peek_token (parser)->location; save_break = c_break_label; @@ -3992,18 +4013,26 @@ c_parser_do_statement (c_parser *parser) cond = c_parser_paren_condition (parser); if (!c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>")) c_parser_skip_to_end_of_block_or_statement (parser); - c_finish_loop (loc, cond, NULL, body, new_break, new_cont, false); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + c_finish_loop (loc, cond, NULL, body, new_break, new_cont, attrs, false); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ add_stmt (c_end_compound_stmt (block, flag_isoc99)); } /* Parse a for statement (C90 6.6.5, C99 6.8.5). for-statement: - for ( expression[opt] ; expression[opt] ; expression[opt] ) statement - for ( nested-declaration expression[opt] ; expression[opt] ) statement + APPLE LOCAL begin for-fsf-4_4 3274130 5295549 + for attributes ( expression[opt] ; expression[opt] ; expression[opt] ) \ + statement + for attributes ( nested-declaration expression[opt] ; expression[opt] ) \ + statement The form with a declaration is new in C99. + The use of attributes is a GNU extension. + + APPLE LOCAL end for-fsf-4_4 3274130 5295549 ??? In accordance with the old parser, the declaration may be a nested function, which is then rejected in check_for_loop_decls, but does it make any sense for this to be included in the grammar? @@ -4015,11 +4044,16 @@ c_parser_do_statement (c_parser *parser) static void c_parser_for_statement (c_parser *parser) { - tree block, cond, incr, save_break, save_cont, body; +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + tree block, cond, incr, save_break, save_cont, body, attrs; +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ location_t loc; gcc_assert (c_parser_next_token_is_keyword (parser, RID_FOR)); loc = c_parser_peek_token (parser)->location; c_parser_consume_token (parser); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + attrs = c_parser_attributes (parser); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ block = c_begin_compound_stmt (flag_isoc99); if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { @@ -4094,7 +4128,10 @@ c_parser_for_statement (c_parser *parser save_cont = c_cont_label; c_cont_label = NULL_TREE; body = c_parser_c99_block_statement (parser); - c_finish_loop (loc, cond, incr, body, c_break_label, c_cont_label, true); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + c_finish_loop (loc, cond, incr, body, c_break_label, c_cont_label, attrs, + true); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ add_stmt (c_end_compound_stmt (block, flag_isoc99)); c_break_label = save_break; c_cont_label = save_cont; Modified: stable/9/contrib/gcc/c-tree.h ============================================================================== --- stable/9/contrib/gcc/c-tree.h Mon Jan 20 19:37:38 2014 (r260918) +++ stable/9/contrib/gcc/c-tree.h Mon Jan 20 19:38:16 2014 (r260919) @@ -257,6 +257,10 @@ struct c_declspecs { BOOL_BITFIELD explicit_signed_p : 1; /* Whether the specifiers include a deprecated typedef. */ BOOL_BITFIELD deprecated_p : 1; + /* APPLE LOCAL begin "unavailable" attribute (radar 2809697) */ + /* Whether the specifiers include a unavailable typedef. */ + BOOL_BITFIELD unavailable_p : 1; + /* APPLE LOCAL end "unavailable" attribute (radar 2809697) */ /* Whether the type defaulted to "int" because there were no type specifiers. */ BOOL_BITFIELD default_int_p; @@ -573,7 +577,10 @@ extern int c_types_compatible_p (tree, t extern tree c_begin_compound_stmt (bool); extern tree c_end_compound_stmt (tree, bool); extern void c_finish_if_stmt (location_t, tree, tree, tree, bool); -extern void c_finish_loop (location_t, tree, tree, tree, tree, tree, bool); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ +extern void c_finish_loop (location_t, tree, tree, tree, tree, tree, tree, + bool); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ extern tree c_begin_stmt_expr (void); extern tree c_finish_stmt_expr (tree); extern tree c_process_expr_stmt (tree); Modified: stable/9/contrib/gcc/c-typeck.c ============================================================================== --- stable/9/contrib/gcc/c-typeck.c Mon Jan 20 19:37:38 2014 (r260918) +++ stable/9/contrib/gcc/c-typeck.c Mon Jan 20 19:38:16 2014 (r260919) @@ -1849,6 +1849,11 @@ build_component_ref (tree datum, tree co if (TREE_DEPRECATED (subdatum)) warn_deprecated_use (subdatum); + /* APPLE LOCAL begin "unavailable" attribute (radar 2809697) */ + if (TREE_UNAVAILABLE (subdatum)) + error_unavailable_use (subdatum); + /* APPLE LOCAL end "unavailable" attribute (radar 2809697) */ + datum = ref; field = TREE_CHAIN (field); @@ -2090,6 +2095,11 @@ build_external_ref (tree id, int fun, lo if (TREE_DEPRECATED (ref)) warn_deprecated_use (ref); + /* APPLE LOCAL begin "unavailable" attribute (radar 2809697) */ + if (TREE_UNAVAILABLE (ref)) + error_unavailable_use (ref); + /* APPLE LOCAL end "unavailable" attribute (radar 2809697) */ + if (!skip_evaluation) assemble_external (ref); TREE_USED (ref) = 1; @@ -7247,15 +7257,22 @@ c_finish_if_stmt (location_t if_locus, t add_stmt (stmt); } -/* Emit a general-purpose loop construct. START_LOCUS is the location of - the beginning of the loop. COND is the loop condition. COND_IS_FIRST - is false for DO loops. INCR is the FOR increment expression. BODY is - the statement controlled by the loop. BLAB is the break label. CLAB is - the continue label. Everything is allowed to be NULL. */ +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ +/* Emit a general-purpose loop construct. START_LOCUS is the location + of the beginning of the loop. COND is the loop condition. + COND_IS_FIRST is false for DO loops. INCR is the FOR increment + expression. BODY is the statement controlled by the loop. BLAB is + the break label. CLAB is the continue label. ATTRS is the + attributes associated with the loop, which at present are + associated with the topmost label. Everything is allowed to be + NULL. */ +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ void c_finish_loop (location_t start_locus, tree cond, tree incr, tree body, - tree blab, tree clab, bool cond_is_first) +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + tree blab, tree clab, tree attrs, bool cond_is_first) +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ { tree entry = NULL, exit = NULL, t; Copied: stable/9/contrib/gcc/cp/ChangeLog.apple (from r260014, head/contrib/gcc/cp/ChangeLog.apple) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/contrib/gcc/cp/ChangeLog.apple Mon Jan 20 19:38:16 2014 (r260919, copy of r260014, head/contrib/gcc/cp/ChangeLog.apple) @@ -0,0 +1,31 @@ +2006-02-15 Fariborz Jahanian + + Radar 4445586 + * semantics.c (begin_do_stmt): DO_STMT nodes take an + extra argument to build. + + # APPLE LOCAL begin for-fsf-4_4 3274130 5295549 +2007-08-03 Geoffrey Keating + + Radar 5295549 + * parser.c (cp_parser_iteration_statement): Handle attributes. + * semantics.c (begin_for_stmt): Put attributes in built tree. + (begin_while_stmt): Put attributes in built tree. + (begin_do_stmt): Put attributes in built tree. + * pt.c (tsubst_expr): Handle attributes for FOR_STMT, WHILE_STMT, + DO_STMT. + * cp-gimplify.c (gimplify_cp_loop): Handle attributes. + (gimplify_for_stmt): Pass attributes to gimplify_cp_loop. + (gimplify_while_stmt): Pass attributes to gimplify_cp_loop. + (gimplify_do_stmt): Pass attributes to gimplify_cp_loop. + * dump.c (cp_dump_tree): Dump attributes for FOR_STMT, WHILE_STMT, + DO_STMT. + * cp-tree.h (begin_while_stmt): Update prototype. + (begin_do_stmt): Likewise. + (begin_for_stmt): Likewise. + * cp-tree.def (FOR_STMT): Add extra parameter. + (WHILE_STMT): Likewise. + (DO_STMT): Likewise. + * init.c (build_vec_init): Update for change to begin_for_stmt. + + # APPLE LOCAL end for-fsf-4_4 3274130 5295549 Modified: stable/9/contrib/gcc/cp/cp-gimplify.c ============================================================================== --- stable/9/contrib/gcc/cp/cp-gimplify.c Mon Jan 20 19:37:38 2014 (r260918) +++ stable/9/contrib/gcc/cp/cp-gimplify.c Mon Jan 20 19:38:16 2014 (r260919) @@ -188,7 +188,10 @@ gimplify_if_stmt (tree *stmt_p) loop body as in do-while loops. */ static tree -gimplify_cp_loop (tree cond, tree body, tree incr, bool cond_is_first) +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ +gimplify_cp_loop (tree cond, tree body, tree incr, tree attrs, + bool cond_is_first, tree inner_foreach) +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ { tree top, entry, exit, cont_block, break_block, stmt_list, t; location_t stmt_locus; @@ -223,6 +226,12 @@ gimplify_cp_loop (tree cond, tree body, out of the loop, or to the top of it. If there's no exit condition, then we just build a jump back to the top. */ exit = build_and_jump (&LABEL_EXPR_LABEL (top)); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + + /* Add the attributes to the 'top' label. */ + decl_attributes (&LABEL_EXPR_LABEL (top), attrs, 0); + +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ if (cond && !integer_nonzerop (cond)) { t = build_bc_goto (bc_break); @@ -270,8 +279,11 @@ gimplify_for_stmt (tree *stmt_p, tree *p if (FOR_INIT_STMT (stmt)) gimplify_and_add (FOR_INIT_STMT (stmt), pre_p); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ *stmt_p = gimplify_cp_loop (FOR_COND (stmt), FOR_BODY (stmt), - FOR_EXPR (stmt), 1); + FOR_EXPR (stmt), FOR_ATTRIBUTES (stmt), 1, + NULL_TREE); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ } /* Gimplify a WHILE_STMT node. */ @@ -280,8 +292,11 @@ static void gimplify_while_stmt (tree *stmt_p) { tree stmt = *stmt_p; +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ *stmt_p = gimplify_cp_loop (WHILE_COND (stmt), WHILE_BODY (stmt), - NULL_TREE, 1); + NULL_TREE, WHILE_ATTRIBUTES (stmt), 1, + NULL_TREE); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ } /* Gimplify a DO_STMT node. */ @@ -290,8 +305,11 @@ static void gimplify_do_stmt (tree *stmt_p) { tree stmt = *stmt_p; +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ *stmt_p = gimplify_cp_loop (DO_COND (stmt), DO_BODY (stmt), - NULL_TREE, 0); + NULL_TREE, DO_ATTRIBUTES (stmt), 0, + DO_FOREACH (stmt)); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ } /* Genericize a SWITCH_STMT by turning it into a SWITCH_EXPR. */ Modified: stable/9/contrib/gcc/cp/cp-tree.def ============================================================================== --- stable/9/contrib/gcc/cp/cp-tree.def Mon Jan 20 19:37:38 2014 (r260918) +++ stable/9/contrib/gcc/cp/cp-tree.def Mon Jan 20 19:38:16 2014 (r260919) @@ -281,18 +281,23 @@ DEFTREECODE (CLEANUP_STMT, "cleanup_stmt and COND_EXPR for the benefit of templates. */ DEFTREECODE (IF_STMT, "if_stmt", tcc_statement, 3) +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ /* Used to represent a `for' statement. The operands are - FOR_INIT_STMT, FOR_COND, FOR_EXPR, and FOR_BODY, respectively. */ -DEFTREECODE (FOR_STMT, "for_stmt", tcc_statement, 4) + FOR_INIT_STMT, FOR_COND, FOR_EXPR, FOR_BODY and FOR_ATTRIBUTES + respectively. */ +DEFTREECODE (FOR_STMT, "for_stmt", tcc_statement, 5) /* Used to represent a 'while' statement. The operands are WHILE_COND - and WHILE_BODY, respectively. */ -DEFTREECODE (WHILE_STMT, "while_stmt", tcc_statement, 2) + WHILE_BODY, and WHILE_ATTRIBUTES respectively. */ +DEFTREECODE (WHILE_STMT, "while_stmt", tcc_statement, 3) -/* Used to represent a 'do' statement. The operands are DO_BODY and - DO_COND, respectively. */ -DEFTREECODE (DO_STMT, "do_stmt", tcc_statement, 2) +/* APPLE LOCAL begin radar 4445586 */ +/* Used to represent a 'do' statement. The operands are DO_BODY, + DO_COND, DO_ATTRIBUTES, and DO_FOREACH respectively. */ +DEFTREECODE (DO_STMT, "do_stmt", tcc_statement, 4) +/* APPLE LOCAL end radar 4445586 */ +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ /* Used to represent a 'break' statement. */ DEFTREECODE (BREAK_STMT, "break_stmt", tcc_statement, 0) Modified: stable/9/contrib/gcc/cp/cp-tree.h ============================================================================== --- stable/9/contrib/gcc/cp/cp-tree.h Mon Jan 20 19:37:38 2014 (r260918) +++ stable/9/contrib/gcc/cp/cp-tree.h Mon Jan 20 19:38:16 2014 (r260919) @@ -3080,12 +3080,24 @@ extern void decl_shadowed_for_var_insert while statement and the body of the while statement, respectively. */ #define WHILE_COND(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 0) #define WHILE_BODY(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 1) +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ +#define WHILE_ATTRIBUTES(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 2) +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ /* DO_STMT accessors. These give access to the condition of the do statement and the body of the do statement, respectively. */ #define DO_COND(NODE) TREE_OPERAND (DO_STMT_CHECK (NODE), 0) #define DO_BODY(NODE) TREE_OPERAND (DO_STMT_CHECK (NODE), 1) +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ +#define DO_ATTRIBUTES(NODE) TREE_OPERAND (DO_STMT_CHECK (NODE), 2) +/* APPLE LOCAL begin C* language */ +/* Used as a flag to indicate synthesized inner do-while loop of a + foreach statement. Used for generation of break/continue statement + of the loop. */ +#define DO_FOREACH(NODE) TREE_OPERAND (DO_STMT_CHECK (NODE), 3) +/* APPLE LOCAL end C* language */ +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ /* FOR_STMT accessors. These give access to the init statement, condition, update expression, and body of the for statement, respectively. */ @@ -3093,7 +3105,10 @@ extern void decl_shadowed_for_var_insert #define FOR_COND(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 1) #define FOR_EXPR(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 2) #define FOR_BODY(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 3) +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ +#define FOR_ATTRIBUTES(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 4) +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ #define SWITCH_STMT_COND(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 0) #define SWITCH_STMT_BODY(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 1) #define SWITCH_STMT_TYPE(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 2) @@ -4258,14 +4273,20 @@ extern tree finish_then_clause (tree); extern void begin_else_clause (tree); extern void finish_else_clause (tree); extern void finish_if_stmt (tree); -extern tree begin_while_stmt (void); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ +extern tree begin_while_stmt (tree); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ extern void finish_while_stmt_cond (tree, tree); extern void finish_while_stmt (tree); -extern tree begin_do_stmt (void); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ +extern tree begin_do_stmt (tree); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ extern void finish_do_body (tree); extern void finish_do_stmt (tree, tree); extern tree finish_return_stmt (tree); -extern tree begin_for_stmt (void); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ +extern tree begin_for_stmt (tree); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ extern void finish_for_init_stmt (tree); extern void finish_for_cond (tree, tree); extern void finish_for_expr (tree, tree); Modified: stable/9/contrib/gcc/cp/decl.c ============================================================================== --- stable/9/contrib/gcc/cp/decl.c Mon Jan 20 19:37:38 2014 (r260918) +++ stable/9/contrib/gcc/cp/decl.c Mon Jan 20 19:38:16 2014 (r260919) @@ -232,10 +232,17 @@ int function_depth; with __attribute__((deprecated)). An object declared as __attribute__((deprecated)) suppresses warnings of uses of other deprecated items. */ +/* APPLE LOCAL begin "unavailable" attribute (radar 2809697) */ +/* An object declared as __attribute__((unavailable)) suppresses + any reports of being declared with unavailable or deprecated + items. */ +/* APPLE LOCAL end "unavailable" attribute (radar 2809697) */ enum deprecated_states { DEPRECATED_NORMAL, DEPRECATED_SUPPRESS + /* APPLE LOCAL "unavailable" attribute (radar 2809697) */ + , DEPRECATED_UNAVAILABLE_SUPPRESS }; static enum deprecated_states deprecated_state = DEPRECATED_NORMAL; @@ -3836,14 +3843,40 @@ start_decl (const cp_declarator *declara tree decl; tree type, tem; tree context; + /* APPLE LOCAL "unavailable" attribute (radar 2809697) */ + tree a; bool was_public; *pushed_scope_p = NULL_TREE; - /* An object declared as __attribute__((deprecated)) suppresses - warnings of uses of other deprecated items. */ + /* APPLE LOCAL begin "unavailable" attribute (radar 2809697) */ + /* An object declared as __attribute__((unavailable)) suppresses + any reports of being declared with unavailable or deprecated + items. An object declared as __attribute__((deprecated)) + suppresses warnings of uses of other deprecated items. */ +#ifdef A_LESS_INEFFICENT_WAY /* which I really don't want to do! */ if (lookup_attribute ("deprecated", attributes)) deprecated_state = DEPRECATED_SUPPRESS; + else if (lookup_attribute ("unavailable", attributes)) + deprecated_state = DEPRECATED_UNAVAILABLE_SUPPRESS; +#else /* a more efficient way doing what lookup_attribute would do */ + for (a = attributes; a; a = TREE_CHAIN (a)) + { + tree name = TREE_PURPOSE (a); + if (TREE_CODE (name) == IDENTIFIER_NODE) + if (is_attribute_p ("deprecated", name)) + { + deprecated_state = DEPRECATED_SUPPRESS; + break; + } + if (is_attribute_p ("unavailable", name)) + { + deprecated_state = DEPRECATED_UNAVAILABLE_SUPPRESS; + break; + } + } +#endif + /* APPLE LOCAL end "unavailable" attribute (radar 2809697) */ attributes = chainon (attributes, prefix_attributes); @@ -7274,6 +7307,19 @@ grokdeclarator (const cp_declarator *dec type = NULL_TREE; type_was_error_mark_node = true; } + + /* APPLE LOCAL begin unavailable attribute (radar 2809697) --bowdidge */ + /* If the entire declaration is itself tagged as unavailable then + suppress reports of unavailable/deprecated items. If the + entire declaration is tagged as only deprecated we still + report unavailable uses. */ + if (type && TREE_DEPRECATED (type) && TREE_UNAVAILABLE (type)) + { + if (deprecated_state != DEPRECATED_UNAVAILABLE_SUPPRESS) + warn_deprecated_use (type); + } + else + /* APPLE LOCAL end unavailable attribute (radar 2809697) --bowdidge */ /* If the entire declaration is itself tagged as deprecated then suppress reports of deprecated items. */ if (type && TREE_DEPRECATED (type) Modified: stable/9/contrib/gcc/cp/dump.c ============================================================================== --- stable/9/contrib/gcc/cp/dump.c Mon Jan 20 19:37:38 2014 (r260918) +++ stable/9/contrib/gcc/cp/dump.c Mon Jan 20 19:38:16 2014 (r260919) @@ -433,6 +433,9 @@ cp_dump_tree (void* dump_info, tree t) dump_stmt (di, t); dump_child ("body", DO_BODY (t)); dump_child ("cond", DO_COND (t)); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + dump_child ("attrs", DO_ATTRIBUTES (t)); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ break; case FOR_STMT: @@ -441,6 +444,9 @@ cp_dump_tree (void* dump_info, tree t) dump_child ("cond", FOR_COND (t)); dump_child ("expr", FOR_EXPR (t)); dump_child ("body", FOR_BODY (t)); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + dump_child ("attrs", FOR_ATTRIBUTES (t)); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ break; case SWITCH_STMT: @@ -453,6 +459,9 @@ cp_dump_tree (void* dump_info, tree t) dump_stmt (di, t); dump_child ("cond", WHILE_COND (t)); dump_child ("body", WHILE_BODY (t)); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + dump_child ("attrs", WHILE_ATTRIBUTES (t)); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ break; case STMT_EXPR: Modified: stable/9/contrib/gcc/cp/init.c ============================================================================== --- stable/9/contrib/gcc/cp/init.c Mon Jan 20 19:37:38 2014 (r260918) +++ stable/9/contrib/gcc/cp/init.c Mon Jan 20 19:38:16 2014 (r260919) @@ -2563,7 +2563,9 @@ build_vec_init (tree base, tree maxindex tree elt_init; tree to; - for_stmt = begin_for_stmt (); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + for_stmt = begin_for_stmt (NULL_TREE); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ finish_for_init_stmt (for_stmt); finish_for_cond (build2 (NE_EXPR, boolean_type_node, iterator, build_int_cst (TREE_TYPE (iterator), -1)), Modified: stable/9/contrib/gcc/cp/parser.c ============================================================================== --- stable/9/contrib/gcc/cp/parser.c Mon Jan 20 19:37:38 2014 (r260918) +++ stable/9/contrib/gcc/cp/parser.c Mon Jan 20 19:38:16 2014 (r260919) @@ -6787,6 +6787,16 @@ cp_parser_condition (cp_parser* parser) for ( for-init-statement condition [opt] ; expression [opt] ) statement + APPLE LOCAL begin for-fsf-4_4 3274130 5295549 + GNU extension: + + while attributes [opt] ( condition ) statement + do attributes [opt] statement while ( expression ) ; + for attributes [opt] + ( for-init-statement condition [opt] ; expression [opt] ) + statement + + APPLE LOCAL end for-fsf-4_4 3274130 5295549 Returns the new WHILE_STMT, DO_STMT, or FOR_STMT. */ static tree @@ -6794,10 +6804,14 @@ cp_parser_iteration_statement (cp_parser { cp_token *token; enum rid keyword; - tree statement; +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + tree statement, attributes; +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ unsigned char in_statement; - /* Peek at the next token. */ +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + /* Get the keyword at the start of the loop. */ +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ token = cp_parser_require (parser, CPP_KEYWORD, "iteration-statement"); if (!token) return error_mark_node; @@ -6806,6 +6820,11 @@ cp_parser_iteration_statement (cp_parser statement. */ in_statement = parser->in_statement; +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + /* Parse the attributes, if any. */ + attributes = cp_parser_attributes_opt (parser); + +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ /* See what kind of keyword it is. */ keyword = token->keyword; switch (keyword) @@ -6815,7 +6834,9 @@ cp_parser_iteration_statement (cp_parser tree condition; /* Begin the while-statement. */ - statement = begin_while_stmt (); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + statement = begin_while_stmt (attributes); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ /* Look for the `('. */ cp_parser_require (parser, CPP_OPEN_PAREN, "`('"); /* Parse the condition. */ @@ -6837,7 +6858,9 @@ cp_parser_iteration_statement (cp_parser tree expression; /* Begin the do-statement. */ - statement = begin_do_stmt (); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + statement = begin_do_stmt (attributes); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ /* Parse the body of the do-statement. */ parser->in_statement = IN_ITERATION_STMT; cp_parser_implicitly_scoped_statement (parser, NULL); @@ -6864,7 +6887,9 @@ cp_parser_iteration_statement (cp_parser tree expression = NULL_TREE; /* Begin the for-statement. */ - statement = begin_for_stmt (); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + statement = begin_for_stmt (attributes); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ /* Look for the `('. */ cp_parser_require (parser, CPP_OPEN_PAREN, "`('"); /* Parse the initialization. */ Modified: stable/9/contrib/gcc/cp/pt.c ============================================================================== --- stable/9/contrib/gcc/cp/pt.c Mon Jan 20 19:37:38 2014 (r260918) +++ stable/9/contrib/gcc/cp/pt.c Mon Jan 20 19:38:16 2014 (r260919) @@ -8593,8 +8593,11 @@ tsubst_expr (tree t, tree args, tsubst_f } case FOR_STMT: - stmt = begin_for_stmt (); - RECUR (FOR_INIT_STMT (t)); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + tmp = RECUR (FOR_ATTRIBUTES (t)); + stmt = begin_for_stmt (tmp); + RECUR (FOR_INIT_STMT (t)); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ finish_for_init_stmt (stmt); tmp = RECUR (FOR_COND (t)); finish_for_cond (tmp, stmt); @@ -8605,7 +8608,10 @@ tsubst_expr (tree t, tree args, tsubst_f break; case WHILE_STMT: - stmt = begin_while_stmt (); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + tmp = RECUR (WHILE_ATTRIBUTES (t)); + stmt = begin_while_stmt (tmp); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ tmp = RECUR (WHILE_COND (t)); finish_while_stmt_cond (tmp, stmt); RECUR (WHILE_BODY (t)); @@ -8613,7 +8619,10 @@ tsubst_expr (tree t, tree args, tsubst_f break; case DO_STMT: - stmt = begin_do_stmt (); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + tmp = RECUR (DO_ATTRIBUTES (t)); + stmt = begin_do_stmt (tmp); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ RECUR (DO_BODY (t)); finish_do_body (stmt); tmp = RECUR (DO_COND (t)); Modified: stable/9/contrib/gcc/cp/semantics.c ============================================================================== --- stable/9/contrib/gcc/cp/semantics.c Mon Jan 20 19:37:38 2014 (r260918) +++ stable/9/contrib/gcc/cp/semantics.c Mon Jan 20 19:38:16 2014 (r260919) @@ -704,10 +704,14 @@ finish_if_stmt (tree if_stmt) appropriate. */ tree -begin_while_stmt (void) +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ +begin_while_stmt (tree attribs) +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ { tree r; - r = build_stmt (WHILE_STMT, NULL_TREE, NULL_TREE); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + r = build_stmt (WHILE_STMT, NULL_TREE, NULL_TREE, attribs); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ add_stmt (r); WHILE_BODY (r) = do_pushlevel (sk_block); begin_cond (&WHILE_COND (r)); @@ -737,9 +741,14 @@ finish_while_stmt (tree while_stmt) appropriate. */ tree -begin_do_stmt (void) -{ - tree r = build_stmt (DO_STMT, NULL_TREE, NULL_TREE); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ +begin_do_stmt (tree attribs) +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ +{ + /* APPLE LOCAL radar 4445586 */ +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + tree r = build_stmt (DO_STMT, NULL_TREE, NULL_TREE, attribs, NULL_TREE); +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ add_stmt (r); DO_BODY (r) = push_stmt_list (); return r; @@ -803,12 +812,17 @@ finish_return_stmt (tree expr) /* Begin a for-statement. Returns a new FOR_STMT if appropriate. */ tree -begin_for_stmt (void) +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ +begin_for_stmt (tree attribs) +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ { tree r; r = build_stmt (FOR_STMT, NULL_TREE, NULL_TREE, - NULL_TREE, NULL_TREE); +/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \ + NULL_TREE, NULL_TREE, attribs); + +/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \ if (flag_new_for_scope > 0) TREE_CHAIN (r) = do_pushlevel (sk_for); Modified: stable/9/contrib/gcc/doc/extend.texi ============================================================================== --- stable/9/contrib/gcc/doc/extend.texi Mon Jan 20 19:37:38 2014 (r260918) +++ stable/9/contrib/gcc/doc/extend.texi Mon Jan 20 19:38:16 2014 (r260919) @@ -58,6 +58,9 @@ extensions, accepted by GCC in C89 mode * Character Escapes:: @samp{\e} stands for the character @key{ESC}. * Variable Attributes:: Specifying attributes of variables. * Type Attributes:: Specifying attributes of types. +@c APPLE LOCAL begin for-fsf-4_4 3274130 5295549 +* Label Attributes:: Specifying attributes of labels and statements. +@c APPLE LOCAL end for-fsf-4_4 3274130 5295549 * Alignment:: Inquiring about the alignment of a type or variable. * Inline:: Defining inline functions (as fast as macros). * Extended Asm:: Assembler instructions with C expressions as operands. @@ -1587,8 +1590,11 @@ attributes are currently defined for fun @code{gnu_inline} and @code{externally_visible}. Several other attributes are defined for functions on particular target systems. Other *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-9@FreeBSD.ORG Mon Jan 20 20:34:31 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 956C61F2; Mon, 20 Jan 2014 20:34:31 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 80DAF182B; Mon, 20 Jan 2014 20:34:31 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0KKYV4D060999; Mon, 20 Jan 2014 20:34:31 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0KKYVlF060998; Mon, 20 Jan 2014 20:34:31 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201401202034.s0KKYVlF060998@svn.freebsd.org> From: Mikolaj Golub Date: Mon, 20 Jan 2014 20:34:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r260925 - stable/9/usr.bin/script X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jan 2014 20:34:31 -0000 Author: trociny Date: Mon Jan 20 20:34:31 2014 New Revision: 260925 URL: http://svnweb.freebsd.org/changeset/base/260925 Log: MFC r260833: Bring back r226403, the fix for bin/161526, which was (accidentally?) reverted in r238896. PR: bin/161526 Reported by: Karli.Sjoberg slu.se Modified: stable/9/usr.bin/script/script.c Directory Properties: stable/9/usr.bin/script/ (props changed) Modified: stable/9/usr.bin/script/script.c ============================================================================== --- stable/9/usr.bin/script/script.c Mon Jan 20 20:33:40 2014 (r260924) +++ stable/9/usr.bin/script/script.c Mon Jan 20 20:34:31 2014 (r260925) @@ -235,12 +235,15 @@ main(int argc, char *argv[]) FD_SET(master, &rfd); if (readstdin) FD_SET(STDIN_FILENO, &rfd); - if ((!readstdin && ttyflg) || flushtime > 0) { - tv.tv_sec = !readstdin && ttyflg ? 1 : - flushtime - (tvec - start); + if (!readstdin && ttyflg) { + tv.tv_sec = 1; tv.tv_usec = 0; tvp = &tv; readstdin = 1; + } else if (flushtime > 0) { + tv.tv_sec = flushtime - (tvec - start); + tv.tv_usec = 0; + tvp = &tv; } else { tvp = NULL; } From owner-svn-src-stable-9@FreeBSD.ORG Mon Jan 20 21:52:01 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3431CC2C; Mon, 20 Jan 2014 21:52:01 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 1F5E11F94; Mon, 20 Jan 2014 21:52:01 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0KLq1Rc003286; Mon, 20 Jan 2014 21:52:01 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0KLq0rM003279; Mon, 20 Jan 2014 21:52:00 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201401202152.s0KLq0rM003279@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Mon, 20 Jan 2014 21:52:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r260933 - stable/9/contrib/gcc/cp X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jan 2014 21:52:01 -0000 Author: pfg Date: Mon Jan 20 21:52:00 2014 New Revision: 260933 URL: http://svnweb.freebsd.org/changeset/base/260933 Log: MFC r260332; gcc: backport some fixes from llvm-gcc llvm-gcc backported some patches from gcc trunk: http://gcc.gnu.org/ml/gcc-cvs/2007-05/msg00662.html http://gcc.gnu.org/ml/gcc-cvs/2007-07/msg00019.html http://gcc.gnu.org/ml/gcc-cvs/2007-08/msg00240.html http://gcc.gnu.org/ml/gcc-cvs/2007-08/msg00493.html The first two were always GPL2. The last two were added after the GPL3 transition, but were written by aaw@google.com and Rafael Espíndola got permission to relicense them under the GPL2 for inclusion in llvm-gcc. This fixes GCC-PR c++/31749 Obtained from: llvm-gcc (rev. 75463; GPLv2) Modified: stable/9/contrib/gcc/cp/decl.c stable/9/contrib/gcc/cp/name-lookup.c stable/9/contrib/gcc/cp/parser.c Directory Properties: stable/9/ (props changed) stable/9/contrib/gcc/ (props changed) Modified: stable/9/contrib/gcc/cp/decl.c ============================================================================== --- stable/9/contrib/gcc/cp/decl.c Mon Jan 20 21:50:31 2014 (r260932) +++ stable/9/contrib/gcc/cp/decl.c Mon Jan 20 21:52:00 2014 (r260933) @@ -9784,6 +9784,12 @@ lookup_and_check_tag (enum tag_types tag | DECL_SELF_REFERENCE_P (decl)); return t; } + else if (decl && TREE_CODE (decl) == TREE_LIST) + { + error ("reference to %qD is ambiguous", name); + print_candidates (decl); + return error_mark_node; + } else return NULL_TREE; } Modified: stable/9/contrib/gcc/cp/name-lookup.c ============================================================================== --- stable/9/contrib/gcc/cp/name-lookup.c Mon Jan 20 21:50:31 2014 (r260932) +++ stable/9/contrib/gcc/cp/name-lookup.c Mon Jan 20 21:52:00 2014 (r260933) @@ -42,7 +42,6 @@ struct scope_binding { #define EMPTY_SCOPE_BINDING { NULL_TREE, NULL_TREE } static cxx_scope *innermost_nonclass_level (void); -static tree select_decl (const struct scope_binding *, int); static cxx_binding *binding_for_name (cxx_scope *, tree); static tree lookup_name_innermost_nonclass_level (tree); static tree push_overloaded_decl (tree, int, bool); @@ -2082,6 +2081,22 @@ do_nonmember_using_decl (tree scope, tre return; } + /* LLVM LOCAL begin mainline */ + /* Shift the old and new bindings around so we're comparing class and + enumeration names to each other. */ + if (oldval && DECL_IMPLICIT_TYPEDEF_P (oldval)) + { + oldtype = oldval; + oldval = NULL_TREE; + } + + if (decls.value && DECL_IMPLICIT_TYPEDEF_P (decls.value)) + { + decls.type = decls.value; + decls.value = NULL_TREE; + } + /* LLVM LOCAL end mainline */ + /* It is impossible to overload a built-in function; any explicit declaration eliminates the built-in declaration. So, if OLDVAL is a built-in, then we can just pretend it isn't there. */ @@ -2091,95 +2106,112 @@ do_nonmember_using_decl (tree scope, tre && !DECL_HIDDEN_FRIEND_P (oldval)) oldval = NULL_TREE; - /* Check for using functions. */ - if (decls.value && is_overloaded_fn (decls.value)) + /* LLVM LOCAL begin mainline */ + if (decls.value) { - tree tmp, tmp1; - - if (oldval && !is_overloaded_fn (oldval)) - { - if (!DECL_IMPLICIT_TYPEDEF_P (oldval)) - error ("%qD is already declared in this scope", name); - oldval = NULL_TREE; - } - - *newval = oldval; - for (tmp = decls.value; tmp; tmp = OVL_NEXT (tmp)) + /* Check for using functions. */ + if (is_overloaded_fn (decls.value)) { - tree new_fn = OVL_CURRENT (tmp); + tree tmp, tmp1; - /* [namespace.udecl] + if (oldval && !is_overloaded_fn (oldval)) + { + error ("%qD is already declared in this scope", name); + oldval = NULL_TREE; + } - If a function declaration in namespace scope or block - scope has the same name and the same parameter types as a - function introduced by a using declaration the program is - ill-formed. */ - for (tmp1 = oldval; tmp1; tmp1 = OVL_NEXT (tmp1)) + *newval = oldval; + for (tmp = decls.value; tmp; tmp = OVL_NEXT (tmp)) { - tree old_fn = OVL_CURRENT (tmp1); + tree new_fn = OVL_CURRENT (tmp); - if (new_fn == old_fn) - /* The function already exists in the current namespace. */ - break; - else if (OVL_USED (tmp1)) - continue; /* this is a using decl */ - else if (compparms (TYPE_ARG_TYPES (TREE_TYPE (new_fn)), - TYPE_ARG_TYPES (TREE_TYPE (old_fn)))) + /* [namespace.udecl] + + If a function declaration in namespace scope or block + scope has the same name and the same parameter types as a + function introduced by a using declaration the program is + ill-formed. */ + for (tmp1 = oldval; tmp1; tmp1 = OVL_NEXT (tmp1)) { - gcc_assert (!DECL_ANTICIPATED (old_fn) - || DECL_HIDDEN_FRIEND_P (old_fn)); + tree old_fn = OVL_CURRENT (tmp1); - /* There was already a non-using declaration in - this scope with the same parameter types. If both - are the same extern "C" functions, that's ok. */ - if (decls_match (new_fn, old_fn)) + if (new_fn == old_fn) + /* The function already exists in the current namespace. */ break; - else + else if (OVL_USED (tmp1)) + continue; /* this is a using decl */ + else if (compparms (TYPE_ARG_TYPES (TREE_TYPE (new_fn)), + TYPE_ARG_TYPES (TREE_TYPE (old_fn)))) { - error ("%qD is already declared in this scope", name); - break; + gcc_assert (!DECL_ANTICIPATED (old_fn) + || DECL_HIDDEN_FRIEND_P (old_fn)); + + /* There was already a non-using declaration in + this scope with the same parameter types. If both + are the same extern "C" functions, that's ok. */ + if (decls_match (new_fn, old_fn)) + break; + else + { + error ("%qD is already declared in this scope", name); + break; + } } } - } - /* If we broke out of the loop, there's no reason to add - this function to the using declarations for this - scope. */ - if (tmp1) - continue; - - /* If we are adding to an existing OVERLOAD, then we no - longer know the type of the set of functions. */ - if (*newval && TREE_CODE (*newval) == OVERLOAD) - TREE_TYPE (*newval) = unknown_type_node; - /* Add this new function to the set. */ - *newval = build_overload (OVL_CURRENT (tmp), *newval); - /* If there is only one function, then we use its type. (A - using-declaration naming a single function can be used in - contexts where overload resolution cannot be - performed.) */ - if (TREE_CODE (*newval) != OVERLOAD) - { - *newval = ovl_cons (*newval, NULL_TREE); - TREE_TYPE (*newval) = TREE_TYPE (OVL_CURRENT (tmp)); + /* If we broke out of the loop, there's no reason to add + this function to the using declarations for this + scope. */ + if (tmp1) + continue; + + /* If we are adding to an existing OVERLOAD, then we no + longer know the type of the set of functions. */ + if (*newval && TREE_CODE (*newval) == OVERLOAD) + TREE_TYPE (*newval) = unknown_type_node; + /* Add this new function to the set. */ + *newval = build_overload (OVL_CURRENT (tmp), *newval); + /* If there is only one function, then we use its type. (A + using-declaration naming a single function can be used in + contexts where overload resolution cannot be + performed.) */ + if (TREE_CODE (*newval) != OVERLOAD) + { + *newval = ovl_cons (*newval, NULL_TREE); + TREE_TYPE (*newval) = TREE_TYPE (OVL_CURRENT (tmp)); + } + OVL_USED (*newval) = 1; } - OVL_USED (*newval) = 1; + } + else + { + *newval = decls.value; + if (oldval && !decls_match (*newval, oldval)) + error ("%qD is already declared in this scope", name); } } else + *newval = oldval; + + if (decls.type && TREE_CODE (decls.type) == TREE_LIST) { - *newval = decls.value; - if (oldval && !decls_match (*newval, oldval)) - error ("%qD is already declared in this scope", name); + error ("reference to %qD is ambiguous", name); + print_candidates (decls.type); } - - *newtype = decls.type; - if (oldtype && *newtype && !same_type_p (oldtype, *newtype)) + else { - error ("using declaration %qD introduced ambiguous type %qT", - name, oldtype); - return; + *newtype = decls.type; + if (oldtype && *newtype && !decls_match (oldtype, *newtype)) + error ("%qD is already declared in this scope", name); } + + /* If *newval is empty, shift any class or enumeration name down. */ + if (!*newval) + { + *newval = *newtype; + *newtype = NULL_TREE; + } + /* LLVM LOCAL end mainline */ } /* Process a using-declaration at function scope. */ @@ -3477,43 +3509,63 @@ merge_functions (tree s1, tree s2) XXX In what way should I treat extern declarations? XXX I don't want to repeat the entire duplicate_decls here */ +/* LLVM LOCAL begin mainline */ static void -ambiguous_decl (tree name, struct scope_binding *old, cxx_binding *new, - int flags) +ambiguous_decl (struct scope_binding *old, cxx_binding *new, int flags) { tree val, type; gcc_assert (old != NULL); + + /* Copy the type. */ + type = new->type; + if (LOOKUP_NAMESPACES_ONLY (flags) + || (type && hidden_name_p (type) && !(flags & LOOKUP_HIDDEN))) + type = NULL_TREE; + /* Copy the value. */ val = new->value; if (val) - switch (TREE_CODE (val)) - { - case TEMPLATE_DECL: - /* If we expect types or namespaces, and not templates, - or this is not a template class. */ - if ((LOOKUP_QUALIFIERS_ONLY (flags) - && !DECL_CLASS_TEMPLATE_P (val)) - || hidden_name_p (val)) - val = NULL_TREE; - break; - case TYPE_DECL: - if (LOOKUP_NAMESPACES_ONLY (flags) || hidden_name_p (val)) - val = NULL_TREE; - break; - case NAMESPACE_DECL: - if (LOOKUP_TYPES_ONLY (flags)) - val = NULL_TREE; - break; - case FUNCTION_DECL: - /* Ignore built-in functions that are still anticipated. */ - if (LOOKUP_QUALIFIERS_ONLY (flags) || hidden_name_p (val)) - val = NULL_TREE; - break; - default: - if (LOOKUP_QUALIFIERS_ONLY (flags)) - val = NULL_TREE; - } + { + if (hidden_name_p (val) && !(flags & LOOKUP_HIDDEN)) + val = NULL_TREE; + else + switch (TREE_CODE (val)) + { + case TEMPLATE_DECL: + /* If we expect types or namespaces, and not templates, + or this is not a template class. */ + if ((LOOKUP_QUALIFIERS_ONLY (flags) + && !DECL_CLASS_TEMPLATE_P (val))) + val = NULL_TREE; + break; + case TYPE_DECL: + if (LOOKUP_NAMESPACES_ONLY (flags) + || (type && (flags & LOOKUP_PREFER_TYPES))) + val = NULL_TREE; + break; + case NAMESPACE_DECL: + if (LOOKUP_TYPES_ONLY (flags)) + val = NULL_TREE; + break; + case FUNCTION_DECL: + /* Ignore built-in functions that are still anticipated. */ + if (LOOKUP_QUALIFIERS_ONLY (flags)) + val = NULL_TREE; + break; + default: + if (LOOKUP_QUALIFIERS_ONLY (flags)) + val = NULL_TREE; + } + } + + /* If val is hidden, shift down any class or enumeration name. */ + if (!val) + { + val = type; + type = NULL_TREE; + } +/* LLVM LOCAL end mainline */ if (!old->value) old->value = val; else if (val && val != old->value) @@ -3523,25 +3575,21 @@ ambiguous_decl (tree name, struct scope_ else { old->value = tree_cons (NULL_TREE, old->value, - build_tree_list (NULL_TREE, new->value)); + build_tree_list (NULL_TREE, val)); TREE_TYPE (old->value) = error_mark_node; } } - /* ... and copy the type. */ - type = new->type; - if (LOOKUP_NAMESPACES_ONLY (flags)) - type = NULL_TREE; + + /* LLVM LOCAL begin mainline */ if (!old->type) old->type = type; else if (type && old->type != type) { - if (flags & LOOKUP_COMPLAIN) - { - error ("%qD denotes an ambiguous type",name); - error ("%J first type here", TYPE_MAIN_DECL (old->type)); - error ("%J other type here", TYPE_MAIN_DECL (type)); - } + old->type = tree_cons (NULL_TREE, old->type, + build_tree_list (NULL_TREE, type)); + TREE_TYPE (old->type) = error_mark_node; } + /* LLVM LOCAL end mainline */ } /* Return the declarations that are members of the namespace NS. */ @@ -3630,36 +3678,6 @@ remove_hidden_names (tree fns) return fns; } -/* Select the right _DECL from multiple choices. */ - -static tree -select_decl (const struct scope_binding *binding, int flags) -{ - tree val; - val = binding->value; - - timevar_push (TV_NAME_LOOKUP); - if (LOOKUP_NAMESPACES_ONLY (flags)) - { - /* We are not interested in types. */ - if (val && (TREE_CODE (val) == NAMESPACE_DECL - || TREE_CODE (val) == TREE_LIST)) - POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, val); - POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE); - } - - /* If looking for a type, or if there is no non-type binding, select - the value binding. */ - if (binding->type && (!val || (flags & LOOKUP_PREFER_TYPES))) - val = binding->type; - /* Don't return non-types if we really prefer types. */ - else if (val && LOOKUP_TYPES_ONLY (flags) - && ! DECL_DECLARES_TYPE_P (val)) - val = NULL_TREE; - - POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, val); -} - /* Unscoped lookup of a global: iterate over current namespaces, considering using-directives. */ @@ -3671,22 +3689,18 @@ unqualified_namespace_lookup (tree name, tree siter; struct cp_binding_level *level; tree val = NULL_TREE; - struct scope_binding binding = EMPTY_SCOPE_BINDING; timevar_push (TV_NAME_LOOKUP); for (; !val; scope = CP_DECL_CONTEXT (scope)) { + struct scope_binding binding = EMPTY_SCOPE_BINDING; cxx_binding *b = cxx_scope_find_binding_for_name (NAMESPACE_LEVEL (scope), name); if (b) - { - if (b->value - && ((flags & LOOKUP_HIDDEN) || !hidden_name_p (b->value))) - binding.value = b->value; - binding.type = b->type; - } + /* LLVM LOCAL mainline */ + ambiguous_decl (&binding, b, flags); /* Add all _DECLs seen through local using-directives. */ for (level = current_binding_level; @@ -3711,7 +3725,7 @@ unqualified_namespace_lookup (tree name, siter = CP_DECL_CONTEXT (siter); } - val = select_decl (&binding, flags); + val = binding.value; if (scope == global_namespace) break; } @@ -3741,7 +3755,7 @@ lookup_qualified_name (tree scope, tree if (is_type_p) flags |= LOOKUP_PREFER_TYPES; if (qualified_lookup_using_namespace (name, scope, &binding, flags)) - t = select_decl (&binding, flags); + t = binding.value; } else if (is_aggr_type (scope, complain)) t = lookup_member (scope, name, 2, is_type_p); @@ -3774,7 +3788,8 @@ lookup_using_namespace (tree name, struc cxx_scope_find_binding_for_name (NAMESPACE_LEVEL (used), name); /* Resolve ambiguities. */ if (val1) - ambiguous_decl (name, val, val1, flags); + /* LLVM LOCAL mainline */ + ambiguous_decl (val, val1, flags); } POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, val->value != error_mark_node); } @@ -3803,7 +3818,8 @@ qualified_lookup_using_namespace (tree n cxx_scope_find_binding_for_name (NAMESPACE_LEVEL (scope), name); seen = tree_cons (scope, NULL_TREE, seen); if (binding) - ambiguous_decl (name, result, binding, flags); + /* LLVM LOCAL mainline */ + ambiguous_decl (result, binding, flags); /* Consider strong using directives always, and non-strong ones if we haven't found a binding yet. ??? Shouldn't we consider Modified: stable/9/contrib/gcc/cp/parser.c ============================================================================== --- stable/9/contrib/gcc/cp/parser.c Mon Jan 20 21:50:31 2014 (r260932) +++ stable/9/contrib/gcc/cp/parser.c Mon Jan 20 21:52:00 2014 (r260933) @@ -10337,13 +10337,19 @@ cp_parser_elaborated_type_specifier (cp_ if (parser->scope) { tree decl; + tree ambiguous_decls; decl = cp_parser_lookup_name (parser, identifier, tag_type, /*is_template=*/false, /*is_namespace=*/false, /*check_dependency=*/true, - /*ambiguous_decls=*/NULL); + &ambiguous_decls); + + /* If the lookup was ambiguous, an error will already have been + issued. */ + if (ambiguous_decls) + return error_mark_node; /* If we are parsing friend declaration, DECL may be a TEMPLATE_DECL tree node here. However, we need to check From owner-svn-src-stable-9@FreeBSD.ORG Mon Jan 20 23:25:53 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 44A58929; Mon, 20 Jan 2014 23:25:53 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 3056A1706; Mon, 20 Jan 2014 23:25:53 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0KNPraH040771; Mon, 20 Jan 2014 23:25:53 GMT (envelope-from wblock@svn.freebsd.org) Received: (from wblock@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0KNPrOw040770; Mon, 20 Jan 2014 23:25:53 GMT (envelope-from wblock@svn.freebsd.org) Message-Id: <201401202325.s0KNPrOw040770@svn.freebsd.org> From: Warren Block Date: Mon, 20 Jan 2014 23:25:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r260948 - stable/9/bin/df X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jan 2014 23:25:53 -0000 Author: wblock (doc committer) Date: Mon Jan 20 23:25:52 2014 New Revision: 260948 URL: http://svnweb.freebsd.org/changeset/base/260948 Log: MFC r260782: -h and -H options backwards in manual page. Modified: stable/9/bin/df/df.1 Directory Properties: stable/9/bin/df/ (props changed) Modified: stable/9/bin/df/df.1 ============================================================================== --- stable/9/bin/df/df.1 Mon Jan 20 23:23:29 2014 (r260947) +++ stable/9/bin/df/df.1 Mon Jan 20 23:25:52 2014 (r260948) @@ -29,7 +29,7 @@ .\" @(#)df.1 8.3 (Berkeley) 5/8/95 .\" $FreeBSD$ .\" -.Dd January 24, 2013 +.Dd January 16, 2014 .Dt DF 1 .Os .Sh NAME @@ -83,13 +83,13 @@ Use 1073741824 byte (1 Gibibyte) blocks This overrides any .Ev BLOCKSIZE specification from the environment. -.It Fl H +.It Fl h .Dq Human-readable output. Use unit suffixes: Byte, Kibibyte, Mebibyte, Gibibyte, Tebibyte and Pebibyte (based on powers of 1024) in order to reduce the number of digits to four or fewer. -.It Fl h +.It Fl H .Dq Human-readable output. Use unit suffixes: Byte, Kilobyte, Megabyte, From owner-svn-src-stable-9@FreeBSD.ORG Tue Jan 21 00:14:07 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 01C1AD7C; Tue, 21 Jan 2014 00:14:07 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id E1A701AE6; Tue, 21 Jan 2014 00:14:06 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0L0E6e6062830; Tue, 21 Jan 2014 00:14:06 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0L0E6IS062829; Tue, 21 Jan 2014 00:14:06 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401210014.s0L0E6IS062829@svn.freebsd.org> From: Alexander Motin Date: Tue, 21 Jan 2014 00:14:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r260960 - stable/9/sys/cam/scsi X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jan 2014 00:14:07 -0000 Author: mav Date: Tue Jan 21 00:14:06 2014 New Revision: 260960 URL: http://svnweb.freebsd.org/changeset/base/260960 Log: MFC r254970 (by ken): If a drive returns ASC/ASCQ 0x04,0x11 "Logical unit not ready, notify (enable spinup) required", instead of doing the normal retries, poll for a change in status. We will poll every half second for a minute for the status to change. Hitachi drives (and likely other SAS drives) return that ASC/ASCQ when they are waiting to spin up. What it means is that they are waiting for the SAS expander to send them the SAS NOTIFY (ENABLE SPINUP) primitive. That primitive is the mechanism expanders/enclosures use to sequence drive spinup to avoid overloading power supplies. Modified: stable/9/sys/cam/scsi/scsi_all.c Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/sys/cam/scsi/scsi_all.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_all.c Mon Jan 20 23:59:32 2014 (r260959) +++ stable/9/sys/cam/scsi/scsi_all.c Tue Jan 21 00:14:06 2014 (r260960) @@ -1118,7 +1118,7 @@ static struct asc_table_entry asc_table[ { SST(0x04, 0x10, SS_RDEF, /* XXX TBD */ "Logical unit not ready, auxiliary memory not accessible") }, /* DT WRO AEB VF */ - { SST(0x04, 0x11, SS_RDEF, /* XXX TBD */ + { SST(0x04, 0x11, SS_TUR | SSQ_MANY | SSQ_DECREMENT_COUNT | EBUSY, "Logical unit not ready, notify (enable spinup) required") }, /* M V */ { SST(0x04, 0x12, SS_RDEF, /* XXX TBD */ From owner-svn-src-stable-9@FreeBSD.ORG Tue Jan 21 00:16:42 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 35F0D117; Tue, 21 Jan 2014 00:16:42 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 2018E1B09; Tue, 21 Jan 2014 00:16:42 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0L0GghH063313; Tue, 21 Jan 2014 00:16:42 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0L0Gfww063309; Tue, 21 Jan 2014 00:16:41 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401210016.s0L0Gfww063309@svn.freebsd.org> From: Alexander Motin Date: Tue, 21 Jan 2014 00:16:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r260961 - in stable/9: sbin/camcontrol sys/cam/scsi X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jan 2014 00:16:42 -0000 Author: mav Date: Tue Jan 21 00:16:41 2014 New Revision: 260961 URL: http://svnweb.freebsd.org/changeset/base/260961 Log: MFC r255307 (by bryanv): Add camcontrol support for the SCSI sanitize command Modified: stable/9/sbin/camcontrol/camcontrol.8 stable/9/sbin/camcontrol/camcontrol.c stable/9/sys/cam/scsi/scsi_da.c stable/9/sys/cam/scsi/scsi_da.h Directory Properties: stable/9/ (props changed) stable/9/sbin/ (props changed) stable/9/sbin/camcontrol/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/sbin/camcontrol/camcontrol.8 ============================================================================== --- stable/9/sbin/camcontrol/camcontrol.8 Tue Jan 21 00:14:06 2014 (r260960) +++ stable/9/sbin/camcontrol/camcontrol.8 Tue Jan 21 00:16:41 2014 (r260961) @@ -207,6 +207,19 @@ .Op Fl w .Op Fl y .Nm +.Ic sanitize +.Op device id +.Op generic args +.Aq Fl a Ar overwrite | block | crypto | exitfailure +.Op Fl c Ar passes +.Op Fl I +.Op Fl P Ar pattern +.Op Fl q +.Op Fl U +.Op Fl r +.Op Fl w +.Op Fl y +.Nm .Ic idle .Op device id .Op generic args @@ -1088,6 +1101,116 @@ The user will not be asked about the timeout if a timeout is specified on the command line. .El +.It Ic sanitize +Issue the +.Tn SCSI +SANITIZE command to the named device. +.Pp +.Em WARNING! WARNING! WARNING! +.Pp +ALL data in the cache and on the disk will be destroyed or made inaccessible. +Recovery of the data is not possible. +Use extreme caution when issuing this command. +.Pp +The +.Sq sanitize +subcommand takes several arguments that modify its default behavior. +The +.Fl q +and +.Fl y +arguments can be useful for scripts. +.Bl -tag -width 6n +.It Fl a Ar operation +Specify the sanitize operation to perform. +.Bl -tag -width 16n +.It overwrite +Perform an overwrite operation by writing a user supplied +data pattern to the device one or more times. +The pattern is given by the +.Fl P +argument. +The number of times is given by the +.Fl c +argument. +.It block +Perform a block erase operation. +All the device's blocks are set to a vendor defined +value, typically zero. +.It crypto +Perform a cryptographic erase operation. +The encryption keys are changed to prevent the decryption +of the data. +.It exitfailure +Exits a previously failed sanitize operation. +A failed sanitize operation can only be exited if it was +run in the unrestricted completion mode, as provided by the +.Fl U +argument. +.El +.It Fl c Ar passes +The number of passes when performing an +.Sq overwrite +operation. +Valid values are between 1 and 31. The default is 1. +.It Fl I +When performing an +.Sq overwrite +operation, the pattern is inverted between consecutive passes. +.It Fl P Ar pattern +Path to the file containing the pattern to use when +performing an +.Sq overwrite +operation. +The pattern is repeated as needed to fill each block. +.It Fl q +Be quiet, do not print any status messages. +This option will not disable +the questions, however. +To disable questions, use the +.Fl y +argument, below. +.It Fl U +Perform the sanitize in the unrestricted completion mode. +If the operation fails, it can later be exited with the +.Sq exitfailure +operation. +.It Fl r +Run in +.Dq report only +mode. +This will report status on a sanitize that is already running on the drive. +.It Fl w +Issue a non-immediate sanitize command. +By default, +.Nm +issues the SANITIZE command with the immediate bit set. +This tells the +device to immediately return the sanitize command, before +the sanitize has actually completed. +Then, +.Nm +gathers +.Tn SCSI +sense information from the device every second to determine how far along +in the sanitize process it is. +If the +.Fl w +argument is specified, +.Nm +will issue a non-immediate sanitize command, and will be unable to print any +information to let the user know what percentage of the disk has been +sanitized. +.It Fl y +Do not ask any questions. +By default, +.Nm +will ask the user if he/she really wants to sanitize the disk in question, +and also if the default sanitize command timeout is acceptable. +The user +will not be asked about the timeout if a timeout is specified on the +command line. +.El .It Ic idle Put ATA device into IDLE state. Optional parameter .Pq Fl t Modified: stable/9/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/9/sbin/camcontrol/camcontrol.c Tue Jan 21 00:14:06 2014 (r260960) +++ stable/9/sbin/camcontrol/camcontrol.c Tue Jan 21 00:16:41 2014 (r260961) @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -93,7 +94,8 @@ typedef enum { CAM_CMD_SMP_MANINFO = 0x0000001b, CAM_CMD_DOWNLOAD_FW = 0x0000001c, CAM_CMD_SECURITY = 0x0000001d, - CAM_CMD_HPA = 0x0000001e + CAM_CMD_HPA = 0x0000001e, + CAM_CMD_SANITIZE = 0x0000001f, } cam_cmdmask; typedef enum { @@ -209,6 +211,7 @@ static struct camcontrol_opts option_tab {"rate", CAM_CMD_RATE, CAM_ARG_NONE, negotiate_opts}, {"debug", CAM_CMD_DEBUG, CAM_ARG_NONE, "IPTSXcp"}, {"format", CAM_CMD_FORMAT, CAM_ARG_NONE, "qrwy"}, + {"sanitize", CAM_CMD_SANITIZE, CAM_ARG_NONE, "a:c:IP:qrUwy"}, {"idle", CAM_CMD_IDLE, CAM_ARG_NONE, "t:"}, {"standby", CAM_CMD_STANDBY, CAM_ARG_NONE, "t:"}, {"sleep", CAM_CMD_SLEEP, CAM_ARG_NONE, ""}, @@ -301,6 +304,8 @@ static int ratecontrol(struct cam_device int timeout, int argc, char **argv, char *combinedopt); static int scsiformat(struct cam_device *device, int argc, char **argv, char *combinedopt, int retry_count, int timeout); +static int scsisanitize(struct cam_device *device, int argc, char **argv, + char *combinedopt, int retry_count, int timeout); static int scsireportluns(struct cam_device *device, int argc, char **argv, char *combinedopt, int retry_count, int timeout); static int scsireadcapacity(struct cam_device *device, int argc, char **argv, @@ -5537,6 +5542,402 @@ scsiformat_bailout: } static int +scsisanitize(struct cam_device *device, int argc, char **argv, + char *combinedopt, int retry_count, int timeout) +{ + union ccb *ccb; + u_int8_t action = 0; + int c; + int ycount = 0, quiet = 0; + int error = 0, retval = 0; + int use_timeout = 10800 * 1000; + int immediate = 1; + int invert = 0; + int passes = 0; + int ause = 0; + int fd = -1; + const char *pattern = NULL; + u_int8_t *data_ptr = NULL; + u_int32_t dxfer_len = 0; + u_int8_t byte2 = 0; + int num_warnings = 0; + int reportonly = 0; + + ccb = cam_getccb(device); + + if (ccb == NULL) { + warnx("scsisanitize: error allocating ccb"); + return(1); + } + + bzero(&(&ccb->ccb_h)[1], + sizeof(struct ccb_scsiio) - sizeof(struct ccb_hdr)); + + while ((c = getopt(argc, argv, combinedopt)) != -1) { + switch(c) { + case 'a': + if (strcasecmp(optarg, "overwrite") == 0) + action = SSZ_SERVICE_ACTION_OVERWRITE; + else if (strcasecmp(optarg, "block") == 0) + action = SSZ_SERVICE_ACTION_BLOCK_ERASE; + else if (strcasecmp(optarg, "crypto") == 0) + action = SSZ_SERVICE_ACTION_CRYPTO_ERASE; + else if (strcasecmp(optarg, "exitfailure") == 0) + action = SSZ_SERVICE_ACTION_EXIT_MODE_FAILURE; + else { + warnx("invalid service operation \"%s\"", + optarg); + error = 1; + goto scsisanitize_bailout; + } + break; + case 'c': + passes = strtol(optarg, NULL, 0); + if (passes < 1 || passes > 31) { + warnx("invalid passes value %d", passes); + error = 1; + goto scsisanitize_bailout; + } + break; + case 'I': + invert = 1; + break; + case 'P': + pattern = optarg; + break; + case 'q': + quiet++; + break; + case 'U': + ause = 1; + break; + case 'r': + reportonly = 1; + break; + case 'w': + immediate = 0; + break; + case 'y': + ycount++; + break; + } + } + + if (reportonly) + goto doreport; + + if (action == 0) { + warnx("an action is required"); + error = 1; + goto scsisanitize_bailout; + } else if (action == SSZ_SERVICE_ACTION_OVERWRITE) { + struct scsi_sanitize_parameter_list *pl; + struct stat sb; + ssize_t sz, amt; + + if (pattern == NULL) { + warnx("overwrite action requires -P argument"); + error = 1; + goto scsisanitize_bailout; + } + fd = open(pattern, O_RDONLY); + if (fd < 0) { + warn("cannot open pattern file %s", pattern); + error = 1; + goto scsisanitize_bailout; + } + if (fstat(fd, &sb) < 0) { + warn("cannot stat pattern file %s", pattern); + error = 1; + goto scsisanitize_bailout; + } + sz = sb.st_size; + if (sz > SSZPL_MAX_PATTERN_LENGTH) { + warnx("pattern file size exceeds maximum value %d", + SSZPL_MAX_PATTERN_LENGTH); + error = 1; + goto scsisanitize_bailout; + } + dxfer_len = sizeof(*pl) + sz; + data_ptr = calloc(1, dxfer_len); + if (data_ptr == NULL) { + warnx("cannot allocate parameter list buffer"); + error = 1; + goto scsisanitize_bailout; + } + + amt = read(fd, data_ptr + sizeof(*pl), sz); + if (amt < 0) { + warn("cannot read pattern file"); + error = 1; + goto scsisanitize_bailout; + } else if (amt != sz) { + warnx("short pattern file read"); + error = 1; + goto scsisanitize_bailout; + } + + pl = (struct scsi_sanitize_parameter_list *)data_ptr; + if (passes == 0) + pl->byte1 = 1; + else + pl->byte1 = passes; + if (invert != 0) + pl->byte1 |= SSZPL_INVERT; + scsi_ulto2b(sz, pl->length); + } else { + const char *arg; + + if (passes != 0) + arg = "-c"; + else if (invert != 0) + arg = "-I"; + else if (pattern != NULL) + arg = "-P"; + else + arg = NULL; + if (arg != NULL) { + warnx("%s argument only valid with overwrite " + "operation", arg); + error = 1; + goto scsisanitize_bailout; + } + } + + if (quiet == 0) { + fprintf(stdout, "You are about to REMOVE ALL DATA from the " + "following device:\n"); + + error = scsidoinquiry(device, argc, argv, combinedopt, + retry_count, timeout); + + if (error != 0) { + warnx("scsisanitize: error sending inquiry"); + goto scsisanitize_bailout; + } + } + + if (ycount == 0) { + if (!get_confirmation()) { + error = 1; + goto scsisanitize_bailout; + } + } + + if (timeout != 0) + use_timeout = timeout; + + if (quiet == 0) { + fprintf(stdout, "Current sanitize timeout is %d seconds\n", + use_timeout / 1000); + } + + /* + * If the user hasn't disabled questions and didn't specify a + * timeout on the command line, ask them if they want the current + * timeout. + */ + if ((ycount == 0) + && (timeout == 0)) { + char str[1024]; + int new_timeout = 0; + + fprintf(stdout, "Enter new timeout in seconds or press\n" + "return to keep the current timeout [%d] ", + use_timeout / 1000); + + if (fgets(str, sizeof(str), stdin) != NULL) { + if (str[0] != '\0') + new_timeout = atoi(str); + } + + if (new_timeout != 0) { + use_timeout = new_timeout * 1000; + fprintf(stdout, "Using new timeout value %d\n", + use_timeout / 1000); + } + } + + byte2 = action; + if (ause != 0) + byte2 |= SSZ_UNRESTRICTED_EXIT; + if (immediate != 0) + byte2 |= SSZ_IMMED; + + scsi_sanitize(&ccb->csio, + /* retries */ retry_count, + /* cbfcnp */ NULL, + /* tag_action */ MSG_SIMPLE_Q_TAG, + /* byte2 */ byte2, + /* control */ 0, + /* data_ptr */ data_ptr, + /* dxfer_len */ dxfer_len, + /* sense_len */ SSD_FULL_SIZE, + /* timeout */ use_timeout); + + /* Disable freezing the device queue */ + ccb->ccb_h.flags |= CAM_DEV_QFRZDIS; + + if (arglist & CAM_ARG_ERR_RECOVER) + ccb->ccb_h.flags |= CAM_PASS_ERR_RECOVER; + + if (((retval = cam_send_ccb(device, ccb)) < 0) + || ((immediate == 0) + && ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP))) { + const char errstr[] = "error sending sanitize command"; + + if (retval < 0) + warn(errstr); + else + warnx(errstr); + + if (arglist & CAM_ARG_VERBOSE) { + cam_error_print(device, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + } + error = 1; + goto scsisanitize_bailout; + } + + /* + * If we ran in non-immediate mode, we already checked for errors + * above and printed out any necessary information. If we're in + * immediate mode, we need to loop through and get status + * information periodically. + */ + if (immediate == 0) { + if (quiet == 0) { + fprintf(stdout, "Sanitize Complete\n"); + } + goto scsisanitize_bailout; + } + +doreport: + do { + cam_status status; + + bzero(&(&ccb->ccb_h)[1], + sizeof(struct ccb_scsiio) - sizeof(struct ccb_hdr)); + + /* + * There's really no need to do error recovery or + * retries here, since we're just going to sit in a + * loop and wait for the device to finish sanitizing. + */ + scsi_test_unit_ready(&ccb->csio, + /* retries */ 0, + /* cbfcnp */ NULL, + /* tag_action */ MSG_SIMPLE_Q_TAG, + /* sense_len */ SSD_FULL_SIZE, + /* timeout */ 5000); + + /* Disable freezing the device queue */ + ccb->ccb_h.flags |= CAM_DEV_QFRZDIS; + + retval = cam_send_ccb(device, ccb); + + /* + * If we get an error from the ioctl, bail out. SCSI + * errors are expected. + */ + if (retval < 0) { + warn("error sending CAMIOCOMMAND ioctl"); + if (arglist & CAM_ARG_VERBOSE) { + cam_error_print(device, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + } + error = 1; + goto scsisanitize_bailout; + } + + status = ccb->ccb_h.status & CAM_STATUS_MASK; + + if ((status != CAM_REQ_CMP) + && (status == CAM_SCSI_STATUS_ERROR) + && ((ccb->ccb_h.status & CAM_AUTOSNS_VALID) != 0)) { + struct scsi_sense_data *sense; + int error_code, sense_key, asc, ascq; + + sense = &ccb->csio.sense_data; + scsi_extract_sense_len(sense, ccb->csio.sense_len - + ccb->csio.sense_resid, &error_code, &sense_key, + &asc, &ascq, /*show_errors*/ 1); + + /* + * According to the SCSI-3 spec, a drive that is in the + * middle of a sanitize should return NOT READY with an + * ASC of "logical unit not ready, sanitize in + * progress". The sense key specific bytes will then + * be a progress indicator. + */ + if ((sense_key == SSD_KEY_NOT_READY) + && (asc == 0x04) && (ascq == 0x1b)) { + uint8_t sks[3]; + + if ((scsi_get_sks(sense, ccb->csio.sense_len - + ccb->csio.sense_resid, sks) == 0) + && (quiet == 0)) { + int val; + u_int64_t percentage; + + val = scsi_2btoul(&sks[1]); + percentage = 10000 * val; + + fprintf(stdout, + "\rSanitizing: %ju.%02u %% " + "(%d/%d) done", + (uintmax_t)(percentage / + (0x10000 * 100)), + (unsigned)((percentage / + 0x10000) % 100), + val, 0x10000); + fflush(stdout); + } else if ((quiet == 0) + && (++num_warnings <= 1)) { + warnx("Unexpected SCSI Sense Key " + "Specific value returned " + "during sanitize:"); + scsi_sense_print(device, &ccb->csio, + stderr); + warnx("Unable to print status " + "information, but sanitze will " + "proceed."); + warnx("will exit when sanitize is " + "complete"); + } + sleep(1); + } else { + warnx("Unexpected SCSI error during sanitize"); + cam_error_print(device, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + error = 1; + goto scsisanitize_bailout; + } + + } else if (status != CAM_REQ_CMP) { + warnx("Unexpected CAM status %#x", status); + if (arglist & CAM_ARG_VERBOSE) + cam_error_print(device, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + error = 1; + goto scsisanitize_bailout; + } + } while((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP); + + if (quiet == 0) + fprintf(stdout, "\nSanitize Complete\n"); + +scsisanitize_bailout: + if (fd >= 0) + close(fd); + if (data_ptr != NULL) + free(data_ptr); + cam_freeccb(ccb); + + return(error); +} + +static int scsireportluns(struct cam_device *device, int argc, char **argv, char *combinedopt, int retry_count, int timeout) { @@ -7360,6 +7761,10 @@ usage(int printlong) " [-q][-R syncrate][-v][-T ]\n" " [-U][-W bus_width]\n" " camcontrol format [dev_id][generic args][-q][-r][-w][-y]\n" +" camcontrol sanitize [dev_id][generic args]\n" +" [-a overwrite|block|crypto|exitfailure]\n" +" [-c passes][-I][-P pattern][-q][-U][-r][-w]\n" +" [-y]\n" " camcontrol idle [dev_id][generic args][-t time]\n" " camcontrol standby [dev_id][generic args][-t time]\n" " camcontrol sleep [dev_id][generic args]\n" @@ -7402,6 +7807,7 @@ usage(int printlong) "tags report or set the number of transaction slots for a device\n" "negotiate report or set device negotiation parameters\n" "format send the SCSI FORMAT UNIT command to the named device\n" +"sanitize send the SCSI SANITIZE command to the named device\n" "idle send the ATA IDLE command to the named device\n" "standby send the ATA STANDBY command to the named device\n" "sleep send the ATA SLEEP command to the named device\n" @@ -7497,6 +7903,16 @@ usage(int printlong) "-r run in report only mode\n" "-w don't send immediate format command\n" "-y don't ask any questions\n" +"sanitize arguments:\n" +"-a operation operation mode: overwrite, block, crypto or exitfailure\n" +"-c passes overwrite passes to perform (1 to 31)\n" +"-I invert overwrite pattern after each pass\n" +"-P pattern path to overwrite pattern file\n" +"-q be quiet, don't print status messages\n" +"-r run in report only mode\n" +"-U run operation in unrestricted completion exit mode\n" +"-w don't send immediate sanitize command\n" +"-y don't ask any questions\n" "idle/standby arguments:\n" "-t number of seconds before respective state.\n" "fwdownload arguments:\n" @@ -7859,6 +8275,10 @@ main(int argc, char **argv) arglist & CAM_ARG_VERBOSE, retry_count, timeout, get_disk_type(cam_dev)); break; + case CAM_CMD_SANITIZE: + error = scsisanitize(cam_dev, argc, argv, + combinedopt, retry_count, timeout); + break; #endif /* MINIMALISTIC */ case CAM_CMD_USAGE: usage(1); Modified: stable/9/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_da.c Tue Jan 21 00:14:06 2014 (r260960) +++ stable/9/sys/cam/scsi/scsi_da.c Tue Jan 21 00:16:41 2014 (r260961) @@ -3841,4 +3841,31 @@ scsi_format_unit(struct ccb_scsiio *csio timeout); } +void +scsi_sanitize(struct ccb_scsiio *csio, u_int32_t retries, + void (*cbfcnp)(struct cam_periph *, union ccb *), + u_int8_t tag_action, u_int8_t byte2, u_int16_t control, + u_int8_t *data_ptr, u_int32_t dxfer_len, u_int8_t sense_len, + u_int32_t timeout) +{ + struct scsi_sanitize *scsi_cmd; + + scsi_cmd = (struct scsi_sanitize *)&csio->cdb_io.cdb_bytes; + scsi_cmd->opcode = SANITIZE; + scsi_cmd->byte2 = byte2; + scsi_cmd->control = control; + scsi_ulto2b(dxfer_len, scsi_cmd->length); + + cam_fill_csio(csio, + retries, + cbfcnp, + /*flags*/ (dxfer_len > 0) ? CAM_DIR_OUT : CAM_DIR_NONE, + tag_action, + data_ptr, + dxfer_len, + sense_len, + sizeof(*scsi_cmd), + timeout); +} + #endif /* _KERNEL */ Modified: stable/9/sys/cam/scsi/scsi_da.h ============================================================================== --- stable/9/sys/cam/scsi/scsi_da.h Tue Jan 21 00:14:06 2014 (r260960) +++ stable/9/sys/cam/scsi/scsi_da.h Tue Jan 21 00:16:41 2014 (r260961) @@ -116,6 +116,31 @@ struct scsi_read_defect_data_10 u_int8_t control; }; +struct scsi_sanitize +{ + u_int8_t opcode; + u_int8_t byte2; +#define SSZ_SERVICE_ACTION_OVERWRITE 0x01 +#define SSZ_SERVICE_ACTION_BLOCK_ERASE 0x02 +#define SSZ_SERVICE_ACTION_CRYPTO_ERASE 0x03 +#define SSZ_SERVICE_ACTION_EXIT_MODE_FAILURE 0x1F +#define SSZ_UNRESTRICTED_EXIT 0x20 +#define SSZ_IMMED 0x80 + u_int8_t reserved[5]; + u_int8_t length[2]; + u_int8_t control; +}; + +struct scsi_sanitize_parameter_list +{ + u_int8_t byte1; +#define SSZPL_INVERT 0x80 + u_int8_t reserved; + u_int8_t length[2]; + /* Variable length initialization pattern. */ +#define SSZPL_MAX_PATTERN_LENGTH 65535 +}; + struct scsi_read_defect_data_12 { u_int8_t opcode; @@ -156,6 +181,7 @@ struct scsi_read_defect_data_12 #define WRITE_AND_VERIFY 0x2e #define VERIFY 0x2f #define READ_DEFECT_DATA_10 0x37 +#define SANITIZE 0x48 #define READ_DEFECT_DATA_12 0xb7 struct format_defect_list_header @@ -508,6 +534,12 @@ void scsi_format_unit(struct ccb_scsiio u_int8_t *data_ptr, u_int32_t dxfer_len, u_int8_t sense_len, u_int32_t timeout); +void scsi_sanitize(struct ccb_scsiio *csio, u_int32_t retries, + void (*cbfcnp)(struct cam_periph *, union ccb *), + u_int8_t tag_action, u_int8_t byte2, u_int16_t control, + u_int8_t *data_ptr, u_int32_t dxfer_len, u_int8_t sense_len, + u_int32_t timeout); + #endif /* !_KERNEL */ __END_DECLS From owner-svn-src-stable-9@FreeBSD.ORG Tue Jan 21 00:22:09 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 62BD343F; Tue, 21 Jan 2014 00:22:09 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 34D5B1CA2; Tue, 21 Jan 2014 00:22:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0L0M9iH066828; Tue, 21 Jan 2014 00:22:09 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0L0M9aI066826; Tue, 21 Jan 2014 00:22:09 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401210022.s0L0M9aI066826@svn.freebsd.org> From: Alexander Motin Date: Tue, 21 Jan 2014 00:22:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r260962 - stable/9/sys/cam/ata X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jan 2014 00:22:09 -0000 Author: mav Date: Tue Jan 21 00:22:08 2014 New Revision: 260962 URL: http://svnweb.freebsd.org/changeset/base/260962 Log: MFC r256836: Remove hard limit on number of BIOs handled with one ATA TRIM request. Modified: stable/9/sys/cam/ata/ata_da.c Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/sys/cam/ata/ata_da.c ============================================================================== --- stable/9/sys/cam/ata/ata_da.c Tue Jan 21 00:16:41 2014 (r260961) +++ stable/9/sys/cam/ata/ata_da.c Tue Jan 21 00:22:08 2014 (r260962) @@ -124,10 +124,9 @@ struct disk_params { #define TRIM_MAX_BLOCKS 8 #define TRIM_MAX_RANGES (TRIM_MAX_BLOCKS * ATA_DSM_BLK_RANGES) -#define TRIM_MAX_BIOS (TRIM_MAX_RANGES * 4) struct trim_request { uint8_t data[TRIM_MAX_RANGES * ATA_DSM_RANGE_SIZE]; - struct bio *bps[TRIM_MAX_BIOS]; + TAILQ_HEAD(, bio) bps; }; struct ada_softc { @@ -1424,10 +1423,11 @@ adastart(struct cam_periph *periph, unio struct trim_request *req = &softc->trim_req; struct bio *bp1; uint64_t lastlba = (uint64_t)-1; - int bps = 0, c, lastcount = 0, off, ranges = 0; + int c, lastcount = 0, off, ranges = 0; softc->trim_running = 1; bzero(req, sizeof(*req)); + TAILQ_INIT(&req->bps); bp1 = bp; do { uint64_t lba = bp1->bio_pblkno; @@ -1470,10 +1470,9 @@ adastart(struct cam_periph *periph, unio */ } lastlba = lba; - req->bps[bps++] = bp1; + TAILQ_INSERT_TAIL(&req->bps, bp1, bio_queue); bp1 = bioq_first(&softc->trim_queue); - if (bps >= TRIM_MAX_BIOS || - bp1 == NULL || + if (bp1 == NULL || bp1->bio_bcount / softc->params.secsize > (softc->trim_max_ranges - ranges) * ATA_DSM_RANGE_MAX) @@ -1762,23 +1761,22 @@ adadone(struct cam_periph *periph, union if (softc->outstanding_cmds == 0) softc->flags |= ADA_FLAG_WENT_IDLE; if (state == ADA_CCB_TRIM) { - struct trim_request *req = - (struct trim_request *)ataio->data_ptr; - int i; - - for (i = 1; i < TRIM_MAX_BIOS && req->bps[i]; i++) { - struct bio *bp1 = req->bps[i]; + TAILQ_HEAD(, bio) queue; + struct bio *bp1; - bp1->bio_error = bp->bio_error; - if (bp->bio_flags & BIO_ERROR) { + TAILQ_INIT(&queue); + TAILQ_CONCAT(&queue, &softc->trim_req.bps, bio_queue); + softc->trim_running = 0; + while ((bp1 = TAILQ_FIRST(&queue)) != NULL) { + TAILQ_REMOVE(&queue, bp1, bio_queue); + bp1->bio_error = error; + if (error != 0) { bp1->bio_flags |= BIO_ERROR; bp1->bio_resid = bp1->bio_bcount; } else bp1->bio_resid = 0; biodone(bp1); } - softc->trim_running = 0; - biodone(bp); adaschedule(periph); } else biodone(bp); From owner-svn-src-stable-9@FreeBSD.ORG Tue Jan 21 00:25:51 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4C6E5758; Tue, 21 Jan 2014 00:25:51 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 386B61CCA; Tue, 21 Jan 2014 00:25:51 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0L0Pp9b067587; Tue, 21 Jan 2014 00:25:51 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0L0PpCE067586; Tue, 21 Jan 2014 00:25:51 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401210025.s0L0PpCE067586@svn.freebsd.org> From: Alexander Motin Date: Tue, 21 Jan 2014 00:25:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r260963 - stable/9/sys/cam X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jan 2014 00:25:51 -0000 Author: mav Date: Tue Jan 21 00:25:50 2014 New Revision: 260963 URL: http://svnweb.freebsd.org/changeset/base/260963 Log: MFC r256895: Fix memory and references leak due to unfreed path. Modified: stable/9/sys/cam/cam_periph.c Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/sys/cam/cam_periph.c ============================================================================== --- stable/9/sys/cam/cam_periph.c Tue Jan 21 00:22:08 2014 (r260962) +++ stable/9/sys/cam/cam_periph.c Tue Jan 21 00:25:50 2014 (r260963) @@ -1786,9 +1786,11 @@ cam_periph_error(union ccb *ccb, cam_fla scan_ccb->ccb_h.func_code = XPT_SCAN_TGT; scan_ccb->crcn.flags = 0; xpt_rescan(scan_ccb); - } else + } else { xpt_print(newpath, "Can't allocate CCB to rescan target\n"); + xpt_free_path(newpath); + } } } From owner-svn-src-stable-9@FreeBSD.ORG Tue Jan 21 00:27:50 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3859089F; Tue, 21 Jan 2014 00:27:50 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 2457C1CD8; Tue, 21 Jan 2014 00:27:50 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0L0RoFN068025; Tue, 21 Jan 2014 00:27:50 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0L0RoLM068024; Tue, 21 Jan 2014 00:27:50 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401210027.s0L0RoLM068024@svn.freebsd.org> From: Alexander Motin Date: Tue, 21 Jan 2014 00:27:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r260964 - stable/9/sys/cam/ctl X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jan 2014 00:27:50 -0000 Author: mav Date: Tue Jan 21 00:27:49 2014 New Revision: 260964 URL: http://svnweb.freebsd.org/changeset/base/260964 Log: MFC r256995: Remove 128KB bzero() call done for every block I/O data buffer. Modified: stable/9/sys/cam/ctl/ctl_backend_block.c Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- stable/9/sys/cam/ctl/ctl_backend_block.c Tue Jan 21 00:25:50 2014 (r260963) +++ stable/9/sys/cam/ctl/ctl_backend_block.c Tue Jan 21 00:27:49 2014 (r260964) @@ -1618,18 +1618,6 @@ ctl_be_block_open(struct ctl_be_block_so } static int -ctl_be_block_mem_ctor(void *mem, int size, void *arg, int flags) -{ - return (0); -} - -static void -ctl_be_block_mem_dtor(void *mem, int size, void *arg) -{ - bzero(mem, size); -} - -static int ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) { struct ctl_be_block_lun *be_lun; @@ -1656,8 +1644,7 @@ ctl_be_block_create(struct ctl_be_block_ mtx_init(&be_lun->lock, be_lun->lunname, NULL, MTX_DEF); be_lun->lun_zone = uma_zcreate(be_lun->lunname, MAXPHYS, - ctl_be_block_mem_ctor, ctl_be_block_mem_dtor, NULL, NULL, - /*align*/ 0, /*flags*/0); + NULL, NULL, NULL, NULL, /*align*/ 0, /*flags*/0); if (be_lun->lun_zone == NULL) { snprintf(req->error_str, sizeof(req->error_str), From owner-svn-src-stable-9@FreeBSD.ORG Tue Jan 21 00:31:32 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id F0763BF3; Tue, 21 Jan 2014 00:31:31 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D0F641D64; Tue, 21 Jan 2014 00:31:31 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0L0VVDR071723; Tue, 21 Jan 2014 00:31:31 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0L0VV5i071709; Tue, 21 Jan 2014 00:31:31 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401210031.s0L0VV5i071709@svn.freebsd.org> From: Alexander Motin Date: Tue, 21 Jan 2014 00:31:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r260965 - in stable/9/sys/cam: ata scsi X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jan 2014 00:31:32 -0000 Author: mav Date: Tue Jan 21 00:31:31 2014 New Revision: 260965 URL: http://svnweb.freebsd.org/changeset/base/260965 Log: MFC r257054: Some microoptimizations for da and ada drivers: - Replace ordered_tag_count counter with single flag; - From da remove outstanding_cmds counter, duplicating pending_ccbs list; - From da_softc remove unused links field. Modified: stable/9/sys/cam/ata/ata_da.c stable/9/sys/cam/scsi/scsi_da.c Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/sys/cam/ata/ata_da.c ============================================================================== --- stable/9/sys/cam/ata/ata_da.c Tue Jan 21 00:27:49 2014 (r260964) +++ stable/9/sys/cam/ata/ata_da.c Tue Jan 21 00:31:31 2014 (r260965) @@ -81,7 +81,7 @@ typedef enum { ADA_FLAG_CAN_NCQ = 0x0008, ADA_FLAG_CAN_DMA = 0x0010, ADA_FLAG_NEED_OTAG = 0x0020, - ADA_FLAG_WENT_IDLE = 0x0040, + ADA_FLAG_WAS_OTAG = 0x0040, ADA_FLAG_CAN_TRIM = 0x0080, ADA_FLAG_OPEN = 0x0100, ADA_FLAG_SCTX_INIT = 0x0200, @@ -132,12 +132,12 @@ struct trim_request { struct ada_softc { struct bio_queue_head bio_queue; struct bio_queue_head trim_queue; + int outstanding_cmds; /* Number of active commands */ + int refcount; /* Active xpt_action() calls */ ada_state state; - ada_flags flags; + ada_flags flags; ada_quirks quirks; int sort_io_queue; - int ordered_tag_count; - int outstanding_cmds; int trim_max_ranges; int trim_running; int read_ahead; @@ -1504,7 +1504,7 @@ adastart(struct cam_periph *periph, unio if ((bp->bio_flags & BIO_ORDERED) != 0 || (softc->flags & ADA_FLAG_NEED_OTAG) != 0) { softc->flags &= ~ADA_FLAG_NEED_OTAG; - softc->ordered_tag_count++; + softc->flags |= ADA_FLAG_WAS_OTAG; tag_code = 0; } else { tag_code = 1; @@ -1759,7 +1759,7 @@ adadone(struct cam_periph *periph, union } softc->outstanding_cmds--; if (softc->outstanding_cmds == 0) - softc->flags |= ADA_FLAG_WENT_IDLE; + softc->flags |= ADA_FLAG_WAS_OTAG; if (state == ADA_CCB_TRIM) { TAILQ_HEAD(, bio) queue; struct bio *bp1; @@ -1923,14 +1923,11 @@ adasendorderedtag(void *arg) struct ada_softc *softc = arg; if (ada_send_ordered) { - if ((softc->ordered_tag_count == 0) - && ((softc->flags & ADA_FLAG_WENT_IDLE) == 0)) { - softc->flags |= ADA_FLAG_NEED_OTAG; + if (softc->outstanding_cmds > 0) { + if ((softc->flags & ADA_FLAG_WAS_OTAG) == 0) + softc->flags |= ADA_FLAG_NEED_OTAG; + softc->flags &= ~ADA_FLAG_WAS_OTAG; } - if (softc->outstanding_cmds > 0) - softc->flags &= ~ADA_FLAG_WENT_IDLE; - - softc->ordered_tag_count = 0; } /* Queue us up again */ callout_reset(&softc->sendordered_c, Modified: stable/9/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_da.c Tue Jan 21 00:27:49 2014 (r260964) +++ stable/9/sys/cam/scsi/scsi_da.c Tue Jan 21 00:31:31 2014 (r260965) @@ -84,7 +84,7 @@ typedef enum { DA_FLAG_PACK_LOCKED = 0x004, DA_FLAG_PACK_REMOVABLE = 0x008, DA_FLAG_NEED_OTAG = 0x020, - DA_FLAG_WENT_IDLE = 0x040, + DA_FLAG_WAS_OTAG = 0x040, DA_FLAG_RETRY_UA = 0x080, DA_FLAG_OPEN = 0x100, DA_FLAG_SCTX_INIT = 0x200, @@ -199,19 +199,17 @@ struct da_softc { struct bio_queue_head bio_queue; struct bio_queue_head delete_queue; struct bio_queue_head delete_run_queue; - SLIST_ENTRY(da_softc) links; LIST_HEAD(, ccb_hdr) pending_ccbs; + int tur; /* TEST UNIT READY should be sent */ + int refcount; /* Active xpt_action() calls */ da_state state; da_flags flags; da_quirks quirks; int sort_io_queue; int minimum_cmd_size; int error_inject; - int ordered_tag_count; - int outstanding_cmds; int trim_max_ranges; int delete_running; - int tur; int delete_available; /* Delete methods possibly available */ uint32_t unmap_max_ranges; uint32_t unmap_max_lba; @@ -2266,7 +2264,7 @@ skipstate: if ((bp->bio_flags & BIO_ORDERED) != 0 || (softc->flags & DA_FLAG_NEED_OTAG) != 0) { softc->flags &= ~DA_FLAG_NEED_OTAG; - softc->ordered_tag_count++; + softc->flags |= DA_FLAG_WAS_OTAG; tag_code = MSG_ORDERED_Q_TAG; } else { tag_code = MSG_SIMPLE_Q_TAG; @@ -2318,13 +2316,8 @@ skipstate: start_ccb->ccb_h.ccb_state = DA_CCB_BUFFER_IO; out: - /* - * Block out any asynchronous callbacks - * while we touch the pending ccb list. - */ LIST_INSERT_HEAD(&softc->pending_ccbs, &start_ccb->ccb_h, periph_links.le); - softc->outstanding_cmds++; /* We expect a unit attention from this device */ if ((softc->flags & DA_FLAG_RETRY_UA) != 0) { @@ -2980,14 +2973,9 @@ dadone(struct cam_periph *periph, union } } - /* - * Block out any asynchronous callbacks - * while we touch the pending ccb list. - */ LIST_REMOVE(&done_ccb->ccb_h, periph_links.le); - softc->outstanding_cmds--; - if (softc->outstanding_cmds == 0) - softc->flags |= DA_FLAG_WENT_IDLE; + if (LIST_EMPTY(&softc->pending_ccbs)) + softc->flags |= DA_FLAG_WAS_OTAG; if (state == DA_CCB_DELETE) { while ((bp1 = bioq_takefirst(&softc->delete_run_queue)) @@ -3572,7 +3560,7 @@ damediapoll(void *arg) struct cam_periph *periph = arg; struct da_softc *softc = periph->softc; - if (!softc->tur && softc->outstanding_cmds == 0) { + if (!softc->tur && LIST_EMPTY(&softc->pending_ccbs)) { if (cam_periph_acquire(periph) == CAM_REQ_CMP) { softc->tur = 1; daschedule(periph); @@ -3739,14 +3727,11 @@ dasendorderedtag(void *arg) struct da_softc *softc = arg; if (da_send_ordered) { - if ((softc->ordered_tag_count == 0) - && ((softc->flags & DA_FLAG_WENT_IDLE) == 0)) { - softc->flags |= DA_FLAG_NEED_OTAG; + if (!LIST_EMPTY(&softc->pending_ccbs)) { + if ((softc->flags & DA_FLAG_WAS_OTAG) == 0) + softc->flags |= DA_FLAG_NEED_OTAG; + softc->flags &= ~DA_FLAG_WAS_OTAG; } - if (softc->outstanding_cmds > 0) - softc->flags &= ~DA_FLAG_WENT_IDLE; - - softc->ordered_tag_count = 0; } /* Queue us up again */ callout_reset(&softc->sendordered_c, From owner-svn-src-stable-9@FreeBSD.ORG Tue Jan 21 00:34:37 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CFA29EF2; Tue, 21 Jan 2014 00:34:37 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id BB8B51D7F; Tue, 21 Jan 2014 00:34:37 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0L0YbHh072547; Tue, 21 Jan 2014 00:34:37 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0L0YbLl072546; Tue, 21 Jan 2014 00:34:37 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401210034.s0L0YbLl072546@svn.freebsd.org> From: Alexander Motin Date: Tue, 21 Jan 2014 00:34:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r260966 - stable/9/sys/cam/scsi X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jan 2014 00:34:37 -0000 Author: mav Date: Tue Jan 21 00:34:37 2014 New Revision: 260966 URL: http://svnweb.freebsd.org/changeset/base/260966 Log: MFC r260407: Allow delete_method sysctl to be set to "DISABLE". Modified: stable/9/sys/cam/scsi/scsi_da.c Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_da.c Tue Jan 21 00:31:31 2014 (r260965) +++ stable/9/sys/cam/scsi/scsi_da.c Tue Jan 21 00:34:37 2014 (r260966) @@ -1968,7 +1968,7 @@ dadeletemethodsysctl(SYSCTL_HANDLER_ARGS char buf[16]; const char *p; struct da_softc *softc; - int i, error, value; + int i, error, methods, value; softc = (struct da_softc *)arg1; @@ -1981,8 +1981,9 @@ dadeletemethodsysctl(SYSCTL_HANDLER_ARGS error = sysctl_handle_string(oidp, buf, sizeof(buf), req); if (error != 0 || req->newptr == NULL) return (error); + methods = softc->delete_available | (1 << DA_DELETE_DISABLE); for (i = 0; i <= DA_DELETE_MAX; i++) { - if (!(softc->delete_available & (1 << i)) || + if (!(methods & (1 << i)) || strcmp(buf, da_delete_method_names[i]) != 0) continue; dadeletemethodset(softc, i); From owner-svn-src-stable-9@FreeBSD.ORG Tue Jan 21 09:20:46 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CBB51E67; Tue, 21 Jan 2014 09:20:46 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id B7F5F16CE; Tue, 21 Jan 2014 09:20:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0L9KkL9081479; Tue, 21 Jan 2014 09:20:46 GMT (envelope-from marck@svn.freebsd.org) Received: (from marck@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0L9KjK6081475; Tue, 21 Jan 2014 09:20:45 GMT (envelope-from marck@svn.freebsd.org) Message-Id: <201401210920.s0L9KjK6081475@svn.freebsd.org> From: Dmitry Morozovsky Date: Tue, 21 Jan 2014 09:20:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r260981 - in stable/9/sys: geom/part sys X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jan 2014 09:20:47 -0000 Author: marck (doc committer) Date: Tue Jan 21 09:20:45 2014 New Revision: 260981 URL: http://svnweb.freebsd.org/changeset/base/260981 Log: MFC r259925-259926: Add GPT UUID for VMware vSAN meta-data partition. Approved by: ae Modified: stable/9/sys/geom/part/g_part.c stable/9/sys/geom/part/g_part.h stable/9/sys/geom/part/g_part_gpt.c stable/9/sys/sys/gpt.h Directory Properties: stable/9/sys/ (props changed) stable/9/sys/sys/ (props changed) Modified: stable/9/sys/geom/part/g_part.c ============================================================================== --- stable/9/sys/geom/part/g_part.c Tue Jan 21 09:19:28 2014 (r260980) +++ stable/9/sys/geom/part/g_part.c Tue Jan 21 09:20:45 2014 (r260981) @@ -108,6 +108,7 @@ struct g_part_alias_list { { "vmware-vmfs", G_PART_ALIAS_VMFS }, { "vmware-vmkdiag", G_PART_ALIAS_VMKDIAG }, { "vmware-reserved", G_PART_ALIAS_VMRESERVED }, + { "vmware-vsanhdr", G_PART_ALIAS_VMVSANHDR }, }; SYSCTL_DECL(_kern_geom); Modified: stable/9/sys/geom/part/g_part.h ============================================================================== --- stable/9/sys/geom/part/g_part.h Tue Jan 21 09:19:28 2014 (r260980) +++ stable/9/sys/geom/part/g_part.h Tue Jan 21 09:20:45 2014 (r260981) @@ -74,6 +74,7 @@ enum g_part_alias { G_PART_ALIAS_VMFS, /* A VMware VMFS partition entry */ G_PART_ALIAS_VMKDIAG, /* A VMware vmkDiagnostic partition entry */ G_PART_ALIAS_VMRESERVED, /* A VMware reserved partition entry */ + G_PART_ALIAS_VMVSANHDR, /* A VMware vSAN header partition entry */ /* Keep the following last */ G_PART_ALIAS_COUNT }; Modified: stable/9/sys/geom/part/g_part_gpt.c ============================================================================== --- stable/9/sys/geom/part/g_part_gpt.c Tue Jan 21 09:19:28 2014 (r260980) +++ stable/9/sys/geom/part/g_part_gpt.c Tue Jan 21 09:20:45 2014 (r260981) @@ -167,6 +167,7 @@ static struct uuid gpt_uuid_linux_swap = static struct uuid gpt_uuid_vmfs = GPT_ENT_TYPE_VMFS; static struct uuid gpt_uuid_vmkdiag = GPT_ENT_TYPE_VMKDIAG; static struct uuid gpt_uuid_vmreserved = GPT_ENT_TYPE_VMRESERVED; +static struct uuid gpt_uuid_vmvsanhdr = GPT_ENT_TYPE_VMVSANHDR; static struct uuid gpt_uuid_ms_basic_data = GPT_ENT_TYPE_MS_BASIC_DATA; static struct uuid gpt_uuid_ms_reserved = GPT_ENT_TYPE_MS_RESERVED; static struct uuid gpt_uuid_ms_ldm_data = GPT_ENT_TYPE_MS_LDM_DATA; @@ -208,6 +209,7 @@ static struct g_part_uuid_alias { { &gpt_uuid_vmfs, G_PART_ALIAS_VMFS, 0 }, { &gpt_uuid_vmkdiag, G_PART_ALIAS_VMKDIAG, 0 }, { &gpt_uuid_vmreserved, G_PART_ALIAS_VMRESERVED, 0 }, + { &gpt_uuid_vmvsanhdr, G_PART_ALIAS_VMVSANHDR, 0 }, { &gpt_uuid_mbr, G_PART_ALIAS_MBR, 0 }, { &gpt_uuid_ms_basic_data, G_PART_ALIAS_MS_BASIC_DATA, 0x0b }, { &gpt_uuid_ms_ldm_data, G_PART_ALIAS_MS_LDM_DATA, 0 }, Modified: stable/9/sys/sys/gpt.h ============================================================================== --- stable/9/sys/sys/gpt.h Tue Jan 21 09:19:28 2014 (r260980) +++ stable/9/sys/sys/gpt.h Tue Jan 21 09:20:45 2014 (r260981) @@ -128,6 +128,8 @@ struct gpt_ent { {0x9d275380,0x40ad,0x11db,0xbf,0x97,{0x00,0x0c,0x29,0x11,0xd1,0xb8}} #define GPT_ENT_TYPE_VMRESERVED \ {0x9198effc,0x31c0,0x11db,0x8f,0x78,{0x00,0x0c,0x29,0x11,0xd1,0xb8}} +#define GPT_ENT_TYPE_VMVSANHDR \ + {0x381cfccc,0x7288,0x11e0,0x92,0xee,{0x00,0x0c,0x29,0x11,0xd0,0xb2}} #define GPT_ENT_TYPE_APPLE_BOOT \ {0x426F6F74,0x0000,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}} From owner-svn-src-stable-9@FreeBSD.ORG Wed Jan 22 09:23:30 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D6557320; Wed, 22 Jan 2014 09:23:30 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C1E381281; Wed, 22 Jan 2014 09:23:30 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0M9NUbu059163; Wed, 22 Jan 2014 09:23:30 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0M9NUvH059162; Wed, 22 Jan 2014 09:23:30 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201401220923.s0M9NUvH059162@svn.freebsd.org> From: Gleb Smirnoff Date: Wed, 22 Jan 2014 09:23:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261010 - stable/9/sys/netgraph X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jan 2014 09:23:30 -0000 Author: glebius Date: Wed Jan 22 09:23:30 2014 New Revision: 261010 URL: http://svnweb.freebsd.org/changeset/base/261010 Log: Merge 260225: Fix circular math macro. PR: 146082 Modified: stable/9/sys/netgraph/ng_l2tp.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netgraph/ng_l2tp.c ============================================================================== --- stable/9/sys/netgraph/ng_l2tp.c Wed Jan 22 09:22:39 2014 (r261009) +++ stable/9/sys/netgraph/ng_l2tp.c Wed Jan 22 09:23:30 2014 (r261010) @@ -98,7 +98,7 @@ static MALLOC_DEFINE(M_NETGRAPH_L2TP, "n #define L2TP_ENABLE_DSEQ 1 /* enable data seq # */ /* Compare sequence numbers using circular math */ -#define L2TP_SEQ_DIFF(x, y) ((int)((int16_t)(x) - (int16_t)(y))) +#define L2TP_SEQ_DIFF(x, y) ((int16_t)((x) - (y))) #define SESSHASHSIZE 0x0020 #define SESSHASH(x) (((x) ^ ((x) >> 8)) & (SESSHASHSIZE - 1)) From owner-svn-src-stable-9@FreeBSD.ORG Thu Jan 23 00:26:25 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 17D9C953; Thu, 23 Jan 2014 00:26:25 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id DDCEC14DC; Thu, 23 Jan 2014 00:26:24 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0N0QOB3042416; Thu, 23 Jan 2014 00:26:24 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0N0QOS1042415; Thu, 23 Jan 2014 00:26:24 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401230026.s0N0QOS1042415@svn.freebsd.org> From: Alexander Motin Date: Thu, 23 Jan 2014 00:26:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261056 - stable/9/sys/rpc X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jan 2014 00:26:25 -0000 Author: mav Date: Thu Jan 23 00:26:24 2014 New Revision: 261056 URL: http://svnweb.freebsd.org/changeset/base/261056 Log: MFC r258132: Some minor tuning to rpc/svc.c: - close cosmetic race in svc_exit(); - do not set wait timeout for idle threads if we have no use for wakeups; - create new requested thread sooner, not only after some another thread wakeup, that may happen later under constant load. Modified: stable/9/sys/rpc/svc.c Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/sys/rpc/svc.c ============================================================================== --- stable/9/sys/rpc/svc.c Wed Jan 22 23:55:25 2014 (r261055) +++ stable/9/sys/rpc/svc.c Thu Jan 23 00:26:24 2014 (r261056) @@ -1013,6 +1013,18 @@ svc_run_internal(SVCPOOL *pool, bool_t i while (pool->sp_state != SVCPOOL_CLOSING) { /* + * Create new thread if requested. + */ + if (pool->sp_state == SVCPOOL_THREADWANTED) { + pool->sp_state = SVCPOOL_THREADSTARTING; + pool->sp_lastcreatetime = time_uptime; + mtx_unlock(&pool->sp_lock); + svc_new_thread(pool); + mtx_lock(&pool->sp_lock); + continue; + } + + /* * Check for idle transports once per second. */ if (time_uptime > pool->sp_lastidlecheck) { @@ -1048,8 +1060,13 @@ svc_run_internal(SVCPOOL *pool, bool_t i continue; LIST_INSERT_HEAD(&pool->sp_idlethreads, st, st_ilink); - error = cv_timedwait_sig(&st->st_cond, &pool->sp_lock, - 5 * hz); + if (ismaster || (!ismaster && + pool->sp_threadcount > pool->sp_minthreads)) + error = cv_timedwait_sig(&st->st_cond, + &pool->sp_lock, 5 * hz); + else + error = cv_wait_sig(&st->st_cond, + &pool->sp_lock); LIST_REMOVE(st, st_ilink); /* @@ -1062,24 +1079,11 @@ svc_run_internal(SVCPOOL *pool, bool_t i && !st->st_xprt && STAILQ_EMPTY(&st->st_reqs)) break; - } - if (error == EWOULDBLOCK) - continue; - if (error) { - if (pool->sp_state != SVCPOOL_CLOSING) { - mtx_unlock(&pool->sp_lock); - svc_exit(pool); - mtx_lock(&pool->sp_lock); - } - break; - } - - if (pool->sp_state == SVCPOOL_THREADWANTED) { - pool->sp_state = SVCPOOL_THREADSTARTING; - pool->sp_lastcreatetime = time_uptime; + } else if (error) { mtx_unlock(&pool->sp_lock); - svc_new_thread(pool); + svc_exit(pool); mtx_lock(&pool->sp_lock); + break; } continue; } @@ -1247,9 +1251,11 @@ svc_exit(SVCPOOL *pool) mtx_lock(&pool->sp_lock); - pool->sp_state = SVCPOOL_CLOSING; - LIST_FOREACH(st, &pool->sp_idlethreads, st_ilink) - cv_signal(&st->st_cond); + if (pool->sp_state != SVCPOOL_CLOSING) { + pool->sp_state = SVCPOOL_CLOSING; + LIST_FOREACH(st, &pool->sp_idlethreads, st_ilink) + cv_signal(&st->st_cond); + } mtx_unlock(&pool->sp_lock); } From owner-svn-src-stable-9@FreeBSD.ORG Thu Jan 23 00:28:21 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CA682C6C; Thu, 23 Jan 2014 00:28:21 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id B37FA14F7; Thu, 23 Jan 2014 00:28:21 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0N0SLrs042912; Thu, 23 Jan 2014 00:28:21 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0N0SIai042895; Thu, 23 Jan 2014 00:28:18 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401230028.s0N0SIai042895@svn.freebsd.org> From: Alexander Motin Date: Thu, 23 Jan 2014 00:28:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261057 - in stable/9: include/rpc lib/libc/rpc sys/rpc X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jan 2014 00:28:21 -0000 Author: mav Date: Thu Jan 23 00:28:17 2014 New Revision: 261057 URL: http://svnweb.freebsd.org/changeset/base/261057 Log: MFC r258578, r258580, r258581 (by hrs): Replace Sun RPC license in TI-RPC library with a 3-clause BSD license with the explicit permissions. Modified: stable/9/include/rpc/auth.h stable/9/include/rpc/auth_des.h stable/9/include/rpc/auth_kerb.h stable/9/include/rpc/auth_unix.h stable/9/include/rpc/clnt.h stable/9/include/rpc/clnt_soc.h stable/9/include/rpc/des.h stable/9/include/rpc/des_crypt.h stable/9/include/rpc/nettype.h stable/9/include/rpc/pmap_clnt.h stable/9/include/rpc/pmap_prot.h stable/9/include/rpc/pmap_rmt.h stable/9/include/rpc/raw.h stable/9/include/rpc/rpc.h stable/9/include/rpc/rpc_com.h stable/9/include/rpc/rpc_msg.h stable/9/include/rpc/rpcb_clnt.h stable/9/include/rpc/rpcb_prot.x stable/9/include/rpc/rpcent.h stable/9/include/rpc/svc.h stable/9/include/rpc/svc_auth.h stable/9/include/rpc/svc_dg.h stable/9/include/rpc/svc_soc.h stable/9/include/rpc/xdr.h stable/9/lib/libc/rpc/DISCLAIMER stable/9/lib/libc/rpc/auth_des.c stable/9/lib/libc/rpc/auth_none.c stable/9/lib/libc/rpc/auth_unix.c stable/9/lib/libc/rpc/authdes_prot.c stable/9/lib/libc/rpc/authunix_prot.c stable/9/lib/libc/rpc/bindresvport.c stable/9/lib/libc/rpc/clnt_bcast.c stable/9/lib/libc/rpc/clnt_dg.c stable/9/lib/libc/rpc/clnt_generic.c stable/9/lib/libc/rpc/clnt_perror.c stable/9/lib/libc/rpc/clnt_raw.c stable/9/lib/libc/rpc/clnt_simple.c stable/9/lib/libc/rpc/clnt_vc.c stable/9/lib/libc/rpc/des_crypt.c stable/9/lib/libc/rpc/des_soft.c stable/9/lib/libc/rpc/getnetconfig.c stable/9/lib/libc/rpc/getnetpath.c stable/9/lib/libc/rpc/getpublickey.c stable/9/lib/libc/rpc/getrpcent.c stable/9/lib/libc/rpc/getrpcport.c stable/9/lib/libc/rpc/key_call.c stable/9/lib/libc/rpc/key_prot_xdr.c stable/9/lib/libc/rpc/netname.c stable/9/lib/libc/rpc/netnamer.c stable/9/lib/libc/rpc/pmap_clnt.c stable/9/lib/libc/rpc/pmap_getmaps.c stable/9/lib/libc/rpc/pmap_getport.c stable/9/lib/libc/rpc/pmap_prot.c stable/9/lib/libc/rpc/pmap_prot2.c stable/9/lib/libc/rpc/pmap_rmt.c stable/9/lib/libc/rpc/rpc_callmsg.c stable/9/lib/libc/rpc/rpc_com.h stable/9/lib/libc/rpc/rpc_commondata.c stable/9/lib/libc/rpc/rpc_dtablesize.c stable/9/lib/libc/rpc/rpc_generic.c stable/9/lib/libc/rpc/rpc_prot.c stable/9/lib/libc/rpc/rpc_soc.c stable/9/lib/libc/rpc/rpcb_clnt.c stable/9/lib/libc/rpc/rpcb_prot.c stable/9/lib/libc/rpc/rpcb_st_xdr.c stable/9/lib/libc/rpc/rpcdname.c stable/9/lib/libc/rpc/rtime.c stable/9/lib/libc/rpc/svc.c stable/9/lib/libc/rpc/svc_auth.c stable/9/lib/libc/rpc/svc_auth_des.c stable/9/lib/libc/rpc/svc_auth_unix.c stable/9/lib/libc/rpc/svc_dg.c stable/9/lib/libc/rpc/svc_generic.c stable/9/lib/libc/rpc/svc_raw.c stable/9/lib/libc/rpc/svc_run.c stable/9/lib/libc/rpc/svc_simple.c stable/9/lib/libc/rpc/svc_vc.c stable/9/sys/rpc/auth.h stable/9/sys/rpc/auth_none.c stable/9/sys/rpc/auth_unix.c stable/9/sys/rpc/authunix_prot.c stable/9/sys/rpc/clnt.h stable/9/sys/rpc/clnt_dg.c stable/9/sys/rpc/clnt_vc.c stable/9/sys/rpc/nettype.h stable/9/sys/rpc/pmap_prot.h stable/9/sys/rpc/rpc.h stable/9/sys/rpc/rpc_callmsg.c stable/9/sys/rpc/rpc_com.h stable/9/sys/rpc/rpc_generic.c stable/9/sys/rpc/rpc_msg.h stable/9/sys/rpc/rpc_prot.c stable/9/sys/rpc/rpcb_clnt.c stable/9/sys/rpc/rpcb_clnt.h stable/9/sys/rpc/rpcb_prot.c stable/9/sys/rpc/rpcb_prot.h stable/9/sys/rpc/svc.c stable/9/sys/rpc/svc.h stable/9/sys/rpc/svc_auth.c stable/9/sys/rpc/svc_auth.h stable/9/sys/rpc/svc_auth_unix.c stable/9/sys/rpc/svc_dg.c stable/9/sys/rpc/svc_generic.c stable/9/sys/rpc/svc_vc.c stable/9/sys/rpc/types.h stable/9/sys/rpc/xdr.h Directory Properties: stable/9/ (props changed) stable/9/include/ (props changed) stable/9/lib/ (props changed) stable/9/lib/libc/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/include/rpc/auth.h ============================================================================== --- stable/9/include/rpc/auth.h Thu Jan 23 00:26:24 2014 (r261056) +++ stable/9/include/rpc/auth.h Thu Jan 23 00:28:17 2014 (r261057) @@ -1,32 +1,31 @@ /* $NetBSD: auth.h,v 1.15 2000/06/02 22:57:55 fvdl Exp $ */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 +/*- + * Copyright (c) 2009, Sun Microsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. * * from: @(#)auth.h 1.17 88/02/08 SMI * from: @(#)auth.h 2.3 88/08/07 4.0 RPCSRC Modified: stable/9/include/rpc/auth_des.h ============================================================================== --- stable/9/include/rpc/auth_des.h Thu Jan 23 00:26:24 2014 (r261056) +++ stable/9/include/rpc/auth_des.h Thu Jan 23 00:28:17 2014 (r261057) @@ -1,32 +1,31 @@ /* @(#)auth_des.h 2.2 88/07/29 4.0 RPCSRC; from 1.3 88/02/08 SMI */ /* $FreeBSD$ */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 +/*- + * Copyright (c) 2009, Sun Microsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. * * from: @(#)auth_des.h 2.2 88/07/29 4.0 RPCSRC * from: @(#)auth_des.h 1.14 94/04/25 SMI Modified: stable/9/include/rpc/auth_kerb.h ============================================================================== --- stable/9/include/rpc/auth_kerb.h Thu Jan 23 00:26:24 2014 (r261056) +++ stable/9/include/rpc/auth_kerb.h Thu Jan 23 00:28:17 2014 (r261057) @@ -1,31 +1,30 @@ /* $FreeBSD$ */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 +/*- + * Copyright (c) 2009, Sun Microsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ /* * auth_kerb.h, Protocol for Kerberos style authentication for RPC Modified: stable/9/include/rpc/auth_unix.h ============================================================================== --- stable/9/include/rpc/auth_unix.h Thu Jan 23 00:26:24 2014 (r261056) +++ stable/9/include/rpc/auth_unix.h Thu Jan 23 00:28:17 2014 (r261057) @@ -1,30 +1,29 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 +/*- + * Copyright (c) 2009, Sun Microsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. * * from: @(#)auth_unix.h 1.8 88/02/08 SMI * from: @(#)auth_unix.h 2.2 88/07/29 4.0 RPCSRC Modified: stable/9/include/rpc/clnt.h ============================================================================== --- stable/9/include/rpc/clnt.h Thu Jan 23 00:26:24 2014 (r261056) +++ stable/9/include/rpc/clnt.h Thu Jan 23 00:28:17 2014 (r261057) @@ -1,49 +1,31 @@ /* $NetBSD: clnt.h,v 1.14 2000/06/02 22:57:55 fvdl Exp $ */ -/* - * The contents of this file are subject to the Sun Standards - * License Version 1.0 the (the "License";) You may not use - * this file except in compliance with the License. You may - * obtain a copy of the License at lib/libc/rpc/LICENSE - * - * Software distributed under the License is distributed on - * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either - * express or implied. See the License for the specific - * language governing rights and limitations under the License. - * - * The Original Code is Copyright 1998 by Sun Microsystems, Inc - * - * The Initial Developer of the Original Code is: Sun - * Microsystems, Inc. - * - * All Rights Reserved. - * - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. +/*- + * Copyright (c) 2010, Oracle America, Inc. + * All rights reserved. * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of the "Oracle America, Inc." nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. * * from: @(#)clnt.h 1.31 94/04/29 SMI * from: @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC @@ -52,9 +34,6 @@ /* * clnt.h - Client side remote procedure call interface. - * - * Copyright (c) 1986-1991,1994-1999 by Sun Microsystems, Inc. - * All rights reserved. */ #ifndef _RPC_CLNT_H_ Modified: stable/9/include/rpc/clnt_soc.h ============================================================================== --- stable/9/include/rpc/clnt_soc.h Thu Jan 23 00:26:24 2014 (r261056) +++ stable/9/include/rpc/clnt_soc.h Thu Jan 23 00:28:17 2014 (r261057) @@ -1,33 +1,32 @@ /* $NetBSD: clnt_soc.h,v 1.1 2000/06/02 22:57:55 fvdl Exp $ */ /* $FreeBSD$ */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 +/*- + * Copyright (c) 2009, Sun Microsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ /* * Copyright (c) 1984 - 1991 by Sun Microsystems, Inc. Modified: stable/9/include/rpc/des.h ============================================================================== --- stable/9/include/rpc/des.h Thu Jan 23 00:26:24 2014 (r261056) +++ stable/9/include/rpc/des.h Thu Jan 23 00:28:17 2014 (r261057) @@ -1,32 +1,31 @@ /* @(#)des.h 2.2 88/08/10 4.0 RPCSRC; from 2.7 88/02/08 SMI */ /* $FreeBSD$ */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 +/*- + * Copyright (c) 2009, Sun Microsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ /* * Generic DES driver interface Modified: stable/9/include/rpc/des_crypt.h ============================================================================== --- stable/9/include/rpc/des_crypt.h Thu Jan 23 00:26:24 2014 (r261056) +++ stable/9/include/rpc/des_crypt.h Thu Jan 23 00:28:17 2014 (r261057) @@ -5,33 +5,32 @@ * des_crypt.h, des library routine interface * Copyright (C) 1986, Sun Microsystems, Inc. */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 +/*- + * Copyright (c) 2009, Sun Microsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ /* * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. Modified: stable/9/include/rpc/nettype.h ============================================================================== --- stable/9/include/rpc/nettype.h Thu Jan 23 00:26:24 2014 (r261056) +++ stable/9/include/rpc/nettype.h Thu Jan 23 00:28:17 2014 (r261057) @@ -1,33 +1,32 @@ /* $NetBSD: nettype.h,v 1.2 2000/07/06 03:17:19 christos Exp $ */ /* $FreeBSD$ */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 +/*- + * Copyright (c) 2009, Sun Microsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ /* * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. Modified: stable/9/include/rpc/pmap_clnt.h ============================================================================== --- stable/9/include/rpc/pmap_clnt.h Thu Jan 23 00:26:24 2014 (r261056) +++ stable/9/include/rpc/pmap_clnt.h Thu Jan 23 00:28:17 2014 (r261057) @@ -1,32 +1,31 @@ /* $NetBSD: pmap_clnt.h,v 1.9 2000/06/02 22:57:55 fvdl Exp $ */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 +/*- + * Copyright (c) 2009, Sun Microsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. * * from: @(#)pmap_clnt.h 1.11 88/02/08 SMI * from: @(#)pmap_clnt.h 2.1 88/07/29 4.0 RPCSRC Modified: stable/9/include/rpc/pmap_prot.h ============================================================================== --- stable/9/include/rpc/pmap_prot.h Thu Jan 23 00:26:24 2014 (r261056) +++ stable/9/include/rpc/pmap_prot.h Thu Jan 23 00:28:17 2014 (r261057) @@ -1,32 +1,31 @@ /* $NetBSD: pmap_prot.h,v 1.8 2000/06/02 22:57:55 fvdl Exp $ */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 +/*- + * Copyright (c) 2009, Sun Microsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. * * from: @(#)pmap_prot.h 1.14 88/02/08 SMI * from: @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC Modified: stable/9/include/rpc/pmap_rmt.h ============================================================================== --- stable/9/include/rpc/pmap_rmt.h Thu Jan 23 00:26:24 2014 (r261056) +++ stable/9/include/rpc/pmap_rmt.h Thu Jan 23 00:28:17 2014 (r261057) @@ -1,32 +1,31 @@ /* $NetBSD: pmap_rmt.h,v 1.7 1998/02/11 23:01:23 lukem Exp $ */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 +/*- + * Copyright (c) 2009, Sun Microsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. * * from: @(#)pmap_rmt.h 1.2 88/02/08 SMI * from: @(#)pmap_rmt.h 2.1 88/07/29 4.0 RPCSRC Modified: stable/9/include/rpc/raw.h ============================================================================== --- stable/9/include/rpc/raw.h Thu Jan 23 00:26:24 2014 (r261056) +++ stable/9/include/rpc/raw.h Thu Jan 23 00:28:17 2014 (r261057) @@ -1,33 +1,32 @@ /* $NetBSD: raw.h,v 1.1 2000/06/02 22:57:56 fvdl Exp $ */ /* $FreeBSD$ */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 +/*- + * Copyright (c) 2009, Sun Microsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ /* * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. Modified: stable/9/include/rpc/rpc.h ============================================================================== --- stable/9/include/rpc/rpc.h Thu Jan 23 00:26:24 2014 (r261056) +++ stable/9/include/rpc/rpc.h Thu Jan 23 00:28:17 2014 (r261057) @@ -1,32 +1,31 @@ /* $NetBSD: rpc.h,v 1.13 2000/06/02 22:57:56 fvdl Exp $ */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 +/*- + * Copyright (c) 2009, Sun Microsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. * * from: @(#)rpc.h 1.9 88/02/08 SMI * from: @(#)rpc.h 2.4 89/07/11 4.0 RPCSRC Modified: stable/9/include/rpc/rpc_com.h ============================================================================== --- stable/9/include/rpc/rpc_com.h Thu Jan 23 00:26:24 2014 (r261056) +++ stable/9/include/rpc/rpc_com.h Thu Jan 23 00:28:17 2014 (r261057) @@ -1,33 +1,32 @@ /* $NetBSD: rpc_com.h,v 1.3 2000/12/10 04:10:08 christos Exp $ */ /* $FreeBSD$ */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 +/*- + * Copyright (c) 2009, Sun Microsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ /* * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. Modified: stable/9/include/rpc/rpc_msg.h ============================================================================== --- stable/9/include/rpc/rpc_msg.h Thu Jan 23 00:26:24 2014 (r261056) +++ stable/9/include/rpc/rpc_msg.h Thu Jan 23 00:28:17 2014 (r261057) @@ -1,32 +1,31 @@ /* $NetBSD: rpc_msg.h,v 1.11 2000/06/02 22:57:56 fvdl Exp $ */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 +/*- + * Copyright (c) 2009, Sun Microsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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 *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-9@FreeBSD.ORG Thu Jan 23 00:35:43 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 899752A8; Thu, 23 Jan 2014 00:35:43 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 74E8E1609; Thu, 23 Jan 2014 00:35:43 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0N0ZhuA046729; Thu, 23 Jan 2014 00:35:43 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0N0ZgBT046723; Thu, 23 Jan 2014 00:35:42 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401230035.s0N0ZgBT046723@svn.freebsd.org> From: Alexander Motin Date: Thu, 23 Jan 2014 00:35:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261058 - stable/9/sys/rpc X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jan 2014 00:35:43 -0000 Author: mav Date: Thu Jan 23 00:35:41 2014 New Revision: 261058 URL: http://svnweb.freebsd.org/changeset/base/261058 Log: MFC r244008 (by rmacklem): Add support for backchannels to the kernel RPC. Backchannels are used by NFSv4.1 for callbacks. A backchannel is a connection established by the client, but used for RPCs done by the server on the client (callbacks). As a result, this patch mixes some client side calls in the server side and vice versa. Some definitions in the .c files were extracted out into a file called krpc.h, so that they could be included in multiple .c files. This code has been in projects/nfsv4.1-client for some time. Although no one has given it a formal review, I believe kib@ has taken a look at it. Added: stable/9/sys/rpc/krpc.h - copied unchanged from r244008, head/sys/rpc/krpc.h Modified: stable/9/sys/rpc/clnt.h stable/9/sys/rpc/clnt_rc.c stable/9/sys/rpc/clnt_vc.c stable/9/sys/rpc/svc.h stable/9/sys/rpc/svc_vc.c Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/sys/rpc/clnt.h ============================================================================== --- stable/9/sys/rpc/clnt.h Thu Jan 23 00:28:17 2014 (r261057) +++ stable/9/sys/rpc/clnt.h Thu Jan 23 00:35:41 2014 (r261058) @@ -354,6 +354,7 @@ enum clnt_stat clnt_call_private(CLIENT #define CLGET_RETRIES 26 /* get retry count for reconnect */ #define CLSET_PRIVPORT 27 /* set privileged source port flag */ #define CLGET_PRIVPORT 28 /* get privileged source port flag */ +#define CLSET_BACKCHANNEL 29 /* set backchannel for socket */ #endif Modified: stable/9/sys/rpc/clnt_rc.c ============================================================================== --- stable/9/sys/rpc/clnt_rc.c Thu Jan 23 00:28:17 2014 (r261057) +++ stable/9/sys/rpc/clnt_rc.c Thu Jan 23 00:35:41 2014 (r261058) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include static enum clnt_stat clnt_reconnect_call(CLIENT *, struct rpc_callextra *, rpcproc_t, struct mbuf *, struct mbuf **, struct timeval); @@ -67,27 +68,6 @@ static struct clnt_ops clnt_reconnect_op static int fake_wchan; -struct rc_data { - struct mtx rc_lock; - struct sockaddr_storage rc_addr; /* server address */ - struct netconfig* rc_nconf; /* network type */ - rpcprog_t rc_prog; /* program number */ - rpcvers_t rc_vers; /* version number */ - size_t rc_sendsz; - size_t rc_recvsz; - struct timeval rc_timeout; - struct timeval rc_retry; - int rc_retries; - int rc_privport; - char *rc_waitchan; - int rc_intr; - int rc_connecting; - int rc_closed; - struct ucred *rc_ucred; - CLIENT* rc_client; /* underlying RPC client */ - struct rpc_err rc_err; -}; - CLIENT * clnt_reconnect_create( struct netconfig *nconf, /* network type */ @@ -211,6 +191,8 @@ clnt_reconnect_connect(CLIENT *cl) CLNT_CONTROL(newclient, CLSET_RETRY_TIMEOUT, &rc->rc_retry); CLNT_CONTROL(newclient, CLSET_WAITCHAN, rc->rc_waitchan); CLNT_CONTROL(newclient, CLSET_INTERRUPTIBLE, &rc->rc_intr); + if (rc->rc_backchannel != NULL) + CLNT_CONTROL(newclient, CLSET_BACKCHANNEL, rc->rc_backchannel); stat = RPC_SUCCESS; out: @@ -385,6 +367,7 @@ static bool_t clnt_reconnect_control(CLIENT *cl, u_int request, void *info) { struct rc_data *rc = (struct rc_data *)cl->cl_private; + SVCXPRT *xprt; if (info == NULL) { return (FALSE); @@ -466,6 +449,13 @@ clnt_reconnect_control(CLIENT *cl, u_int *(int *) info = rc->rc_privport; break; + case CLSET_BACKCHANNEL: + xprt = (SVCXPRT *)info; + SVC_ACQUIRE(xprt); + xprt_register(xprt); + rc->rc_backchannel = info; + break; + default: return (FALSE); } @@ -502,9 +492,15 @@ static void clnt_reconnect_destroy(CLIENT *cl) { struct rc_data *rc = (struct rc_data *)cl->cl_private; + SVCXPRT *xprt; if (rc->rc_client) CLNT_DESTROY(rc->rc_client); + if (rc->rc_backchannel) { + xprt = (SVCXPRT *)rc->rc_backchannel; + xprt_unregister(xprt); + SVC_RELEASE(xprt); + } crfree(rc->rc_ucred); mtx_destroy(&rc->rc_lock); mem_free(rc, sizeof(*rc)); Modified: stable/9/sys/rpc/clnt_vc.c ============================================================================== --- stable/9/sys/rpc/clnt_vc.c Thu Jan 23 00:28:17 2014 (r261057) +++ stable/9/sys/rpc/clnt_vc.c Thu Jan 23 00:35:41 2014 (r261058) @@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -76,8 +77,7 @@ __FBSDID("$FreeBSD$"); #include #include - -#define MCALL_MSG_SIZE 24 +#include struct cmessage { struct cmsghdr cmsg; @@ -105,43 +105,6 @@ static struct clnt_ops clnt_vc_ops = { .cl_control = clnt_vc_control }; -/* - * A pending RPC request which awaits a reply. Requests which have - * received their reply will have cr_xid set to zero and cr_mrep to - * the mbuf chain of the reply. - */ -struct ct_request { - TAILQ_ENTRY(ct_request) cr_link; - uint32_t cr_xid; /* XID of request */ - struct mbuf *cr_mrep; /* reply received by upcall */ - int cr_error; /* any error from upcall */ - char cr_verf[MAX_AUTH_BYTES]; /* reply verf */ -}; - -TAILQ_HEAD(ct_request_list, ct_request); - -struct ct_data { - struct mtx ct_lock; - int ct_threads; /* number of threads in clnt_vc_call */ - bool_t ct_closing; /* TRUE if we are closing */ - bool_t ct_closed; /* TRUE if we are closed */ - struct socket *ct_socket; /* connection socket */ - bool_t ct_closeit; /* close it on destroy */ - struct timeval ct_wait; /* wait interval in milliseconds */ - struct sockaddr_storage ct_addr; /* remote addr */ - struct rpc_err ct_error; - uint32_t ct_xid; - char ct_mcallc[MCALL_MSG_SIZE]; /* marshalled callmsg */ - size_t ct_mpos; /* pos after marshal */ - const char *ct_waitchan; - int ct_waitflag; - struct mbuf *ct_record; /* current reply record */ - size_t ct_record_resid; /* how much left of reply to read */ - bool_t ct_record_eor; /* true if reading last fragment */ - struct ct_request_list ct_pending; - int ct_upcallrefs; /* Ref cnt of upcalls in prog. */ -}; - static void clnt_vc_upcallsdone(struct ct_data *); /* @@ -635,6 +598,7 @@ clnt_vc_control(CLIENT *cl, u_int reques { struct ct_data *ct = (struct ct_data *)cl->cl_private; void *infop = info; + SVCXPRT *xprt; mtx_lock(&ct->ct_lock); @@ -746,6 +710,14 @@ clnt_vc_control(CLIENT *cl, u_int reques *(int *) info = FALSE; break; + case CLSET_BACKCHANNEL: + xprt = (SVCXPRT *)info; + if (ct->ct_backchannelxprt == NULL) { + xprt->xp_p2 = ct; + ct->ct_backchannelxprt = xprt; + } + break; + default: mtx_unlock(&ct->ct_lock); return (FALSE); @@ -811,10 +783,20 @@ clnt_vc_destroy(CLIENT *cl) { struct ct_data *ct = (struct ct_data *) cl->cl_private; struct socket *so = NULL; + SVCXPRT *xprt; clnt_vc_close(cl); mtx_lock(&ct->ct_lock); + xprt = ct->ct_backchannelxprt; + ct->ct_backchannelxprt = NULL; + if (xprt != NULL) { + mtx_unlock(&ct->ct_lock); /* To avoid a LOR. */ + sx_xlock(&xprt->xp_lock); + mtx_lock(&ct->ct_lock); + xprt->xp_p2 = NULL; + xprt_unregister(xprt); + } if (ct->ct_socket) { if (ct->ct_closeit) { @@ -823,6 +805,10 @@ clnt_vc_destroy(CLIENT *cl) } mtx_unlock(&ct->ct_lock); + if (xprt != NULL) { + sx_xunlock(&xprt->xp_lock); + SVC_RELEASE(xprt); + } mtx_destroy(&ct->ct_lock); if (so) { @@ -853,12 +839,15 @@ clnt_vc_soupcall(struct socket *so, void { struct ct_data *ct = (struct ct_data *) arg; struct uio uio; - struct mbuf *m; + struct mbuf *m, *m2; struct ct_request *cr; int error, rcvflag, foundreq; - uint32_t xid, header; + uint32_t xid_plus_direction[2], header; bool_t do_read; + SVCXPRT *xprt; + struct cf_conn *cd; + CTASSERT(sizeof(xid_plus_direction) == 2 * sizeof(uint32_t)); ct->ct_upcallrefs++; uio.uio_td = curthread; do { @@ -972,45 +961,89 @@ clnt_vc_soupcall(struct socket *so, void && ct->ct_record_eor) { /* * The XID is in the first uint32_t of - * the reply. + * the reply and the message direction + * is the second one. */ - if (ct->ct_record->m_len < sizeof(xid) && + if (ct->ct_record->m_len < + sizeof(xid_plus_direction) && m_length(ct->ct_record, NULL) < - sizeof(xid)) { + sizeof(xid_plus_direction)) { m_freem(ct->ct_record); break; } - m_copydata(ct->ct_record, 0, sizeof(xid), - (char *)&xid); - xid = ntohl(xid); - - mtx_lock(&ct->ct_lock); - foundreq = 0; - TAILQ_FOREACH(cr, &ct->ct_pending, cr_link) { - if (cr->cr_xid == xid) { + m_copydata(ct->ct_record, 0, + sizeof(xid_plus_direction), + (char *)xid_plus_direction); + xid_plus_direction[0] = + ntohl(xid_plus_direction[0]); + xid_plus_direction[1] = + ntohl(xid_plus_direction[1]); + /* Check message direction. */ + if (xid_plus_direction[1] == CALL) { + /* This is a backchannel request. */ + mtx_lock(&ct->ct_lock); + xprt = ct->ct_backchannelxprt; + if (xprt == NULL) { + mtx_unlock(&ct->ct_lock); + /* Just throw it away. */ + m_freem(ct->ct_record); + ct->ct_record = NULL; + } else { + cd = (struct cf_conn *) + xprt->xp_p1; + m2 = cd->mreq; /* - * This one - * matches. We leave - * the reply mbuf in - * cr->cr_mrep. Set - * the XID to zero so - * that we will ignore - * any duplicaed - * replies. + * The requests are chained + * in the m_nextpkt list. */ - cr->cr_xid = 0; - cr->cr_mrep = ct->ct_record; - cr->cr_error = 0; - foundreq = 1; - wakeup(cr); - break; + while (m2 != NULL && + m2->m_nextpkt != NULL) + /* Find end of list. */ + m2 = m2->m_nextpkt; + if (m2 != NULL) + m2->m_nextpkt = + ct->ct_record; + else + cd->mreq = + ct->ct_record; + ct->ct_record->m_nextpkt = + NULL; + ct->ct_record = NULL; + xprt_active(xprt); + mtx_unlock(&ct->ct_lock); } - } - mtx_unlock(&ct->ct_lock); + } else { + mtx_lock(&ct->ct_lock); + foundreq = 0; + TAILQ_FOREACH(cr, &ct->ct_pending, + cr_link) { + if (cr->cr_xid == + xid_plus_direction[0]) { + /* + * This one + * matches. We leave + * the reply mbuf in + * cr->cr_mrep. Set + * the XID to zero so + * that we will ignore + * any duplicated + * replies. + */ + cr->cr_xid = 0; + cr->cr_mrep = + ct->ct_record; + cr->cr_error = 0; + foundreq = 1; + wakeup(cr); + break; + } + } + mtx_unlock(&ct->ct_lock); - if (!foundreq) - m_freem(ct->ct_record); - ct->ct_record = NULL; + if (!foundreq) + m_freem(ct->ct_record); + ct->ct_record = NULL; + } } } } while (m); Copied: stable/9/sys/rpc/krpc.h (from r244008, head/sys/rpc/krpc.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/sys/rpc/krpc.h Thu Jan 23 00:35:41 2014 (r261058, copy of r244008, head/sys/rpc/krpc.h) @@ -0,0 +1,111 @@ +/*- + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * $FreeBSD$ + */ + +#ifndef _RPC_KRPC_H_ +#define _RPC_KRPC_H_ + +#ifdef _KERNEL +/* + * Definitions now shared between client and server RPC for backchannels. + */ +#define MCALL_MSG_SIZE 24 + +/* + * A pending RPC request which awaits a reply. Requests which have + * received their reply will have cr_xid set to zero and cr_mrep to + * the mbuf chain of the reply. + */ +struct ct_request { + TAILQ_ENTRY(ct_request) cr_link; + uint32_t cr_xid; /* XID of request */ + struct mbuf *cr_mrep; /* reply received by upcall */ + int cr_error; /* any error from upcall */ + char cr_verf[MAX_AUTH_BYTES]; /* reply verf */ +}; + +TAILQ_HEAD(ct_request_list, ct_request); + +struct rc_data { + struct mtx rc_lock; + struct sockaddr_storage rc_addr; /* server address */ + struct netconfig* rc_nconf; /* network type */ + rpcprog_t rc_prog; /* program number */ + rpcvers_t rc_vers; /* version number */ + size_t rc_sendsz; + size_t rc_recvsz; + struct timeval rc_timeout; + struct timeval rc_retry; + int rc_retries; + int rc_privport; + char *rc_waitchan; + int rc_intr; + int rc_connecting; + int rc_closed; + struct ucred *rc_ucred; + CLIENT* rc_client; /* underlying RPC client */ + struct rpc_err rc_err; + void *rc_backchannel; +}; + +struct ct_data { + struct mtx ct_lock; + int ct_threads; /* number of threads in clnt_vc_call */ + bool_t ct_closing; /* TRUE if we are closing */ + bool_t ct_closed; /* TRUE if we are closed */ + struct socket *ct_socket; /* connection socket */ + bool_t ct_closeit; /* close it on destroy */ + struct timeval ct_wait; /* wait interval in milliseconds */ + struct sockaddr_storage ct_addr; /* remote addr */ + struct rpc_err ct_error; + uint32_t ct_xid; + char ct_mcallc[MCALL_MSG_SIZE]; /* marshalled callmsg */ + size_t ct_mpos; /* pos after marshal */ + const char *ct_waitchan; + int ct_waitflag; + struct mbuf *ct_record; /* current reply record */ + size_t ct_record_resid; /* how much left of reply to read */ + bool_t ct_record_eor; /* true if reading last fragment */ + struct ct_request_list ct_pending; + int ct_upcallrefs; /* Ref cnt of upcalls in prog. */ + SVCXPRT *ct_backchannelxprt; /* xprt for backchannel */ +}; + +struct cf_conn { /* kept in xprt->xp_p1 for actual connection */ + enum xprt_stat strm_stat; + struct mbuf *mpending; /* unparsed data read from the socket */ + struct mbuf *mreq; /* current record being built from mpending */ + uint32_t resid; /* number of bytes needed for fragment */ + bool_t eor; /* reading last fragment of current record */ +}; + +#endif /* _KERNEL */ + +#endif /* _RPC_KRPC_H_ */ Modified: stable/9/sys/rpc/svc.h ============================================================================== --- stable/9/sys/rpc/svc.h Thu Jan 23 00:28:17 2014 (r261057) +++ stable/9/sys/rpc/svc.h Thu Jan 23 00:35:41 2014 (r261058) @@ -702,6 +702,8 @@ extern SVCXPRT *svc_vc_create(SVCPOOL *, * const size_t recvsize; -- max recv size */ +extern SVCXPRT *svc_vc_create_backchannel(SVCPOOL *); + /* * Generic TLI create routine */ Modified: stable/9/sys/rpc/svc_vc.c ============================================================================== --- stable/9/sys/rpc/svc_vc.c Thu Jan 23 00:28:17 2014 (r261057) +++ stable/9/sys/rpc/svc_vc.c Thu Jan 23 00:35:41 2014 (r261058) @@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include @@ -82,6 +83,14 @@ static bool_t svc_vc_reply(SVCXPRT *, st static bool_t svc_vc_control(SVCXPRT *xprt, const u_int rq, void *in); static bool_t svc_vc_rendezvous_control (SVCXPRT *xprt, const u_int rq, void *in); +static void svc_vc_backchannel_destroy(SVCXPRT *); +static enum xprt_stat svc_vc_backchannel_stat(SVCXPRT *); +static bool_t svc_vc_backchannel_recv(SVCXPRT *, struct rpc_msg *, + struct sockaddr **, struct mbuf **); +static bool_t svc_vc_backchannel_reply(SVCXPRT *, struct rpc_msg *, + struct sockaddr *, struct mbuf *); +static bool_t svc_vc_backchannel_control(SVCXPRT *xprt, const u_int rq, + void *in); static SVCXPRT *svc_vc_create_conn(SVCPOOL *pool, struct socket *so, struct sockaddr *raddr); static int svc_vc_accept(struct socket *head, struct socket **sop); @@ -104,12 +113,12 @@ static struct xp_ops svc_vc_ops = { .xp_control = svc_vc_control }; -struct cf_conn { /* kept in xprt->xp_p1 for actual connection */ - enum xprt_stat strm_stat; - struct mbuf *mpending; /* unparsed data read from the socket */ - struct mbuf *mreq; /* current record being built from mpending */ - uint32_t resid; /* number of bytes needed for fragment */ - bool_t eor; /* reading last fragment of current record */ +static struct xp_ops svc_vc_backchannel_ops = { + .xp_recv = svc_vc_backchannel_recv, + .xp_stat = svc_vc_backchannel_stat, + .xp_reply = svc_vc_backchannel_reply, + .xp_destroy = svc_vc_backchannel_destroy, + .xp_control = svc_vc_backchannel_control }; /* @@ -269,6 +278,28 @@ cleanup_svc_vc_create: } /* + * Create a new transport for a backchannel on a clnt_vc socket. + */ +SVCXPRT * +svc_vc_create_backchannel(SVCPOOL *pool) +{ + SVCXPRT *xprt = NULL; + struct cf_conn *cd = NULL; + + cd = mem_alloc(sizeof(*cd)); + cd->strm_stat = XPRT_IDLE; + + xprt = svc_xprt_alloc(); + sx_init(&xprt->xp_lock, "xprt->xp_lock"); + xprt->xp_pool = pool; + xprt->xp_socket = NULL; + xprt->xp_p1 = cd; + xprt->xp_p2 = NULL; + xprt->xp_ops = &svc_vc_backchannel_ops; + return (xprt); +} + +/* * This does all of the accept except the final call to soaccept. The * caller will call soaccept after dropping its locks (soaccept may * call malloc). @@ -454,6 +485,22 @@ svc_vc_destroy(SVCXPRT *xprt) mem_free(cd, sizeof(*cd)); } +static void +svc_vc_backchannel_destroy(SVCXPRT *xprt) +{ + struct cf_conn *cd = (struct cf_conn *)xprt->xp_p1; + struct mbuf *m, *m2; + + svc_xprt_free(xprt); + m = cd->mreq; + while (m != NULL) { + m2 = m; + m = m->m_nextpkt; + m_freem(m2); + } + mem_free(cd, sizeof(*cd)); +} + /*ARGSUSED*/ static bool_t svc_vc_control(SVCXPRT *xprt, const u_int rq, void *in) @@ -468,6 +515,13 @@ svc_vc_rendezvous_control(SVCXPRT *xprt, return (FALSE); } +static bool_t +svc_vc_backchannel_control(SVCXPRT *xprt, const u_int rq, void *in) +{ + + return (FALSE); +} + static enum xprt_stat svc_vc_stat(SVCXPRT *xprt) { @@ -508,6 +562,19 @@ svc_vc_stat(SVCXPRT *xprt) return (XPRT_IDLE); } +static enum xprt_stat +svc_vc_backchannel_stat(SVCXPRT *xprt) +{ + struct cf_conn *cd; + + cd = (struct cf_conn *)(xprt->xp_p1); + + if (cd->mreq != NULL) + return (XPRT_MOREREQS); + + return (XPRT_IDLE); +} + static bool_t svc_vc_recv(SVCXPRT *xprt, struct rpc_msg *msg, struct sockaddr **addrp, struct mbuf **mp) @@ -682,6 +749,44 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_ms } static bool_t +svc_vc_backchannel_recv(SVCXPRT *xprt, struct rpc_msg *msg, + struct sockaddr **addrp, struct mbuf **mp) +{ + struct cf_conn *cd = (struct cf_conn *) xprt->xp_p1; + struct ct_data *ct; + struct mbuf *m; + XDR xdrs; + + sx_xlock(&xprt->xp_lock); + ct = (struct ct_data *)xprt->xp_p2; + if (ct == NULL) { + sx_xunlock(&xprt->xp_lock); + return (FALSE); + } + mtx_lock(&ct->ct_lock); + m = cd->mreq; + if (m == NULL) { + xprt_inactive(xprt); + mtx_unlock(&ct->ct_lock); + sx_xunlock(&xprt->xp_lock); + return (FALSE); + } + cd->mreq = m->m_nextpkt; + mtx_unlock(&ct->ct_lock); + sx_xunlock(&xprt->xp_lock); + + xdrmbuf_create(&xdrs, m, XDR_DECODE); + if (! xdr_callmsg(&xdrs, msg)) { + XDR_DESTROY(&xdrs); + return (FALSE); + } + *addrp = NULL; + *mp = xdrmbuf_getall(&xdrs); + XDR_DESTROY(&xdrs); + return (TRUE); +} + +static bool_t svc_vc_reply(SVCXPRT *xprt, struct rpc_msg *msg, struct sockaddr *addr, struct mbuf *m) { @@ -735,6 +840,65 @@ svc_vc_reply(SVCXPRT *xprt, struct rpc_m } static bool_t +svc_vc_backchannel_reply(SVCXPRT *xprt, struct rpc_msg *msg, + struct sockaddr *addr, struct mbuf *m) +{ + struct ct_data *ct; + XDR xdrs; + struct mbuf *mrep; + bool_t stat = TRUE; + int error; + + /* + * Leave space for record mark. + */ + MGETHDR(mrep, M_WAITOK, MT_DATA); + mrep->m_len = 0; + mrep->m_data += sizeof(uint32_t); + + xdrmbuf_create(&xdrs, mrep, XDR_ENCODE); + + if (msg->rm_reply.rp_stat == MSG_ACCEPTED && + msg->rm_reply.rp_acpt.ar_stat == SUCCESS) { + if (!xdr_replymsg(&xdrs, msg)) + stat = FALSE; + else + xdrmbuf_append(&xdrs, m); + } else { + stat = xdr_replymsg(&xdrs, msg); + } + + if (stat) { + m_fixhdr(mrep); + + /* + * Prepend a record marker containing the reply length. + */ + M_PREPEND(mrep, sizeof(uint32_t), M_WAITOK); + *mtod(mrep, uint32_t *) = + htonl(0x80000000 | (mrep->m_pkthdr.len + - sizeof(uint32_t))); + sx_xlock(&xprt->xp_lock); + ct = (struct ct_data *)xprt->xp_p2; + if (ct != NULL) + error = sosend(ct->ct_socket, NULL, NULL, mrep, NULL, + 0, curthread); + else + error = EPIPE; + sx_xunlock(&xprt->xp_lock); + if (!error) { + stat = TRUE; + } + } else { + m_freem(mrep); + } + + XDR_DESTROY(&xdrs); + + return (stat); +} + +static bool_t svc_vc_null() { From owner-svn-src-stable-9@FreeBSD.ORG Thu Jan 23 00:40:29 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 40C15790; Thu, 23 Jan 2014 00:40:29 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id E66111657; Thu, 23 Jan 2014 00:40:28 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0N0eSms049114; Thu, 23 Jan 2014 00:40:28 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0N0eSWB049113; Thu, 23 Jan 2014 00:40:28 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401230040.s0N0eSWB049113@svn.freebsd.org> From: Alexander Motin Date: Thu, 23 Jan 2014 00:40:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261059 - stable/9/sys/rpc X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jan 2014 00:40:29 -0000 Author: mav Date: Thu Jan 23 00:40:28 2014 New Revision: 261059 URL: http://svnweb.freebsd.org/changeset/base/261059 Log: MFC r259632: Rework flow control for connection-oriented (TCP) RPC server. When processing receive buffer, write the amount of data, expected in present request record, into socket's so_rcv.sb_lowat to make stack aware about our needs. When processing following upcalls, ignore them until socket collect enough data to be read and processed in one turn. This change reduces number of context switches and other operations in RPC stack during large NFS writes (especially via non-Jumbo networks) by order of magnitude. After precessing current packet, take another look into the pending buffer to find out whether the next packet had been already received. If not, deactivate this port right there without making RPC code to push this port to another thread just to find that there is nothing. If the next packet is received partially, also deactivate the port, but also update socket's so_rcv.sb_lowat to not be woken up prematurely. This change additionally reduces number of context switches per NFS request about in half. Modified: stable/9/sys/rpc/svc_vc.c Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/sys/rpc/svc_vc.c ============================================================================== --- stable/9/sys/rpc/svc_vc.c Thu Jan 23 00:35:41 2014 (r261058) +++ stable/9/sys/rpc/svc_vc.c Thu Jan 23 00:40:28 2014 (r261059) @@ -381,15 +381,11 @@ svc_vc_rendezvous_recv(SVCXPRT *xprt, st * We must re-test for new connections after taking * the lock to protect us in the case where a new * connection arrives after our call to accept fails - * with EWOULDBLOCK. The pool lock protects us from - * racing the upcall after our TAILQ_EMPTY() call - * returns false. + * with EWOULDBLOCK. */ ACCEPT_LOCK(); - mtx_lock(&xprt->xp_pool->sp_lock); if (TAILQ_EMPTY(&xprt->xp_socket->so_comp)) - xprt_inactive_locked(xprt); - mtx_unlock(&xprt->xp_pool->sp_lock); + xprt_inactive(xprt); ACCEPT_UNLOCK(); sx_xunlock(&xprt->xp_lock); return (FALSE); @@ -526,35 +522,14 @@ static enum xprt_stat svc_vc_stat(SVCXPRT *xprt) { struct cf_conn *cd; - struct mbuf *m; - size_t n; cd = (struct cf_conn *)(xprt->xp_p1); if (cd->strm_stat == XPRT_DIED) return (XPRT_DIED); - /* - * Return XPRT_MOREREQS if we have buffered data and we are - * mid-record or if we have enough data for a record - * marker. Since this is only a hint, we read mpending and - * resid outside the lock. We do need to take the lock if we - * have to traverse the mbuf chain. - */ - if (cd->mpending) { - if (cd->resid) - return (XPRT_MOREREQS); - n = 0; - sx_xlock(&xprt->xp_lock); - m = cd->mpending; - while (m && n < sizeof(uint32_t)) { - n += m->m_len; - m = m->m_next; - } - sx_xunlock(&xprt->xp_lock); - if (n >= sizeof(uint32_t)) - return (XPRT_MOREREQS); - } + if (cd->mreq != NULL && cd->resid == 0 && cd->eor) + return (XPRT_MOREREQS); if (soreadable(xprt->xp_socket)) return (XPRT_MOREREQS); @@ -575,6 +550,78 @@ svc_vc_backchannel_stat(SVCXPRT *xprt) return (XPRT_IDLE); } +/* + * If we have an mbuf chain in cd->mpending, try to parse a record from it, + * leaving the result in cd->mreq. If we don't have a complete record, leave + * the partial result in cd->mreq and try to read more from the socket. + */ +static void +svc_vc_process_pending(SVCXPRT *xprt) +{ + struct cf_conn *cd = (struct cf_conn *) xprt->xp_p1; + struct socket *so = xprt->xp_socket; + struct mbuf *m; + + /* + * If cd->resid is non-zero, we have part of the + * record already, otherwise we are expecting a record + * marker. + */ + if (!cd->resid && cd->mpending) { + /* + * See if there is enough data buffered to + * make up a record marker. Make sure we can + * handle the case where the record marker is + * split across more than one mbuf. + */ + size_t n = 0; + uint32_t header; + + m = cd->mpending; + while (n < sizeof(uint32_t) && m) { + n += m->m_len; + m = m->m_next; + } + if (n < sizeof(uint32_t)) { + so->so_rcv.sb_lowat = sizeof(uint32_t) - n; + return; + } + m_copydata(cd->mpending, 0, sizeof(header), + (char *)&header); + header = ntohl(header); + cd->eor = (header & 0x80000000) != 0; + cd->resid = header & 0x7fffffff; + m_adj(cd->mpending, sizeof(uint32_t)); + } + + /* + * Start pulling off mbufs from cd->mpending + * until we either have a complete record or + * we run out of data. We use m_split to pull + * data - it will pull as much as possible and + * split the last mbuf if necessary. + */ + while (cd->mpending && cd->resid) { + m = cd->mpending; + if (cd->mpending->m_next + || cd->mpending->m_len > cd->resid) + cd->mpending = m_split(cd->mpending, + cd->resid, M_WAITOK); + else + cd->mpending = NULL; + if (cd->mreq) + m_last(cd->mreq)->m_next = m; + else + cd->mreq = m; + while (m) { + cd->resid -= m->m_len; + m = m->m_next; + } + } + + so->so_rcv.sb_lowat = imax(1, imin(cd->resid, so->so_rcv.sb_hiwat / 2)); +} + static bool_t svc_vc_recv(SVCXPRT *xprt, struct rpc_msg *msg, struct sockaddr **addrp, struct mbuf **mp) @@ -582,6 +629,7 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_ms struct cf_conn *cd = (struct cf_conn *) xprt->xp_p1; struct uio uio; struct mbuf *m; + struct socket* so = xprt->xp_socket; XDR xdrs; int error, rcvflag; @@ -592,99 +640,40 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_ms sx_xlock(&xprt->xp_lock); for (;;) { - /* - * If we have an mbuf chain in cd->mpending, try to parse a - * record from it, leaving the result in cd->mreq. If we don't - * have a complete record, leave the partial result in - * cd->mreq and try to read more from the socket. - */ - if (cd->mpending) { - /* - * If cd->resid is non-zero, we have part of the - * record already, otherwise we are expecting a record - * marker. - */ - if (!cd->resid) { - /* - * See if there is enough data buffered to - * make up a record marker. Make sure we can - * handle the case where the record marker is - * split across more than one mbuf. - */ - size_t n = 0; - uint32_t header; - - m = cd->mpending; - while (n < sizeof(uint32_t) && m) { - n += m->m_len; - m = m->m_next; - } - if (n < sizeof(uint32_t)) - goto readmore; - m_copydata(cd->mpending, 0, sizeof(header), - (char *)&header); - header = ntohl(header); - cd->eor = (header & 0x80000000) != 0; - cd->resid = header & 0x7fffffff; - m_adj(cd->mpending, sizeof(uint32_t)); - } - - /* - * Start pulling off mbufs from cd->mpending - * until we either have a complete record or - * we run out of data. We use m_split to pull - * data - it will pull as much as possible and - * split the last mbuf if necessary. - */ - while (cd->mpending && cd->resid) { - m = cd->mpending; - if (cd->mpending->m_next - || cd->mpending->m_len > cd->resid) - cd->mpending = m_split(cd->mpending, - cd->resid, M_WAIT); - else - cd->mpending = NULL; - if (cd->mreq) - m_last(cd->mreq)->m_next = m; - else - cd->mreq = m; - while (m) { - cd->resid -= m->m_len; - m = m->m_next; - } + /* If we have no request ready, check pending queue. */ + while (cd->mpending && + (cd->mreq == NULL || cd->resid != 0 || !cd->eor)) + svc_vc_process_pending(xprt); + + /* Process and return complete request in cd->mreq. */ + if (cd->mreq != NULL && cd->resid == 0 && cd->eor) { + + xdrmbuf_create(&xdrs, cd->mreq, XDR_DECODE); + cd->mreq = NULL; + + /* Check for next request in a pending queue. */ + svc_vc_process_pending(xprt); + if (cd->mreq == NULL || cd->resid != 0) { + SOCKBUF_LOCK(&so->so_rcv); + if (!soreadable(so)) + xprt_inactive(xprt); + SOCKBUF_UNLOCK(&so->so_rcv); } - /* - * If cd->resid is zero now, we have managed to - * receive a record fragment from the stream. Check - * for the end-of-record mark to see if we need more. - */ - if (cd->resid == 0) { - if (!cd->eor) - continue; - - /* - * Success - we have a complete record in - * cd->mreq. - */ - xdrmbuf_create(&xdrs, cd->mreq, XDR_DECODE); - cd->mreq = NULL; - sx_xunlock(&xprt->xp_lock); - - if (! xdr_callmsg(&xdrs, msg)) { - XDR_DESTROY(&xdrs); - return (FALSE); - } + sx_xunlock(&xprt->xp_lock); - *addrp = NULL; - *mp = xdrmbuf_getall(&xdrs); + if (! xdr_callmsg(&xdrs, msg)) { XDR_DESTROY(&xdrs); - - return (TRUE); + return (FALSE); } + + *addrp = NULL; + *mp = xdrmbuf_getall(&xdrs); + XDR_DESTROY(&xdrs); + + return (TRUE); } - readmore: /* * The socket upcall calls xprt_active() which will eventually * cause the server to call us here. We attempt to @@ -697,8 +686,7 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_ms uio.uio_td = curthread; m = NULL; rcvflag = MSG_DONTWAIT; - error = soreceive(xprt->xp_socket, NULL, &uio, &m, NULL, - &rcvflag); + error = soreceive(so, NULL, &uio, &m, NULL, &rcvflag); if (error == EWOULDBLOCK) { /* @@ -706,25 +694,23 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_ms * taking the lock to protect us in the case * where a new packet arrives on the socket * after our call to soreceive fails with - * EWOULDBLOCK. The pool lock protects us from - * racing the upcall after our soreadable() - * call returns false. + * EWOULDBLOCK. */ - mtx_lock(&xprt->xp_pool->sp_lock); - if (!soreadable(xprt->xp_socket)) - xprt_inactive_locked(xprt); - mtx_unlock(&xprt->xp_pool->sp_lock); + SOCKBUF_LOCK(&so->so_rcv); + if (!soreadable(so)) + xprt_inactive(xprt); + SOCKBUF_UNLOCK(&so->so_rcv); sx_xunlock(&xprt->xp_lock); return (FALSE); } if (error) { - SOCKBUF_LOCK(&xprt->xp_socket->so_rcv); + SOCKBUF_LOCK(&so->so_rcv); if (xprt->xp_upcallset) { xprt->xp_upcallset = 0; - soupcall_clear(xprt->xp_socket, SO_RCV); + soupcall_clear(so, SO_RCV); } - SOCKBUF_UNLOCK(&xprt->xp_socket->so_rcv); + SOCKBUF_UNLOCK(&so->so_rcv); xprt_inactive(xprt); cd->strm_stat = XPRT_DIED; sx_xunlock(&xprt->xp_lock); @@ -910,7 +896,8 @@ svc_vc_soupcall(struct socket *so, void { SVCXPRT *xprt = (SVCXPRT *) arg; - xprt_active(xprt); + if (soreadable(xprt->xp_socket)) + xprt_active(xprt); return (SU_OK); } From owner-svn-src-stable-9@FreeBSD.ORG Thu Jan 23 00:41:24 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B57DBA91; Thu, 23 Jan 2014 00:41:24 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 96E1B16BB; Thu, 23 Jan 2014 00:41:24 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0N0fOLE050323; Thu, 23 Jan 2014 00:41:24 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0N0fOH1050320; Thu, 23 Jan 2014 00:41:24 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401230041.s0N0fOH1050320@svn.freebsd.org> From: Alexander Motin Date: Thu, 23 Jan 2014 00:41:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261060 - in stable/9/sys: nfs rpc X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jan 2014 00:41:24 -0000 Author: mav Date: Thu Jan 23 00:41:23 2014 New Revision: 261060 URL: http://svnweb.freebsd.org/changeset/base/261060 Log: MFC r259659, r259662: Remove several linear list traversals per request from RPC server code. Do not insert active ports into pool->sp_active list if they are success- fully assigned to some thread. This makes that list include only ports that really require attention, and so traversal can be reduced to simple taking the first one. Remove idle thread from pool->sp_idlethreads list when assigning some work (port of requests) to it. That again makes possible to replace list traversals with simple taking the first element. Modified: stable/9/sys/nfs/nfs_fha.c stable/9/sys/rpc/svc.c stable/9/sys/rpc/svc.h Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/sys/nfs/nfs_fha.c ============================================================================== --- stable/9/sys/nfs/nfs_fha.c Thu Jan 23 00:40:28 2014 (r261059) +++ stable/9/sys/nfs/nfs_fha.c Thu Jan 23 00:41:23 2014 (r261060) @@ -289,19 +289,6 @@ fha_hash_entry_add_op(struct fha_hash_en fhe->num_rw += count; } -static SVCTHREAD * -get_idle_thread(SVCPOOL *pool) -{ - SVCTHREAD *st; - - LIST_FOREACH(st, &pool->sp_idlethreads, st_ilink) { - if (st->st_xprt == NULL && STAILQ_EMPTY(&st->st_reqs)) - return (st); - } - return (NULL); -} - - /* * Get the service thread currently associated with the fhe that is * appropriate to handle this operation. @@ -386,7 +373,7 @@ fha_hash_entry_choose_thread(struct fha_ ITRACE_CURPROC(ITRACE_NFS, ITRACE_INFO, "fha: %p(%d)t", thread, thread->st_reqcount); #endif - } else if ((thread = get_idle_thread(pool))) { + } else if ((thread = LIST_FIRST(&pool->sp_idlethreads))) { #if 0 ITRACE_CURPROC(ITRACE_NFS, ITRACE_INFO, "fha: %p(%d)i", thread, thread->st_reqcount); @@ -418,7 +405,6 @@ SVCTHREAD * fha_assign(SVCTHREAD *this_thread, struct svc_req *req, struct fha_params *softc) { - SVCPOOL *pool; SVCTHREAD *thread; struct fha_info i; struct fha_hash_entry *fhe; @@ -439,7 +425,6 @@ fha_assign(SVCTHREAD *this_thread, struc if (req->rq_vers != 2 && req->rq_vers != 3) return (this_thread); - pool = req->rq_xprt->xp_pool; fha_extract_info(req, &i, cb); /* Modified: stable/9/sys/rpc/svc.c ============================================================================== --- stable/9/sys/rpc/svc.c Thu Jan 23 00:40:28 2014 (r261059) +++ stable/9/sys/rpc/svc.c Thu Jan 23 00:41:23 2014 (r261060) @@ -293,12 +293,10 @@ xprt_unregister_locked(SVCXPRT *xprt) { SVCPOOL *pool = xprt->xp_pool; + mtx_assert(&pool->sp_lock, MA_OWNED); KASSERT(xprt->xp_registered == TRUE, ("xprt_unregister_locked: not registered")); - if (xprt->xp_active) { - TAILQ_REMOVE(&pool->sp_active, xprt, xp_alink); - xprt->xp_active = FALSE; - } + xprt_inactive_locked(xprt); TAILQ_REMOVE(&pool->sp_xlist, xprt, xp_link); xprt->xp_registered = FALSE; } @@ -320,25 +318,25 @@ xprt_unregister(SVCXPRT *xprt) SVC_RELEASE(xprt); } -static void +/* + * Attempt to assign a service thread to this transport. + */ +static int xprt_assignthread(SVCXPRT *xprt) { SVCPOOL *pool = xprt->xp_pool; SVCTHREAD *st; - /* - * Attempt to assign a service thread to this - * transport. - */ - LIST_FOREACH(st, &pool->sp_idlethreads, st_ilink) { - if (st->st_xprt == NULL && STAILQ_EMPTY(&st->st_reqs)) - break; - } + mtx_assert(&pool->sp_lock, MA_OWNED); + st = LIST_FIRST(&pool->sp_idlethreads); if (st) { + LIST_REMOVE(st, st_ilink); + st->st_idle = FALSE; SVC_ACQUIRE(xprt); xprt->xp_thread = st; st->st_xprt = xprt; cv_signal(&st->st_cond); + return (TRUE); } else { /* * See if we can create a new thread. The @@ -354,6 +352,7 @@ xprt_assignthread(SVCXPRT *xprt) pool->sp_state = SVCPOOL_THREADWANTED; } } + return (FALSE); } void @@ -372,9 +371,12 @@ xprt_active(SVCXPRT *xprt) } if (!xprt->xp_active) { - TAILQ_INSERT_TAIL(&pool->sp_active, xprt, xp_alink); xprt->xp_active = TRUE; - xprt_assignthread(xprt); + if (xprt->xp_thread == NULL) { + if (!xprt_assignthread(xprt)) + TAILQ_INSERT_TAIL(&pool->sp_active, xprt, + xp_alink); + } } mtx_unlock(&pool->sp_lock); @@ -385,8 +387,10 @@ xprt_inactive_locked(SVCXPRT *xprt) { SVCPOOL *pool = xprt->xp_pool; + mtx_assert(&pool->sp_lock, MA_OWNED); if (xprt->xp_active) { - TAILQ_REMOVE(&pool->sp_active, xprt, xp_alink); + if (xprt->xp_thread == NULL) + TAILQ_REMOVE(&pool->sp_active, xprt, xp_alink); xprt->xp_active = FALSE; } } @@ -950,10 +954,11 @@ svc_assign_waiting_sockets(SVCPOOL *pool { SVCXPRT *xprt; - TAILQ_FOREACH(xprt, &pool->sp_active, xp_alink) { - if (!xprt->xp_thread) { - xprt_assignthread(xprt); - } + while ((xprt = TAILQ_FIRST(&pool->sp_active)) != NULL) { + if (xprt_assignthread(xprt)) + TAILQ_REMOVE(&pool->sp_active, xprt, xp_alink); + else + break; } } @@ -1044,21 +1049,17 @@ svc_run_internal(SVCPOOL *pool, bool_t i * active transport which isn't being serviced * by a thread. */ - if (svc_request_space_available(pool)) { - TAILQ_FOREACH(xprt, &pool->sp_active, - xp_alink) { - if (!xprt->xp_thread) { - SVC_ACQUIRE(xprt); - xprt->xp_thread = st; - st->st_xprt = xprt; - break; - } - } - } - if (st->st_xprt) + if (svc_request_space_available(pool) && + (xprt = TAILQ_FIRST(&pool->sp_active)) != NULL) { + TAILQ_REMOVE(&pool->sp_active, xprt, xp_alink); + SVC_ACQUIRE(xprt); + xprt->xp_thread = st; + st->st_xprt = xprt; continue; + } LIST_INSERT_HEAD(&pool->sp_idlethreads, st, st_ilink); + st->st_idle = TRUE; if (ismaster || (!ismaster && pool->sp_threadcount > pool->sp_minthreads)) error = cv_timedwait_sig(&st->st_cond, @@ -1066,7 +1067,10 @@ svc_run_internal(SVCPOOL *pool, bool_t i else error = cv_wait_sig(&st->st_cond, &pool->sp_lock); - LIST_REMOVE(st, st_ilink); + if (st->st_idle) { + LIST_REMOVE(st, st_ilink); + st->st_idle = FALSE; + } /* * Reduce worker thread count when idle. @@ -1134,11 +1138,12 @@ svc_run_internal(SVCPOOL *pool, bool_t i * execute the request * immediately. */ - if (stpref != st) { - cv_signal(&stpref->st_cond); - continue; - } else { + if (stpref == st) break; + if (stpref->st_idle) { + LIST_REMOVE(stpref, st_ilink); + stpref->st_idle = FALSE; + cv_signal(&stpref->st_cond); } } } while (stat == XPRT_MOREREQS @@ -1155,10 +1160,9 @@ svc_run_internal(SVCPOOL *pool, bool_t i xprt->xp_thread = NULL; st->st_xprt = NULL; if (xprt->xp_active) { - xprt_assignthread(xprt); - TAILQ_REMOVE(&pool->sp_active, xprt, xp_alink); - TAILQ_INSERT_TAIL(&pool->sp_active, xprt, - xp_alink); + if (!xprt_assignthread(xprt)) + TAILQ_INSERT_TAIL(&pool->sp_active, + xprt, xp_alink); } mtx_unlock(&pool->sp_lock); SVC_RELEASE(xprt); Modified: stable/9/sys/rpc/svc.h ============================================================================== --- stable/9/sys/rpc/svc.h Thu Jan 23 00:40:28 2014 (r261059) +++ stable/9/sys/rpc/svc.h Thu Jan 23 00:41:23 2014 (r261060) @@ -278,6 +278,7 @@ typedef struct __rpc_svcthread { SVCXPRT *st_xprt; /* transport we are processing */ struct svc_reqlist st_reqs; /* RPC requests to execute */ int st_reqcount; /* number of queued reqs */ + int st_idle; /* thread is on idle list */ struct cv st_cond; /* sleeping for work */ LIST_ENTRY(__rpc_svcthread) st_link; /* all threads list */ LIST_ENTRY(__rpc_svcthread) st_ilink; /* idle threads list */ From owner-svn-src-stable-9@FreeBSD.ORG Thu Jan 23 00:42:09 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B935CBC3; Thu, 23 Jan 2014 00:42:09 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 9929016BF; Thu, 23 Jan 2014 00:42:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0N0g9qu050469; Thu, 23 Jan 2014 00:42:09 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0N0g8CY050465; Thu, 23 Jan 2014 00:42:08 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401230042.s0N0g8CY050465@svn.freebsd.org> From: Alexander Motin Date: Thu, 23 Jan 2014 00:42:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261061 - in stable/9/sys: fs/nfsserver nfs nfsserver X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jan 2014 00:42:09 -0000 Author: mav Date: Thu Jan 23 00:42:08 2014 New Revision: 261061 URL: http://svnweb.freebsd.org/changeset/base/261061 Log: MFC r259765: Fix RPC server threads file handle affinity to work better with ZFS. Instead of taking 8 specific bytes of file handle to identify file during RPC thread affitinity handling, use trivial hash of the full file handle. ZFS's struct zfid_short does not have padding field after the length field, as result, originally picked 8 bytes are loosing lower 16 bits of object ID, causing many false matches and unneeded requests affinity to same thread. This fix substantially improves NFS server latency and scalability in SPEC NFS benchmark by more flexible use of multiple NFS threads. Modified: stable/9/sys/fs/nfsserver/nfs_fha_new.c stable/9/sys/nfs/nfs_fha.c stable/9/sys/nfs/nfs_fha.h stable/9/sys/nfsserver/nfs_fha_old.c Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) stable/9/sys/fs/ (props changed) Modified: stable/9/sys/fs/nfsserver/nfs_fha_new.c ============================================================================== --- stable/9/sys/fs/nfsserver/nfs_fha_new.c Thu Jan 23 00:41:23 2014 (r261060) +++ stable/9/sys/fs/nfsserver/nfs_fha_new.c Thu Jan 23 00:42:08 2014 (r261061) @@ -41,7 +41,7 @@ static void fhanew_init(void *foo); static void fhanew_uninit(void *foo); rpcproc_t fhanew_get_procnum(rpcproc_t procnum); int fhanew_realign(struct mbuf **mb, int malloc_flags); -int fhanew_get_fh(fhandle_t *fh, int v3, struct mbuf **md, caddr_t *dpos); +int fhanew_get_fh(uint64_t *fh, int v3, struct mbuf **md, caddr_t *dpos); int fhanew_is_read(rpcproc_t procnum); int fhanew_is_write(rpcproc_t procnum); int fhanew_get_offset(struct mbuf **md, caddr_t *dpos, int v3, @@ -128,11 +128,13 @@ fhanew_realign(struct mbuf **mb, int mal } int -fhanew_get_fh(fhandle_t *fh, int v3, struct mbuf **md, caddr_t *dpos) +fhanew_get_fh(uint64_t *fh, int v3, struct mbuf **md, caddr_t *dpos) { struct nfsrv_descript lnd, *nd; uint32_t *tl; - int error, len; + uint8_t *buf; + uint64_t t; + int error, len, i; error = 0; len = 0; @@ -151,11 +153,13 @@ fhanew_get_fh(fhandle_t *fh, int v3, str len = NFSX_V2FH; } + t = 0; if (len != 0) { - NFSM_DISSECT_NONBLOCK(tl, uint32_t *, len); - bcopy(tl, fh, len); - } else - bzero(fh, sizeof(*fh)); + NFSM_DISSECT_NONBLOCK(buf, uint8_t *, len); + for (i = 0; i < len; i++) + t ^= ((uint64_t)buf[i] << (i & 7) * 8); + } + *fh = t; nfsmout: *md = nd->nd_md; Modified: stable/9/sys/nfs/nfs_fha.c ============================================================================== --- stable/9/sys/nfs/nfs_fha.c Thu Jan 23 00:41:23 2014 (r261060) +++ stable/9/sys/nfs/nfs_fha.c Thu Jan 23 00:42:08 2014 (r261061) @@ -130,7 +130,6 @@ fha_extract_info(struct svc_req *req, st struct fha_callbacks *cb) { struct mbuf *md; - fhandle_t fh; caddr_t dpos; static u_int64_t random_fh = 0; int error; @@ -177,12 +176,10 @@ fha_extract_info(struct svc_req *req, st dpos = mtod(md, caddr_t); /* Grab the filehandle. */ - error = cb->get_fh(&fh, v3, &md, &dpos); + error = cb->get_fh(&i->fh, v3, &md, &dpos); if (error) goto out; - bcopy(fh.fh_fid.fid_data, &i->fh, sizeof(i->fh)); - /* Content ourselves with zero offset for all but reads. */ if (cb->is_read(procnum) || cb->is_write(procnum)) cb->get_offset(&md, &dpos, v3, i); Modified: stable/9/sys/nfs/nfs_fha.h ============================================================================== --- stable/9/sys/nfs/nfs_fha.h Thu Jan 23 00:41:23 2014 (r261060) +++ stable/9/sys/nfs/nfs_fha.h Thu Jan 23 00:42:08 2014 (r261061) @@ -82,7 +82,7 @@ struct fha_info { struct fha_callbacks { rpcproc_t (*get_procnum)(rpcproc_t procnum); int (*realign)(struct mbuf **mb, int malloc_flags); - int (*get_fh)(fhandle_t *fh, int v3, struct mbuf **md, caddr_t *dpos); + int (*get_fh)(uint64_t *fh, int v3, struct mbuf **md, caddr_t *dpos); int (*is_read)(rpcproc_t procnum); int (*is_write)(rpcproc_t procnum); int (*get_offset)(struct mbuf **md, caddr_t *dpos, int v3, struct Modified: stable/9/sys/nfsserver/nfs_fha_old.c ============================================================================== --- stable/9/sys/nfsserver/nfs_fha_old.c Thu Jan 23 00:41:23 2014 (r261060) +++ stable/9/sys/nfsserver/nfs_fha_old.c Thu Jan 23 00:42:08 2014 (r261061) @@ -49,7 +49,7 @@ static void fhaold_init(void *foo); static void fhaold_uninit(void *foo); rpcproc_t fhaold_get_procnum(rpcproc_t procnum); int fhaold_realign(struct mbuf **mb, int malloc_flags); -int fhaold_get_fh(fhandle_t *fh, int v3, struct mbuf **md, caddr_t *dpos); +int fhaold_get_fh(uint64_t *fh, int v3, struct mbuf **md, caddr_t *dpos); int fhaold_is_read(rpcproc_t procnum); int fhaold_is_write(rpcproc_t procnum); int fhaold_get_offset(struct mbuf **md, caddr_t *dpos, int v3, @@ -135,9 +135,33 @@ fhaold_realign(struct mbuf **mb, int mal } int -fhaold_get_fh(fhandle_t *fh, int v3, struct mbuf **md, caddr_t *dpos) +fhaold_get_fh(uint64_t *fh, int v3, struct mbuf **md, caddr_t *dpos) { - return (nfsm_srvmtofh_xx(fh, v3, md, dpos)); + u_int32_t *tl; + uint8_t *buf; + uint64_t t; + int fhlen, i; + + if (v3) { + tl = nfsm_dissect_xx_nonblock(NFSX_UNSIGNED, md, dpos); + if (tl == NULL) + return EBADRPC; + fhlen = fxdr_unsigned(int, *tl); + if (fhlen != 0 && fhlen != NFSX_V3FH) + return EBADRPC; + } else { + fhlen = NFSX_V2FH; + } + t = 0; + if (fhlen != 0) { + buf = nfsm_dissect_xx_nonblock(fhlen, md, dpos); + if (buf == NULL) + return EBADRPC; + for (i = 0; i < fhlen; i++) + t ^= ((uint64_t)buf[i] << (i & 7) * 8); + } + *fh = t; + return 0; } int From owner-svn-src-stable-9@FreeBSD.ORG Thu Jan 23 00:42:56 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6B9D5D0F; Thu, 23 Jan 2014 00:42:56 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 56F0F16C9; Thu, 23 Jan 2014 00:42:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0N0guRO050591; Thu, 23 Jan 2014 00:42:56 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0N0guta050590; Thu, 23 Jan 2014 00:42:56 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401230042.s0N0guta050590@svn.freebsd.org> From: Alexander Motin Date: Thu, 23 Jan 2014 00:42:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261062 - stable/9/sys/rpc X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jan 2014 00:42:56 -0000 Author: mav Date: Thu Jan 23 00:42:55 2014 New Revision: 261062 URL: http://svnweb.freebsd.org/changeset/base/261062 Log: MFC r259828: Fix a bug introduced at r259632, triggering infinite loop in some cases. Modified: stable/9/sys/rpc/svc_vc.c Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/sys/rpc/svc_vc.c ============================================================================== --- stable/9/sys/rpc/svc_vc.c Thu Jan 23 00:42:08 2014 (r261061) +++ stable/9/sys/rpc/svc_vc.c Thu Jan 23 00:42:55 2014 (r261062) @@ -555,7 +555,7 @@ svc_vc_backchannel_stat(SVCXPRT *xprt) * leaving the result in cd->mreq. If we don't have a complete record, leave * the partial result in cd->mreq and try to read more from the socket. */ -static void +static int svc_vc_process_pending(SVCXPRT *xprt) { struct cf_conn *cd = (struct cf_conn *) xprt->xp_p1; @@ -584,7 +584,7 @@ svc_vc_process_pending(SVCXPRT *xprt) } if (n < sizeof(uint32_t)) { so->so_rcv.sb_lowat = sizeof(uint32_t) - n; - return; + return (FALSE); } m_copydata(cd->mpending, 0, sizeof(header), (char *)&header); @@ -620,6 +620,7 @@ svc_vc_process_pending(SVCXPRT *xprt) } so->so_rcv.sb_lowat = imax(1, imin(cd->resid, so->so_rcv.sb_hiwat / 2)); + return (TRUE); } static bool_t @@ -642,8 +643,10 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_ms for (;;) { /* If we have no request ready, check pending queue. */ while (cd->mpending && - (cd->mreq == NULL || cd->resid != 0 || !cd->eor)) - svc_vc_process_pending(xprt); + (cd->mreq == NULL || cd->resid != 0 || !cd->eor)) { + if (!svc_vc_process_pending(xprt)) + break; + } /* Process and return complete request in cd->mreq. */ if (cd->mreq != NULL && cd->resid == 0 && cd->eor) { From owner-svn-src-stable-9@FreeBSD.ORG Thu Jan 23 00:43:33 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A6BF1E58; Thu, 23 Jan 2014 00:43:33 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 8721116D4; Thu, 23 Jan 2014 00:43:33 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0N0hXMm050790; Thu, 23 Jan 2014 00:43:33 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0N0hXn0050789; Thu, 23 Jan 2014 00:43:33 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401230043.s0N0hXn0050789@svn.freebsd.org> From: Alexander Motin Date: Thu, 23 Jan 2014 00:43:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261063 - stable/9/sys/fs/nfsserver X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jan 2014 00:43:33 -0000 Author: mav Date: Thu Jan 23 00:43:33 2014 New Revision: 261063 URL: http://svnweb.freebsd.org/changeset/base/261063 Log: MFC r259877: Slightly simplify expiration logic introduced in r254337. - Do not update the histogram for items we are any way deleting from cache. - Do not update the histogram if nfsrc_tcphighwater is not set. - Remove some extra math operations. Modified: stable/9/sys/fs/nfsserver/nfs_nfsdcache.c Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) stable/9/sys/fs/ (props changed) Modified: stable/9/sys/fs/nfsserver/nfs_nfsdcache.c ============================================================================== --- stable/9/sys/fs/nfsserver/nfs_nfsdcache.c Thu Jan 23 00:42:55 2014 (r261062) +++ stable/9/sys/fs/nfsserver/nfs_nfsdcache.c Thu Jan 23 00:43:33 2014 (r261063) @@ -832,6 +832,7 @@ nfsrvd_cleancache(void) nfsrc_tcpsavedreplies = 0; } +#define HISTSIZE 16 /* * The basic rule is to get rid of entries that are expired. */ @@ -839,7 +840,7 @@ static void nfsrc_trimcache(u_int64_t sockref, struct socket *so) { struct nfsrvcache *rp, *nextrp; - int i, j, k, time_histo[10]; + int i, j, k, tto, time_histo[HISTSIZE]; time_t thisstamp; static time_t udp_lasttrim = 0, tcp_lasttrim = 0; static int onethread = 0; @@ -863,8 +864,9 @@ nfsrc_trimcache(u_int64_t sockref, struc } if (NFSD_MONOSEC != tcp_lasttrim || nfsrc_tcpsavedreplies >= nfsrc_tcphighwater) { - for (i = 0; i < 10; i++) + for (i = 0; i < HISTSIZE; i++) time_histo[i] = 0; + tto = nfsrc_tcptimeout; for (i = 0; i < NFSRVCACHE_HASHSIZE; i++) { mtx_lock(&nfsrchash_table[i].mtx); if (i == 0) @@ -874,6 +876,15 @@ nfsrc_trimcache(u_int64_t sockref, struc if (!(rp->rc_flag & (RC_INPROG|RC_LOCKED|RC_WANTED)) && rp->rc_refcnt == 0) { + if ((rp->rc_flag & RC_REFCNT) || + tcp_lasttrim > rp->rc_timestamp || + nfsrc_activesocket(rp, sockref, so)) { + nfsrc_freecache(rp); + continue; + } + + if (nfsrc_tcphighwater == 0) + continue; /* * The timestamps range from roughly the * present (tcp_lasttrim) to the present @@ -881,16 +892,13 @@ nfsrc_trimcache(u_int64_t sockref, struc * histogram of where the timeouts fall. */ j = rp->rc_timestamp - tcp_lasttrim; - if (j >= nfsrc_tcptimeout) - j = nfsrc_tcptimeout - 1; - if (j < 0) + if (j >= tto) + j = HISTSIZE - 1; + else if (j < 0) j = 0; - j = (j * 10 / nfsrc_tcptimeout) % 10; + else + j = j * HISTSIZE / tto; time_histo[j]++; - if ((rp->rc_flag & RC_REFCNT) || - tcp_lasttrim > rp->rc_timestamp || - nfsrc_activesocket(rp, sockref, so)) - nfsrc_freecache(rp); } } mtx_unlock(&nfsrchash_table[i].mtx); @@ -903,12 +911,12 @@ nfsrc_trimcache(u_int64_t sockref, struc * 80% of the nfsrc_tcphighwater. */ k = 0; - for (i = 0; i < 8; i++) { + for (i = 0; i < (HISTSIZE - 2); i++) { k += time_histo[i]; if (k > j) break; } - k = nfsrc_tcptimeout * (i + 1) / 10; + k = tto * (i + 1) / HISTSIZE; if (k < 1) k = 1; thisstamp = tcp_lasttrim + k; From owner-svn-src-stable-9@FreeBSD.ORG Thu Jan 23 00:44:15 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 239F9101; Thu, 23 Jan 2014 00:44:15 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 0FFBF16E0; Thu, 23 Jan 2014 00:44:15 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0N0iEfY050977; Thu, 23 Jan 2014 00:44:14 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0N0iEpF050976; Thu, 23 Jan 2014 00:44:14 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401230044.s0N0iEpF050976@svn.freebsd.org> From: Alexander Motin Date: Thu, 23 Jan 2014 00:44:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261064 - stable/9/sys/rpc X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jan 2014 00:44:15 -0000 Author: mav Date: Thu Jan 23 00:44:14 2014 New Revision: 261064 URL: http://svnweb.freebsd.org/changeset/base/261064 Log: MFC r260031: In addition to r259632 completely block receive upcalls if we have more data than we need. This reduces lock pressure from xprt_active() side. Modified: stable/9/sys/rpc/svc_vc.c Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/sys/rpc/svc_vc.c ============================================================================== --- stable/9/sys/rpc/svc_vc.c Thu Jan 23 00:43:33 2014 (r261063) +++ stable/9/sys/rpc/svc_vc.c Thu Jan 23 00:44:14 2014 (r261064) @@ -619,7 +619,15 @@ svc_vc_process_pending(SVCXPRT *xprt) } } - so->so_rcv.sb_lowat = imax(1, imin(cd->resid, so->so_rcv.sb_hiwat / 2)); + /* + * Block receive upcalls if we have more data pending, + * otherwise report our need. + */ + if (cd->mpending) + so->so_rcv.sb_lowat = INT_MAX; + else + so->so_rcv.sb_lowat = + imax(1, imin(cd->resid, so->so_rcv.sb_hiwat / 2)); return (TRUE); } From owner-svn-src-stable-9@FreeBSD.ORG Thu Jan 23 00:44:46 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7634F263; Thu, 23 Jan 2014 00:44:46 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 56D8D16EC; Thu, 23 Jan 2014 00:44:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0N0ikLb051083; Thu, 23 Jan 2014 00:44:46 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0N0ijiQ051079; Thu, 23 Jan 2014 00:44:45 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401230044.s0N0ijiQ051079@svn.freebsd.org> From: Alexander Motin Date: Thu, 23 Jan 2014 00:44:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261065 - stable/9/sys/rpc X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jan 2014 00:44:46 -0000 Author: mav Date: Thu Jan 23 00:44:45 2014 New Revision: 261065 URL: http://svnweb.freebsd.org/changeset/base/261065 Log: MFC r260036: Introduce xprt_inactive_self() -- variant for use when sure that port is assigned to thread. For example, withing receive handlers. In that case the function reduces to single assignment and can avoid locking. Modified: stable/9/sys/rpc/svc.c stable/9/sys/rpc/svc.h stable/9/sys/rpc/svc_dg.c stable/9/sys/rpc/svc_vc.c Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/sys/rpc/svc.c ============================================================================== --- stable/9/sys/rpc/svc.c Thu Jan 23 00:44:14 2014 (r261064) +++ stable/9/sys/rpc/svc.c Thu Jan 23 00:44:45 2014 (r261065) @@ -406,6 +406,19 @@ xprt_inactive(SVCXPRT *xprt) } /* + * Variant of xprt_inactive() for use only when sure that port is + * assigned to thread. For example, withing receive handlers. + */ +void +xprt_inactive_self(SVCXPRT *xprt) +{ + + KASSERT(xprt->xp_thread != NULL, + ("xprt_inactive_self(%p) with NULL xp_thread", xprt)); + xprt->xp_active = FALSE; +} + +/* * Add a service program to the callout list. * The dispatch routine will be called when a rpc request for this * program number comes in. Modified: stable/9/sys/rpc/svc.h ============================================================================== --- stable/9/sys/rpc/svc.h Thu Jan 23 00:44:14 2014 (r261064) +++ stable/9/sys/rpc/svc.h Thu Jan 23 00:44:45 2014 (r261065) @@ -523,6 +523,7 @@ __BEGIN_DECLS extern void xprt_active(SVCXPRT *); extern void xprt_inactive(SVCXPRT *); extern void xprt_inactive_locked(SVCXPRT *); +extern void xprt_inactive_self(SVCXPRT *); __END_DECLS #endif Modified: stable/9/sys/rpc/svc_dg.c ============================================================================== --- stable/9/sys/rpc/svc_dg.c Thu Jan 23 00:44:14 2014 (r261064) +++ stable/9/sys/rpc/svc_dg.c Thu Jan 23 00:44:45 2014 (r261065) @@ -196,10 +196,10 @@ svc_dg_recv(SVCXPRT *xprt, struct rpc_ms * from racing the upcall after our soreadable() call * returns false. */ - mtx_lock(&xprt->xp_pool->sp_lock); + SOCKBUF_LOCK(&xprt->xp_socket->so_rcv); if (!soreadable(xprt->xp_socket)) - xprt_inactive_locked(xprt); - mtx_unlock(&xprt->xp_pool->sp_lock); + xprt_inactive_self(xprt); + SOCKBUF_UNLOCK(&xprt->xp_socket->so_rcv); sx_xunlock(&xprt->xp_lock); return (FALSE); } @@ -208,7 +208,7 @@ svc_dg_recv(SVCXPRT *xprt, struct rpc_ms SOCKBUF_LOCK(&xprt->xp_socket->so_rcv); soupcall_clear(xprt->xp_socket, SO_RCV); SOCKBUF_UNLOCK(&xprt->xp_socket->so_rcv); - xprt_inactive(xprt); + xprt_inactive_self(xprt); sx_xunlock(&xprt->xp_lock); return (FALSE); } Modified: stable/9/sys/rpc/svc_vc.c ============================================================================== --- stable/9/sys/rpc/svc_vc.c Thu Jan 23 00:44:14 2014 (r261064) +++ stable/9/sys/rpc/svc_vc.c Thu Jan 23 00:44:45 2014 (r261065) @@ -385,7 +385,7 @@ svc_vc_rendezvous_recv(SVCXPRT *xprt, st */ ACCEPT_LOCK(); if (TAILQ_EMPTY(&xprt->xp_socket->so_comp)) - xprt_inactive(xprt); + xprt_inactive_self(xprt); ACCEPT_UNLOCK(); sx_xunlock(&xprt->xp_lock); return (FALSE); @@ -398,7 +398,7 @@ svc_vc_rendezvous_recv(SVCXPRT *xprt, st soupcall_clear(xprt->xp_socket, SO_RCV); } SOCKBUF_UNLOCK(&xprt->xp_socket->so_rcv); - xprt_inactive(xprt); + xprt_inactive_self(xprt); sx_xunlock(&xprt->xp_lock); return (FALSE); } @@ -667,7 +667,7 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_ms if (cd->mreq == NULL || cd->resid != 0) { SOCKBUF_LOCK(&so->so_rcv); if (!soreadable(so)) - xprt_inactive(xprt); + xprt_inactive_self(xprt); SOCKBUF_UNLOCK(&so->so_rcv); } @@ -709,7 +709,7 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_ms */ SOCKBUF_LOCK(&so->so_rcv); if (!soreadable(so)) - xprt_inactive(xprt); + xprt_inactive_self(xprt); SOCKBUF_UNLOCK(&so->so_rcv); sx_xunlock(&xprt->xp_lock); return (FALSE); @@ -722,7 +722,7 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_ms soupcall_clear(so, SO_RCV); } SOCKBUF_UNLOCK(&so->so_rcv); - xprt_inactive(xprt); + xprt_inactive_self(xprt); cd->strm_stat = XPRT_DIED; sx_xunlock(&xprt->xp_lock); return (FALSE); @@ -732,7 +732,7 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_ms /* * EOF - the other end has closed the socket. */ - xprt_inactive(xprt); + xprt_inactive_self(xprt); cd->strm_stat = XPRT_DIED; sx_xunlock(&xprt->xp_lock); return (FALSE); @@ -763,7 +763,7 @@ svc_vc_backchannel_recv(SVCXPRT *xprt, s mtx_lock(&ct->ct_lock); m = cd->mreq; if (m == NULL) { - xprt_inactive(xprt); + xprt_inactive_self(xprt); mtx_unlock(&ct->ct_lock); sx_xunlock(&xprt->xp_lock); return (FALSE); From owner-svn-src-stable-9@FreeBSD.ORG Thu Jan 23 00:45:21 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7745E3B3; Thu, 23 Jan 2014 00:45:21 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 61A1516F5; Thu, 23 Jan 2014 00:45:21 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0N0jLVB051253; Thu, 23 Jan 2014 00:45:21 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0N0jKqU051249; Thu, 23 Jan 2014 00:45:20 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401230045.s0N0jKqU051249@svn.freebsd.org> From: Alexander Motin Date: Thu, 23 Jan 2014 00:45:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261066 - in stable/9/sys: nfs rpc X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jan 2014 00:45:21 -0000 Author: mav Date: Thu Jan 23 00:45:20 2014 New Revision: 261066 URL: http://svnweb.freebsd.org/changeset/base/261066 Log: MFC r260097: Move most of NFS file handle affinity code out of the heavily congested global RPC thread pool lock and protect it with own set of locks. On synthetic benchmarks this improves peak NFS request rate by 40%. Modified: stable/9/sys/nfs/nfs_fha.c stable/9/sys/nfs/nfs_fha.h stable/9/sys/rpc/svc.c stable/9/sys/rpc/svc.h Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/sys/nfs/nfs_fha.c ============================================================================== --- stable/9/sys/nfs/nfs_fha.c Thu Jan 23 00:44:45 2014 (r261065) +++ stable/9/sys/nfs/nfs_fha.c Thu Jan 23 00:45:20 2014 (r261066) @@ -52,13 +52,10 @@ void fha_init(struct fha_params *softc) { char tmpstr[128]; + int i; - /* - * A small hash table to map filehandles to fha_hash_entry - * structures. - */ - softc->g_fha.hashtable = hashinit(256, M_NFS_FHA, - &softc->g_fha.hashmask); + for (i = 0; i < FHA_HASH_SIZE; i++) + mtx_init(&softc->fha_hash[i].mtx, "fhalock", NULL, MTX_DEF); /* * Set the default tuning parameters. @@ -117,8 +114,11 @@ fha_init(struct fha_params *softc) void fha_uninit(struct fha_params *softc) { + int i; + sysctl_ctx_free(&softc->sysctl_ctx); - hashdestroy(softc->g_fha.hashtable, M_NFS_FHA, softc->g_fha.hashmask); + for (i = 0; i < FHA_HASH_SIZE; i++) + mtx_destroy(&softc->fha_hash[i].mtx); } /* @@ -207,8 +207,13 @@ static void fha_hash_entry_destroy(struct fha_hash_entry *e) { - if (e->num_rw + e->num_exclusive) - panic("nonempty fhe"); + mtx_assert(e->mtx, MA_OWNED); + KASSERT(e->num_rw == 0, + ("%d reqs on destroyed fhe %p", e->num_rw, e)); + KASSERT(e->num_exclusive == 0, + ("%d exclusive reqs on destroyed fhe %p", e->num_exclusive, e)); + KASSERT(e->num_threads == 0, + ("%d threads on destroyed fhe %p", e->num_threads, e)); free(e, M_NFS_FHA); } @@ -216,6 +221,7 @@ static void fha_hash_entry_remove(struct fha_hash_entry *e) { + mtx_assert(e->mtx, MA_OWNED); LIST_REMOVE(e, link); fha_hash_entry_destroy(e); } @@ -224,36 +230,22 @@ static struct fha_hash_entry * fha_hash_entry_lookup(struct fha_params *softc, u_int64_t fh) { SVCPOOL *pool; - - pool = *softc->pool; - + struct fha_hash_slot *fhs; struct fha_hash_entry *fhe, *new_fhe; - LIST_FOREACH(fhe, &softc->g_fha.hashtable[fh % softc->g_fha.hashmask], - link) + pool = *softc->pool; + fhs = &softc->fha_hash[fh % FHA_HASH_SIZE]; + new_fhe = fha_hash_entry_new(fh); + new_fhe->mtx = &fhs->mtx; + mtx_lock(&fhs->mtx); + LIST_FOREACH(fhe, &fhs->list, link) if (fhe->fh == fh) break; - if (!fhe) { - /* Allocate a new entry. */ - mtx_unlock(&pool->sp_lock); - new_fhe = fha_hash_entry_new(fh); - mtx_lock(&pool->sp_lock); - - /* Double-check to make sure we still need the new entry. */ - LIST_FOREACH(fhe, - &softc->g_fha.hashtable[fh % softc->g_fha.hashmask], link) - if (fhe->fh == fh) - break; - if (!fhe) { - fhe = new_fhe; - LIST_INSERT_HEAD( - &softc->g_fha.hashtable[fh % softc->g_fha.hashmask], - fhe, link); - } else - fha_hash_entry_destroy(new_fhe); - } - + fhe = new_fhe; + LIST_INSERT_HEAD(&fhs->list, fhe, link); + } else + fha_hash_entry_destroy(new_fhe); return (fhe); } @@ -261,6 +253,8 @@ static void fha_hash_entry_add_thread(struct fha_hash_entry *fhe, SVCTHREAD *thread) { + mtx_assert(fhe->mtx, MA_OWNED); + thread->st_p2 = 0; LIST_INSERT_HEAD(&fhe->threads, thread, st_alink); fhe->num_threads++; } @@ -269,6 +263,9 @@ static void fha_hash_entry_remove_thread(struct fha_hash_entry *fhe, SVCTHREAD *thread) { + mtx_assert(fhe->mtx, MA_OWNED); + KASSERT(thread->st_p2 == 0, + ("%d reqs on removed thread %p", thread->st_p2, thread)); LIST_REMOVE(thread, st_alink); fhe->num_threads--; } @@ -280,6 +277,7 @@ static void fha_hash_entry_add_op(struct fha_hash_entry *fhe, int locktype, int count) { + mtx_assert(fhe->mtx, MA_OWNED); if (LK_EXCLUSIVE == locktype) fhe->num_exclusive += count; else @@ -306,7 +304,7 @@ fha_hash_entry_choose_thread(struct fha_ pool = *softc->pool; LIST_FOREACH(thread, &fhe->threads, st_alink) { - req_count = thread->st_reqcount; + req_count = thread->st_p2; /* If there are any writes in progress, use the first thread. */ if (fhe->num_exclusive) { @@ -322,7 +320,7 @@ fha_hash_entry_choose_thread(struct fha_ * exceed our per-thread load limit in the process. */ offset1 = i->offset; - offset2 = STAILQ_FIRST(&thread->st_reqs)->rq_p3; + offset2 = thread->st_p3; if (((offset1 >= offset2) && ((offset1 - offset2) < (1 << softc->ctls.bin_shift))) @@ -360,28 +358,11 @@ fha_hash_entry_choose_thread(struct fha_ */ if ((softc->ctls.max_nfsds_per_fh == 0) || (fhe->num_threads < softc->ctls.max_nfsds_per_fh)) { - /* - * We can add a new thread, so try for an idle thread - * first, and fall back to this_thread if none are idle. - */ - if (STAILQ_EMPTY(&this_thread->st_reqs)) { - thread = this_thread; + thread = this_thread; #if 0 - ITRACE_CURPROC(ITRACE_NFS, ITRACE_INFO, - "fha: %p(%d)t", thread, thread->st_reqcount); -#endif - } else if ((thread = LIST_FIRST(&pool->sp_idlethreads))) { -#if 0 - ITRACE_CURPROC(ITRACE_NFS, ITRACE_INFO, - "fha: %p(%d)i", thread, thread->st_reqcount); -#endif - } else { - thread = this_thread; -#if 0 - ITRACE_CURPROC(ITRACE_NFS, ITRACE_INFO, - "fha: %p(%d)b", thread, thread->st_reqcount); + ITRACE_CURPROC(ITRACE_NFS, ITRACE_INFO, + "fha: %p(%d)t", thread, thread->st_p2); #endif - } fha_hash_entry_add_thread(fhe, thread); } else { /* @@ -411,16 +392,16 @@ fha_assign(SVCTHREAD *this_thread, struc /* Check to see whether we're enabled. */ if (softc->ctls.enable == 0) - return (this_thread); + goto thist; /* * Only do placement if this is an NFS request. */ if (req->rq_prog != NFS_PROG) - return (this_thread); + goto thist; if (req->rq_vers != 2 && req->rq_vers != 3) - return (this_thread); + goto thist; fha_extract_info(req, &i, cb); @@ -440,8 +421,21 @@ fha_assign(SVCTHREAD *this_thread, struc thread = fha_hash_entry_choose_thread(softc, fhe, &i, this_thread); KASSERT(thread, ("fha_assign: NULL thread!")); fha_hash_entry_add_op(fhe, i.locktype, 1); + thread->st_p2++; + thread->st_p3 = i.offset; + + /* + * Grab the pool lock here to not let chosen thread go away before + * the new request inserted to its queue while we drop fhe lock. + */ + mtx_lock(&(*softc->pool)->sp_lock); + mtx_unlock(fhe->mtx); return (thread); +thist: + req->rq_p1 = NULL; + mtx_lock(&(*softc->pool)->sp_lock); + return (this_thread); } /* @@ -452,6 +446,7 @@ void fha_nd_complete(SVCTHREAD *thread, struct svc_req *req) { struct fha_hash_entry *fhe = req->rq_p1; + struct mtx *mtx; /* * This may be called for reqs that didn't go through @@ -460,13 +455,18 @@ fha_nd_complete(SVCTHREAD *thread, struc if (!fhe) return; + mtx = fhe->mtx; + mtx_lock(mtx); fha_hash_entry_add_op(fhe, req->rq_p2, -1); - - if (thread->st_reqcount == 0) { + thread->st_p2--; + KASSERT(thread->st_p2 >= 0, ("Negative request count %d on %p", + thread->st_p2, thread)); + if (thread->st_p2 == 0) { fha_hash_entry_remove_thread(fhe, thread); if (0 == fhe->num_rw + fhe->num_exclusive) fha_hash_entry_remove(fhe); } + mtx_unlock(mtx); } int @@ -489,10 +489,9 @@ fhe_stats_sysctl(SYSCTL_HANDLER_ARGS, st } pool = *softc->pool; - mtx_lock(&pool->sp_lock); count = 0; - for (i = 0; i <= softc->g_fha.hashmask; i++) - if (!LIST_EMPTY(&softc->g_fha.hashtable[i])) + for (i = 0; i < FHA_HASH_SIZE; i++) + if (!LIST_EMPTY(&softc->fha_hash[i].list)) count++; if (count == 0) { @@ -500,8 +499,9 @@ fhe_stats_sysctl(SYSCTL_HANDLER_ARGS, st goto out; } - for (i = 0; i <= softc->g_fha.hashmask; i++) { - LIST_FOREACH(fhe, &softc->g_fha.hashtable[i], link) { + for (i = 0; i < FHA_HASH_SIZE; i++) { + mtx_lock(&softc->fha_hash[i].mtx); + LIST_FOREACH(fhe, &softc->fha_hash[i].list, link) { sbuf_printf(&sb, "%sfhe %p: {\n", first ? "" : ", ", fhe); sbuf_printf(&sb, " fh: %ju\n", (uintmax_t) fhe->fh); @@ -512,8 +512,7 @@ fhe_stats_sysctl(SYSCTL_HANDLER_ARGS, st LIST_FOREACH(thread, &fhe->threads, st_alink) { sbuf_printf(&sb, " thread %p offset %ju " "(count %d)\n", thread, - STAILQ_FIRST(&thread->st_reqs)->rq_p3, - thread->st_reqcount); + thread->st_p3, thread->st_p2); } sbuf_printf(&sb, "}"); @@ -525,11 +524,10 @@ fhe_stats_sysctl(SYSCTL_HANDLER_ARGS, st break; } } + mtx_unlock(&softc->fha_hash[i].mtx); } out: - if (pool) - mtx_unlock(&pool->sp_lock); sbuf_trim(&sb); sbuf_finish(&sb); error = sysctl_handle_string(oidp, sbuf_data(&sb), sbuf_len(&sb), req); Modified: stable/9/sys/nfs/nfs_fha.h ============================================================================== --- stable/9/sys/nfs/nfs_fha.h Thu Jan 23 00:44:45 2014 (r261065) +++ stable/9/sys/nfs/nfs_fha.h Thu Jan 23 00:45:20 2014 (r261066) @@ -35,11 +35,7 @@ #define FHA_DEF_MAX_NFSDS_PER_FH 8 #define FHA_DEF_MAX_REQS_PER_NFSD 0 /* Unlimited */ -/* This is the global structure that represents the state of the fha system. */ -struct fha_global { - struct fha_hash_entry_list *hashtable; - u_long hashmask; -}; +#define FHA_HASH_SIZE 251 struct fha_ctls { int enable; @@ -62,6 +58,7 @@ struct fha_ctls { * avoid contention between threads over single files. */ struct fha_hash_entry { + struct mtx *mtx; LIST_ENTRY(fha_hash_entry) link; u_int64_t fh; u_int32_t num_rw; @@ -72,6 +69,11 @@ struct fha_hash_entry { LIST_HEAD(fha_hash_entry_list, fha_hash_entry); +struct fha_hash_slot { + struct fha_hash_entry_list list; + struct mtx mtx; +}; + /* A structure used for passing around data internally. */ struct fha_info { u_int64_t fh; @@ -93,7 +95,7 @@ struct fha_callbacks { }; struct fha_params { - struct fha_global g_fha; + struct fha_hash_slot fha_hash[FHA_HASH_SIZE]; struct sysctl_ctx_list sysctl_ctx; struct sysctl_oid *sysctl_tree; struct fha_ctls ctls; Modified: stable/9/sys/rpc/svc.c ============================================================================== --- stable/9/sys/rpc/svc.c Thu Jan 23 00:44:45 2014 (r261065) +++ stable/9/sys/rpc/svc.c Thu Jan 23 00:45:20 2014 (r261066) @@ -71,6 +71,8 @@ static struct svc_callout *svc_find(SVCP char *); static void svc_new_thread(SVCPOOL *pool); static void xprt_unregister_locked(SVCXPRT *xprt); +static void svc_change_space_used(SVCPOOL *pool, int delta); +static bool_t svc_request_space_available(SVCPOOL *pool); /* *************** SVCXPRT related stuff **************** */ @@ -373,7 +375,8 @@ xprt_active(SVCXPRT *xprt) if (!xprt->xp_active) { xprt->xp_active = TRUE; if (xprt->xp_thread == NULL) { - if (!xprt_assignthread(xprt)) + if (!svc_request_space_available(pool) || + !xprt_assignthread(xprt)) TAILQ_INSERT_TAIL(&pool->sp_active, xprt, xp_alink); } @@ -967,56 +970,63 @@ svc_assign_waiting_sockets(SVCPOOL *pool { SVCXPRT *xprt; + mtx_lock(&pool->sp_lock); while ((xprt = TAILQ_FIRST(&pool->sp_active)) != NULL) { if (xprt_assignthread(xprt)) TAILQ_REMOVE(&pool->sp_active, xprt, xp_alink); else break; } + mtx_unlock(&pool->sp_lock); } -static bool_t -svc_request_space_available(SVCPOOL *pool) +static void +svc_change_space_used(SVCPOOL *pool, int delta) { + unsigned int value; - mtx_assert(&pool->sp_lock, MA_OWNED); - - if (pool->sp_space_throttled) { - /* - * Below the low-water yet? If so, assign any waiting sockets. - */ - if (pool->sp_space_used < pool->sp_space_low) { - pool->sp_space_throttled = FALSE; - svc_assign_waiting_sockets(pool); - return TRUE; - } - - return FALSE; - } else { - if (pool->sp_space_used - >= pool->sp_space_high) { + value = atomic_fetchadd_int(&pool->sp_space_used, delta) + delta; + if (delta > 0) { + if (value >= pool->sp_space_high && !pool->sp_space_throttled) { pool->sp_space_throttled = TRUE; pool->sp_space_throttle_count++; - return FALSE; } - - return TRUE; + if (value > pool->sp_space_used_highest) + pool->sp_space_used_highest = value; + } else { + if (value < pool->sp_space_low && pool->sp_space_throttled) { + pool->sp_space_throttled = FALSE; + svc_assign_waiting_sockets(pool); + } } } +static bool_t +svc_request_space_available(SVCPOOL *pool) +{ + + if (pool->sp_space_throttled) + return (FALSE); + return (TRUE); +} + static void svc_run_internal(SVCPOOL *pool, bool_t ismaster) { + struct svc_reqlist reqs; SVCTHREAD *st, *stpref; SVCXPRT *xprt; enum xprt_stat stat; struct svc_req *rqstp; + size_t sz; int error; st = mem_alloc(sizeof(*st)); + st->st_pool = pool; st->st_xprt = NULL; STAILQ_INIT(&st->st_reqs); cv_init(&st->st_cond, "rpcsvc"); + STAILQ_INIT(&reqs); mtx_lock(&pool->sp_lock); LIST_INSERT_HEAD(&pool->sp_threads, st, st_link); @@ -1110,15 +1120,14 @@ svc_run_internal(SVCPOOL *pool, bool_t i * RPCs. */ xprt->xp_lastactive = time_uptime; - stat = XPRT_IDLE; do { + mtx_unlock(&pool->sp_lock); if (!svc_request_space_available(pool)) break; rqstp = NULL; - mtx_unlock(&pool->sp_lock); stat = svc_getreq(xprt, &rqstp); - mtx_lock(&pool->sp_lock); if (rqstp) { + svc_change_space_used(pool, rqstp->rq_size); /* * See if the application has * a preference for some other @@ -1128,17 +1137,12 @@ svc_run_internal(SVCPOOL *pool, bool_t i if (pool->sp_assign) stpref = pool->sp_assign(st, rqstp); + else + mtx_lock(&pool->sp_lock); - pool->sp_space_used += - rqstp->rq_size; - if (pool->sp_space_used - > pool->sp_space_used_highest) - pool->sp_space_used_highest = - pool->sp_space_used; rqstp->rq_thread = stpref; STAILQ_INSERT_TAIL(&stpref->st_reqs, rqstp, rq_link); - stpref->st_reqcount++; /* * If we assigned the request @@ -1158,7 +1162,8 @@ svc_run_internal(SVCPOOL *pool, bool_t i stpref->st_idle = FALSE; cv_signal(&stpref->st_cond); } - } + } else + mtx_lock(&pool->sp_lock); } while (stat == XPRT_MOREREQS && pool->sp_state != SVCPOOL_CLOSING); @@ -1173,25 +1178,30 @@ svc_run_internal(SVCPOOL *pool, bool_t i xprt->xp_thread = NULL; st->st_xprt = NULL; if (xprt->xp_active) { - if (!xprt_assignthread(xprt)) + if (!svc_request_space_available(pool) || + !xprt_assignthread(xprt)) TAILQ_INSERT_TAIL(&pool->sp_active, xprt, xp_alink); } + STAILQ_CONCAT(&reqs, &st->st_reqs); mtx_unlock(&pool->sp_lock); SVC_RELEASE(xprt); - mtx_lock(&pool->sp_lock); + } else { + STAILQ_CONCAT(&reqs, &st->st_reqs); + mtx_unlock(&pool->sp_lock); } /* * Execute what we have queued. */ - while ((rqstp = STAILQ_FIRST(&st->st_reqs)) != NULL) { - size_t sz = rqstp->rq_size; - mtx_unlock(&pool->sp_lock); + sz = 0; + while ((rqstp = STAILQ_FIRST(&reqs)) != NULL) { + STAILQ_REMOVE_HEAD(&reqs, rq_link); + sz += rqstp->rq_size; svc_executereq(rqstp); - mtx_lock(&pool->sp_lock); - pool->sp_space_used -= sz; } + svc_change_space_used(pool, -sz); + mtx_lock(&pool->sp_lock); } if (st->st_xprt) { @@ -1311,24 +1321,13 @@ void svc_freereq(struct svc_req *rqstp) { SVCTHREAD *st; - SVCXPRT *xprt; SVCPOOL *pool; st = rqstp->rq_thread; - xprt = rqstp->rq_xprt; - if (xprt) - pool = xprt->xp_pool; - else - pool = NULL; if (st) { - mtx_lock(&pool->sp_lock); - KASSERT(rqstp == STAILQ_FIRST(&st->st_reqs), - ("Freeing request out of order")); - STAILQ_REMOVE_HEAD(&st->st_reqs, rq_link); - st->st_reqcount--; + pool = st->st_pool; if (pool->sp_done) pool->sp_done(st, rqstp); - mtx_unlock(&pool->sp_lock); } if (rqstp->rq_auth.svc_ah_ops) Modified: stable/9/sys/rpc/svc.h ============================================================================== --- stable/9/sys/rpc/svc.h Thu Jan 23 00:44:45 2014 (r261065) +++ stable/9/sys/rpc/svc.h Thu Jan 23 00:45:20 2014 (r261066) @@ -275,14 +275,16 @@ STAILQ_HEAD(svc_reqlist, svc_req); * thread to read and execute pending RPCs. */ typedef struct __rpc_svcthread { + struct __rpc_svcpool *st_pool; SVCXPRT *st_xprt; /* transport we are processing */ struct svc_reqlist st_reqs; /* RPC requests to execute */ - int st_reqcount; /* number of queued reqs */ int st_idle; /* thread is on idle list */ struct cv st_cond; /* sleeping for work */ LIST_ENTRY(__rpc_svcthread) st_link; /* all threads list */ LIST_ENTRY(__rpc_svcthread) st_ilink; /* idle threads list */ LIST_ENTRY(__rpc_svcthread) st_alink; /* application thread list */ + int st_p2; /* application workspace */ + uint64_t st_p3; /* application workspace */ } SVCTHREAD; LIST_HEAD(svcthread_list, __rpc_svcthread); From owner-svn-src-stable-9@FreeBSD.ORG Thu Jan 23 00:46:31 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E13754F9; Thu, 23 Jan 2014 00:46:31 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id CB32116FF; Thu, 23 Jan 2014 00:46:31 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0N0kVY9051433; Thu, 23 Jan 2014 00:46:31 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0N0kTcI051423; Thu, 23 Jan 2014 00:46:29 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401230046.s0N0kTcI051423@svn.freebsd.org> From: Alexander Motin Date: Thu, 23 Jan 2014 00:46:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261067 - in stable/9/sys: fs/nfs fs/nfsserver rpc X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jan 2014 00:46:32 -0000 Author: mav Date: Thu Jan 23 00:46:29 2014 New Revision: 261067 URL: http://svnweb.freebsd.org/changeset/base/261067 Log: MFC r260229, r260258, r260367, r260390, r260459, r260648: Rework NFS Duplicate Request Cache cleanup logic. - Introduce additional hash to group requests by hash of sockref. This allows to process TCP acknowledgements without looping though all the cache, and as result allows to do it every time. - Indroduce additional callbacks to notify application layer about sockets disconnection. Without this last few requests processed just before socket disconnection never processed their ACKs and stuck in cache for many hours. - Implement transport-specific method for tracking reply acknowledgements. New implementation does not cross multiple stack layers to get the data and does not have race conditions that previously made some requests stuck in cache. This could be done more efficiently at sockbuf layer, but that would broke some KBIs, while I don't know other consumers for it aside NFS. - Instead of traversing all DRC twice per request, run cleaning only once per request, and except in some conditions traverse only single hash slot at a time. Together this limits NFS DRC growth only to situations of real connectivity problems. If network is working well, and so all replies are acknowledged, cache remains almost empty even after hours of heavy load. Without this change on the same test cache was growing to many thousand requests even with perfectly working local network. As another result this reduces CPU time spent on the DRC handling during SPEC NFS benchmark from about 10% to 0.5%. Sponsored by: iXsystems, Inc. Modified: stable/9/sys/fs/nfs/nfs_var.h stable/9/sys/fs/nfs/nfsrvcache.h stable/9/sys/fs/nfsserver/nfs_nfsdcache.c stable/9/sys/fs/nfsserver/nfs_nfsdkrpc.c stable/9/sys/fs/nfsserver/nfs_nfsdport.c stable/9/sys/fs/nfsserver/nfs_nfsdsubs.c stable/9/sys/rpc/svc.c stable/9/sys/rpc/svc.h stable/9/sys/rpc/svc_dg.c stable/9/sys/rpc/svc_vc.c Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) stable/9/sys/fs/ (props changed) Modified: stable/9/sys/fs/nfs/nfs_var.h ============================================================================== --- stable/9/sys/fs/nfs/nfs_var.h Thu Jan 23 00:45:20 2014 (r261066) +++ stable/9/sys/fs/nfs/nfs_var.h Thu Jan 23 00:46:29 2014 (r261067) @@ -215,14 +215,14 @@ void nfsrvd_dorpc(struct nfsrv_descript /* nfs_nfsdcache.c */ void nfsrvd_initcache(void); -int nfsrvd_getcache(struct nfsrv_descript *, struct socket *); -struct nfsrvcache *nfsrvd_updatecache(struct nfsrv_descript *, - struct socket *); -void nfsrvd_sentcache(struct nfsrvcache *, struct socket *, int); +int nfsrvd_getcache(struct nfsrv_descript *); +struct nfsrvcache *nfsrvd_updatecache(struct nfsrv_descript *); +void nfsrvd_sentcache(struct nfsrvcache *, int, uint32_t); void nfsrvd_cleancache(void); void nfsrvd_refcache(struct nfsrvcache *); void nfsrvd_derefcache(struct nfsrvcache *); void nfsrvd_delcache(struct nfsrvcache *); +void nfsrc_trimcache(uint64_t, uint32_t, int); /* nfs_commonsubs.c */ void newnfs_init(void); @@ -316,9 +316,6 @@ int nfsd_checkrootexp(struct nfsrv_descr void nfscl_retopts(struct nfsmount *, char *, size_t); /* nfs_commonport.c */ -int nfsrv_checksockseqnum(struct socket *, tcp_seq); -int nfsrv_getsockseqnum(struct socket *, tcp_seq *); -int nfsrv_getsocksndseq(struct socket *, tcp_seq *, tcp_seq *); int nfsrv_lookupfilename(struct nameidata *, char *, NFSPROC_T *); void nfsrv_object_create(vnode_t, NFSPROC_T *); int nfsrv_mallocmget_limit(void); Modified: stable/9/sys/fs/nfs/nfsrvcache.h ============================================================================== --- stable/9/sys/fs/nfs/nfsrvcache.h Thu Jan 23 00:45:20 2014 (r261066) +++ stable/9/sys/fs/nfs/nfsrvcache.h Thu Jan 23 00:46:29 2014 (r261067) @@ -46,6 +46,7 @@ /* Cache table entry. */ struct nfsrvcache { LIST_ENTRY(nfsrvcache) rc_hash; /* Hash chain */ + LIST_ENTRY(nfsrvcache) rc_ahash; /* ACK hash chain */ TAILQ_ENTRY(nfsrvcache) rc_lru; /* UDP lru chain */ u_int32_t rc_xid; /* rpc id number */ time_t rc_timestamp; /* Time done */ @@ -64,6 +65,7 @@ struct nfsrvcache { int16_t refcnt; u_int16_t cksum; time_t cachetime; + int acked; } ot; } rc_un2; u_int16_t rc_proc; /* rpc proc number */ @@ -81,6 +83,13 @@ struct nfsrvcache { #define rc_reqlen rc_un2.ot.len #define rc_cksum rc_un2.ot.cksum #define rc_cachetime rc_un2.ot.cachetime +#define rc_acked rc_un2.ot.acked + +/* TCP ACK values */ +#define RC_NO_SEQ 0 +#define RC_NO_ACK 1 +#define RC_ACK 2 +#define RC_NACK 3 /* Return values */ #define RC_DROPIT 0 @@ -95,7 +104,6 @@ struct nfsrvcache { #define RC_UDP 0x0010 #define RC_INETIPV6 0x0020 #define RC_INPROG 0x0040 -#define RC_TCPSEQ 0x0080 #define RC_NFSV2 0x0100 #define RC_NFSV3 0x0200 #define RC_NFSV4 0x0400 Modified: stable/9/sys/fs/nfsserver/nfs_nfsdcache.c ============================================================================== --- stable/9/sys/fs/nfsserver/nfs_nfsdcache.c Thu Jan 23 00:45:20 2014 (r261066) +++ stable/9/sys/fs/nfsserver/nfs_nfsdcache.c Thu Jan 23 00:46:29 2014 (r261067) @@ -162,6 +162,7 @@ __FBSDID("$FreeBSD$"); extern struct nfsstats newnfsstats; extern struct mtx nfsrc_udpmtx; extern struct nfsrchash_bucket nfsrchash_table[NFSRVCACHE_HASHSIZE]; +extern struct nfsrchash_bucket nfsrcahash_table[NFSRVCACHE_HASHSIZE]; int nfsrc_floodlevel = NFSRVCACHE_FLOODLEVEL, nfsrc_tcpsavedreplies = 0; #endif /* !APPLEKEXT */ @@ -238,6 +239,7 @@ static int newnfsv2_procid[NFS_V3NPROCS] (&nfsrvudphashtbl[nfsrc_hash(xid)]) #define NFSRCHASH(xid) \ (&nfsrchash_table[nfsrc_hash(xid)].tbl) +#define NFSRCAHASH(xid) (&nfsrcahash_table[nfsrc_hash(xid)]) #define TRUE 1 #define FALSE 0 #define NFSRVCACHE_CHECKLEN 100 @@ -281,9 +283,6 @@ static void nfsrc_lock(struct nfsrvcache static void nfsrc_unlock(struct nfsrvcache *rp); static void nfsrc_wanted(struct nfsrvcache *rp); static void nfsrc_freecache(struct nfsrvcache *rp); -static void nfsrc_trimcache(u_int64_t, struct socket *); -static int nfsrc_activesocket(struct nfsrvcache *rp, u_int64_t, - struct socket *); static int nfsrc_getlenandcksum(mbuf_t m1, u_int16_t *cksum); static void nfsrc_marksametcpconn(u_int64_t); @@ -314,6 +313,7 @@ nfsrvd_initcache(void) for (i = 0; i < NFSRVCACHE_HASHSIZE; i++) { LIST_INIT(&nfsrvudphashtbl[i]); LIST_INIT(&nfsrchash_table[i].tbl); + LIST_INIT(&nfsrcahash_table[i].tbl); } TAILQ_INIT(&nfsrvudplru); nfsrc_tcpsavedreplies = 0; @@ -325,10 +325,9 @@ nfsrvd_initcache(void) /* * Get a cache entry for this request. Basically just malloc a new one * and then call nfsrc_getudp() or nfsrc_gettcp() to do the rest. - * Call nfsrc_trimcache() to clean up the cache before returning. */ APPLESTATIC int -nfsrvd_getcache(struct nfsrv_descript *nd, struct socket *so) +nfsrvd_getcache(struct nfsrv_descript *nd) { struct nfsrvcache *newrp; int ret; @@ -356,7 +355,6 @@ nfsrvd_getcache(struct nfsrv_descript *n } else { ret = nfsrc_gettcp(nd, newrp); } - nfsrc_trimcache(nd->nd_sockref, so); NFSEXITCODE2(0, nd); return (ret); } @@ -456,7 +454,7 @@ out: * Update a request cache entry after the rpc has been done */ APPLESTATIC struct nfsrvcache * -nfsrvd_updatecache(struct nfsrv_descript *nd, struct socket *so) +nfsrvd_updatecache(struct nfsrv_descript *nd) { struct nfsrvcache *rp; struct nfsrvcache *retrp = NULL; @@ -549,7 +547,6 @@ nfsrvd_updatecache(struct nfsrv_descript } out: - nfsrc_trimcache(nd->nd_sockref, so); NFSEXITCODE2(0, nd); return (retrp); } @@ -575,29 +572,23 @@ nfsrvd_delcache(struct nfsrvcache *rp) /* * Called after nfsrvd_updatecache() once the reply is sent, to update - * the entry for nfsrc_activesocket() and unlock it. The argument is + * the entry's sequence number and unlock it. The argument is * the pointer returned by nfsrvd_updatecache(). */ APPLESTATIC void -nfsrvd_sentcache(struct nfsrvcache *rp, struct socket *so, int err) +nfsrvd_sentcache(struct nfsrvcache *rp, int have_seq, uint32_t seq) { - tcp_seq tmp_seq; - struct mtx *mutex; + struct nfsrchash_bucket *hbp; - mutex = nfsrc_cachemutex(rp); - if (!(rp->rc_flag & RC_LOCKED)) - panic("nfsrvd_sentcache not locked"); - if (!err) { - if ((so->so_proto->pr_domain->dom_family != AF_INET && - so->so_proto->pr_domain->dom_family != AF_INET6) || - so->so_proto->pr_protocol != IPPROTO_TCP) - panic("nfs sent cache"); - if (nfsrv_getsockseqnum(so, &tmp_seq)) { - mtx_lock(mutex); - rp->rc_tcpseq = tmp_seq; - rp->rc_flag |= RC_TCPSEQ; - mtx_unlock(mutex); - } + KASSERT(rp->rc_flag & RC_LOCKED, ("nfsrvd_sentcache not locked")); + if (have_seq) { + hbp = NFSRCAHASH(rp->rc_sockref); + mtx_lock(&hbp->mtx); + rp->rc_tcpseq = seq; + if (rp->rc_acked != RC_NO_ACK) + LIST_INSERT_HEAD(&hbp->tbl, rp, rc_ahash); + rp->rc_acked = RC_NO_ACK; + mtx_unlock(&hbp->mtx); } nfsrc_unlock(rp); } @@ -790,11 +781,18 @@ nfsrc_wanted(struct nfsrvcache *rp) static void nfsrc_freecache(struct nfsrvcache *rp) { + struct nfsrchash_bucket *hbp; LIST_REMOVE(rp, rc_hash); if (rp->rc_flag & RC_UDP) { TAILQ_REMOVE(&nfsrvudplru, rp, rc_lru); nfsrc_udpcachesize--; + } else if (rp->rc_acked != RC_NO_SEQ) { + hbp = NFSRCAHASH(rp->rc_sockref); + mtx_lock(&hbp->mtx); + if (rp->rc_acked == RC_NO_ACK) + LIST_REMOVE(rp, rc_ahash); + mtx_unlock(&hbp->mtx); } nfsrc_wanted(rp); if (rp->rc_flag & RC_REPMBUF) { @@ -836,14 +834,32 @@ nfsrvd_cleancache(void) /* * The basic rule is to get rid of entries that are expired. */ -static void -nfsrc_trimcache(u_int64_t sockref, struct socket *so) +void +nfsrc_trimcache(u_int64_t sockref, uint32_t snd_una, int final) { + struct nfsrchash_bucket *hbp; struct nfsrvcache *rp, *nextrp; - int i, j, k, tto, time_histo[HISTSIZE]; + int force, lastslot, i, j, k, tto, time_histo[HISTSIZE]; time_t thisstamp; static time_t udp_lasttrim = 0, tcp_lasttrim = 0; - static int onethread = 0; + static int onethread = 0, oneslot = 0; + + if (sockref != 0) { + hbp = NFSRCAHASH(sockref); + mtx_lock(&hbp->mtx); + LIST_FOREACH_SAFE(rp, &hbp->tbl, rc_ahash, nextrp) { + if (sockref == rp->rc_sockref) { + if (SEQ_GEQ(snd_una, rp->rc_tcpseq)) { + rp->rc_acked = RC_ACK; + LIST_REMOVE(rp, rc_ahash); + } else if (final) { + rp->rc_acked = RC_NACK; + LIST_REMOVE(rp, rc_ahash); + } + } + } + mtx_unlock(&hbp->mtx); + } if (atomic_cmpset_acq_int(&onethread, 0, 1) == 0) return; @@ -864,13 +880,28 @@ nfsrc_trimcache(u_int64_t sockref, struc } if (NFSD_MONOSEC != tcp_lasttrim || nfsrc_tcpsavedreplies >= nfsrc_tcphighwater) { - for (i = 0; i < HISTSIZE; i++) - time_histo[i] = 0; + force = nfsrc_tcphighwater / 4; + if (force > 0 && + nfsrc_tcpsavedreplies + force >= nfsrc_tcphighwater) { + for (i = 0; i < HISTSIZE; i++) + time_histo[i] = 0; + i = 0; + lastslot = NFSRVCACHE_HASHSIZE - 1; + } else { + force = 0; + if (NFSD_MONOSEC != tcp_lasttrim) { + i = 0; + lastslot = NFSRVCACHE_HASHSIZE - 1; + } else { + lastslot = i = oneslot; + if (++oneslot >= NFSRVCACHE_HASHSIZE) + oneslot = 0; + } + } tto = nfsrc_tcptimeout; - for (i = 0; i < NFSRVCACHE_HASHSIZE; i++) { + tcp_lasttrim = NFSD_MONOSEC; + for (; i <= lastslot; i++) { mtx_lock(&nfsrchash_table[i].mtx); - if (i == 0) - tcp_lasttrim = NFSD_MONOSEC; LIST_FOREACH_SAFE(rp, &nfsrchash_table[i].tbl, rc_hash, nextrp) { if (!(rp->rc_flag & @@ -878,12 +909,12 @@ nfsrc_trimcache(u_int64_t sockref, struc && rp->rc_refcnt == 0) { if ((rp->rc_flag & RC_REFCNT) || tcp_lasttrim > rp->rc_timestamp || - nfsrc_activesocket(rp, sockref, so)) { + rp->rc_acked == RC_ACK) { nfsrc_freecache(rp); continue; } - if (nfsrc_tcphighwater == 0) + if (force == 0) continue; /* * The timestamps range from roughly the @@ -903,8 +934,7 @@ nfsrc_trimcache(u_int64_t sockref, struc } mtx_unlock(&nfsrchash_table[i].mtx); } - j = nfsrc_tcphighwater / 5; /* 20% of it */ - if (j > 0 && (nfsrc_tcpsavedreplies + j) > nfsrc_tcphighwater) { + if (force) { /* * Trim some more with a smaller timeout of as little * as 20% of nfsrc_tcptimeout to try and get below @@ -913,7 +943,7 @@ nfsrc_trimcache(u_int64_t sockref, struc k = 0; for (i = 0; i < (HISTSIZE - 2); i++) { k += time_histo[i]; - if (k > j) + if (k > force) break; } k = tto * (i + 1) / HISTSIZE; @@ -929,8 +959,7 @@ nfsrc_trimcache(u_int64_t sockref, struc && rp->rc_refcnt == 0 && ((rp->rc_flag & RC_REFCNT) || thisstamp > rp->rc_timestamp || - nfsrc_activesocket(rp, sockref, - so))) + rp->rc_acked == RC_ACK)) nfsrc_freecache(rp); } mtx_unlock(&nfsrchash_table[i].mtx); @@ -975,28 +1004,6 @@ nfsrvd_derefcache(struct nfsrvcache *rp) } /* - * Check to see if the socket is active. - * Return 1 if the reply has been received/acknowledged by the client, - * 0 otherwise. - * XXX - Uses tcp internals. - */ -static int -nfsrc_activesocket(struct nfsrvcache *rp, u_int64_t cur_sockref, - struct socket *cur_so) -{ - int ret = 0; - - if (!(rp->rc_flag & RC_TCPSEQ)) - return (ret); - /* - * If the sockref is the same, it is the same TCP connection. - */ - if (cur_sockref == rp->rc_sockref) - ret = nfsrv_checksockseqnum(cur_so, rp->rc_tcpseq); - return (ret); -} - -/* * Calculate the length of the mbuf list and a checksum on the first up to * NFSRVCACHE_CHECKLEN bytes. */ Modified: stable/9/sys/fs/nfsserver/nfs_nfsdkrpc.c ============================================================================== --- stable/9/sys/fs/nfsserver/nfs_nfsdkrpc.c Thu Jan 23 00:45:20 2014 (r261066) +++ stable/9/sys/fs/nfsserver/nfs_nfsdkrpc.c Thu Jan 23 00:46:29 2014 (r261067) @@ -97,8 +97,8 @@ static int nfs_maxvers = NFS_VER4; SYSCTL_INT(_vfs_nfsd, OID_AUTO, server_max_nfsvers, CTLFLAG_RW, &nfs_maxvers, 0, "The highest version of NFS handled by the server"); -static int nfs_proc(struct nfsrv_descript *, u_int32_t, struct socket *, - u_int64_t, struct nfsrvcache **); +static int nfs_proc(struct nfsrv_descript *, u_int32_t, SVCXPRT *xprt, + struct nfsrvcache **); extern u_long sb_max_adj; extern int newnfs_numnfsd; @@ -251,8 +251,7 @@ nfssvc_program(struct svc_req *rqst, SVC } } - cacherep = nfs_proc(&nd, rqst->rq_xid, xprt->xp_socket, - xprt->xp_sockref, &rp); + cacherep = nfs_proc(&nd, rqst->rq_xid, xprt, &rp); NFSLOCKV4ROOTMUTEX(); nfsv4_relref(&nfsd_suspend_lock); NFSUNLOCKV4ROOTMUTEX(); @@ -287,8 +286,10 @@ nfssvc_program(struct svc_req *rqst, SVC } else if (!svc_sendreply_mbuf(rqst, nd.nd_mreq)) { svcerr_systemerr(rqst); } - if (rp != NULL) - nfsrvd_sentcache(rp, xprt->xp_socket, 0); + if (rp != NULL) { + nfsrvd_sentcache(rp, (rqst->rq_reply_seq != 0 || + SVC_ACK(xprt, NULL)), rqst->rq_reply_seq); + } svc_freereq(rqst); out: @@ -300,11 +301,12 @@ out: * Return the appropriate cache response. */ static int -nfs_proc(struct nfsrv_descript *nd, u_int32_t xid, struct socket *so, - u_int64_t sockref, struct nfsrvcache **rpp) +nfs_proc(struct nfsrv_descript *nd, u_int32_t xid, SVCXPRT *xprt, + struct nfsrvcache **rpp) { struct thread *td = curthread; int cacherep = RC_DOIT, isdgram; + uint32_t ack; *rpp = NULL; if (nd->nd_nam2 == NULL) { @@ -336,8 +338,11 @@ nfs_proc(struct nfsrv_descript *nd, u_in nd->nd_flag |= ND_SAMETCPCONN; nd->nd_retxid = xid; nd->nd_tcpconntime = NFSD_MONOSEC; - nd->nd_sockref = sockref; - cacherep = nfsrvd_getcache(nd, so); + nd->nd_sockref = xprt->xp_sockref; + cacherep = nfsrvd_getcache(nd); + ack = 0; + SVC_ACK(xprt, &ack); + nfsrc_trimcache(xprt->xp_sockref, ack, 0); } /* @@ -352,13 +357,23 @@ nfs_proc(struct nfsrv_descript *nd, u_in cacherep = RC_DROPIT; else cacherep = RC_REPLY; - *rpp = nfsrvd_updatecache(nd, so); + *rpp = nfsrvd_updatecache(nd); } NFSEXITCODE2(0, nd); return (cacherep); } +static void +nfssvc_loss(SVCXPRT *xprt) +{ + uint32_t ack; + + ack = 0; + SVC_ACK(xprt, &ack); + nfsrc_trimcache(xprt->xp_sockref, ack, 1); +} + /* * Adds a socket to the list for servicing by nfsds. */ @@ -399,6 +414,8 @@ nfsrvd_addsock(struct file *fp) if (nfs_maxvers >= NFS_VER4) svc_reg(xprt, NFS_PROG, NFS_VER4, nfssvc_program, NULL); + if (so->so_type == SOCK_STREAM) + svc_loss_reg(xprt, nfssvc_loss); SVC_RELEASE(xprt); } Modified: stable/9/sys/fs/nfsserver/nfs_nfsdport.c ============================================================================== --- stable/9/sys/fs/nfsserver/nfs_nfsdport.c Thu Jan 23 00:45:20 2014 (r261066) +++ stable/9/sys/fs/nfsserver/nfs_nfsdport.c Thu Jan 23 00:46:29 2014 (r261067) @@ -61,6 +61,7 @@ extern struct nfsv4lock nfsd_suspend_loc struct vfsoptlist nfsv4root_opt, nfsv4root_newopt; NFSDLOCKMUTEX; struct nfsrchash_bucket nfsrchash_table[NFSRVCACHE_HASHSIZE]; +struct nfsrchash_bucket nfsrcahash_table[NFSRVCACHE_HASHSIZE]; struct mtx nfsrc_udpmtx; struct mtx nfs_v4root_mutex; struct nfsrvfh nfs_rootfh, nfs_pubfh; @@ -2894,40 +2895,6 @@ out: } /* - * Get the tcp socket sequence numbers we need. - * (Maybe this should be moved to the tcp sources?) - */ -int -nfsrv_getsocksndseq(struct socket *so, tcp_seq *maxp, tcp_seq *unap) -{ - struct inpcb *inp; - struct tcpcb *tp; - int error = 0; - - inp = sotoinpcb(so); - KASSERT(inp != NULL, ("nfsrv_getsocksndseq: inp == NULL")); - INP_RLOCK(inp); - if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { - INP_RUNLOCK(inp); - error = EPIPE; - goto out; - } - tp = intotcpcb(inp); - if (tp->t_state != TCPS_ESTABLISHED) { - INP_RUNLOCK(inp); - error = EPIPE; - goto out; - } - *maxp = tp->snd_max; - *unap = tp->snd_una; - INP_RUNLOCK(inp); - -out: - NFSEXITCODE(error); - return (error); -} - -/* * This function needs to test to see if the system is near its limit * for memory allocation via malloc() or mget() and return True iff * either of these resources are near their limit. @@ -3350,6 +3317,11 @@ nfsd_modevent(module_t mod, int type, vo i); mtx_init(&nfsrchash_table[i].mtx, nfsrchash_table[i].lock_name, NULL, MTX_DEF); + snprintf(nfsrcahash_table[i].lock_name, + sizeof(nfsrcahash_table[i].lock_name), "nfsrc_tcpa%d", + i); + mtx_init(&nfsrcahash_table[i].mtx, + nfsrcahash_table[i].lock_name, NULL, MTX_DEF); } mtx_init(&nfsrc_udpmtx, "nfs_udpcache_mutex", NULL, MTX_DEF); mtx_init(&nfs_v4root_mutex, "nfs_v4root_mutex", NULL, MTX_DEF); @@ -3395,8 +3367,10 @@ nfsd_modevent(module_t mod, int type, vo svcpool_destroy(nfsrvd_pool); /* and get rid of the locks */ - for (i = 0; i < NFSRVCACHE_HASHSIZE; i++) + for (i = 0; i < NFSRVCACHE_HASHSIZE; i++) { mtx_destroy(&nfsrchash_table[i].mtx); + mtx_destroy(&nfsrcahash_table[i].mtx); + } mtx_destroy(&nfsrc_udpmtx); mtx_destroy(&nfs_v4root_mutex); mtx_destroy(&nfsv4root_mnt.mnt_mtx); Modified: stable/9/sys/fs/nfsserver/nfs_nfsdsubs.c ============================================================================== --- stable/9/sys/fs/nfsserver/nfs_nfsdsubs.c Thu Jan 23 00:45:20 2014 (r261066) +++ stable/9/sys/fs/nfsserver/nfs_nfsdsubs.c Thu Jan 23 00:46:29 2014 (r261067) @@ -1987,47 +1987,6 @@ nfsmout: return (error); } -/* - * Check the tcp socket sequence number has been acknowledged. - */ -int -nfsrv_checksockseqnum(struct socket *so, tcp_seq tcpseqval) -{ - tcp_seq maxseq, unaseq; - int error, ret; - - error = nfsrv_getsocksndseq(so, &maxseq, &unaseq); - if (error) - return (0); - ret = SEQ_GEQ(unaseq, tcpseqval); - return (ret); -} - -/* - * Get the tcp sequence number to be acknowledged. - */ -int -nfsrv_getsockseqnum(struct socket *so, tcp_seq *tcpseqp) -{ - tcp_seq maxseq, unaseq; - u_int sbcc; - int error; - - sbcc = so->so_snd.sb_cc; - error = nfsrv_getsocksndseq(so, &maxseq, &unaseq); - if (error) - return (0); - /* - * Set the seq# to a value that will - * be at least the end of the reply. - * When this sequence# is acknowledged - * by the client, the client has received - * the reply. - */ - *tcpseqp = sbcc + maxseq; - return (1); -} - void nfsd_init(void) { Modified: stable/9/sys/rpc/svc.c ============================================================================== --- stable/9/sys/rpc/svc.c Thu Jan 23 00:45:20 2014 (r261066) +++ stable/9/sys/rpc/svc.c Thu Jan 23 00:46:29 2014 (r261067) @@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -93,6 +94,7 @@ svcpool_create(const char *name, struct TAILQ_INIT(&pool->sp_xlist); TAILQ_INIT(&pool->sp_active); TAILQ_INIT(&pool->sp_callouts); + TAILQ_INIT(&pool->sp_lcallouts); LIST_INIT(&pool->sp_threads); LIST_INIT(&pool->sp_idlethreads); pool->sp_minthreads = 1; @@ -158,6 +160,7 @@ svcpool_destroy(SVCPOOL *pool) { SVCXPRT *xprt, *nxprt; struct svc_callout *s; + struct svc_loss_callout *sl; struct svcxprt_list cleanup; TAILQ_INIT(&cleanup); @@ -169,12 +172,16 @@ svcpool_destroy(SVCPOOL *pool) TAILQ_INSERT_TAIL(&cleanup, xprt, xp_link); } - while (TAILQ_FIRST(&pool->sp_callouts)) { - s = TAILQ_FIRST(&pool->sp_callouts); + while ((s = TAILQ_FIRST(&pool->sp_callouts)) != NULL) { mtx_unlock(&pool->sp_lock); svc_unreg(pool, s->sc_prog, s->sc_vers); mtx_lock(&pool->sp_lock); } + while ((sl = TAILQ_FIRST(&pool->sp_lcallouts)) != NULL) { + mtx_unlock(&pool->sp_lock); + svc_loss_unreg(pool, sl->slc_dispatch); + mtx_lock(&pool->sp_lock); + } mtx_unlock(&pool->sp_lock); TAILQ_FOREACH_SAFE(xprt, &cleanup, xp_link, nxprt) { @@ -511,6 +518,55 @@ svc_unreg(SVCPOOL *pool, const rpcprog_t mtx_unlock(&pool->sp_lock); } +/* + * Add a service connection loss program to the callout list. + * The dispatch routine will be called when some port in ths pool die. + */ +bool_t +svc_loss_reg(SVCXPRT *xprt, void (*dispatch)(SVCXPRT *)) +{ + SVCPOOL *pool = xprt->xp_pool; + struct svc_loss_callout *s; + + mtx_lock(&pool->sp_lock); + TAILQ_FOREACH(s, &pool->sp_lcallouts, slc_link) { + if (s->slc_dispatch == dispatch) + break; + } + if (s != NULL) { + mtx_unlock(&pool->sp_lock); + return (TRUE); + } + s = malloc(sizeof (struct svc_callout), M_RPC, M_NOWAIT); + if (s == NULL) { + mtx_unlock(&pool->sp_lock); + return (FALSE); + } + s->slc_dispatch = dispatch; + TAILQ_INSERT_TAIL(&pool->sp_lcallouts, s, slc_link); + mtx_unlock(&pool->sp_lock); + return (TRUE); +} + +/* + * Remove a service connection loss program from the callout list. + */ +void +svc_loss_unreg(SVCPOOL *pool, void (*dispatch)(SVCXPRT *)) +{ + struct svc_loss_callout *s; + + mtx_lock(&pool->sp_lock); + TAILQ_FOREACH(s, &pool->sp_lcallouts, slc_link) { + if (s->slc_dispatch == dispatch) { + TAILQ_REMOVE(&pool->sp_lcallouts, s, slc_link); + free(s, M_RPC); + break; + } + } + mtx_unlock(&pool->sp_lock); +} + /* ********************** CALLOUT list related stuff ************* */ /* @@ -554,7 +610,7 @@ svc_sendreply_common(struct svc_req *rqs if (!SVCAUTH_WRAP(&rqstp->rq_auth, &body)) return (FALSE); - ok = SVC_REPLY(xprt, rply, rqstp->rq_addr, body); + ok = SVC_REPLY(xprt, rply, rqstp->rq_addr, body, &rqstp->rq_reply_seq); if (rqstp->rq_addr) { free(rqstp->rq_addr, M_SONAME); rqstp->rq_addr = NULL; @@ -805,6 +861,7 @@ svc_getreq(SVCXPRT *xprt, struct svc_req struct svc_req *r; struct rpc_msg msg; struct mbuf *args; + struct svc_loss_callout *s; enum xprt_stat stat; /* now receive msgs from xprtprt (support batch calls) */ @@ -833,7 +890,7 @@ svc_getreq(SVCXPRT *xprt, struct svc_req break; case RS_DONE: SVC_REPLY(xprt, &repmsg, r->rq_addr, - repbody); + repbody, &r->rq_reply_seq); if (r->rq_addr) { free(r->rq_addr, M_SONAME); r->rq_addr = NULL; @@ -883,6 +940,8 @@ call_done: r = NULL; } if ((stat = SVC_STAT(xprt)) == XPRT_DIED) { + TAILQ_FOREACH(s, &pool->sp_lcallouts, slc_link) + (*s->slc_dispatch)(xprt); xprt_unregister(xprt); } Modified: stable/9/sys/rpc/svc.h ============================================================================== --- stable/9/sys/rpc/svc.h Thu Jan 23 00:45:20 2014 (r261066) +++ stable/9/sys/rpc/svc.h Thu Jan 23 00:46:29 2014 (r261067) @@ -103,9 +103,11 @@ struct xp_ops { struct sockaddr **, struct mbuf **); /* get transport status */ enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *); + /* get transport acknowledge sequence */ + bool_t (*xp_ack)(struct __rpc_svcxprt *, uint32_t *); /* send reply */ bool_t (*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *, - struct sockaddr *, struct mbuf *); + struct sockaddr *, struct mbuf *, uint32_t *); /* destroy this struct */ void (*xp_destroy)(struct __rpc_svcxprt *); /* catch-all function */ @@ -166,6 +168,8 @@ typedef struct __rpc_svcxprt { time_t xp_lastactive; /* time of last RPC */ u_int64_t xp_sockref; /* set by nfsv4 to identify socket */ int xp_upcallset; /* socket upcall is set up */ + uint32_t xp_snd_cnt; /* # of bytes to send to socket */ + uint32_t xp_snt_cnt; /* # of bytes sent to socket */ #else int xp_fd; u_short xp_port; /* associated port number */ @@ -230,6 +234,17 @@ struct svc_callout { }; TAILQ_HEAD(svc_callout_list, svc_callout); +/* + * The services connection loss list + * The dispatch routine takes request structs and runs the + * apropriate procedure. + */ +struct svc_loss_callout { + TAILQ_ENTRY(svc_loss_callout) slc_link; + void (*slc_dispatch)(SVCXPRT *); +}; +TAILQ_HEAD(svc_loss_callout_list, svc_loss_callout); + struct __rpc_svcthread; /* @@ -253,6 +268,7 @@ struct svc_req { void *rq_p1; /* application workspace */ int rq_p2; /* application workspace */ uint64_t rq_p3; /* application workspace */ + uint32_t rq_reply_seq; /* reply socket sequence # */ char rq_credarea[3*MAX_AUTH_BYTES]; }; STAILQ_HEAD(svc_reqlist, svc_req); @@ -311,13 +327,14 @@ enum svcpool_state { typedef SVCTHREAD *pool_assign_fn(SVCTHREAD *, struct svc_req *); typedef void pool_done_fn(SVCTHREAD *, struct svc_req *); typedef struct __rpc_svcpool { - struct mtx sp_lock; /* protect the transport lists */ + struct mtx_padalign sp_lock; /* protect the transport lists */ const char *sp_name; /* pool name (e.g. "nfsd", "NLM" */ enum svcpool_state sp_state; /* current pool state */ struct proc *sp_proc; /* process which is in svc_run */ struct svcxprt_list sp_xlist; /* all transports in the pool */ struct svcxprt_list sp_active; /* transports needing service */ struct svc_callout_list sp_callouts; /* (prog,vers)->dispatch list */ + struct svc_loss_callout_list sp_lcallouts; /* loss->dispatch list */ struct svcthread_list sp_threads; /* service threads */ struct svcthread_list sp_idlethreads; /* idle service threads */ int sp_minthreads; /* minimum service thread count */ @@ -393,8 +410,12 @@ struct svc_req { #define SVC_STAT(xprt) \ (*(xprt)->xp_ops->xp_stat)(xprt) -#define SVC_REPLY(xprt, msg, addr, m) \ - (*(xprt)->xp_ops->xp_reply) ((xprt), (msg), (addr), (m)) +#define SVC_ACK(xprt, ack) \ + ((xprt)->xp_ops->xp_ack == NULL ? FALSE : \ + ((ack) == NULL ? TRUE : (*(xprt)->xp_ops->xp_ack)((xprt), (ack)))) + +#define SVC_REPLY(xprt, msg, addr, m, seq) \ + (*(xprt)->xp_ops->xp_reply) ((xprt), (msg), (addr), (m), (seq)) #define SVC_DESTROY(xprt) \ (*(xprt)->xp_ops->xp_destroy)(xprt) @@ -495,6 +516,32 @@ extern void svc_unreg(const rpcprog_t, c #endif __END_DECLS +#ifdef _KERNEL +/* + * Service connection loss registration + * + * svc_loss_reg(xprt, dispatch) + * const SVCXPRT *xprt; + * const void (*dispatch)(); + */ + +__BEGIN_DECLS +extern bool_t svc_loss_reg(SVCXPRT *, void (*)(SVCXPRT *)); +__END_DECLS + +/* + * Service connection loss un-registration + * + * svc_loss_unreg(xprt, dispatch) + * const SVCXPRT *xprt; + * const void (*dispatch)(); + */ + +__BEGIN_DECLS +extern void svc_loss_unreg(SVCPOOL *, void (*)(SVCXPRT *)); +__END_DECLS +#endif + /* * Transport registration. * Modified: stable/9/sys/rpc/svc_dg.c ============================================================================== --- stable/9/sys/rpc/svc_dg.c Thu Jan 23 00:45:20 2014 (r261066) +++ stable/9/sys/rpc/svc_dg.c Thu Jan 23 00:46:29 2014 (r261067) @@ -66,7 +66,7 @@ static enum xprt_stat svc_dg_stat(SVCXPR static bool_t svc_dg_recv(SVCXPRT *, struct rpc_msg *, struct sockaddr **, struct mbuf **); static bool_t svc_dg_reply(SVCXPRT *, struct rpc_msg *, - struct sockaddr *, struct mbuf *); + struct sockaddr *, struct mbuf *, uint32_t *); static void svc_dg_destroy(SVCXPRT *); static bool_t svc_dg_control(SVCXPRT *, const u_int, void *); static int svc_dg_soupcall(struct socket *so, void *arg, int waitflag); @@ -230,7 +230,7 @@ svc_dg_recv(SVCXPRT *xprt, struct rpc_ms static bool_t svc_dg_reply(SVCXPRT *xprt, struct rpc_msg *msg, - struct sockaddr *addr, struct mbuf *m) + struct sockaddr *addr, struct mbuf *m, uint32_t *seq) { XDR xdrs; struct mbuf *mrep; Modified: stable/9/sys/rpc/svc_vc.c ============================================================================== --- stable/9/sys/rpc/svc_vc.c Thu Jan 23 00:45:20 2014 (r261066) +++ stable/9/sys/rpc/svc_vc.c Thu Jan 23 00:46:29 2014 (r261067) @@ -76,10 +76,11 @@ static void svc_vc_rendezvous_destroy(SV static bool_t svc_vc_null(void); static void svc_vc_destroy(SVCXPRT *); static enum xprt_stat svc_vc_stat(SVCXPRT *); +static bool_t svc_vc_ack(SVCXPRT *, uint32_t *); static bool_t svc_vc_recv(SVCXPRT *, struct rpc_msg *, struct sockaddr **, struct mbuf **); static bool_t svc_vc_reply(SVCXPRT *, struct rpc_msg *, - struct sockaddr *, struct mbuf *); + struct sockaddr *, struct mbuf *, uint32_t *seq); static bool_t svc_vc_control(SVCXPRT *xprt, const u_int rq, void *in); static bool_t svc_vc_rendezvous_control (SVCXPRT *xprt, const u_int rq, void *in); @@ -88,7 +89,7 @@ static enum xprt_stat svc_vc_backchannel static bool_t svc_vc_backchannel_recv(SVCXPRT *, struct rpc_msg *, struct sockaddr **, struct mbuf **); static bool_t svc_vc_backchannel_reply(SVCXPRT *, struct rpc_msg *, - struct sockaddr *, struct mbuf *); + struct sockaddr *, struct mbuf *, uint32_t *); static bool_t svc_vc_backchannel_control(SVCXPRT *xprt, const u_int rq, void *in); static SVCXPRT *svc_vc_create_conn(SVCPOOL *pool, struct socket *so, @@ -100,7 +101,7 @@ static struct xp_ops svc_vc_rendezvous_o .xp_recv = svc_vc_rendezvous_recv, .xp_stat = svc_vc_rendezvous_stat, .xp_reply = (bool_t (*)(SVCXPRT *, struct rpc_msg *, - struct sockaddr *, struct mbuf *))svc_vc_null, + struct sockaddr *, struct mbuf *, uint32_t *))svc_vc_null, .xp_destroy = svc_vc_rendezvous_destroy, .xp_control = svc_vc_rendezvous_control }; @@ -108,6 +109,7 @@ static struct xp_ops svc_vc_rendezvous_o static struct xp_ops svc_vc_ops = { .xp_recv = svc_vc_recv, .xp_stat = svc_vc_stat, + .xp_ack = svc_vc_ack, .xp_reply = svc_vc_reply, .xp_destroy = svc_vc_destroy, .xp_control = svc_vc_control @@ -184,8 +186,10 @@ svc_vc_create(SVCPOOL *pool, struct sock return (xprt); cleanup_svc_vc_create: - if (xprt) + if (xprt) { + sx_destroy(&xprt->xp_lock); svc_xprt_free(xprt); + } return (NULL); } @@ -270,7 +274,8 @@ svc_vc_create_conn(SVCPOOL *pool, struct return (xprt); cleanup_svc_vc_create: if (xprt) { - mem_free(xprt, sizeof(*xprt)); + sx_destroy(&xprt->xp_lock); + svc_xprt_free(xprt); } if (cd) mem_free(cd, sizeof(*cd)); @@ -451,7 +456,6 @@ svc_vc_destroy_common(SVCXPRT *xprt) } SOCKBUF_UNLOCK(&xprt->xp_socket->so_rcv); - sx_destroy(&xprt->xp_lock); if (xprt->xp_socket) (void)soclose(xprt->xp_socket); @@ -537,6 +541,15 @@ svc_vc_stat(SVCXPRT *xprt) return (XPRT_IDLE); } +static bool_t +svc_vc_ack(SVCXPRT *xprt, uint32_t *ack) +{ + + *ack = atomic_load_acq_32(&xprt->xp_snt_cnt); + *ack -= xprt->xp_socket->so_snd.sb_cc; + return (TRUE); +} + static enum xprt_stat svc_vc_backchannel_stat(SVCXPRT *xprt) { @@ -785,12 +798,12 @@ svc_vc_backchannel_recv(SVCXPRT *xprt, s static bool_t svc_vc_reply(SVCXPRT *xprt, struct rpc_msg *msg, - struct sockaddr *addr, struct mbuf *m) + struct sockaddr *addr, struct mbuf *m, uint32_t *seq) { XDR xdrs; struct mbuf *mrep; bool_t stat = TRUE; - int error; + int error, len; /* * Leave space for record mark. @@ -818,14 +831,19 @@ svc_vc_reply(SVCXPRT *xprt, struct rpc_m * Prepend a record marker containing the reply length. */ M_PREPEND(mrep, sizeof(uint32_t), M_WAIT); + len = mrep->m_pkthdr.len; *mtod(mrep, uint32_t *) = - htonl(0x80000000 | (mrep->m_pkthdr.len - - sizeof(uint32_t))); + htonl(0x80000000 | (len - sizeof(uint32_t))); + atomic_add_acq_32(&xprt->xp_snd_cnt, len); error = sosend(xprt->xp_socket, NULL, NULL, mrep, NULL, 0, curthread); if (!error) { + atomic_add_rel_32(&xprt->xp_snt_cnt, len); + if (seq) + *seq = xprt->xp_snd_cnt; stat = TRUE; - } + } else + atomic_subtract_32(&xprt->xp_snd_cnt, len); } else { m_freem(mrep); } @@ -838,7 +856,7 @@ svc_vc_reply(SVCXPRT *xprt, struct rpc_m static bool_t svc_vc_backchannel_reply(SVCXPRT *xprt, struct rpc_msg *msg, - struct sockaddr *addr, struct mbuf *m) + struct sockaddr *addr, struct mbuf *m, uint32_t *seq) { struct ct_data *ct; XDR xdrs; From owner-svn-src-stable-9@FreeBSD.ORG Thu Jan 23 17:27:17 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 93F15F4; Thu, 23 Jan 2014 17:27:17 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 7FCDB15D2; Thu, 23 Jan 2014 17:27:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0NHRHoH039984; Thu, 23 Jan 2014 17:27:17 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0NHRH9A039978; Thu, 23 Jan 2014 17:27:17 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401231727.s0NHRH9A039978@svn.freebsd.org> From: Alexander Motin Date: Thu, 23 Jan 2014 17:27:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261082 - stable/9/sys/rpc X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jan 2014 17:27:17 -0000 Author: mav Date: Thu Jan 23 17:27:16 2014 New Revision: 261082 URL: http://svnweb.freebsd.org/changeset/base/261082 Log: Fix build on stable/9. I am sorry. :( Modified: stable/9/sys/rpc/svc.h stable/9/sys/rpc/svc_vc.c Modified: stable/9/sys/rpc/svc.h ============================================================================== --- stable/9/sys/rpc/svc.h Thu Jan 23 17:26:28 2014 (r261081) +++ stable/9/sys/rpc/svc.h Thu Jan 23 17:27:16 2014 (r261082) @@ -327,7 +327,7 @@ enum svcpool_state { typedef SVCTHREAD *pool_assign_fn(SVCTHREAD *, struct svc_req *); typedef void pool_done_fn(SVCTHREAD *, struct svc_req *); typedef struct __rpc_svcpool { - struct mtx_padalign sp_lock; /* protect the transport lists */ + struct mtx sp_lock; /* protect the transport lists */ const char *sp_name; /* pool name (e.g. "nfsd", "NLM" */ enum svcpool_state sp_state; /* current pool state */ struct proc *sp_proc; /* process which is in svc_run */ Modified: stable/9/sys/rpc/svc_vc.c ============================================================================== --- stable/9/sys/rpc/svc_vc.c Thu Jan 23 17:26:28 2014 (r261081) +++ stable/9/sys/rpc/svc_vc.c Thu Jan 23 17:27:16 2014 (r261082) @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); */ #include +#include #include #include #include From owner-svn-src-stable-9@FreeBSD.ORG Fri Jan 24 07:27:11 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A53B231B; Fri, 24 Jan 2014 07:27:11 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 904C01DB3; Fri, 24 Jan 2014 07:27:11 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0O7RBEg003235; Fri, 24 Jan 2014 07:27:11 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0O7RB6m003234; Fri, 24 Jan 2014 07:27:11 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201401240727.s0O7RB6m003234@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 24 Jan 2014 07:27:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261097 - stable/9/sys/dev/usb/controller X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jan 2014 07:27:11 -0000 Author: hselasky Date: Fri Jan 24 07:27:11 2014 New Revision: 261097 URL: http://svnweb.freebsd.org/changeset/base/261097 Log: MFC r260388, r260535 and r260536: Fix XHCI interrupt logic for "Intel Lynx Point" found in MBP2013. Modified: stable/9/sys/dev/usb/controller/xhci.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/usb/controller/xhci.c ============================================================================== --- stable/9/sys/dev/usb/controller/xhci.c Fri Jan 24 07:24:40 2014 (r261096) +++ stable/9/sys/dev/usb/controller/xhci.c Fri Jan 24 07:27:11 2014 (r261097) @@ -1544,23 +1544,26 @@ void xhci_interrupt(struct xhci_softc *sc) { uint32_t status; + uint32_t temp; USB_BUS_LOCK(&sc->sc_bus); status = XREAD4(sc, oper, XHCI_USBSTS); - if (status == 0) - goto done; - /* acknowledge interrupts */ + /* acknowledge interrupts, if any */ + if (status != 0) { + XWRITE4(sc, oper, XHCI_USBSTS, status); + DPRINTFN(16, "real interrupt (status=0x%08x)\n", status); + } - XWRITE4(sc, oper, XHCI_USBSTS, status); + temp = XREAD4(sc, runt, XHCI_IMAN(0)); - DPRINTFN(16, "real interrupt (status=0x%08x)\n", status); + /* force clearing of pending interrupts */ + if (temp & XHCI_IMAN_INTR_PEND) + XWRITE4(sc, runt, XHCI_IMAN(0), temp); - if (status & XHCI_STS_EINT) { - /* check for event(s) */ - xhci_interrupt_poll(sc); - } + /* check for event(s) */ + xhci_interrupt_poll(sc); if (status & (XHCI_STS_PCD | XHCI_STS_HCH | XHCI_STS_HSE | XHCI_STS_HCE)) { @@ -1584,7 +1587,6 @@ xhci_interrupt(struct xhci_softc *sc) __FUNCTION__); } } -done: USB_BUS_UNLOCK(&sc->sc_bus); } From owner-svn-src-stable-9@FreeBSD.ORG Fri Jan 24 07:33:55 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 93AAE6F7; Fri, 24 Jan 2014 07:33:55 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 73D461E3B; Fri, 24 Jan 2014 07:33:55 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0O7Xtrh006746; Fri, 24 Jan 2014 07:33:55 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0O7Xt0e006745; Fri, 24 Jan 2014 07:33:55 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201401240733.s0O7Xt0e006745@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 24 Jan 2014 07:33:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261100 - stable/9/sys/dev/usb/serial X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jan 2014 07:33:55 -0000 Author: hselasky Date: Fri Jan 24 07:33:54 2014 New Revision: 261100 URL: http://svnweb.freebsd.org/changeset/base/261100 Log: MFC r260559: Don't do synchronous USB requests inside USB transfer callbacks. It is technically OK, but not recommended. Modified: stable/9/sys/dev/usb/serial/umcs.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/usb/serial/umcs.c ============================================================================== --- stable/9/sys/dev/usb/serial/umcs.c Fri Jan 24 07:32:05 2014 (r261099) +++ stable/9/sys/dev/usb/serial/umcs.c Fri Jan 24 07:33:54 2014 (r261100) @@ -121,8 +121,6 @@ struct umcs7840_softc_oneport { uint8_t sc_lcr; /* local line control register */ uint8_t sc_mcr; /* local modem control register */ - uint8_t sc_lsr; /* local line status register */ - uint8_t sc_msr; /* local modem status register */ }; struct umcs7840_softc { @@ -535,12 +533,7 @@ umcs7840_cfg_open(struct ucom_softc *uco if (umcs7840_set_reg_sync(sc, umcs7840_port_registers[pn].reg_control, data)) return; - /* Read LSR & MSR */ - if (umcs7840_get_UART_reg_sync(sc, pn, MCS7840_UART_REG_LSR, &sc->sc_ports[pn].sc_lsr)) - return; - if (umcs7840_get_UART_reg_sync(sc, pn, MCS7840_UART_REG_MSR, &sc->sc_ports[pn].sc_msr)) - return; - DPRINTF("Port %d has been opened, LSR=%02x MSR=%02x\n", pn, sc->sc_ports[pn].sc_lsr, sc->sc_ports[pn].sc_msr); + DPRINTF("Port %d has been opened\n", pn); } static void @@ -748,9 +741,17 @@ static void umcs7840_cfg_get_status(struct ucom_softc *ucom, uint8_t *lsr, uint8_t *msr) { struct umcs7840_softc *sc = ucom->sc_parent; + uint8_t pn = ucom->sc_portno; + uint8_t hw_lsr = 0; /* local line status register */ + uint8_t hw_msr = 0; /* local modem status register */ + + /* Read LSR & MSR */ + umcs7840_get_UART_reg_sync(sc, pn, MCS7840_UART_REG_LSR, &hw_lsr); + umcs7840_get_UART_reg_sync(sc, pn, MCS7840_UART_REG_MSR, &hw_msr); + + *lsr = hw_lsr; + *msr = hw_msr; - *lsr = sc->sc_ports[ucom->sc_portno].sc_lsr; - *msr = sc->sc_ports[ucom->sc_portno].sc_msr; DPRINTF("Port %d status: LSR=%02x MSR=%02x\n", ucom->sc_portno, *lsr, *msr); } @@ -781,21 +782,11 @@ umcs7840_intr_callback(struct usb_xfer * case MCS7840_UART_ISR_RXERR: case MCS7840_UART_ISR_RXHASDATA: case MCS7840_UART_ISR_RXTIMEOUT: - /* Read new LSR */ - if (umcs7840_get_UART_reg_sync(sc, pn, MCS7840_UART_REG_LSR, &sc->sc_ports[pn].sc_lsr)) - break; /* Inner switch */ + case MCS7840_UART_ISR_MSCHANGE: ucom_status_change(&sc->sc_ucom[subunit]); - /* Inner switch */ break; - case MCS7840_UART_ISR_TXEMPTY: + default: /* Do nothing */ - break; /* Inner switch */ - case MCS7840_UART_ISR_MSCHANGE: - /* Read new MSR */ - if (umcs7840_get_UART_reg_sync(sc, pn, MCS7840_UART_REG_MSR, &sc->sc_ports[pn].sc_msr)) - break; /* Inner switch */ - DPRINTF("Port %d: new MSR %02x\n", pn, sc->sc_ports[pn].sc_msr); - ucom_status_change(&sc->sc_ucom[subunit]); break; } } From owner-svn-src-stable-9@FreeBSD.ORG Fri Jan 24 07:42:26 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C5B37DD5; Fri, 24 Jan 2014 07:42:26 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 972CE1EE4; Fri, 24 Jan 2014 07:42:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0O7gQeb010389; Fri, 24 Jan 2014 07:42:26 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0O7gQrT010388; Fri, 24 Jan 2014 07:42:26 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201401240742.s0O7gQrT010388@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 24 Jan 2014 07:42:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261103 - stable/9/sys/dev/usb/controller X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jan 2014 07:42:26 -0000 Author: hselasky Date: Fri Jan 24 07:42:26 2014 New Revision: 261103 URL: http://svnweb.freebsd.org/changeset/base/261103 Log: MFC r260563: Make sure reserved fields of the EHCI DMA descriptors are not dirty after previous transfers. Modified: stable/9/sys/dev/usb/controller/ehci.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/usb/controller/ehci.c ============================================================================== --- stable/9/sys/dev/usb/controller/ehci.c Fri Jan 24 07:40:58 2014 (r261102) +++ stable/9/sys/dev/usb/controller/ehci.c Fri Jan 24 07:42:26 2014 (r261103) @@ -1651,12 +1651,17 @@ restart: } td->len = 0; + /* properly reset reserved fields */ td->qtd_buffer[0] = 0; - td->qtd_buffer_hi[0] = 0; - td->qtd_buffer[1] = 0; + td->qtd_buffer[2] = 0; + td->qtd_buffer[3] = 0; + td->qtd_buffer[4] = 0; + td->qtd_buffer_hi[0] = 0; td->qtd_buffer_hi[1] = 0; - + td->qtd_buffer_hi[2] = 0; + td->qtd_buffer_hi[3] = 0; + td->qtd_buffer_hi[4] = 0; } else { uint8_t x; @@ -1711,6 +1716,12 @@ restart: htohc32(temp->sc, buf_res.physaddr & (~0xFFF)); td->qtd_buffer_hi[x] = 0; + + /* properly reset reserved fields */ + while (++x < EHCI_QTD_NBUFFERS) { + td->qtd_buffer[x] = 0; + td->qtd_buffer_hi[x] = 0; + } } if (td_next) { @@ -1998,6 +2009,18 @@ ehci_setup_standard_chain(struct usb_xfe qh->qh_qtd.qtd_altnext = htohc32(temp.sc, EHCI_LINK_TERMINATE); + /* properly reset reserved fields */ + qh->qh_qtd.qtd_buffer[0] = 0; + qh->qh_qtd.qtd_buffer[1] = 0; + qh->qh_qtd.qtd_buffer[2] = 0; + qh->qh_qtd.qtd_buffer[3] = 0; + qh->qh_qtd.qtd_buffer[4] = 0; + qh->qh_qtd.qtd_buffer_hi[0] = 0; + qh->qh_qtd.qtd_buffer_hi[1] = 0; + qh->qh_qtd.qtd_buffer_hi[2] = 0; + qh->qh_qtd.qtd_buffer_hi[3] = 0; + qh->qh_qtd.qtd_buffer_hi[4] = 0; + usb_pc_cpu_flush(qh->page_cache); if (xfer->xroot->udev->flags.self_suspended == 0) { From owner-svn-src-stable-9@FreeBSD.ORG Fri Jan 24 07:57:23 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BAA913B9; Fri, 24 Jan 2014 07:57:23 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A4DDD1FB8; Fri, 24 Jan 2014 07:57:23 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0O7vNPs014788; Fri, 24 Jan 2014 07:57:23 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0O7vMua014771; Fri, 24 Jan 2014 07:57:22 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201401240757.s0O7vMua014771@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 24 Jan 2014 07:57:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261106 - in stable/9/sys/dev/usb: . controller X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jan 2014 07:57:23 -0000 Author: hselasky Date: Fri Jan 24 07:57:21 2014 New Revision: 261106 URL: http://svnweb.freebsd.org/changeset/base/261106 Log: MFC r260588 and r260589: - Separate I/O errors from reception of STALL PID. - Implement better error recovery for Transaction Translators, TTs, found in High Speed USB HUBs which translate from High Speed USB into FULL or LOW speed USB. In some rare cases SPLIT transactions might get lost, which might leave the TT in an unknown state. Whenever we detect such an error try to issue either a clear TT buffer request, or if that is not possible reset the whole TT. Modified: stable/9/sys/dev/usb/controller/ehci.c stable/9/sys/dev/usb/controller/uhci.c stable/9/sys/dev/usb/usb_device.c stable/9/sys/dev/usb/usb_device.h stable/9/sys/dev/usb/usb_hub.c stable/9/sys/dev/usb/usb_hub.h stable/9/sys/dev/usb/usb_request.c stable/9/sys/dev/usb/usb_transfer.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/usb/controller/ehci.c ============================================================================== --- stable/9/sys/dev/usb/controller/ehci.c Fri Jan 24 07:48:52 2014 (r261105) +++ stable/9/sys/dev/usb/controller/ehci.c Fri Jan 24 07:57:21 2014 (r261106) @@ -1195,9 +1195,16 @@ ehci_non_isoc_done_sub(struct usb_xfer * (status & EHCI_QTD_PINGSTATE) ? "[PING]" : ""); } #endif - - return ((status & EHCI_QTD_HALTED) ? - USB_ERR_STALLED : USB_ERR_NORMAL_COMPLETION); + if (status & EHCI_QTD_HALTED) { + if ((xfer->xroot->udev->parent_hs_hub != NULL) || + (xfer->xroot->udev->address != 0)) { + /* try to separate I/O errors from STALL */ + if (EHCI_QTD_GET_CERR(status) == 0) + return (USB_ERR_IOERROR); + } + return (USB_ERR_STALLED); + } + return (USB_ERR_NORMAL_COMPLETION); } static void Modified: stable/9/sys/dev/usb/controller/uhci.c ============================================================================== --- stable/9/sys/dev/usb/controller/uhci.c Fri Jan 24 07:48:52 2014 (r261105) +++ stable/9/sys/dev/usb/controller/uhci.c Fri Jan 24 07:57:21 2014 (r261106) @@ -1176,8 +1176,13 @@ uhci_non_isoc_done_sub(struct usb_xfer * (status & UHCI_TD_SPD) ? "[SPD]" : ""); } #endif - return (status & UHCI_TD_STALLED) ? - USB_ERR_STALLED : USB_ERR_NORMAL_COMPLETION; + if (status & UHCI_TD_STALLED) { + /* try to separate I/O errors from STALL */ + if (UHCI_TD_GET_ERRCNT(status) == 0) + return (USB_ERR_IOERROR); + return (USB_ERR_STALLED); + } + return (USB_ERR_NORMAL_COMPLETION); } static void Modified: stable/9/sys/dev/usb/usb_device.c ============================================================================== --- stable/9/sys/dev/usb/usb_device.c Fri Jan 24 07:48:52 2014 (r261105) +++ stable/9/sys/dev/usb/usb_device.c Fri Jan 24 07:57:21 2014 (r261106) @@ -94,7 +94,7 @@ static void usb_init_attach_arg(struct u struct usb_attach_arg *); static void usb_suspend_resume_sub(struct usb_device *, device_t, uint8_t); -static void usbd_clear_stall_proc(struct usb_proc_msg *_pm); +static usb_proc_callback_t usbd_clear_stall_proc; static usb_error_t usb_config_parse(struct usb_device *, uint8_t, uint8_t); static void usbd_set_device_strings(struct usb_device *); #if USB_HAVE_DEVCTL @@ -1444,7 +1444,7 @@ usb_suspend_resume(struct usb_device *ud static void usbd_clear_stall_proc(struct usb_proc_msg *_pm) { - struct usb_clear_stall_msg *pm = (void *)_pm; + struct usb_udev_msg *pm = (void *)_pm; struct usb_device *udev = pm->udev; /* Change lock */ Modified: stable/9/sys/dev/usb/usb_device.h ============================================================================== --- stable/9/sys/dev/usb/usb_device.h Fri Jan 24 07:48:52 2014 (r261105) +++ stable/9/sys/dev/usb/usb_device.h Fri Jan 24 07:57:21 2014 (r261106) @@ -53,7 +53,7 @@ struct usb_symlink; /* UGEN */ #define USB_UNCFG_FLAG_NONE 0x00 #define USB_UNCFG_FLAG_FREE_EP0 0x02 /* endpoint zero is freed */ -struct usb_clear_stall_msg { +struct usb_udev_msg { struct usb_proc_msg hdr; struct usb_device *udev; }; @@ -179,8 +179,8 @@ union usb_device_scratch { * these structures for every USB device. */ struct usb_device { - struct usb_clear_stall_msg cs_msg[2]; /* generic clear stall - * messages */ + /* generic clear stall message */ + struct usb_udev_msg cs_msg[2]; struct sx enum_sx; struct sx sr_sx; struct mtx device_mtx; @@ -304,4 +304,10 @@ void usbd_sr_lock(struct usb_device *); void usbd_sr_unlock(struct usb_device *); uint8_t usbd_enum_is_locked(struct usb_device *); +#if USB_HAVE_TT_SUPPORT +void uhub_tt_buffer_reset_async_locked(struct usb_device *, struct usb_endpoint *); +#endif + +uint8_t uhub_count_active_host_ports(struct usb_device *, enum usb_dev_speed); + #endif /* _USB_DEVICE_H_ */ Modified: stable/9/sys/dev/usb/usb_hub.c ============================================================================== --- stable/9/sys/dev/usb/usb_hub.c Fri Jan 24 07:48:52 2014 (r261105) +++ stable/9/sys/dev/usb/usb_hub.c Fri Jan 24 07:57:21 2014 (r261106) @@ -70,7 +70,13 @@ #include #define UHUB_INTR_INTERVAL 250 /* ms */ -#define UHUB_N_TRANSFER 1 +enum { + UHUB_INTR_TRANSFER, +#if USB_HAVE_TT_SUPPORT + UHUB_RESET_TT_TRANSFER, +#endif + UHUB_N_TRANSFER, +}; #ifdef USB_DEBUG static int uhub_debug = 0; @@ -123,6 +129,9 @@ static bus_child_location_str_t uhub_chi static bus_child_pnpinfo_str_t uhub_child_pnpinfo_string; static usb_callback_t uhub_intr_callback; +#if USB_HAVE_TT_SUPPORT +static usb_callback_t uhub_reset_tt_callback; +#endif static void usb_dev_resume_peer(struct usb_device *udev); static void usb_dev_suspend_peer(struct usb_device *udev); @@ -130,7 +139,7 @@ static uint8_t usb_peer_should_wakeup(st static const struct usb_config uhub_config[UHUB_N_TRANSFER] = { - [0] = { + [UHUB_INTR_TRANSFER] = { .type = UE_INTERRUPT, .endpoint = UE_ADDR_ANY, .direction = UE_DIR_ANY, @@ -140,6 +149,17 @@ static const struct usb_config uhub_conf .callback = &uhub_intr_callback, .interval = UHUB_INTR_INTERVAL, }, +#if USB_HAVE_TT_SUPPORT + [UHUB_RESET_TT_TRANSFER] = { + .type = UE_CONTROL, + .endpoint = 0x00, /* Control pipe */ + .direction = UE_DIR_ANY, + .bufsize = sizeof(struct usb_device_request), + .callback = &uhub_reset_tt_callback, + .timeout = 1000, /* 1 second */ + .usb_mode = USB_MODE_HOST, + }, +#endif }; /* @@ -209,6 +229,199 @@ uhub_intr_callback(struct usb_xfer *xfer } /*------------------------------------------------------------------------* + * uhub_reset_tt_proc + * + * This function starts the TT reset USB request + *------------------------------------------------------------------------*/ +#if USB_HAVE_TT_SUPPORT +static void +uhub_reset_tt_proc(struct usb_proc_msg *_pm) +{ + struct usb_udev_msg *pm = (void *)_pm; + struct usb_device *udev = pm->udev; + struct usb_hub *hub; + struct uhub_softc *sc; + + hub = udev->hub; + if (hub == NULL) + return; + sc = hub->hubsoftc; + if (sc == NULL) + return; + + /* Change lock */ + USB_BUS_UNLOCK(udev->bus); + mtx_lock(&sc->sc_mtx); + /* Start transfer */ + usbd_transfer_start(sc->sc_xfer[UHUB_RESET_TT_TRANSFER]); + /* Change lock */ + mtx_unlock(&sc->sc_mtx); + USB_BUS_LOCK(udev->bus); +} +#endif + +/*------------------------------------------------------------------------* + * uhub_tt_buffer_reset_async_locked + * + * This function queues a TT reset for the given USB device and endpoint. + *------------------------------------------------------------------------*/ +#if USB_HAVE_TT_SUPPORT +void +uhub_tt_buffer_reset_async_locked(struct usb_device *child, struct usb_endpoint *ep) +{ + struct usb_device_request req; + struct usb_device *udev; + struct usb_hub *hub; + struct usb_port *up; + uint16_t wValue; + uint8_t port; + + if (child == NULL || ep == NULL) + return; + + udev = child->parent_hs_hub; + port = child->hs_port_no; + + if (udev == NULL) + return; + + hub = udev->hub; + if ((hub == NULL) || + (udev->speed != USB_SPEED_HIGH) || + (child->speed != USB_SPEED_LOW && + child->speed != USB_SPEED_FULL) || + (child->flags.usb_mode != USB_MODE_HOST) || + (port == 0) || (ep->edesc == NULL)) { + /* not applicable */ + return; + } + + USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED); + + up = hub->ports + port - 1; + + if (udev->ddesc.bDeviceClass == UDCLASS_HUB && + udev->ddesc.bDeviceProtocol == UDPROTO_HSHUBSTT) + port = 1; + + /* if we already received a clear buffer request, reset the whole TT */ + if (up->req_reset_tt.bRequest != 0) { + req.bmRequestType = UT_WRITE_CLASS_OTHER; + req.bRequest = UR_RESET_TT; + USETW(req.wValue, 0); + req.wIndex[0] = port; + req.wIndex[1] = 0; + USETW(req.wLength, 0); + } else { + wValue = (ep->edesc->bEndpointAddress & 0xF) | + ((child->address & 0x7F) << 4) | + ((ep->edesc->bEndpointAddress & 0x80) << 8) | + ((ep->edesc->bmAttributes & 3) << 12); + + req.bmRequestType = UT_WRITE_CLASS_OTHER; + req.bRequest = UR_CLEAR_TT_BUFFER; + USETW(req.wValue, wValue); + req.wIndex[0] = port; + req.wIndex[1] = 0; + USETW(req.wLength, 0); + } + up->req_reset_tt = req; + /* get reset transfer started */ + usb_proc_msignal(&udev->bus->non_giant_callback_proc, + &hub->tt_msg[0], &hub->tt_msg[1]); +} +#endif + +#if USB_HAVE_TT_SUPPORT +static void +uhub_reset_tt_callback(struct usb_xfer *xfer, usb_error_t error) +{ + struct uhub_softc *sc; + struct usb_device *udev; + struct usb_port *up; + uint8_t x; + + DPRINTF("TT buffer reset\n"); + + sc = usbd_xfer_softc(xfer); + udev = sc->sc_udev; + + switch (USB_GET_STATE(xfer)) { + case USB_ST_TRANSFERRED: + case USB_ST_SETUP: +tr_setup: + USB_BUS_LOCK(udev->bus); + /* find first port which needs a TT reset */ + for (x = 0; x != udev->hub->nports; x++) { + up = udev->hub->ports + x; + + if (up->req_reset_tt.bRequest == 0) + continue; + + /* copy in the transfer */ + usbd_copy_in(xfer->frbuffers, 0, &up->req_reset_tt, + sizeof(up->req_reset_tt)); + /* reset buffer */ + memset(&up->req_reset_tt, 0, sizeof(up->req_reset_tt)); + + /* set length */ + usbd_xfer_set_frame_len(xfer, 0, sizeof(up->req_reset_tt)); + xfer->nframes = 1; + USB_BUS_UNLOCK(udev->bus); + + usbd_transfer_submit(xfer); + return; + } + USB_BUS_UNLOCK(udev->bus); + break; + + default: + if (error == USB_ERR_CANCELLED) + break; + + DPRINTF("TT buffer reset failed (%s)\n", usbd_errstr(error)); + goto tr_setup; + } +} +#endif + +/*------------------------------------------------------------------------* + * uhub_count_active_host_ports + * + * This function counts the number of active ports at the given speed. + *------------------------------------------------------------------------*/ +uint8_t +uhub_count_active_host_ports(struct usb_device *udev, enum usb_dev_speed speed) +{ + struct uhub_softc *sc; + struct usb_device *child; + struct usb_hub *hub; + struct usb_port *up; + uint8_t retval = 0; + uint8_t x; + + if (udev == NULL) + goto done; + hub = udev->hub; + if (hub == NULL) + goto done; + sc = hub->hubsoftc; + if (sc == NULL) + goto done; + + for (x = 0; x != hub->nports; x++) { + up = hub->ports + x; + child = usb_bus_port_get_device(udev->bus, up); + if (child != NULL && + child->flags.usb_mode == USB_MODE_HOST && + child->speed == speed) + retval++; + } +done: + return (retval); +} + +/*------------------------------------------------------------------------* * uhub_explore_sub - subroutine * * Return values: @@ -1105,7 +1318,12 @@ uhub_attach(device_t dev) hub->explore = &uhub_explore; hub->nports = nports; hub->hubudev = udev; - +#if USB_HAVE_TT_SUPPORT + hub->tt_msg[0].hdr.pm_callback = &uhub_reset_tt_proc; + hub->tt_msg[0].udev = udev; + hub->tt_msg[1].hdr.pm_callback = &uhub_reset_tt_proc; + hub->tt_msg[1].udev = udev; +#endif /* if self powered hub, give ports maximum current */ if (udev->flags.self_powered) { hub->portpower = USB_MAX_POWER; @@ -1207,11 +1425,9 @@ uhub_attach(device_t dev) /* Start the interrupt endpoint, if any */ - if (sc->sc_xfer[0] != NULL) { - mtx_lock(&sc->sc_mtx); - usbd_transfer_start(sc->sc_xfer[0]); - mtx_unlock(&sc->sc_mtx); - } + mtx_lock(&sc->sc_mtx); + usbd_transfer_start(sc->sc_xfer[UHUB_INTR_TRANSFER]); + mtx_unlock(&sc->sc_mtx); /* Enable automatic power save on all USB HUBs */ @@ -1241,6 +1457,7 @@ uhub_detach(device_t dev) { struct uhub_softc *sc = device_get_softc(dev); struct usb_hub *hub = sc->sc_udev->hub; + struct usb_bus *bus = sc->sc_udev->bus; struct usb_device *child; uint8_t x; @@ -1253,7 +1470,7 @@ uhub_detach(device_t dev) /* Detach all ports */ for (x = 0; x != hub->nports; x++) { - child = usb_bus_port_get_device(sc->sc_udev->bus, hub->ports + x); + child = usb_bus_port_get_device(bus, hub->ports + x); if (child == NULL) { continue; @@ -1265,6 +1482,13 @@ uhub_detach(device_t dev) usb_free_device(child, 0); } +#if USB_HAVE_TT_SUPPORT + /* Make sure our TT messages are not queued anywhere */ + USB_BUS_LOCK(bus); + usb_proc_mwait(&bus->non_giant_callback_proc, + &hub->tt_msg[0], &hub->tt_msg[1]); + USB_BUS_UNLOCK(bus); +#endif free(hub, M_USBDEV); sc->sc_udev->hub = NULL; Modified: stable/9/sys/dev/usb/usb_hub.h ============================================================================== --- stable/9/sys/dev/usb/usb_hub.h Fri Jan 24 07:48:52 2014 (r261105) +++ stable/9/sys/dev/usb/usb_hub.h Fri Jan 24 07:57:21 2014 (r261106) @@ -35,6 +35,9 @@ struct usb_port { #define USB_RESTART_MAX 5 uint8_t device_index; /* zero means not valid */ enum usb_hc_mode usb_mode; /* host or device mode */ +#if USB_HAVE_TT_SUPPORT + struct usb_device_request req_reset_tt __aligned(4); +#endif }; /* @@ -44,6 +47,9 @@ struct usb_hub { struct usb_device *hubudev; /* the HUB device */ usb_error_t (*explore) (struct usb_device *hub); void *hubsoftc; +#if USB_HAVE_TT_SUPPORT + struct usb_udev_msg tt_msg[2]; +#endif usb_size_t uframe_usage[USB_HS_MICRO_FRAMES_MAX]; uint16_t portpower; /* mA per USB port */ uint8_t isoc_last_time; Modified: stable/9/sys/dev/usb/usb_request.c ============================================================================== --- stable/9/sys/dev/usb/usb_request.c Fri Jan 24 07:48:52 2014 (r261105) +++ stable/9/sys/dev/usb/usb_request.c Fri Jan 24 07:57:21 2014 (r261106) @@ -714,6 +714,17 @@ done: if ((mtx != NULL) && (mtx != &Giant)) mtx_lock(mtx); + switch (err) { + case USB_ERR_NORMAL_COMPLETION: + case USB_ERR_SHORT_XFER: + case USB_ERR_STALLED: + case USB_ERR_CANCELLED: + break; + default: + DPRINTF("I/O error - waiting a bit for TT cleanup\n"); + usb_pause_mtx(mtx, hz / 16); + break; + } return ((usb_error_t)err); } @@ -1965,6 +1976,7 @@ usbd_req_re_enumerate(struct usb_device return (USB_ERR_INVAL); } retry: +#if USB_HAVE_TT_SUPPORT /* * Try to reset the High Speed parent HUB of a LOW- or FULL- * speed device, if any. @@ -1972,15 +1984,24 @@ retry: if (udev->parent_hs_hub != NULL && udev->speed != USB_SPEED_HIGH) { DPRINTF("Trying to reset parent High Speed TT.\n"); - err = usbd_req_reset_tt(udev->parent_hs_hub, NULL, - udev->hs_port_no); + if (udev->parent_hs_hub == parent_hub && + (uhub_count_active_host_ports(parent_hub, USB_SPEED_LOW) + + uhub_count_active_host_ports(parent_hub, USB_SPEED_FULL)) == 1) { + /* we can reset the whole TT */ + err = usbd_req_reset_tt(parent_hub, NULL, + udev->hs_port_no); + } else { + /* only reset a particular device and endpoint */ + err = usbd_req_clear_tt_buffer(udev->parent_hs_hub, NULL, + udev->hs_port_no, old_addr, UE_CONTROL, 0); + } if (err) { DPRINTF("Resetting parent High " "Speed TT failed (%s).\n", usbd_errstr(err)); } } - +#endif /* Try to warm reset first */ if (parent_hub->speed == USB_SPEED_SUPER) usbd_req_warm_reset_port(parent_hub, mtx, udev->port_no); Modified: stable/9/sys/dev/usb/usb_transfer.c ============================================================================== --- stable/9/sys/dev/usb/usb_transfer.c Fri Jan 24 07:48:52 2014 (r261105) +++ stable/9/sys/dev/usb/usb_transfer.c Fri Jan 24 07:57:21 2014 (r261106) @@ -2366,7 +2366,9 @@ usbd_transfer_enqueue(struct usb_xfer_qu void usbd_transfer_done(struct usb_xfer *xfer, usb_error_t error) { - USB_BUS_LOCK_ASSERT(xfer->xroot->bus, MA_OWNED); + struct usb_xfer_root *info = xfer->xroot; + + USB_BUS_LOCK_ASSERT(info->bus, MA_OWNED); DPRINTF("err=%s\n", usbd_errstr(error)); @@ -2380,10 +2382,10 @@ usbd_transfer_done(struct usb_xfer *xfer xfer->flags_int.control_act = 0; return; } - /* only set transfer error if not already set */ - if (!xfer->error) { + /* only set transfer error, if not already set */ + if (xfer->error == USB_ERR_NORMAL_COMPLETION) xfer->error = error; - } + /* stop any callouts */ usb_callout_stop(&xfer->timeout_handle); @@ -2395,14 +2397,14 @@ usbd_transfer_done(struct usb_xfer *xfer usbd_transfer_dequeue(xfer); #if USB_HAVE_BUSDMA - if (mtx_owned(xfer->xroot->xfer_mtx)) { + if (mtx_owned(info->xfer_mtx)) { struct usb_xfer_queue *pq; /* * If the private USB lock is not locked, then we assume * that the BUS-DMA load stage has been passed: */ - pq = &xfer->xroot->dma_q; + pq = &info->dma_q; if (pq->curr == xfer) { /* start the next BUS-DMA load, if any */ @@ -2412,10 +2414,10 @@ usbd_transfer_done(struct usb_xfer *xfer #endif /* keep some statistics */ if (xfer->error) { - xfer->xroot->bus->stats_err.uds_requests + info->bus->stats_err.uds_requests [xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE]++; } else { - xfer->xroot->bus->stats_ok.uds_requests + info->bus->stats_ok.uds_requests [xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE]++; } @@ -2781,6 +2783,22 @@ usbd_callback_wrapper_sub(struct usb_xfe /* end of control transfer, if any */ xfer->flags_int.control_act = 0; +#if USB_HAVE_TT_SUPPORT + switch (xfer->error) { + case USB_ERR_NORMAL_COMPLETION: + case USB_ERR_SHORT_XFER: + case USB_ERR_STALLED: + case USB_ERR_CANCELLED: + /* nothing to do */ + break; + default: + /* try to reset the TT, if any */ + USB_BUS_LOCK(bus); + uhub_tt_buffer_reset_async_locked(xfer->xroot->udev, xfer->endpoint); + USB_BUS_UNLOCK(bus); + break; + } +#endif /* check if we should block the execution queue */ if ((xfer->error != USB_ERR_CANCELLED) && (xfer->flags.pipe_bof)) { From owner-svn-src-stable-9@FreeBSD.ORG Fri Jan 24 08:08:28 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D731E937; Fri, 24 Jan 2014 08:08:28 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C25B0109D; Fri, 24 Jan 2014 08:08:28 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0O88SD8019248; Fri, 24 Jan 2014 08:08:28 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0O88SGO019246; Fri, 24 Jan 2014 08:08:28 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201401240808.s0O88SGO019246@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 24 Jan 2014 08:08:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261109 - stable/9/sys/dev/usb X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jan 2014 08:08:28 -0000 Author: hselasky Date: Fri Jan 24 08:08:28 2014 New Revision: 261109 URL: http://svnweb.freebsd.org/changeset/base/261109 Log: MFC r260808 and r260814: - Close a minor deadlock. - Fix a possible memory use after free and leak situation associated with USB device detach when using character device handles. This also includes LibUSB. It turns out that "usb_close()" cannot always get a reference to clean up its USB transfers and such, if called during the kernel USB device detach. Modified: stable/9/sys/dev/usb/usb_dev.c stable/9/sys/dev/usb/usb_device.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/usb/usb_dev.c ============================================================================== --- stable/9/sys/dev/usb/usb_dev.c Fri Jan 24 08:06:14 2014 (r261108) +++ stable/9/sys/dev/usb/usb_dev.c Fri Jan 24 08:08:28 2014 (r261109) @@ -203,6 +203,11 @@ usb_ref_device(struct usb_cdev_privdata DPRINTFN(2, "no device at %u\n", cpd->dev_index); goto error; } + if (cpd->udev->state == USB_STATE_DETACHED && + (need_uref != 2)) { + DPRINTFN(2, "device is detached\n"); + goto error; + } if (cpd->udev->refcount == USB_DEV_REF_MAX) { DPRINTFN(2, "no dev ref\n"); goto error; @@ -593,6 +598,13 @@ usb_fifo_free(struct usb_fifo *f) mtx_unlock(f->priv_mtx); mtx_lock(&usb_ref_lock); + /* + * Check if the "f->refcount" variable reached zero + * during the unlocked time before entering wait: + */ + if (f->refcount == 0) + break; + /* wait for sync */ cv_wait(&f->cv_drain, &usb_ref_lock); } @@ -911,23 +923,12 @@ usb_close(void *arg) DPRINTFN(2, "cpd=%p\n", cpd); - err = usb_ref_device(cpd, &refs, 0); - if (err) + err = usb_ref_device(cpd, &refs, + 2 /* uref and allow detached state */); + if (err) { + DPRINTFN(0, "Cannot grab USB reference when " + "closing USB file handle\n"); goto done; - - /* - * If this function is not called directly from the root HUB - * thread, there is usually a need to lock the enumeration - * lock. Check this. - */ - if (!usbd_enum_is_locked(cpd->udev)) { - - DPRINTFN(2, "Locking enumeration\n"); - - /* reference device */ - err = usb_usb_ref_device(cpd, &refs); - if (err) - goto done; } if (cpd->fflags & FREAD) { usb_fifo_close(refs.rxfifo, cpd->fflags); Modified: stable/9/sys/dev/usb/usb_device.c ============================================================================== --- stable/9/sys/dev/usb/usb_device.c Fri Jan 24 08:06:14 2014 (r261108) +++ stable/9/sys/dev/usb/usb_device.c Fri Jan 24 08:08:28 2014 (r261109) @@ -2036,6 +2036,8 @@ usb_free_device(struct usb_device *udev, DPRINTFN(4, "udev=%p port=%d\n", udev, udev->port_no); bus = udev->bus; + + /* set DETACHED state to prevent any further references */ usb_set_device_state(udev, USB_STATE_DETACHED); #if USB_HAVE_DEVCTL @@ -2051,16 +2053,7 @@ usb_free_device(struct usb_device *udev, usb_free_symlink(udev->ugen_symlink); udev->ugen_symlink = NULL; } -#endif - /* - * Unregister our device first which will prevent any further - * references: - */ - usb_bus_port_set_device(bus, udev->parent_hub ? - udev->parent_hub->hub->ports + udev->port_index : NULL, - NULL, USB_ROOT_HUB_ADDR); -#if USB_HAVE_UGEN /* wait for all pending references to go away: */ mtx_lock(&usb_ref_lock); udev->refcount--; @@ -2080,6 +2073,11 @@ usb_free_device(struct usb_device *udev, /* the following will get the device unconfigured in software */ usb_unconfigure(udev, USB_UNCFG_FLAG_FREE_EP0); + /* final device unregister after all character devices are closed */ + usb_bus_port_set_device(bus, udev->parent_hub ? + udev->parent_hub->hub->ports + udev->port_index : NULL, + NULL, USB_ROOT_HUB_ADDR); + /* unsetup any leftover default USB transfers */ usbd_transfer_unsetup(udev->ctrl_xfer, USB_CTRL_XFER_MAX); @@ -2613,8 +2611,14 @@ usb_set_device_state(struct usb_device * DPRINTF("udev %p state %s -> %s\n", udev, usb_statestr(udev->state), usb_statestr(state)); - udev->state = state; +#if USB_HAVE_UGEN + mtx_lock(&usb_ref_lock); +#endif + udev->state = state; +#if USB_HAVE_UGEN + mtx_unlock(&usb_ref_lock); +#endif if (udev->bus->methods->device_state_change != NULL) (udev->bus->methods->device_state_change) (udev); } From owner-svn-src-stable-9@FreeBSD.ORG Fri Jan 24 08:16:20 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 859DEEBB; Fri, 24 Jan 2014 08:16:20 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 71110116D; Fri, 24 Jan 2014 08:16:20 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0O8GKWT023156; Fri, 24 Jan 2014 08:16:20 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0O8GKQN023155; Fri, 24 Jan 2014 08:16:20 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201401240816.s0O8GKQN023155@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 24 Jan 2014 08:16:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261112 - stable/9/sys/dev/usb/controller X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jan 2014 08:16:20 -0000 Author: hselasky Date: Fri Jan 24 08:16:19 2014 New Revision: 261112 URL: http://svnweb.freebsd.org/changeset/base/261112 Log: MFC r258545: Comply to the XHCI specification. Certain input context fields should always be zero. Modified: stable/9/sys/dev/usb/controller/xhci.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/usb/controller/xhci.c ============================================================================== --- stable/9/sys/dev/usb/controller/xhci.c Fri Jan 24 08:15:21 2014 (r261111) +++ stable/9/sys/dev/usb/controller/xhci.c Fri Jan 24 08:16:19 2014 (r261112) @@ -2544,7 +2544,11 @@ xhci_configure_device(struct usb_device xhci_ctx_set_le32(sc, &pinp->ctx_slot.dwSctx2, temp); - temp = XHCI_SCTX_3_DEV_ADDR_SET(udev->address) | + /* + * These fields should be initialized to zero, according to + * XHCI section 6.2.2 - slot context: + */ + temp = XHCI_SCTX_3_DEV_ADDR_SET(0) | XHCI_SCTX_3_SLOT_STATE_SET(0); xhci_ctx_set_le32(sc, &pinp->ctx_slot.dwSctx3, temp); From owner-svn-src-stable-9@FreeBSD.ORG Fri Jan 24 08:19:51 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 98F9623D; Fri, 24 Jan 2014 08:19:51 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 83FCD118C; Fri, 24 Jan 2014 08:19:51 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0O8Jp32023643; Fri, 24 Jan 2014 08:19:51 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0O8JpwQ023642; Fri, 24 Jan 2014 08:19:51 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201401240819.s0O8JpwQ023642@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 24 Jan 2014 08:19:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261114 - stable/9/sys/dev/usb/net X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jan 2014 08:19:51 -0000 Author: hselasky Date: Fri Jan 24 08:19:50 2014 New Revision: 261114 URL: http://svnweb.freebsd.org/changeset/base/261114 Log: MFC r260534: Move USB ID from u3g driver to uhso driver. Modified: stable/9/sys/dev/usb/net/uhso.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/usb/net/uhso.c ============================================================================== --- stable/9/sys/dev/usb/net/uhso.c Fri Jan 24 08:17:47 2014 (r261113) +++ stable/9/sys/dev/usb/net/uhso.c Fri Jan 24 08:19:50 2014 (r261114) @@ -268,6 +268,8 @@ static const STRUCT_USB_HOST_ID uhso_dev UHSO_DEV(OPTION, ICON401, UHSO_AUTO_IFACE), /* Option GlobeTrotter Module 382 */ UHSO_DEV(OPTION, GMT382, UHSO_AUTO_IFACE), + /* Option GTM661W */ + UHSO_DEV(OPTION, GTM661W, UHSO_AUTO_IFACE), /* Option iCON EDGE */ UHSO_DEV(OPTION, ICONEDGE, UHSO_STATIC_IFACE), /* Option Module HSxPA */