summaryrefslogtreecommitdiff
path: root/fsck/system-bcachefsck.slice
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2023-12-04 18:43:31 -0800
committerKent Overstreet <kent.overstreet@linux.dev>2023-12-07 11:57:36 -0500
commitfbfdd05ac5b5b748cf9c7c0ea72be5268917c5d6 (patch)
tree478e759ed430c56b4a7f02c2ec26457efd3134e0 /fsck/system-bcachefsck.slice
parent5fa7db9806b1f7a082a0bcda8ba7b7beeb03bc61 (diff)
fsck: add systemd service definitions for automatic online service
Add some systemd service files so that bcachefs can automatically fsck mounted filesystems in the background. Hopefully with minimal disruption to frontend operations. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fsck/system-bcachefsck.slice')
-rw-r--r--fsck/system-bcachefsck.slice30
1 files changed, 30 insertions, 0 deletions
diff --git a/fsck/system-bcachefsck.slice b/fsck/system-bcachefsck.slice
new file mode 100644
index 00000000..ea368032
--- /dev/null
+++ b/fsck/system-bcachefsck.slice
@@ -0,0 +1,30 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (C) 2023-2024 Oracle. All Rights Reserved.
+# Author: Darrick J. Wong <djwong@kernel.org>
+
+[Unit]
+Description=bcachefsck background service slice
+Before=slices.target
+
+[Slice]
+
+# If the CPU usage cgroup controller is available, don't use more than 60% of a
+# single core for all background processes.
+CPUQuota=60%
+CPUAccounting=true
+
+[Install]
+# As of systemd 249, the systemd cgroupv2 configuration code will drop resource
+# controllers from the root and system.slice cgroups at startup if it doesn't
+# find any direct dependencies that require a given controller. Newly
+# activated units with resource control directives are created under the system
+# slice but do not cause a reconfiguration of the slice's resource controllers.
+# Hence we cannot put CPUQuota= into the bcachefsck service units directly.
+#
+# For the CPUQuota directive to have any effect, we must therefore create an
+# explicit definition file for the slice that systemd creates to contain the
+# bcachefsck instance units (e.g. bcachefsck@.service) and we must configure this
+# slice as a dependency of the system slice to establish the direct dependency
+# relation.
+WantedBy=system.slice