Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim L2ARC #9789

Merged
merged 1 commit into from
Jun 9, 2020
Merged

Trim L2ARC #9789

merged 1 commit into from
Jun 9, 2020

Conversation

gamanakis
Copy link
Contributor

@gamanakis gamanakis commented Dec 30, 2019

Implement TRIM on cache devices.

Signed-off-by: George Amanakis gamanakis@gmail.com

Motivation and Context

Closes #9713
Closes #10224

Description

The l2arc_evict() function is responsible for evicting buffers which
reference the next bytes of the L2ARC device to be overwritten. Teach
this function to additionally TRIM that vdev space before it is
overwritten if the device has been filled with data. This is done by
vdev_trim_simple() which trims by issuing a new type of TRIM,
TRIM_TYPE_SIMPLE.

We also implement a "Trim Ahead" feature. It is a zfs module parameter,
expressed in % of the current write size. This trims ahead of the
current write size. A minimum of 64MB will be trimmed. The default is 0
which disables TRIM on L2ARC as it can put significant stress to
underlying storage devices. To enable TRIM on L2ARC we set
l2arc_trim_ahead > 0.

We also implement TRIM of the whole cache device upon addition to a
pool, pool creation or when the header of the device is invalid upon
importing a pool or onlining a cache device. This is dependent on
l2arc_trim_ahead > 0. TRIM of the whole device is done with
TRIM_TYPE_MANUAL so that its status can be monitored by zpool status -t.
We save the TRIM state for the whole device and the time of competion
on-disk in the header, and restore these upon L2ARC rebuild so that
zpool status -t can correctly report them. Whole device TRIM is done
asynchronously so that the user can export of the pool or remove the
cache device while it is trimming (ie if it is too slow).

We do not TRIM the whole device if persistent L2ARC has been disabled by
l2arc_rebuild_enabled = 0 because we may not want to lose all cached
buffers (eg we may want to import the pool with
l2arc_rebuild_enabled = 0 only once because of memory pressure). If
persistent L2ARC has been disabled by setting the module parameter
l2arc_rebuild_blocks_min_l2size to a value greater than the size of the
cache device then the whole device is trimmed upon creation or import of
a pool if l2arc_trim_ahead > 0.

How Has This Been Tested?

Tests have been added in ZTS.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (a change to man pages or other documentation)

Checklist:

  • My code follows the ZFS on Linux code style requirements.
  • I have updated the documentation accordingly.
  • I have read the contributing document.
  • I have added tests to cover my changes.
  • I have run the ZFS Test Suite with this change applied.
  • All commit messages are properly formatted and contain Signed-off-by.

Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for starting to look in to this!

module/zfs/arc.c Outdated Show resolved Hide resolved
module/zfs/arc.c Show resolved Hide resolved
@behlendorf behlendorf added the Status: Work in Progress Not yet ready for general review label Dec 30, 2019
@codecov
Copy link

codecov bot commented Dec 31, 2019

Codecov Report

Merging #9789 into master will decrease coverage by <1%.
The diff coverage is 85%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master    #9789    +/-   ##
========================================
- Coverage      79%      79%   -<1%     
========================================
  Files         385      385            
  Lines      121481   121515    +34     
========================================
- Hits        96461    96449    -12     
- Misses      25020    25066    +46
Flag Coverage Δ
#kernel 80% <88%> (ø) ⬇️
#user 67% <12%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 82e996c...038e8a3. Read the comment docs.

@gamanakis
Copy link
Contributor Author

I will add a test later.

@gamanakis
Copy link
Contributor Author

There is a peculiarity with the current approach:
l2arc_evict() runs periodically after the cache device has been filled once completely with data (dev->l2ad_first). However l2arc_write_buffers() may not actually write data to the space evicted and trimmed by l2arc_evict(), and thus dev->l2ad_hand does not move. This means that the next time l2arc_evict() runs, the space that has been previously evicted and trimmed is going to be evicted and trimmed again, and this is going to happen until l2arc_write_buffers() decides to write data and move dev->l2ad_hand.

Is this a problem?

@gamanakis
Copy link
Contributor Author

I think it is possible to leverage this in l2arc_evict() by using vd->vdev_trim_last_offset.

@gamanakis gamanakis force-pushed the l2arc_trim branch 7 times, most recently from 9a5a874 to c7a81ec Compare January 2, 2020 05:52
@gamanakis gamanakis force-pushed the l2arc_trim branch 2 times, most recently from 173da55 to d897b4f Compare January 18, 2020 03:56
@gamanakis gamanakis mentioned this pull request Jan 21, 2020
12 tasks
@pashford
Copy link
Contributor

Here are some general comments on Trim of the L2ARC. Sorry, I didn't have time to comment on this a month ago, when it was more active.

My understanding of how L2ARC works (based on Solaris 10 ZFS) is that it's a circular buffer. New writes are always at the "end" of that buffer, with a block rarely (almost never) being preserved. Any "old" data that gets overwritten as the end moves forward gets the in-core header released. This was an excellent design for the 10KRPM/15KRPM disks that were being used for L2ARC at the time. Alas, time passes and technology moves forward.

On an SSD, when a block of data gets overwritten, it's released and available to be erased. Issuing a Trim command for the block to be overwritten may help slightly with fragmentation of the space and will give a few additional microseconds for the SSD controller to start erasing blocks before the data arrives. Increasing the size of the segment being released will help a bit more. The real gain here is that these blocks will always be on a SSD block boundary, removing any need to defragment the blocks being Trimmed.

Off the top of my head, there are a few other items that might be able to be trimmed.

  1. When an L2ARC is initialized (including clearing a persistent L2ARC), a Trim should be issued for the entire partition. This might already be being done.

  2. When a block that's in the L2ARC gets updated (COW now places that file block into a different disk block), the old data can probably be trimmed. The chances of using the old data block through the active file-system are now ZERO, and the chances of it being used through a snapshot are usually low.

  3. When an inode is deallocated, any blocks that it has in the L2ARC can probably be trimmed. This will probably have a lower ROI than the above, because I expect most blocks in files being deleted (except intermediate/temporary files) won't be in the L2ARC. If this is done, there would be a lot of chasing through the L2ARC metadata looking for blocks that aren't there.

Items 2 & 3 above would be likely to increase SSD fragmentation. The SSD controller would be spending a lot more time consolidating mapped blocks to make a device block available to be erased. As long as the controller can keep up (most modern SSD controllers probably won't have a problem), this should be fine, but older (or low-end) SSDs might have a problem.

@gamanakis
Copy link
Contributor Author

gamanakis commented Jan 24, 2020

@pashford Thank you for the feedback.
(1) is very reasonable and will be implemented.
(2) This is what this PR does right now. Though I am not sure L2ARC is COW.
(3) This will probably be not so effective for the reasons you mention.

I believe it is more reasonable to get #9582 (persistent L2ARC) merged first, and then work out the details of this PR. This PR requires additional code to co-exist with #9582. I have both implemented in local builds and everything seems to be running smoothly.

@bghira
Copy link

bghira commented Jan 24, 2020

trimming during adding of l2arc if implemented, should certainly be optional. not all devices trim equally, it would be awful to wait for the entire partition to be done.

@gamanakis gamanakis force-pushed the l2arc_trim branch 2 times, most recently from d6a8126 to 038e8a3 Compare January 24, 2020 19:32
@pashford
Copy link
Contributor

@misterbigstuff,

Excellent idea. Perhaps it would be possible to trim the entire partition in "small" chunks, maybe 64MB-1GB/S - at least twice the specified max L2ARC write rate. That would keep the controller's erase queue short, but still keep the erased blocks ahead of the blocks being written.

@pashford
Copy link
Contributor

@gamanakis,

Based on your response, I'm not sure that when I meant came through clearly. Please allow me to provide an example that should make my meaning clear.

Let's say that there's a 1-block file that's being updated. The updates are infrequent enough that the blocks often get migrated to L2ARC between updates. When the update happens, the block might still be valid in a snapshot, but not in the active instance of the file-system, due to COW.

When this happens, the L2ARC instance of the possibly valid block should be released and trimmed. This is because the chances of the block being used by any snapshot that might still have it allocated are very slim, when compared to the use by the active instance of the file-system.

Does this make more sense?

@pashford
Copy link
Contributor

This is based on Brian Behledorf's comment at #9713.

When I wrote my first comment in this issue, I thought you were referring to Brian's post about using a larger overwrite size. Since that's not the case, here's another way that Trim can be used to improve performance of SSD-based L2ARCs.

Implement a "TrimAhead" feature. This is based on the 8MB overwrite feature, but it's more flexible. The default would be the greater of 64MB or twice the current write speed limit (the initial fill rate can be set higher than the refresh fill rate) with a minimum of 8MB. It would be a tunable parameter, which would be expressed in MB or %. This would free farther ahead of the current write pointer.

The purpose of this is to better accommodate write bursts (the L2ARC writes are bursty). Also, for consumer-grade SSDs, it would effectively reserve the specified amount of SSD space for the controller to catch up, and to lessen the amount of page defragmentation the controller needs to do. This is superior to leaving a portion of the SSD unused, in that you know that the unused portion will be trimmed and you know that it will never be accidentally used or put to "temporary" use.

@gamanakis gamanakis force-pushed the l2arc_trim branch 2 times, most recently from 7dc4f92 to e446144 Compare April 11, 2020 05:23
@codecov-io
Copy link

codecov-io commented Apr 11, 2020

Codecov Report

Merging #9789 into master will decrease coverage by 0.34%.
The diff coverage is 95.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9789      +/-   ##
==========================================
- Coverage   79.52%   79.17%   -0.35%     
==========================================
  Files         389      389              
  Lines      123120   123255     +135     
==========================================
- Hits        97906    97590     -316     
- Misses      25214    25665     +451     
Flag Coverage Δ
#kernel 79.90% <97.20%> (-0.01%) ⬇️
#user 64.15% <37.25%> (-1.87%) ⬇️
Impacted Files Coverage Δ
module/zfs/vdev_trim.c 95.18% <93.05%> (-0.12%) ⬇️
module/zfs/arc.c 89.14% <96.36%> (+0.34%) ⬆️
cmd/zdb/zdb.c 81.19% <100.00%> (+0.04%) ⬆️
module/os/linux/zfs/spa_stats.c 82.90% <100.00%> (+0.28%) ⬆️
module/zfs/spa.c 86.89% <100.00%> (+0.07%) ⬆️
module/zfs/vdev.c 90.01% <100.00%> (+0.05%) ⬆️
module/zfs/vdev_removal.c 94.16% <100.00%> (-2.62%) ⬇️
cmd/ztest/ztest.c 71.81% <0.00%> (-8.37%) ⬇️
module/os/linux/spl/spl-kmem-cache.c 75.58% <0.00%> (-8.14%) ⬇️
module/zfs/space_map.c 92.82% <0.00%> (-5.45%) ⬇️
... and 56 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6ed4391...ef10ef8. Read the comment docs.

@gamanakis gamanakis force-pushed the l2arc_trim branch 2 times, most recently from 032f438 to e0c6612 Compare May 31, 2020 05:15
@gamanakis
Copy link
Contributor Author

032f438: To keep things simple, I renamed TRIM_TYPE_L2ARC to TRIM_TYPE_SIMPLE (along with all related stats and references). Now vdev_trim_simple() uses always TRIM_TYPE_SIMPLE.

Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The restructured code looks nice. Good idea renaming TRIM_TYPE_L2ARC to TRIM_TYPE_SIMPLE, that definitely helped to keep things clear and simple. I added a few more comments, then this looks good to me. Please take a moment to rebase this on master after addressing the latest comments.

include/sys/vdev.h Outdated Show resolved Hide resolved
man/man5/zfs-module-parameters.5 Outdated Show resolved Hide resolved
module/zfs/arc.c Outdated Show resolved Hide resolved
@behlendorf behlendorf requested a review from lundman June 1, 2020 17:41
@gamanakis gamanakis force-pushed the l2arc_trim branch 2 times, most recently from 204b00a to c4cc669 Compare June 2, 2020 04:10
@gamanakis
Copy link
Contributor Author

gamanakis commented Jun 2, 2020

204b00a: Addresses comments from @behlendorf, rebased to master.
c4cc669: Update the commit message.

@gamanakis
Copy link
Contributor Author

gamanakis commented Jun 2, 2020

298654a: Updated some comments in the code.
3393d5b: In vdev_trim_l2arc_thread() set l2ad_trim_all to false before broadcasting vdev_trim_cv and only if TRIM of the whole device was successfully completed.

Otherwise if the TRIM is not completed this will be reflected in trim_state in the device header and l2ad_trim_all will be set to false leading to the cache device being used. However, upon next import of the pool the device will be trimmed again because in the device header we have trim_state != VDEV_TRIM_COMPLETE leading to unexpected behaviour (unexpected TRIM of the whole device the second time although it appeared to have been trimmed already).

The l2arc_evict() function is responsible for evicting buffers which
reference the next bytes of the L2ARC device to be overwritten. Teach
this function to additionally TRIM that vdev space before it is
overwritten if the device has been filled with data. This is done by
vdev_trim_simple() which trims by issuing a new type of TRIM,
TRIM_TYPE_SIMPLE.

We also implement a "Trim Ahead" feature. It is a zfs module parameter,
expressed in % of the current write size. This trims ahead of the
current write size. A minimum of 64MB will be trimmed. The default is 0
which disables TRIM on L2ARC as it can put significant stress to
underlying storage devices. To enable TRIM on L2ARC we set
l2arc_trim_ahead > 0.

We also implement TRIM of the whole cache device upon addition to a
pool, pool creation or when the header of the device is invalid upon
importing a pool or onlining a cache device. This is dependent on
l2arc_trim_ahead > 0. TRIM of the whole device is done with
TRIM_TYPE_MANUAL so that its status can be monitored by zpool status -t.
We save the TRIM state for the whole device and the time of competion
on-disk in the header, and restore these upon L2ARC rebuild so that
zpool status -t can correctly report them. Whole device TRIM is done
asynchronously so that the user can export of the pool or remove the
cache device while it is trimming (ie if it is too slow).

We do not TRIM the whole device if persistent L2ARC has been disabled by
l2arc_rebuild_enabled = 0 because we may not want to lose all cached
buffers (eg we may want to import the pool with
l2arc_rebuild_enabled = 0 only once because of memory pressure). If
persistent L2ARC has been disabled by setting the module parameter
l2arc_rebuild_blocks_min_l2size to a value greater than the size of the
cache device then the whole device is trimmed upon creation or import of
a pool if l2arc_trim_ahead > 0.

Signed-off-by: George Amanakis <gamanakis@gmail.com>
@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Jun 3, 2020
@behlendorf
Copy link
Contributor

This is ready to merge. If anyone has additional feedback please post it by Monday June 8th.

@behlendorf behlendorf merged commit b7654bd into openzfs:master Jun 9, 2020
@behlendorf
Copy link
Contributor

Merged!

BrainSlayer pushed a commit to BrainSlayer/zfs that referenced this pull request Jun 10, 2020
The l2arc_evict() function is responsible for evicting buffers which
reference the next bytes of the L2ARC device to be overwritten. Teach
this function to additionally TRIM that vdev space before it is
overwritten if the device has been filled with data. This is done by
vdev_trim_simple() which trims by issuing a new type of TRIM,
TRIM_TYPE_SIMPLE.

We also implement a "Trim Ahead" feature. It is a zfs module parameter,
expressed in % of the current write size. This trims ahead of the
current write size. A minimum of 64MB will be trimmed. The default is 0
which disables TRIM on L2ARC as it can put significant stress to
underlying storage devices. To enable TRIM on L2ARC we set
l2arc_trim_ahead > 0.

We also implement TRIM of the whole cache device upon addition to a
pool, pool creation or when the header of the device is invalid upon
importing a pool or onlining a cache device. This is dependent on
l2arc_trim_ahead > 0. TRIM of the whole device is done with
TRIM_TYPE_MANUAL so that its status can be monitored by zpool status -t.
We save the TRIM state for the whole device and the time of completion
on-disk in the header, and restore these upon L2ARC rebuild so that
zpool status -t can correctly report them. Whole device TRIM is done
asynchronously so that the user can export of the pool or remove the
cache device while it is trimming (ie if it is too slow).

We do not TRIM the whole device if persistent L2ARC has been disabled by
l2arc_rebuild_enabled = 0 because we may not want to lose all cached
buffers (eg we may want to import the pool with
l2arc_rebuild_enabled = 0 only once because of memory pressure). If
persistent L2ARC has been disabled by setting the module parameter
l2arc_rebuild_blocks_min_l2size to a value greater than the size of the
cache device then the whole device is trimmed upon creation or import of
a pool if l2arc_trim_ahead > 0.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Adam D. Moss <c@yotes.com>
Signed-off-by: George Amanakis <gamanakis@gmail.com>
Closes openzfs#9713
Closes openzfs#9789 
Closes openzfs#10224
lundman referenced this pull request in openzfsonosx/openzfs Jun 12, 2020
The l2arc_evict() function is responsible for evicting buffers which
reference the next bytes of the L2ARC device to be overwritten. Teach
this function to additionally TRIM that vdev space before it is
overwritten if the device has been filled with data. This is done by
vdev_trim_simple() which trims by issuing a new type of TRIM,
TRIM_TYPE_SIMPLE.

We also implement a "Trim Ahead" feature. It is a zfs module parameter,
expressed in % of the current write size. This trims ahead of the
current write size. A minimum of 64MB will be trimmed. The default is 0
which disables TRIM on L2ARC as it can put significant stress to
underlying storage devices. To enable TRIM on L2ARC we set
l2arc_trim_ahead > 0.

We also implement TRIM of the whole cache device upon addition to a
pool, pool creation or when the header of the device is invalid upon
importing a pool or onlining a cache device. This is dependent on
l2arc_trim_ahead > 0. TRIM of the whole device is done with
TRIM_TYPE_MANUAL so that its status can be monitored by zpool status -t.
We save the TRIM state for the whole device and the time of completion
on-disk in the header, and restore these upon L2ARC rebuild so that
zpool status -t can correctly report them. Whole device TRIM is done
asynchronously so that the user can export of the pool or remove the
cache device while it is trimming (ie if it is too slow).

We do not TRIM the whole device if persistent L2ARC has been disabled by
l2arc_rebuild_enabled = 0 because we may not want to lose all cached
buffers (eg we may want to import the pool with
l2arc_rebuild_enabled = 0 only once because of memory pressure). If
persistent L2ARC has been disabled by setting the module parameter
l2arc_rebuild_blocks_min_l2size to a value greater than the size of the
cache device then the whole device is trimmed upon creation or import of
a pool if l2arc_trim_ahead > 0.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Adam D. Moss <c@yotes.com>
Signed-off-by: George Amanakis <gamanakis@gmail.com>
Closes #9713
Closes #9789 
Closes #10224
jsai20 pushed a commit to jsai20/zfs that referenced this pull request Mar 30, 2021
The l2arc_evict() function is responsible for evicting buffers which
reference the next bytes of the L2ARC device to be overwritten. Teach
this function to additionally TRIM that vdev space before it is
overwritten if the device has been filled with data. This is done by
vdev_trim_simple() which trims by issuing a new type of TRIM,
TRIM_TYPE_SIMPLE.

We also implement a "Trim Ahead" feature. It is a zfs module parameter,
expressed in % of the current write size. This trims ahead of the
current write size. A minimum of 64MB will be trimmed. The default is 0
which disables TRIM on L2ARC as it can put significant stress to
underlying storage devices. To enable TRIM on L2ARC we set
l2arc_trim_ahead > 0.

We also implement TRIM of the whole cache device upon addition to a
pool, pool creation or when the header of the device is invalid upon
importing a pool or onlining a cache device. This is dependent on
l2arc_trim_ahead > 0. TRIM of the whole device is done with
TRIM_TYPE_MANUAL so that its status can be monitored by zpool status -t.
We save the TRIM state for the whole device and the time of completion
on-disk in the header, and restore these upon L2ARC rebuild so that
zpool status -t can correctly report them. Whole device TRIM is done
asynchronously so that the user can export of the pool or remove the
cache device while it is trimming (ie if it is too slow).

We do not TRIM the whole device if persistent L2ARC has been disabled by
l2arc_rebuild_enabled = 0 because we may not want to lose all cached
buffers (eg we may want to import the pool with
l2arc_rebuild_enabled = 0 only once because of memory pressure). If
persistent L2ARC has been disabled by setting the module parameter
l2arc_rebuild_blocks_min_l2size to a value greater than the size of the
cache device then the whole device is trimmed upon creation or import of
a pool if l2arc_trim_ahead > 0.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Adam D. Moss <c@yotes.com>
Signed-off-by: George Amanakis <gamanakis@gmail.com>
Closes openzfs#9713
Closes openzfs#9789 
Closes openzfs#10224
sempervictus pushed a commit to sempervictus/zfs that referenced this pull request May 31, 2021
The l2arc_evict() function is responsible for evicting buffers which
reference the next bytes of the L2ARC device to be overwritten. Teach
this function to additionally TRIM that vdev space before it is
overwritten if the device has been filled with data. This is done by
vdev_trim_simple() which trims by issuing a new type of TRIM,
TRIM_TYPE_SIMPLE.

We also implement a "Trim Ahead" feature. It is a zfs module parameter,
expressed in % of the current write size. This trims ahead of the
current write size. A minimum of 64MB will be trimmed. The default is 0
which disables TRIM on L2ARC as it can put significant stress to
underlying storage devices. To enable TRIM on L2ARC we set
l2arc_trim_ahead > 0.

We also implement TRIM of the whole cache device upon addition to a
pool, pool creation or when the header of the device is invalid upon
importing a pool or onlining a cache device. This is dependent on
l2arc_trim_ahead > 0. TRIM of the whole device is done with
TRIM_TYPE_MANUAL so that its status can be monitored by zpool status -t.
We save the TRIM state for the whole device and the time of completion
on-disk in the header, and restore these upon L2ARC rebuild so that
zpool status -t can correctly report them. Whole device TRIM is done
asynchronously so that the user can export of the pool or remove the
cache device while it is trimming (ie if it is too slow).

We do not TRIM the whole device if persistent L2ARC has been disabled by
l2arc_rebuild_enabled = 0 because we may not want to lose all cached
buffers (eg we may want to import the pool with
l2arc_rebuild_enabled = 0 only once because of memory pressure). If
persistent L2ARC has been disabled by setting the module parameter
l2arc_rebuild_blocks_min_l2size to a value greater than the size of the
cache device then the whole device is trimmed upon creation or import of
a pool if l2arc_trim_ahead > 0.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Adam D. Moss <c@yotes.com>
Signed-off-by: George Amanakis <gamanakis@gmail.com>
Closes openzfs#9713
Closes openzfs#9789 
Closes openzfs#10224
@mailinglists35
Copy link

mailinglists35 commented Jun 7, 2023

@gamanakis how to ensure trim can be done on l2arc devices, and how to troubleshoot if it doesn't?

I am in the same situation as #14488 and #9713
zpool trim -t only shows the log device being trimmed, but the l2arc devices shows as "(untrimmed)", despite both the log and cache vdevs being on the same ssd

@adamdmoss
Copy link
Contributor

@gamanakis how to ensure trim can be done on l2arc devices, and how to troubleshoot if it doesn't?

I am in the same situation as #14488 and #9713 zpool trim -t only shows the log device being trimmed, but the l2arc devices shows as "(untrimmed)", despite both the log and cache vdevs being on the same ssd

Since an L2ARC's natural state is to be full (since l2arc gained persistence across boots, at least!) it doesn't usually make much sense to trim the l2arc device spontaneously.

If you want the l2arc trimmed, continuous trim-ahead should be effective, as documented at:
https://openzfs.github.io/openzfs-docs/Performance%20and%20Tuning/Module%20Parameters.html#l2arc-trim-ahead

@Rudd-O
Copy link
Contributor

Rudd-O commented Sep 19, 2023

[root@milena ~]# echo 100 > /sys/module/zfs/parameters/l2arc_trim_ahead 
[root@milena ~]# cat /sys/module/zfs/parameters/l2arc_trim_ahead 
100
[root@milena ~]# zpool trim -w backups
cannot trim: no devices in pool support trim operations

Setting this parameter does not change the error message produced by zpool trim.

#14488 is exactly what I am experiencing.

@mabod
Copy link

mabod commented Oct 13, 2024

I just added an SSD cache device to my main pool. Now I am wondering if this PR will be implemented in 2.2.7 or 2.3.. I am afraid that the SSD cache will loose its performance advantage when not being trimmed.

@amotin
Copy link
Member

amotin commented Oct 14, 2024

@mabod This PR was merged 4 years ago back in 2020, so it is sure in both 2.2 and 2.3. But I think you worry too much about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

zpool iostat reporting 16E free on a ~266G l2arc device Cannot trim L2ARC on SSD