Date: Sun, 6 Jan 2019 22:50:16 +0000 (UTC) From: Kirk McKusick <mckusick@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r342821 - stable/11/sys/kern Message-ID: <201901062250.x06MoGEQ060482@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mckusick Date: Sun Jan 6 22:50:16 2019 New Revision: 342821 URL: https://svnweb.freebsd.org/changeset/base/342821 Log: MFC of 342135 and 342290 Properly respond to error from VFS_ROOT() during mount. Sponsored by: Netflix Modified: stable/11/sys/kern/vfs_mount.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/vfs_mount.c ============================================================================== --- stable/11/sys/kern/vfs_mount.c Sun Jan 6 22:48:56 2019 (r342820) +++ stable/11/sys/kern/vfs_mount.c Sun Jan 6 22:50:16 2019 (r342821) @@ -825,7 +825,7 @@ vfs_domount_first( struct vattr va; struct mount *mp; struct vnode *newdp; - int error; + int error, error1; ASSERT_VOP_ELOCKED(vp, __func__); KASSERT((fsflags & MNT_UPDATE) == 0, ("MNT_UPDATE shouldn't be here")); @@ -867,8 +867,15 @@ vfs_domount_first( * XXX The final recipients of VFS_MOUNT just overwrite the ndp they * get. No freeing of cn_pnbuf. */ - error = VFS_MOUNT(mp); - if (error != 0) { + error1 = 0; + if ((error = VFS_MOUNT(mp)) != 0 || + (error1 = VFS_STATFS(mp, &mp->mnt_stat)) != 0 || + (error1 = VFS_ROOT(mp, LK_EXCLUSIVE, &newdp)) != 0) { + if (error1 != 0) { + error = error1; + if ((error1 = VFS_UNMOUNT(mp, 0)) != 0) + printf("VFS_UNMOUNT returned %d\n", error1); + } vfs_unbusy(mp); mp->mnt_vnodecovered = NULL; vfs_mount_destroy(mp); @@ -878,12 +885,12 @@ vfs_domount_first( vrele(vp); return (error); } + VOP_UNLOCK(newdp, 0); if (mp->mnt_opt != NULL) vfs_freeopts(mp->mnt_opt); mp->mnt_opt = mp->mnt_optnew; *optlist = NULL; - (void)VFS_STATFS(mp, &mp->mnt_stat); /* * Prevent external consumers of mount options from reading mnt_optnew. @@ -909,8 +916,7 @@ vfs_domount_first( TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); mtx_unlock(&mountlist_mtx); vfs_event_signal(NULL, VQ_MOUNT, 0); - if (VFS_ROOT(mp, LK_EXCLUSIVE, &newdp)) - panic("mount: lost mount"); + vn_lock(newdp, LK_EXCLUSIVE | LK_RETRY); VOP_UNLOCK(vp, 0); EVENTHANDLER_INVOKE(vfs_mounted, mp, newdp, td); VOP_UNLOCK(newdp, 0);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201901062250.x06MoGEQ060482>