Date: Tue, 25 Jun 2013 07:32:50 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252202 - stable/9/sys/cam Message-ID: <201306250732.r5P7WoBc015572@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Tue Jun 25 07:32:49 2013 New Revision: 252202 URL: http://svnweb.freebsd.org/changeset/base/252202 Log: MFC r249980: 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. Modified: stable/9/sys/cam/cam_periph.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/cam_periph.c ============================================================================== --- stable/9/sys/cam/cam_periph.c Tue Jun 25 07:27:23 2013 (r252201) +++ stable/9/sys/cam/cam_periph.c Tue Jun 25 07:32:49 2013 (r252202) @@ -203,7 +203,7 @@ cam_periph_alloc(periph_ctor_t *periph_c periph->type = type; periph->periph_name = name; periph->immediate_priority = CAM_PRIORITY_NONE; - periph->refcount = 0; + periph->refcount = 1; /* Dropped by invalidation. */ periph->sim = sim; SLIST_INIT(&periph->ccb_list); status = xpt_create_path(&path, periph, path_id, target_id, lun_id); @@ -381,10 +381,8 @@ cam_periph_release_locked_buses(struct c mtx_assert(periph->sim->mtx, MA_OWNED); KASSERT(periph->refcount >= 1, ("periph->refcount >= 1")); - if (--periph->refcount == 0 - && (periph->flags & CAM_PERIPH_INVALID)) { + if (--periph->refcount == 0) camperiphfree(periph); - } } void @@ -579,23 +577,20 @@ void cam_periph_invalidate(struct cam_periph *periph) { - CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph invalidated\n")); mtx_assert(periph->sim->mtx, MA_OWNED); /* * We only call this routine the first time a peripheral is * invalidated. */ - if (((periph->flags & CAM_PERIPH_INVALID) == 0) - && (periph->periph_oninval != NULL)) - periph->periph_oninval(periph); + if ((periph->flags & CAM_PERIPH_INVALID) != 0) + return; + CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph invalidated\n")); periph->flags |= CAM_PERIPH_INVALID; periph->flags &= ~CAM_PERIPH_NEW_DEV_FOUND; - - xpt_lock_buses(); - if (periph->refcount == 0) - camperiphfree(periph); - xpt_unlock_buses(); + if (periph->periph_oninval != NULL) + periph->periph_oninval(periph); + cam_periph_release_locked(periph); } static void
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201306250732.r5P7WoBc015572>