From owner-freebsd-hackers@FreeBSD.ORG Thu May 21 18:54:31 2015 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E14D766C for ; Thu, 21 May 2015 18:54:31 +0000 (UTC) Received: from mail-pa0-f48.google.com (mail-pa0-f48.google.com [209.85.220.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B4B2B1840 for ; Thu, 21 May 2015 18:54:31 +0000 (UTC) Received: by pabts4 with SMTP id ts4so114251638pab.3 for ; Thu, 21 May 2015 11:54:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:mime-version:content-type:from :in-reply-to:date:cc:message-id:references:to; bh=FpmoRgyTX+HL5R4TROAsAaDg4N7UeLu2g5kwoXZVVMI=; b=CQWy2niGDwv2nHLfa9q+K8e5+dz0HVQMR3hJyFToDPyAeENupjkaNbS+BiAXrqW7LD qFs3UNGezvrAEgEh4YlYYaaT1uu6OhAZ08aKuqfSoH9tk0FfzqYmUgIkmw5C7z+1P6ii idIvpC78lHSH6VamJP3HnBDM/03xZoYeQVpDLgEafD0q4LvaMxlVsV/453GWsZYQwPwL SaTuMSlwrx2ft++cypZ0il29nzv81NjpunyvGg18bG3hIDADu7zJ1e9tEvQjiMUq86xe R41kgH6yTkfmzORaU3g02aBZ+mQ4vlYPBxjekHTzpvlli/9+CIb6hC1t8UmB/S8TeXww 0s9A== X-Gm-Message-State: ALoCoQkadTpPXGXEg9ShZ5KxMTY8xba9pSc1oX5bl41RRP3yHxuJKIoStrPdU97f3bXzbv4mSFES X-Received: by 10.68.57.142 with SMTP id i14mr8230426pbq.135.1432234465373; Thu, 21 May 2015 11:54:25 -0700 (PDT) Received: from [10.64.24.126] ([69.53.236.236]) by mx.google.com with ESMTPSA id do16sm20037568pac.15.2015.05.21.11.54.23 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 21 May 2015 11:54:24 -0700 (PDT) Sender: Warner Losh Subject: Re: Botched NCQ on SSD - cannot disable? Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) Content-Type: multipart/signed; boundary="Apple-Mail=_F796935C-00AE-4B10-81D6-6CC27AFD50C4"; protocol="application/pgp-signature"; micalg=pgp-sha512 X-Pgp-Agent: GPGMail 2.5b6 From: Warner Losh In-Reply-To: Date: Thu, 21 May 2015 12:54:21 -0600 Cc: hackers@freebsd.org, mav@freebsd.org, imp@freebsd.org Message-Id: <8EDE2E6C-FED8-498B-9211-E3534A28D2FC@bsdimp.com> References: To: Neffi X-Mailer: Apple Mail (2.2098) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 May 2015 18:54:32 -0000 --Apple-Mail=_F796935C-00AE-4B10-81D6-6CC27AFD50C4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On May 21, 2015, at 12:42 PM, Neffi wrote: >=20 > I was discussing this issue in freenode/#freebsd and I was recommended = to shoot an email to you fellows about it. >=20 > I've got an Samsung 840 EVO SSD (model MZ-7TE250BW), which uses = Samsung's own controller from what I can gather. I had issues of mass = data corruption when used under Linux, and several programs crashing = unexpectedly when used under FreeBSD. I've gone through 2 drives under = warranty with the same issue before customer service suggested to = disable drive queuing. >=20 > After some research it seems as though this drive (and several other = common SSDs) report that they support NCQ, but in fact are botched and = will have all sorts of problems with NCQ enabled ranging from poor = performance, to I/O stalls to data corruption. >=20 > Sure enough the logs on Linux spit out something along the lines of: >=20 > > ata1: exception Emask 0x0 SAct 0xf SErr 0x0 action 0x10 frozen > > ata1.00: failed command: READ FPDMA QUEUED >=20 > This happens several times when used on Linux, in the few hours = leading up to total filesystem corruption. >=20 > The recommendation in the Linux world is to disable NCQ on these = drives, for which there is an easy boot-time tunable for it. This fixes = the issue. No more data corruption. >=20 > There doesn't seem to be a tunable for this anywhere on FreeBSD. = camcontrol(8) mentions setting the tags used, but only between some = hardcoded limits, with a default of 2 -- not sufficient to disable NCQ = on the drive. It looks like presently the only option is to manually = patch the quirks for this drive in the kernel and recompile before I can = even install the system to the drive. One option is to use drives that don=E2=80=99t suck so bad. If you are using the AHCI controller, it has quirks for some cards that = don=E2=80=99t properly fill in the NCQ tags, but so far that=E2=80=99s a = tiny list of mostly older gear. What=E2=80=99s the host controller you = are using. Also, just because the command that hung on the drive is an NCQ command, = that doesn=E2=80=99t mean disabling NCQ commands will keep you safe. = That=E2=80=99s just the first one that=E2=80=99s issued after the = firmware wedges (or could be: that=E2=80=99s a very common scenario for = this kind of failure mode). There=E2=80=99s a quirk for the 840 EVO, but that=E2=80=99s just to = force 4k sector size. While I haven=E2=80=99t used this generation of Samsung SSDs, I=E2=80=99d = be highly surprised if this issue was really a problem in the drive = instead of some cabling issue, or other environmental issue leading the = the wedge. It=E2=80=99s true there=E2=80=99s no way to totally disable NCQ, but if = the drive is hanging with NCQ depth of 2, I=E2=80=99d be highly = surprised if it is actually NCQ causing this... Warner --Apple-Mail=_F796935C-00AE-4B10-81D6-6CC27AFD50C4 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJVXindAAoJEGwc0Sh9sBEA3HoP/3NlsC66V2bPHoi+4GaxMi47 U+fsZ74aHCWi9MBShldNCYrM3umKDj126sMNSoAZaR1/Bd5y3vF55b+wHnd+Oc2P 7+mck+3PuexqtCq9lxhqPWpM5fIZ+3t/QfQus4qHbgBjajFIX+F21vqulC0BuE/m 5vw/QBKZ3hqaHZH7mHaY83vlNwzxpY0z5UHW8B2JFTJuVU7ixu2D9b6WcFM0Dd8a 92v4MeA47Hr6H3Kv9QzfprKs7MYV8Q67AM5qvZDitHIkFzwg8dFlSVe1KZCbyQox 7ia8JfnVhj8hPJlycC9Cc2xH78VJDML6yK9HruNuwy6TBobz6PgnYk7e1T5Kj62Y yk5IH2dQxdevMGZLNrl0SpuRzszJm6ukZOgmsrENC81wJ/EpiVuVYaBlWV7jLaxU NTtL2n7/MSVecHKi7MqgoHDg/JjpUmUnCiRitY77LiQSc/oA2cnVJREQtT1mMSWM NweaQsiJwNdjs2k1XUArop2mj+2PJSg8Zqzm5djq35F9iuRnXIX9WcgUvlvVWgLr BspdwtX1aaNDt9HRyrGFjBxrd19n2K4GsswCFNRzTy/18HQHhOuVRgUT6ai+8neK kYGgU1gvKQMe30/QMbBbpruJfMDyVgFayq862L74zjeqr956PpAar/nE61JNuId9 pwm9TfQIcUsV6yk7NPXB =BdTp -----END PGP SIGNATURE----- --Apple-Mail=_F796935C-00AE-4B10-81D6-6CC27AFD50C4--