root@pts/0#camcontrol devlist <HL-DT-ST DVDRAM GSA-H42N RL00> at scbus0 target 0 lun 0 (cd0,pass0) <ModusLnk > at scbus10 target 0 lun 0 (da0,pass1) <ModusLnk > at scbus10 target 1 lun 0 (da1,pass2) <ModusLnk > at scbus10 target 2 lun 0 (da2,pass3) <ModusLnk > at scbus10 target 3 lun 0 (da3,pass4) <ModusLnk > at scbus11 target 1 lun 0 (da4,pass5) <ModusLnk > at scbus11 target 2 lun 0 (da5,pass6) <ModusLnk > at scbus11 target 3 lun 0 (da6,pass7) root@pts/0#smartctl -a /dev/da0 -d scsi smartctl 6.2 2013-07-26 r3841 [FreeBSD 9.2-PRERELEASE i386] (local build) Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org Segmentation fault (core dumped) How-To-Repeat: installport on a system with scsi discs. use smartctl to check health of an scsi disc.
Maintainer of sysutils/smartmontools, Please note that PR ports/181836 has just been submitted. If it contains a patch for an upgrade, an enhancement or a bug fix you agree on, reply to this email stating that you approve the patch and a committer will take care of it. The full text of the PR can be found at: http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/181836 -- Edwin Groothuis via the GNATS Auto Assign Tool edwin@FreeBSD.org
State Changed From-To: open->feedback Awaiting maintainers feedback (via the GNATS Auto Assign Tool)
I was able to catch this bug and [probably] fix it. Could you please try this patch (or latest svn version) and tell me if it works for you?
Hello, I got email feedback that provided patch is soving the problem. Please add it to the port, or let me know if i need to open new PR for this. Thanks.
State Changed From-To: feedback->open Maintainer approved.
Responsible Changed From-To: freebsd-ports-bugs->tijl Take.
Hi Alex, I'm looking into your patch for ports/181836: http://www.freebsd.org/cgi/query-pr.cgi?pr=181836 I think this part is not correct: - if (((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) && ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_SCSI_STATUS_ERROR)) { + if (((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) && ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR)) { (ccb->ccb_h.status & CAM_STATUS_MASK) is a status code. If it is equal to CAM_SCSI_STATUS_ERROR it can't be equal to CAM_REQ_CMP. I did some digging into the history of this file. The second part with CAM_SCSI_STATUS_ERROR has been added in this revision: http://sourceforge.net/p/smartmontools/code/2893/ Maybe you can remember why? I think the line from before that revision is the correct one, so: - if (((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) && ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_SCSI_STATUS_ERROR)) { + if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { I've attached a new patch for the port. It also converts the port to support staging. Can you test/review/approve it? Thanks, Tijl
On Fri, 3 Jan 2014 10:35:08 +0100 Tijl Coosemans wrote: > On Thu, 26 Dec 2013 17:21:05 +0100 Tijl Coosemans wrote: >> On Thu, 26 Dec 2013 08:53:57 +0100 Alex Samorukov wrote: >>> On 12/25/2013 09:27 PM, Tijl Coosemans wrote: >>>> I'm looking into your patch for ports/181836: >>>> http://www.freebsd.org/cgi/query-pr.cgi?pr=181836 >>>> >>>> I think this part is not correct: >>>> >>>> - if (((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) && ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_SCSI_STATUS_ERROR)) { >>>> + if (((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) && ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR)) { >>> >>> Thank you for feedback. You are correct, i think it needs to be splitted >>> by 2 checks. >>> >>> First one will check for CAM_SCSI_STATUS_ERROR and print CAM debug error >>> information and free CCB. Second check needs to be generic, w/o >>> debugging information printing. >> >> Does the second check also free CCB? >> >>>> (ccb->ccb_h.status & CAM_STATUS_MASK) is a status code. If it is equal >>>> to CAM_SCSI_STATUS_ERROR it can't be equal to CAM_REQ_CMP. >>>> >>>> I did some digging into the history of this file. The second part with >>>> CAM_SCSI_STATUS_ERROR has been added in this revision: >>>> http://sourceforge.net/p/smartmontools/code/2893/ >>>> >>>> Maybe you can remember why? >>> >>> I am agree that line is bogus, but original intent was to handle SCSI >>> CAM errors as well. >>> >>>> I think the line from before that revision is the correct one, so: >>>> >>>> - if (((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) && ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_SCSI_STATUS_ERROR)) { >>>> + if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { >>> >>> I think this will cause crash if STATUS_MASK is CAM_SCSI_STATUS_ERROR. >>> This could happens if older drive do not support some commands. >> >> If the status code is CAM_SCSI_STATUS_ERROR it is != CAM_REQ_CMP and >> the ccb is released. That's correct isn't it? It's what your original >> patch for this PR does. > > Have you had a chance to look into this? And another week went by... Can you please look into this? The only change I'm worried about in your original patch is this: - if (((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) && ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_SCSI_STATUS_ERROR)) { + if (((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) && ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR)) { If ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR) is true then ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) is always true. It makes no sense to test both. The condition must either be this: if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { Like it is everywhere else in the source code and like it used to be in an older version. Or it must be this: if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR) { Please pick one.
On Fri, 10 Jan 2014 11:23:13 +0100 =C5=81ukasz W=C4=85sikowski wrote: > W dniu 2013-12-20 17:00, tijl@FreeBSD.org pisze: >> http://www.freebsd.org/cgi/query-pr.cgi?pr=3D181836 >=20 > Tijl, your patch works for me, can you commit it? Thanks for testing it. I'm still hoping to get maintainer approval.
Author: tijl Date: Fri Jan 17 09:31:42 2014 New Revision: 340020 URL: http://svnweb.freebsd.org/changeset/ports/340020 QAT: https://qat.redports.org/buildarchive/r340020/ Log: - Fix a crash with some SCSI disks. - Add DOCS option and use option helpers. - USES=gmake. - Staging. - Remove CFLAGS left from old versions. PR: ports/181836 Approved by: maintainer timeout (3 weeks) Added: head/sysutils/smartmontools/files/patch-os_freebsd.cpp (contents, props changed) Modified: head/sysutils/smartmontools/Makefile head/sysutils/smartmontools/pkg-plist Modified: head/sysutils/smartmontools/Makefile ============================================================================== --- head/sysutils/smartmontools/Makefile Fri Jan 17 09:18:48 2014 (r340019) +++ head/sysutils/smartmontools/Makefile Fri Jan 17 09:31:42 2014 (r340020) @@ -3,6 +3,7 @@ PORTNAME= smartmontools PORTVERSION= 6.2 +PORTREVISION= 1 CATEGORIES= sysutils MASTER_SITES= SF @@ -13,7 +14,11 @@ LICENSE= GPLv2 CONFLICTS= smartmontools-devel-[0-9]* -USE_GMAKE= yes +OPTIONS_DEFINE= DOCS +DOCS_CONFIGURE_OFF= --without-docdir --without-exampledir +DOCS_CONFIGURE_ON= --with-docdir=${DOCSDIR} + +USES= gmake GNU_CONFIGURE= yes CONFIGURE_ARGS= --disable-dependency-tracking \ --enable-drivedb --enable-sample \ @@ -22,29 +27,14 @@ CONFIGURE_ARGS= --disable-dependency-tra SUB_FILES= pkg-message smart USE_RC_SUBR= smartd -MAN5= smartd.conf.5 -MAN8= smartd.8 smartctl.8 - PORTDOCS= * -NO_STAGE= yes -.include <bsd.port.options.mk> - -.if ! ${PORT_OPTIONS:MDOCS} -CONFIGURE_ARGS+= --without-docdir --without-exampledir -.else -CONFIGURE_ARGS+= --with-docdir=${DOCSDIR} -.endif - -CFLAGS:= ${CFLAGS:S/-O2/-O/} -Wno-write-strings - post-patch: @${REINPLACE_CMD} -e 's| install-initdDATA| |' ${WRKSRC}/Makefile.in post-install: - ${MKDIR} ${PREFIX}/etc/periodic/daily - ${INSTALL_SCRIPT} ${WRKDIR}/smart ${PREFIX}/etc/periodic/daily/smart - - @${CAT} ${PKGMESSAGE} + ${MKDIR} ${STAGEDIR}${PREFIX}/etc/periodic/daily + ${INSTALL_SCRIPT} ${WRKDIR}/smart \ + ${STAGEDIR}${PREFIX}/etc/periodic/daily .include <bsd.port.mk> Added: head/sysutils/smartmontools/files/patch-os_freebsd.cpp ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/smartmontools/files/patch-os_freebsd.cpp Fri Jan 17 09:31:42 2014 (r340020) @@ -0,0 +1,31 @@ +--- os_freebsd.cpp.orig 2013-07-05 12:40:38.000000000 +0200 ++++ os_freebsd.cpp 2013-12-25 20:54:46.000000000 +0100 +@@ -445,7 +445,8 @@ + } + + if ((ccb.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { +- cam_error_print(m_camdev, &ccb, CAM_ESF_ALL, CAM_EPF_ALL, stderr); ++ if(scsi_debugmode > 0) ++ cam_error_print(m_camdev, &ccb, CAM_ESF_ALL, CAM_EPF_ALL, stderr); + set_err(EIO); + return -1; + } +@@ -997,13 +998,15 @@ + + if (cam_send_ccb(m_camdev,ccb) < 0) { + warn("error sending SCSI ccb"); +- cam_error_print(m_camdev,ccb,CAM_ESF_ALL,CAM_EPF_ALL,stderr); ++ if (report > 0) ++ cam_error_print(m_camdev,ccb,CAM_ESF_ALL,CAM_EPF_ALL,stderr); + cam_freeccb(ccb); + return -EIO; + } + +- if (((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) && ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_SCSI_STATUS_ERROR)) { +- cam_error_print(m_camdev,ccb,CAM_ESF_ALL,CAM_EPF_ALL,stderr); ++ if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { ++ if(report > 0) ++ cam_error_print(m_camdev,ccb,CAM_ESF_ALL,CAM_EPF_ALL,stderr); + cam_freeccb(ccb); + return -EIO; + } Modified: head/sysutils/smartmontools/pkg-plist ============================================================================== --- head/sysutils/smartmontools/pkg-plist Fri Jan 17 09:18:48 2014 (r340019) +++ head/sysutils/smartmontools/pkg-plist Fri Jan 17 09:31:42 2014 (r340020) @@ -1,7 +1,9 @@ -@stopdaemon smartd etc/periodic/daily/smart etc/smartd.conf.sample etc/smartd_warning.sh +man/man5/smartd.conf.5.gz +man/man8/smartd.8.gz +man/man8/smartctl.8.gz sbin/smartctl sbin/smartd sbin/update-smart-drivedb _______________________________________________ svn-ports-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-ports-all To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
State Changed From-To: open->closed Committed in r340020.
Hello This patch broke support for [at least] SATA disks on an LSI SAS controller. The particular change in question is this: @@ -1004,7 +1004,7 @@ return -EIO; } - if (((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) && ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_SCSI_STATUS_ERROR)) { + if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { if(report > 0) cam_error_print(m_camdev,ccb,CAM_ESF_ALL,CAM_EPF_ALL,stderr); cam_freeccb(ccb); With that in place, 'smartctl -H -r ioctl /dev/da0' shows this failure: REPORT-IOCTL: Device=/dev/da0 Command=SMART STATUS CHECK Input: FR=0xda, SC=...., LL=...., LM=0x4f, LH=0xc2, DEV=...., CMD=0xb0 [ata pass-through(16): 85 06 2c 00 da 00 00 00 00 00 4f 00 c2 00 b0 00 ](pass1:mpt0:0:0:0): ATA COMMAND PASS THROUGH(16). CDB: 85 06 2c 00 da 00 00 00 00 00 4f 00 c2 00 b0 00 (pass1:mpt0:0:0:0): CAM status: SCSI Status Error (pass1:mpt0:0:0:0): SCSI status: Check Condition (pass1:mpt0:0:0:0): SCSI sense: RECOVERED ERROR asc:0,1d (ATA pass through information available) (pass1:mpt0:0:0:0): Descriptor 0x9: 00 00 00 00 00 00 00 4f 00 c2 00 50 [Duration: 0.064s] SMART STATUS RETURN: incomplete response, ATA output registers missing REPORT-IOCTL: Device=/dev/da0 Command=SMART STATUS CHECK returned -1 errno=78 [Function not implemented] SMART overall-health self-assessment test result: PASSED Warning: This result is based on an Attribute check. With that reverted, I get the expected response: REPORT-IOCTL: Device=/dev/da0 Command=SMART STATUS CHECK Input: FR=0xda, SC=...., LL=...., LM=0x4f, LH=0xc2, DEV=...., CMD=0xb0 [ata pass-through(16): 85 06 2c 00 da 00 00 00 00 00 4f 00 c2 00 b0 00 ] status=0 Incoming data, len=0: [Duration: 0.068s] Output: ERR=0x00, SC=0x00, LL=0x00, LM=0x4f, LH=0xc2, DEV=0x00, STS=0x50 REPORT-IOCTL: Device=/dev/da0 Command=SMART STATUS CHECK returned 0 SMART overall-health self-assessment test result: PASSED I have the following controller and drives: # mptutil show adapter mpt0 Adapter: Board Name: SAS3081E Board Assembly: L3-00159-02D Chip Name: C1068E Chip Revision: UNUSED RAID Levels: none # mptutil show drives mpt0 Physical Drives: da0 ( 1863G) ONLINE <WDC WD2002FAEX-0 1D05> SATA bus 0 id 0 da1 ( 1863G) ONLINE <WDC WD2002FAEX-0 1D05> SATA bus 0 id 1 da2 ( 1863G) ONLINE <WDC WD2002FAEX-0 1D05> SATA bus 0 id 2 da3 ( 1863G) ONLINE <WDC WD2002FAEX-0 1D05> SATA bus 0 id 3 da4 ( 1863G) ONLINE <WDC WD2002FAEX-0 1D05> SATA bus 0 id 4 da5 ( 1863G) ONLINE <WDC WD2002FAEX-0 1D05> SATA bus 0 id 5 da6 ( 1863G) ONLINE <WDC WD2002FAEX-0 1D05> SATA bus 0 id 6 da7 ( 1863G) ONLINE <WDC WD2002FAEX-0 1D05> SATA bus 0 id 7 # -- Hugo Lombard .___. (o,o) /) ) ---"-"---
On Sun, 16 Feb 2014 08:00:00 GMT Hugo Lombard wrote: > This patch broke support for [at least] SATA disks on an LSI SAS controller. Try the patch in http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/186095
On Sun, Feb 16, 2014 at 10:41:08AM +0100, Tijl Coosemans wrote: > > Try the patch in http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/186095 Does the trick: REPORT-IOCTL: Device=/dev/da0 Command=SMART STATUS CHECK Input: FR=0xda, SC=...., LL=...., LM=0x4f, LH=0xc2, DEV=...., CMD=0xb0 [ata pass-through(16): 85 06 2c 00 da 00 00 00 00 00 4f 00 c2 00 b0 00 ] CAM status=0x2, SCSI status=0x8c, resid=0x0 status=0x2: [desc] sense_key=0x1 asc=0x0 ascq=0x1d [Duration: 0.078s] Output: ERR=0x00, SC=0x00, LL=0x00, LM=0x4f, LH=0xc2, DEV=0x00, STS=0x50 REPORT-IOCTL: Device=/dev/da0 Command=SMART STATUS CHECK returned 0 SMART overall-health self-assessment test result: PASSED Thanks! -- Hugo Lombard .___. (o,o) /) ) ---"-"---
Author: tijl Date: Mon Mar 3 18:58:14 2014 New Revision: 346953 URL: http://svnweb.freebsd.org/changeset/ports/346953 QAT: https://qat.redports.org/buildarchive/r346953/ Log: Improve the FreeBSD SCSI and SAS support in smartmontools: - Remove unused private fields from some classes (found by Clang). - In freebsd_scsi_device::scsi_pass_through: * Make sure this function returns false on error instead of an error code that gets converted to true. * Put printing of the "Incoming data" debug info right after the cam_send_ccb() call and before the error checking to make debugging easier. * When copying sense data make sure the fields in the CCB are actually valid with CAM_AUTOSNS_VALID. Also make sure that the size of the sense data doesn't overflow max_sense_len. This was the real cause for the crash in ports/181836. * Add some debug printing on the sense data. Committed upstream as r3873. PR: ports/181836, ports/185960, ports/186095 Tested by: many Modified: head/sysutils/smartmontools/Makefile head/sysutils/smartmontools/files/patch-os_freebsd.cpp Modified: head/sysutils/smartmontools/Makefile ============================================================================== --- head/sysutils/smartmontools/Makefile Mon Mar 3 18:56:44 2014 (r346952) +++ head/sysutils/smartmontools/Makefile Mon Mar 3 18:58:14 2014 (r346953) @@ -3,7 +3,7 @@ PORTNAME= smartmontools PORTVERSION= 6.2 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= sysutils MASTER_SITES= SF Modified: head/sysutils/smartmontools/files/patch-os_freebsd.cpp ============================================================================== --- head/sysutils/smartmontools/files/patch-os_freebsd.cpp Mon Mar 3 18:56:44 2014 (r346952) +++ head/sysutils/smartmontools/files/patch-os_freebsd.cpp Mon Mar 3 18:58:14 2014 (r346953) @@ -1,6 +1,44 @@ --- os_freebsd.cpp.orig 2013-07-05 12:40:38.000000000 +0200 -+++ os_freebsd.cpp 2013-12-25 20:54:46.000000000 +0100 -@@ -445,7 +445,8 @@ ++++ os_freebsd.cpp 2014-03-03 19:16:11.000000000 +0100 +@@ -75,7 +75,7 @@ + #define PATHINQ_SETTINGS_SIZE 128 + #endif + +-const char *os_XXXX_c_cvsid="$Id: os_freebsd.cpp 3824 2013-07-05 10:40:38Z samm2 $" \ ++const char *os_XXXX_c_cvsid="$Id: os_freebsd.cpp 3874 2014-02-18 00:47:23Z samm2 $" \ + ATACMDS_H_CVSID CCISS_H_CVSID CONFIG_H_CVSID INT64_H_CVSID OS_FREEBSD_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID; + + #define NO_RETURN 0 +@@ -135,9 +135,9 @@ + : virtual public /*implements*/ smart_device + { + public: +- explicit freebsd_smart_device(const char * mode) ++ explicit freebsd_smart_device() + : smart_device(never_called), +- m_fd(-1), m_mode(mode) { } ++ m_fd(-1) { } + + virtual ~freebsd_smart_device() throw(); + +@@ -157,7 +157,6 @@ + + private: + int m_fd; ///< filedesc, -1 if not open. +- const char * m_mode; ///< Mode string for deviceopen(). + }; + + #ifdef __GLIBC__ +@@ -249,7 +248,7 @@ + + freebsd_ata_device::freebsd_ata_device(smart_interface * intf, const char * dev_name, const char * req_type) + : smart_device(intf, dev_name, "ata", req_type), +- freebsd_smart_device("ATA") ++ freebsd_smart_device() + { + } + +@@ -445,7 +444,8 @@ } if ((ccb.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { @@ -10,22 +48,230 @@ set_err(EIO); return -1; } -@@ -997,13 +998,15 @@ +@@ -489,10 +489,7 @@ + freebsd_escalade_device::freebsd_escalade_device(smart_interface * intf, const char * dev_name, + int escalade_type, int disknum) + : smart_device(intf, dev_name, "3ware", "3ware"), +- freebsd_smart_device( +- escalade_type==CONTROLLER_3WARE_9000_CHAR ? "ATA_3WARE_9000" : +- escalade_type==CONTROLLER_3WARE_678K_CHAR ? "ATA_3WARE_678K" : +- /* CONTROLLER_3WARE_678K */ "ATA" ), ++ freebsd_smart_device(), + m_escalade_type(escalade_type), m_disknum(disknum) + { + set_info().info_name = strprintf("%s [3ware_disk_%02d]", dev_name, disknum); +@@ -704,7 +701,7 @@ + freebsd_highpoint_device::freebsd_highpoint_device(smart_interface * intf, const char * dev_name, + unsigned char controller, unsigned char channel, unsigned char port) + : smart_device(intf, dev_name, "hpt", "hpt"), +- freebsd_smart_device("ATA") ++ freebsd_smart_device() + { + m_hpt_data[0] = controller; m_hpt_data[1] = channel; m_hpt_data[2] = port; + set_info().info_name = strprintf("%s [hpt_disk_%u/%u/%u]", dev_name, m_hpt_data[0], m_hpt_data[1], m_hpt_data[2]); +@@ -897,7 +894,6 @@ + virtual bool close(); + + private: +- int m_fd; + struct cam_device *m_camdev; + }; + +@@ -921,17 +917,16 @@ + freebsd_scsi_device::freebsd_scsi_device(smart_interface * intf, + const char * dev_name, const char * req_type) + : smart_device(intf, dev_name, "scsi", req_type), +- freebsd_smart_device("SCSI") ++ freebsd_smart_device() + { + } + + + bool freebsd_scsi_device::scsi_pass_through(scsi_cmnd_io * iop) + { +- int report=scsi_debugmode; + union ccb *ccb; + +- if (report > 0) { ++ if (scsi_debugmode) { + unsigned int k; + const unsigned char * ucp = iop->cmnd; + const char * np; +@@ -940,7 +935,7 @@ + pout(" [%s: ", np ? np : "<unknown opcode>"); + for (k = 0; k < iop->cmnd_len; ++k) + pout("%02x ", ucp[k]); +- if ((report > 1) && ++ if ((scsi_debugmode > 1) && + (DXFER_TO_DEVICE == iop->dxfer_dir) && (iop->dxferp)) { + int trunc = (iop->dxfer_len > 256) ? 1 : 0; + +@@ -949,18 +944,21 @@ + dStrHex(iop->dxferp, (trunc ? 256 : iop->dxfer_len) , 1); + } + else +- pout("]"); ++ pout("]\n"); + } + + if(m_camdev==NULL) { +- warnx("error: camdev=0!"); +- return -ENOTTY; ++ if (scsi_debugmode) ++ pout(" error: camdev=0!\n"); ++ return set_err(ENOTTY); + } + + if (!(ccb = cam_getccb(m_camdev))) { +- warnx("error allocating ccb"); +- return -ENOMEM; ++ if (scsi_debugmode) ++ pout(" error allocating ccb\n"); ++ return set_err(ENOMEM); + } ++ + // mfi SAT layer is known to be buggy + if(!strcmp("mfi",m_camdev->sim_name)) { + if (iop->cmnd[0] == SAT_ATA_PASSTHROUGH_12 || iop->cmnd[0] == SAT_ATA_PASSTHROUGH_16) { +@@ -984,8 +982,8 @@ + sizeof(struct ccb_scsiio) - sizeof(struct ccb_hdr)); + + cam_fill_csio(&ccb->csio, +- /*retrires*/ 1, +- /*cbfcnp*/ NULL, ++ /* retries */ 1, ++ /* cbfcnp */ NULL, + /* flags */ (iop->dxfer_dir == DXFER_NONE ? CAM_DIR_NONE :(iop->dxfer_dir == DXFER_FROM_DEVICE ? CAM_DIR_IN : CAM_DIR_OUT)), + /* tagaction */ MSG_SIMPLE_Q_TAG, + /* dataptr */ iop->dxferp, +@@ -996,44 +994,81 @@ + memcpy(ccb->csio.cdb_io.cdb_bytes,iop->cmnd,iop->cmnd_len); if (cam_send_ccb(m_camdev,ccb) < 0) { - warn("error sending SCSI ccb"); +- warn("error sending SCSI ccb"); - cam_error_print(m_camdev,ccb,CAM_ESF_ALL,CAM_EPF_ALL,stderr); -+ if (report > 0) ++ if (scsi_debugmode) { ++ pout(" error sending SCSI ccb\n"); + cam_error_print(m_camdev,ccb,CAM_ESF_ALL,CAM_EPF_ALL,stderr); ++ } cam_freeccb(ccb); - return -EIO; +- return -EIO; ++ return set_err(EIO); ++ } ++ ++ if (scsi_debugmode) { ++ pout(" CAM status=0x%x, SCSI status=0x%x, resid=0x%x\n", ++ ccb->ccb_h.status, ccb->csio.scsi_status, ccb->csio.resid); ++ if ((scsi_debugmode > 1) && (DXFER_FROM_DEVICE == iop->dxfer_dir)) { ++ int trunc, len; ++ ++ len = iop->dxfer_len - ccb->csio.resid; ++ trunc = (len > 256) ? 1 : 0; ++ if (len > 0) { ++ pout(" Incoming data, len=%d%s:\n", len, ++ (trunc ? " [only first 256 bytes shown]" : "")); ++ dStrHex(iop->dxferp, (trunc ? 256 : len), 1); ++ } ++ else ++ pout(" Incoming data trimmed to nothing by resid\n"); ++ } } -- if (((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) && ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_SCSI_STATUS_ERROR)) { + if (((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) && ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_SCSI_STATUS_ERROR)) { - cam_error_print(m_camdev,ccb,CAM_ESF_ALL,CAM_EPF_ALL,stderr); -+ if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { -+ if(report > 0) ++ if (scsi_debugmode) + cam_error_print(m_camdev,ccb,CAM_ESF_ALL,CAM_EPF_ALL,stderr); cam_freeccb(ccb); - return -EIO; +- return -EIO; ++ return set_err(EIO); + } + +- if (iop->sensep) { ++ iop->resid = ccb->csio.resid; ++ iop->scsi_status = ccb->csio.scsi_status; ++ if (iop->sensep && (ccb->ccb_h.status & CAM_AUTOSNS_VALID) != 0) { ++ if (scsi_debugmode) ++ pout(" sense_len=0x%x, sense_resid=0x%x\n", ++ ccb->csio.sense_len, ccb->csio.sense_resid); + iop->resp_sense_len = ccb->csio.sense_len - ccb->csio.sense_resid; +- memcpy(iop->sensep,&(ccb->csio.sense_data),iop->resp_sense_len); ++ /* Some SCSI controller device drivers miscalculate the sense_resid ++ field so cap resp_sense_len on max_sense_len. */ ++ if (iop->resp_sense_len > iop->max_sense_len) ++ iop->resp_sense_len = iop->max_sense_len; ++ if (iop->resp_sense_len > 0) { ++ memcpy(iop->sensep, &(ccb->csio.sense_data), iop->resp_sense_len); ++ if (scsi_debugmode) { ++ if (scsi_debugmode > 1) { ++ pout(" >>> Sense buffer, len=%zu:\n", iop->resp_sense_len); ++ dStrHex(iop->sensep, iop->resp_sense_len, 1); ++ } ++ if ((iop->sensep[0] & 0x7f) > 0x71) ++ pout(" status=0x%x: [desc] sense_key=0x%x asc=0x%x ascq=0x%x\n", ++ iop->scsi_status, iop->sensep[1] & 0xf, ++ iop->sensep[2], iop->sensep[3]); ++ else ++ pout(" status=0x%x: sense_key=0x%x asc=0x%x ascq=0x%x\n", ++ iop->scsi_status, iop->sensep[2] & 0xf, ++ iop->sensep[12], iop->sensep[13]); ++ } ++ } ++ else if (scsi_debugmode) ++ pout(" status=0x%x\n", iop->scsi_status); + } +- +- iop->scsi_status = ccb->csio.scsi_status; ++ else if (scsi_debugmode) ++ pout(" status=0x%x\n", iop->scsi_status); + + cam_freeccb(ccb); + +- if (report > 0) { +- int trunc; +- +- pout(" status=0\n"); +- trunc = (iop->dxfer_len > 256) ? 1 : 0; +- +- pout(" Incoming data, len=%d%s:\n", (int)iop->dxfer_len, +- (trunc ? " [only first 256 bytes shown]" : "")); +- dStrHex(iop->dxferp, (trunc ? 256 : iop->dxfer_len) , 1); +- } +- + // mfip replacing PDT of the device so response does not make a sense + // this sets PDT to 00h - direct-access block device + if((!strcmp("mfi", m_camdev->sim_name) || !strcmp("mpt", m_camdev->sim_name)) + && iop->cmnd[0] == INQUIRY) { +- if (report > 0) { +- pout("device on %s controller, patching PDT\n", m_camdev->sim_name); ++ if (scsi_debugmode) { ++ pout(" device on %s controller, patching PDT\n", m_camdev->sim_name); + } + iop->dxferp[0] = iop->dxferp[0] & 0xe0; } +@@ -1077,7 +1112,7 @@ + // Areca RAID Controller(SATA Disk) + freebsd_areca_ata_device::freebsd_areca_ata_device(smart_interface * intf, const char * dev_name, int disknum, int encnum) + : smart_device(intf, dev_name, "areca", "areca"), +- freebsd_smart_device("ATA") ++ freebsd_smart_device() + { + set_disknum(disknum); + set_encnum(encnum); +@@ -1146,7 +1181,7 @@ + // Areca RAID Controller(SAS Device) + freebsd_areca_scsi_device::freebsd_areca_scsi_device(smart_interface * intf, const char * dev_name, int disknum, int encnum) + : smart_device(intf, dev_name, "areca", "areca"), +- freebsd_smart_device("SCSI") ++ freebsd_smart_device() + { + set_disknum(disknum); + set_encnum(encnum); +@@ -1220,7 +1255,7 @@ + freebsd_cciss_device::freebsd_cciss_device(smart_interface * intf, + const char * dev_name, unsigned char disknum) + : smart_device(intf, dev_name, "cciss", "cciss"), +- freebsd_smart_device("SCSI"), ++ freebsd_smart_device(), + m_disknum(disknum) + { + set_info().info_name = strprintf("%s [cciss_disk_%02d]", dev_name, disknum); _______________________________________________ svn-ports-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-ports-all To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"