Now that cam_periph_runccb() can be called from situations where the

kernel scheduler is stopped, replace the by hand calling of
xpt_polled_action() with it.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13388
This commit is contained in:
Warner Losh 2017-12-06 23:05:15 +00:00
parent f93a843cd2
commit 2b31251a64
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=326644
3 changed files with 17 additions and 70 deletions

View File

@ -1088,13 +1088,8 @@ adadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t len
ata_28bit_cmd(&ccb.ataio, ATA_WRITE_DMA,
0, lba, count);
}
xpt_polled_action(&ccb);
error = adaerror(&ccb,
0, SF_NO_RECOVERY | SF_NO_RETRY);
if ((ccb.ccb_h.status & CAM_DEV_QFRZN) != 0)
cam_release_devq(ccb.ccb_h.path, /*relsim_flags*/0,
/*reduction*/0, /*timeout*/0, /*getcount_only*/0);
error = cam_periph_runccb(&ccb, adaerror,
0, SF_NO_RECOVERY | SF_NO_RETRY, NULL);
if (error != 0)
printf("Aborting dump due to I/O error.\n");
@ -1124,13 +1119,8 @@ adadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t len
ata_48bit_cmd(&ccb.ataio, ATA_FLUSHCACHE48, 0, 0, 0);
else
ata_28bit_cmd(&ccb.ataio, ATA_FLUSHCACHE, 0, 0, 0);
xpt_polled_action(&ccb);
error = adaerror(&ccb,
0, SF_NO_RECOVERY | SF_NO_RETRY);
if ((ccb.ccb_h.status & CAM_DEV_QFRZN) != 0)
cam_release_devq(ccb.ccb_h.path, /*relsim_flags*/0,
/*reduction*/0, /*timeout*/0, /*getcount_only*/0);
error = cam_periph_runccb(&ccb, adaerror,
0, SF_NO_RECOVERY | SF_NO_RETRY, NULL);
if (error != 0)
xpt_print(periph->path, "Synchronize cache failed\n");
}
@ -3510,32 +3500,9 @@ adaspindown(uint8_t cmd, int flags)
0,
ada_default_timeout*1000);
ata_28bit_cmd(&local_ccb, cmd, 0, 0, 0);
if (!SCHEDULER_STOPPED()) {
/*
* Not panicing, can just do the normal runccb
* XXX should make cam_periph_runccb work while
* XXX panicing... later
*/
error = cam_periph_runccb((union ccb *)&local_ccb, adaerror,
/*cam_flags*/0, /*sense_flags*/ SF_NO_RECOVERY | SF_NO_RETRY,
softc->disk->d_devstat);
} else {
/*
* Panicing, so we have to do this by hand: do
* xpt_polled_action to run the request through the SIM,
* extract the error, and if the queue was frozen,
* unfreeze it. cam_periph_runccb takes care of these
* details, but xpt_polled_action doesn't.
*/
xpt_polled_action((union ccb *)&local_ccb);
error = adaerror((union ccb *)&local_ccb, 0,
SF_NO_RECOVERY | SF_NO_RETRY);
if ((local_ccb.ccb_h.status & CAM_DEV_QFRZN) != 0)
cam_release_devq(local_ccb.ccb_h.path,
/*relsim_flags*/0, /*reduction*/0,
/*timeout*/0, /*getcount_only*/0);
}
error = cam_periph_runccb((union ccb *)&local_ccb, adaerror,
/*cam_flags*/0, /*sense_flags*/ SF_NO_RECOVERY | SF_NO_RETRY,
softc->disk->d_devstat);
if (error != 0)
xpt_print(periph->path, "Spin-down disk failed\n");
cam_periph_unlock(periph);

View File

@ -404,17 +404,12 @@ ndadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t len
xpt_setup_ccb(&nvmeio.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
nvmeio.ccb_h.ccb_state = NDA_CCB_DUMP;
nda_nvme_write(softc, &nvmeio, virtual, lba, length, count);
xpt_polled_action((union ccb *)&nvmeio);
error = cam_periph_error((union ccb *)&nvmeio,
0, SF_NO_RECOVERY | SF_NO_RETRY);
if ((nvmeio.ccb_h.status & CAM_DEV_QFRZN) != 0)
cam_release_devq(nvmeio.ccb_h.path, /*relsim_flags*/0,
/*reduction*/0, /*timeout*/0, /*getcount_only*/0);
error = cam_periph_runccb((union ccb *)&nvmeio, cam_periph_error,
0, SF_NO_RECOVERY | SF_NO_RETRY, NULL);
if (error != 0)
printf("Aborting dump due to I/O error.\n");
printf("Aborting dump due to I/O error %d.\n", error);
cam_periph_unlock(periph);
return (error);
}
@ -423,13 +418,8 @@ ndadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t len
nvmeio.ccb_h.ccb_state = NDA_CCB_DUMP;
nda_nvme_flush(softc, &nvmeio);
xpt_polled_action((union ccb *)&nvmeio);
error = cam_periph_error((union ccb *)&nvmeio,
0, SF_NO_RECOVERY | SF_NO_RETRY);
if ((nvmeio.ccb_h.status & CAM_DEV_QFRZN) != 0)
cam_release_devq(nvmeio.ccb_h.path, /*relsim_flags*/0,
/*reduction*/0, /*timeout*/0, /*getcount_only*/0);
error = cam_periph_runccb((union ccb *)&nvmeio, cam_periph_error,
0, SF_NO_RECOVERY | SF_NO_RETRY, NULL);
if (error != 0)
xpt_print(periph->path, "flush cmd failed\n");
cam_periph_unlock(periph);

View File

@ -1673,13 +1673,8 @@ dadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t leng
/*dxfer_len*/length,
/*sense_len*/SSD_FULL_SIZE,
da_default_timeout * 1000);
xpt_polled_action((union ccb *)&csio);
error = cam_periph_error((union ccb *)&csio,
0, SF_NO_RECOVERY | SF_NO_RETRY);
if ((csio.ccb_h.status & CAM_DEV_QFRZN) != 0)
cam_release_devq(csio.ccb_h.path, /*relsim_flags*/0,
/*reduction*/0, /*timeout*/0, /*getcount_only*/0);
error = cam_periph_runccb((union ccb *)&csio, cam_periph_error,
0, SF_NO_RECOVERY | SF_NO_RETRY, NULL);
if (error != 0)
printf("Aborting dump due to I/O error.\n");
cam_periph_unlock(periph);
@ -1701,13 +1696,8 @@ dadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t leng
/*lb_count*/0,
SSD_FULL_SIZE,
5 * 1000);
xpt_polled_action((union ccb *)&csio);
error = cam_periph_error((union ccb *)&csio,
0, SF_NO_RECOVERY | SF_NO_RETRY | SF_QUIET_IR);
if ((csio.ccb_h.status & CAM_DEV_QFRZN) != 0)
cam_release_devq(csio.ccb_h.path, /*relsim_flags*/0,
/*reduction*/0, /*timeout*/0, /*getcount_only*/0);
error = cam_periph_runccb((union ccb *)&csio, cam_periph_error,
0, SF_NO_RECOVERY | SF_NO_RETRY, NULL);
if (error != 0)
xpt_print(periph->path, "Synchronize cache failed\n");
}