Avoid the GEOM topology lock recursion when autoexpanding a pool

The steps to reproduce the problem:

        mdconfig -a -t swap -s 3g -u 0
        gpart create -s GPT md0
        gpart add -t freebsd-zfs -s 1g md0
        zpool create -o autoexpand=on foo md0p1
        gpart resize -i 1 -s 2g md0

Authored by: pjd <pjd@FreeBSD.org>
FreeBSD-commit: freebsd/freebsd@bccd2db598

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Ported-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #10270
This commit is contained in:
Ryan Moeller 2020-05-04 18:10:41 -04:00 committed by GitHub
parent 639dfeb831
commit 6f3e1a4828
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 3 deletions

View File

@ -38,6 +38,10 @@
#include <geom/geom_disk.h> #include <geom/geom_disk.h>
#include <geom/geom_int.h> #include <geom/geom_int.h>
#ifndef g_topology_locked
#define g_topology_locked() sx_xlocked(&topology_lock)
#endif
/* /*
* Virtual device vector for GEOM. * Virtual device vector for GEOM.
*/ */
@ -800,7 +804,7 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
{ {
struct g_provider *pp; struct g_provider *pp;
struct g_consumer *cp; struct g_consumer *cp;
int error, has_trim; int error, has_trim, locked;
uint16_t rate; uint16_t rate;
/* /*
@ -827,6 +831,8 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
} }
DROP_GIANT(); DROP_GIANT();
locked = g_topology_locked();
if (!locked)
g_topology_lock(); g_topology_lock();
error = 0; error = 0;
@ -922,6 +928,7 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
vdev_geom_set_physpath(vd, cp, /* do_null_update */B_FALSE); vdev_geom_set_physpath(vd, cp, /* do_null_update */B_FALSE);
} }
if (!locked)
g_topology_unlock(); g_topology_unlock();
PICKUP_GIANT(); PICKUP_GIANT();
if (cp == NULL) { if (cp == NULL) {