Advertisement
ddeineka

modified /etc/init.d/flashcache for using with LVM volume

Oct 9th, 2013
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # flashcache Init Script to manage cachedev loads
  4. #
  5. # chkconfig: 345 9 98
  6. # description: Flashcache Management
  7.  
  8. # Flashcache options
  9. # modify this before using this init script
  10.  
  11. SSD_DISK=/dev/sdc
  12. BACKEND_DISK=/dev/md127
  13. CACHEDEV_NAME=flashcache0
  14. MOUNTPOINT=/kvm
  15. FLASHCACHE_NAME=sdc+md127
  16.  
  17. # Just a check, to validate the above params are set
  18. [ -z "$SSD_DISK" ] && exit 10
  19. [ -z "$BACKEND_DISK" ] && exit 11
  20. [ -z "$CACHEDEV_NAME" ] && exit 12
  21. [ -z "$MOUNTPOINT" ] && exit 13
  22. [ -z "$FLASHCACHE_NAME" ] && exit 14
  23.  
  24. # Source function library.
  25. . /etc/rc.d/init.d/functions
  26.  
  27. #globals
  28. DMSETUP=`/usr/bin/which dmsetup`
  29. SERVICE=flashcache
  30. FLASHCACHE_LOAD=/sbin/flashcache_load
  31. SUBSYS_LOCK=/var/lock/subsys/$SERVICE
  32.  
  33. RETVAL=0
  34.  
  35. start() {
  36. echo "Starting Flashcache..."
  37. #Load the module
  38. /sbin/modprobe flashcache
  39. RETVAL=$?
  40. if [ $RETVAL -ne 0 ]; then
  41. echo "Module Load Error: flashcache. Exited with status - $RETVAL"
  42. exit $RETVAL
  43. fi
  44. #flashcache_load the cachedev
  45. $FLASHCACHE_LOAD $SSD_DISK $CACHEDEV_NAME
  46. RETVAL=$?
  47. if [ $RETVAL -ne 0 ]; then
  48. echo "Failed: flashcache_load $SSD_DISK $CACHEDEV_NAME"
  49. exit $RETVAL;
  50. fi
  51. #mount
  52. if [ -L /dev/mapper/$CACHEDEV_NAME ]; then
  53. RETVAL=$?
  54. ## /bin/mount /dev/mapper/$CACHEDEV_NAME $MOUNTPOINT
  55. ## RETVAL=$?
  56. ## if [ $RETVAL -ne 0 ]; then
  57. ## echo "Mount Failed: /dev/mapper/$CACHEDEV_NAME to $MOUNTPOINT"
  58. ## exit $RETVAL
  59. ## fi
  60. else
  61. echo "Not Found: /dev/mapper/$CACHEDEV_NAME"
  62. exit 1
  63. fi
  64. #lock subsys
  65. touch $SUBSYS_LOCK
  66. }
  67.  
  68. stop() {
  69. #unmount
  70. # /bin/umount $MOUNTPOINT
  71. #check for force flag
  72. FLAG=0
  73. [ "$1" == '--force' ] && FLAG=1
  74. /sbin/sysctl -w dev.flashcache.$FLASHCACHE_NAME.fast_remove=$FLAG
  75. echo "Flushing flashcache: Flushes to $BACKEND_DISK"
  76. $DMSETUP remove $CACHEDEV_NAME
  77. #unlock subsys
  78. rm -f $SUBSYS_LOCK
  79. }
  80.  
  81. status() {
  82. [ -f $SUBSYS_LOCK ] && echo "Flashcache status: loaded" || echo "Flashcache status: NOT loaded";
  83. $DMSETUP status $CACHEDEV_NAME
  84. exit $?
  85. }
  86. case $1 in
  87. start)
  88. start
  89. ;;
  90. stop)
  91. stop
  92. ;;
  93. status)
  94. status
  95. ;;
  96. forcestop)
  97. stop --force
  98. ;;
  99. *)
  100. echo "Usage: $0 {start|stop|status}"
  101. exit 1
  102. esac
  103.  
  104. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement