svn commit: r265664 - stable/9/sys/cam/scsi
Alexander Motin
mav at FreeBSD.org
Thu May 8 08:35:25 UTC 2014
Author: mav
Date: Thu May 8 08:35:24 2014
New Revision: 265664
URL: http://svnweb.freebsd.org/changeset/base/265664
Log:
MFC r265159:
Respect MAXIMUM TRANSFER LENGTH field of Block Limits VPD page.
Nobody yet reported disk supporting I/Os less then our MAXPHYS value, but
since we any way have code to read Block Limits VPD page, that is easy.
Modified:
stable/9/sys/cam/scsi/scsi_da.c
Directory Properties:
stable/9/ (props changed)
stable/9/sys/ (props changed)
Modified: stable/9/sys/cam/scsi/scsi_da.c
==============================================================================
--- stable/9/sys/cam/scsi/scsi_da.c Thu May 8 08:34:49 2014 (r265663)
+++ stable/9/sys/cam/scsi/scsi_da.c Thu May 8 08:35:24 2014 (r265664)
@@ -213,6 +213,7 @@ struct da_softc {
int trim_max_ranges;
int delete_running;
int delete_available; /* Delete methods possibly available */
+ u_int maxio;
uint32_t unmap_max_ranges;
uint32_t unmap_max_lba; /* Max LBAs in UNMAP req */
uint64_t ws_max_blks;
@@ -2152,11 +2153,12 @@ daregister(struct cam_periph *periph, vo
softc->disk->d_name = "da";
softc->disk->d_drv1 = periph;
if (cpi.maxio == 0)
- softc->disk->d_maxsize = DFLTPHYS; /* traditional default */
+ softc->maxio = DFLTPHYS; /* traditional default */
else if (cpi.maxio > MAXPHYS)
- softc->disk->d_maxsize = MAXPHYS; /* for safety */
+ softc->maxio = MAXPHYS; /* for safety */
else
- softc->disk->d_maxsize = cpi.maxio;
+ softc->maxio = cpi.maxio;
+ softc->disk->d_maxsize = softc->maxio;
softc->disk->d_unit = periph->unit_number;
softc->disk->d_flags = 0;
if ((softc->quirks & DA_Q_NO_SYNC_CACHE) == 0)
@@ -3292,14 +3294,6 @@ dadone(struct cam_periph *periph, union
(lbp->flags & SVPD_LBP_WS10));
dadeleteflag(softc, DA_DELETE_UNMAP,
(lbp->flags & SVPD_LBP_UNMAP));
-
- if (lbp->flags & SVPD_LBP_UNMAP) {
- free(lbp, M_SCSIDA);
- xpt_release_ccb(done_ccb);
- softc->state = DA_STATE_PROBE_BLK_LIMITS;
- xpt_schedule(periph, priority);
- return;
- }
} else {
int error;
error = daerror(done_ccb, CAM_RETRY_SELTO,
@@ -3325,7 +3319,7 @@ dadone(struct cam_periph *periph, union
free(lbp, M_SCSIDA);
xpt_release_ccb(done_ccb);
- softc->state = DA_STATE_PROBE_BDC;
+ softc->state = DA_STATE_PROBE_BLK_LIMITS;
xpt_schedule(periph, priority);
return;
}
@@ -3336,12 +3330,20 @@ dadone(struct cam_periph *periph, union
block_limits = (struct scsi_vpd_block_limits *)csio->data_ptr;
if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
+ uint32_t max_txfer_len = scsi_4btoul(
+ block_limits->max_txfer_len);
uint32_t max_unmap_lba_cnt = scsi_4btoul(
block_limits->max_unmap_lba_cnt);
uint32_t max_unmap_blk_cnt = scsi_4btoul(
block_limits->max_unmap_blk_cnt);
uint64_t ws_max_blks = scsi_8btou64(
block_limits->max_write_same_length);
+
+ if (max_txfer_len != 0) {
+ softc->disk->d_maxsize = MIN(softc->maxio,
+ (off_t)max_txfer_len * softc->params.secsize);
+ }
+
/*
* We should already support UNMAP but we check lba
* and block count to be sure
More information about the svn-src-stable-9
mailing list