Skip to content

Commit

Permalink
Avoid the GEOM topology lock recursion when autoexpanding a pool
Browse files Browse the repository at this point in the history
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-src@bccd2db

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 openzfs#10270
  • Loading branch information
Ryan Moeller authored May 4, 2020
1 parent 639dfeb commit 6f3e1a4
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions module/os/freebsd/zfs/vdev_geom.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
#include <geom/geom_disk.h>
#include <geom/geom_int.h>

#ifndef g_topology_locked
#define g_topology_locked() sx_xlocked(&topology_lock)
#endif

/*
* Virtual device vector for GEOM.
*/
Expand Down Expand Up @@ -800,7 +804,7 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
{
struct g_provider *pp;
struct g_consumer *cp;
int error, has_trim;
int error, has_trim, locked;
uint16_t rate;

/*
Expand All @@ -827,7 +831,9 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
}

DROP_GIANT();
g_topology_lock();
locked = g_topology_locked();
if (!locked)
g_topology_lock();
error = 0;

if (vd->vdev_spa->spa_is_splitting ||
Expand Down Expand Up @@ -922,7 +928,8 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
vdev_geom_set_physpath(vd, cp, /* do_null_update */B_FALSE);
}

g_topology_unlock();
if (!locked)
g_topology_unlock();
PICKUP_GIANT();
if (cp == NULL) {
vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
Expand Down

0 comments on commit 6f3e1a4

Please sign in to comment.