MFprojects/camlock r249541:
Give periph validity flag own periph reference. That slightly simplifies the release logic and covers hypothetical case if lock is dropped inside the periph_oninval() method.
This commit is contained in:
parent
3143f63a23
commit
d38c0e53a8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=249980
@ -203,7 +203,7 @@ cam_periph_alloc(periph_ctor_t *periph_ctor,
|
|||||||
periph->type = type;
|
periph->type = type;
|
||||||
periph->periph_name = name;
|
periph->periph_name = name;
|
||||||
periph->immediate_priority = CAM_PRIORITY_NONE;
|
periph->immediate_priority = CAM_PRIORITY_NONE;
|
||||||
periph->refcount = 0;
|
periph->refcount = 1; /* Dropped by invalidation. */
|
||||||
periph->sim = sim;
|
periph->sim = sim;
|
||||||
SLIST_INIT(&periph->ccb_list);
|
SLIST_INIT(&periph->ccb_list);
|
||||||
status = xpt_create_path(&path, periph, path_id, target_id, lun_id);
|
status = xpt_create_path(&path, periph, path_id, target_id, lun_id);
|
||||||
@ -381,10 +381,8 @@ cam_periph_release_locked_buses(struct cam_periph *periph)
|
|||||||
|
|
||||||
mtx_assert(periph->sim->mtx, MA_OWNED);
|
mtx_assert(periph->sim->mtx, MA_OWNED);
|
||||||
KASSERT(periph->refcount >= 1, ("periph->refcount >= 1"));
|
KASSERT(periph->refcount >= 1, ("periph->refcount >= 1"));
|
||||||
if (--periph->refcount == 0
|
if (--periph->refcount == 0)
|
||||||
&& (periph->flags & CAM_PERIPH_INVALID)) {
|
|
||||||
camperiphfree(periph);
|
camperiphfree(periph);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -579,23 +577,20 @@ void
|
|||||||
cam_periph_invalidate(struct cam_periph *periph)
|
cam_periph_invalidate(struct cam_periph *periph)
|
||||||
{
|
{
|
||||||
|
|
||||||
CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph invalidated\n"));
|
|
||||||
mtx_assert(periph->sim->mtx, MA_OWNED);
|
mtx_assert(periph->sim->mtx, MA_OWNED);
|
||||||
/*
|
/*
|
||||||
* We only call this routine the first time a peripheral is
|
* We only call this routine the first time a peripheral is
|
||||||
* invalidated.
|
* invalidated.
|
||||||
*/
|
*/
|
||||||
if (((periph->flags & CAM_PERIPH_INVALID) == 0)
|
if ((periph->flags & CAM_PERIPH_INVALID) != 0)
|
||||||
&& (periph->periph_oninval != NULL))
|
return;
|
||||||
periph->periph_oninval(periph);
|
|
||||||
|
|
||||||
|
CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph invalidated\n"));
|
||||||
periph->flags |= CAM_PERIPH_INVALID;
|
periph->flags |= CAM_PERIPH_INVALID;
|
||||||
periph->flags &= ~CAM_PERIPH_NEW_DEV_FOUND;
|
periph->flags &= ~CAM_PERIPH_NEW_DEV_FOUND;
|
||||||
|
if (periph->periph_oninval != NULL)
|
||||||
xpt_lock_buses();
|
periph->periph_oninval(periph);
|
||||||
if (periph->refcount == 0)
|
cam_periph_release_locked(periph);
|
||||||
camperiphfree(periph);
|
|
||||||
xpt_unlock_buses();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user