Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serial scrub for raid5 and raid6 devices #116

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
16 changes: 15 additions & 1 deletion btrfs-scrub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,21 @@ for MNT in $BTRFS_SCRUB_MOUNTPOINTS; do
echo "Path $MNT is not btrfs, skipping"
continue
fi
run_task btrfs scrub start -Bd $ioprio $readonly "$MNT"

if ! is_raid56 "$MNT"; then
echo "RAID level is not 5 or 6, parallel device scrubbing"
run_task btrfs scrub start -Bd $ioprio $readonly "$MNT"
else
echo "RAID level is 5 or 6, sequential device scrubbing"
for DEV in $(btrfs filesystem show "$MNT" | awk '/ path /{print $NF}')
do
run_task btrfs scrub start -Bd $ioprio $readonly "$DEV"
until btrfs scrub status "$DEV" | grep finished
do
sleep 5
done
done
fi
if [ "$?" != "0" ]; then
echo "Scrub cancelled at $MNT"
exit 1
Expand Down
10 changes: 10 additions & 0 deletions btrfsmaintenance-functions
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ is_btrfs() {
return 1
}

# function: is_raid56
# parameter: path to a mounted filesystem
#
# check if filesystem is on a RAID-5 or RAID-6
is_raid56() {
btrfs filesystem usage "$1" | grep Data,RAID5 && return 0
btrfs filesystem usage "$1" | grep Data,RAID6 && return 0
return 1
}

# function: btrfs_fsid
# parameter: path to a mounted filesystem
#
Expand Down