svn commit: r342135 - head/sys/kern
Kirk McKusick
mckusick at FreeBSD.org
Sat Dec 15 19:04:51 UTC 2018
Author: mckusick
Date: Sat Dec 15 19:04:50 2018
New Revision: 342135
URL: https://svnweb.freebsd.org/changeset/base/342135
Log:
Under UFS/FFS the VFS_ROOT() function will return an error if the inode
check-hash fails. Panic'ing is not an appropriate response. So, check
for an error return from VFS_ROOT() and when an error is reported,
unwind and return the error.
Reported by: Gary Jennejohn (gj)
Sponsored by: Netflix
Modified:
head/sys/kern/vfs_mount.c
Modified: head/sys/kern/vfs_mount.c
==============================================================================
--- head/sys/kern/vfs_mount.c Sat Dec 15 18:49:30 2018 (r342134)
+++ head/sys/kern/vfs_mount.c Sat Dec 15 19:04:50 2018 (r342135)
@@ -841,7 +841,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"));
@@ -893,8 +893,14 @@ 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_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);
@@ -904,6 +910,7 @@ vfs_domount_first(
vrele(vp);
return (error);
}
+ VOP_UNLOCK(newdp, 0);
if (mp->mnt_opt != NULL)
vfs_freeopts(mp->mnt_opt);
@@ -935,8 +942,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_DIRECT_INVOKE(vfs_mounted, mp, newdp, td);
VOP_UNLOCK(newdp, 0);
More information about the svn-src-all
mailing list