forked from facebookarchive/flashcache
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | 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 |