Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions btrfs-balance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ fi
LOGIDENTIFIER='btrfs-balance'
. $(dirname $(realpath "$0"))/btrfsmaintenance-functions

ioprio=
if [ "$BTRFS_BALANCE_PRIORITY" = "idle" ]; then
# ionice(3) idle proirity
ioprio="ionice -c 3"
fi

{
BTRFS_BALANCE_MOUNTPOINTS=$(expand_auto_mountpoint "$BTRFS_BALANCE_MOUNTPOINTS")
OIFS="$IFS"
Expand All @@ -33,26 +39,26 @@ for MM in $BTRFS_BALANCE_MOUNTPOINTS; do
df -H "$MM"

if detect_mixed_bg "$MM"; then
btrfs balance start -musage=0 -dusage=0 "$MM"
$ioprio btrfs balance start -musage=0 -dusage=0 "$MM"
# we use the MUSAGE values for both, supposedly less aggressive
# values, but as the data and metadata space is shared on
# mixed-bg this does not lead to the situations we want to
# prevent when the blockgroups are split (ie. underused
# blockgroups)
for BB in $BTRFS_BALANCE_MUSAGE; do
# quick round to clean up the unused block groups
btrfs balance start -v -musage=$BB -dusage=$BB "$MM"
$ioprio btrfs balance start -v -musage=$BB -dusage=$BB "$MM"
done
else
btrfs balance start -dusage=0 "$MM"
$ioprio btrfs balance start -dusage=0 "$MM"
for BB in $BTRFS_BALANCE_DUSAGE; do
# quick round to clean up the unused block groups
btrfs balance start -v -dusage=$BB "$MM"
$ioprio btrfs balance start -v -dusage=$BB "$MM"
done
btrfs balance start -musage=0 "$MM"
$ioprio btrfs balance start -musage=0 "$MM"
for BB in $BTRFS_BALANCE_MUSAGE; do
# quick round to clean up the unused block groups
btrfs balance start -v -musage="$BB" "$MM"
$ioprio btrfs balance start -v -musage="$BB" "$MM"
done
fi

Expand Down
8 changes: 8 additions & 0 deletions sysconfig.btrfsmaintenance
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ BTRFS_BALANCE_MOUNTPOINTS="/"
# Frequency of periodic balance.
BTRFS_BALANCE_PERIOD="weekly"

## Path: System/File systems/btrfs
## Type: string(idle,normal)
## Default: "idle"
#
# Priority of IO at which the balance process will run. Idle should not degrade
# performance as much as normal.
BTRFS_BALANCE_PRIORITY="normal"

## Path: System/File systems/btrfs
## Type: string
## Default: "1 5 10 20 30 40 50"
Expand Down