ZoL, trim separate device?

Greetings from Sweden!

So, I’m trying out TrueNAS Scale 21.04 and so far it’s great!
But i have a little question that i hope someone can help me with;

I have a striped mirror (raid10) pool and wanted to try out adding a SLOG.
I had a Intel 760p 240GB lying around, yes it’s not the ideal SLOG but this is as a proof of concept before i take the plunge and buy a 900p/905p and i dont care if i kill it fast.

I created a 32GB partition with fdisk, and added it with:

zpool add storage log /dev/nvme0n1p1

The idea with the 32GB partition was that i had in my mind that it could extend the lifetime some at least with TRIM rotating cells.
I couldnt figure out how to TRIM the whole SLOG device, only the partition…

So i added a cronjob with;

0 12 * * *      zpool trim storage nvme0n1p1

Question 1: Is the above correct, that TRIM will “rotate” the cells?
Question 2: If i TRIM only a partition, will it trigger TRIM for the whole device?
Question 3: If “No” on question 2, how do i TRIM a whole device that is not a pool in ZoL?

Thanks in advance!

P.S
I got 32GB by calculating (20 x 0,125) x 5 + some more = 32 . As i have 2 x 10Gbit
D.S

1 Like

I suspect you can’t trim the device in this context.

The way we’re intended to use devices in ZFS (On Linux or Otherwise) is to use the entire disk, not to partition it up.

ZFS is assuming that’s what we’re doing, so I guess the tools do too.

May I ask what pool disks are? That’s just out of interest, not related to your question.

Edit: Why don’t you enable autotrim?

BerraBing,

We are in 2021. Manual trimming of flash devices is no longer necessary, unless you’re dealing with a really old drive or you’re actually interacting with the flash memory directly, such as is done with some eMMCs. Think 2012 and earlier. As long as you leave some space out for the SSD itself to handle trimming - not that it’s needed, it’s more of a precaution - you should be fine.

Best regards,

vhns

Heya and thanks for your quick reply!

Okay yeah I’m starting to realize that. Just had something in the back of my mind saying that i saw Wendell doing this in a video, but could have been someone else and could also have been a really old vid :smiley:

So you suggest adding the whole 760p as a SLOG without parting it up?
I have autotrim enabled but i dont see the device being TRIMmed in

zpool status -t

The pool consists of 10 x WDC_WD40EFRX-68WT0N0 in raid10.

Heya and thanks for yet another quick reply!

Ahaa okay, was reading on Intels website regarding TRIM and it stated that it had to be initiated by the OS?

Should i remove the partition and add the whole device as a SLOG instead then?

BerraBing,

I am just a person on the internet. My statement could be wrong. Would you mind linking to said part of the website?

Best regards,

vhns

Wow you guys are awesome at helping out fast!

Now that i read it again, I might have missunderstood the Intel page, but here is the statement;
"
Environment:

For TRIM to function, both the SSD and operating system must support TRIM and be enabled in the operating system.
"
And the reason why i thought i needed manual TRIM is that i dont see the drives beeing TRIMmed in status of pools…

Thanks again!

Regards

1 Like

You totally can add a partition, and you’re only testing right now right? But you don’t need to trim the whole disk, per se.

I personally don’t use partitions.

Personally, I’d just use the whole disk and turn on zpool autotrim and let zfs do what it wants.

You and vhns are awesome, thanks for the quick help!

Yes right now its just proof of concept, but also to figure out the optimal settings for when i buy the 900p/905p.
I rather mess up now with this device than on the proper one :slight_smile:

zpool get autotrim storage

Returns “ON”

When I run:

zpool status -t

the status for TRIM is never updated…?

Thanks again!

2 Likes

Sorry for the delay, I had to play taxi.

Autotrim is continuous and doesn’t show in status.

You can run a manual trim if it’s triggering you. And I completely understand!

2 Likes
Automatic TRIM happens continuously in the background and operates
solely on recently freed blocks (ms_trim not ms_allocatable).
...
While the automatic TRIM process is highly effective it is more likely
than a manual TRIM to encounter tiny ranges.  Ranges less than or equal to
'zfs_trim_extent_bytes_min' (32k) are considered too small to efficiently
TRIM and are skipped.  This means small amounts of freed space may not
be automatically trimmed.
2 Likes

Here’s a question, instead of partitions would making use of “namespaces” with intelmas or maby nvme-cli (should be included in linux) be more viable for trim support? Not sure what the truenas equivalent would be.

By default, nvme drives have a single namespace (/dev/nvme0n1) provisioned with the capacity of the entire drive, but can apparently be set to to a certain size

So giving ZFS the namespace may be somewhat more like handing it a “real” drive and trim might work normally. At least, from my very rough understanding. I’ve not played with this myself yet.

edit Ah, just saw @anon86748826 post, good to know!*

Thanks for posting that.

I wouldn’t expect the small block size issue to be a problem for the slog. It’s going to write out in blocks larger than that 35k limit isn’t it?

I normally create partitions on my SSDs so they last a bit longer than giving the whole drive

but thanks for this thread… i didnt realize my autotrim wasnt on.

image

edit… error thrown when I told it to trim the l2arc ssd - not supported on that vdev

2 Likes