aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGeorge Amanakis <[email protected]>2023-05-09 17:54:41 +0200
committerGitHub <[email protected]>2023-05-09 08:54:41 -0700
commitd38c815fe27c033564d1f7cc769e74eba11cfb83 (patch)
tree2e70e3474f98c17f7e5302f52fbe5b2c809b353f /module
parentb035f2b2cb9b88b1330c4b48641b8793d6460c9b (diff)
Remove duplicate code in l2arc_evict()
l2arc_evict() performs the adjustment of the size of buffers to be written on L2ARC unnecessarily. l2arc_write_size() is called right before l2arc_evict() and performs those adjustments. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Brian Atkinson <[email protected]> Signed-off-by: George Amanakis <[email protected]> Closes #14828
Diffstat (limited to 'module')
-rw-r--r--module/zfs/arc.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/module/zfs/arc.c b/module/zfs/arc.c
index bf8d99f94..a78f664c4 100644
--- a/module/zfs/arc.c
+++ b/module/zfs/arc.c
@@ -8198,10 +8198,17 @@ l2arc_write_size(l2arc_dev_t *dev)
* iteration can occur.
*/
dev_size = dev->l2ad_end - dev->l2ad_start;
+
+ /* We need to add in the worst case scenario of log block overhead. */
tsize = size + l2arc_log_blk_overhead(size, dev);
- if (dev->l2ad_vdev->vdev_has_trim && l2arc_trim_ahead > 0)
+ if (dev->l2ad_vdev->vdev_has_trim && l2arc_trim_ahead > 0) {
+ /*
+ * Trim ahead of the write size 64MB or (l2arc_trim_ahead/100)
+ * times the writesize, whichever is greater.
+ */
tsize += MAX(64 * 1024 * 1024,
(tsize * l2arc_trim_ahead) / 100);
+ }
if (tsize >= dev_size) {
cmn_err(CE_NOTE, "l2arc_write_max or l2arc_write_boost "
@@ -8836,19 +8843,6 @@ l2arc_evict(l2arc_dev_t *dev, uint64_t distance, boolean_t all)
buflist = &dev->l2ad_buflist;
- /*
- * We need to add in the worst case scenario of log block overhead.
- */
- distance += l2arc_log_blk_overhead(distance, dev);
- if (vd->vdev_has_trim && l2arc_trim_ahead > 0) {
- /*
- * Trim ahead of the write size 64MB or (l2arc_trim_ahead/100)
- * times the write size, whichever is greater.
- */
- distance += MAX(64 * 1024 * 1024,
- (distance * l2arc_trim_ahead) / 100);
- }
-
top:
rerun = B_FALSE;
if (dev->l2ad_hand >= (dev->l2ad_end - distance)) {