[BCACHE] Forcing the PD controller to follow the disks activity time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi.

I wrote this shell script for get a low dirty data size, and a low cache/backing devices overload.

This script sets a low or very low writeback rate for medium or medium hight disks activity time.
And set medium writeback rate for very low disks activity time.

Then some information is printed in the standard output because this script is executed every second by an applet that displays the information in the user's desktop.

P.S. If this strategy was placed inside bcache, it should set the maximum writeback rate, and the PD controller should be more aggressive with the mimum writeback.


#!/bin/bash

bkDev="sdb"
chDev="nvme"
sysBcBase="/sys/block"

bcDev=`find /sys/block/$bkDev/ | grep -e 'bcache[0-9,a-z,A-Z]\{1,\}' | sed -e 's/.*\///'`
sysBcDev="$sysBcBase/$bcDev/bcache"

bkUsage="0"
chUsage="0"

echo -e "Device: $bcDev"


    while read diskLine
    do
#echo $diskLine >> /tmp/grrr.txt
	read diskName diskUsage  < <(echo $diskLine | sed -e 's/\([0-9,a-z]\{1,\}\).* \([0-9]\{1,\}\)/\1 \2/')

	if [ $(expr "$diskName" : "$bkDev") != 0 ]; then
	    bkUsage=$diskUsage
    	elif [ $(expr "$diskName" : "$chDev") != 0 ]; then
	    chUsage=$diskUsage
	fi
	
	echo -e "Device: $diskName\tUsage: $diskUsage"
    done < <(iostat -dmx --dec=0 -y 1 1 | grep -e "$bkDev\|$chDev")


attWBRateMin=$(cat $sysBcDev/writeback_rate_minimum)
newWBrateMin=$attWBRateMin

if [ "$bkUsage" -le "10" ] && [ "$chUsage" -le "10" ]; then
    if [ "$attWBRateMin" -lt "50000" ]; then
	newWBrateMin=50000;
    fi
elif [ "$bkUsage" -le "20" ] && [ "$chUsage" -le "20" ]; then
    newWBrateMin=10000;
elif [ "$bkUsage" -le "40" ] && [ "$chUsage" -le "40" ]; then
    newWBrateMin=100;
elif [ "$attWBRateMin" -ge "10" ]; then
    newWBrateMin=10;
fi

if [ "$newWBrateMin" != "$attWBRateMin" ]; then echo $newWBrateMin > $sysBcDev/writeback_rate_minimum; fi

echo -e "bkUsage: $bkUsage\tchUsage: $chUsage"
echo -en "Dirty: $(cat $sysBcDev/dirty_data)"
echo -en "   Rate: $(cat $sysBcDev/writeback_rate)"
echo -en "   R.Min: $(cat $sysBcDev/writeback_rate_minimum)\n"



echo -e "$(cat $sysBcDev/writeback_rate_debug)"












[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux ARM Kernel]     [Linux Filesystem Development]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux