L2ARC: Implement DWPD-based rate limiting with adaptive feed intervals

Add DWPD (Drive Writes Per Day) rate limiting to control L2ARC write
speeds and protect SSD endurance. Write rate is constrained by the
minimum of l2arc_write_max and DWPD-calculated budget. Devices
accumulate unused write budget over 24-hour periods with automatic reset
and carry-over. Writes occur in controlled bursts (max 50MB) with
adaptive intervals to achieve target rates. Applies after initial device
fill.

Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ameer Hamza <ahamza@ixsystems.com>
Closes #18093
This commit is contained in:
Ameer Hamza
2025-09-25 23:24:03 +05:00
committed by Brian Behlendorf
parent b525525b44
commit d1f290f1ea
5 changed files with 184 additions and 46 deletions
+10
View File
@@ -442,6 +442,13 @@ typedef struct l2arc_dev {
*/
zfs_refcount_t l2ad_lb_count;
boolean_t l2ad_trim_all; /* TRIM whole device */
/*
* DWPD tracking with daily reset
*/
uint64_t l2ad_dwpd_writes; /* 24h bytes written */
uint64_t l2ad_dwpd_start; /* 24h period start */
uint64_t l2ad_dwpd_accumulated; /* Accumulated */
uint64_t l2ad_dwpd_bump; /* Reset trigger */
/*
* Per-device feed thread for parallel L2ARC writes
*/
@@ -1087,6 +1094,7 @@ extern uint_t zfs_arc_pc_percent;
extern uint_t arc_lotsfree_percent;
extern uint64_t zfs_arc_min;
extern uint64_t zfs_arc_max;
extern uint64_t l2arc_dwpd_limit;
extern uint64_t arc_reduce_target_size(uint64_t to_free);
extern boolean_t arc_reclaim_needed(void);
@@ -1106,6 +1114,8 @@ extern int param_set_arc_u64(ZFS_MODULE_PARAM_ARGS);
extern int param_set_arc_int(ZFS_MODULE_PARAM_ARGS);
extern int param_set_arc_min(ZFS_MODULE_PARAM_ARGS);
extern int param_set_arc_max(ZFS_MODULE_PARAM_ARGS);
extern int param_set_l2arc_dwpd_limit(ZFS_MODULE_PARAM_ARGS);
extern void l2arc_dwpd_bump_reset(void);
/* used in zdb.c */
boolean_t l2arc_log_blkptr_valid(l2arc_dev_t *dev,