Bug 188685 - [cam] [patch] QUIRK: Add 4K quirks for WD Red and Black MHDDs
Summary: [cam] [patch] QUIRK: Add 4K quirks for WD Red and Black MHDDs
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 9.2-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Eitan Adler
Keywords: easy, patch
Depends on:
Reported: 2014-04-16 10:20 UTC by Jeremy Chadwick
Modified: 2019-08-08 17:31 UTC (History)
1 user (show)

See Also:
eadler: mfc-stable11?
eadler: mfc-stable10-
eadler: mfc-stable9-
eadler: mfc-stable8-

file.diff (1.08 KB, patch)
2014-04-16 10:20 UTC, Jeremy Chadwick
no flags Details | Diff
Updated diff for 4K quirks (fix for WDxxxxFAEX series) (722 bytes, patch)
2016-04-06 13:44 UTC, Jeremy Chadwick
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Chadwick 2014-04-16 10:20:00 UTC
	Add some 4K quirks for the following Western Digital Caviar MHDDs:

	- WD Black, 4000GB, WD4003FZEX
	- WD Black, 3000GB, WD3003FZEX
	- WD Black, 2000GB, WD2003FZEX
	- WD Black, 1000GB, WD1003FZEX
	- WD Black,  500GB, WD5003AZEX (yes this really does use 4K physical)
	- WD Black, 2000GB, WD2002FAEX
	- WD Black, 1000GB, WD1002FAEX
	- WD Black, 4000GB, WD4001FAEX
	- WD Black, 3000GB, WD3001FAEX
	- WD Black, 2000GB, WD2001FAEX
	- WD Black, 1000GB, WD1001FAEX
	- WD Red,    750GB, WD7500BFCX (yes this really does use 4K physical)
	- WD Red,   1000GB, WD10JFCX

	Also add a comment reflecting that WD????RX also matches some models
	of Red drives (not listed above) and not just Green.

Fix: Apply below patch.

How-To-Repeat: 	n/a
Comment 1 Jeremy Chadwick 2014-04-16 10:21:43 UTC
Patch available here:


| Jeremy Chadwick                                   jdc@koitsu.org |
| UNIX Systems Administrator                http://jdc.koitsu.org/ |
| Making life hard for others since 1977.             PGP 4BD6C0CB |
Comment 2 commit-hook freebsd_committer 2015-03-30 09:05:33 UTC
A commit references this bug:

Author: eadler
Date: Mon Mar 30 09:05:21 UTC 2015
New revision: 280845
URL: https://svnweb.freebsd.org/changeset/base/280845

  Add some additional quirks for various Western Digital Caviar MHDDs

  Submitted by:	Jeremy Chadwick
  PR:		188685
  MFC After:	1 month

Comment 3 Glen Barber freebsd_committer 2015-07-08 18:32:01 UTC
To originators/assignees of this PR:

A commit to the tree references this PR, however the PR is still in a non-closed state.

Please review this PR and close as appropriate, or if closing the PR requires a merge to stable/10, please let re@ know as soon as possible.

Thank you.

Comment 4 Martin Birgmeier 2016-04-05 18:54:58 UTC
I just switched from ataahci to ahci and now see that WD2002FAEX is flagged with a 4K quirk.

I think this is wrong: Both camcontrol identify and smartctl -a report 512n sectors. What's more, the disk behaves like the other 512n disks I have in terms of write speed: WD2001FASS, WD2000FYYZ.

So I think that at least for the WD2002FAEX, the 4k quirk should be removed.

-- Martin
Comment 5 Jeremy Chadwick 2016-04-06 01:08:52 UTC
As someone who has used WD2002FAEX disks, I can assure you the 4K quirk is not related to your problem.  Much more likely is the possibility that your filesystem(s) are not 4K-aligned, so the write I/O performance would be abysmal.  Another possibility is the drive is actually going bad or has some actual issue.

There's no actual difference between a WD2002FAEX and, say, a WD3003FZEX in terms of sector size.

Now let's talk about the userland utilities.

Recent (past 3-4 years) smartctl -a will show two sector sizes: logical and physical.  On WD2002FAEX drives, the result should be 512 logical, 4096 physical.  This information is obtained directly from the ATA IDENTIFY command (i.e. the disk says this, FreeBSD does not tinker with it).

Recent (past 3-4 years) camcontrol identify should do the exact same: display both logical and physical sector size, and the data comes from the ATA IDENTIFY command like above.

I strongly maintain that removal of the 4K quirk for WD2002FAEX is incorrect.
Comment 6 Martin Birgmeier 2016-04-06 10:32:51 UTC
I probably did not word this clearly enough... there is no problem except that with the new ahci driver I noticed the 4k quirk for the WD2002FAEX.

But my WD2002FAEX performance-wise behaves like the other five disks in the raidz2 array which consists of 3 x WD2001FASS, 2 x WD2000FYYZ, and this single WD2002FAEX. Which is to say it does not exhibit longer read or write times (gstat) than the other five.

So since these other five disks are 512n, and the WD2002FAEX behaves like them, I thought it is also 512n. And also camcontrol and smartctl say so (but maybe I have to have another look to see whether this has changed with a newer release of the two).

But maybe the performance is the same because zfs does > 4k writes only. And of course I have aligned my zfs gparts on (big) boundaries.

In that case of course my assumption might be wrong.

-- Martin
Comment 7 Martin Birgmeier 2016-04-06 11:34:14 UTC
I should add that my zfs ashift = 9. But still the partitions are aligned to 4k.
Comment 8 Jeremy Chadwick 2016-04-06 12:27:09 UTC
I had a chance to review this more in depth.  I now see the issue, and I apologise for my confusion.

It's possible that the drives I tested of this capacity were WD2003FZEX (which is definitely 512 logical 4096 physical, 100% confirmed), not WD2002FAEX.  Apparently the two models differ in several regards, but I can't find anything technically definitive; WDC's PDF on this model series is ambiguous.

Could you please provide output from "camcontrol identify" against the WD2002FAEX drive you have?  "smartctl -a" would also be useful.  You can XXX-out the WWN and/or serial numbers if you wish, but please retain all other data.

camcontrol identify was extended to display sector sizes (both logical and physical) back in November 2009: https://svnweb.freebsd.org/base?view=revision&revision=198897 -- the data shown comes directly from the drive.

smartctl was extended to support display of sector sizes (both logical and physical), if my memory serves me right, with the release of 5.41.

If your output shows 512 physical, then yes, the 4K quirk is incorrect and I'll submit a regression patch to have that model removed from the 4K quirk list; I'll also track down (possibly purchase) some drives in the *2FAEX series (there are a few) to determine what their physical sector sizes are, to double-verify some of the quirks.

As for your ashift=9, I would suggest moving to ashift=12 anyway (there's no harm in this on 512 physical sector size drives).  Recent-ish FreeBSD ZFS supports this via sysctl vfs.zfs.min_auto_ashift=12 (or if your FreeBSD doesn't support that, you'll need to use the gnop method).  The pools would need to be created.  I cannot comment on pools whose data sources are partitions (a la GPT); I only have experience with ZFS using raw drives.
Comment 9 Jeremy Chadwick 2016-04-06 13:17:53 UTC
I've managed to determine that there are a few drives in this quirk list that *are not* 4096-byte physical sector drives. The confusion can be attributed to a combination of user error (easy to mix up model numbers) as well as (at the time) WDC's site pointing to PDFs that contained wrong specifications (often spec for successor models).  Details:

- WD Black, 4000GB, WD4003FZEX -- 512 bytes logical, 4096 bytes physical
- WD Black, 3000GB, WD3003FZEX -- 512 bytes logical, 4096 bytes physical
- WD Black, 2000GB, WD2003FZEX -- 512 bytes logical, 4096 bytes physical
- WD Black, 1000GB, WD1003FZEX -- 512 bytes logical, 4096 bytes physical
- WD Black,  500GB, WD5003AZEX -- 512 bytes logical, 4096 bytes physical
- WD Black, 2000GB, WD2002FAEX -- 512 bytes logical/physical
- WD Black, 1000GB, WD1002FAEX -- 512 bytes logical/physical
- WD Black, 4000GB, WD4001FAEX -- 512 bytes logical/physical
- WD Black, 3000GB, WD3001FAEX -- 512 bytes logical/physical
- WD Black, 2000GB, WD2001FAEX -- unverified (likely 512 l/p)
- WD Black, 1000GB, WD1001FAEX -- unverified (likely 512 l/p)
- WD Red,    750GB, WD7500BFCX -- WDC 2879-800001.pdf states 4096 physical
- WD Red,   1000GB, WD10JFCX   -- WDC 2879-800001.pdf states 4096 physical

The two marked "unverified" are models I cannot definitively determine the sector sizes as of this writing.  Seems I'll need to find people with these drives or purchase them myself.  But odds are, given that other larger-capacity models in the same WDx001FAEX "series" are 512, these are too.

I'll be submitting a regression patch that removes the 6 models in question from the 4K quirks list.
Comment 10 Jeremy Chadwick 2016-04-06 13:44:59 UTC
Created attachment 169035 [details]
Updated diff for 4K quirks (fix for WDxxxxFAEX series)

Patch is for stable/10 (svn).  Description:

r280845 incorrectly enabled 4K quirks for WDxxxxFAEX models (which are 512b physical sector drives).  Only enable 4K quirks for the WDxxxxAZEX and WDxxxxFZEX models.
Comment 11 Martin Birgmeier 2016-11-03 19:10:14 UTC
The latest patch seems to be o.k. as far as my setup is concerned, so if it has been applied to all relevant branches the issue could most likely be closed.

-- Martin
Comment 12 commit-hook freebsd_committer 2018-01-05 07:15:16 UTC
A commit references this bug:

Author: eadler
Date: Fri Jan  5 07:14:39 UTC 2018
New revision: 327577
URL: https://svnweb.freebsd.org/changeset/base/327577

  cam/da: QUIRK: Add 4K quirks for WD Red and Black MHDDs

  PR:		188685
  Submitted by:	Jeremy Chadwick <jdc@koitsu.org>
  Reported by:	Martin Birgmeier <d8zNeCFG@aon.at>

Comment 13 commit-hook freebsd_committer 2019-08-08 17:31:05 UTC
A commit references this bug:

Author: mav
Date: Thu Aug  8 17:30:51 UTC 2019
New revision: 350763
URL: https://svnweb.freebsd.org/changeset/base/350763

  MFC r327577 (by eadler):
  cam/da: QUIRK: Add 4K quirks for WD Red and Black MHDDs

  PR:             188685

_U  stable/11/