Commit c337b23f authored by Linus Torvalds's avatar Linus Torvalds

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
parents 334e5a82 ef9cddfe
...@@ -56,11 +56,9 @@ ...@@ -56,11 +56,9 @@
#define BTRFS_DISCARD_DELAY (120ULL * NSEC_PER_SEC) #define BTRFS_DISCARD_DELAY (120ULL * NSEC_PER_SEC)
#define BTRFS_DISCARD_UNUSED_DELAY (10ULL * NSEC_PER_SEC) #define BTRFS_DISCARD_UNUSED_DELAY (10ULL * NSEC_PER_SEC)
/* Target completion latency of discarding all discardable extents */
#define BTRFS_DISCARD_TARGET_MSEC (6 * 60 * 60UL * MSEC_PER_SEC)
#define BTRFS_DISCARD_MIN_DELAY_MSEC (1UL) #define BTRFS_DISCARD_MIN_DELAY_MSEC (1UL)
#define BTRFS_DISCARD_MAX_DELAY_MSEC (1000UL) #define BTRFS_DISCARD_MAX_DELAY_MSEC (1000UL)
#define BTRFS_DISCARD_MAX_IOPS (10U) #define BTRFS_DISCARD_MAX_IOPS (1000U)
/* Monotonically decreasing minimum length filters after index 0 */ /* Monotonically decreasing minimum length filters after index 0 */
static int discard_minlen[BTRFS_NR_DISCARD_LISTS] = { static int discard_minlen[BTRFS_NR_DISCARD_LISTS] = {
...@@ -577,6 +575,7 @@ void btrfs_discard_calc_delay(struct btrfs_discard_ctl *discard_ctl) ...@@ -577,6 +575,7 @@ void btrfs_discard_calc_delay(struct btrfs_discard_ctl *discard_ctl)
s32 discardable_extents; s32 discardable_extents;
s64 discardable_bytes; s64 discardable_bytes;
u32 iops_limit; u32 iops_limit;
unsigned long min_delay = BTRFS_DISCARD_MIN_DELAY_MSEC;
unsigned long delay; unsigned long delay;
discardable_extents = atomic_read(&discard_ctl->discardable_extents); discardable_extents = atomic_read(&discard_ctl->discardable_extents);
...@@ -607,13 +606,19 @@ void btrfs_discard_calc_delay(struct btrfs_discard_ctl *discard_ctl) ...@@ -607,13 +606,19 @@ void btrfs_discard_calc_delay(struct btrfs_discard_ctl *discard_ctl)
} }
iops_limit = READ_ONCE(discard_ctl->iops_limit); iops_limit = READ_ONCE(discard_ctl->iops_limit);
if (iops_limit)
if (iops_limit) {
delay = MSEC_PER_SEC / iops_limit; delay = MSEC_PER_SEC / iops_limit;
else } else {
delay = BTRFS_DISCARD_TARGET_MSEC / discardable_extents; /*
* Unset iops_limit means go as fast as possible, so allow a
* delay of 0.
*/
delay = 0;
min_delay = 0;
}
delay = clamp(delay, BTRFS_DISCARD_MIN_DELAY_MSEC, delay = clamp(delay, min_delay, BTRFS_DISCARD_MAX_DELAY_MSEC);
BTRFS_DISCARD_MAX_DELAY_MSEC);
discard_ctl->delay_ms = delay; discard_ctl->delay_ms = delay;
spin_unlock(&discard_ctl->lock); spin_unlock(&discard_ctl->lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment