mirror of
https://codeberg.org/wonky/udev-usb-sync.git
synced 2024-09-19 23:30:37 +02:00
Added kernel minor to the factor
Only kernels above 6.1 supports strict_limit and max_bytes
This commit is contained in:
parent
9e8236c88b
commit
1fe2ddca75
2 changed files with 9 additions and 7 deletions
4
PKGBUILD
4
PKGBUILD
|
@ -1,7 +1,7 @@
|
||||||
# Maintainer: root.nix.dk
|
# Maintainer: root.nix.dk
|
||||||
pkgname='udev-usb-sync'
|
pkgname='udev-usb-sync'
|
||||||
pkgver=0.9
|
pkgver=0.10
|
||||||
pkgrel=3
|
pkgrel=1
|
||||||
pkgdesc='Fine tune write cache and impose buffer limits when USB storage device is plugged'
|
pkgdesc='Fine tune write cache and impose buffer limits when USB storage device is plugged'
|
||||||
arch=('any')
|
arch=('any')
|
||||||
url='https://codeberg.org/wonky/udev-usb-sync'
|
url='https://codeberg.org/wonky/udev-usb-sync'
|
||||||
|
|
|
@ -42,21 +42,23 @@ CONFIG='/etc/udev-usb-sync/udev-usb-sync.conf'
|
||||||
BLOCKDEVICE="$1"
|
BLOCKDEVICE="$1"
|
||||||
SPEED="$2"
|
SPEED="$2"
|
||||||
KERNEL_MAJOR_VERSION=$(uname -r | awk -F'.' '{print $1}')
|
KERNEL_MAJOR_VERSION=$(uname -r | awk -F'.' '{print $1}')
|
||||||
|
KERNEL_MINOR_VERSION=$(uname -r | awk -F'.' '{print $2}')
|
||||||
|
|
||||||
# disable write cache for device if possible
|
# disable write cache for device if possible
|
||||||
[[ -n $(which hdparm) ]] && $(which hdparm) -W 0 /dev/$BLOCKDEVICE
|
[[ -n $(which hdparm) ]] && $(which hdparm) -W 0 /dev/$BLOCKDEVICE > /dev/null
|
||||||
|
|
||||||
if [[ $KERNEL_MAJOR_VERSION -le 5 ]]; then
|
if [[ $KERNEL_MAJOR_VERSION -le 6 ]]; then
|
||||||
# the following rules is introduced with kernel 2.6
|
# the following rules is introduced with kernel 2.6
|
||||||
# https://docs.kernel.org/admin-guide/abi-testing.html#abi-sys-class-bdi-bdi-max-ratio
|
# https://docs.kernel.org/admin-guide/abi-testing.html#abi-sys-class-bdi-bdi-max-ratio
|
||||||
|
|
||||||
# 1% of available RAM -> 8046522kB -> 80.465kB -> 80MB
|
# 1% of available RAM -> 8046522kB -> 80.465kB -> 80MB
|
||||||
echo 1 > /sys/block/$BLOCKDEVICE/bdi/max_ratio
|
echo 1 > /sys/block/$BLOCKDEVICE/bdi/max_ratio
|
||||||
elif [[ $KERNEL_MAJOR_VERSION -ge 6 ]]; then
|
elif [[ $KERNEL_MAJOR_VERSION -ge 6 ]] && [[ $KERNEL_MINOR_VERSION -ge 2 ]]; then
|
||||||
# the following rules is introduced with kernel 6.1
|
# the following rules is introduced with kernel 6.2
|
||||||
# https://docs.kernel.org/admin-guide/abi-testing.html#abi-sys-class-bdi-bdi-strict-limit
|
# https://docs.kernel.org/admin-guide/abi-testing.html#abi-sys-class-bdi-bdi-strict-limit
|
||||||
# https://docs.kernel.org/admin-guide/abi-testing.html#abi-sys-class-bdi-bdi-max-bytes
|
# https://docs.kernel.org/admin-guide/abi-testing.html#abi-sys-class-bdi-bdi-max-bytes
|
||||||
|
|
||||||
|
# Turning strictlimit on has no visible effect if max_ratio is equal to 100%.
|
||||||
|
echo 50 > /sys/block/$BLOCKDEVICE/bdi/max_ratio
|
||||||
# apply strict limit
|
# apply strict limit
|
||||||
echo 1 > /sys/block/$BLOCKDEVICE/bdi/strict_limit
|
echo 1 > /sys/block/$BLOCKDEVICE/bdi/strict_limit
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue