From owner-svn-src-all@freebsd.org Mon Feb 6 20:44:36 2017 Return-Path: Delivered-To: svn-src-all@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 4AF79CD3EDB; Mon, 6 Feb 2017 20:44:36 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 17FA085; Mon, 6 Feb 2017 20:44:36 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v16KiZTI065164; Mon, 6 Feb 2017 20:44:35 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v16KiZOv065163; Mon, 6 Feb 2017 20:44:35 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201702062044.v16KiZOv065163@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Mon, 6 Feb 2017 20:44:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r313351 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Feb 2017 20:44:36 -0000 Author: trasz Date: Mon Feb 6 20:44:34 2017 New Revision: 313351 URL: https://svnweb.freebsd.org/changeset/base/313351 Log: Make root_mount_hold() work after boot. This is important for two reasons. First is rerooting into USB-mounted device that happens to be not yet enumerated. The second is when mounting with (non-root) filesystem on USB device on a hub that's enumerated later than the root mount: the rc scripts explicitly mount for the root mount holds to be released, but each USB bus takes the hold asynchronously, and if that happens after root mount, it would just get ignored. Reviewed by: marcel MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9388 Modified: head/sys/kern/vfs_mountroot.c Modified: head/sys/kern/vfs_mountroot.c ============================================================================== --- head/sys/kern/vfs_mountroot.c Mon Feb 6 20:36:59 2017 (r313350) +++ head/sys/kern/vfs_mountroot.c Mon Feb 6 20:44:34 2017 (r313351) @@ -171,9 +171,6 @@ root_mount_hold(const char *identifier) { struct root_hold_token *h; - if (root_mounted()) - return (NULL); - h = malloc(sizeof *h, M_DEVBUF, M_ZERO | M_WAITOK); h->who = identifier; mtx_lock(&root_holds_mtx); @@ -186,8 +183,8 @@ void root_mount_rel(struct root_hold_token *h) { - if (h == NULL) - return; + KASSERT(h != NULL, ("%s: NULL token", __func__)); + mtx_lock(&root_holds_mtx); LIST_REMOVE(h, list); wakeup(&root_holds);