From owner-svn-src-head@freebsd.org Sun Aug 6 06:31:48 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CECFBDC6E20; Sun, 6 Aug 2017 06:31:48 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9EC4874FD5; Sun, 6 Aug 2017 06:31:48 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v766Vl7k052961; Sun, 6 Aug 2017 06:31:47 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v766VlJg052960; Sun, 6 Aug 2017 06:31:47 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201708060631.v766VlJg052960@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sun, 6 Aug 2017 06:31:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322112 - head/kerberos5/lib/libkafs5 X-SVN-Group: head X-SVN-Commit-Author: cy X-SVN-Commit-Paths: head/kerberos5/lib/libkafs5 X-SVN-Commit-Revision: 322112 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Aug 2017 06:31:48 -0000 Author: cy Date: Sun Aug 6 06:31:47 2017 New Revision: 322112 URL: https://svnweb.freebsd.org/changeset/base/322112 Log: krb5_err.h is generated from a .et file in kerberos5/lib/libkrb5. As kerberos5/lib/krb5 include files are already referenced it makes no sense to generate it again here. MFC after: 1 month Modified: head/kerberos5/lib/libkafs5/Makefile Modified: head/kerberos5/lib/libkafs5/Makefile ============================================================================== --- head/kerberos5/lib/libkafs5/Makefile Sat Aug 5 23:54:26 2017 (r322111) +++ head/kerberos5/lib/libkafs5/Makefile Sun Aug 6 06:31:47 2017 (r322112) @@ -22,7 +22,7 @@ MLINKS= kafs5.3 k_afs_cell_of_file.3 \ kafs5.3 krb_afslog.3 \ kafs5.3 krb_afslog_uid.3 -SRCS= afssys.c afskrb5.c common.c krb5_err.h +SRCS= afssys.c afskrb5.c common.c CFLAGS+= -I${KRB5DIR}/lib/kafs \ -I${KRB5DIR}/lib/krb5 \ From owner-svn-src-head@freebsd.org Sun Aug 6 06:35:42 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3E1E1DC73DB; Sun, 6 Aug 2017 06:35:42 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0BCF87532B; Sun, 6 Aug 2017 06:35:41 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v766Zfo7055992; Sun, 6 Aug 2017 06:35:41 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v766ZfU8055991; Sun, 6 Aug 2017 06:35:41 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201708060635.v766ZfU8055991@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sun, 6 Aug 2017 06:35:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322113 - head/kerberos5/libexec/ipropd-master X-SVN-Group: head X-SVN-Commit-Author: cy X-SVN-Commit-Paths: head/kerberos5/libexec/ipropd-master X-SVN-Commit-Revision: 322113 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Aug 2017 06:35:42 -0000 Author: cy Date: Sun Aug 6 06:35:40 2017 New Revision: 322113 URL: https://svnweb.freebsd.org/changeset/base/322113 Log: Remove dead target introduced in r178828. MFC after: 1 week Modified: head/kerberos5/libexec/ipropd-master/Makefile Modified: head/kerberos5/libexec/ipropd-master/Makefile ============================================================================== --- head/kerberos5/libexec/ipropd-master/Makefile Sun Aug 6 06:31:47 2017 (r322112) +++ head/kerberos5/libexec/ipropd-master/Makefile Sun Aug 6 06:35:40 2017 (r322113) @@ -10,9 +10,6 @@ DPADD= ${LDAPDPADD} LDADD= ${LDAPLDADD} LDFLAGS=${LDAPLDFLAGS} -foo:: - echo ${LIBHX509} - .include .PATH: ${KRB5DIR}/lib/kadm5 From owner-svn-src-head@freebsd.org Sun Aug 6 11:39:29 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2AC63DD4B1F; Sun, 6 Aug 2017 11:39:29 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by mx1.freebsd.org (Postfix) with ESMTP id E15DB82816; Sun, 6 Aug 2017 11:39:28 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 6FAF51047DC3; Sun, 6 Aug 2017 21:39:19 +1000 (AEST) Date: Sun, 6 Aug 2017 21:39:18 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Konstantin Belousov cc: Bruce Evans , Hans Petter Selasky , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r321920 - head/sys/sys In-Reply-To: <20170805074243.GX1700@kib.kiev.ua> Message-ID: <20170806213334.V1366@besplex.bde.org> References: <201708021014.v72AEHEk061037@repo.freebsd.org> <37abc595-c80e-a8da-04a8-815f42c634de@selasky.org> <20170802135455.GG1700@kib.kiev.ua> <20170803122015.Q1093@besplex.bde.org> <20170803075747.GJ1700@kib.kiev.ua> <20170803180419.R2314@besplex.bde.org> <20170803120729.GO1700@kib.kiev.ua> <20170805112924.W1055@besplex.bde.org> <20170805074243.GX1700@kib.kiev.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=KeqiiUQD c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=kj9zAlcOel0A:10 a=RFnRnYDGFsOq-WPcPKwA:9 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Aug 2017 11:39:29 -0000 On Sat, 5 Aug 2017, Konstantin Belousov wrote: > On Sat, Aug 05, 2017 at 12:26:03PM +1000, Bruce Evans wrote: >>> +#define minor(x) ((int)(x)) >> >> Another nice simplification. Strictly, it should be (int)(dev_t)(x) since >> the pseudo-prototype says that the arg is converted to dev_t, but yesterday >> I couldn't see any differences even for exotic x and exotic arches. >> >> Today I can see some difference for exotic x and perverse implementations. >> E.g., x with extra bits in a large signed integer type to invoke >> implementation-defined behaviour, and a perverse implementation that >> truncates to 0 for direct conversion to int but does the right thing >> for indirect conversion). But we depend on the implementation doing >> the right thing for other casts to int. >> >> Also, if dev_t == uintptr_t, it is valid for the caller to keep dev_t's >> in void *'s internally but not to pass void * to minor() or major() >> according to the prototype. However, casting in the macros breaks the >> warning for this. I think pure macros should not cast their args or >> pretend to have prototypes, but require callers to pass args of supported >> types. The old dev_t macros were closer to this -- they have expressions >> like ((x) << 8) which will fail if x is not an integral type or give >> wrong results ix x has extra bits. > So you are arguing to keep the & 0xffffffff operation ? No, I don't want to go that deep. > I think this is not needed, since your note about cast being equivalent > holds for all supported architectures and I do not see anywhere a contract > for the operations to work on non-dev_t. The pseudo-prototypes look like they provide such a contract. They must be read sort of backwards as saying that it is the caller's responsibility to pass args of the type in the pseudo-prototype, like for a K&R function or a C90 function with prototype is in scope. > So are you fine with the posted patch to sys/types.h ? OK. Bruce From owner-svn-src-head@freebsd.org Sun Aug 6 12:27:21 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CE8E5DD7829; Sun, 6 Aug 2017 12:27:21 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9D02384596; Sun, 6 Aug 2017 12:27:21 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v76CRKsI099109; Sun, 6 Aug 2017 12:27:20 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v76CRKmp099108; Sun, 6 Aug 2017 12:27:20 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201708061227.v76CRKmp099108@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 6 Aug 2017 12:27:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322118 - head/sys/sys X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/sys X-SVN-Commit-Revision: 322118 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Aug 2017 12:27:21 -0000 Author: kib Date: Sun Aug 6 12:27:20 2017 New Revision: 322118 URL: https://svnweb.freebsd.org/changeset/base/322118 Log: Remove trivial comments. Remove and-ing with UINT_MAX for minor(), cast to int already does the required truncation of significant bits. Requested and reviewed by: bde Sponsored by: The FreeBSD Foundation Modified: head/sys/sys/types.h Modified: head/sys/sys/types.h ============================================================================== --- head/sys/sys/types.h Sun Aug 6 10:07:25 2017 (r322117) +++ head/sys/sys/types.h Sun Aug 6 12:27:20 2017 (r322118) @@ -364,9 +364,9 @@ __bitcount64(__uint64_t _x) #include -#define major(x) ((int)((dev_t)(x) >> 32)) /* major number */ -#define minor(x) ((int)((x) & 0xffffffff)) /* minor number */ -#define makedev(x, y) (((dev_t)(x) << 32) | (unsigned)(y)) /* create dev_t */ +#define major(x) ((int)((dev_t)(x) >> 32)) +#define minor(x) ((int)(x)) +#define makedev(x, y) (((dev_t)(x) << 32) | (unsigned)(y)) /* * These declarations belong elsewhere, but are repeated here and in From owner-svn-src-head@freebsd.org Sun Aug 6 19:46:00 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EB72FDC5EDF; Sun, 6 Aug 2017 19:46:00 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ADA3E6B50D; Sun, 6 Aug 2017 19:46:00 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v76Jjx25077977; Sun, 6 Aug 2017 19:45:59 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v76Jjxxw077976; Sun, 6 Aug 2017 19:45:59 GMT (envelope-from np@FreeBSD.org) Message-Id: <201708061945.v76Jjxxw077976@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Sun, 6 Aug 2017 19:45:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322123 - head/sys/dev/cxgbe X-SVN-Group: head X-SVN-Commit-Author: np X-SVN-Commit-Paths: head/sys/dev/cxgbe X-SVN-Commit-Revision: 322123 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Aug 2017 19:46:01 -0000 Author: np Date: Sun Aug 6 19:45:59 2017 New Revision: 322123 URL: https://svnweb.freebsd.org/changeset/base/322123 Log: cxgbe(4): Avoid a NULL dereference that would occur during module unload if there were problems earlier during attach. MFC after: 3 days Sponsored by: Chelsio Communications Modified: head/sys/dev/cxgbe/t4_sched.c Modified: head/sys/dev/cxgbe/t4_sched.c ============================================================================== --- head/sys/dev/cxgbe/t4_sched.c Sun Aug 6 16:12:56 2017 (r322122) +++ head/sys/dev/cxgbe/t4_sched.c Sun Aug 6 19:45:59 2017 (r322123) @@ -382,8 +382,10 @@ t4_free_tx_sched(struct adapter *sc) taskqueue_drain(taskqueue_thread, &sc->tc_task); - for_each_port(sc, i) - free(sc->port[i]->sched_params, M_CXGBE); + for_each_port(sc, i) { + if (sc->port[i] != NULL) + free(sc->port[i]->sched_params, M_CXGBE); + } if (mtx_initialized(&sc->tc_lock)) mtx_destroy(&sc->tc_lock); From owner-svn-src-head@freebsd.org Sun Aug 6 21:54:44 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 90D67DCC1A4; Sun, 6 Aug 2017 21:54:44 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5C0376F601; Sun, 6 Aug 2017 21:54:44 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v76LshS9029771; Sun, 6 Aug 2017 21:54:43 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v76LshbH029770; Sun, 6 Aug 2017 21:54:43 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201708062154.v76LshbH029770@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Sun, 6 Aug 2017 21:54:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322124 - head/usr.sbin/bluetooth/rfcomm_pppd X-SVN-Group: head X-SVN-Commit-Author: avos X-SVN-Commit-Paths: head/usr.sbin/bluetooth/rfcomm_pppd X-SVN-Commit-Revision: 322124 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Aug 2017 21:54:44 -0000 Author: avos Date: Sun Aug 6 21:54:43 2017 New Revision: 322124 URL: https://svnweb.freebsd.org/changeset/base/322124 Log: rfcomm_pppd.8: fix a typo (SPD -> SDP). MFC after: 3 days Modified: head/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.8 Modified: head/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.8 ============================================================================== --- head/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.8 Sun Aug 6 19:45:59 2017 (r322123) +++ head/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.8 Sun Aug 6 21:54:43 2017 (r322124) @@ -348,7 +348,7 @@ label. The .Nm utility in server mode will try to register the Bluetooth LAN Access Over PPP -service with the local SPD daemon. +service with the local SDP daemon. If the local SDP daemon is not running, .Nm will exit with an error. From owner-svn-src-head@freebsd.org Mon Aug 7 08:45:10 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2065EDC4524; Mon, 7 Aug 2017 08:45:10 +0000 (UTC) (envelope-from gahr@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EF11716E3; Mon, 7 Aug 2017 08:45:09 +0000 (UTC) (envelope-from gahr@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v778j9V7092671; Mon, 7 Aug 2017 08:45:09 GMT (envelope-from gahr@FreeBSD.org) Received: (from gahr@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v778j8gS092667; Mon, 7 Aug 2017 08:45:08 GMT (envelope-from gahr@FreeBSD.org) Message-Id: <201708070845.v778j8gS092667@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gahr set sender to gahr@FreeBSD.org using -f From: Pietro Cerutti Date: Mon, 7 Aug 2017 08:45:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322139 - in head: contrib/top usr.bin/top X-SVN-Group: head X-SVN-Commit-Author: gahr X-SVN-Commit-Paths: in head: contrib/top usr.bin/top X-SVN-Commit-Revision: 322139 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 08:45:10 -0000 Author: gahr (ports committer) Date: Mon Aug 7 08:45:08 2017 New Revision: 322139 URL: https://svnweb.freebsd.org/changeset/base/322139 Log: Enhance top(1) to filter on multiple usernames Reviewed by: cognet, bapt Approved by: cognet MFC after: 1 week Relnotes: yes Differential Revision: https://reviews.freebsd.org/D11840 Modified: head/contrib/top/machine.h head/contrib/top/top.c head/contrib/top/top.xs head/usr.bin/top/machine.c Modified: head/contrib/top/machine.h ============================================================================== --- head/contrib/top/machine.h Mon Aug 7 07:40:00 2017 (r322138) +++ head/contrib/top/machine.h Mon Aug 7 08:45:08 2017 (r322139) @@ -70,7 +70,8 @@ struct process_select int self; /* show self */ int system; /* show system processes */ int thread; /* show threads */ - int uid; /* only this uid (unless uid == -1) */ +#define TOP_MAX_UIDS 8 + int uid[TOP_MAX_UIDS]; /* only these uids (unless uid[0] == -1) */ int wcpu; /* show weighted cpu */ int jid; /* only this jid (unless jid == -1) */ int jail; /* show jail ID */ Modified: head/contrib/top/top.c ============================================================================== --- head/contrib/top/top.c Mon Aug 7 07:40:00 2017 (r322138) +++ head/contrib/top/top.c Mon Aug 7 08:45:08 2017 (r322139) @@ -134,7 +134,110 @@ void (*d_process)(int line, char *thisline) = i_proces void reset_display(void); +static void +reset_uids() +{ + for (size_t i = 0; i < TOP_MAX_UIDS; ++i) + ps.uid[i] = -1; +} +static int +add_uid(int uid) +{ + size_t i = 0; + + /* Add the uid if there's room */ + for (; i < TOP_MAX_UIDS; ++i) + { + if (ps.uid[i] == -1 || ps.uid[i] == uid) + { + ps.uid[i] = uid; + break; + } + } + + return (i == TOP_MAX_UIDS); +} + +static void +rem_uid(int uid) +{ + size_t i = 0; + size_t where = TOP_MAX_UIDS; + + /* Look for the user to remove - no problem if it's not there */ + for (; i < TOP_MAX_UIDS; ++i) + { + if (ps.uid[i] == -1) + break; + if (ps.uid[i] == uid) + where = i; + } + + /* Make sure we don't leave a hole in the middle */ + if (where != TOP_MAX_UIDS) + { + ps.uid[where] = ps.uid[i-1]; + ps.uid[i-1] = -1; + } +} + +static int +handle_user(char *buf, size_t buflen) +{ + int rc = 0; + int uid = -1; + char *buf2 = buf; + + new_message(MT_standout, "Username to show (+ for all): "); + if (readline(buf, buflen, No) <= 0) + { + clear_message(); + return rc; + } + + if (buf[0] == '+' || buf[0] == '-') + { + if (buf[1] == '\0') + { + reset_uids(); + goto end; + } + else + ++buf2; + } + + if ((uid = userid(buf2)) == -1) + { + new_message(MT_standout, " %s: unknown user", buf2); + rc = 1; + goto end; + } + + if (buf2 == buf) + { + reset_uids(); + ps.uid[0] = uid; + goto end; + } + + if (buf[0] == '+') + { + if (add_uid(uid)) + { + new_message(MT_standout, " too many users, reset with '+'"); + rc = 1; + goto end; + } + } + else + rem_uid(uid); + +end: + putchar('\r'); + return rc; +} + int main(argc, argv) @@ -252,7 +355,7 @@ char *argv[]; ps.idle = Yes; ps.self = -1; ps.system = No; - ps.uid = -1; + reset_uids(); ps.thread = No; ps.wcpu = 1; ps.jid = -1; @@ -299,7 +402,7 @@ char *argv[]; break; case 'U': /* display only username's processes */ - if ((ps.uid = userid(optarg)) == -1) + if ((ps.uid[0] = userid(optarg)) == -1) { fprintf(stderr, "%s: unknown user\n", optarg); exit(1); @@ -1004,31 +1107,8 @@ restart: break; case CMD_user: - new_message(MT_standout, - "Username to show (+ for all): "); - if (readline(tempbuf2, sizeof(tempbuf2), No) > 0) - { - if (tempbuf2[0] == '+' && - tempbuf2[1] == '\0') - { - ps.uid = -1; - } - else if ((i = userid(tempbuf2)) == -1) - { - new_message(MT_standout, - " %s: unknown user", tempbuf2); - no_command = Yes; - } - else - { - ps.uid = i; - } - putchar('\r'); - } - else - { - clear_message(); - } + if (handle_user(tempbuf2, sizeof(tempbuf2))) + no_command = Yes; break; case CMD_thrtog: Modified: head/contrib/top/top.xs ============================================================================== --- head/contrib/top/top.xs Mon Aug 7 07:40:00 2017 (r322138) +++ head/contrib/top/top.xs Mon Aug 7 08:45:08 2017 (r322139) @@ -307,9 +307,11 @@ This acts similarly to the command .IR renice (8)). .TP .B u -Display only processes owned by a specific username (prompt for username). -If the username specified is simply \*(lq+\*(rq, then processes belonging -to all users will be displayed. +Display only processes owned by a specific set of usernames (prompt for +username). If the username specified is simply \*(lq+\*(rq or \*(lq-\*(rq, +then processes belonging to all users will be displayed. Usernames can be added +to and removed from the set by prepending them with \*(lq+\*(rq and +\*(lq-\*(rq, respectively. .TP .B o Change the order in which the display is sorted. This command is not Modified: head/usr.bin/top/machine.c ============================================================================== --- head/usr.bin/top/machine.c Mon Aug 7 07:40:00 2017 (r322138) +++ head/usr.bin/top/machine.c Mon Aug 7 08:45:08 2017 (r322139) @@ -273,7 +273,19 @@ static const char *format_nice(const struct kinfo_proc static void getsysctl(const char *name, void *ptr, size_t len); static int swapmode(int *retavail, int *retfree); static void update_layout(void); +static int find_uid(uid_t needle, int *haystack); +static int +find_uid(uid_t needle, int *haystack) +{ + size_t i = 0; + + for (; i < TOP_MAX_UIDS; ++i) + if ((uid_t)haystack[i] == needle) + return 1; + return 0; +} + void toggle_pcpustats(void) { @@ -847,7 +859,7 @@ get_process_info(struct system_info *si, struct proces show_jid = sel->jid != -1; show_self = sel->self == -1; show_system = sel->system; - show_uid = sel->uid != -1; + show_uid = sel->uid[0] != -1; show_command = sel->command != NULL; show_kidle = sel->kidle; @@ -906,7 +918,7 @@ get_process_info(struct system_info *si, struct proces /* skip proc. that don't belong to the selected JID */ continue; - if (show_uid && pp->ki_ruid != (uid_t)sel->uid) + if (show_uid && !find_uid(pp->ki_ruid, sel->uid)) /* skip proc. that don't belong to the selected UID */ continue; From owner-svn-src-head@freebsd.org Mon Aug 7 14:04:20 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9D7DFDD5786; Mon, 7 Aug 2017 14:04:20 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 788BE6D757; Mon, 7 Aug 2017 14:04:20 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77E4JLJ024046; Mon, 7 Aug 2017 14:04:19 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77E4JRQ024045; Mon, 7 Aug 2017 14:04:19 GMT (envelope-from np@FreeBSD.org) Message-Id: <201708071404.v77E4JRQ024045@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Mon, 7 Aug 2017 14:04:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322167 - head/sys/conf X-SVN-Group: head X-SVN-Commit-Author: np X-SVN-Commit-Paths: head/sys/conf X-SVN-Commit-Revision: 322167 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 14:04:20 -0000 Author: np Date: Mon Aug 7 14:04:19 2017 New Revision: 322167 URL: https://svnweb.freebsd.org/changeset/base/322167 Log: cxgbe(4): Add the T6 and T5 Unified Wire configuration files to the kernel, just like for T4, when the driver is compiled into the kernel. Reported by: mav@ MFC after: 3 days Sponsored by: Chelsio Communications Modified: head/sys/conf/files Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Mon Aug 7 13:27:35 2017 (r322166) +++ head/sys/conf/files Mon Aug 7 14:04:19 2017 (r322167) @@ -1399,7 +1399,7 @@ t4fw.fw optional cxgbe \ no-obj no-implicit-rule \ clean "t4fw.fw" t5fw_cfg.c optional cxgbe \ - compile-with "${AWK} -f $S/tools/fw_stub.awk t5fw_cfg.fw:t5fw_cfg t5fw.fw:t5fw -mt5fw_cfg -c${.TARGET}" \ + compile-with "${AWK} -f $S/tools/fw_stub.awk t5fw_cfg.fw:t5fw_cfg t5fw_cfg_uwire.fw:t5fw_cfg_uwire t4fw.fw:t4fw -mt5fw_cfg -c${.TARGET}" \ no-implicit-rule before-depend local \ clean "t5fw_cfg.c" t5fw_cfg.fwo optional cxgbe \ @@ -1412,6 +1412,16 @@ t5fw_cfg.fw optional cxgbe \ compile-with "${CP} ${.ALLSRC} ${.TARGET}" \ no-obj no-implicit-rule \ clean "t5fw_cfg.fw" +t5fw_cfg_uwire.fwo optional cxgbe \ + dependency "t5fw_cfg_uwire.fw" \ + compile-with "${NORMAL_FWO}" \ + no-implicit-rule \ + clean "t5fw_cfg_uwire.fwo" +t5fw_cfg_uwire.fw optional cxgbe \ + dependency "$S/dev/cxgbe/firmware/t5fw_cfg_uwire.txt" \ + compile-with "${CP} ${.ALLSRC} ${.TARGET}" \ + no-obj no-implicit-rule \ + clean "t5fw_cfg_uwire.fw" t5fw.fwo optional cxgbe \ dependency "t5fw.fw" \ compile-with "${NORMAL_FWO}" \ @@ -1423,7 +1433,7 @@ t5fw.fw optional cxgbe \ no-obj no-implicit-rule \ clean "t5fw.fw" t6fw_cfg.c optional cxgbe \ - compile-with "${AWK} -f $S/tools/fw_stub.awk t6fw_cfg.fw:t6fw_cfg t6fw.fw:t6fw -mt6fw_cfg -c${.TARGET}" \ + compile-with "${AWK} -f $S/tools/fw_stub.awk t6fw_cfg.fw:t6fw_cfg t6fw_cfg_uwire.fw:t6fw_cfg_uwire t6fw.fw:t6fw -mt6fw_cfg -c${.TARGET}" \ no-implicit-rule before-depend local \ clean "t6fw_cfg.c" t6fw_cfg.fwo optional cxgbe \ @@ -1436,6 +1446,16 @@ t6fw_cfg.fw optional cxgbe \ compile-with "${CP} ${.ALLSRC} ${.TARGET}" \ no-obj no-implicit-rule \ clean "t6fw_cfg.fw" +t6fw_cfg_uwire.fwo optional cxgbe \ + dependency "t6fw_cfg_uwire.fw" \ + compile-with "${NORMAL_FWO}" \ + no-implicit-rule \ + clean "t6fw_cfg_uwire.fwo" +t6fw_cfg_uwire.fw optional cxgbe \ + dependency "$S/dev/cxgbe/firmware/t6fw_cfg_uwire.txt" \ + compile-with "${CP} ${.ALLSRC} ${.TARGET}" \ + no-obj no-implicit-rule \ + clean "t6fw_cfg_uwire.fw" t6fw.fwo optional cxgbe \ dependency "t6fw.fw" \ compile-with "${NORMAL_FWO}" \ From owner-svn-src-head@freebsd.org Mon Aug 7 14:10:01 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A11ADDD5A88; Mon, 7 Aug 2017 14:10:01 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 68EB76D95F; Mon, 7 Aug 2017 14:10:01 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77EA0WU024334; Mon, 7 Aug 2017 14:10:00 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77E9vZw024276; Mon, 7 Aug 2017 14:09:57 GMT (envelope-from br@FreeBSD.org) Message-Id: <201708071409.v77E9vZw024276@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Mon, 7 Aug 2017 14:09:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322168 - in head: cddl/contrib/opensolaris/lib/libdtrace/common contrib/compiler-rt/lib/builtins contrib/compiler-rt/lib/sanitizer_common contrib/elftoolchain/libelf contrib/jemalloc/i... X-SVN-Group: head X-SVN-Commit-Author: br X-SVN-Commit-Paths: in head: cddl/contrib/opensolaris/lib/libdtrace/common contrib/compiler-rt/lib/builtins contrib/compiler-rt/lib/sanitizer_common contrib/elftoolchain/libelf contrib/jemalloc/include/jemalloc contrib/j... X-SVN-Commit-Revision: 322168 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 14:10:01 -0000 Author: br Date: Mon Aug 7 14:09:57 2017 New Revision: 322168 URL: https://svnweb.freebsd.org/changeset/base/322168 Log: o Replace __riscv__ with __riscv o Replace __riscv64 with (__riscv && __riscv_xlen == 64) This is required to support new GCC 7.1 compiler. This is compatible with current GCC 6.1 compiler. RISC-V is extensible ISA and the idea here is to have built-in define per each extension, so together with __riscv we will have some subset of these as well (depending on -march string passed to compiler): __riscv_compressed __riscv_atomic __riscv_mul __riscv_div __riscv_muldiv __riscv_fdiv __riscv_fsqrt __riscv_float_abi_soft __riscv_float_abi_single __riscv_float_abi_double __riscv_cmodel_medlow __riscv_cmodel_medany __riscv_cmodel_pic __riscv_xlen Reviewed by: ngie Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D11901 Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c head/contrib/compiler-rt/lib/builtins/int_lib.h head/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h head/contrib/elftoolchain/libelf/_libelf_config.h head/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal_types.h head/contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h head/contrib/llvm/projects/libunwind/include/__libunwind_config.h head/contrib/llvm/projects/libunwind/src/UnwindRegistersRestore.S head/contrib/llvm/projects/libunwind/src/UnwindRegistersSave.S head/contrib/llvm/projects/libunwind/src/config.h head/contrib/llvm/projects/libunwind/src/libunwind.cpp head/contrib/netbsd-tests/lib/libc/gen/t_dir.c head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c head/contrib/zstd/lib/common/xxhash.c head/lib/libc/gen/tls.c head/lib/libproc/proc_bkpt.c head/lib/libproc/proc_regs.c head/libexec/rtld-elf/rtld.c head/share/man/man7/arch.7 head/sys/cddl/compat/opensolaris/sys/atomic.h head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h head/sys/cddl/contrib/opensolaris/uts/common/sys/isa_defs.h head/sys/cddl/dev/profile/profile.c head/sys/compat/linuxkpi/common/src/linux_page.c head/sys/dev/sym/sym_hipd.c head/sys/kern/subr_devmap.c head/sys/modules/dtrace/dtraceall/dtraceall.c head/sys/sys/cdefs.h head/usr.bin/ldd/ldd.c head/usr.bin/xlint/lint1/param.h Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c Mon Aug 7 14:04:19 2017 (r322167) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c Mon Aug 7 14:09:57 2017 (r322168) @@ -250,7 +250,7 @@ printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__L dofr[j].dofr_offset + 4; rel->r_info = ELF32_R_INFO(count + dep->de_global, R_PPC_REL32); -#elif defined(__riscv__) +#elif defined(__riscv) /* XXX */ printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); #else @@ -430,7 +430,7 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dofr[j].dofr_offset; rel->r_info = ELF64_R_INFO(count + dep->de_global, R_PPC64_REL64); -#elif defined(__riscv__) +#elif defined(__riscv) /* XXX */ #elif defined(__i386) || defined(__amd64) rel->r_offset = s->dofs_offset + @@ -904,7 +904,7 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, return (0); } -#elif defined(__riscv__) +#elif defined(__riscv) /* XXX */ static int dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c Mon Aug 7 14:04:19 2017 (r322167) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c Mon Aug 7 14:09:57 2017 (r322168) @@ -311,7 +311,7 @@ pfprint_fp(dtrace_hdl_t *dtp, FILE *fp, const char *fo return (dt_printf(dtp, fp, format, *((double *)addr) / n)); #if !defined(__arm__) && !defined(__powerpc__) && \ - !defined(__mips__) && !defined(__riscv__) + !defined(__mips__) && !defined(__riscv) case sizeof (long double): return (dt_printf(dtp, fp, format, *((long double *)addr) / ldn)); Modified: head/contrib/compiler-rt/lib/builtins/int_lib.h ============================================================================== --- head/contrib/compiler-rt/lib/builtins/int_lib.h Mon Aug 7 14:04:19 2017 (r322167) +++ head/contrib/compiler-rt/lib/builtins/int_lib.h Mon Aug 7 14:09:57 2017 (r322168) @@ -92,7 +92,7 @@ * does not have dedicated bit counting instructions. */ #if defined(__FreeBSD__) && (defined(__sparc64__) || \ - defined(__mips_n64) || defined(__mips_o64) || defined(__riscv__)) + defined(__mips_n64) || defined(__mips_o64) || defined(__riscv)) si_int __clzsi2(si_int); si_int __ctzsi2(si_int); #define __builtin_clz __clzsi2 Modified: head/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h ============================================================================== --- head/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h Mon Aug 7 14:04:19 2017 (r322167) +++ head/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h Mon Aug 7 14:09:57 2017 (r322168) @@ -83,7 +83,7 @@ namespace __sanitizer { #elif defined(__powerpc64__) const unsigned struct_kernel_stat_sz = 144; const unsigned struct_kernel_stat64_sz = 104; -#elif defined(__riscv__) +#elif defined(__riscv) /* RISCVTODO: check that these values are correct */ const unsigned struct_kernel_stat_sz = 128; const unsigned struct_kernel_stat64_sz = 128; @@ -126,7 +126,7 @@ namespace __sanitizer { #if SANITIZER_LINUX || SANITIZER_FREEBSD -#if defined(__powerpc64__) || defined(__riscv__) || defined(__s390__) +#if defined(__powerpc64__) || defined(__riscv) || defined(__s390__) const unsigned struct___old_kernel_stat_sz = 0; #elif !defined(__sparc__) const unsigned struct___old_kernel_stat_sz = 32; @@ -554,7 +554,7 @@ namespace __sanitizer { typedef long __sanitizer___kernel_off_t; #endif -#if defined(__powerpc__) || defined(__mips__) || defined(__riscv__) +#if defined(__powerpc__) || defined(__mips__) || defined(__riscv) typedef unsigned int __sanitizer___kernel_old_uid_t; typedef unsigned int __sanitizer___kernel_old_gid_t; #else Modified: head/contrib/elftoolchain/libelf/_libelf_config.h ============================================================================== --- head/contrib/elftoolchain/libelf/_libelf_config.h Mon Aug 7 14:04:19 2017 (r322167) +++ head/contrib/elftoolchain/libelf/_libelf_config.h Mon Aug 7 14:09:57 2017 (r322168) @@ -97,7 +97,7 @@ #define LIBELF_BYTEORDER ELFDATA2MSB #define LIBELF_CLASS ELFCLASS32 -#elif defined(__riscv64) +#elif defined(__riscv) && (__riscv_xlen == 64) #define LIBELF_ARCH EM_RISCV #define LIBELF_BYTEORDER ELFDATA2LSB Modified: head/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal_types.h ============================================================================== --- head/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal_types.h Mon Aug 7 14:04:19 2017 (r322167) +++ head/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal_types.h Mon Aug 7 14:09:57 2017 (r322168) @@ -88,7 +88,7 @@ typedef int malloc_cpuid_t; # ifdef __powerpc__ # define LG_QUANTUM 4 # endif -# ifdef __riscv__ +# ifdef __riscv # define LG_QUANTUM 4 # endif # ifdef __s390__ Modified: head/contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h ============================================================================== --- head/contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h Mon Aug 7 14:04:19 2017 (r322167) +++ head/contrib/jemalloc/include/jemalloc/jemalloc_FreeBSD.h Mon Aug 7 14:09:57 2017 (r322168) @@ -67,7 +67,7 @@ # define LG_VADDR 32 # define LG_SIZEOF_PTR 2 #endif -#ifdef __riscv__ +#ifdef __riscv # define LG_VADDR 64 # define LG_SIZEOF_PTR 3 #endif Modified: head/contrib/llvm/projects/libunwind/include/__libunwind_config.h ============================================================================== --- head/contrib/llvm/projects/libunwind/include/__libunwind_config.h Mon Aug 7 14:04:19 2017 (r322167) +++ head/contrib/llvm/projects/libunwind/include/__libunwind_config.h Mon Aug 7 14:09:57 2017 (r322168) @@ -48,7 +48,7 @@ # define _LIBUNWIND_CONTEXT_SIZE 16 # define _LIBUNWIND_CURSOR_SIZE 28 # define _LIBUNWIND_MAX_REGISTER 32 -# elif defined(__riscv__) +# elif defined(__riscv) # define _LIBUNWIND_TARGET_RISCV 1 # define _LIBUNWIND_CONTEXT_SIZE 64 # define _LIBUNWIND_CURSOR_SIZE 76 Modified: head/contrib/llvm/projects/libunwind/src/UnwindRegistersRestore.S ============================================================================== --- head/contrib/llvm/projects/libunwind/src/UnwindRegistersRestore.S Mon Aug 7 14:04:19 2017 (r322167) +++ head/contrib/llvm/projects/libunwind/src/UnwindRegistersRestore.S Mon Aug 7 14:09:57 2017 (r322168) @@ -478,7 +478,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind14Regis l.jr r9 l.nop -#elif defined(__riscv__) +#elif defined(__riscv) // // void libunwind::Registers_riscv::jumpto() Modified: head/contrib/llvm/projects/libunwind/src/UnwindRegistersSave.S ============================================================================== --- head/contrib/llvm/projects/libunwind/src/UnwindRegistersSave.S Mon Aug 7 14:04:19 2017 (r322167) +++ head/contrib/llvm/projects/libunwind/src/UnwindRegistersSave.S Mon Aug 7 14:09:57 2017 (r322168) @@ -464,7 +464,7 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) l.sw 120(r3), r30 l.sw 124(r3), r31 -#elif defined(__riscv__) +#elif defined(__riscv) /* RISCVTODO */ Modified: head/contrib/llvm/projects/libunwind/src/config.h ============================================================================== --- head/contrib/llvm/projects/libunwind/src/config.h Mon Aug 7 14:04:19 2017 (r322167) +++ head/contrib/llvm/projects/libunwind/src/config.h Mon Aug 7 14:09:57 2017 (r322168) @@ -71,7 +71,7 @@ (!defined(__APPLE__) && defined(__arm__)) || \ (defined(__arm64__) || defined(__aarch64__)) || \ (defined(__APPLE__) && defined(__mips__)) || \ - defined(__riscv__) + defined(__riscv) #define _LIBUNWIND_BUILD_ZERO_COST_APIS 1 #else #define _LIBUNWIND_BUILD_ZERO_COST_APIS 0 Modified: head/contrib/llvm/projects/libunwind/src/libunwind.cpp ============================================================================== --- head/contrib/llvm/projects/libunwind/src/libunwind.cpp Mon Aug 7 14:04:19 2017 (r322167) +++ head/contrib/llvm/projects/libunwind/src/libunwind.cpp Mon Aug 7 14:09:57 2017 (r322168) @@ -57,7 +57,7 @@ _LIBUNWIND_EXPORT int unw_init_local(unw_cursor_t *cur # define REGISTER_KIND Registers_arm #elif defined(__or1k__) # define REGISTER_KIND Registers_or1k -#elif defined(__riscv__) +#elif defined(__riscv) # define REGISTER_KIND Registers_riscv #elif defined(__mips__) # warning The MIPS architecture is not supported. Modified: head/contrib/netbsd-tests/lib/libc/gen/t_dir.c ============================================================================== --- head/contrib/netbsd-tests/lib/libc/gen/t_dir.c Mon Aug 7 14:04:19 2017 (r322167) +++ head/contrib/netbsd-tests/lib/libc/gen/t_dir.c Mon Aug 7 14:09:57 2017 (r322168) @@ -135,7 +135,7 @@ ATF_TC_BODY(seekdir_basic, tc) } /* There is no sbrk on AArch64 and RISC-V */ -#if !defined(__aarch64__) && !defined(__riscv__) +#if !defined(__aarch64__) && !defined(__riscv) ATF_TC(telldir_leak); ATF_TC_HEAD(telldir_leak, tc) { @@ -185,7 +185,7 @@ ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, seekdir_basic); -#if !defined(__aarch64__) && !defined(__riscv__) +#if !defined(__aarch64__) && !defined(__riscv) ATF_TP_ADD_TC(tp, telldir_leak); #endif Modified: head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c ============================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c Mon Aug 7 14:04:19 2017 (r322167) +++ head/contrib/netbsd-tests/lib/libc/sys/t_mlock.c Mon Aug 7 14:09:57 2017 (r322168) @@ -103,7 +103,7 @@ ATF_TC_BODY(mlock_err, tc) unsigned long vmin = 0; size_t len = sizeof(vmin); #endif -#if !defined(__aarch64__) && !defined(__riscv__) +#if !defined(__aarch64__) && !defined(__riscv) void *invalid_ptr; #endif int null_errno = ENOMEM; /* error expected for NULL */ @@ -155,7 +155,7 @@ ATF_TC_BODY(mlock_err, tc) ATF_REQUIRE_ERRNO(ENOMEM, munlock(buf, page) == -1); /* There is no sbrk on AArch64 and RISC-V */ -#if !defined(__aarch64__) && !defined(__riscv__) +#if !defined(__aarch64__) && !defined(__riscv) /* * These are permitted to fail (EINVAL) but do not on NetBSD */ Modified: head/contrib/zstd/lib/common/xxhash.c ============================================================================== --- head/contrib/zstd/lib/common/xxhash.c Mon Aug 7 14:04:19 2017 (r322167) +++ head/contrib/zstd/lib/common/xxhash.c Mon Aug 7 14:09:57 2017 (r322168) @@ -206,7 +206,7 @@ static U64 XXH_read64(const void* memPtr) #if defined(_MSC_VER) /* Visual Studio */ # define XXH_swap32 _byteswap_ulong # define XXH_swap64 _byteswap_uint64 -#elif (GCC_VERSION >= 403 && !defined(__riscv__)) +#elif (GCC_VERSION >= 403 && !defined(__riscv)) # define XXH_swap32 __builtin_bswap32 # define XXH_swap64 __builtin_bswap64 #else Modified: head/lib/libc/gen/tls.c ============================================================================== --- head/lib/libc/gen/tls.c Mon Aug 7 14:04:19 2017 (r322167) +++ head/lib/libc/gen/tls.c Mon Aug 7 14:09:57 2017 (r322168) @@ -66,7 +66,7 @@ void __libc_free_tls(void *tls, size_t tcbsize, size_t #if defined(__amd64__) #define TLS_TCB_ALIGN 16 #elif defined(__aarch64__) || defined(__arm__) || defined(__i386__) || \ - defined(__mips__) || defined(__powerpc__) || defined(__riscv__) || \ + defined(__mips__) || defined(__powerpc__) || defined(__riscv) || \ defined(__sparc64__) #define TLS_TCB_ALIGN sizeof(void *) #else @@ -74,7 +74,7 @@ void __libc_free_tls(void *tls, size_t tcbsize, size_t #endif #if defined(__aarch64__) || defined(__arm__) || defined(__mips__) || \ - defined(__powerpc__) || defined(__riscv__) + defined(__powerpc__) || defined(__riscv) #define TLS_VARIANT_I #endif #if defined(__i386__) || defined(__amd64__) || defined(__sparc64__) Modified: head/lib/libproc/proc_bkpt.c ============================================================================== --- head/lib/libproc/proc_bkpt.c Mon Aug 7 14:04:19 2017 (r322167) +++ head/lib/libproc/proc_bkpt.c Mon Aug 7 14:09:57 2017 (r322168) @@ -61,7 +61,7 @@ __FBSDID("$FreeBSD$"); #elif defined(__powerpc__) #define BREAKPOINT_INSTR 0x7fe00008 /* trap */ #define BREAKPOINT_INSTR_SZ 4 -#elif defined(__riscv__) +#elif defined(__riscv) #define BREAKPOINT_INSTR 0x00100073 /* sbreak */ #define BREAKPOINT_INSTR_SZ 4 #else Modified: head/lib/libproc/proc_regs.c ============================================================================== --- head/lib/libproc/proc_regs.c Mon Aug 7 14:04:19 2017 (r322167) +++ head/lib/libproc/proc_regs.c Mon Aug 7 14:09:57 2017 (r322168) @@ -67,7 +67,7 @@ proc_regget(struct proc_handle *phdl, proc_reg_t reg, *regvalue = regs.r_regs[PC]; #elif defined(__powerpc__) *regvalue = regs.pc; -#elif defined(__riscv__) +#elif defined(__riscv) *regvalue = regs.sepc; #endif break; @@ -84,7 +84,7 @@ proc_regget(struct proc_handle *phdl, proc_reg_t reg, *regvalue = regs.r_regs[SP]; #elif defined(__powerpc__) *regvalue = regs.fixreg[1]; -#elif defined(__riscv__) +#elif defined(__riscv) *regvalue = regs.sp; #endif break; @@ -122,7 +122,7 @@ proc_regset(struct proc_handle *phdl, proc_reg_t reg, regs.r_regs[PC] = regvalue; #elif defined(__powerpc__) regs.pc = regvalue; -#elif defined(__riscv__) +#elif defined(__riscv) regs.sepc = regvalue; #endif break; @@ -139,7 +139,7 @@ proc_regset(struct proc_handle *phdl, proc_reg_t reg, regs.r_regs[PC] = regvalue; #elif defined(__powerpc__) regs.fixreg[1] = regvalue; -#elif defined(__riscv__) +#elif defined(__riscv) regs.sp = regvalue; #endif break; Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Mon Aug 7 14:04:19 2017 (r322167) +++ head/libexec/rtld-elf/rtld.c Mon Aug 7 14:09:57 2017 (r322168) @@ -4662,7 +4662,7 @@ tls_get_addr_common(Elf_Addr **dtvp, int index, size_t } #if defined(__aarch64__) || defined(__arm__) || defined(__mips__) || \ - defined(__powerpc__) || defined(__riscv__) + defined(__powerpc__) || defined(__riscv) /* * Allocate Static TLS using the Variant I method. Modified: head/share/man/man7/arch.7 ============================================================================== --- head/share/man/man7/arch.7 Mon Aug 7 14:04:19 2017 (r322167) +++ head/share/man/man7/arch.7 Mon Aug 7 14:09:57 2017 (r322168) @@ -337,8 +337,8 @@ Architecture-specific macros: .It powerpc Ta Dv __powerpc__ .It powerpcspe Ta Dv __powerpc__, Dv __SPE__ .It powerpc64 Ta Dv __powerpc__, Dv __powerpc64__ -.It riscv64 Ta Dv __riscv__, Dv __riscv64 -.It riscv64sf Ta Dv __riscv__, Dv __riscv64 +.It riscv64 Ta Dv __riscv, Dv __riscv_xlen == 64 +.It riscv64sf Ta Dv __riscv, Dv __riscv_xlen == 64 .It sparc64 Ta Dv __sparc64__ .El .Sh SEE ALSO Modified: head/sys/cddl/compat/opensolaris/sys/atomic.h ============================================================================== --- head/sys/cddl/compat/opensolaris/sys/atomic.h Mon Aug 7 14:04:19 2017 (r322167) +++ head/sys/cddl/compat/opensolaris/sys/atomic.h Mon Aug 7 14:09:57 2017 (r322168) @@ -51,7 +51,7 @@ extern uint8_t atomic_or_8_nv(volatile uint8_t *target extern void membar_producer(void); #if defined(__sparc64__) || defined(__powerpc__) || defined(__arm__) || \ - defined(__mips__) || defined(__aarch64__) || defined(__riscv__) + defined(__mips__) || defined(__aarch64__) || defined(__riscv) extern void atomic_or_8(volatile uint8_t *target, uint8_t value); #else static __inline void Modified: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Mon Aug 7 14:04:19 2017 (r322167) +++ head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Mon Aug 7 14:09:57 2017 (r322168) @@ -12120,7 +12120,7 @@ err: *factor = 1; #if defined(__aarch64__) || defined(__amd64__) || defined(__arm__) || \ - defined(__mips__) || defined(__powerpc__) || defined(__riscv__) + defined(__mips__) || defined(__powerpc__) || defined(__riscv) /* * FreeBSD isn't good at limiting the amount of memory we * ask to malloc, so let's place a limit here before trying Modified: head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h Mon Aug 7 14:04:19 2017 (r322167) +++ head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h Mon Aug 7 14:09:57 2017 (r322168) @@ -2492,7 +2492,7 @@ extern void dtrace_helpers_destroy(proc_t *); #define DTRACE_INVOP_SD 1 #define DTRACE_INVOP_LD 2 -#elif defined(__riscv__) +#elif defined(__riscv) #define SD_RA_SP_MASK 0x01fff07f #define SD_RA_SP 0x00113023 Modified: head/sys/cddl/contrib/opensolaris/uts/common/sys/isa_defs.h ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/sys/isa_defs.h Mon Aug 7 14:04:19 2017 (r322167) +++ head/sys/cddl/contrib/opensolaris/uts/common/sys/isa_defs.h Mon Aug 7 14:09:57 2017 (r322168) @@ -388,7 +388,7 @@ extern "C" { #define _DONT_USE_1275_GENERIC_NAMES #define _HAVE_CPUID_INSN -#elif defined(__riscv__) +#elif defined(__riscv) /* * Define the appropriate "processor characteristics" Modified: head/sys/cddl/dev/profile/profile.c ============================================================================== --- head/sys/cddl/dev/profile/profile.c Mon Aug 7 14:04:19 2017 (r322167) +++ head/sys/cddl/dev/profile/profile.c Mon Aug 7 14:09:57 2017 (r322168) @@ -143,7 +143,7 @@ struct profile_probe_percpu; #define PROF_ARTIFICIAL_FRAMES 10 #endif -#ifdef __riscv__ +#ifdef __riscv /* TODO: verify */ #define PROF_ARTIFICIAL_FRAMES 10 #endif Modified: head/sys/compat/linuxkpi/common/src/linux_page.c ============================================================================== --- head/sys/compat/linuxkpi/common/src/linux_page.c Mon Aug 7 14:04:19 2017 (r322167) +++ head/sys/compat/linuxkpi/common/src/linux_page.c Mon Aug 7 14:09:57 2017 (r322168) @@ -62,7 +62,7 @@ __FBSDID("$FreeBSD$"); #include #include -#if defined(__amd64__) || defined(__aarch64__) || defined(__riscv__) +#if defined(__amd64__) || defined(__aarch64__) || defined(__riscv) #define LINUXKPI_HAVE_DMAP #else #undef LINUXKPI_HAVE_DMAP Modified: head/sys/dev/sym/sym_hipd.c ============================================================================== --- head/sys/dev/sym/sym_hipd.c Mon Aug 7 14:04:19 2017 (r322167) +++ head/sys/dev/sym/sym_hipd.c Mon Aug 7 14:09:57 2017 (r322168) @@ -138,7 +138,7 @@ typedef u_int32_t u32; #define MEMORY_BARRIER() dmb() #elif defined __aarch64__ #define MEMORY_BARRIER() dmb(sy) -#elif defined __riscv__ +#elif defined __riscv #define MEMORY_BARRIER() fence() #else #error "Not supported platform" Modified: head/sys/kern/subr_devmap.c ============================================================================== --- head/sys/kern/subr_devmap.c Mon Aug 7 14:04:19 2017 (r322167) +++ head/sys/kern/subr_devmap.c Mon Aug 7 14:09:57 2017 (r322168) @@ -53,7 +53,7 @@ static struct devmap_entry akva_devmap_entries[AKVA_DE static u_int akva_devmap_idx; static vm_offset_t akva_devmap_vaddr = DEVMAP_MAX_VADDR; -#if defined(__aarch64__) || defined(__riscv__) +#if defined(__aarch64__) || defined(__riscv) extern int early_boot; #endif @@ -197,7 +197,7 @@ devmap_bootstrap(vm_offset_t l1pt, const struct devmap pmap_map_chunk(l1pt, pd->pd_va, pd->pd_pa, pd->pd_size, VM_PROT_READ | VM_PROT_WRITE, PTE_DEVICE); #endif -#elif defined(__aarch64__) || defined(__riscv__) +#elif defined(__aarch64__) || defined(__riscv) pmap_kenter_device(pd->pd_va, pd->pd_size, pd->pd_pa); #endif } @@ -270,7 +270,7 @@ pmap_mapdev(vm_offset_t pa, vm_size_t size) pa = trunc_page(pa); size = round_page(size + offset); -#if defined(__aarch64__) || defined(__riscv__) +#if defined(__aarch64__) || defined(__riscv) if (early_boot) { akva_devmap_vaddr = trunc_page(akva_devmap_vaddr - size); va = akva_devmap_vaddr; Modified: head/sys/modules/dtrace/dtraceall/dtraceall.c ============================================================================== --- head/sys/modules/dtrace/dtraceall/dtraceall.c Mon Aug 7 14:04:19 2017 (r322167) +++ head/sys/modules/dtrace/dtraceall/dtraceall.c Mon Aug 7 14:09:57 2017 (r322168) @@ -70,7 +70,7 @@ MODULE_DEPEND(dtraceall, dtmalloc, 1, 1, 1); MODULE_DEPEND(dtraceall, dtnfscl, 1, 1, 1); #endif #if defined(__aarch64__) || defined(__amd64__) || defined(__arm__) || \ - defined(__i386__) || defined(__powerpc__) || defined(__riscv__) + defined(__i386__) || defined(__powerpc__) || defined(__riscv) MODULE_DEPEND(dtraceall, fbt, 1, 1, 1); #endif #if defined(__amd64__) || defined(__i386__) Modified: head/sys/sys/cdefs.h ============================================================================== --- head/sys/sys/cdefs.h Mon Aug 7 14:04:19 2017 (r322167) +++ head/sys/sys/cdefs.h Mon Aug 7 14:09:57 2017 (r322168) @@ -782,7 +782,7 @@ #endif #endif /* __STDC_WANT_LIB_EXT1__ */ -#if defined(__mips) || defined(__powerpc64__) || defined(__riscv__) +#if defined(__mips) || defined(__powerpc64__) || defined(__riscv) #define __NO_TLS 1 #endif Modified: head/usr.bin/ldd/ldd.c ============================================================================== --- head/usr.bin/ldd/ldd.c Mon Aug 7 14:04:19 2017 (r322167) +++ head/usr.bin/ldd/ldd.c Mon Aug 7 14:09:57 2017 (r322168) @@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$"); #include "extern.h" /* We don't support a.out executables on arm64 and riscv */ -#if !defined(__aarch64__) && !defined(__riscv__) +#if !defined(__aarch64__) && !defined(__riscv) #include #define AOUT_SUPPORTED #endif Modified: head/usr.bin/xlint/lint1/param.h ============================================================================== --- head/usr.bin/xlint/lint1/param.h Mon Aug 7 14:04:19 2017 (r322167) +++ head/usr.bin/xlint/lint1/param.h Mon Aug 7 14:09:57 2017 (r322168) @@ -80,7 +80,7 @@ #elif __powerpc__ #define PTRDIFF_IS_LONG 0 #define SIZEOF_IS_ULONG 0 -#elif __riscv__ +#elif __riscv #define PTRDIFF_IS_LONG 1 #define SIZEOF_IS_ULONG 1 #elif __sparc__ From owner-svn-src-head@freebsd.org Mon Aug 7 14:34:07 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2BC70DD6D4F; Mon, 7 Aug 2017 14:34:07 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 07E516E9F4; Mon, 7 Aug 2017 14:34:06 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77EY6Wf036369; Mon, 7 Aug 2017 14:34:06 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77EY516036367; Mon, 7 Aug 2017 14:34:05 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201708071434.v77EY516036367@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 7 Aug 2017 14:34:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322169 - in head/sys/compat/linuxkpi/common: include/linux src X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in head/sys/compat/linuxkpi/common: include/linux src X-SVN-Commit-Revision: 322169 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 14:34:07 -0000 Author: mav Date: Mon Aug 7 14:34:05 2017 New Revision: 322169 URL: https://svnweb.freebsd.org/changeset/base/322169 Log: Fix hrtimer_active() in case of cancellation. While there, switch to FreeBSD internal callout active status. Reviewed by: markj, hselasky Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D11900 Modified: head/sys/compat/linuxkpi/common/include/linux/hrtimer.h head/sys/compat/linuxkpi/common/src/linux_hrtimer.c Modified: head/sys/compat/linuxkpi/common/include/linux/hrtimer.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/hrtimer.h Mon Aug 7 14:09:57 2017 (r322168) +++ head/sys/compat/linuxkpi/common/include/linux/hrtimer.h Mon Aug 7 14:34:05 2017 (r322169) @@ -48,7 +48,6 @@ struct hrtimer { enum hrtimer_restart (*function)(struct hrtimer *); struct mtx mtx; struct callout callout; - uint32_t flags; }; #define hrtimer_active(hrtimer) linux_hrtimer_active(hrtimer) Modified: head/sys/compat/linuxkpi/common/src/linux_hrtimer.c ============================================================================== --- head/sys/compat/linuxkpi/common/src/linux_hrtimer.c Mon Aug 7 14:09:57 2017 (r322168) +++ head/sys/compat/linuxkpi/common/src/linux_hrtimer.c Mon Aug 7 14:34:05 2017 (r322169) @@ -37,9 +37,6 @@ __FBSDID("$FreeBSD$"); #include -/* hrtimer flags */ -#define HRTIMER_ACTIVE 0x01 - static void hrtimer_call_handler(void *arg) { @@ -49,7 +46,7 @@ hrtimer_call_handler(void *arg) hrtimer = arg; ret = hrtimer->function(hrtimer); MPASS(ret == HRTIMER_NORESTART); - hrtimer->flags &= ~HRTIMER_ACTIVE; + callout_deactivate(&hrtimer->callout); } bool @@ -58,19 +55,20 @@ linux_hrtimer_active(struct hrtimer *hrtimer) bool ret; mtx_lock(&hrtimer->mtx); - ret = (hrtimer->flags & HRTIMER_ACTIVE) != 0; + ret = callout_active(&hrtimer->callout); mtx_unlock(&hrtimer->mtx); return (ret); } +/* + * Cancel active hrtimer. + * Return 1 if timer was active and cancellation succeeded, or 0 otherwise. + */ int linux_hrtimer_cancel(struct hrtimer *hrtimer) { - if (!hrtimer_active(hrtimer)) - return (0); - (void)callout_drain(&hrtimer->callout); - return (1); + return (callout_drain(&hrtimer->callout) > 0); } void @@ -78,7 +76,6 @@ linux_hrtimer_init(struct hrtimer *hrtimer) { hrtimer->function = NULL; - hrtimer->flags = 0; mtx_init(&hrtimer->mtx, "hrtimer", NULL, MTX_DEF | MTX_RECURSE); callout_init_mtx(&hrtimer->callout, &hrtimer->mtx, 0); } @@ -103,6 +100,5 @@ linux_hrtimer_start_range_ns(struct hrtimer *hrtimer, mtx_lock(&hrtimer->mtx); callout_reset_sbt(&hrtimer->callout, nstosbt(time.tv64), nstosbt(nsec), hrtimer_call_handler, hrtimer, 0); - hrtimer->flags |= HRTIMER_ACTIVE; mtx_unlock(&hrtimer->mtx); } From owner-svn-src-head@freebsd.org Mon Aug 7 16:23:54 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D2A3CDB44CB; Mon, 7 Aug 2017 16:23:54 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9D4E872EA1; Mon, 7 Aug 2017 16:23:54 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77GNrq6081023; Mon, 7 Aug 2017 16:23:53 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77GNrFZ081021; Mon, 7 Aug 2017 16:23:53 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201708071623.v77GNrFZ081021@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Mon, 7 Aug 2017 16:23:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322170 - head X-SVN-Group: head X-SVN-Commit-Author: dim X-SVN-Commit-Paths: head X-SVN-Commit-Revision: 322170 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 16:23:54 -0000 Author: dim Date: Mon Aug 7 16:23:53 2017 New Revision: 322170 URL: https://svnweb.freebsd.org/changeset/base/322170 Log: Follow-up to r321684 (Don't use libc++ when cross-building for gcc arches), and handle two more cases where libc++ includes could be incorrectly enabled, in case the host compiler is clang 5.0.0, and the target (cross) compiler is gcc 4.2.1. Noted by: bdrewery MFC after: 3 days X-MFC-With: 321684 Modified: head/Makefile.inc1 head/Makefile.libcompat Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Mon Aug 7 14:34:05 2017 (r322169) +++ head/Makefile.inc1 Mon Aug 7 16:23:53 2017 (r322170) @@ -2742,8 +2742,7 @@ CD2CFLAGS+= -isystem ${XDDESTDIR}/usr/include -L${XDDE # combined with --sysroot. CD2CFLAGS+= -B${XDDESTDIR}/usr/lib # Force using libc++ for external GCC. -# XXX: This should be checking MK_GNUCXX == no -.if ${X_COMPILER_VERSION} >= 40800 +.if ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800 CD2CXXFLAGS+= -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \ -nostdinc++ .endif Modified: head/Makefile.libcompat ============================================================================== --- head/Makefile.libcompat Mon Aug 7 14:34:05 2017 (r322169) +++ head/Makefile.libcompat Mon Aug 7 16:23:53 2017 (r322170) @@ -99,8 +99,7 @@ LIBCOMPATCFLAGS+= -B${LIBCOMPATTMP}/usr/lib${libcompat # sysroot path which --sysroot does not actually do for headers. LIBCOMPATCFLAGS+= -isystem ${LIBCOMPATTMP}/usr/include # Force using libc++ for external GCC. -# XXX: This should be checking MK_GNUCXX == no -.if ${X_COMPILER_VERSION} >= 40800 && \ +.if ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800 && \ (${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no") LIBCOMPATCXXFLAGS+= -isystem ${LIBCOMPATTMP}/usr/include/c++/v1 -std=c++11 \ -nostdinc++ From owner-svn-src-head@freebsd.org Mon Aug 7 17:23:11 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C8CB9DBC6A6; Mon, 7 Aug 2017 17:23:11 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 96B267587E; Mon, 7 Aug 2017 17:23:11 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77HNAZ9005306; Mon, 7 Aug 2017 17:23:10 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77HNAJG005305; Mon, 7 Aug 2017 17:23:10 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201708071723.v77HNAJG005305@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 7 Aug 2017 17:23:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322171 - head/sys/amd64/amd64 X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/amd64/amd64 X-SVN-Commit-Revision: 322171 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 17:23:11 -0000 Author: kib Date: Mon Aug 7 17:23:10 2017 New Revision: 322171 URL: https://svnweb.freebsd.org/changeset/base/322171 Log: Explain why delayed invalidation is not required in pmap_protect() and pmap_remove_pages(). Submitted by: alc MFC after: 1 week Modified: head/sys/amd64/amd64/pmap.c Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Mon Aug 7 16:23:53 2017 (r322170) +++ head/sys/amd64/amd64/pmap.c Mon Aug 7 17:23:10 2017 (r322171) @@ -4085,6 +4085,26 @@ pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t PG_RW = pmap_rw_bit(pmap); anychanged = FALSE; + /* + * Although this function delays and batches the invalidation + * of stale TLB entries, it does not need to call + * pmap_delayed_invl_started() and + * pmap_delayed_invl_finished(), because it does not + * ordinarily destroy mappings. Stale TLB entries from + * protection-only changes need only be invalidated before the + * pmap lock is released, because protection-only changes do + * not destroy PV entries. Even operations that iterate over + * a physical page's PV list of mappings, like + * pmap_remove_write(), acquire the pmap lock for each + * mapping. Consequently, for protection-only changes, the + * pmap lock suffices to synchronize both page table and TLB + * updates. + * + * This function only destroys a mapping if pmap_demote_pde() + * fails. In that case, stale TLB entries are immediately + * invalidated. + */ + PMAP_LOCK(pmap); for (; sva < eva; sva = va_next) { @@ -5469,6 +5489,15 @@ pmap_page_is_mapped(vm_page_t m) * no processor is currently accessing the user address space. In * particular, a page table entry's dirty bit won't change state once * this function starts. + * + * Although this function destroys all of the pmap's managed, + * non-wired mappings, it can delay and batch the invalidation of TLB + * entries without calling pmap_delayed_invl_started() and + * pmap_delayed_invl_finished(). Because the pmap is not active on + * any other processor, none of these TLB entries will ever be used + * before their eventual invalidation. Consequently, there is no need + * for either pmap_remove_all() or pmap_remove_write() to wait for + * that eventual TLB invalidation. */ void pmap_remove_pages(pmap_t pmap) From owner-svn-src-head@freebsd.org Mon Aug 7 17:29:56 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1F264DBCDDF; Mon, 7 Aug 2017 17:29:56 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E5C7075E02; Mon, 7 Aug 2017 17:29:55 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77HTtZA005748; Mon, 7 Aug 2017 17:29:55 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77HTtFa005747; Mon, 7 Aug 2017 17:29:55 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201708071729.v77HTtFa005747@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 7 Aug 2017 17:29:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322175 - head/sys/amd64/amd64 X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/amd64/amd64 X-SVN-Commit-Revision: 322175 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 17:29:56 -0000 Author: kib Date: Mon Aug 7 17:29:54 2017 New Revision: 322175 URL: https://svnweb.freebsd.org/changeset/base/322175 Log: Avoid DI recursion when reclaim_pv_chunk() is called from pmap_advise() or pmap_remove(). Reported and tested by: pho (previous version) Reviewed by: alc Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/amd64/amd64/pmap.c Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Mon Aug 7 17:29:48 2017 (r322174) +++ head/sys/amd64/amd64/pmap.c Mon Aug 7 17:29:54 2017 (r322175) @@ -428,8 +428,15 @@ static struct lock_object invl_gen_ts = { .lo_name = "invlts", }; +static bool +pmap_not_in_di(void) +{ + + return (curthread->td_md.md_invl_gen.gen == 0); +} + #define PMAP_ASSERT_NOT_IN_DI() \ - KASSERT(curthread->td_md.md_invl_gen.gen == 0, ("DI already started")) + KASSERT(pmap_not_in_di(), ("DI already started")) /* * Start a new Delayed Invalidation (DI) block of code, executed by @@ -2856,6 +2863,19 @@ SYSCTL_INT(_vm_pmap, OID_AUTO, pv_entry_spare, CTLFLAG "Current number of spare pv entries"); #endif +static void +reclaim_pv_chunk_leave_pmap(pmap_t pmap, pmap_t locked_pmap, bool start_di) +{ + + if (pmap == NULL) + return; + pmap_invalidate_all(pmap); + if (pmap != locked_pmap) + PMAP_UNLOCK(pmap); + if (start_di) + pmap_delayed_invl_finished(); +} + /* * We are in a serious low memory condition. Resort to * drastic measures to free some pages so we can allocate @@ -2883,6 +2903,7 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **l struct spglist free; uint64_t inuse; int bit, field, freed; + bool start_di; PMAP_LOCK_ASSERT(locked_pmap, MA_OWNED); KASSERT(lockp != NULL, ("reclaim_pv_chunk: lockp is NULL")); @@ -2891,19 +2912,21 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **l PG_G = PG_A = PG_M = PG_RW = 0; SLIST_INIT(&free); TAILQ_INIT(&new_tail); - pmap_delayed_invl_started(); + + /* + * A delayed invalidation block should already be active if + * pmap_advise() or pmap_remove() called this function by way + * of pmap_demote_pde_locked(). + */ + start_di = pmap_not_in_di(); + mtx_lock(&pv_chunks_mutex); while ((pc = TAILQ_FIRST(&pv_chunks)) != NULL && SLIST_EMPTY(&free)) { TAILQ_REMOVE(&pv_chunks, pc, pc_lru); mtx_unlock(&pv_chunks_mutex); if (pmap != pc->pc_pmap) { - if (pmap != NULL) { - pmap_invalidate_all(pmap); - if (pmap != locked_pmap) - PMAP_UNLOCK(pmap); - } - pmap_delayed_invl_finished(); - pmap_delayed_invl_started(); + reclaim_pv_chunk_leave_pmap(pmap, locked_pmap, + start_di); pmap = pc->pc_pmap; /* Avoid deadlock and lock recursion. */ if (pmap > locked_pmap) { @@ -2920,6 +2943,8 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **l PG_A = pmap_accessed_bit(pmap); PG_M = pmap_modified_bit(pmap); PG_RW = pmap_rw_bit(pmap); + if (start_di) + pmap_delayed_invl_started(); } /* @@ -2994,12 +3019,7 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **l } TAILQ_CONCAT(&pv_chunks, &new_tail, pc_lru); mtx_unlock(&pv_chunks_mutex); - if (pmap != NULL) { - pmap_invalidate_all(pmap); - if (pmap != locked_pmap) - PMAP_UNLOCK(pmap); - } - pmap_delayed_invl_finished(); + reclaim_pv_chunk_leave_pmap(pmap, locked_pmap, start_di); if (m_pc == NULL && !SLIST_EMPTY(&free)) { m_pc = SLIST_FIRST(&free); SLIST_REMOVE_HEAD(&free, plinks.s.ss); From owner-svn-src-head@freebsd.org Mon Aug 7 18:01:29 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5C21EDBEB97; Mon, 7 Aug 2017 18:01:29 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1E47A775A3; Mon, 7 Aug 2017 18:01:29 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77I1SbA020916; Mon, 7 Aug 2017 18:01:28 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77I1SIG020914; Mon, 7 Aug 2017 18:01:28 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708071801.v77I1SIG020914@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 7 Aug 2017 18:01:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322177 - head/usr.bin/indent X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/usr.bin/indent X-SVN-Commit-Revision: 322177 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 18:01:29 -0000 Author: kevans Date: Mon Aug 7 18:01:27 2017 New Revision: 322177 URL: https://svnweb.freebsd.org/changeset/base/322177 Log: Respect SIMPLE_BACKUP_SUFFIX environment variable in indent(1) Instead of using a non-configurable ".BAK" suffix, respect the SIMPLE_BACKUP_SUFFIX environment variable also used by patch(1). This simplifies cleanup operations in some patch/indent workflows. Reviewed by: cem (earlier version), emaste, pstef Approved by: emaste (mentor) Differential Revision: https://reviews.freebsd.org/D10921 Modified: head/usr.bin/indent/indent.1 head/usr.bin/indent/indent.c Modified: head/usr.bin/indent/indent.1 ============================================================================== --- head/usr.bin/indent/indent.1 Mon Aug 7 17:30:22 2017 (r322176) +++ head/usr.bin/indent/indent.1 Mon Aug 7 18:01:27 2017 (r322177) @@ -30,7 +30,7 @@ .\" @(#)indent.1 8.1 (Berkeley) 7/1/93 .\" $FreeBSD$ .\" -.Dd July 25, 2017 +.Dd August 7, 2017 .Dt INDENT 1 .Os .Sh NAME @@ -119,7 +119,10 @@ If is named .Sq Pa /blah/blah/file , the backup file is named -.Sq Pa file.BAK . +.Sq Pa file.BAK +by default. The extension used for the backup file may be overridden using the +.Ev SIMPLE_BACKUP_SUFFIX +environment variable. .Pp If .Ar output-file Modified: head/usr.bin/indent/indent.c ============================================================================== --- head/usr.bin/indent/indent.c Mon Aug 7 17:30:22 2017 (r322176) +++ head/usr.bin/indent/indent.c Mon Aug 7 18:01:27 2017 (r322177) @@ -71,6 +71,8 @@ const char *in_name = "Standard Input"; /* will always * file */ const char *out_name = "Standard Output"; /* will always point to name * of output file */ +const char *simple_backup_suffix = ".BAK"; /* Suffix to use for backup + * files */ char bakfile[MAXPATHLEN] = ""; int @@ -99,8 +101,8 @@ main(int argc, char **argv) int last_else = 0; /* true iff last keyword was an else */ const char *profile_name = NULL; + const char *envval = NULL; - /*-----------------------------------------------*\ | INITIALIZATION | \*-----------------------------------------------*/ @@ -160,6 +162,10 @@ main(int argc, char **argv) output = NULL; tabs_to_var = 0; + envval = getenv("SIMPLE_BACKUP_SUFFIX"); + if (envval) + simple_backup_suffix = envval; + /*--------------------------------------------------*\ | COMMAND LINE SCAN | \*--------------------------------------------------*/ @@ -1234,7 +1240,7 @@ bakcopy(void) p--; if (*p == '/') p++; - sprintf(bakfile, "%s.BAK", p); + sprintf(bakfile, "%s%s", p, simple_backup_suffix); /* copy in_name to backup file */ bakchn = creat(bakfile, 0600); From owner-svn-src-head@freebsd.org Mon Aug 7 19:18:28 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EAF21DC2B80; Mon, 7 Aug 2017 19:18:28 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C63F27E81C; Mon, 7 Aug 2017 19:18:28 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77JIShs052317; Mon, 7 Aug 2017 19:18:28 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77JISXB052316; Mon, 7 Aug 2017 19:18:28 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201708071918.v77JISXB052316@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Mon, 7 Aug 2017 19:18:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322178 - head/sys/geom/journal X-SVN-Group: head X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: head/sys/geom/journal X-SVN-Commit-Revision: 322178 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 19:18:29 -0000 Author: mckusick Date: Mon Aug 7 19:18:27 2017 New Revision: 322178 URL: https://svnweb.freebsd.org/changeset/base/322178 Log: sysctl kern.geom.journal.cache.limit shows negative value for FreeBSD/amd64 system having over 4GB RAM. That's due to: 1) the limit being u_int instead of u_long like vm.kmem_size (the limit is half of vm.kmem_size by default for amd64); 2) sysctl handler g_journal_cache_limit_sysctl() using u_int instead of u_long. The fix is to replace u_int with u_long for the kern.geom.journal.cache.limit sysctl variable. PR: 198500 Submitted by: Dr. Andreas Longwitz Reported by: Eugene Grosbein Discussed with: kib MFC after: 1 week Modified: head/sys/geom/journal/g_journal.c Modified: head/sys/geom/journal/g_journal.c ============================================================================== --- head/sys/geom/journal/g_journal.c Mon Aug 7 18:01:27 2017 (r322177) +++ head/sys/geom/journal/g_journal.c Mon Aug 7 19:18:27 2017 (r322178) @@ -130,26 +130,26 @@ SYSCTL_PROC(_kern_geom_journal, OID_AUTO, record_entri SYSCTL_UINT(_kern_geom_journal, OID_AUTO, optimize, CTLFLAG_RW, &g_journal_do_optimize, 0, "Try to combine bios on flush and copy"); -static u_int g_journal_cache_used = 0; -static u_int g_journal_cache_limit = 64 * 1024 * 1024; +static u_long g_journal_cache_used = 0; +static u_long g_journal_cache_limit = 64 * 1024 * 1024; static u_int g_journal_cache_divisor = 2; static u_int g_journal_cache_switch = 90; static u_int g_journal_cache_misses = 0; static u_int g_journal_cache_alloc_failures = 0; -static u_int g_journal_cache_low = 0; +static u_long g_journal_cache_low = 0; static SYSCTL_NODE(_kern_geom_journal, OID_AUTO, cache, CTLFLAG_RW, 0, "GEOM_JOURNAL cache"); -SYSCTL_UINT(_kern_geom_journal_cache, OID_AUTO, used, CTLFLAG_RD, +SYSCTL_ULONG(_kern_geom_journal_cache, OID_AUTO, used, CTLFLAG_RD, &g_journal_cache_used, 0, "Number of allocated bytes"); static int g_journal_cache_limit_sysctl(SYSCTL_HANDLER_ARGS) { - u_int limit; + u_long limit; int error; limit = g_journal_cache_limit; - error = sysctl_handle_int(oidp, &limit, 0, req); + error = sysctl_handle_long(oidp, &limit, 0, req); if (error != 0 || req->newptr == NULL) return (error); g_journal_cache_limit = limit; @@ -157,7 +157,7 @@ g_journal_cache_limit_sysctl(SYSCTL_HANDLER_ARGS) return (0); } SYSCTL_PROC(_kern_geom_journal_cache, OID_AUTO, limit, - CTLTYPE_UINT | CTLFLAG_RWTUN, NULL, 0, g_journal_cache_limit_sysctl, "I", + CTLTYPE_ULONG | CTLFLAG_RWTUN, NULL, 0, g_journal_cache_limit_sysctl, "I", "Maximum number of allocated bytes"); SYSCTL_UINT(_kern_geom_journal_cache, OID_AUTO, divisor, CTLFLAG_RDTUN, &g_journal_cache_divisor, 0, @@ -3046,9 +3046,9 @@ g_journal_switcher(void *arg) kproc_exit(0); } if (error == 0 && g_journal_sync_requested == 0) { - GJ_DEBUG(1, "Out of cache, force switch (used=%u " - "limit=%u).", g_journal_cache_used, - g_journal_cache_limit); + GJ_DEBUG(1, "Out of cache, force switch (used=%jd " + "limit=%jd).", (intmax_t)g_journal_cache_used, + (intmax_t)g_journal_cache_limit); } GJ_TIMER_START(1, &bt); g_journal_do_switch(mp); From owner-svn-src-head@freebsd.org Mon Aug 7 19:40:04 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 62395DC4070; Mon, 7 Aug 2017 19:40:04 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 315BD7F332; Mon, 7 Aug 2017 19:40:04 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77Je3Kl060493; Mon, 7 Aug 2017 19:40:03 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77Je3g3060491; Mon, 7 Aug 2017 19:40:03 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201708071940.v77Je3g3060491@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Mon, 7 Aug 2017 19:40:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322179 - head/sys/geom/journal X-SVN-Group: head X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: head/sys/geom/journal X-SVN-Commit-Revision: 322179 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 19:40:04 -0000 Author: mckusick Date: Mon Aug 7 19:40:03 2017 New Revision: 322179 URL: https://svnweb.freebsd.org/changeset/base/322179 Log: gjournal is broken in handling its flush_queue. If we have 10 bio's in the flush_queue: 1 2 3 4 5 6 7 8 9 10 and another 10 bio's go into the flush queue after only the first five bio's are removed from the flush queue, the queue should look like: 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20, but because of the bug we end up with 6 11 12 13 14 15 16 17 18 19 20 7 8 9 10. So the sequence of the bio's is damaged in the flush queue (and therefore in the journal on disk !). This error can be triggered by ffs_snapshot() when a block is read with readblock() and gjournal finds this block in the broken flush queue before it goes to the correct active queue. The fix is to place all new blocks at the end of the queue. Submitted by: Dr. Andreas Longwitz Discussed with: kib MFC after: 1 week Modified: head/sys/geom/journal/g_journal.c head/sys/geom/journal/g_journal.h Modified: head/sys/geom/journal/g_journal.c ============================================================================== --- head/sys/geom/journal/g_journal.c Mon Aug 7 19:18:27 2017 (r322178) +++ head/sys/geom/journal/g_journal.c Mon Aug 7 19:40:03 2017 (r322179) @@ -1261,7 +1261,7 @@ g_journal_flush(struct g_journal_softc *sc) strlcpy(hdr.jrh_magic, GJ_RECORD_HEADER_MAGIC, sizeof(hdr.jrh_magic)); bioq = &sc->sc_active.jj_queue; - pbp = sc->sc_flush_queue; + GJQ_LAST(sc->sc_flush_queue, pbp); fbp = g_alloc_bio(); fbp->bio_parent = NULL; Modified: head/sys/geom/journal/g_journal.h ============================================================================== --- head/sys/geom/journal/g_journal.h Mon Aug 7 19:18:27 2017 (r322178) +++ head/sys/geom/journal/g_journal.h Mon Aug 7 19:40:03 2017 (r322179) @@ -182,6 +182,17 @@ struct g_journal_softc { (pbp)->bio_next = (bp); \ } \ } while (0) +#define GJQ_LAST(head, bp) do { \ + struct bio *_bp; \ + \ + if ((head) == NULL) { \ + (bp) = (head); \ + break; \ + } \ + for (_bp = (head); _bp->bio_next != NULL; _bp = _bp->bio_next) \ + continue; \ + (bp) = (_bp); \ +} while (0) #define GJQ_FIRST(head) (head) #define GJQ_REMOVE(head, bp) do { \ struct bio *_bp; \ From owner-svn-src-head@freebsd.org Mon Aug 7 21:12:29 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AB6CDDC8FBE; Mon, 7 Aug 2017 21:12:29 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 843FD83111; Mon, 7 Aug 2017 21:12:29 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77LCSIK001385; Mon, 7 Aug 2017 21:12:28 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77LCSxL001381; Mon, 7 Aug 2017 21:12:28 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201708072112.v77LCSxL001381@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Mon, 7 Aug 2017 21:12:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322196 - head/sys/geom X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/geom X-SVN-Commit-Revision: 322196 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 21:12:29 -0000 Author: imp Date: Mon Aug 7 21:12:28 2017 New Revision: 322196 URL: https://svnweb.freebsd.org/changeset/base/322196 Log: Add aliasing concept to geom. Add an alias name list to geoms. Use them in geom_dev to create aliases. Previously, geom_dev would create an device node for the name of the geom. Now, additional nodes are created pointing back to the primary node with make_dev_alias_p. Aliases must be in place on the geom before any tasting occurs. Differential Revision: https://reviews.freebsd.org/D11873 Modified: head/sys/geom/geom.h head/sys/geom/geom_dev.c head/sys/geom/geom_dump.c head/sys/geom/geom_subr.c Modified: head/sys/geom/geom.h ============================================================================== --- head/sys/geom/geom.h Mon Aug 7 19:56:09 2017 (r322195) +++ head/sys/geom/geom.h Mon Aug 7 21:12:28 2017 (r322196) @@ -120,6 +120,15 @@ struct g_class { LIST_HEAD(,g_geom) geom; }; +/* + * The g_geom_alias is a list node for aliases for the geom name + * for device node creation. + */ +struct g_geom_alias { + LIST_ENTRY(g_geom_alias) ga_next; + const char *ga_alias; +}; + #define G_VERSION_00 0x19950323 #define G_VERSION_01 0x20041207 /* add fflag to g_ioctl_t */ #define G_VERSION G_VERSION_01 @@ -150,6 +159,7 @@ struct g_geom { unsigned flags; #define G_GEOM_WITHER 1 #define G_GEOM_VOLATILE_BIO 2 + LIST_HEAD(,g_geom_alias) aliases; }; /* @@ -269,6 +279,7 @@ void g_destroy_provider(struct g_provider *pp); void g_detach(struct g_consumer *cp); void g_error_provider(struct g_provider *pp, int error); struct g_provider *g_provider_by_name(char const *arg); +void g_geom_add_alias(struct g_geom *gp, const char *alias); int g_getattr__(const char *attr, struct g_consumer *cp, void *var, int len); #define g_getattr(a, c, v) g_getattr__((a), (c), (v), sizeof *(v)) int g_handleattr(struct bio *bp, const char *attribute, const void *val, Modified: head/sys/geom/geom_dev.c ============================================================================== --- head/sys/geom/geom_dev.c Mon Aug 7 19:56:09 2017 (r322195) +++ head/sys/geom/geom_dev.c Mon Aug 7 21:12:28 2017 (r322196) @@ -315,10 +315,11 @@ static struct g_geom * g_dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused) { struct g_geom *gp; + struct g_geom_alias *gap; struct g_consumer *cp; struct g_dev_softc *sc; int error; - struct cdev *dev; + struct cdev *dev, *adev; char buf[SPECNAMELEN + 6]; g_trace(G_T_TOPOLOGY, "dev_taste(%s,%s)", mp->name, pp->name); @@ -357,6 +358,23 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp, g_dev_attrchanged(cp, "GEOM::physpath"); snprintf(buf, sizeof(buf), "cdev=%s", gp->name); devctl_notify_f("GEOM", "DEV", "CREATE", buf, M_WAITOK); + /* + * Now add all the aliases for this drive + */ + LIST_FOREACH(gap, &pp->geom->aliases, ga_next) { + error = make_dev_alias_p(MAKEDEV_CHECKNAME | MAKEDEV_WAITOK, &adev, dev, + "%s", gap->ga_alias); + if (error) { + printf("%s: make_dev_alias_p() failed (name=%s, error=%d)\n", + __func__, gap->ga_alias, error); + continue; + } + adev->si_flags |= SI_UNMAPPED; + adev->si_iosize_max = dev->si_iosize_max; + adev->si_drv2 = dev->si_drv2; + snprintf(buf, sizeof(buf), "cdev=%s", gap->ga_alias); + devctl_notify_f("GEOM", "DEV", "CREATE", buf, M_WAITOK); + } return (gp); } Modified: head/sys/geom/geom_dump.c ============================================================================== --- head/sys/geom/geom_dump.c Mon Aug 7 19:56:09 2017 (r322195) +++ head/sys/geom/geom_dump.c Mon Aug 7 21:12:28 2017 (r322196) @@ -234,6 +234,7 @@ g_conf_geom(struct sbuf *sb, struct g_geom *gp, struct { struct g_consumer *cp2; struct g_provider *pp2; + struct g_geom_alias *gap; sbuf_printf(sb, " \n", gp); sbuf_printf(sb, " \n", gp->class); @@ -258,6 +259,11 @@ g_conf_geom(struct sbuf *sb, struct g_geom *gp, struct if (pp != NULL && pp != pp2) continue; g_conf_provider(sb, pp2); + } + LIST_FOREACH(gap, &gp->aliases, ga_next) { + sbuf_printf(sb, " \n"); + g_conf_printf_escaped(sb, "%s", gap->ga_alias); + sbuf_printf(sb, " \n"); } sbuf_printf(sb, " \n"); } Modified: head/sys/geom/geom_subr.c ============================================================================== --- head/sys/geom/geom_subr.c Mon Aug 7 19:56:09 2017 (r322195) +++ head/sys/geom/geom_subr.c Mon Aug 7 21:12:28 2017 (r322196) @@ -347,6 +347,7 @@ g_new_geomf(struct g_class *mp, const char *fmt, ...) gp->rank = 1; LIST_INIT(&gp->consumer); LIST_INIT(&gp->provider); + LIST_INIT(&gp->aliases); LIST_INSERT_HEAD(&mp->geom, gp, geom); TAILQ_INSERT_HEAD(&geoms, gp, geoms); strcpy(gp->name, sbuf_data(sb)); @@ -367,6 +368,7 @@ g_new_geomf(struct g_class *mp, const char *fmt, ...) void g_destroy_geom(struct g_geom *gp) { + struct g_geom_alias *gap, *gaptmp; g_topology_assert(); G_VALID_GEOM(gp); @@ -380,6 +382,8 @@ g_destroy_geom(struct g_geom *gp) g_cancel_event(gp); LIST_REMOVE(gp, geom); TAILQ_REMOVE(&geoms, gp, geoms); + LIST_FOREACH_SAFE(gap, &gp->aliases, ga_next, gaptmp) + g_free(gap); g_free(gp->name); g_free(gp); } @@ -1210,6 +1214,18 @@ g_compare_names(const char *namea, const char *nameb) if (strcmp(namea + deva, nameb + devb) == 0) return (1); return (0); +} + +void +g_geom_add_alias(struct g_geom *gp, const char *alias) +{ + struct g_geom_alias *gap; + + gap = (struct g_geom_alias *)g_malloc( + sizeof(struct g_geom_alias) + strlen(alias) + 1, M_WAITOK); + strcpy((char *)(gap + 1), alias); + gap->ga_alias = (const char *)(gap + 1); + LIST_INSERT_HEAD(&gp->aliases, gap, ga_next); } #if defined(DIAGNOSTIC) || defined(DDB) From owner-svn-src-head@freebsd.org Mon Aug 7 21:12:34 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B534BDC8FDA; Mon, 7 Aug 2017 21:12:34 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7876C83126; Mon, 7 Aug 2017 21:12:34 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77LCXof001438; Mon, 7 Aug 2017 21:12:33 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77LCXcH001437; Mon, 7 Aug 2017 21:12:33 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201708072112.v77LCXcH001437@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Mon, 7 Aug 2017 21:12:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322197 - head/sys/geom/part X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/geom/part X-SVN-Commit-Revision: 322197 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 21:12:34 -0000 Author: imp Date: Mon Aug 7 21:12:33 2017 New Revision: 322197 URL: https://svnweb.freebsd.org/changeset/base/322197 Log: Add alias support to gpart. When we're creating new providers for each of the partitions, add aliases to the geom before we create the provider so when geom_dev tastes the provider, the aliases are in place so the proper /dev entries are created. So foo5p6 gets created as an alias for bar5p6 when foo is an alias for bar in the geom we're partitioning with g_part. This also copies aliases from the container geom (eg disk) to the label geom (the disk with GPT partitioning) so that aliases nest properly. Differential Revision: https://reviews.freebsd.org/D11873 Modified: head/sys/geom/part/g_part.c Modified: head/sys/geom/part/g_part.c ============================================================================== --- head/sys/geom/part/g_part.c Mon Aug 7 21:12:28 2017 (r322196) +++ head/sys/geom/part/g_part.c Mon Aug 7 21:12:33 2017 (r322197) @@ -429,6 +429,7 @@ g_part_new_provider(struct g_geom *gp, struct g_part_t struct g_consumer *cp; struct g_provider *pp; struct sbuf *sb; + struct g_geom_alias *gap; off_t offset; cp = LIST_FIRST(&gp->consumer); @@ -439,6 +440,19 @@ g_part_new_provider(struct g_geom *gp, struct g_part_t entry->gpe_offset = offset; if (entry->gpe_pp == NULL) { + /* + * Add aliases to the geom before we create the provider so that + * geom_dev can taste it with all the aliases in place so all + * the aliased dev_t instances get created for each partition + * (eg foo5p7 gets created for bar5p7 when foo is an alias of bar). + */ + LIST_FOREACH(gap, &table->gpt_gp->aliases, ga_next) { + sb = sbuf_new_auto(); + G_PART_FULLNAME(table, entry, sb, gap->ga_alias); + sbuf_finish(sb); + g_geom_add_alias(gp, sbuf_data(sb)); + sbuf_delete(sb); + } sb = sbuf_new_auto(); G_PART_FULLNAME(table, entry, sb, gp->name); sbuf_finish(sb); @@ -1901,6 +1915,7 @@ g_part_taste(struct g_class *mp, struct g_provider *pp struct g_part_entry *entry; struct g_part_table *table; struct root_hold_token *rht; + struct g_geom_alias *gap; int attr, depth; int error; @@ -1913,10 +1928,12 @@ g_part_taste(struct g_class *mp, struct g_provider *pp /* * Create a GEOM with consumer and hook it up to the provider. - * With that we become part of the topology. Optain read access + * With that we become part of the topology. Obtain read access * to the provider. */ gp = g_new_geomf(mp, "%s", pp->name); + LIST_FOREACH(gap, &pp->geom->aliases, ga_next) + g_geom_add_alias(gp, gap->ga_alias); cp = g_new_consumer(gp); cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE; error = g_attach(cp, pp); From owner-svn-src-head@freebsd.org Mon Aug 7 21:12:40 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0CEBFDC9022; Mon, 7 Aug 2017 21:12:40 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DAD2083196; Mon, 7 Aug 2017 21:12:39 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77LCdEt001492; Mon, 7 Aug 2017 21:12:39 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77LCcXm001489; Mon, 7 Aug 2017 21:12:38 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201708072112.v77LCcXm001489@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Mon, 7 Aug 2017 21:12:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322198 - in head: share/man/man9 sys/geom X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: in head: share/man/man9 sys/geom X-SVN-Commit-Revision: 322198 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 21:12:40 -0000 Author: imp Date: Mon Aug 7 21:12:38 2017 New Revision: 322198 URL: https://svnweb.freebsd.org/changeset/base/322198 Log: Expose API to allow disks to ask for alias names in devfs. Implement disk_add_alias to allow aliases to be added to disks. All disk have a primary name (say "foo") can also have secondary names (say "bar") such that all instances of "foo" also have a "bar" alias. So if you have foo0, foo0p1, foo1, foo1s1 and foo1s1a nodes created by the foo driver and gpart, device nodes bar0, bar0p1, bar1, bar1s1 and bar1s1a will appear as symlinks back to the original nodes. This generalizes to multiple aliases. However, since the unit number follows the primary name, multiple device drivers can't create the same aliases unless those drives coorinate the unit number space (eg you couldn't add an alias 'disk' to both 'da' and 'ada' because it's possible to have da0 and ada0, because 'disk0' is ambiguous). Differential Revision: https://reviews.freebsd.org/D11873 Modified: head/share/man/man9/disk.9 head/sys/geom/geom_disk.c head/sys/geom/geom_disk.h Modified: head/share/man/man9/disk.9 ============================================================================== --- head/share/man/man9/disk.9 Mon Aug 7 21:12:33 2017 (r322197) +++ head/share/man/man9/disk.9 Mon Aug 7 21:12:38 2017 (r322198) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 30, 2012 +.Dd August 3, 2017 .Dt DISK 9 .Os .Sh NAME @@ -45,6 +45,8 @@ .Fn disk_destroy "struct disk *disk" .Ft int .Fn disk_resize "struct disk *disk" "int flags" +.Ft void +.Fn disk_add_alias "struct disk *disk" "const char *alias" .Sh DESCRIPTION The disk storage API permits kernel device drivers providing access to disk-like storage devices to advertise the device to other kernel @@ -69,6 +71,20 @@ function, fill in the fields and call .Fn disk_create when the device is ready to service requests. +.Fn disk_add_alias +adds an alias for the disk and must be called before +.Fn disk_create , +but may be called multiple times. +For each alias added, a device node will be created with +.Xr make_dev_alias 9 +in the same way primary device nodes are created with +.Xr make_dev 9 +for +.Va d_name +and +.Va d_unit . +Care should be taken to ensure that only one driver creates aliases +for any given name. .Fn disk_resize can be called by the driver after modifying .Va d_mediasize @@ -227,7 +243,13 @@ structure for this disk device. .El .Sh SEE ALSO .Xr GEOM 4 , -.Xr devfs 5 +.Xr devfs 5 , +.Xr MAKE_DEV 9 .Sh AUTHORS This manual page was written by .An Robert Watson . +.Sh BUGS +Disk aliases are not a general purpose aliasing mechanism, but are +intended only to ease the transition from one name to another. +They can be used to ensure that nvd0 and nda0 are the same thing. +They cannot be used to implement the diskX concept from macOS. Modified: head/sys/geom/geom_disk.c ============================================================================== --- head/sys/geom/geom_disk.c Mon Aug 7 21:12:33 2017 (r322197) +++ head/sys/geom/geom_disk.c Mon Aug 7 21:12:38 2017 (r322198) @@ -676,6 +676,7 @@ g_disk_create(void *arg, int flag) struct g_provider *pp; struct disk *dp; struct g_disk_softc *sc; + struct disk_alias *dap; char tmpstr[80]; if (flag == EV_CANCEL) @@ -704,6 +705,10 @@ g_disk_create(void *arg, int flag) sc->dp = dp; gp = g_new_geomf(&g_disk_class, "%s%d", dp->d_name, dp->d_unit); gp->softc = sc; + LIST_FOREACH(dap, &dp->d_aliases, da_next) { + snprintf(tmpstr, sizeof(tmpstr), "%s%d", dap->da_alias, dp->d_unit); + g_geom_add_alias(gp, tmpstr); + } pp = g_new_providerf(gp, "%s", gp->name); devstat_remove_entry(pp->stat); pp->stat = NULL; @@ -791,6 +796,7 @@ g_disk_destroy(void *ptr, int flag) struct disk *dp; struct g_geom *gp; struct g_disk_softc *sc; + struct disk_alias *dap, *daptmp; g_topology_assert(); dp = ptr; @@ -802,6 +808,8 @@ g_disk_destroy(void *ptr, int flag) dp->d_geom = NULL; g_wither_geom(gp, ENXIO); } + LIST_FOREACH_SAFE(dap, &dp->d_aliases, da_next, daptmp) + g_free(dap); g_free(dp); } @@ -834,8 +842,11 @@ g_disk_ident_adjust(char *ident, size_t size) struct disk * disk_alloc(void) { + struct disk *dp; - return (g_malloc(sizeof(struct disk), M_WAITOK | M_ZERO)); + dp = g_malloc(sizeof(struct disk), M_WAITOK | M_ZERO); + LIST_INIT(&dp->d_aliases); + return (dp); } void @@ -882,6 +893,18 @@ disk_destroy(struct disk *dp) if (dp->d_devstat != NULL) devstat_remove_entry(dp->d_devstat); g_post_event(g_disk_destroy, dp, M_WAITOK, NULL); +} + +void +disk_add_alias(struct disk *dp, const char *name) +{ + struct disk_alias *dap; + + dap = (struct disk_alias *)g_malloc( + sizeof(struct disk_alias) + strlen(name) + 1, M_WAITOK); + strcpy((char *)(dap + 1), name); + dap->da_alias = (const char *)(dap + 1); + LIST_INSERT_HEAD(&dp->d_aliases, dap, da_next); } void Modified: head/sys/geom/geom_disk.h ============================================================================== --- head/sys/geom/geom_disk.h Mon Aug 7 21:12:33 2017 (r322197) +++ head/sys/geom/geom_disk.h Mon Aug 7 21:12:38 2017 (r322198) @@ -66,6 +66,11 @@ typedef enum { DISK_INIT_DONE } disk_init_level; +struct disk_alias { + LIST_ENTRY(disk_alias) da_next; + const char *da_alias; +}; + struct disk { /* Fields which are private to geom_disk */ struct g_geom *d_geom; @@ -109,6 +114,9 @@ struct disk { /* Fields private to the driver */ void *d_drv1; + + /* Fields private to geom_disk, to be moved on next version bump */ + LIST_HEAD(,disk_alias) d_aliases; }; #define DISKFLAG_RESERVED 0x1 /* Was NEEDSGIANT */ @@ -132,6 +140,7 @@ void disk_attr_changed(struct disk *dp, const char *at void disk_media_changed(struct disk *dp, int flag); void disk_media_gone(struct disk *dp, int flag); int disk_resize(struct disk *dp, int flag); +void disk_add_alias(struct disk *disk, const char *); #define DISK_VERSION_00 0x58561059 #define DISK_VERSION_01 0x5856105a From owner-svn-src-head@freebsd.org Mon Aug 7 21:12:45 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0E778DC9074; Mon, 7 Aug 2017 21:12:45 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D0DD68322F; Mon, 7 Aug 2017 21:12:44 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77LChjK001555; Mon, 7 Aug 2017 21:12:43 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77LChcT001554; Mon, 7 Aug 2017 21:12:43 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201708072112.v77LChcT001554@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Mon, 7 Aug 2017 21:12:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322199 - head/sys/cam/nvme X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/cam/nvme X-SVN-Commit-Revision: 322199 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 21:12:45 -0000 Author: imp Date: Mon Aug 7 21:12:43 2017 New Revision: 322199 URL: https://svnweb.freebsd.org/changeset/base/322199 Log: Add nvd alias to nda ndoes. All ndaX and ndaXpY nodes will appear as nvdX and nvdXpY as well (through symlinks in devfs via the normal disk aliasing mechanism in GEOM). Differential Revision: https://reviews.freebsd.org/D11873 Modified: head/sys/cam/nvme/nvme_da.c Modified: head/sys/cam/nvme/nvme_da.c ============================================================================== --- head/sys/cam/nvme/nvme_da.c Mon Aug 7 21:12:38 2017 (r322198) +++ head/sys/cam/nvme/nvme_da.c Mon Aug 7 21:12:43 2017 (r322199) @@ -808,6 +808,10 @@ ndaregister(struct cam_periph *periph, void *arg) DEVSTAT_ALL_SUPPORTED, DEVSTAT_TYPE_DIRECT | XPORT_DEVSTAT_TYPE(cpi.transport), DEVSTAT_PRIORITY_DISK); + /* + * Add alias for older nvd drives to ease transition. + */ + disk_add_alias(disk, "nvd"); /* * Acquire a reference to the periph before we register with GEOM. From owner-svn-src-head@freebsd.org Mon Aug 7 21:23:55 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D9EBBDC99ED; Mon, 7 Aug 2017 21:23:55 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B454B83ACF; Mon, 7 Aug 2017 21:23:55 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77LNs3C005749; Mon, 7 Aug 2017 21:23:54 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77LNsfC005748; Mon, 7 Aug 2017 21:23:54 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201708072123.v77LNsfC005748@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Mon, 7 Aug 2017 21:23:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322200 - head/sbin/fsck_ffs X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sbin/fsck_ffs X-SVN-Commit-Revision: 322200 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 21:23:56 -0000 Author: imp Date: Mon Aug 7 21:23:54 2017 New Revision: 322200 URL: https://svnweb.freebsd.org/changeset/base/322200 Log: Make it possible to ignore superblock mismatch. This will not fix such a mismatch, but will allow fsck to continue when the last alternate superblock gets corrupted somehow. Also, remove searching for alternate super blocks. It should have been removed two years ago with r276737 by imp@. Leave minor vestiges in place in case someone wants to solve the hard problem of knowing where altnernate superblocks live without access to data formerly stored in disklabels. Differential Revision: https://reviews.freebsd.org/D11589 Modified: head/sbin/fsck_ffs/setup.c Modified: head/sbin/fsck_ffs/setup.c ============================================================================== --- head/sbin/fsck_ffs/setup.c Mon Aug 7 21:12:43 2017 (r322199) +++ head/sbin/fsck_ffs/setup.c Mon Aug 7 21:23:54 2017 (r322200) @@ -68,10 +68,9 @@ static void badsb(int listerr, const char *s); int setup(char *dev) { - long cg, asked, i, j; + long asked, i, j; long bmapsize; struct stat statb; - struct fs proto; size_t size; havesb = 0; @@ -178,26 +177,8 @@ setup(char *dev) skipclean = 0; if (bflag || preen) return(0); - if (reply("LOOK FOR ALTERNATE SUPERBLOCKS") == 0) - return (0); - for (cg = 0; cg < proto.fs_ncg; cg++) { - bflag = fsbtodb(&proto, cgsblock(&proto, cg)); - if (readsb(0) != 0) - break; - } - if (cg >= proto.fs_ncg) { - printf("%s %s\n%s %s\n%s %s\n", - "SEARCH FOR ALTERNATE SUPER-BLOCK", - "FAILED. YOU MUST USE THE", - "-b OPTION TO FSCK TO SPECIFY THE", - "LOCATION OF AN ALTERNATE", - "SUPER-BLOCK TO SUPPLY NEEDED", - "INFORMATION; SEE fsck_ffs(8)."); - bflag = 0; - return(0); - } - pwarn("USING ALTERNATE SUPERBLOCK AT %jd\n", bflag); - bflag = 0; + /* Looking for alternates is hard punt for now but retain structure */ + return (0); } if (skipclean && ckclean && sblock.fs_clean) { pwarn("FILE SYSTEM CLEAN; SKIPPING CHECKS\n"); @@ -393,9 +374,16 @@ readsb(int listerr) altsblock.fs_ipg != sblock.fs_ipg || altsblock.fs_fpg != sblock.fs_fpg || altsblock.fs_magic != sblock.fs_magic) { - badsb(listerr, - "VALUES IN SUPER BLOCK DISAGREE WITH THOSE IN FIRST ALTERNATE"); - return (0); + if (listerr == 0) + return (0); + if (preen) + printf("%s: ", cdevname); + printf( + "VALUES IN SUPER BLOCK LSB=%jd DISAGREE WITH THOSE IN\n" + "FIRST ALTERNATE LSB=%jd\n", + sblk.b_bno, asblk.b_bno); + if (reply("IGNORE ALTERNATE SUPER BLOCK") == 0) + return (0); } out: /* @@ -415,17 +403,6 @@ out: } havesb = 1; return (1); -} - -static void -badsb(int listerr, const char *s) -{ - - if (!listerr) - return; - if (preen) - printf("%s: ", cdevname); - pfatal("BAD SUPER BLOCK: %s\n", s); } void From owner-svn-src-head@freebsd.org Mon Aug 7 21:24:01 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1EBF6DC9A36; Mon, 7 Aug 2017 21:24:01 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F02AC83B35; Mon, 7 Aug 2017 21:24:00 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77LO0sl005806; Mon, 7 Aug 2017 21:24:00 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77LO0fj005805; Mon, 7 Aug 2017 21:24:00 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201708072124.v77LO0fj005805@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Mon, 7 Aug 2017 21:24:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322201 - head/sbin/fsck_ffs X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sbin/fsck_ffs X-SVN-Commit-Revision: 322201 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 21:24:01 -0000 Author: imp Date: Mon Aug 7 21:23:59 2017 New Revision: 322201 URL: https://svnweb.freebsd.org/changeset/base/322201 Log: In debug mode, print the differences between the superblock and alternate superblock when the values disagree and we're going to reject it. Differential Revision: https://reviews.freebsd.org/D11589 Modified: head/sbin/fsck_ffs/setup.c Modified: head/sbin/fsck_ffs/setup.c ============================================================================== --- head/sbin/fsck_ffs/setup.c Mon Aug 7 21:23:54 2017 (r322200) +++ head/sbin/fsck_ffs/setup.c Mon Aug 7 21:23:59 2017 (r322201) @@ -294,7 +294,7 @@ int readsb(int listerr) { ufs2_daddr_t super; - int i; + int i, bad; if (bflag) { super = bflag; @@ -344,43 +344,53 @@ readsb(int listerr) dev_bsize = sblock.fs_fsize / fsbtodb(&sblock, 1); sblk.b_bno = super / dev_bsize; sblk.b_size = SBLOCKSIZE; - if (bflag) - goto out; /* * Compare all fields that should not differ in alternate super block. * When an alternate super-block is specified this check is skipped. */ + if (bflag) + goto out; getblk(&asblk, cgsblock(&sblock, sblock.fs_ncg - 1), sblock.fs_sbsize); if (asblk.b_errs) return (0); - if (altsblock.fs_sblkno != sblock.fs_sblkno || - altsblock.fs_cblkno != sblock.fs_cblkno || - altsblock.fs_iblkno != sblock.fs_iblkno || - altsblock.fs_dblkno != sblock.fs_dblkno || - altsblock.fs_ncg != sblock.fs_ncg || - altsblock.fs_bsize != sblock.fs_bsize || - altsblock.fs_fsize != sblock.fs_fsize || - altsblock.fs_frag != sblock.fs_frag || - altsblock.fs_bmask != sblock.fs_bmask || - altsblock.fs_fmask != sblock.fs_fmask || - altsblock.fs_bshift != sblock.fs_bshift || - altsblock.fs_fshift != sblock.fs_fshift || - altsblock.fs_fragshift != sblock.fs_fragshift || - altsblock.fs_fsbtodb != sblock.fs_fsbtodb || - altsblock.fs_sbsize != sblock.fs_sbsize || - altsblock.fs_nindir != sblock.fs_nindir || - altsblock.fs_inopb != sblock.fs_inopb || - altsblock.fs_cssize != sblock.fs_cssize || - altsblock.fs_ipg != sblock.fs_ipg || - altsblock.fs_fpg != sblock.fs_fpg || - altsblock.fs_magic != sblock.fs_magic) { + bad = 0; +#define CHK(x, y) \ + if (altsblock.x != sblock.x) { \ + bad++; \ + if (listerr && debug) \ + printf("SUPER BLOCK VS ALTERNATE MISMATCH %s: " y " vs " y "\n", \ + #x, (intmax_t)sblock.x, (intmax_t)altsblock.x); \ + } + CHK(fs_sblkno, "%jd"); + CHK(fs_cblkno, "%jd"); + CHK(fs_iblkno, "%jd"); + CHK(fs_dblkno, "%jd"); + CHK(fs_ncg, "%jd"); + CHK(fs_bsize, "%jd"); + CHK(fs_fsize, "%jd"); + CHK(fs_frag, "%jd"); + CHK(fs_bmask, "%#jx"); + CHK(fs_fmask, "%#jx"); + CHK(fs_bshift, "%jd"); + CHK(fs_fshift, "%jd"); + CHK(fs_fragshift, "%jd"); + CHK(fs_fsbtodb, "%jd"); + CHK(fs_sbsize, "%jd"); + CHK(fs_nindir, "%jd"); + CHK(fs_inopb, "%jd"); + CHK(fs_cssize, "%jd"); + CHK(fs_ipg, "%jd"); + CHK(fs_fpg, "%jd"); + CHK(fs_magic, "%#jx"); +#undef CHK + if (bad) { if (listerr == 0) return (0); if (preen) printf("%s: ", cdevname); printf( "VALUES IN SUPER BLOCK LSB=%jd DISAGREE WITH THOSE IN\n" - "FIRST ALTERNATE LSB=%jd\n", + "LAST ALTERNATE LSB=%jd\n", sblk.b_bno, asblk.b_bno); if (reply("IGNORE ALTERNATE SUPER BLOCK") == 0) return (0); From owner-svn-src-head@freebsd.org Mon Aug 7 21:29:29 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0C457DC9E71; Mon, 7 Aug 2017 21:29:29 +0000 (UTC) (envelope-from nwhitehorn@freebsd.org) Received: from c.mail.sonic.net (c.mail.sonic.net [64.142.111.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EC1C583F1C; Mon, 7 Aug 2017 21:29:28 +0000 (UTC) (envelope-from nwhitehorn@freebsd.org) Received: from aurora.physics.berkeley.edu (aurora.physics.berkeley.edu [128.32.117.67]) (authenticated bits=0) by c.mail.sonic.net (8.15.1/8.15.1) with ESMTPSA id v77LJ9at020655 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Mon, 7 Aug 2017 14:19:09 -0700 Subject: Re: svn commit: r322198 - in head: share/man/man9 sys/geom To: Warner Losh , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201708072112.v77LCcXm001489@repo.freebsd.org> From: Nathan Whitehorn Message-ID: Date: Mon, 7 Aug 2017 14:19:08 -0700 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <201708072112.v77LCcXm001489@repo.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Sonic-CAuth: UmFuZG9tSVZanR1XNDjwUc+d68kKRHx9cZPgvD2jA9A4qr1UorDYX7HUzHVija80Qsyyp6dGYx6Ffx1jBBljpnoYyED+uRJF4Nw54js4q08= X-Sonic-ID: C;kngODbZ75xGdWMGbEi49jA== M;4uhNDbZ75xGdWMGbEi49jA== X-Spam-Flag: No X-Sonic-Spam-Details: 0.0/5.0 by cerberusd X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 21:29:29 -0000 It would be really nice to let gpart provide aliases correct to partition labels, which would fix the existing racy and unreliable glabel code. Do you see any obstacles to using this code for that? -Nathan On 08/07/17 14:12, Warner Losh wrote: > Author: imp > Date: Mon Aug 7 21:12:38 2017 > New Revision: 322198 > URL: https://svnweb.freebsd.org/changeset/base/322198 > > Log: > Expose API to allow disks to ask for alias names in devfs. > > Implement disk_add_alias to allow aliases to be added to disks. All > disk have a primary name (say "foo") can also have secondary names > (say "bar") such that all instances of "foo" also have a "bar" > alias. So if you have foo0, foo0p1, foo1, foo1s1 and foo1s1a nodes > created by the foo driver and gpart, device nodes bar0, bar0p1, bar1, > bar1s1 and bar1s1a will appear as symlinks back to the original nodes. > This generalizes to multiple aliases. However, since the unit number > follows the primary name, multiple device drivers can't create the > same aliases unless those drives coorinate the unit number space (eg > you couldn't add an alias 'disk' to both 'da' and 'ada' because it's > possible to have da0 and ada0, because 'disk0' is ambiguous). > > Differential Revision: https://reviews.freebsd.org/D11873 > > Modified: > head/share/man/man9/disk.9 > head/sys/geom/geom_disk.c > head/sys/geom/geom_disk.h > > Modified: head/share/man/man9/disk.9 > ============================================================================== > --- head/share/man/man9/disk.9 Mon Aug 7 21:12:33 2017 (r322197) > +++ head/share/man/man9/disk.9 Mon Aug 7 21:12:38 2017 (r322198) > @@ -27,7 +27,7 @@ > .\" > .\" $FreeBSD$ > .\" > -.Dd October 30, 2012 > +.Dd August 3, 2017 > .Dt DISK 9 > .Os > .Sh NAME > @@ -45,6 +45,8 @@ > .Fn disk_destroy "struct disk *disk" > .Ft int > .Fn disk_resize "struct disk *disk" "int flags" > +.Ft void > +.Fn disk_add_alias "struct disk *disk" "const char *alias" > .Sh DESCRIPTION > The disk storage API permits kernel device drivers providing access to > disk-like storage devices to advertise the device to other kernel > @@ -69,6 +71,20 @@ function, > fill in the fields and call > .Fn disk_create > when the device is ready to service requests. > +.Fn disk_add_alias > +adds an alias for the disk and must be called before > +.Fn disk_create , > +but may be called multiple times. > +For each alias added, a device node will be created with > +.Xr make_dev_alias 9 > +in the same way primary device nodes are created with > +.Xr make_dev 9 > +for > +.Va d_name > +and > +.Va d_unit . > +Care should be taken to ensure that only one driver creates aliases > +for any given name. > .Fn disk_resize > can be called by the driver after modifying > .Va d_mediasize > @@ -227,7 +243,13 @@ structure for this disk device. > .El > .Sh SEE ALSO > .Xr GEOM 4 , > -.Xr devfs 5 > +.Xr devfs 5 , > +.Xr MAKE_DEV 9 > .Sh AUTHORS > This manual page was written by > .An Robert Watson . > +.Sh BUGS > +Disk aliases are not a general purpose aliasing mechanism, but are > +intended only to ease the transition from one name to another. > +They can be used to ensure that nvd0 and nda0 are the same thing. > +They cannot be used to implement the diskX concept from macOS. > > Modified: head/sys/geom/geom_disk.c > ============================================================================== > --- head/sys/geom/geom_disk.c Mon Aug 7 21:12:33 2017 (r322197) > +++ head/sys/geom/geom_disk.c Mon Aug 7 21:12:38 2017 (r322198) > @@ -676,6 +676,7 @@ g_disk_create(void *arg, int flag) > struct g_provider *pp; > struct disk *dp; > struct g_disk_softc *sc; > + struct disk_alias *dap; > char tmpstr[80]; > > if (flag == EV_CANCEL) > @@ -704,6 +705,10 @@ g_disk_create(void *arg, int flag) > sc->dp = dp; > gp = g_new_geomf(&g_disk_class, "%s%d", dp->d_name, dp->d_unit); > gp->softc = sc; > + LIST_FOREACH(dap, &dp->d_aliases, da_next) { > + snprintf(tmpstr, sizeof(tmpstr), "%s%d", dap->da_alias, dp->d_unit); > + g_geom_add_alias(gp, tmpstr); > + } > pp = g_new_providerf(gp, "%s", gp->name); > devstat_remove_entry(pp->stat); > pp->stat = NULL; > @@ -791,6 +796,7 @@ g_disk_destroy(void *ptr, int flag) > struct disk *dp; > struct g_geom *gp; > struct g_disk_softc *sc; > + struct disk_alias *dap, *daptmp; > > g_topology_assert(); > dp = ptr; > @@ -802,6 +808,8 @@ g_disk_destroy(void *ptr, int flag) > dp->d_geom = NULL; > g_wither_geom(gp, ENXIO); > } > + LIST_FOREACH_SAFE(dap, &dp->d_aliases, da_next, daptmp) > + g_free(dap); > > g_free(dp); > } > @@ -834,8 +842,11 @@ g_disk_ident_adjust(char *ident, size_t size) > struct disk * > disk_alloc(void) > { > + struct disk *dp; > > - return (g_malloc(sizeof(struct disk), M_WAITOK | M_ZERO)); > + dp = g_malloc(sizeof(struct disk), M_WAITOK | M_ZERO); > + LIST_INIT(&dp->d_aliases); > + return (dp); > } > > void > @@ -882,6 +893,18 @@ disk_destroy(struct disk *dp) > if (dp->d_devstat != NULL) > devstat_remove_entry(dp->d_devstat); > g_post_event(g_disk_destroy, dp, M_WAITOK, NULL); > +} > + > +void > +disk_add_alias(struct disk *dp, const char *name) > +{ > + struct disk_alias *dap; > + > + dap = (struct disk_alias *)g_malloc( > + sizeof(struct disk_alias) + strlen(name) + 1, M_WAITOK); > + strcpy((char *)(dap + 1), name); > + dap->da_alias = (const char *)(dap + 1); > + LIST_INSERT_HEAD(&dp->d_aliases, dap, da_next); > } > > void > > Modified: head/sys/geom/geom_disk.h > ============================================================================== > --- head/sys/geom/geom_disk.h Mon Aug 7 21:12:33 2017 (r322197) > +++ head/sys/geom/geom_disk.h Mon Aug 7 21:12:38 2017 (r322198) > @@ -66,6 +66,11 @@ typedef enum { > DISK_INIT_DONE > } disk_init_level; > > +struct disk_alias { > + LIST_ENTRY(disk_alias) da_next; > + const char *da_alias; > +}; > + > struct disk { > /* Fields which are private to geom_disk */ > struct g_geom *d_geom; > @@ -109,6 +114,9 @@ struct disk { > > /* Fields private to the driver */ > void *d_drv1; > + > + /* Fields private to geom_disk, to be moved on next version bump */ > + LIST_HEAD(,disk_alias) d_aliases; > }; > > #define DISKFLAG_RESERVED 0x1 /* Was NEEDSGIANT */ > @@ -132,6 +140,7 @@ void disk_attr_changed(struct disk *dp, const char *at > void disk_media_changed(struct disk *dp, int flag); > void disk_media_gone(struct disk *dp, int flag); > int disk_resize(struct disk *dp, int flag); > +void disk_add_alias(struct disk *disk, const char *); > > #define DISK_VERSION_00 0x58561059 > #define DISK_VERSION_01 0x5856105a > From owner-svn-src-head@freebsd.org Mon Aug 7 21:29:43 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2216EDC9ED7; Mon, 7 Aug 2017 21:29:43 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A8CBD83FDB; Mon, 7 Aug 2017 21:29:42 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v77LTbCV054758 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 8 Aug 2017 00:29:38 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v77LTbCV054758 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v77LTbZm054757; Tue, 8 Aug 2017 00:29:37 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 8 Aug 2017 00:29:37 +0300 From: Konstantin Belousov To: Warner Losh Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r322196 - head/sys/geom Message-ID: <20170807212937.GJ1700@kib.kiev.ua> References: <201708072112.v77LCSxL001381@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201708072112.v77LCSxL001381@repo.freebsd.org> User-Agent: Mutt/1.8.3 (2017-05-23) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 21:29:43 -0000 On Mon, Aug 07, 2017 at 09:12:28PM +0000, Warner Losh wrote: > + LIST_FOREACH(gap, &pp->geom->aliases, ga_next) { > + error = make_dev_alias_p(MAKEDEV_CHECKNAME | MAKEDEV_WAITOK, &adev, dev, > + "%s", gap->ga_alias); > + if (error) { > + printf("%s: make_dev_alias_p() failed (name=%s, error=%d)\n", > + __func__, gap->ga_alias, error); > + continue; > + } > + adev->si_flags |= SI_UNMAPPED; Why do you set the flag unconditionally ? > + adev->si_iosize_max = dev->si_iosize_max; > + adev->si_drv2 = dev->si_drv2; And what are you trying to do by these initializations, including the si_flags adjustment ? Aliases cause creation of symlinks in the devfs populate loop, which makes it impossible to access the alias cdevs. From owner-svn-src-head@freebsd.org Mon Aug 7 21:29:56 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F2575DC9F58; Mon, 7 Aug 2017 21:29:56 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C0C1984121; Mon, 7 Aug 2017 21:29:56 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77LTtIt006046; Mon, 7 Aug 2017 21:29:55 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77LTtDB006045; Mon, 7 Aug 2017 21:29:55 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201708072129.v77LTtDB006045@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 7 Aug 2017 21:29:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322202 - head X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head X-SVN-Commit-Revision: 322202 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 21:29:57 -0000 Author: emaste Date: Mon Aug 7 21:29:55 2017 New Revision: 322202 URL: https://svnweb.freebsd.org/changeset/base/322202 Log: UPDATING: clarify what the RCMDS knob controls Modified: head/UPDATING Modified: head/UPDATING ============================================================================== --- head/UPDATING Mon Aug 7 21:23:59 2017 (r322201) +++ head/UPDATING Mon Aug 7 21:29:55 2017 (r322202) @@ -64,8 +64,8 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW: and upgrading, if you are not already using clang 3.5.0 or higher. 20170701: - WITHOUT_RCMDS is now the default. Set WITH_RCMDS if you need them to be - built with the base system. + WITHOUT_RCMDS is now the default. Set WITH_RCMDS if you need the + r-commands (rlogin, rsh, etc.) to be built with the base system. 20170625: The FreeBSD/powerpc platform now uses a 64-bit type for time_t. This is From owner-svn-src-head@freebsd.org Mon Aug 7 21:32:04 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 326A1DCA358 for ; Mon, 7 Aug 2017 21:32:04 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x22e.google.com (mail-it0-x22e.google.com [IPv6:2607:f8b0:4001:c0b::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EA93884583 for ; Mon, 7 Aug 2017 21:32:03 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x22e.google.com with SMTP id 77so9730800itj.1 for ; Mon, 07 Aug 2017 14:32:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=uvmBlFI9/OKaLGRNZINyvZi35LbG4SJzA0YnDK6uPMY=; b=AnkYRzeBMqvSBkJzCV/jELo5OtAzV6jZFmk/OyZQwXX5cV4wo5kNWr+TPBljbe//Pk VWQJu8eo1POQJM+kEhBfuJT+WmPR7kFlFw1qmJ65eWV6bwM8HqaMBN1Lwm6HO6PaAncQ gvDxCgM7c2E81l9+u+ipbcdjAzJii8rJ67hRxqcapgWe2rrk4B7cx3BQTlv2KZidBhDG yH2l6gyuZeyYwSK0ZWBhx4qKkhQrTG66pLv42SwXH4MLqpEhKcqpDiQIwJQPFlh3m+p9 /d0R3wldDtSFYQzsfiktdBcV1h6kgKDSIeEQNb6zCEYsaUuj9C+CRp/OflZExKAC7SzO djmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=uvmBlFI9/OKaLGRNZINyvZi35LbG4SJzA0YnDK6uPMY=; b=rKW1iRMRDrVDMmqAfjXBvEoQI8pyCMG7FoxkWGVyH78QQUMi/2lc6sMFNyEj9cUWs8 LgdW/KVK7xunIF5n9prgr8rtVzPpWwhuy+ijFzCZU2Zoc6VVTaK2elB7IN0jCVrkWb2l NjvITQ25j4CEl4/K4KI3XWYWo6vhfA0z3RQ4L9XeI6Da7EkrqXJi0HsZeh77kpIQCcQl ZNypuO6ttEtwg94vmX4HzLTKFu98B+tftoMMGBE1U3wdcypbUUGx+7IzDa7H9iEyDXEw nnVrD9JcQxJn0izyzTFMSc00zWsZeHVySb4k5UaXnlhh0idC0N0t9GgvNqWt3L+TT19T ffmA== X-Gm-Message-State: AIVw110IVGwGmw6873lAhIsbhK5r/tZ7OTkpIRqXxxlMCU0hwTTxvqek jAbtYdyPp0SFUVbpbPwbx35QFppN5xub X-Received: by 10.36.101.2 with SMTP id u2mr2271056itb.38.1502141523246; Mon, 07 Aug 2017 14:32:03 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.10.71 with HTTP; Mon, 7 Aug 2017 14:32:02 -0700 (PDT) X-Originating-IP: [2603:300b:6:5100:f809:2296:13f6:2a42] In-Reply-To: References: <201708072112.v77LCcXm001489@repo.freebsd.org> From: Warner Losh Date: Mon, 7 Aug 2017 15:32:02 -0600 X-Google-Sender-Auth: 04HUKsAClqfiG0KP1UGUg_AXnJ8 Message-ID: Subject: Re: svn commit: r322198 - in head: share/man/man9 sys/geom To: Nathan Whitehorn Cc: Warner Losh , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 21:32:04 -0000 On Mon, Aug 7, 2017 at 3:19 PM, Nathan Whitehorn wrote: > It would be really nice to let gpart provide aliases correct to partition > labels, which would fix the existing racy and unreliable glabel code. Do > you see any obstacles to using this code for that? I'm not sure I understand well enough the issue here to have an opinion. Warner On 08/07/17 14:12, Warner Losh wrote: > >> Author: imp >> Date: Mon Aug 7 21:12:38 2017 >> New Revision: 322198 >> URL: https://svnweb.freebsd.org/changeset/base/322198 >> >> Log: >> Expose API to allow disks to ask for alias names in devfs. >> Implement disk_add_alias to allow aliases to be added to disks. All >> disk have a primary name (say "foo") can also have secondary names >> (say "bar") such that all instances of "foo" also have a "bar" >> alias. So if you have foo0, foo0p1, foo1, foo1s1 and foo1s1a nodes >> created by the foo driver and gpart, device nodes bar0, bar0p1, bar1, >> bar1s1 and bar1s1a will appear as symlinks back to the original nodes. >> This generalizes to multiple aliases. However, since the unit number >> follows the primary name, multiple device drivers can't create the >> same aliases unless those drives coorinate the unit number space (eg >> you couldn't add an alias 'disk' to both 'da' and 'ada' because it's >> possible to have da0 and ada0, because 'disk0' is ambiguous). >> Differential Revision: https://reviews.freebsd.org/D11873 >> >> Modified: >> head/share/man/man9/disk.9 >> head/sys/geom/geom_disk.c >> head/sys/geom/geom_disk.h >> >> Modified: head/share/man/man9/disk.9 >> ============================================================ >> ================== >> --- head/share/man/man9/disk.9 Mon Aug 7 21:12:33 2017 (r322197) >> +++ head/share/man/man9/disk.9 Mon Aug 7 21:12:38 2017 (r322198) >> @@ -27,7 +27,7 @@ >> .\" >> .\" $FreeBSD$ >> .\" >> -.Dd October 30, 2012 >> +.Dd August 3, 2017 >> .Dt DISK 9 >> .Os >> .Sh NAME >> @@ -45,6 +45,8 @@ >> .Fn disk_destroy "struct disk *disk" >> .Ft int >> .Fn disk_resize "struct disk *disk" "int flags" >> +.Ft void >> +.Fn disk_add_alias "struct disk *disk" "const char *alias" >> .Sh DESCRIPTION >> The disk storage API permits kernel device drivers providing access to >> disk-like storage devices to advertise the device to other kernel >> @@ -69,6 +71,20 @@ function, >> fill in the fields and call >> .Fn disk_create >> when the device is ready to service requests. >> +.Fn disk_add_alias >> +adds an alias for the disk and must be called before >> +.Fn disk_create , >> +but may be called multiple times. >> +For each alias added, a device node will be created with >> +.Xr make_dev_alias 9 >> +in the same way primary device nodes are created with >> +.Xr make_dev 9 >> +for >> +.Va d_name >> +and >> +.Va d_unit . >> +Care should be taken to ensure that only one driver creates aliases >> +for any given name. >> .Fn disk_resize >> can be called by the driver after modifying >> .Va d_mediasize >> @@ -227,7 +243,13 @@ structure for this disk device. >> .El >> .Sh SEE ALSO >> .Xr GEOM 4 , >> -.Xr devfs 5 >> +.Xr devfs 5 , >> +.Xr MAKE_DEV 9 >> .Sh AUTHORS >> This manual page was written by >> .An Robert Watson . >> +.Sh BUGS >> +Disk aliases are not a general purpose aliasing mechanism, but are >> +intended only to ease the transition from one name to another. >> +They can be used to ensure that nvd0 and nda0 are the same thing. >> +They cannot be used to implement the diskX concept from macOS. >> >> Modified: head/sys/geom/geom_disk.c >> ============================================================ >> ================== >> --- head/sys/geom/geom_disk.c Mon Aug 7 21:12:33 2017 (r322197) >> +++ head/sys/geom/geom_disk.c Mon Aug 7 21:12:38 2017 (r322198) >> @@ -676,6 +676,7 @@ g_disk_create(void *arg, int flag) >> struct g_provider *pp; >> struct disk *dp; >> struct g_disk_softc *sc; >> + struct disk_alias *dap; >> char tmpstr[80]; >> if (flag == EV_CANCEL) >> @@ -704,6 +705,10 @@ g_disk_create(void *arg, int flag) >> sc->dp = dp; >> gp = g_new_geomf(&g_disk_class, "%s%d", dp->d_name, dp->d_unit); >> gp->softc = sc; >> + LIST_FOREACH(dap, &dp->d_aliases, da_next) { >> + snprintf(tmpstr, sizeof(tmpstr), "%s%d", dap->da_alias, >> dp->d_unit); >> + g_geom_add_alias(gp, tmpstr); >> + } >> pp = g_new_providerf(gp, "%s", gp->name); >> devstat_remove_entry(pp->stat); >> pp->stat = NULL; >> @@ -791,6 +796,7 @@ g_disk_destroy(void *ptr, int flag) >> struct disk *dp; >> struct g_geom *gp; >> struct g_disk_softc *sc; >> + struct disk_alias *dap, *daptmp; >> g_topology_assert(); >> dp = ptr; >> @@ -802,6 +808,8 @@ g_disk_destroy(void *ptr, int flag) >> dp->d_geom = NULL; >> g_wither_geom(gp, ENXIO); >> } >> + LIST_FOREACH_SAFE(dap, &dp->d_aliases, da_next, daptmp) >> + g_free(dap); >> g_free(dp); >> } >> @@ -834,8 +842,11 @@ g_disk_ident_adjust(char *ident, size_t size) >> struct disk * >> disk_alloc(void) >> { >> + struct disk *dp; >> - return (g_malloc(sizeof(struct disk), M_WAITOK | M_ZERO)); >> + dp = g_malloc(sizeof(struct disk), M_WAITOK | M_ZERO); >> + LIST_INIT(&dp->d_aliases); >> + return (dp); >> } >> void >> @@ -882,6 +893,18 @@ disk_destroy(struct disk *dp) >> if (dp->d_devstat != NULL) >> devstat_remove_entry(dp->d_devstat); >> g_post_event(g_disk_destroy, dp, M_WAITOK, NULL); >> +} >> + >> +void >> +disk_add_alias(struct disk *dp, const char *name) >> +{ >> + struct disk_alias *dap; >> + >> + dap = (struct disk_alias *)g_malloc( >> + sizeof(struct disk_alias) + strlen(name) + 1, M_WAITOK); >> + strcpy((char *)(dap + 1), name); >> + dap->da_alias = (const char *)(dap + 1); >> + LIST_INSERT_HEAD(&dp->d_aliases, dap, da_next); >> } >> void >> >> Modified: head/sys/geom/geom_disk.h >> ============================================================ >> ================== >> --- head/sys/geom/geom_disk.h Mon Aug 7 21:12:33 2017 (r322197) >> +++ head/sys/geom/geom_disk.h Mon Aug 7 21:12:38 2017 (r322198) >> @@ -66,6 +66,11 @@ typedef enum { >> DISK_INIT_DONE >> } disk_init_level; >> +struct disk_alias { >> + LIST_ENTRY(disk_alias) da_next; >> + const char *da_alias; >> +}; >> + >> struct disk { >> /* Fields which are private to geom_disk */ >> struct g_geom *d_geom; >> @@ -109,6 +114,9 @@ struct disk { >> /* Fields private to the driver */ >> void *d_drv1; >> + >> + /* Fields private to geom_disk, to be moved on next version bump >> */ >> + LIST_HEAD(,disk_alias) d_aliases; >> }; >> #define DISKFLAG_RESERVED 0x1 /* Was NEEDSGIANT */ >> @@ -132,6 +140,7 @@ void disk_attr_changed(struct disk *dp, const char *at >> void disk_media_changed(struct disk *dp, int flag); >> void disk_media_gone(struct disk *dp, int flag); >> int disk_resize(struct disk *dp, int flag); >> +void disk_add_alias(struct disk *disk, const char *); >> #define DISK_VERSION_00 0x58561059 >> #define DISK_VERSION_01 0x5856105a >> >> > From owner-svn-src-head@freebsd.org Mon Aug 7 21:37:58 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 81CD8DCA74F for ; Mon, 7 Aug 2017 21:37:58 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x233.google.com (mail-it0-x233.google.com [IPv6:2607:f8b0:4001:c0b::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3E29D84866 for ; Mon, 7 Aug 2017 21:37:58 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x233.google.com with SMTP id 77so9791055itj.1 for ; Mon, 07 Aug 2017 14:37:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=NI8SPRm+PsybPL/kAX0p0cNCCji6y3xyJswDwJNTVac=; b=vOIomLcSp2yrp+UN9u/QEofg+M7T9X/u4YEvt7+gp1ymHo5hZMeXuR0l+ssV5mVx+u WTSKjg7lL/Ytzu3CsPSRvzNTrbWHQtuTYh5VIiAyDTNwmkcM4cYbjQZ1zjxHGAoPPKvv HqVHvjvNtnYP+jE4dEnQQyrfDEgjr2kpmCTrMVasou++WsruT0GmOvSkQ7By0Is1XssM kCvDCgiZl1Sm3Lzd6mTaw1uehHe22jqPCx8zE0Wy3ZE5oVUj/LOHT+QxYnM6eS27tiE5 gg6V66YC31jKBKwfWKVVI5pNLlYm+smcWw8RDlJHO/wb3eHIVnLfRTw0leFkaO7234kh pT4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=NI8SPRm+PsybPL/kAX0p0cNCCji6y3xyJswDwJNTVac=; b=NAHIhPe7IDg0vwh5dWRKxfilwOhAYTOum4vx3h0v79mC6XpUSfkLCsnoa9GQaaIZZN E2H0RpJXoOOmQHVKsZYEIno2XEQVViTfXQwjt/KrnYpx9UUPNvKHrSnDp2vEVJfLHiPb Ysl1ZLpKdXimuU/QmMQAxINMwMPuzrl8pTNSPQX5xC+XNAaqvTq3AzIUSCuuSPCMsFI0 xDjVSKboh31g3RSsL0a4WSkxzoHne8mFCPixGDA7eiruuYRC6Pm7PBCAkRjI4fgQiKiF YH0VHtnlfhmLNHH4gQ8CHlP8XYH7Ww2eMAVOsuiasKccnFrnJHsD9m1AZLxYK+pNmXJL kVYA== X-Gm-Message-State: AIVw110vQ+DqTB6CeCVvUJsNtNAGquHQKecKwoAZbgDWi+JVCLb0wy2J bD+vq3IHCFKlZU26kyvNyIy7zI+NC4Cr X-Received: by 10.36.68.193 with SMTP id o184mr2089095ita.59.1502141877712; Mon, 07 Aug 2017 14:37:57 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.10.71 with HTTP; Mon, 7 Aug 2017 14:37:57 -0700 (PDT) X-Originating-IP: [2603:300b:6:5100:f809:2296:13f6:2a42] In-Reply-To: <20170807212937.GJ1700@kib.kiev.ua> References: <201708072112.v77LCSxL001381@repo.freebsd.org> <20170807212937.GJ1700@kib.kiev.ua> From: Warner Losh Date: Mon, 7 Aug 2017 15:37:57 -0600 X-Google-Sender-Auth: _YaedL6OTiTGDFf4VI-Q-BhVgXU Message-ID: Subject: Re: svn commit: r322196 - head/sys/geom To: Konstantin Belousov Cc: Warner Losh , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 21:37:58 -0000 On Mon, Aug 7, 2017 at 3:29 PM, Konstantin Belousov wrote: > On Mon, Aug 07, 2017 at 09:12:28PM +0000, Warner Losh wrote: > > + LIST_FOREACH(gap, &pp->geom->aliases, ga_next) { > > + error = make_dev_alias_p(MAKEDEV_CHECKNAME | > MAKEDEV_WAITOK, &adev, dev, > > + "%s", gap->ga_alias); > > + if (error) { > > + printf("%s: make_dev_alias_p() failed (name=%s, > error=%d)\n", > > + __func__, gap->ga_alias, error); > > + continue; > > + } > > + adev->si_flags |= SI_UNMAPPED; > Why do you set the flag unconditionally ? Because it's set for "dev" unconditionally and the old compat code did it too... > + adev->si_iosize_max = dev->si_iosize_max; > > + adev->si_drv2 = dev->si_drv2; > And what are you trying to do by these initializations, including the > si_flags adjustment ? > The old (ad->ada) compat code set them. Though to be honest, I didn't drill down into the devfs code to see if that as still relevant. It sounds like maybe not relevant... > Aliases cause creation of symlinks in the devfs populate loop, which > makes it impossible to access the alias cdevs. > True enough. If so, do you think these adjustments to adev can just be removed entirely? A quick look in devfs code suggests that it doesn't matter since, as you point out, it's a symlink not a new, different node. Thanks for the feedback. Warner From owner-svn-src-head@freebsd.org Mon Aug 7 21:38:11 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6F332DCA7AF; Mon, 7 Aug 2017 21:38:11 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 439A58491E; Mon, 7 Aug 2017 21:38:11 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77LcAY2009903; Mon, 7 Aug 2017 21:38:10 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77LcAiY009902; Mon, 7 Aug 2017 21:38:10 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201708072138.v77LcAiY009902@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Mon, 7 Aug 2017 21:38:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322203 - head/usr.sbin/tzsetup X-SVN-Group: head X-SVN-Commit-Author: marius X-SVN-Commit-Paths: head/usr.sbin/tzsetup X-SVN-Commit-Revision: 322203 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 21:38:11 -0000 Author: marius Date: Mon Aug 7 21:38:10 2017 New Revision: 322203 URL: https://svnweb.freebsd.org/changeset/base/322203 Log: Revert the parts of r322097 related to /etc/wall_cmos_clock handling as the previous behavior actually is required for setting up configurations in which the RTC is using UTC but the timezone is not. Still, besides uniform error handling, that file should get the same treatment in the non-interactive variants supported by tzsetup(8). Modified: head/usr.sbin/tzsetup/tzsetup.c Modified: head/usr.sbin/tzsetup/tzsetup.c ============================================================================== --- head/usr.sbin/tzsetup/tzsetup.c Mon Aug 7 21:29:55 2017 (r322202) +++ head/usr.sbin/tzsetup/tzsetup.c Mon Aug 7 21:38:10 2017 (r322203) @@ -866,48 +866,10 @@ install_zoneinfo_file(const char *zoneinfo_file) static int install_zoneinfo(const char *zoneinfo) { - int fd, rv; + int rv; FILE *f; char path_zoneinfo_file[MAXPATHLEN]; - char prompt[SILLY_BUFFER_SIZE], title[64]; - if (reallydoit) { - if (strcmp(zoneinfo, "UTC") == 0) { - if (unlink(path_wall_cmos_clock) < 0 && - errno != ENOENT) { - snprintf(title, sizeof(title), "Error"); - snprintf(prompt, sizeof(prompt), - "Could not delete %s: %s", - path_wall_cmos_clock, strerror(errno)); -#ifdef HAVE_DIALOG - if (usedialog) - dialog_msgbox(title, prompt, 8, 72, 1); - else -#endif - fprintf(stderr, "%s\n", prompt); - - return (DITEM_FAILURE | DITEM_RECREATE); - } - } else { - fd = open(path_wall_cmos_clock, O_WRONLY | O_CREAT | - O_TRUNC, S_IRUSR | S_IRGRP | S_IROTH); - if (fd < 0) { - snprintf(title, sizeof(title), "Error"); - snprintf(prompt, sizeof(prompt), - "Could not create %s: %s", - path_wall_cmos_clock, strerror(errno)); -#ifdef HAVE_DIALOG - if (usedialog) - dialog_msgbox(title, prompt, 8, 72, 1); - else -#endif - fprintf(stderr, "%s\n", prompt); - return (DITEM_FAILURE | DITEM_RECREATE); - } - close(fd); - } - } - if ((size_t)snprintf(path_zoneinfo_file, sizeof(path_zoneinfo_file), "%s/%s", path_zoneinfo, zoneinfo) >= sizeof(path_zoneinfo_file)) errx(1, "%s/%s name too long", path_zoneinfo, zoneinfo); @@ -938,6 +900,7 @@ main(int argc, char **argv) { #ifdef HAVE_DIALOG char title[64], prompt[128]; + int fd; #endif int c, rv, skiputc; char vm_guest[16] = ""; @@ -992,7 +955,6 @@ main(int argc, char **argv) _PATH_WALL_CMOS_CLOCK); } - /* Override the user-supplied umask. */ (void)umask(S_IWGRP | S_IWOTH); @@ -1059,11 +1021,19 @@ main(int argc, char **argv) yesno = dialog_yesno(title, prompt, 7, 73); dlg_restore_vars(&save_vars); if (!yesno) { + if (reallydoit) + unlink(path_wall_cmos_clock); + } else { if (reallydoit) { - rv = install_zoneinfo("UTC"); - dlg_clear(); - end_dialog(); - exit(rv & ~DITEM_LEAVE_MENU); + fd = open(path_wall_cmos_clock, + O_WRONLY | O_CREAT | O_TRUNC, + S_IRUSR | S_IRGRP | S_IROTH); + if (fd < 0) { + end_dialog(); + err(1, "create %s", + path_wall_cmos_clock); + } + close(fd); } } dlg_clear(); From owner-svn-src-head@freebsd.org Mon Aug 7 21:51:48 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0545FDCB600; Mon, 7 Aug 2017 21:51:48 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8E03086E; Mon, 7 Aug 2017 21:51:47 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v77Lpa5J060342 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 8 Aug 2017 00:51:37 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v77Lpa5J060342 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v77LpaGH060341; Tue, 8 Aug 2017 00:51:36 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 8 Aug 2017 00:51:36 +0300 From: Konstantin Belousov To: Warner Losh Cc: Warner Losh , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r322196 - head/sys/geom Message-ID: <20170807215136.GK1700@kib.kiev.ua> References: <201708072112.v77LCSxL001381@repo.freebsd.org> <20170807212937.GJ1700@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.3 (2017-05-23) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 21:51:48 -0000 On Mon, Aug 07, 2017 at 03:37:57PM -0600, Warner Losh wrote: > On Mon, Aug 7, 2017 at 3:29 PM, Konstantin Belousov > wrote: > > > On Mon, Aug 07, 2017 at 09:12:28PM +0000, Warner Losh wrote: > > > + LIST_FOREACH(gap, &pp->geom->aliases, ga_next) { > > > + error = make_dev_alias_p(MAKEDEV_CHECKNAME | > > MAKEDEV_WAITOK, &adev, dev, > > > + "%s", gap->ga_alias); > > > + if (error) { > > > + printf("%s: make_dev_alias_p() failed (name=%s, > > error=%d)\n", > > > + __func__, gap->ga_alias, error); > > > + continue; > > > + } > > > + adev->si_flags |= SI_UNMAPPED; > > Why do you set the flag unconditionally ? > > > Because it's set for "dev" unconditionally and the old compat code did it > too... > > > + adev->si_iosize_max = dev->si_iosize_max; > > > + adev->si_drv2 = dev->si_drv2; > > And what are you trying to do by these initializations, including the > > si_flags adjustment ? > > > > The old (ad->ada) compat code set them. Though to be honest, I didn't drill > down into the devfs code to see if that as still relevant. It sounds like > maybe not relevant... > > > > Aliases cause creation of symlinks in the devfs populate loop, which > > makes it impossible to access the alias cdevs. > > > > True enough. If so, do you think these adjustments to adev can just be > removed entirely? A quick look in devfs code suggests that it doesn't > matter since, as you point out, it's a symlink not a new, different node. Yes, I think that the adev tweaks are not needed. I will be surprised if it appears to be used, but then there might be some hole in the devfs symlinks handling. That said, since you mentioned ada/ad aliases, are they still in the tree ? If yes, do you plan to convert them as well ? From owner-svn-src-head@freebsd.org Mon Aug 7 22:00:19 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1ABE5DCBB40 for ; Mon, 7 Aug 2017 22:00:19 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-io0-x234.google.com (mail-io0-x234.google.com [IPv6:2607:f8b0:4001:c06::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D30B9C2D for ; Mon, 7 Aug 2017 22:00:18 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-io0-x234.google.com with SMTP id c74so7349617iod.4 for ; Mon, 07 Aug 2017 15:00:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=q9IEw/sgQBHuytiSK/3Slfhhg/o4WaAk8MN2W4ngBfQ=; b=fhAqw36yCnkoJB/dZQCsTETdNPM8ij0/8hTjv/KlIyLTg7MdpV8B6B1fqbl3BbYrbS eqiaH3Te/LMi4c7uXJC9Oq8ekUx2YsF2STm4BNdC3Ziv01ap5DnTq75/+XrdszKSfWPO 5mOcqYqE5upi0vn1ccju/o1lYQF7HraCkk2D2FANH4nRuDxBMt2K9UlVNWNQb48Yzut8 R25z70+0PVf9ieaKYPLccNUxrp+pJUXV/Rh91r3S4L8CRbOwHzNTO16SKwE0C6x3+ftM 6nJfTrCi8mdYWiEvEkHqG3udCXeB/DnxtpsAR5oYyMyGPI27ZZY3TIVsrm43Fkl6B/xQ 0/AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=q9IEw/sgQBHuytiSK/3Slfhhg/o4WaAk8MN2W4ngBfQ=; b=WN0Guzlsk1tQ8dAkUDt16NfuYNcm6SW44xneC1PQimzFvIeTUPxXHtxlP3NCo8itxO HunIb7Ndl37pWdxAC+ieTlCs/pzG3oziMMwGJdzxRlI+sMSYCeSQ82QCNNL6Zfssdm9D 1Gg0ef4Wx9lOLAc+9T0I9jvB5I61XtzmMjTlq+SMI+NXI1ii9WTcM68ibmManw+rKPE8 uvDZXZ4/QHi57YAKM8Kcyl1LFzsKXd4aWB7vDoQoDvDLHgofIteZNrXZYti788AhjVNw OxyUIf5p/skpnWJji58YofAiYbEsi5ricXLUela3BdNPk1E6tDBROdUrHLH6bWUA6Y+C vpGA== X-Gm-Message-State: AIVw112zcPAKSQBXRHZxlEYlMk6YmsjnY6YHA5HVX7z71I9Wuwz5RhHB qEOuuVp/1ahLhLgglERBkKcdezctGX/b X-Received: by 10.107.147.133 with SMTP id v127mr1812624iod.128.1502143218296; Mon, 07 Aug 2017 15:00:18 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.10.71 with HTTP; Mon, 7 Aug 2017 15:00:17 -0700 (PDT) X-Originating-IP: [2603:300b:6:5100:f809:2296:13f6:2a42] In-Reply-To: <20170807215136.GK1700@kib.kiev.ua> References: <201708072112.v77LCSxL001381@repo.freebsd.org> <20170807212937.GJ1700@kib.kiev.ua> <20170807215136.GK1700@kib.kiev.ua> From: Warner Losh Date: Mon, 7 Aug 2017 16:00:17 -0600 X-Google-Sender-Auth: xeMD_KUYpArcONA3TBQ_hvNYx1s Message-ID: Subject: Re: svn commit: r322196 - head/sys/geom To: Konstantin Belousov Cc: Warner Losh , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 22:00:19 -0000 On Mon, Aug 7, 2017 at 3:51 PM, Konstantin Belousov wrote: > On Mon, Aug 07, 2017 at 03:37:57PM -0600, Warner Losh wrote: > > On Mon, Aug 7, 2017 at 3:29 PM, Konstantin Belousov > > > wrote: > > > > > On Mon, Aug 07, 2017 at 09:12:28PM +0000, Warner Losh wrote: > > > > + LIST_FOREACH(gap, &pp->geom->aliases, ga_next) { > > > > + error = make_dev_alias_p(MAKEDEV_CHECKNAME | > > > MAKEDEV_WAITOK, &adev, dev, > > > > + "%s", gap->ga_alias); > > > > + if (error) { > > > > + printf("%s: make_dev_alias_p() failed (name=%s, > > > error=%d)\n", > > > > + __func__, gap->ga_alias, error); > > > > + continue; > > > > + } > > > > + adev->si_flags |= SI_UNMAPPED; > > > Why do you set the flag unconditionally ? > > > > > > Because it's set for "dev" unconditionally and the old compat code did it > > too... > > > > > + adev->si_iosize_max = dev->si_iosize_max; > > > > + adev->si_drv2 = dev->si_drv2; > > > And what are you trying to do by these initializations, including the > > > si_flags adjustment ? > > > > > > > The old (ad->ada) compat code set them. Though to be honest, I didn't > drill > > down into the devfs code to see if that as still relevant. It sounds like > > maybe not relevant... > > > > > > > Aliases cause creation of symlinks in the devfs populate loop, which > > > makes it impossible to access the alias cdevs. > > > > > > > True enough. If so, do you think these adjustments to adev can just be > > removed entirely? A quick look in devfs code suggests that it doesn't > > matter since, as you point out, it's a symlink not a new, different node. > Yes, I think that the adev tweaks are not needed. I will be surprised > if it appears to be used, but then there might be some hole in the > devfs symlinks handling. > Maybe I'm just setting 'dead variables' here that don't matter. I don't know that this is required, just kept the same code that used to 'work'. > That said, since you mentioned ada/ad aliases, are they still in the tree ? > If yes, do you plan to convert them as well ? > That code was removed in 11. I thought about bringing the code that ada used to implement them back verbatim for nda (and soon mda), but thought this approach was better and more general (and less error prone). I have no plans to re-add them. Warner From owner-svn-src-head@freebsd.org Mon Aug 7 22:20:20 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8CB4EDCC8C8; Mon, 7 Aug 2017 22:20:20 +0000 (UTC) (envelope-from nwhitehorn@freebsd.org) Received: from c.mail.sonic.net (c.mail.sonic.net [64.142.111.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 73F3516AA; Mon, 7 Aug 2017 22:20:19 +0000 (UTC) (envelope-from nwhitehorn@freebsd.org) Received: from aurora.physics.berkeley.edu (aurora.physics.berkeley.edu [128.32.117.67]) (authenticated bits=0) by c.mail.sonic.net (8.15.1/8.15.1) with ESMTPSA id v77MKFch016136 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Mon, 7 Aug 2017 15:20:16 -0700 Subject: Re: svn commit: r322198 - in head: share/man/man9 sys/geom To: Warner Losh Cc: Warner Losh , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" References: <201708072112.v77LCcXm001489@repo.freebsd.org> From: Nathan Whitehorn Message-ID: Date: Mon, 7 Aug 2017 15:20:15 -0700 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Sonic-CAuth: UmFuZG9tSVb9xHFseSlKGqz/QUV2bNmClrWf5AS1Bg7C0zDLKPqfcqZE2hTydO9Ok3QDeZL7HTKC057/Xx+6RlBRu1KuPZXEwkLleUlfPjE= X-Sonic-ID: C;2tiIlr575xGvjcGbEi49jA== M;kl3Tlr575xGvjcGbEi49jA== X-Spam-Flag: No X-Sonic-Spam-Details: 0.0/5.0 by cerberusd Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 22:20:20 -0000 On 08/07/17 14:32, Warner Losh wrote: > > > On Mon, Aug 7, 2017 at 3:19 PM, Nathan Whitehorn > > wrote: > > It would be really nice to let gpart provide aliases correct to > partition labels, which would fix the existing racy and unreliable > glabel code. Do you see any obstacles to using this code for that? > > > I'm not sure I understand well enough the issue here to have an opinion. We get /dev/gpt/foo (etc.) right now by parsing the GPT labels with a completely parallel piece of code to gpart and then create an extra geom provider based on the label. This falls down in four ways: 1. The code is racy. It is perfectly possible to get a GPT label set by gpart but not have it picked up by glabel for some period of time that may be infinite (until a retaste), since the events don't propagate. 2. The resulting /dev entry is unpredictable from the label, since glabel internally does some fixups related to spaces, etc. You need to copy and paste glabel's munging code. 3. It isn't implemented for all of the schemes gpart supports since it has a reimplementation of the partition table parser. 4. Because it uses an extra provider, mounting, say, /dev/adaXpY causes /dev/gpt/Z to vanish. This combination of things is why we don't currently use labels in the installer and never have. Having gpart internally create symlinks would fix all of this at a stroke. I will take a look at this some more and see how hard it would be to implement; at the very least, I think you would also need a disk_remove_alias() or the like. -Nathan > Warner > > On 08/07/17 14:12, Warner Losh wrote: > > Author: imp > Date: Mon Aug 7 21:12:38 2017 > New Revision: 322198 > URL: https://svnweb.freebsd.org/changeset/base/322198 > > > Log: > Expose API to allow disks to ask for alias names in devfs. > Implement disk_add_alias to allow aliases to be added to > disks. All > disk have a primary name (say "foo") can also have > secondary names > (say "bar") such that all instances of "foo" also have a "bar" > alias. So if you have foo0, foo0p1, foo1, foo1s1 and > foo1s1a nodes > created by the foo driver and gpart, device nodes bar0, > bar0p1, bar1, > bar1s1 and bar1s1a will appear as symlinks back to the > original nodes. > This generalizes to multiple aliases. However, since the > unit number > follows the primary name, multiple device drivers can't > create the > same aliases unless those drives coorinate the unit number > space (eg > you couldn't add an alias 'disk' to both 'da' and 'ada' > because it's > possible to have da0 and ada0, because 'disk0' is ambiguous). > Differential Revision: > https://reviews.freebsd.org/D11873 > > > Modified: > head/share/man/man9/disk.9 > head/sys/geom/geom_disk.c > head/sys/geom/geom_disk.h > > Modified: head/share/man/man9/disk.9 > ============================================================================== > --- head/share/man/man9/disk.9 Mon Aug 7 21:12:33 2017 > (r322197) > +++ head/share/man/man9/disk.9 Mon Aug 7 21:12:38 2017 > (r322198) > @@ -27,7 +27,7 @@ > .\" > .\" $FreeBSD$ > .\" > -.Dd October 30, 2012 > +.Dd August 3, 2017 > .Dt DISK 9 > .Os > .Sh NAME > @@ -45,6 +45,8 @@ > .Fn disk_destroy "struct disk *disk" > .Ft int > .Fn disk_resize "struct disk *disk" "int flags" > +.Ft void > +.Fn disk_add_alias "struct disk *disk" "const char *alias" > .Sh DESCRIPTION > The disk storage API permits kernel device drivers providing > access to > disk-like storage devices to advertise the device to other > kernel > @@ -69,6 +71,20 @@ function, > fill in the fields and call > .Fn disk_create > when the device is ready to service requests. > +.Fn disk_add_alias > +adds an alias for the disk and must be called before > +.Fn disk_create , > +but may be called multiple times. > +For each alias added, a device node will be created with > +.Xr make_dev_alias 9 > +in the same way primary device nodes are created with > +.Xr make_dev 9 > +for > +.Va d_name > +and > +.Va d_unit . > +Care should be taken to ensure that only one driver creates > aliases > +for any given name. > .Fn disk_resize > can be called by the driver after modifying > .Va d_mediasize > @@ -227,7 +243,13 @@ structure for this disk device. > .El > .Sh SEE ALSO > .Xr GEOM 4 , > -.Xr devfs 5 > +.Xr devfs 5 , > +.Xr MAKE_DEV 9 > .Sh AUTHORS > This manual page was written by > .An Robert Watson . > +.Sh BUGS > +Disk aliases are not a general purpose aliasing mechanism, > but are > +intended only to ease the transition from one name to another. > +They can be used to ensure that nvd0 and nda0 are the same thing. > +They cannot be used to implement the diskX concept from macOS. > > Modified: head/sys/geom/geom_disk.c > ============================================================================== > --- head/sys/geom/geom_disk.c Mon Aug 7 21:12:33 2017 > (r322197) > +++ head/sys/geom/geom_disk.c Mon Aug 7 21:12:38 2017 > (r322198) > @@ -676,6 +676,7 @@ g_disk_create(void *arg, int flag) > struct g_provider *pp; > struct disk *dp; > struct g_disk_softc *sc; > + struct disk_alias *dap; > char tmpstr[80]; > if (flag == EV_CANCEL) > @@ -704,6 +705,10 @@ g_disk_create(void *arg, int flag) > sc->dp = dp; > gp = g_new_geomf(&g_disk_class, "%s%d", dp->d_name, > dp->d_unit); > gp->softc = sc; > + LIST_FOREACH(dap, &dp->d_aliases, da_next) { > + snprintf(tmpstr, sizeof(tmpstr), "%s%d", > dap->da_alias, dp->d_unit); > + g_geom_add_alias(gp, tmpstr); > + } > pp = g_new_providerf(gp, "%s", gp->name); > devstat_remove_entry(pp->stat); > pp->stat = NULL; > @@ -791,6 +796,7 @@ g_disk_destroy(void *ptr, int flag) > struct disk *dp; > struct g_geom *gp; > struct g_disk_softc *sc; > + struct disk_alias *dap, *daptmp; > g_topology_assert(); > dp = ptr; > @@ -802,6 +808,8 @@ g_disk_destroy(void *ptr, int flag) > dp->d_geom = NULL; > g_wither_geom(gp, ENXIO); > } > + LIST_FOREACH_SAFE(dap, &dp->d_aliases, da_next, daptmp) > + g_free(dap); > g_free(dp); > } > @@ -834,8 +842,11 @@ g_disk_ident_adjust(char *ident, size_t size) > struct disk * > disk_alloc(void) > { > + struct disk *dp; > - return (g_malloc(sizeof(struct disk), M_WAITOK | M_ZERO)); > + dp = g_malloc(sizeof(struct disk), M_WAITOK | M_ZERO); > + LIST_INIT(&dp->d_aliases); > + return (dp); > } > void > @@ -882,6 +893,18 @@ disk_destroy(struct disk *dp) > if (dp->d_devstat != NULL) > devstat_remove_entry(dp->d_devstat); > g_post_event(g_disk_destroy, dp, M_WAITOK, NULL); > +} > + > +void > +disk_add_alias(struct disk *dp, const char *name) > +{ > + struct disk_alias *dap; > + > + dap = (struct disk_alias *)g_malloc( > + sizeof(struct disk_alias) + strlen(name) + 1, > M_WAITOK); > + strcpy((char *)(dap + 1), name); > + dap->da_alias = (const char *)(dap + 1); > + LIST_INSERT_HEAD(&dp->d_aliases, dap, da_next); > } > void > > Modified: head/sys/geom/geom_disk.h > ============================================================================== > --- head/sys/geom/geom_disk.h Mon Aug 7 21:12:33 2017 > (r322197) > +++ head/sys/geom/geom_disk.h Mon Aug 7 21:12:38 2017 > (r322198) > @@ -66,6 +66,11 @@ typedef enum { > DISK_INIT_DONE > } disk_init_level; > +struct disk_alias { > + LIST_ENTRY(disk_alias) da_next; > + const char *da_alias; > +}; > + > struct disk { > /* Fields which are private to geom_disk */ > struct g_geom *d_geom; > @@ -109,6 +114,9 @@ struct disk { > /* Fields private to the driver */ > void *d_drv1; > + > + /* Fields private to geom_disk, to be moved on next > version bump */ > + LIST_HEAD(,disk_alias) d_aliases; > }; > #define DISKFLAG_RESERVED 0x1 /* Was NEEDSGIANT */ > @@ -132,6 +140,7 @@ void disk_attr_changed(struct disk *dp, > const char *at > void disk_media_changed(struct disk *dp, int flag); > void disk_media_gone(struct disk *dp, int flag); > int disk_resize(struct disk *dp, int flag); > +void disk_add_alias(struct disk *disk, const char *); > #define DISK_VERSION_00 0x58561059 > #define DISK_VERSION_01 0x5856105a > > > From owner-svn-src-head@freebsd.org Mon Aug 7 22:27:27 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E1360DCCE63 for ; Mon, 7 Aug 2017 22:27:27 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-io0-x230.google.com (mail-io0-x230.google.com [IPv6:2607:f8b0:4001:c06::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A43931C7E for ; Mon, 7 Aug 2017 22:27:27 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-io0-x230.google.com with SMTP id j32so7594733iod.0 for ; Mon, 07 Aug 2017 15:27:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=Dj4uVpHicX8f2cJwwuQVH4o8zHcichwoVDCHKZZXRBE=; b=oMx32OaBhmiD9xOyFcwRz1f8ajEl90Lw/Cuq21yzmotJuQYRCLGDS2AjBvBWyaWDis HssXcQ+pHu95p3MXb0Tcc/itbh2n6FcRS8otqEbt1iCgRdKDzzmHl5fv0ayLbRWbhcOO 8my7PLdob4IlBT3Ml5vnBSL3N9z3jtbnTuQ55jhe4xZ3azc/qyhxMekILiMUR67dTHQF 9PrwdA3D3RFbo//j2RiafyXH/P8HN/kBJJy/0pnO8QmUUrvQsPurVphyWkL52fMybNQY UzaOwfpNpOrA/gqicd0JcEIMZK8CWFNvFrN0+OuPKzkwYy3LsxBRQpMOtejkj658/MKp GkMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=Dj4uVpHicX8f2cJwwuQVH4o8zHcichwoVDCHKZZXRBE=; b=Ttt+sLw5sM2Qu8zC0YlQTsE+5K70S8GaUShtTZCbi5eCQx7Fj/n5RtExsh97wr8B6n c4OW6qupYd+jH8hz6NmveZUDeopjShuFfPucwNK7552N/qDtoC4zZVImGsi0PjVCabAB HvolQccJaSApsvWD6CHYFUw8UKXcrOLg2ppQbUTsOJS9TS1s/cV3JJnadjAW/S3uGDqM Eu9lOjQ+4vzKgk7iqMKMDbWW1w+i5P2dKAadNjmUCs3577yI4QzHz8SLvhXNzhSoRGCy okjPS48wWG9RPweeYVQdbo0+Uf1Bkg6Q6q8OcZvZBb1/KYN74trTp6NMM6oCCQRCf1ha vjIQ== X-Gm-Message-State: AHYfb5jkYYNZ3vdsuDQ2fB9Gd94ys6w4I/3ojqjcyfHpLkbZJ3Gdh5zw oiXX/qvQq1G2EWhhwlblHp+10B/pEpkD X-Received: by 10.107.36.18 with SMTP id k18mr1998886iok.147.1502144847006; Mon, 07 Aug 2017 15:27:27 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.10.71 with HTTP; Mon, 7 Aug 2017 15:27:26 -0700 (PDT) X-Originating-IP: [2603:300b:6:5100:f809:2296:13f6:2a42] In-Reply-To: References: <201708072112.v77LCcXm001489@repo.freebsd.org> From: Warner Losh Date: Mon, 7 Aug 2017 16:27:26 -0600 X-Google-Sender-Auth: v2RLNhOy1-V9VJ32s9o_BFXmqFI Message-ID: Subject: Re: svn commit: r322198 - in head: share/man/man9 sys/geom To: Nathan Whitehorn Cc: Warner Losh , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 22:27:28 -0000 On Mon, Aug 7, 2017 at 4:20 PM, Nathan Whitehorn wrote: > > > On 08/07/17 14:32, Warner Losh wrote: > > > > On Mon, Aug 7, 2017 at 3:19 PM, Nathan Whitehorn > wrote: > >> It would be really nice to let gpart provide aliases correct to partition >> labels, which would fix the existing racy and unreliable glabel code. Do >> you see any obstacles to using this code for that? > > > I'm not sure I understand well enough the issue here to have an opinion. > > > We get /dev/gpt/foo (etc.) right now by parsing the GPT labels with a > completely parallel piece of code to gpart and then create an extra geom > provider based on the label. This falls down in four ways: > 1. The code is racy. It is perfectly possible to get a GPT label set by > gpart but not have it picked up by glabel for some period of time that may > be infinite (until a retaste), since the events don't propagate. > 2. The resulting /dev entry is unpredictable from the label, since glabel > internally does some fixups related to spaces, etc. You need to copy and > paste glabel's munging code. > 3. It isn't implemented for all of the schemes gpart supports since it has > a reimplementation of the partition table parser. > 4. Because it uses an extra provider, mounting, say, /dev/adaXpY causes > /dev/gpt/Z to vanish. > > This combination of things is why we don't currently use labels in the > installer and never have. Having gpart internally create symlinks would fix > all of this at a stroke. I will take a look at this some more and see how > hard it would be to implement; at the very least, I think you would also > need a disk_remove_alias() or the like. > I've experienced all but #1 and #2. I've run systems for about a decade with root mounted on /dev/gpt/HOST-root, usr on /dev/gpt/HOST-usr, etc. Must have gotten lucky, or not hit the use case that you've seen. Not sure what's up with #3, but it sounds orthogonal and an incomplete gpart/glabel integration. #4 has always bothered me. While device aliases like I've done here would solve that problem, I'm not sure what other issues there'd be demoting glabel devices to mere /dev/ nodes from first class geom objects. The main issue I see is needing to have the aliases in place when tasting time comes for the geom being tasted. I haven't thought through geom's sequence enough to know if that would be more robust or not. Warner -Nathan > > > Warner > > On 08/07/17 14:12, Warner Losh wrote: >> >>> Author: imp >>> Date: Mon Aug 7 21:12:38 2017 >>> New Revision: 322198 >>> URL: https://svnweb.freebsd.org/changeset/base/322198 >>> >>> Log: >>> Expose API to allow disks to ask for alias names in devfs. >>> Implement disk_add_alias to allow aliases to be added to disks. All >>> disk have a primary name (say "foo") can also have secondary names >>> (say "bar") such that all instances of "foo" also have a "bar" >>> alias. So if you have foo0, foo0p1, foo1, foo1s1 and foo1s1a nodes >>> created by the foo driver and gpart, device nodes bar0, bar0p1, bar1, >>> bar1s1 and bar1s1a will appear as symlinks back to the original nodes. >>> This generalizes to multiple aliases. However, since the unit number >>> follows the primary name, multiple device drivers can't create the >>> same aliases unless those drives coorinate the unit number space (eg >>> you couldn't add an alias 'disk' to both 'da' and 'ada' because it's >>> possible to have da0 and ada0, because 'disk0' is ambiguous). >>> Differential Revision: https://reviews.freebsd.org/D11873 >>> >>> Modified: >>> head/share/man/man9/disk.9 >>> head/sys/geom/geom_disk.c >>> head/sys/geom/geom_disk.h >>> >>> Modified: head/share/man/man9/disk.9 >>> ============================================================ >>> ================== >>> --- head/share/man/man9/disk.9 Mon Aug 7 21:12:33 2017 (r322197) >>> +++ head/share/man/man9/disk.9 Mon Aug 7 21:12:38 2017 (r322198) >>> @@ -27,7 +27,7 @@ >>> .\" >>> .\" $FreeBSD$ >>> .\" >>> -.Dd October 30, 2012 >>> +.Dd August 3, 2017 >>> .Dt DISK 9 >>> .Os >>> .Sh NAME >>> @@ -45,6 +45,8 @@ >>> .Fn disk_destroy "struct disk *disk" >>> .Ft int >>> .Fn disk_resize "struct disk *disk" "int flags" >>> +.Ft void >>> +.Fn disk_add_alias "struct disk *disk" "const char *alias" >>> .Sh DESCRIPTION >>> The disk storage API permits kernel device drivers providing access to >>> disk-like storage devices to advertise the device to other kernel >>> @@ -69,6 +71,20 @@ function, >>> fill in the fields and call >>> .Fn disk_create >>> when the device is ready to service requests. >>> +.Fn disk_add_alias >>> +adds an alias for the disk and must be called before >>> +.Fn disk_create , >>> +but may be called multiple times. >>> +For each alias added, a device node will be created with >>> +.Xr make_dev_alias 9 >>> +in the same way primary device nodes are created with >>> +.Xr make_dev 9 >>> +for >>> +.Va d_name >>> +and >>> +.Va d_unit . >>> +Care should be taken to ensure that only one driver creates aliases >>> +for any given name. >>> .Fn disk_resize >>> can be called by the driver after modifying >>> .Va d_mediasize >>> @@ -227,7 +243,13 @@ structure for this disk device. >>> .El >>> .Sh SEE ALSO >>> .Xr GEOM 4 , >>> -.Xr devfs 5 >>> +.Xr devfs 5 , >>> +.Xr MAKE_DEV 9 >>> .Sh AUTHORS >>> This manual page was written by >>> .An Robert Watson . >>> +.Sh BUGS >>> +Disk aliases are not a general purpose aliasing mechanism, but are >>> +intended only to ease the transition from one name to another. >>> +They can be used to ensure that nvd0 and nda0 are the same thing. >>> +They cannot be used to implement the diskX concept from macOS. >>> >>> Modified: head/sys/geom/geom_disk.c >>> ============================================================ >>> ================== >>> --- head/sys/geom/geom_disk.c Mon Aug 7 21:12:33 2017 (r322197) >>> +++ head/sys/geom/geom_disk.c Mon Aug 7 21:12:38 2017 (r322198) >>> @@ -676,6 +676,7 @@ g_disk_create(void *arg, int flag) >>> struct g_provider *pp; >>> struct disk *dp; >>> struct g_disk_softc *sc; >>> + struct disk_alias *dap; >>> char tmpstr[80]; >>> if (flag == EV_CANCEL) >>> @@ -704,6 +705,10 @@ g_disk_create(void *arg, int flag) >>> sc->dp = dp; >>> gp = g_new_geomf(&g_disk_class, "%s%d", dp->d_name, dp->d_unit); >>> gp->softc = sc; >>> + LIST_FOREACH(dap, &dp->d_aliases, da_next) { >>> + snprintf(tmpstr, sizeof(tmpstr), "%s%d", dap->da_alias, >>> dp->d_unit); >>> + g_geom_add_alias(gp, tmpstr); >>> + } >>> pp = g_new_providerf(gp, "%s", gp->name); >>> devstat_remove_entry(pp->stat); >>> pp->stat = NULL; >>> @@ -791,6 +796,7 @@ g_disk_destroy(void *ptr, int flag) >>> struct disk *dp; >>> struct g_geom *gp; >>> struct g_disk_softc *sc; >>> + struct disk_alias *dap, *daptmp; >>> g_topology_assert(); >>> dp = ptr; >>> @@ -802,6 +808,8 @@ g_disk_destroy(void *ptr, int flag) >>> dp->d_geom = NULL; >>> g_wither_geom(gp, ENXIO); >>> } >>> + LIST_FOREACH_SAFE(dap, &dp->d_aliases, da_next, daptmp) >>> + g_free(dap); >>> g_free(dp); >>> } >>> @@ -834,8 +842,11 @@ g_disk_ident_adjust(char *ident, size_t size) >>> struct disk * >>> disk_alloc(void) >>> { >>> + struct disk *dp; >>> - return (g_malloc(sizeof(struct disk), M_WAITOK | M_ZERO)); >>> + dp = g_malloc(sizeof(struct disk), M_WAITOK | M_ZERO); >>> + LIST_INIT(&dp->d_aliases); >>> + return (dp); >>> } >>> void >>> @@ -882,6 +893,18 @@ disk_destroy(struct disk *dp) >>> if (dp->d_devstat != NULL) >>> devstat_remove_entry(dp->d_devstat); >>> g_post_event(g_disk_destroy, dp, M_WAITOK, NULL); >>> +} >>> + >>> +void >>> +disk_add_alias(struct disk *dp, const char *name) >>> +{ >>> + struct disk_alias *dap; >>> + >>> + dap = (struct disk_alias *)g_malloc( >>> + sizeof(struct disk_alias) + strlen(name) + 1, M_WAITOK); >>> + strcpy((char *)(dap + 1), name); >>> + dap->da_alias = (const char *)(dap + 1); >>> + LIST_INSERT_HEAD(&dp->d_aliases, dap, da_next); >>> } >>> void >>> >>> Modified: head/sys/geom/geom_disk.h >>> ============================================================ >>> ================== >>> --- head/sys/geom/geom_disk.h Mon Aug 7 21:12:33 2017 (r322197) >>> +++ head/sys/geom/geom_disk.h Mon Aug 7 21:12:38 2017 (r322198) >>> @@ -66,6 +66,11 @@ typedef enum { >>> DISK_INIT_DONE >>> } disk_init_level; >>> +struct disk_alias { >>> + LIST_ENTRY(disk_alias) da_next; >>> + const char *da_alias; >>> +}; >>> + >>> struct disk { >>> /* Fields which are private to geom_disk */ >>> struct g_geom *d_geom; >>> @@ -109,6 +114,9 @@ struct disk { >>> /* Fields private to the driver */ >>> void *d_drv1; >>> + >>> + /* Fields private to geom_disk, to be moved on next version bump >>> */ >>> + LIST_HEAD(,disk_alias) d_aliases; >>> }; >>> #define DISKFLAG_RESERVED 0x1 /* Was NEEDSGIANT */ >>> @@ -132,6 +140,7 @@ void disk_attr_changed(struct disk *dp, const char >>> *at >>> void disk_media_changed(struct disk *dp, int flag); >>> void disk_media_gone(struct disk *dp, int flag); >>> int disk_resize(struct disk *dp, int flag); >>> +void disk_add_alias(struct disk *disk, const char *); >>> #define DISK_VERSION_00 0x58561059 >>> #define DISK_VERSION_01 0x5856105a >>> >>> >> > > From owner-svn-src-head@freebsd.org Mon Aug 7 22:42:47 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6ED5CDCDAC6; Mon, 7 Aug 2017 22:42:47 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3BC8E2784; Mon, 7 Aug 2017 22:42:47 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77Mgkal038377; Mon, 7 Aug 2017 22:42:46 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77Mgk5H038376; Mon, 7 Aug 2017 22:42:46 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201708072242.v77Mgk5H038376@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Mon, 7 Aug 2017 22:42:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322206 - head/sys/geom X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/geom X-SVN-Commit-Revision: 322206 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 22:42:47 -0000 Author: imp Date: Mon Aug 7 22:42:46 2017 New Revision: 322206 URL: https://svnweb.freebsd.org/changeset/base/322206 Log: Eliminate useless adjustments of aliased device. No need to set any fields in the cloned device. devfs uses symlinks, so the adev entries returned won't be presented to the drivers. Since we don't save copies, nothing else will see them. This code came from the old compat code, and it appears to be obsolete or never needed. Submitted by: kib@ Differential Review: https://reviews.freebsd.org/D11919 Modified: head/sys/geom/geom_dev.c Modified: head/sys/geom/geom_dev.c ============================================================================== --- head/sys/geom/geom_dev.c Mon Aug 7 22:30:18 2017 (r322205) +++ head/sys/geom/geom_dev.c Mon Aug 7 22:42:46 2017 (r322206) @@ -369,9 +369,6 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp, __func__, gap->ga_alias, error); continue; } - adev->si_flags |= SI_UNMAPPED; - adev->si_iosize_max = dev->si_iosize_max; - adev->si_drv2 = dev->si_drv2; snprintf(buf, sizeof(buf), "cdev=%s", gap->ga_alias); devctl_notify_f("GEOM", "DEV", "CREATE", buf, M_WAITOK); } From owner-svn-src-head@freebsd.org Mon Aug 7 23:33:07 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 60399DD02AD; Mon, 7 Aug 2017 23:33:07 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2F04F636E2; Mon, 7 Aug 2017 23:33:07 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77NX6L5058684; Mon, 7 Aug 2017 23:33:06 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77NX6T7058679; Mon, 7 Aug 2017 23:33:06 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201708072333.v77NX6T7058679@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Mon, 7 Aug 2017 23:33:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322209 - head/sys/dev/mmc X-SVN-Group: head X-SVN-Commit-Author: marius X-SVN-Commit-Paths: head/sys/dev/mmc X-SVN-Commit-Revision: 322209 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 23:33:07 -0000 Author: marius Date: Mon Aug 7 23:33:05 2017 New Revision: 322209 URL: https://svnweb.freebsd.org/changeset/base/322209 Log: - If available, use TRIM instead of ERASE for implementing BIO_DELETE. This also involves adding a quirk table as TRIM is broken for some Kingston eMMC devices, though. Compared to ERASE (declared "legacy" in the eMMC specification v5.1), TRIM has the advantage of operating on write sectors rather than on erase sectors, which typically are of a much larger size. Thus, employing TRIM, we don't need to fiddle with coalescing BIO_DELETE requests that are also of (write) sector units into erase sectors, which might not even add up in all cases. - For some SanDisk iNAND devices, the CMD38 argument, e. g. ERASE, TRIM etc., has to be specified via EXT_CSD[113], which now is also handled via a quirk. - My initial understanding was that for eMMC partitions, the granularity should be used as erase sector size, e. g. 128 KB for boot partitions. However, rereading the relevant parts of the eMMC specification v5.1, this isn't actually correct. So drop the code which used partition granularities for delmaxsize and stripesize. For the most part, this change is a NOP, though, because a) for ERASE, mmcsd_delete() used the erase sector size unconditionally for all partitions anyway and b) g_disk_limit() doesn't actually take the stripesize into account. - Take some more advantage of mmcsd_errmsg() in mmcsd(4) for making error codes human readable. Modified: head/sys/dev/mmc/bridge.h head/sys/dev/mmc/mmc.c head/sys/dev/mmc/mmcreg.h head/sys/dev/mmc/mmcsd.c head/sys/dev/mmc/mmcvar.h Modified: head/sys/dev/mmc/bridge.h ============================================================================== --- head/sys/dev/mmc/bridge.h Mon Aug 7 23:32:00 2017 (r322208) +++ head/sys/dev/mmc/bridge.h Mon Aug 7 23:33:05 2017 (r322209) @@ -180,7 +180,7 @@ struct mmc_host { extern driver_t mmc_driver; extern devclass_t mmc_devclass; -#define MMC_VERSION 4 +#define MMC_VERSION 5 #define MMC_DECLARE_BRIDGE(name) \ DRIVER_MODULE(mmc, name, mmc_driver, mmc_devclass, NULL, NULL); \ Modified: head/sys/dev/mmc/mmc.c ============================================================================== --- head/sys/dev/mmc/mmc.c Mon Aug 7 23:32:00 2017 (r322208) +++ head/sys/dev/mmc/mmc.c Mon Aug 7 23:33:05 2017 (r322209) @@ -104,12 +104,34 @@ struct mmc_ivars { uint32_t hs_tran_speed; /* Max speed in high speed mode */ uint32_t erase_sector; /* Card native erase sector size */ uint32_t cmd6_time; /* Generic switch timeout [us] */ + uint32_t quirks; /* Quirks as per mmc_quirk->quirks */ char card_id_string[64];/* Formatted CID info (serial, MFG, etc) */ char card_sn_string[16];/* Formatted serial # for disk->d_ident */ }; #define CMD_RETRIES 3 +static const struct mmc_quirk mmc_quirks[] = { + /* + * For some SanDisk iNAND devices, the CMD38 argument needs to be + * provided in EXT_CSD[113]. + */ + { 0x2, 0x100, "SEM02G", MMC_QUIRK_INAND_CMD38 }, + { 0x2, 0x100, "SEM04G", MMC_QUIRK_INAND_CMD38 }, + { 0x2, 0x100, "SEM08G", MMC_QUIRK_INAND_CMD38 }, + { 0x2, 0x100, "SEM16G", MMC_QUIRK_INAND_CMD38 }, + { 0x2, 0x100, "SEM32G", MMC_QUIRK_INAND_CMD38 }, + + /* + * Disable TRIM for Kingston eMMCs where a firmware bug can lead to + * unrecoverable data corruption. + */ + { 0x70, MMC_QUIRK_OID_ANY, "V10008", MMC_QUIRK_BROKEN_TRIM }, + { 0x70, MMC_QUIRK_OID_ANY, "V10016", MMC_QUIRK_BROKEN_TRIM }, + + { 0x0, 0x0, NULL, 0x0 } +}; + static SYSCTL_NODE(_hw, OID_AUTO, mmc, CTLFLAG_RD, NULL, "mmc driver"); static int mmc_debug; @@ -1109,7 +1131,7 @@ mmc_format_card_id_string(struct mmc_ivars *ivar) /* * Format a card ID string for use by the mmcsd driver, it's what * appears between the <> in the following: - * mmcsd0: 968MB at mmc0 + * mmcsd0: 968MB at mmc0 * 22.5MHz/4bit/128-block * * Also format just the card serial number, which the mmcsd driver will @@ -1547,6 +1569,7 @@ mmc_log_card(device_t dev, struct mmc_ivars *ivar, int break; } } + device_printf(dev, " quirks: %b\n", ivar->quirks, MMC_QUIRKS_FMT); device_printf(dev, " bus: %ubit, %uMHz (%s timing)\n", (ivar->bus_width == bus_width_1 ? 1 : (ivar->bus_width == bus_width_4 ? 4 : 8)), @@ -1563,6 +1586,7 @@ mmc_discover_cards(struct mmc_softc *sc) u_char switch_res[64]; uint32_t raw_cid[4]; struct mmc_ivars *ivar = NULL; + const struct mmc_quirk *quirk; device_t child; int err, host_caps, i, newcard; uint32_t resp, sec_count, status; @@ -1870,6 +1894,18 @@ mmc_discover_cards(struct mmc_softc *sc) ivar->raw_ext_csd[EXT_CSD_REV] >= 5); child_common: + for (quirk = &mmc_quirks[0]; quirk->mid != 0x0; quirk++) { + if ((quirk->mid == MMC_QUIRK_MID_ANY || + quirk->mid == ivar->cid.mid) && + (quirk->oid == MMC_QUIRK_OID_ANY || + quirk->oid == ivar->cid.oid) && + strncmp(quirk->pnm, ivar->cid.pnm, + sizeof(ivar->cid.pnm)) == 0) { + ivar->quirks = quirk->quirks; + break; + } + } + /* * Some cards that report maximum I/O block sizes greater * than 512 require the block length to be set to 512, even @@ -2470,6 +2506,12 @@ mmc_read_ivar(device_t bus, device_t child, int which, break; case MMC_IVAR_MAX_DATA: *result = mmcbr_get_max_data(bus); + break; + case MMC_IVAR_CMD6_TIMEOUT: + *result = ivar->cmd6_time; + break; + case MMC_IVAR_QUIRKS: + *result = ivar->quirks; break; case MMC_IVAR_CARD_ID_STRING: *(char **)result = ivar->card_id_string; Modified: head/sys/dev/mmc/mmcreg.h ============================================================================== --- head/sys/dev/mmc/mmcreg.h Mon Aug 7 23:32:00 2017 (r322208) +++ head/sys/dev/mmc/mmcreg.h Mon Aug 7 23:33:05 2017 (r322209) @@ -268,6 +268,13 @@ struct mmc_request { #define MMC_ERASE_GROUP_END 36 /* 37 -- reserved old command */ #define MMC_ERASE 38 +#define MMC_ERASE_ERASE 0x00000000 +#define MMC_ERASE_TRIM 0x00000001 +#define MMC_ERASE_FULE 0x00000002 +#define MMC_ERASE_DISCARD 0x00000003 +#define MMC_ERASE_SECURE_ERASE 0x80000000 +#define MMC_ERASE_SECURE_TRIM1 0x80000001 +#define MMC_ERASE_SECURE_TRIM2 0x80008000 /* Class 9: I/O mode commands */ #define MMC_FAST_IO 39 @@ -375,6 +382,7 @@ struct mmc_request { #define EXT_CSD_ERASE_TO_MULT 223 /* RO */ #define EXT_CSD_ERASE_GRP_SIZE 224 /* RO */ #define EXT_CSD_BOOT_SIZE_MULT 226 /* RO */ +#define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */ #define EXT_CSD_PWR_CL_200_195 236 /* RO */ #define EXT_CSD_PWR_CL_200_360 237 /* RO */ #define EXT_CSD_PWR_CL_52_195_DDR 238 /* RO */ @@ -459,6 +467,22 @@ struct mmc_request { #define EXT_CSD_STROBE_SUPPORT_EN 0x01 +#define EXT_CSD_SEC_FEATURE_SUPPORT_ER_EN 0x01 +#define EXT_CSD_SEC_FEATURE_SUPPORT_BD_BLK_EN 0x04 +#define EXT_CSD_SEC_FEATURE_SUPPORT_GB_CL_EN 0x10 +#define EXT_CSD_SEC_FEATURE_SUPPORT_SANITIZE 0x40 + +/* + * Vendor specific EXT_CSD fields + */ +/* SanDisk iNAND */ +#define EXT_CSD_INAND_CMD38 113 +#define EXT_CSD_INAND_CMD38_ERASE 0x00 +#define EXT_CSD_INAND_CMD38_TRIM 0x01 +#define EXT_CSD_INAND_CMD38_SECURE_ERASE 0x80 +#define EXT_CSD_INAND_CMD38_SECURE_TRIM1 0x81 +#define EXT_CSD_INAND_CMD38_SECURE_TRIM2 0x82 + #define MMC_TYPE_HS_26_MAX 26000000 #define MMC_TYPE_HS_52_MAX 52000000 #define MMC_TYPE_DDR52_MAX 52000000 @@ -600,8 +624,7 @@ struct mmc_cid { uint8_t fwrev; }; -struct mmc_csd -{ +struct mmc_csd { uint8_t csd_structure; uint8_t spec_vers; uint16_t ccc; @@ -627,16 +650,14 @@ struct mmc_csd wp_grp_enable:1; }; -struct mmc_scr -{ +struct mmc_scr { unsigned char sda_vsn; unsigned char bus_widths; #define SD_SCR_BUS_WIDTH_1 (1 << 0) #define SD_SCR_BUS_WIDTH_4 (1 << 2) }; -struct mmc_sd_status -{ +struct mmc_sd_status { uint8_t bus_width; uint8_t secured_mode; uint16_t card_type; @@ -648,6 +669,19 @@ struct mmc_sd_status uint8_t erase_timeout; uint8_t erase_offset; }; + +struct mmc_quirk { + uint32_t mid; +#define MMC_QUIRK_MID_ANY ((uint32_t)-1) + uint16_t oid; +#define MMC_QUIRK_OID_ANY ((uint16_t)-1) + const char *pnm; + uint32_t quirks; +#define MMC_QUIRK_INAND_CMD38 0x0001 +#define MMC_QUIRK_BROKEN_TRIM 0x0002 +}; + +#define MMC_QUIRKS_FMT "\020" "\001INAND_CMD38" "\002BROKEN_TRIM" /* * Various MMC/SD constants Modified: head/sys/dev/mmc/mmcsd.c ============================================================================== --- head/sys/dev/mmc/mmcsd.c Mon Aug 7 23:32:00 2017 (r322208) +++ head/sys/dev/mmc/mmcsd.c Mon Aug 7 23:33:05 2017 (r322209) @@ -126,6 +126,10 @@ struct mmcsd_softc { uint8_t part_curr; /* Partition currently switched to */ uint8_t ext_csd[MMC_EXTCSD_SIZE]; uint16_t rca; + uint32_t flags; +#define MMCSD_INAND_CMD38 0x0001 +#define MMCSD_USE_TRIM 0x0002 + uint32_t cmd6_time; /* Generic switch timeout [us] */ uint32_t part_time; /* Partition switch timeout [us] */ off_t enh_base; /* Enhanced user data area slice base ... */ off_t enh_size; /* ... and size [bytes] */ @@ -168,9 +172,10 @@ static int mmcsd_ioctl_rpmb(struct cdev *dev, u_long c int fflag, struct thread *td); static void mmcsd_add_part(struct mmcsd_softc *sc, u_int type, - const char *name, u_int cnt, off_t media_size, off_t erase_size, bool ro); + const char *name, u_int cnt, off_t media_size, bool ro); static int mmcsd_bus_bit_width(device_t dev); static daddr_t mmcsd_delete(struct mmcsd_part *part, struct bio *bp); +static const char *mmcsd_errmsg(int e); static int mmcsd_ioctl(struct mmcsd_part *part, u_long cmd, void *data, int fflag); static int mmcsd_ioctl_cmd(struct mmcsd_part *part, struct mmc_ioc_cmd *mic, @@ -221,6 +226,7 @@ mmcsd_attach(device_t dev) off_t erase_size, sector_size, size, wp_size; uintmax_t bytes; int err, i; + uint32_t quirks; uint8_t rev; bool comp, ro; char unit[2]; @@ -239,21 +245,48 @@ mmcsd_attach(device_t dev) * place either. */ sc->max_data = mmc_get_max_data(dev); - sc->erase_sector = mmc_get_erase_sector(dev); sc->high_cap = mmc_get_high_cap(dev); sc->rca = mmc_get_rca(dev); + sc->cmd6_time = mmc_get_cmd6_timeout(dev); + quirks = mmc_get_quirks(dev); /* Only MMC >= 4.x devices support EXT_CSD. */ if (mmc_get_spec_vers(dev) >= 4) { MMCBUS_ACQUIRE_BUS(mmcbus, dev); err = mmc_send_ext_csd(mmcbus, dev, sc->ext_csd); MMCBUS_RELEASE_BUS(mmcbus, dev); - if (err != MMC_ERR_NONE) - bzero(sc->ext_csd, sizeof(sc->ext_csd)); + if (err != MMC_ERR_NONE) { + device_printf(dev, "Error reading EXT_CSD %s\n", + mmcsd_errmsg(err)); + return (ENXIO); + } } ext_csd = sc->ext_csd; + if ((quirks & MMC_QUIRK_INAND_CMD38) != 0) { + if (mmc_get_spec_vers(dev) < 4) { + device_printf(dev, + "MMC_QUIRK_INAND_CMD38 set but no EXT_CSD\n"); + return (EINVAL); + } + sc->flags |= MMCSD_INAND_CMD38; + } + /* + * EXT_CSD_SEC_FEATURE_SUPPORT_GB_CL_EN denotes support for both + * insecure and secure TRIM. + */ + if ((ext_csd[EXT_CSD_SEC_FEATURE_SUPPORT] & + EXT_CSD_SEC_FEATURE_SUPPORT_GB_CL_EN) != 0 && + (quirks & MMC_QUIRK_BROKEN_TRIM) == 0) { + if (bootverbose) + device_printf(dev, "taking advantage of TRIM\n"); + sc->flags |= MMCSD_USE_TRIM; + sc->erase_sector = 1; + } else + sc->erase_sector = mmc_get_erase_sector(dev); + + /* * Enhanced user data area and general purpose partitions are only * supported in revision 1.4 (EXT_CSD_REV == 4) and later, the RPMB * partition in revision 1.5 (MMC v4.41, EXT_CSD_REV == 5) and later. @@ -306,8 +339,7 @@ mmcsd_attach(device_t dev) */ ro = mmc_get_read_only(dev); mmcsd_add_part(sc, EXT_CSD_PART_CONFIG_ACC_DEFAULT, "mmcsd", - device_get_unit(dev), mmc_get_media_size(dev) * sector_size, - sc->erase_sector * sector_size, ro); + device_get_unit(dev), mmc_get_me