Add interleaving root hold tokens from the CAM probe to disk_create and geom

provider tasting. This is needed for disk attachments that happen after threads
are running in the boot process.

Tested by:	rnoland
This commit is contained in:
Andrew Thompson 2009-04-03 19:49:33 +00:00
parent 626fc9fe3d
commit 31da42bab2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=190677
5 changed files with 17 additions and 0 deletions

View File

@ -5139,6 +5139,7 @@ xpt_find_device(struct cam_et *target, lun_id_t lun_id)
typedef struct {
union ccb *request_ccb;
struct ccb_pathinq *cpi;
struct root_hold_token *roothold;
int counter;
} xpt_scan_bus_info;
@ -5201,6 +5202,7 @@ xpt_scan_bus(struct cam_periph *periph, union ccb *request_ccb)
}
scan_info->request_ccb = request_ccb;
scan_info->cpi = &work_ccb->cpi;
scan_info->roothold = root_mount_hold("CAM", M_NOWAIT);
/* Cache on our stack so we can work asynchronously */
max_target = scan_info->cpi->max_target;
@ -5232,6 +5234,7 @@ xpt_scan_bus(struct cam_periph *periph, union ccb *request_ccb)
printf("xpt_scan_bus: xpt_create_path failed"
" with status %#x, bus scan halted\n",
status);
root_mount_rel(scan_info->roothold);
free(scan_info, M_CAMXPT);
request_ccb->ccb_h.status = status;
xpt_free_ccb(work_ccb);
@ -5240,6 +5243,7 @@ xpt_scan_bus(struct cam_periph *periph, union ccb *request_ccb)
}
work_ccb = xpt_alloc_ccb_nowait();
if (work_ccb == NULL) {
root_mount_rel(scan_info->roothold);
free(scan_info, M_CAMXPT);
xpt_free_path(path);
request_ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
@ -5353,6 +5357,7 @@ xpt_scan_bus(struct cam_periph *periph, union ccb *request_ccb)
xpt_free_ccb(request_ccb);
xpt_free_ccb((union ccb *)scan_info->cpi);
request_ccb = scan_info->request_ccb;
root_mount_rel(scan_info->roothold);
free(scan_info, M_CAMXPT);
request_ccb->ccb_h.status = CAM_REQ_CMP;
xpt_done(request_ccb);
@ -5372,6 +5377,7 @@ xpt_scan_bus(struct cam_periph *periph, union ccb *request_ccb)
xpt_free_ccb(request_ccb);
xpt_free_ccb((union ccb *)scan_info->cpi);
request_ccb = scan_info->request_ccb;
root_mount_rel(scan_info->roothold);
free(scan_info, M_CAMXPT);
request_ccb->ccb_h.status = status;
xpt_done(request_ccb);

View File

@ -193,6 +193,8 @@ struct g_provider {
/* Two fields for the implementing class to use */
void *private;
u_int index;
struct root_hold_token *roothold;
};
/* geom_dev.c */

View File

@ -381,6 +381,7 @@ g_disk_create(void *arg, int flag)
printf("GEOM: new disk %s\n", gp->name);
dp->d_geom = gp;
g_error_provider(pp, 0);
root_mount_rel(dp->d_roothold);
}
static void
@ -467,6 +468,7 @@ disk_create(struct disk *dp, int version)
dp->d_sectorsize, DEVSTAT_ALL_SUPPORTED,
DEVSTAT_TYPE_DIRECT, DEVSTAT_PRIORITY_MAX);
dp->d_geom = NULL;
dp->d_roothold = root_mount_hold(dp->d_name, M_WAITOK);
g_disk_ident_adjust(dp->d_ident, sizeof(dp->d_ident));
g_post_event(g_disk_create, dp, M_WAITOK, dp, NULL);
}

View File

@ -88,6 +88,8 @@ struct disk {
/* Fields private to the driver */
void *d_drv1;
struct root_hold_token *d_roothold;
};
#define DISKFLAG_NEEDSGIANT 0x1

View File

@ -545,6 +545,10 @@ g_new_provider_event(void *arg, int flag)
mp->taste(mp, pp, 0);
g_topology_assert();
}
if (pp->roothold != NULL) {
root_mount_rel(pp->roothold);
pp->roothold = NULL;
}
}
@ -581,6 +585,7 @@ g_new_providerf(struct g_geom *gp, const char *fmt, ...)
pp->stat = devstat_new_entry(pp, -1, 0, DEVSTAT_ALL_SUPPORTED,
DEVSTAT_TYPE_DIRECT, DEVSTAT_PRIORITY_MAX);
LIST_INSERT_HEAD(&gp->provider, pp, provider);
pp->roothold = root_mount_hold(pp->name, M_WAITOK);
g_post_event(g_new_provider_event, pp, M_WAITOK, pp, gp, NULL);
return (pp);
}