Skip to content

Commit d38c815

Browse files
authored
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
1 parent b035f2b commit d38c815

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

module/zfs/arc.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8198,10 +8198,17 @@ l2arc_write_size(l2arc_dev_t *dev)
81988198
* iteration can occur.
81998199
*/
82008200
dev_size = dev->l2ad_end - dev->l2ad_start;
8201+
8202+
/* We need to add in the worst case scenario of log block overhead. */
82018203
tsize = size + l2arc_log_blk_overhead(size, dev);
8202-
if (dev->l2ad_vdev->vdev_has_trim && l2arc_trim_ahead > 0)
8204+
if (dev->l2ad_vdev->vdev_has_trim && l2arc_trim_ahead > 0) {
8205+
/*
8206+
* Trim ahead of the write size 64MB or (l2arc_trim_ahead/100)
8207+
* times the writesize, whichever is greater.
8208+
*/
82038209
tsize += MAX(64 * 1024 * 1024,
82048210
(tsize * l2arc_trim_ahead) / 100);
8211+
}
82058212

82068213
if (tsize >= dev_size) {
82078214
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)
88368843

88378844
buflist = &dev->l2ad_buflist;
88388845

8839-
/*
8840-
* We need to add in the worst case scenario of log block overhead.
8841-
*/
8842-
distance += l2arc_log_blk_overhead(distance, dev);
8843-
if (vd->vdev_has_trim && l2arc_trim_ahead > 0) {
8844-
/*
8845-
* Trim ahead of the write size 64MB or (l2arc_trim_ahead/100)
8846-
* times the write size, whichever is greater.
8847-
*/
8848-
distance += MAX(64 * 1024 * 1024,
8849-
(distance * l2arc_trim_ahead) / 100);
8850-
}
8851-
88528846
top:
88538847
rerun = B_FALSE;
88548848
if (dev->l2ad_hand >= (dev->l2ad_end - distance)) {

tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ typeset VDEV_MIN_MB=$((MINVDEVSIZE * 0.30 / 1024 / 1024))
6767
log_must zpool create -f $TESTPOOL $TRIM_VDEV1 cache $TRIM_VDEV2
6868
verify_vdevs "-le" "$VDEV_MIN_MB" $TRIM_VDEV2
6969

70-
typeset fill_mb=$(( floor(2 * MINVDEVSIZE) ))
70+
typeset fill_mb=$(( floor(3 * MINVDEVSIZE) ))
7171
export DIRECTORY=/$TESTPOOL
7272
export NUMJOBS=1
7373
export FILE_SIZE=${fill_mb}

0 commit comments

Comments
 (0)