# TRIM ATA error via PCI SATA card



## lep (Jul 13, 2022)

I recently added two new *HDDs* to my server which required me to use a pci sata card. Now the disks seem to work fine, i can read and write data to it, zfs status/scrub says they're fine and so does smartmontools. However i get these errors

```
Jul 13 20:30:58 host kernel: (ada1:ata3:0:0:0): DSM TRIM. ACB: 06 01 00 00 00 40 00 00 00 00 01 00
Jul 13 20:30:58 host kernel: (ada1:ata3:0:0:0): CAM status: ATA Status Error
Jul 13 20:30:58 host kernel: (ada1:ata3:0:0:0): ATA status: 51 (DRDY SERV ERR), error: 04 (ABRT )
Jul 13 20:30:58 host kernel: (ada1:ata3:0:0:0): RES: 51 04 00 00 00 00 00 00 00 01 00
```
So the error seems to be that somewhere along the line something doesn't understand TRIM commands. The disks seem to do support TRIM.

```
TRIM Command:     Available, deterministic, zeroed
```
I tried multiple SATA cables so that should not be the cause.
But i basically have no idea about the stuff that is happening or how to debug it. Could it be a driver issue? Or is the pci card just bad? idk

Another question of mine is: how stupid would it be to either a) ignore this error as TRIM shouldn't be *too* important on HDDs (?!)
or b) disable zfs trim via `vfs.zfs.trim.enabled=0`.
*Assuming* (a) isn't totally stupid how would i disable the error reporting to not fill up my /var/log/messages?

I know that either of those are *not *correct things to do but I'm still curious.


For good measure:

```
$ uname -a
FreeBSD host 12.3-RELEASE-p5 FreeBSD 12.3-RELEASE-p5 GENERIC  amd64
```


----------



## Phishfry (Jul 13, 2022)

Can you show a dmesg snippet for the disk drives and controller.
Are they showing up as AHCI?


----------



## VladiBG (Jul 14, 2022)

HDD or SSD?
If HDD and it's with SMR you will have very bad write performance over time. It's better to use HDD with CMR like WD Gold or another server/enterprise disks.





						Windows & macOS: TRIM Command Support for SSD
					






					support-en.wd.com
				





> *TRIM/UNMAP* is supported for external hard drives with *SMR* (Shingled Magnetic Recording) to improve Write performance over time. One of the shingled write benefits is that all physical sectors are written sequentially in a direction radially and are only rewritten after a wrap-around. Rewriting a previously written LBA (Logical Block Addressing) will cause the previous write to be marked invalid and the LBA will be written to the next sequential physical sector. The *TRIM/UNMAP* enables the OS to inform the drive which blocks are no longer considered to be in use and can be reclaimed internally by the HDD to ensure that later write operations perform at full speed.


----------



## lep (Jul 14, 2022)

Phishfry said:


> Can you show a dmesg snippet for the disk drives and controller.
> Are they showing up as AHCI?




```
$ dmesg | nl | grep -B3 'ada[01]\|ata[34]'
   106  pci2: <ACPI PCI bus> on pcib5
   107  atapci0: <SiI 3512 SATA150 controller> port 0x1018-0x101f,0x1024-0x1027,0x1010-0x1017,0x1020-0x1023,0x1000-0x100f irq 21 at device 0.0 on pci2
   108  ata2: <ATA channel> at channel 0 on atapci0
   109  ata3: <ATA channel> at channel 1 on atapci0
   110  isab0: <PCI-ISA bridge> at device 31.0 on pci0
   111  isa0: <ISA bus> on isab0
   112  atapci1: <Intel ICH7 SATA300 controller> port 0x30b8-0x30bf,0x30cc-0x30cf,0x30b0-0x30b7,0x30c8-0x30cb,0x30a0-0x30af mem 0xe0384000-0xe03843ff irq 19 at device 31.2 on pci0
   113  ata4: <ATA channel> at channel 0 on atapci1
--
   115  (noperiph:ata2:0:-1:ffffffff): rescan already queued
   116  atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0
   117  atkbd0: <AT Keyboard> irq 1 on atkbdc0
   118  (noperiph:ata3:0:-1:ffffffff): rescan already queued
--
   165  uhub3: 2 ports with 2 removable, self powered
   166  uhub4: 2 ports with 2 removable, self powered
   167  Root mount waiting for: usbus4 CAM
   168  ada0 at ata2 bus 0 scbus0 target 0 lun 0
   169  ada0: <WDC WD40EZAZ-00SF3B0 80.00A80> ACS-3 ATA SATA 3.x device
   170  ada0: Serial Number WD-WX32D61N0HY4
   171  ada0: 150.000MB/s transfers (SATA 1.x, UDMA5, PIO 8192bytes)
   172  ada0: 3815447MB (7814037168 512 byte sectors)
   173  ada1 at ata3 bus 0 scbus1 target 0 lun 0
   174  ada1: <WDC WD40EZAZ-00SF3B0 80.00A80> ACS-3 ATA SATA 3.x device
   175  ada1: Serial Number WD-WX42D51NKCK1
   176  ada1: 150.000MB/s transfers (SATA 1.x, UDMA5, PIO 8192bytes)
   177  ada1: 3815447MB (7814037168 512 byte sectors)
   178  ada2 at ata4 bus 0 scbus2 target 0 lun 0
```
I hope that's enough context. ada{0,1} being the disks and ata{3,4} being the ata buses. There is no mention of AHCI in dmesg.



VladiBG said:


> HDD or SSD?
> If HDD and it's with SMR you will have very bad write performance over time. It's better to use HDD with CMR like WD Gold or another server/enterprise disks.
> 
> 
> ...


They are indeed SMR HDDs.


----------



## Phishfry (Jul 14, 2022)

Sorry for the noise.
It appears they are running in ATA mode. There is also AHCI mode.
AHCI is not supported on the Sil3512 from what I can find.





						ahci(4)
					






					www.freebsd.org


----------



## VladiBG (Jul 14, 2022)

It's time to replace this old server with something new.


----------



## lep (Jul 14, 2022)

Phishfry said:


> Sorry for the noise.
> It appears they are running in ATA mode. There is also AHCI mode.
> AHCI is not supported on the Sil3512 from what I can find.
> 
> ...


Yeah i assumed it would be the card. Thanks for your time.


VladiBG said:


> It's time to replace this old server with something new.


Technically you are probably correct but i'm quite fond of this machine and except storage space it is *very* far from its limits for my uses


----------

