Author: smh
Date: Thu May  2 14:14:57 2013
New Revision: 250179
URL: http://svnweb.freebsd.org/changeset/base/250179

Log:
  Update probe flow so that devices with lbp can also disable disksort.
  
  Ensure that delete_available is reset so re-probes after a media change,
  to one with different delete characteristics, will result in the correct
  methods being flagged as available.
  
  Make all ccb state changes use a consistent flow:
  * free()
  * xpt_release_ccb()
  * softc->state = <new state>
  * xpt_schedule()
  
  Reviewed by:  mav
  Approved by:  pjd (mentor)
  MFC after:    1 week

Modified:
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/scsi/scsi_da.c
==============================================================================
--- head/sys/cam/scsi/scsi_da.c Thu May  2 13:34:40 2013        (r250178)
+++ head/sys/cam/scsi/scsi_da.c Thu May  2 14:14:57 2013        (r250179)
@@ -2392,7 +2392,7 @@ out:
 
                if (!scsi_vpd_supported_page(periph, SVPD_BLOCK_LIMITS)) {
                        /* Not supported skip to next probe */
-                       softc->state = DA_STATE_PROBE_ATA;
+                       softc->state = DA_STATE_PROBE_BDC;
                        goto skipstate;
                }
 
@@ -2734,9 +2734,9 @@ dadone(struct cam_periph *periph, union 
                                 * with the short version of the command.
                                 */
                                if (maxsector == 0xffffffff) {
-                                       softc->state = DA_STATE_PROBE_RC16;
                                        free(rdcap, M_SCSIDA);
                                        xpt_release_ccb(done_ccb);
+                                       softc->state = DA_STATE_PROBE_RC16;
                                        xpt_schedule(periph, priority);
                                        return;
                                }
@@ -2838,9 +2838,9 @@ dadone(struct cam_periph *periph, union 
                                      (error_code == SSD_CURRENT_ERROR) &&
                                      (sense_key == SSD_KEY_ILLEGAL_REQUEST)))) 
{
                                        softc->flags &= ~DA_FLAG_CAN_RC16;
-                                       softc->state = DA_STATE_PROBE_RC;
                                        free(rdcap, M_SCSIDA);
                                        xpt_release_ccb(done_ccb);
+                                       softc->state = DA_STATE_PROBE_RC;
                                        xpt_schedule(periph, priority);
                                        return;
                                } else
@@ -2897,36 +2897,39 @@ dadone(struct cam_periph *periph, union 
                                                  &softc->sysctl_task);
                                xpt_announce_periph(periph, announce_buf);
 
-                               if (lbp) {
-                                       /*
-                                        * Based on older SBC-3 spec revisions
-                                        * any of the UNMAP methods "may" be
-                                        * available via LBP given this flag so
-                                        * we flag all of them as availble and
-                                        * then remove those which further
-                                        * probes confirm aren't available
-                                        * later.
-                                        *
-                                        * We could also check readcap(16) 
p_type
-                                        * flag to exclude one or more invalid
-                                        * write same (X) types here
-                                        */
-                                       dadeleteflag(softc, DA_DELETE_WS16, 1);
-                                       dadeleteflag(softc, DA_DELETE_WS10, 1);
-                                       dadeleteflag(softc, DA_DELETE_ZERO, 1);
-                                       dadeleteflag(softc, DA_DELETE_UNMAP, 1);
-
-                                       softc->state = DA_STATE_PROBE_LBP;
-                                       xpt_release_ccb(done_ccb);
-                                       xpt_schedule(periph, priority);
-                                       return;
-                               }
                        } else {
                                xpt_print(periph->path, "fatal error, "
                                    "could not acquire reference count\n");
                        }
                }
 
+               /* Ensure re-probe doesn't see old delete. */
+               softc->delete_available = 0;
+               if (lbp) {
+                       /*
+                        * Based on older SBC-3 spec revisions
+                        * any of the UNMAP methods "may" be
+                        * available via LBP given this flag so
+                        * we flag all of them as availble and
+                        * then remove those which further
+                        * probes confirm aren't available
+                        * later.
+                        *
+                        * We could also check readcap(16) p_type
+                        * flag to exclude one or more invalid
+                        * write same (X) types here
+                        */
+                       dadeleteflag(softc, DA_DELETE_WS16, 1);
+                       dadeleteflag(softc, DA_DELETE_WS10, 1);
+                       dadeleteflag(softc, DA_DELETE_ZERO, 1);
+                       dadeleteflag(softc, DA_DELETE_UNMAP, 1);
+
+                       xpt_release_ccb(done_ccb);
+                       softc->state = DA_STATE_PROBE_LBP;
+                       xpt_schedule(periph, priority);
+                       return;
+               }
+
                xpt_release_ccb(done_ccb);
                softc->state = DA_STATE_PROBE_BDC;
                xpt_schedule(periph, priority);
@@ -2954,8 +2957,8 @@ dadone(struct cam_periph *periph, union 
 
                        if (lbp->flags & SVPD_LBP_UNMAP) {
                                free(lbp, M_SCSIDA);
-                               softc->state = DA_STATE_PROBE_BLK_LIMITS;
                                xpt_release_ccb(done_ccb);
+                               softc->state = DA_STATE_PROBE_BLK_LIMITS;
                                xpt_schedule(periph, priority);
                                return;
                        }
@@ -2984,7 +2987,7 @@ dadone(struct cam_periph *periph, union 
 
                free(lbp, M_SCSIDA);
                xpt_release_ccb(done_ccb);
-               softc->state = DA_STATE_PROBE_ATA;
+               softc->state = DA_STATE_PROBE_BDC;
                xpt_schedule(periph, priority);
                return;
        }
@@ -3047,7 +3050,7 @@ dadone(struct cam_periph *periph, union 
 
                free(block_limits, M_SCSIDA);
                xpt_release_ccb(done_ccb);
-               softc->state = DA_STATE_PROBE_ATA;
+               softc->state = DA_STATE_PROBE_BDC;
                xpt_schedule(periph, priority);
                return;
        }
@@ -3084,8 +3087,8 @@ dadone(struct cam_periph *periph, union 
                }
 
                free(bdc, M_SCSIDA);
-               softc->state = DA_STATE_PROBE_ATA;
                xpt_release_ccb(done_ccb);
+               softc->state = DA_STATE_PROBE_ATA;
                xpt_schedule(periph, priority);
                return;
        }
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to