Skip to content

Commit

Permalink
Fix manual trim rate limiting
Browse files Browse the repository at this point in the history
  • Loading branch information
dweeezil committed Apr 7, 2017
1 parent a9a7167 commit 360651e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions module/zfs/vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -3772,6 +3772,7 @@ vdev_man_trim(vdev_trim_info_t *vti)
for (;;) {
uint64_t rate = spa->spa_man_trim_rate;
uint64_t sleep_delay;
clock_t t1;

if (rate == 0) {
/* No delay, just update 't' and move on. */
Expand All @@ -3781,16 +3782,16 @@ vdev_man_trim(vdev_trim_info_t *vti)

sleep_delay = (delta * hz) / rate;
mutex_enter(&spa->spa_man_trim_lock);
(void) cv_timedwait(&spa->spa_man_trim_update_cv,
&spa->spa_man_trim_lock, t);
t1 = cv_timedwait(&spa->spa_man_trim_update_cv,
&spa->spa_man_trim_lock, t + sleep_delay);
mutex_exit(&spa->spa_man_trim_lock);

/* If interrupted, don't try to relock, get out */
if (spa->spa_man_trim_stop)
goto out;

/* Timeout passed, move on to the next metaslab. */
if (ddi_get_lbolt() >= t + sleep_delay) {
if (t1 == -1) {
t += sleep_delay;
break;
}
Expand Down

0 comments on commit 360651e

Please sign in to comment.