-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CA-309979 Fix Storage Manager initialisation
Now that we have xapi-init-complete.target, both mpathcount.service and usb-scan.service can wait until this point as there is no point to either of them until xapi can be notified of their results. In addition, ExecStartPost can be used in both cases to kick them once as soon as they come up, which makes the mpathroot init script obsolete. The sm-multipath init script is likewise incorrect and its reliance on systemd-sysv-generator coupled with its LSB header cause it to come up *after* network-online.target which is too late. Since it that there are non-init uses of this script, leave it alone for now but do not enable it (and disable it on upgrade). Replace its service function with the new oneshot sm-mpath-root.service which calls a simplified version. We should find and replace the non-init uses of /etc/rc.d/init.d/sm-multipath so that we can stop providing it entirely and eventually remove all use of INITDIR from Storage Manager Signed-off-by: Tim Smith <tim.smith@citrix.com>
- Loading branch information
1 parent
b7e346c
commit d84c81a
Showing
9 changed files
with
115 additions
and
133 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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,79 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (C) Citrix Systems Inc. | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser General Public License as published | ||
# by the Free Software Foundation; version 2.1 only. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with this program; if not, write to the Free Software Foundation, Inc., | ||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
# | ||
# Ensures the correct symlinks are present in /dev if rood device | ||
# is multipathed | ||
set -e | ||
MP_UTIL=/usr/sbin/mpathconf | ||
|
||
# | ||
# This block of functions is taken from dracut | ||
# | ||
find_block_device() { | ||
local rootdev blkdev fs type opts misc | ||
while read blkdev fs type opts misc; do | ||
[[ $blkdev = rootfs ]] && continue # skip rootfs entry | ||
[[ $fs = $1 ]] && { rootdev=$blkdev; break; } # we have a winner! | ||
done < /proc/mounts | ||
[[ -b $rootdev ]] || return 1 # oops, not a block device. | ||
# get major/minor for the device | ||
ls -nLl "$rootdev" | \ | ||
(read x x x x maj min x; maj=${maj//,/}; echo $maj:$min) | ||
} | ||
|
||
find_root_block_device() { find_block_device /; } | ||
|
||
find_root_wwid() { | ||
local rootdev blkdev fs type opts misc | ||
while read blkdev fs type opts misc; do | ||
[[ $blkdev = rootfs ]] && continue # skip rootfs entry | ||
[[ $fs = '/' ]] && { rootdev=$blkdev; break; } # we have a winner! | ||
done < /proc/mounts | ||
[[ -b $rootdev ]] || return 1 # oops, not a block device. | ||
/usr/lib/udev/scsi_id -g $rootdev | ||
} | ||
|
||
is_mpath() { | ||
[ -e /sys/dev/block/$1/dm/uuid ] || return 1 | ||
# we modified the matching pattern: ^mpath did not work | ||
[[ $(cat /sys/dev/block/$1/dm/uuid) =~ mpath- ]] && return 0 | ||
return 1 | ||
} | ||
|
||
# | ||
# End of block | ||
|
||
# We want to be sure multipathd is running with modules | ||
$MP_UTIL --enable --with_module y | ||
|
||
# Create an mpInuse symlink for the root device if that is multipath. | ||
ROOT_PART=$(find_root_block_device) | ||
if is_mpath $ROOT_PART; then | ||
ROOT_PART_MINOR=${ROOT_PART#[[:digit:]]*:} | ||
ROOT_PART_SLAVE=$(/bin/ls /sys/block/dm-$ROOT_PART_MINOR/slaves) | ||
ROOT_DISK_MINOR=${ROOT_PART_SLAVE#dm-} | ||
MPATH_NODES="$(dmsetup ls --target multipath --exec ls)" | ||
for n in $MPATH_NODES ; do | ||
# stat %T returns value in hex, convert to decimal before comparing | ||
NODE_MINOR="$((0x$(stat -L --format=%T $n)))" | ||
if [ "$ROOT_DISK_MINOR" = "$NODE_MINOR" ] ; then | ||
mkdir -p /dev/disk/mpInuse | ||
ln -sf $n /dev/disk/mpInuse | ||
fi | ||
done | ||
fi | ||
exit 0 |
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
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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
[Unit] | ||
Description=Multipath scanner | ||
Wants=xapi-init-complete.target | ||
After=xapi-init-complete.target | ||
|
||
[Service] | ||
StandardInput=socket | ||
StandardOutput=null | ||
StandardError=journal | ||
ExecStart=/usr/bin/sh -c '. /etc/xensource-inventory; while dd of=/dev/null bs=4096 count=1 status=none conv=noerror; do /opt/xensource/sm/mpathcount.py; done' | ||
ExecStartPost=/opt/xensource/libexec/kickpipe mpathcount | ||
Restart=always |
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,13 @@ | ||
[Unit] | ||
Description=Ensure symlinks for multipathed rootdev | ||
Wants=basic.target multipathd.service | ||
After=basic.target | ||
Before=multipathd.service | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=/opt/xensource/sm/multipath-root-setup | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
[Unit] | ||
Description=USB device scanner | ||
Wants=xapi-init-complete.target | ||
After=xapi-init-complete.target | ||
|
||
[Service] | ||
StandardInput=socket | ||
StandardOutput=null | ||
StandardError=journal | ||
ExecStart=/usr/bin/sh -c '. /etc/xensource-inventory; while dd of=/dev/null bs=4096 count=1 status=none conv=noerror; do /opt/xensource/bin/xe pusb-scan host-uuid=$${INSTALLATION_UUID}; done' | ||
ExecStartPost=/opt/xensource/libexec/kickpipe usb-scan | ||
Restart=always |