From owner-svn-src-all@freebsd.org Thu Aug 8 17:59:04 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CF3DBADAC2; Thu, 8 Aug 2019 17:59:04 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464GMr59Gfz4f5v; Thu, 8 Aug 2019 17:59:04 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9311FEB7; Thu, 8 Aug 2019 17:59:04 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x78Hx499092083; Thu, 8 Aug 2019 17:59:04 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x78Hx48A092081; Thu, 8 Aug 2019 17:59:04 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201908081759.x78Hx48A092081@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 8 Aug 2019 17:59:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r350769 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sbin/camcontrol X-SVN-Commit-Revision: 350769 X-SVN-Commit-Repository: base 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.29 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 Aug 2019 17:59:04 -0000 Author: mav Date: Thu Aug 8 17:59:03 2019 New Revision: 350769 URL: https://svnweb.freebsd.org/changeset/base/350769 Log: MFC r345051 (by imp): Add -l to camcontrol readcap. The -l flag sends only the READ CAPACITY (16) sevice action. Normally we send the READ CAPACITY (10) command, and only send RC16 when the capacity is larger than 2TB (since that's the max RC10 can report). However, some badly programmed drives report different numbers for RC10 and RC16. This can be hard to diagnose, but generally there's a "Logical block address out of range" error when RC16 reports a larger number than RC10 and the RC10 number is the correct one. By comparing the output of readcap with and without the -l argmuent, one can determine if there's a mismatch and if the DA_Q_NO_RC16 quirk is needed. Modified: stable/11/sbin/camcontrol/camcontrol.8 stable/11/sbin/camcontrol/camcontrol.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.8 ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.8 Thu Aug 8 17:58:14 2019 (r350768) +++ stable/11/sbin/camcontrol/camcontrol.8 Thu Aug 8 17:59:03 2019 (r350769) @@ -78,6 +78,7 @@ .Op Fl b .Op Fl h .Op Fl H +.Op Fl l .Op Fl N .Op Fl q .Op Fl s @@ -544,6 +545,11 @@ or .Fl b . .It Fl H Print out the device size in human readable (base 10, 1K == 1000) format. +.It Fl l +Skip sending the SCSI READ CAPACITY (10) command. +Send only the SCSI READ CAPACITY (16) service action and report +its results. +When the two do not match, a quirk is needed to resolve the ambiguity. .It Fl N Print out the number of blocks in the device instead of the last logical block. Modified: stable/11/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 17:58:14 2019 (r350768) +++ stable/11/sbin/camcontrol/camcontrol.c Thu Aug 8 17:59:03 2019 (r350769) @@ -198,7 +198,7 @@ static struct camcontrol_opts option_table[] = { {"load", CAM_CMD_STARTSTOP, CAM_ARG_START_UNIT | CAM_ARG_EJECT, NULL}, {"eject", CAM_CMD_STARTSTOP, CAM_ARG_EJECT, NULL}, {"reportluns", CAM_CMD_REPORTLUNS, CAM_ARG_NONE, "clr:"}, - {"readcapacity", CAM_CMD_READCAP, CAM_ARG_NONE, "bhHNqs"}, + {"readcapacity", CAM_CMD_READCAP, CAM_ARG_NONE, "bhHlNqs"}, {"reprobe", CAM_CMD_REPROBE, CAM_ARG_NONE, NULL}, #endif /* MINIMALISTIC */ {"rescan", CAM_CMD_RESCAN, CAM_ARG_NONE, NULL}, @@ -6947,7 +6947,7 @@ scsireadcapacity(struct cam_device *device, int argc, char *combinedopt, int task_attr, int retry_count, int timeout) { union ccb *ccb; - int blocksizeonly, humanize, numblocks, quiet, sizeonly, baseten; + int blocksizeonly, humanize, numblocks, quiet, sizeonly, baseten, longonly; struct scsi_read_capacity_data rcap; struct scsi_read_capacity_data_long rcaplong; uint64_t maxsector; @@ -6957,6 +6957,7 @@ scsireadcapacity(struct cam_device *device, int argc, blocksizeonly = 0; humanize = 0; + longonly = 0; numblocks = 0; quiet = 0; sizeonly = 0; @@ -6985,6 +6986,9 @@ scsireadcapacity(struct cam_device *device, int argc, humanize++; baseten++; break; + case 'l': + longonly++; + break; case 'N': numblocks++; break; @@ -7027,6 +7031,9 @@ scsireadcapacity(struct cam_device *device, int argc, goto bailout; } + if (longonly != 0) + goto long_only; + scsi_read_capacity(&ccb->csio, /*retries*/ retry_count, /*cbfcnp*/ NULL, @@ -7069,6 +7076,7 @@ scsireadcapacity(struct cam_device *device, int argc, if (maxsector != 0xffffffff) goto do_print; +long_only: scsi_read_capacity_16(&ccb->csio, /*retries*/ retry_count, /*cbfcnp*/ NULL, @@ -9017,7 +9025,7 @@ usage(int printlong) " camcontrol identify [dev_id][generic args] [-v]\n" " camcontrol reportluns [dev_id][generic args] [-c] [-l] [-r report]\n" " camcontrol readcap [dev_id][generic args] [-b] [-h] [-H] [-N]\n" -" [-q] [-s]\n" +" [-q] [-s] [-l]\n" " camcontrol start [dev_id][generic args]\n" " camcontrol stop [dev_id][generic args]\n" " camcontrol load [dev_id][generic args]\n"