Skip to content

Commit c337b23

Browse files
committed
Merge tag 'for-6.3-rc7-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs fixes from David Sterba: "Two patches fixing the problem with aync discard. The default settings had a low IOPS limit and processing a large batch to discard would take a long time. On laptops this can cause increased power consumption due to disk activity. As async discard has been on by default since 6.2 this likely affects a lot of users. Summary: - increase the default IOPS limit 10x which reportedly helped - setting the sysfs IOPS value to 0 now does not throttle anymore allowing the discards to be processed at full speed. Previously there was an arbitrary 6 hour target for processing the pending batch" * tag 'for-6.3-rc7-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: btrfs: reinterpret async discard iops_limit=0 as no delay btrfs: set default discard iops_limit to 1000
2 parents 334e5a8 + ef9cddf commit c337b23

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

fs/btrfs/discard.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,9 @@
5656
#define BTRFS_DISCARD_DELAY (120ULL * NSEC_PER_SEC)
5757
#define BTRFS_DISCARD_UNUSED_DELAY (10ULL * NSEC_PER_SEC)
5858

59-
/* Target completion latency of discarding all discardable extents */
60-
#define BTRFS_DISCARD_TARGET_MSEC (6 * 60 * 60UL * MSEC_PER_SEC)
6159
#define BTRFS_DISCARD_MIN_DELAY_MSEC (1UL)
6260
#define BTRFS_DISCARD_MAX_DELAY_MSEC (1000UL)
63-
#define BTRFS_DISCARD_MAX_IOPS (10U)
61+
#define BTRFS_DISCARD_MAX_IOPS (1000U)
6462

6563
/* Monotonically decreasing minimum length filters after index 0 */
6664
static int discard_minlen[BTRFS_NR_DISCARD_LISTS] = {
@@ -577,6 +575,7 @@ void btrfs_discard_calc_delay(struct btrfs_discard_ctl *discard_ctl)
577575
s32 discardable_extents;
578576
s64 discardable_bytes;
579577
u32 iops_limit;
578+
unsigned long min_delay = BTRFS_DISCARD_MIN_DELAY_MSEC;
580579
unsigned long delay;
581580

582581
discardable_extents = atomic_read(&discard_ctl->discardable_extents);
@@ -607,13 +606,19 @@ void btrfs_discard_calc_delay(struct btrfs_discard_ctl *discard_ctl)
607606
}
608607

609608
iops_limit = READ_ONCE(discard_ctl->iops_limit);
610-
if (iops_limit)
609+
610+
if (iops_limit) {
611611
delay = MSEC_PER_SEC / iops_limit;
612-
else
613-
delay = BTRFS_DISCARD_TARGET_MSEC / discardable_extents;
612+
} else {
613+
/*
614+
* Unset iops_limit means go as fast as possible, so allow a
615+
* delay of 0.
616+
*/
617+
delay = 0;
618+
min_delay = 0;
619+
}
614620

615-
delay = clamp(delay, BTRFS_DISCARD_MIN_DELAY_MSEC,
616-
BTRFS_DISCARD_MAX_DELAY_MSEC);
621+
delay = clamp(delay, min_delay, BTRFS_DISCARD_MAX_DELAY_MSEC);
617622
discard_ctl->delay_ms = delay;
618623

619624
spin_unlock(&discard_ctl->lock);

0 commit comments

Comments
 (0)