From owner-svn-src-all@freebsd.org Mon Apr 27 13:54:01 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2E8B92B96B4; Mon, 27 Apr 2020 13:54:01 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 499mTj0TtSz44Jp; Mon, 27 Apr 2020 13:54:01 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0BC5AB65B; Mon, 27 Apr 2020 13:54:01 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 03RDs0aU002275; Mon, 27 Apr 2020 13:54:00 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 03RDs0bP002272; Mon, 27 Apr 2020 13:54:00 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202004271354.03RDs0bP002272@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Mon, 27 Apr 2020 13:54:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r360374 - in head/sys: kern sys X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in head/sys: kern sys X-SVN-Commit-Revision: 360374 X-SVN-Commit-Repository: base 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.29 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, 27 Apr 2020 13:54:01 -0000 Author: mjg Date: Mon Apr 27 13:54:00 2020 New Revision: 360374 URL: https://svnweb.freebsd.org/changeset/base/360374 Log: pwd: unbreak repeated calls to set_rootvnode Prior to the change the once set pointer would never be updated. Unbreaks reboot -r. Reported by: Ross Gohlke Modified: head/sys/kern/kern_descrip.c head/sys/kern/vfs_mountroot.c head/sys/sys/filedesc.h Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Mon Apr 27 13:26:43 2020 (r360373) +++ head/sys/kern/kern_descrip.c Mon Apr 27 13:54:00 2020 (r360374) @@ -3475,6 +3475,27 @@ pwd_ensure_dirs(void) pwd_drop(oldpwd); } +void +pwd_set_rootvnode(void) +{ + struct filedesc *fdp; + struct pwd *oldpwd, *newpwd; + + fdp = curproc->p_fd; + + newpwd = pwd_alloc(); + FILEDESC_XLOCK(fdp); + oldpwd = FILEDESC_XLOCKED_LOAD_PWD(fdp); + vrefact(rootvnode); + newpwd->pwd_cdir = rootvnode; + vrefact(rootvnode); + newpwd->pwd_rdir = rootvnode; + pwd_fill(oldpwd, newpwd); + pwd_set(fdp, newpwd); + FILEDESC_XUNLOCK(fdp); + pwd_drop(oldpwd); +} + /* * Scan all active processes and prisons to see if any of them have a current * or root directory of `olddp'. If so, replace them with the new mount point. Modified: head/sys/kern/vfs_mountroot.c ============================================================================== --- head/sys/kern/vfs_mountroot.c Mon Apr 27 13:26:43 2020 (r360373) +++ head/sys/kern/vfs_mountroot.c Mon Apr 27 13:54:00 2020 (r360374) @@ -243,7 +243,7 @@ set_rootvnode(void) VOP_UNLOCK(rootvnode); - pwd_ensure_dirs(); + pwd_set_rootvnode(); } static int Modified: head/sys/sys/filedesc.h ============================================================================== --- head/sys/sys/filedesc.h Mon Apr 27 13:26:43 2020 (r360373) +++ head/sys/sys/filedesc.h Mon Apr 27 13:54:00 2020 (r360374) @@ -298,6 +298,7 @@ fd_modified(struct filedesc *fdp, int fd, seqc_t seqc) void pwd_chdir(struct thread *td, struct vnode *vp); int pwd_chroot(struct thread *td, struct vnode *vp); void pwd_ensure_dirs(void); +void pwd_set_rootvnode(void); struct pwd *pwd_hold_filedesc(struct filedesc *fdp); struct pwd *pwd_hold(struct thread *td);