ffs: fix newly introduced LOR between mntfs vnode lock and topology lock

The mntfs vnode lock should be before topology, as established in
ffs_mountfs().  Extend the locked region in ffs_unmount().

Reported and reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33013
This commit is contained in:
Konstantin Belousov 2021-11-16 19:31:11 +02:00
parent 16bea05ac3
commit c34a5148e8
2 changed files with 1 additions and 3 deletions

View file

@ -309,9 +309,7 @@ g_vfs_close(struct g_consumer *cp)
gp = cp->geom;
sc = gp->softc;
vp = cp->private;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
bufobj_invalbuf(sc->sc_bo, V_SAVE, 0, 0);
VOP_UNLOCK(vp);
sc->sc_bo->bo_private = cp->private;
gp->softc = NULL;
mtx_destroy(&sc->sc_mtx);

View file

@ -1431,6 +1431,7 @@ ffs_unmount(mp, mntflags)
taskqueue_free(ump->um_trim_tq);
free (ump->um_trimhash, M_TRIM);
}
vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY);
g_topology_lock();
g_vfs_close(ump->um_cp);
g_topology_unlock();
@ -1438,7 +1439,6 @@ ffs_unmount(mp, mntflags)
ump->um_odevvp->v_bufobj.bo_flag &= ~BO_NOBUFS;
BO_UNLOCK(&ump->um_odevvp->v_bufobj);
atomic_store_rel_ptr((uintptr_t *)&ump->um_dev->si_mountpt, 0);
vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY);
mntfs_freevp(ump->um_devvp);
vrele(ump->um_odevvp);
dev_rel(ump->um_dev);