summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/cam/scsi/scsi_cd.c1
-rw-r--r--sys/cam/scsi/scsi_da.c1
-rw-r--r--sys/geom/geom_disk.c12
-rw-r--r--sys/geom/geom_disk.h1
-rw-r--r--sys/geom/geom_subr.c5
5 files changed, 18 insertions, 2 deletions
diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c
index d0b2bb2..04f9bb4 100644
--- a/sys/cam/scsi/scsi_cd.c
+++ b/sys/cam/scsi/scsi_cd.c
@@ -407,6 +407,7 @@ cdoninvalidate(struct cam_periph *periph)
&& (softc->pinfo.index != CAM_UNQUEUED_INDEX))
camq_remove(&softc->changer->devq, softc->pinfo.index);
+ disk_gone(softc->disk);
xpt_print_path(periph->path);
printf("lost device\n");
}
diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c
index 30b320c..273fadc 100644
--- a/sys/cam/scsi/scsi_da.c
+++ b/sys/cam/scsi/scsi_da.c
@@ -801,6 +801,7 @@ daoninvalidate(struct cam_periph *periph)
SLIST_REMOVE(&softc_list, softc, da_softc, links);
+ disk_gone(softc->disk);
xpt_print_path(periph->path);
printf("lost device\n");
}
diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c
index 42c40bc..75d8fc4 100644
--- a/sys/geom/geom_disk.c
+++ b/sys/geom/geom_disk.c
@@ -419,6 +419,18 @@ disk_destroy(struct disk *dp)
g_post_event(g_disk_destroy, dp, M_WAITOK, NULL);
}
+void
+disk_gone(struct disk *dp)
+{
+ struct g_geom *gp;
+ struct g_provider *pp;
+
+ gp = dp->d_geom;
+ if (gp != NULL)
+ LIST_FOREACH(pp, &gp->provider, provider)
+ g_orphan_provider(pp, ENXIO);
+}
+
static void
g_kern_disks(void *p, int flag __unused)
{
diff --git a/sys/geom/geom_disk.h b/sys/geom/geom_disk.h
index 42f5b60..23719bf 100644
--- a/sys/geom/geom_disk.h
+++ b/sys/geom/geom_disk.h
@@ -95,6 +95,7 @@ struct disk {
struct disk *disk_alloc(void);
void disk_create(struct disk *disk, int version);
void disk_destroy(struct disk *disk);
+void disk_gone(struct disk *disk);
#define DISK_VERSION_00 0x58561059
#define DISK_VERSION DISK_VERSION_00
diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c
index 4af0d4a..8bedee9 100644
--- a/sys/geom/geom_subr.c
+++ b/sys/geom/geom_subr.c
@@ -734,11 +734,12 @@ g_access(struct g_consumer *cp, int dcr, int dcw, int dce)
if (!error) {
/*
* If we open first write, spoil any partner consumers.
- * If we close last write, trigger re-taste.
+ * If we close last write and provider is not errored,
+ * trigger re-taste.
*/
if (pp->acw == 0 && dcw != 0)
g_spoil(pp, cp);
- else if (pp->acw != 0 && pp->acw == -dcw &&
+ else if (pp->acw != 0 && pp->acw == -dcw && pp->error == 0 &&
!(pp->geom->flags & G_GEOM_WITHER))
g_post_event(g_new_provider_event, pp, M_WAITOK,
pp, NULL);
OpenPOWER on IntegriCloud