Commit 9781c28c authored by Alexander Motin's avatar Alexander Motin
Browse files

mpr(4): Fix unmatched devq release.

Before this change devq was frozen only if some command was sent to
the target after reset started, but release was called always.  This
change freezes the devq immediately, leaving mprsas_action_scsiio()
check only to cover race condition due to different lock devq use.

This should also avoid unnecessary requeue of the commands, creating
additional log noise and confusing some broken apps.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
parent 5d75ffdd
...@@ -237,7 +237,6 @@ mprsas_alloc_tm(struct mpr_softc *sc) ...@@ -237,7 +237,6 @@ mprsas_alloc_tm(struct mpr_softc *sc)
void void
mprsas_free_tm(struct mpr_softc *sc, struct mpr_command *tm) mprsas_free_tm(struct mpr_softc *sc, struct mpr_command *tm)
{ {
int target_id = 0xFFFFFFFF;
MPR_FUNCTRACE(sc); MPR_FUNCTRACE(sc);
if (tm == NULL) if (tm == NULL)
...@@ -248,13 +247,10 @@ mprsas_free_tm(struct mpr_softc *sc, struct mpr_command *tm) ...@@ -248,13 +247,10 @@ mprsas_free_tm(struct mpr_softc *sc, struct mpr_command *tm)
* free the resources used for freezing the devq. Must clear the * free the resources used for freezing the devq. Must clear the
* INRESET flag as well or scsi I/O will not work. * INRESET flag as well or scsi I/O will not work.
*/ */
if (tm->cm_targ != NULL) {
tm->cm_targ->flags &= ~MPRSAS_TARGET_INRESET;
target_id = tm->cm_targ->tid;
}
if (tm->cm_ccb) { if (tm->cm_ccb) {
mpr_dprint(sc, MPR_INFO, "Unfreezing devq for target ID %d\n", mpr_dprint(sc, MPR_XINFO, "Unfreezing devq for target ID %d\n",
target_id); tm->cm_targ->tid);
tm->cm_targ->flags &= ~MPRSAS_TARGET_INRESET;
xpt_release_devq(tm->cm_ccb->ccb_h.path, 1, TRUE); xpt_release_devq(tm->cm_ccb->ccb_h.path, 1, TRUE);
xpt_free_path(tm->cm_ccb->ccb_h.path); xpt_free_path(tm->cm_ccb->ccb_h.path);
xpt_free_ccb(tm->cm_ccb); xpt_free_ccb(tm->cm_ccb);
...@@ -1923,13 +1919,11 @@ mprsas_action_scsiio(struct mprsas_softc *sassc, union ccb *ccb) ...@@ -1923,13 +1919,11 @@ mprsas_action_scsiio(struct mprsas_softc *sassc, union ccb *ccb)
} }
/* /*
* If target has a reset in progress, freeze the devq and return. The * If target has a reset in progress, the devq should be frozen.
* devq will be released when the TM reset is finished. * Geting here we likely hit a race, so just requeue.
*/ */
if (targ->flags & MPRSAS_TARGET_INRESET) { if (targ->flags & MPRSAS_TARGET_INRESET) {
ccb->ccb_h.status = CAM_BUSY | CAM_DEV_QFRZN; ccb->ccb_h.status = CAM_REQUEUE_REQ | CAM_DEV_QFRZN;
mpr_dprint(sc, MPR_INFO, "%s: Freezing devq for target ID %d\n",
__func__, targ->tid);
xpt_freeze_devq(ccb->ccb_h.path, 1); xpt_freeze_devq(ccb->ccb_h.path, 1);
xpt_done(ccb); xpt_done(ccb);
return; return;
...@@ -3426,10 +3420,9 @@ mprsas_async(void *callback_arg, uint32_t code, struct cam_path *path, ...@@ -3426,10 +3420,9 @@ mprsas_async(void *callback_arg, uint32_t code, struct cam_path *path,
} }
/* /*
* Set the INRESET flag for this target so that no I/O will be sent to * Freeze the devq and set the INRESET flag so that no I/O will be sent to
* the target until the reset has completed. If an I/O request does * the target until the reset has completed. The CCB holds the path which
* happen, the devq will be frozen. The CCB holds the path which is * is used to release the devq. The devq is released and the CCB is freed
* used to release the devq. The devq is released and the CCB is freed
* when the TM completes. * when the TM completes.
*/ */
void void
...@@ -3446,6 +3439,10 @@ mprsas_prepare_for_tm(struct mpr_softc *sc, struct mpr_command *tm, ...@@ -3446,6 +3439,10 @@ mprsas_prepare_for_tm(struct mpr_softc *sc, struct mpr_command *tm,
target->tid, lun_id) != CAM_REQ_CMP) { target->tid, lun_id) != CAM_REQ_CMP) {
xpt_free_ccb(ccb); xpt_free_ccb(ccb);
} else { } else {
mpr_dprint(sc, MPR_XINFO,
"%s: Freezing devq for target ID %d\n",
__func__, target->tid);
xpt_freeze_devq(ccb->ccb_h.path, 1);
tm->cm_ccb = ccb; tm->cm_ccb = ccb;
tm->cm_targ = target; tm->cm_targ = target;
target->flags |= MPRSAS_TARGET_INRESET; target->flags |= MPRSAS_TARGET_INRESET;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment