profiles: do not disable barriers on devices with write back cache
Resolves: #801561
This commit is contained in:
parent
9e8f670095
commit
64b45e8a04
4 changed files with 53 additions and 64 deletions
|
|
@ -5,15 +5,7 @@
|
|||
start() {
|
||||
set_cpu_governor performance
|
||||
enable_transparent_hugepages
|
||||
|
||||
# Find non-root and non-boot partitions, disable barriers on them
|
||||
rootvol=$(df -h / | grep "^/dev" | awk '{print $1}')
|
||||
bootvol=$(df -h /boot | grep "^/dev" | awk '{print $1}')
|
||||
volumes=$(df -hl --exclude=tmpfs | grep "^/dev" | awk '{print $1}')
|
||||
|
||||
nobarriervols=$(echo "$volumes" | grep -v $rootvol | grep -v $bootvol)
|
||||
remount_partitions nobarrier $nobarriervols
|
||||
|
||||
disable_disk_barriers
|
||||
multiply_disk_readahead 4
|
||||
|
||||
return 0
|
||||
|
|
@ -22,15 +14,7 @@ start() {
|
|||
stop() {
|
||||
restore_cpu_governor
|
||||
restore_transparent_hugepages
|
||||
|
||||
# Find non-root and non-boot partitions, re-enable barriers
|
||||
rootvol=$(df -h / | grep "^/dev" | awk '{print $1}')
|
||||
bootvol=$(df -h /boot | grep "^/dev" | awk '{print $1}')
|
||||
volumes=$(df -hl --exclude=tmpfs | grep "^/dev" | awk '{print $1}')
|
||||
|
||||
nobarriervols=$(echo "$volumes" | grep -v $rootvol | grep -v $bootvol)
|
||||
remount_partitions barrier $nobarriervols
|
||||
|
||||
enable_disk_barriers
|
||||
multiply_disk_readahead 0.25
|
||||
|
||||
return 0
|
||||
|
|
|
|||
|
|
@ -59,16 +59,6 @@ multiply_disk_readahead() {
|
|||
done
|
||||
}
|
||||
|
||||
# usage: remount_disk options partition1 partition2 ...
|
||||
remount_partitions() {
|
||||
options=$1
|
||||
shift
|
||||
|
||||
for partition in $@; do
|
||||
mount -o remount,$options $partition
|
||||
done
|
||||
}
|
||||
|
||||
DISK_QUANTUM_SAVE="/var/run/tuned/disk_quantum.save"
|
||||
|
||||
set_disk_scheduler_quantum() {
|
||||
|
|
@ -88,6 +78,53 @@ restore_disk_scheduler_quantum() {
|
|||
fi
|
||||
}
|
||||
|
||||
_devices_no_write_back_cache() {
|
||||
for device in $@; do
|
||||
grep -q "write back" /sys/block/"$device"/device/scsi_disk/*/cache_type 2>/dev/null && return 1
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
_disk_barriers_remount() {
|
||||
mount_options="$1"
|
||||
|
||||
lsblk -lno TYPE,KNAME,MOUNTPOINT | \
|
||||
awk '
|
||||
{ type=$1; name=$2; mountpoint=$3; }
|
||||
|
||||
(type == "disk") {
|
||||
device=name
|
||||
next
|
||||
}
|
||||
|
||||
(mountpoint ~ /^\// && mountpoint != "/" && mountpoint != "/boot") {
|
||||
mountpoints[mountpoint] = mountpoints[mountpoint] " " device
|
||||
}
|
||||
|
||||
END {
|
||||
for (mountpoint in mountpoints) {
|
||||
print mountpoint, mountpoints[mountpoint]
|
||||
}
|
||||
}
|
||||
' | \
|
||||
while read mountpoint devices; do
|
||||
if _devices_no_write_back_cache $devices; then
|
||||
mount -o remount,"$mount_options" "$mountpoint"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# remounts all non-root and non-boot partitions with nobarrier option
|
||||
# SCSI drives with write back cache are skipped
|
||||
disable_disk_barriers() {
|
||||
_disk_barriers_remount nobarrier
|
||||
}
|
||||
|
||||
# see: disable_disk_barriers
|
||||
enable_disk_barriers() {
|
||||
_disk_barriers_remount barrier
|
||||
}
|
||||
|
||||
#
|
||||
# CPU tuning
|
||||
#
|
||||
|
|
|
|||
|
|
@ -5,15 +5,7 @@
|
|||
start() {
|
||||
set_cpu_governor performance
|
||||
enable_transparent_hugepages
|
||||
|
||||
# Find non-root and non-boot partitions, disable barriers on them
|
||||
rootvol=$(df -h / | grep "^/dev" | awk '{print $1}')
|
||||
bootvol=$(df -h /boot | grep "^/dev" | awk '{print $1}')
|
||||
volumes=$(df -hl --exclude=tmpfs | grep "^/dev" | awk '{print $1}')
|
||||
|
||||
nobarriervols=$(echo "$volumes" | grep -v $rootvol | grep -v $bootvol)
|
||||
remount_partitions nobarrier $nobarriervols
|
||||
|
||||
disable_disk_barriers
|
||||
multiply_disk_readahead 4
|
||||
|
||||
return 0
|
||||
|
|
@ -22,15 +14,7 @@ start() {
|
|||
stop() {
|
||||
restore_cpu_governor
|
||||
restore_transparent_hugepages
|
||||
|
||||
# Find non-root and non-boot partitions, re-enable barriers
|
||||
rootvol=$(df -h / | grep "^/dev" | awk '{print $1}')
|
||||
bootvol=$(df -h /boot | grep "^/dev" | awk '{print $1}')
|
||||
volumes=$(df -hl --exclude=tmpfs | grep "^/dev" | awk '{print $1}')
|
||||
|
||||
nobarriervols=$(echo "$volumes" | grep -v $rootvol | grep -v $bootvol)
|
||||
remount_partitions barrier $nobarriervols
|
||||
|
||||
enable_disk_barriers
|
||||
multiply_disk_readahead 0.25
|
||||
|
||||
return 0
|
||||
|
|
|
|||
|
|
@ -5,15 +5,7 @@
|
|||
start() {
|
||||
set_cpu_governor performance
|
||||
enable_transparent_hugepages
|
||||
|
||||
# Find non-root and non-boot partitions, disable barriers on them
|
||||
rootvol=$(df -h / | grep "^/dev" | awk '{print $1}')
|
||||
bootvol=$(df -h /boot | grep "^/dev" | awk '{print $1}')
|
||||
volumes=$(df -hl --exclude=tmpfs | grep "^/dev" | awk '{print $1}')
|
||||
|
||||
nobarriervols=$(echo "$volumes" | grep -v $rootvol | grep -v $bootvol)
|
||||
remount_partitions nobarrier $nobarriervols
|
||||
|
||||
disable_disk_barriers
|
||||
multiply_disk_readahead 4
|
||||
|
||||
return 0
|
||||
|
|
@ -22,15 +14,7 @@ start() {
|
|||
stop() {
|
||||
restore_cpu_governor
|
||||
restore_transparent_hugepages
|
||||
|
||||
# Find non-root and non-boot partitions, re-enable barriers
|
||||
rootvol=$(df -h / | grep "^/dev" | awk '{print $1}')
|
||||
bootvol=$(df -h /boot | grep "^/dev" | awk '{print $1}')
|
||||
volumes=$(df -hl --exclude=tmpfs | grep "^/dev" | awk '{print $1}')
|
||||
|
||||
nobarriervols=$(echo "$volumes" | grep -v $rootvol | grep -v $bootvol)
|
||||
remount_partitions barrier $nobarriervols
|
||||
|
||||
enable_disk_barriers
|
||||
multiply_disk_readahead 0.25
|
||||
|
||||
return 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue