Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Flashcache init script - basic
Browse files Browse the repository at this point in the history
  • Loading branch information
boopathi committed Sep 22, 2012
1 parent 140990e commit 2ce099e
Showing 1 changed file with 91 additions and 0 deletions.
91 changes: 91 additions & 0 deletions utils/flashcache
100644 → 100755
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/bin/bash
#
# flashcache Init Script to manage cachedev loads
#
# chkconfig: 345 90 10
# description: Flashcache Management

# Flashcache options
# modify this before using this init script

SSD_DISK=
BACKEND_DISK=
CACHEDEV_NAME=
MOUNTPOINT=
FLASHCACHE_NAME=

# Just a check, to validate the above params are set
[ -n $SSD_DISK ] || exit 10
[ -n $BACKEND_DISK ] || exit 11
[ -n $CACHEDEV_NAME ] || exit 12
[ -n $MOUNTPOINT ] || exit 13
[ -n $FLASHCACHE_NAME ] || exit 14

# Source function library.
. /etc/rc.d/init.d/functions

RETVAL=0

start() {
echo "Starting Flashcache..."
#Load the module
/sbin/modprobe flashcache
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
echo "Module Load Error: flashcache. Exited with status - $RETVAL"
exit $RETVAL
fi
#flashcache_load the cachedev
/sbin/flashcache_load $SSD_DISK $CACHEDEV_NAME
RETVAL=$?
if [ $RETVAl -ne 0 ]; then
echo "Failed: flashcache_load $SSD_DISK $CACHEDEV_NAME"
exit $RETVAL;
fi
#mount
if [ -L /dev/mapper/$CACHEDEV_NAME ]; then
/bin/mount /dev/mapper/$CACHEDEV_NAME $MOUNTPOINT
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
echo "Mount Failed: /dev/mapper/$CACHEDEV_NAME to $MOUNTPOINT"
exit $RETVAL
fi
else
echo "Not Found: /dev/mapper/$CACHEDEV_NAME"
exit 1
fi
#lock subsys
touch /var/lock/subsys/flashcache
}

stop() {
#unmount
/bin/umount $MOUNTPOINT
/sbin/sysctl -w dev.flashcache.$FLASHCACHE_NAME.fast_remove=0
echo "Flushing flashcache: Flushes to $BACKEND_DISK"
dmsetup remove $CACHEDEV_NAME
#unlock subsys
rm -f /var/lock/subsys/flashcache
}

status() {
[ -f /var/lock/subsys/flashcache ] && echo "Flashcache status: loaded" || echo "Flashcache status: NOT loaded";
exit 0
}

case $1 in
start)
start
;;
stop)
stop
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|status}"
exit 1
esac

exit 0

0 comments on commit 2ce099e

Please sign in to comment.