Package: enhanceio Version: 0+git20130620-1 Severity: wishlist Hello,
I have writen a quick'n'dirty init script for EnhanceIO. On start, it checks if EnhanceIO may have been active already by looking for its udev script. If not, if sources its configuration from /etc/default/enhanceio and brings up the cache. On stop, it switches the cache to read-only and blocks till all changes have been written to disk. Afterwards it deletes the cache. Cheers, Unki -- System Information: Debian Release: 7.3 APT prefers stable APT policy: (990, 'stable') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 3.2.0-4-amd64 (SMP w/3 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash
# /etc/default/enhanceio # define cache using the following syntax # # SRCDEV,CACHEDEV,MODE,NAME # # - SRCDEV source device that shall be cached # - CACHEDEV device to be used as cache # - MODE wb (writeback), wt (writethru) or ro (read-only) # - NAME a name for the cache # # multiple caches can be enter separated by a blank" # # Example: CACHES="/dev/sdb,/dev/sdc,wb,ssdcache1 /dev/sdd,/dev/sde/ro,ssdcache2" CACHES="/dev/sdb,/dev/sdc,wb,ssdcache" # if you want to change some of the default values of EnhanceIO # uncomment what you need # Dirty high threshold (%) : The upper limit on percentage of dirty blocks in the entire cache. DIRTY_HIGH_THRESHOLD=10 # Dirty low threshold (%) : The lower limit on percentage of dirty blocks in the entire cache. DIRTY_LOW_THRESHOLD=2 # Dirty set high threshold (%) : The upper limit on percentage of dirty blocks in a set. DIRTY_SET_HIGH_THRESHOLD=50 # Dirty set low threshold (%) : The lower limit on percentage of dirty blocks in a set. DIRTY_SET_LOW_THRESHOLD=10 # Time based clean-up interval (minutes) : This option allows you to specify an interval between each clean-up process. TIME_BASED_CLEAN_INTERVAL=1
#!/bin/bash # # Written by Andreas Unterkircher <u...@netshadow.at>. ### BEGIN INIT INFO # Provides: enhanceio # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Should-Start: # Should-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: EnhanceIO SSD Caching # Description: a software to use a SSD drive as read/write cache ### END INIT INFO set -e test -x /usr/sbin/eio_cli || exit 0 . /lib/lsb/init-functions [ -f /etc/default/enhanceio ] && . /etc/default/enhanceio start_enhanceio() { if [ -f /etc/udev/rules.d/94-enhanceio-ssdcache.rules ]; then log_progress_msg "looks like udev is doing our job" return fi for CACHE in "$CACHES"; do IFS=, read SRCDEV CACHEDEV MODE NAME <<< "$CACHE" log_progress_msg "($NAME) caching $SRCDEV on $CACHEDEV in mode $MODE" /usr/sbin/eio_cli create -d $SRCDEV -s $CACHEDEV -m $MODE -c $NAME if [ ! -z $DIRTY_HIGH_THRESHOLD ]; then sysctl -w dev.enhanceio.$NAME.dirty_high_threshold=$DIRTY_HIGH_THRESHOLD fi if [ ! -z $DIRTY_LOW_THRESHOLD ]; then sysctl -w dev.enhanceio.$NAME.dirty_low_threshold=$DIRTY_LOW_THRESHOLD fi if [ ! -z $DIRTY_SET_HIGH_THRESHOLD ]; then sysctl -w dev.enhanceio.$NAME.dirty_set_high_threshold=$DIRTY_SET_HIGH_THRESHOLD fi if [ ! -z $DIRTY_SET_LOW_THRESHOLD ]; then sysctl -w dev.enhanceio.$NAME.dirty_set_low_threshold=$DIRTY_SET_LOW_THRESHOLD fi if [ ! -z $TIME_BASED_CLEAN_INTERVAL ]; then sysctl -w dev.enhanceio.$NAME.time_based_clean_interval=$TIME_BASED_CLEAN_INTERVAL fi done } stop_enhanceio() { test -d /proc/enhanceio || exit 0; for CACHE in `ls -1d /proc/enhanceio/*`; do CACHENAME=`basename $CACHE` if [ "${CACHENAME}" == "version" ]; then continue; fi log_progress_msg "disabling $CACHENAME" /usr/sbin/eio_cli edit -c $CACHENAME -m ro /usr/sbin/eio_cli delete -c $CACHENAME done } status() { test -d /proc/enhanceio || ( echo "EnhanceIO not loaded"; exit 1; ) for CACHE in `ls -1d /proc/enhanceio/*`; do CACHENAME=`basename $CACHE` if [ "${CACHENAME}" == "version" ]; then continue; fi STATE=`grep ^state $CACHE/config | awk '{ print $2 }'` log_action_begin_msg "state $CACHENAME: " if [ "$STATE" != "normal" ]; then log_action_end_msg 1 "$STATE" else log_action_end_msg 0 "ok" fi done } case "$1" in start) log_daemon_msg "Starting EnhanceIO" start_enhanceio log_end_msg 0 ;; stop) log_daemon_msg "Stopping EnhanceIO" stop_enhanceio log_end_msg 0 ;; restart) log_daemon_msg "Stopping EnhanceIO for restart" stop_exim log_end_msg 0 sleep 2 log_daemon_msg "Restarting EnhanceIO" start_exim log_end_msg 0 ;; status) status ;; *) echo "Usage: $0 {start|stop|restart|status}" exit 1 ;; esac exit 0 # vim:tabstop=2:expandtab:shiftwidth=2