diff mbox series

[4/4] btrfs: discard: reschedule work after param update

Message ID 6114f7d2699147186adf70c4e82a9a22de7a78aa.1604444952.git.asml.silence@gmail.com (mailing list archive)
State New, archived
Headers show
Series fixes for btrfs async discards | expand

Commit Message

Pavel Begunkov Nov. 4, 2020, 9:45 a.m. UTC
After sysfs updates discard's iops_limit or kbps_limit it also needs to
adjust current timer through rescheduling, otherwise the discard work
may wait for a long time for the previous timer to expier or bumped by
someone else.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 fs/btrfs/sysfs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Josef Bacik Nov. 4, 2020, 9 p.m. UTC | #1
On 11/4/20 4:45 AM, Pavel Begunkov wrote:
> After sysfs updates discard's iops_limit or kbps_limit it also needs to
> adjust current timer through rescheduling, otherwise the discard work
> may wait for a long time for the previous timer to expier or bumped by
> someone else.
> 
> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef
diff mbox series

Patch

diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 279d9262b676..65410d3939f2 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -433,7 +433,8 @@  static ssize_t btrfs_discard_iops_limit_store(struct kobject *kobj,
 		return -EINVAL;
 
 	WRITE_ONCE(discard_ctl->iops_limit, iops_limit);
-
+	btrfs_discard_calc_delay(discard_ctl);
+	btrfs_discard_schedule_work(discard_ctl, true);
 	return len;
 }
 BTRFS_ATTR_RW(discard, iops_limit, btrfs_discard_iops_limit_show,
@@ -463,7 +464,7 @@  static ssize_t btrfs_discard_kbps_limit_store(struct kobject *kobj,
 		return -EINVAL;
 
 	WRITE_ONCE(discard_ctl->kbps_limit, kbps_limit);
-
+	btrfs_discard_schedule_work(discard_ctl, true);
 	return len;
 }
 BTRFS_ATTR_RW(discard, kbps_limit, btrfs_discard_kbps_limit_show,