Date: Fri, 4 Sep 2009 22:17:31 GMT From: Brad Huntting <huntting@glarp.com> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/138540: sysutils/smartmontools Message-ID: <200909042217.n84MHVi4089170@www.freebsd.org> Resent-Message-ID: <200909042220.n84MK1vu023820@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 138540 >Category: ports >Synopsis: sysutils/smartmontools >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Sep 04 22:20:00 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Brad Huntting >Release: 7.2-PRERELEASE >Organization: >Environment: FreeBSD PharLap-00005045b076 7.2-PRERELEASE FreeBSD 7.2-PRERELEASE #0: Mon Aug 31 14:58:08 MDT 2009 * amd64 >Description: smartctl likes to read SMART data into 512 byte buffers which it allocates on the stack. While this _should_ work just fine, I have found that sometimes, when using SATA over SAS (-d sat) with an MPT Fusion HBA, smartctl's buffer gets broken into 2 Scatter Gather Elements (probably because the 512 byte buffer stradles a page boundary). Sometimes, only the first of these gets filled before the mpt driver records a timeout and subsequently resets the SAS bus. I have not fully diagnosed the problem or had time to write a sample code'let that can reproduce it. But in the mean time, this patch moves the data buffer from the stack to the heap where it will be aligned to avoid a page boundary. Hopefully I will have time to diagnose the real problem and either fix it (if it's in the driver) or send in a bug report to LSI (if it's in the MPT controller). thanx, brad >How-To-Repeat: pray. Then on a 64bit system, with an 8gig LSI MPT SAS controler Mpi Version 1.5.20.0 FWVersion 1.28.0.0 or FWVersion 1.28.2.0 connected to a SATA drive, turn on all available debugging in CAM and the MPT driver. run smartctl -d sat -r ioctl -a /dev/da<foo> sometimes, if you're 'lucky', you'll see a bus reset, and smartcl will fail to get some of it's SMART data. >Fix: Attached is a patch to the port that adds a patch that makes shure the data buffers used to read smart attributes and logs do not straddle page boundaries. Patch attached with submission follows: diff -Nru /usr/ports/sysutils/smartmontools/Makefile /home/huntting/src/Copan/smartmontools/Makefile --- /usr/ports/sysutils/smartmontools/Makefile 2009-07-08 13:56:07.000000000 -0600 +++ /home/huntting/src/Copan/smartmontools/Makefile 2009-09-04 14:58:21.000000000 -0600 @@ -25,7 +25,7 @@ MAN5= smartd.conf.5 MAN8= smartd.8 smartctl.8 -CFLAGS:= ${CFLAGS:S/-O2/-O/} +CFLAGS:= ${CFLAGS:S/-O2/-O/} -Wno-write-strings post-patch: @${REINPLACE_CMD} -e 's| install-initdDATA | |' ${WRKSRC}/Makefile.in diff -Nru /usr/ports/sysutils/smartmontools/files/patch-scsiata.cpp /home/huntting/src/Copan/smartmontools/files/patch-scsiata.cpp --- /usr/ports/sysutils/smartmontools/files/patch-scsiata.cpp 1969-12-31 17:00:00.000000000 -0700 +++ /home/huntting/src/Copan/smartmontools/files/patch-scsiata.cpp 2009-09-04 14:28:13.000000000 -0600 @@ -0,0 +1,22 @@ +--- scsiata.cpp.orig 2007-12-02 19:14:20.000000000 -0700 ++++ scsiata.cpp 2009-09-04 14:27:48.000000000 -0600 +@@ -380,14 +380,14 @@ + return 1, else 0 */ + int has_sat_pass_through(int device, int packet_interface) + { +- char data[512]; ++ int ret; ++ char *data = (char *)malloc(512); // (alignment) + smart_command_set command; + + command = packet_interface ? PIDENTIFY : IDENTIFY; +- if (0 == sat_command_interface(device, command, 0, data)) +- return 1; +- else +- return 0; ++ ret = ( 0 == sat_command_interface(device, command, 0, data) ? 1 : 0 ); ++ free(data); ++ return ret; + } + + /* Next two functions are borrowed from sg_lib.c in the sg3_utils >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200909042217.n84MHVi4089170>