Author: imp
Date: Wed Dec  6 23:05:15 2017
New Revision: 326644
URL: https://svnweb.freebsd.org/changeset/base/326644

Log:
  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

Modified:
  head/sys/cam/ata/ata_da.c
  head/sys/cam/nvme/nvme_da.c
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/ata/ata_da.c
==============================================================================
--- head/sys/cam/ata/ata_da.c   Wed Dec  6 23:05:07 2017        (r326643)
+++ head/sys/cam/ata/ata_da.c   Wed Dec  6 23:05:15 2017        (r326644)
@@ -1088,13 +1088,8 @@ adadump(void *arg, void *virtual, vm_offset_t physical
                        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
                        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);

Modified: head/sys/cam/nvme/nvme_da.c
==============================================================================
--- head/sys/cam/nvme/nvme_da.c Wed Dec  6 23:05:07 2017        (r326643)
+++ head/sys/cam/nvme/nvme_da.c Wed Dec  6 23:05:15 2017        (r326644)
@@ -404,17 +404,12 @@ ndadump(void *arg, void *virtual, vm_offset_t physical
                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
 
        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);

Modified: head/sys/cam/scsi/scsi_da.c
==============================================================================
--- head/sys/cam/scsi/scsi_da.c Wed Dec  6 23:05:07 2017        (r326643)
+++ head/sys/cam/scsi/scsi_da.c Wed Dec  6 23:05:15 2017        (r326644)
@@ -1673,13 +1673,8 @@ dadump(void *arg, void *virtual, vm_offset_t physical,
                                /*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,
                                       /*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");
        }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to