btrfs-progs icon indicating copy to clipboard operation
btrfs-progs copied to clipboard

scrub start: set bwlimit using cgroups or systemd-start

Open kdave opened this issue 4 years ago • 11 comments

Bandwidth limit per device can be set by systemd-run -p IOBandwidthReadMax=/dev/sdx 10M' btrfs scrub start -B / . The cgroup2 is set up on systems by default.

  • document that this can be used for bandwidth limiting
  • provide an option to run that transparently
  • document sysfs bwlimit (kernel 5.14) as a fallback

kdave avatar Sep 15 '21 19:09 kdave

Now documented, there's a new command btrfs scrub limit to show the limits, setting will be possible in the future too.

kdave avatar Dec 08 '23 17:12 kdave

IIUC, the scrub IO is carried out from the actual btrfs-prog process? (I.e. no deferral to kthreads.)

When a scrub thread waits for IO, can it possibly (exclusively) hold any (btr)fs locks?

Werkov avatar Dec 20 '23 09:12 Werkov

No, the user space part of scrub starts an ioctl and all the io is done by kernel, running from the user process context, ie. no kthread. The locks are managed by kernel and user space cannot interfere with that.

kdave avatar Jan 04 '24 18:01 kdave

user space cannot interfere with that.

No argument about that. But the holder could be waiting (longer) for a throttled IO. Or are locks released before issuing the IO?

Edit: I only want to warn about possible "propagation" of the throttling via a shared lock to other FS users. If there is no such lock, this throttling likely nails the issue of too greedy scrub.

Werkov avatar Jan 04 '24 18:01 Werkov

I haven't found any logic that would block threads outside of scrub. It's running from its own context and the throttling happens on the IO submission, no big locks are held there for a long time (other than to set up data for io, like any other regular io). The special case of device replace can hold some locks longer but still during the setup phase.

kdave avatar Jan 29 '24 22:01 kdave