Created
May 10, 2011 09:55
-
-
Save orimanabu/964201 to your computer and use it in GitHub Desktop.
Send SCSI-3 Persistent Reserve/Release command using sg_persist
This file contains hidden or 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
#!/bin/sh | |
# Send SCSI-3 Persistent Reserve/Release command using sg_persist | |
# Inspired by http://www.redhat.com/archives/cluster-devel/2006-June/msg00084.html | |
# eg1. send SCSI Persistent Reserve to /dev/sde, | |
# where type of PROUT is "exclusive access - registrants only" | |
# $ sudo ./scsi_pr.sh reserve /dev/sde 6 | |
# eg2. send SCSI Persistent Release to /dev/sde, | |
# where type of PROUT is "exclusive access - registrants only" | |
# $ sudo ./scsi_pr.sh release /dev/sde 6 | |
if [ x"$#" != x"3" ]; then | |
echo "$0 cmd dev type" | |
exit 1 | |
fi | |
cmd=$1; shift | |
dev=$1; shift | |
type=$1; shift | |
key=$(gethostip -x $(uname -n)) | |
echo "cmd=${cmd}, key=${key}, type=${type}" | |
echo "==> initial state" | |
sg_persist -d ${dev} -i -k | |
case ${cmd} in | |
reserve) | |
echo "===> step 2" | |
sg_persist -d ${dev} -o -G -S ${key} | |
echo "===> step 3" | |
sg_persist -d ${dev} -o -R -K ${key} -T ${type} | |
;; | |
release) | |
echo "===> step 2" | |
sg_persist -d ${dev} -o -L -K ${key} -T ${type} | |
echo "===> step 3" | |
sg_persist -d ${dev} -o -G -K ${key} -S 0 | |
;; | |
*) | |
echo "unknown cmd: ${cmd}" | |
exit 1 | |
;; | |
esac | |
echo "==> result" | |
sg_persist -d ${dev} -i -k |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment