ahc(4)/ahd(4): target mode: cancel outstanding AIOs and INOTs

When disabling a lun there can still be outstanding AIOs and INOTs, when
this happens previously the lun would just fail to disable and trying to
re-use the lun would break the card.

isp(4) in target mode does the same thing when disabling a lun, in
testing this allows re-starting of ctld(8) with connected initiators and
allows initiators to gracefully resume afterwards.

Signed-off-by: HP van Braam <hp@tmm.cx>
Reviewed by: imp, mav
Pull Request: https://github.com/freebsd/freebsd-src/pull/1190
This commit is contained in:
HP van Braam 2024-04-23 14:47:12 -06:00 committed by Warner Losh
parent 65971073d9
commit d31b677356
2 changed files with 22 additions and 4 deletions

View file

@ -9803,6 +9803,7 @@ ahd_handle_en_lun(struct ahd_softc *ahd, struct cam_sim *sim, union ccb *ccb)
struct ahd_tmode_tstate *tstate;
struct ahd_tmode_lstate *lstate;
struct ccb_en_lun *cel;
union ccb *cancel_ccb;
cam_status status;
u_int target;
u_int lun;
@ -10021,12 +10022,20 @@ ahd_handle_en_lun(struct ahd_softc *ahd, struct cam_sim *sim, union ccb *ccb)
if (SLIST_FIRST(&lstate->accept_tios) != NULL) {
printf("ATIOs pending\n");
ccb->ccb_h.status = CAM_REQ_INVALID;
while ((cancel_ccb = (union ccb *)SLIST_FIRST(&lstate->accept_tios)) != NULL) {
SLIST_REMOVE_HEAD(&lstate->accept_tios, sim_links.sle);
cancel_ccb->ccb_h.status = CAM_REQ_ABORTED;
xpt_done(cancel_ccb);
};
}
if (SLIST_FIRST(&lstate->immed_notifies) != NULL) {
printf("INOTs pending\n");
ccb->ccb_h.status = CAM_REQ_INVALID;
while ((cancel_ccb = (union ccb *)SLIST_FIRST(&lstate->immed_notifies)) != NULL) {
SLIST_REMOVE_HEAD(&lstate->immed_notifies, sim_links.sle);
cancel_ccb->ccb_h.status = CAM_REQ_ABORTED;
xpt_done(cancel_ccb);
};
}
if (ccb->ccb_h.status != CAM_REQ_CMP) {

View file

@ -7253,6 +7253,7 @@ ahc_handle_en_lun(struct ahc_softc *ahc, struct cam_sim *sim, union ccb *ccb)
struct ahc_tmode_tstate *tstate;
struct ahc_tmode_lstate *lstate;
struct ccb_en_lun *cel;
union ccb *cancel_ccb;
cam_status status;
u_int target;
u_int lun;
@ -7520,12 +7521,20 @@ ahc_handle_en_lun(struct ahc_softc *ahc, struct cam_sim *sim, union ccb *ccb)
if (SLIST_FIRST(&lstate->accept_tios) != NULL) {
printf("ATIOs pending\n");
ccb->ccb_h.status = CAM_REQ_INVALID;
while ((cancel_ccb = (union ccb *)SLIST_FIRST(&lstate->accept_tios)) != NULL) {
SLIST_REMOVE_HEAD(&lstate->accept_tios, sim_links.sle);
cancel_ccb->ccb_h.status = CAM_REQ_ABORTED;
xpt_done(cancel_ccb);
};
}
if (SLIST_FIRST(&lstate->immed_notifies) != NULL) {
printf("INOTs pending\n");
ccb->ccb_h.status = CAM_REQ_INVALID;
while ((cancel_ccb = (union ccb *)SLIST_FIRST(&lstate->immed_notifies)) != NULL) {
SLIST_REMOVE_HEAD(&lstate->immed_notifies, sim_links.sle);
cancel_ccb->ccb_h.status = CAM_REQ_ABORTED;
xpt_done(cancel_ccb);
};
}
if (ccb->ccb_h.status != CAM_REQ_CMP) {