git: 79a5c790bdf0 - main - Eliminate a locking panic when cleaning up UFS snapshots after a disk failure.

Kirk McKusick mckusick at FreeBSD.org
Sat Jan 16 00:32:40 UTC 2021


The branch main has been updated by mckusick:

URL: https://cgit.FreeBSD.org/src/commit/?id=79a5c790bdf08cb925693add4699f3e785c12bc6

commit 79a5c790bdf08cb925693add4699f3e785c12bc6
Author:     Kirk McKusick <mckusick at FreeBSD.org>
AuthorDate: 2021-01-16 00:33:00 +0000
Commit:     Kirk McKusick <mckusick at FreeBSD.org>
CommitDate: 2021-01-16 00:36:42 +0000

    Eliminate a locking panic when cleaning up UFS snapshots after a
    disk failure.
    
    Each vnode has an embedded lock that controls access to its contents.
    However vnodes describing a UFS snapshot all share a single snapshot
    lock to coordinate their access and update. As part of mounting a
    UFS filesystem with snapshots, each of the vnodes describing a
    snapshot has its individual lock replaced with the snapshot lock.
    When the filesystem is unmounted the vnode's original lock is
    returned replacing the snapshot lock.
    
    When a disk fails while the UFS filesystem it contains is still
    mounted (for example when a thumb drive is removed) UFS forcibly
    unmounts the filesystem. The loss of the drive causes the GEOM
    subsystem to orphan the provider, but the consumer remains until
    the filesystem has finished with the unmount. Information describing
    the snapshot locks was being prematurely cleared during the orphaning
    causing the return of the snapshot vnode's original locks to fail.
    The fix is to not clear the needed information prematurely.
    
    Sponsored by: Netflix
---
 sys/kern/kern_conf.c     | 1 -
 sys/ufs/ffs/ffs_vfsops.c | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c
index c38bbdb29f5f..5211422199bb 100644
--- a/sys/kern/kern_conf.c
+++ b/sys/kern/kern_conf.c
@@ -1172,7 +1172,6 @@ destroy_devl(struct cdev *dev)
 
 	dev->si_drv1 = 0;
 	dev->si_drv2 = 0;
-	bzero(&dev->__si_u, sizeof(dev->__si_u));
 
 	if (!(dev->si_flags & SI_ALIAS)) {
 		/* Remove from cdevsw list */
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index 52b9b860f817..415bb4614c1a 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -1035,6 +1035,7 @@ ffs_mountfs(odevvp, mp, td)
 	VOP_UNLOCK(odevvp);
 	KASSERT(devvp->v_type == VCHR, ("reclaimed devvp"));
 	dev = devvp->v_rdev;
+	KASSERT(dev->si_snapdata == NULL, ("non-NULL snapshot data"));
 	if (atomic_cmpset_acq_ptr((uintptr_t *)&dev->si_mountpt, 0,
 	    (uintptr_t)mp) == 0) {
 		mntfs_freevp(devvp);


More information about the dev-commits-src-all mailing list