]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Delay GEOM disk_create() until CAM periph probe completes.
authorAlexander Motin <mav@FreeBSD.org>
Thu, 14 Jul 2022 19:38:14 +0000 (15:38 -0400)
committerAlexander Motin <mav@FreeBSD.org>
Thu, 14 Jul 2022 20:17:36 +0000 (16:17 -0400)
commit90bcc81bc35e89049a94a12c259b0c53fcf7a299
tree6b7bea6b913c2eafd4af4044578ce4d5ed137dda
parentb62848b0c3ffcd6c1b0f0b6e617c030acf30f603
Delay GEOM disk_create() until CAM periph probe completes.

Before this patch CAM periph drivers called both disk_alloc() and
disk_create() same time on periph creation.  But then prevented disks
from opening until the periph probe completion with cam_periph_hold().
As result, especially if disk misbehaves during the probe, GEOM event
thread, triggered to taste the disk, got blocked on open attempt,
potentially for a long time, unable to process other events.

This patch moves disk_create() call from periph creation to the end of
the probe. To allow disk_create() calls from non-sleepable CAM contexts
some of its duties requiring memory allocations are moved either back
to disk_alloc() or forward to g_disk_create(), so now disk_alloc() and
disk_add_alias() are the only disk methods that require sleeping.  If
disk fails during the probe disk_create() may just be skipped, going
directly to disk_destroy().  Other method calls during that time are
just ignored.  Since GEOM may now see the disks after CAM bus scan is
already completed, introduce per-periph boot hold functions. Enclosure
driver already had such mechanism, so just generalize it.

Reviewed by: imp
MFC after: 1 month
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D35784
sys/cam/ata/ata_da.c
sys/cam/cam_periph.c
sys/cam/cam_periph.h
sys/cam/nvme/nvme_da.c
sys/cam/scsi/scsi_cd.c
sys/cam/scsi/scsi_da.c
sys/cam/scsi/scsi_enc.c
sys/cam/scsi/scsi_enc_internal.h
sys/geom/geom_disk.c
sys/geom/geom_disk.h