Skip to content

Commit

Permalink
Merge b7a62e4 into 6b2d6df
Browse files Browse the repository at this point in the history
  • Loading branch information
rosslagerwall committed Mar 27, 2015
2 parents 6b2d6df + b7a62e4 commit edccf85
Show file tree
Hide file tree
Showing 22 changed files with 402 additions and 29 deletions.
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ SM_LIBS += B_util
SM_LIBS += wwid_conf
SM_LIBS += trim_util

UDEV_RULES = 40-multipath
UDEV_RULES = 39-multipath 40-multipath 55-xs-mpath-scsidev
MPATH_DAEMON = sm-multipath
MPATH_CONF = multipath.conf

Expand All @@ -74,6 +74,8 @@ PLUGIN_SCRIPT_DEST := /etc/xapi.d/plugins/
LIBEXEC := /opt/xensource/libexec/
CRON_DEST := /etc/cron.d/
UDEV_RULES_DIR := /etc/udev/rules.d/
UDEV_SCRIPTS_DIR := /etc/udev/scripts/
SYSTEMD_SERVICE_DIR := /usr/lib/systemd/system/
INIT_DIR := /etc/rc.d/init.d/
MPATH_CONF_DIR := /etc/multipath.xenserver/

Expand Down Expand Up @@ -121,7 +123,9 @@ install: precheck
$(call mkdir_clean,$(SM_STAGING))
mkdir -p $(SM_STAGING)$(SM_DEST)
mkdir -p $(SM_STAGING)$(UDEV_RULES_DIR)
mkdir -p $(SM_STAGING)$(UDEV_SCRIPTS_DIR)
mkdir -p $(SM_STAGING)$(INIT_DIR)
mkdir -p $(SM_STAGING)$(SYSTEMD_SERVICE_DIR)
mkdir -p $(SM_STAGING)$(MPATH_CONF_DIR)
mkdir -p $(SM_STAGING)$(DEBUG_DEST)
mkdir -p $(SM_STAGING)$(BIN_DEST)
Expand All @@ -135,6 +139,10 @@ install: precheck
$(SM_STAGING)/$(MPATH_CONF_DIR)
install -m 755 multipath/$(MPATH_DAEMON) \
$(SM_STAGING)/$(INIT_DIR)
install -m 755 drivers/updatempppathd.init \
$(SM_STAGING)/$(INIT_DIR)/updatempppathd
install -m 644 etc/make-dummy-sr.service \
$(SM_STAGING)/$(SYSTEMD_SERVICE_DIR)
for i in $(UDEV_RULES); do \
install -m 644 multipath/$$i.rules \
$(SM_STAGING)$(UDEV_RULES_DIR); done
Expand Down Expand Up @@ -173,6 +181,12 @@ install: precheck
install -m 755 -d $(SM_STAGING)$(CRON_DEST)
install -m 644 $(CRON_JOBS:%=etc/cron.d/%) -t $(SM_STAGING)$(CRON_DEST)
ln -sf $(SM_DEST)lcache.py $(SM_STAGING)$(BIN_DEST)tapdisk-cache-stats
ln -sf /dev/null $(SM_STAGING)$(UDEV_RULES_DIR)/62-multipath.rules
install -m 755 scripts/xs-mpath-scsidev.sh $(SM_STAGING)$(UDEV_SCRIPTS_DIR)
install -m 755 scripts/xe-get-arrayid-lunnum $(SM_STAGING)$(BIN_DEST)
install -m 755 scripts/xe-getarrayidentifier $(SM_STAGING)$(BIN_DEST)
install -m 755 scripts/xe-getlunidentifier $(SM_STAGING)$(BIN_DEST)
install -m 755 scripts/make-dummy-sr $(SM_STAGING)$(LIBEXEC)

.PHONY: clean
clean:
Expand Down
4 changes: 2 additions & 2 deletions drivers/blktap2.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ def __str__(self):
return "%s(minor=%d)" % (self.__class__.__name__, self.minor)

def sysfs_devname(self):
return "blktap%d" % self.minor
return "blktap!blktap%d" % self.minor

class Pool(Attribute):
SYSFS_NODENAME = "pool"
Expand Down Expand Up @@ -2023,7 +2023,7 @@ def __init__(self):
self._default_pool = None

def sysfs_devname(self):
return "blktap-control"
return "blktap!control"

class DefaultPool(Attribute):
SYSFS_NODENAME = "default_pool"
Expand Down
2 changes: 1 addition & 1 deletion drivers/iscsilib.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def restart_daemon():
if os.path.exists("/etc/init.d/open-iscsi"):
cmd = ["/etc/init.d/open-iscsi", "start"]
else:
cmd = ["service", "iscsid", "force-start"]
cmd = ["service", "iscsid", "start"]
failuremessage = "Failed to start iscsi daemon"
exn_on_failure(cmd,failuremessage)

Expand Down
2 changes: 1 addition & 1 deletion drivers/lvutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def createVG(root, vgname):
raise xs_errors.XenError('LVMWrite', \
opterr='device %s' % dev)
try:
cmd = [CMD_PVCREATE, "--metadatasize", "10M", dev]
cmd = [CMD_PVCREATE, "-ff", "-y", "--metadatasize", "10M", dev]
util.pread2(cmd)
except util.CommandException, inst:
raise xs_errors.XenError('LVMPartCreate', \
Expand Down
2 changes: 1 addition & 1 deletion drivers/mpath_dmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
DEVBYSCSIPATH = "/dev/disk/by-scsibus"
DEVBYMPPPATH = "/dev/disk/by-mpp"
SYSFS_PATH='/sys/class/scsi_host'
UMPD_PATH='/var/run/updatempppathd.pid'
UMPD_PATH='/var/run/updatempppathd.py.pid'
MP_INUSEDIR = "/dev/disk/mpInuse"

MPPGETAIDLNOBIN = "/opt/xensource/bin/xe-get-arrayid-lunnum"
Expand Down
4 changes: 2 additions & 2 deletions drivers/mpathcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ def get_path_count(SCSIid, active=True):
return count

def get_root_dev_major():
buf = os.stat('/dev/root')
devno = buf.st_rdev
buf = os.stat('/')
devno = buf.st_dev
return os.major(devno)

# @key: key to update
Expand Down
4 changes: 2 additions & 2 deletions drivers/scsiutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ def SCSIid_sanitise(str):

def getSCSIid(path):
dev = rawdev(path)
cmd_fallback = ["scsi_id", "-g", "-s", "/block/%s" % dev]
cmd_new = ["scsi_id", "-g", "--device", "/dev/%s" % dev]
cmd_fallback = ["/usr/lib/udev/scsi_id", "-g", "-s", "/block/%s" % dev]
cmd_new = ["/usr/lib/udev/scsi_id", "-g", "--device", "/dev/%s" % dev]
for cmd in cmd_new, cmd_fallback:
try:
scsi_id = SCSIid_sanitise(util.pread2(cmd)[:-1])
Expand Down
108 changes: 108 additions & 0 deletions drivers/updatempppathd.init
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#!/bin/bash
#
# /etc/rc.d/init.d/updatempppathd
#
# Starts the daemon which updates all MPP LUN paths
#
# chkconfig: 2345 19 76
# description: Manage the daemon which updates all MPP LUN paths
# processname: updatempppathd
# pidfile: /var/run/updatempppathd.py.pid

DAEMON=/opt/xensource/sm/updatempppathd.py
prog=`basename $DAEMON`
pidfile=/var/run/${prog}.pid
logfile=/var/log/SMlog

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

RETVAL=0

#
# See how we were called.
#

start() {
test -x $DAEMON || exit 5
if [ -f $pidfile ]; then
pid=`cat $pidfile`
ps -p $pid > /dev/null
if [ $? -eq 0 ]; then
echo "$prog already running with pid $pid"
return 0
else
rm $pidfile
fi
fi
echo -n $"Starting $prog daemon: "
daemon $DAEMON -d $logfile
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
# Wait a while so that we don't race with the process
# while it is doing a double-fork
sleep 5

for i in `pidof python`; do
line=`ps -h -p $i -o pid,command 2> /dev/null`
echo $line | grep $prog > /dev/null
if [ $? -eq 0 ]; then
echo $i > $pidfile
break
fi
done
success $"$base startup"
else
failure $"$base startup"
fi
echo
return $RETVAL
}

stop() {
echo -n $"Stopping $prog daemon: "
`test -e $pidfile`
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
PID=`cat $pidfile`
kill $PID
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f $pidfile
else
RETVAL=0
fi
[ $RETVAL -eq 0 ] && success $"$base stop" || failure $"$base stop"
echo
return $RETVAL
}

restart() {
stop
start
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
condrestart)
if [ -f $pidfile ]; then
restart
fi
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
RETVAL=3
esac

exit $RETVAL
13 changes: 5 additions & 8 deletions drivers/wwid_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def edit_wwid(wwid, remove=False):
shutil.move(tmp_file, CONF_FILE)

def is_blacklisted(dev):
"""This function returns 0 if the device is not blacklisted according
"""This function returns True if the device is blacklisted according
to multipath.conf rules.
It cannot be used to check the current daemon rules because it
Expand All @@ -83,18 +83,15 @@ def is_blacklisted(dev):
"""

(rc,stdout,stderr) = util.doexec(['/sbin/multipath','-c',dev])
(rc,stdout,stderr) = util.doexec(['/sbin/multipath','-v3','-c',dev])

# If the devices is truly blacklisted, there is nothing on stdout.
# If the devices is blacklisted according to multipath.conf, the
# string "wwid blacklisted" appears in the verbose output.
# This is a very fragile mechanism and keeps changing.
# What we want is a method to tell immediately if a device is
# blacklisted according only to configuration file rules regardless
# of daemon in-memory configuration.
# Current "multipath -c" takes into account multipath/wwids file
# but we do not care about it.
if len(stdout) != 0:
rc = 0
return rc != False
return "wwid blacklisted" in stdout


def check_conf_file():
Expand Down
11 changes: 11 additions & 0 deletions etc/make-dummy-sr.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Make a dummy SR if necessary
DefaultDependencies=no
After=local-fs.target
Before=basic.target

[Service]
ExecStart=/opt/xensource/libexec/make-dummy-sr

[Install]
WantedBy=basic.target
18 changes: 17 additions & 1 deletion mk/sm.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ License: LGPL
URL: http://www.citrix.com
Source0: sm-@SM_VERSION@.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: python-devel xen-devel
BuildRequires: python-devel xen-devel systemd
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd

%description
This package contains storage backends used in XCP
Expand All @@ -30,6 +33,7 @@ rm -rf $RPM_BUILD_ROOT
[ ! -x /sbin/chkconfig ] || chkconfig --add mpathroot
[ ! -x /sbin/chkconfig ] || chkconfig --add sm-multipath
service sm-multipath start
%systemd_post make-dummy-sr.service

[ -f /etc/lvm/lvm.conf.orig ] || cp /etc/lvm/lvm.conf /etc/lvm/lvm.conf.orig || exit $?
[ -d /etc/lvm/master ] || mkdir /etc/lvm/master || exit $?
Expand All @@ -48,13 +52,15 @@ update-alternatives --install /etc/multipath.conf multipath.conf /etc/multipath.

%preun
[ ! -x /sbin/chkconfig ] || chkconfig --del sm-multipath
%systemd_preun make-dummy-sr.service
#only remove in case of erase (but not at upgrade)
if [ $1 -eq 0 ] ; then
update-alternatives --remove multipath.conf /etc/multipath.xenserver/multipath.conf
fi
exit 0

%postun
%systemd_postun make-dummy-sr.service
[ ! -d /etc/lvm/master ] || rm -Rf /etc/lvm/master || exit $?
cp -f /etc/lvm/lvm.conf.orig /etc/lvm/lvm.conf || exit $?

Expand All @@ -63,6 +69,8 @@ cp -f /etc/lvm/lvm.conf.orig /etc/lvm/lvm.conf || exit $?
/etc/cron.d/*
/etc/rc.d/init.d/snapwatchd
/etc/rc.d/init.d/mpathroot
/etc/rc.d/init.d/updatempppathd
/etc/udev/scripts/xs-mpath-scsidev.sh
/etc/xapi.d/plugins/coalesce-leaf
/etc/xapi.d/plugins/lvhd-thin
/etc/xapi.d/plugins/nfs-on-slave
Expand All @@ -75,10 +83,14 @@ cp -f /etc/lvm/lvm.conf.orig /etc/lvm/lvm.conf || exit $?
/etc/xensource/master.d/02-vhdcleanup
/opt/xensource/bin/blktap2
/opt/xensource/bin/tapdisk-cache-stats
/opt/xensource/bin/xe-getarrayidentifier
/opt/xensource/bin/xe-get-arrayid-lunnum
/opt/xensource/bin/xe-getlunidentifier
/opt/xensource/debug/tp
/opt/xensource/libexec/check-device-sharing
/opt/xensource/libexec/dcopy
/opt/xensource/libexec/local-device-change
/opt/xensource/libexec/make-dummy-sr
/opt/xensource/sm/DummySR
/opt/xensource/sm/DummySR.py
/opt/xensource/sm/DummySR.pyc
Expand Down Expand Up @@ -268,7 +280,11 @@ cp -f /etc/lvm/lvm.conf.orig /etc/lvm/lvm.conf || exit $?
/opt/xensource/sm/wwid_conf.pyo
/sbin/mpathutil
/etc/rc.d/init.d/sm-multipath
%{_unitdir}/make-dummy-sr.service
%config /etc/udev/rules.d/39-multipath.rules
%config /etc/udev/rules.d/40-multipath.rules
%config /etc/udev/rules.d/55-xs-mpath-scsidev.rules
%config /etc/udev/rules.d/62-multipath.rules
%config /etc/multipath.xenserver/multipath.conf


Expand Down
Loading

0 comments on commit edccf85

Please sign in to comment.