From owner-svn-src-all@FreeBSD.ORG Thu May 8 07:13:23 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4CAE48F; Thu, 8 May 2014 07:13:23 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2E5F2848; Thu, 8 May 2014 07:13:23 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s487DNZD054573; Thu, 8 May 2014 07:13:23 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s487DN3A054572; Thu, 8 May 2014 07:13:23 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201405080713.s487DN3A054572@svn.freebsd.org> From: Alexander Motin Date: Thu, 8 May 2014 07:13:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r265644 - stable/10/sys/cam/scsi X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 May 2014 07:13:23 -0000 Author: mav Date: Thu May 8 07:13:22 2014 New Revision: 265644 URL: http://svnweb.freebsd.org/changeset/base/265644 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/10/sys/cam/scsi/scsi_da.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/10/sys/cam/scsi/scsi_da.c Thu May 8 07:12:06 2014 (r265643) +++ stable/10/sys/cam/scsi/scsi_da.c Thu May 8 07:13:22 2014 (r265644) @@ -212,6 +212,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; @@ -2135,11 +2136,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 = DISKFLAG_DIRECT_COMPLETION; if ((softc->quirks & DA_Q_NO_SYNC_CACHE) == 0) @@ -3279,14 +3281,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, @@ -3312,7 +3306,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; } @@ -3323,12 +3317,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