Mercurial > illumos > illumos-gate
changeset 4073:245d7a4f5220
6546164 stmsboot does not remove sun4u SMF service, erroneously lists parallel SCSI hbas
author | jmcp |
---|---|
date | Thu, 19 Apr 2007 17:27:52 -0700 |
parents | 3b30e48bc1a6 |
children | 58874e1ba2ef |
files | usr/src/cmd/stmsboot/stmsboot.sh usr/src/cmd/stmsboot/stmsboot_util.c |
diffstat | 2 files changed, 92 insertions(+), 60 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/stmsboot/stmsboot.sh Thu Apr 19 17:02:25 2007 -0700 +++ b/usr/src/cmd/stmsboot/stmsboot.sh Thu Apr 19 17:27:52 2007 -0700 @@ -24,6 +24,7 @@ # Use is subject to license terms. # #ident "%Z%%M% %I% %E% SMI" +# PATH=/usr/bin:/usr/sbin:$PATH; export PATH STMSBOOTUTIL=/lib/mpxio/stmsboot_util @@ -52,6 +53,11 @@ SORT=/usr/bin/sort UNIQ=/usr/bin/uniq EXPR=/usr/bin/expr +SED=/usr/bin/sed +SVCPROP=/usr/bin/svcprop +SVCCFG=/usr/sbin/svccfg +SVCS=/usr/bin/svcs +SVCADM=/usr/sbin/svcadm MACH=`/usr/bin/uname -p` BOOTENV_FILE=/boot/solaris/bootenv.rc @@ -139,7 +145,7 @@ echo "\tcp /mnt${SAVEDIR}/$DRVCONF /mnt$KDRVCONF" >> $RECOVERFILE fi - if [ $1 -ne 0 ]; then + if [ $1 -eq 1 ]; then echo "\tcp /mnt${SAVEDIR}/vfstab /mnt$VFSTAB" >> $RECOVERFILE echo "repository /mnt/etc/svc/repository.db" > $SVCCFG_RECOVERY @@ -147,7 +153,7 @@ echo "setprop general/enabled=false" >> $SVCCFG_RECOVERY echo "exit" >> $SVCCFG_RECOVERY - echo "\t/usr/sbin/svccfg -f /mnt$SVCCFG_RECOVERY" >> $RECOVERFILE + echo "\t$SVCCFG -f /mnt$SVCCFG_RECOVERY" >> $RECOVERFILE if [ "x$MACH" = "xi386" -a "x$new_bootpath" != "x" ]; then echo "\tcp /mnt${SAVEDIR}/bootenv.rc /mnt$BOOTENV_FILE" >> $RECOVERFILE @@ -181,7 +187,9 @@ return 0; fi - need_bootscript="" + # set need_bootscript to the number of drivers that + # we support. + need_bootscript=`echo $SUPPORTED_DRIVERS|$AWK -F"|" '{print NF}'` if [ "x$cmd" = xenable -o "x$cmd" = xdisable ]; then @@ -191,8 +199,14 @@ TMPDRVCONF=/var/run/tmp.$d.conf.$$ cp $KDRVCONF $SAVEDIR - cp $TMPDRVCONF $KDRVCONF - rm -f $TMPDRVCONF > /dev/null 2>&1 + if [ -f $TMPDRVCONF ]; then + cp $TMPDRVCONF $KDRVCONF + rm -f $TMPDRVCONF + else + # if $TMPDRVCONF doesn't exist, then we + # haven't made any changes to it + continue; + fi # # there is no need to update the system files in the following @@ -203,7 +217,13 @@ # disks accessible by vhci paths. # - build_parent_list $d; + # Function to setup the CLIENT_TYPE_PHCI string based on + # the list of drivers that we're operating on. The variable + # depends upon the pathname of the parent node in the + # device tree, which can be different on x86/x64 and sparc. + + CLIENT_TYPE_PHCI=`$STMSBOOTUTIL -D $d -n`; + if [ "x$CLIENT_TYPE_PHCI" = "x" ]; then continue; fi @@ -217,7 +237,7 @@ fi if [ $? -ne 0 ]; then - need_bootscript="$need_bootscript $d" + need_bootscript=`$EXPR $need_bootscript - 1` fi done fi @@ -239,7 +259,6 @@ # in /kernel/drv/fp.conf. EXISTP=`$GREP "^name.*$NNEWP" /kernel/drv/fp.conf` -# if [ -z "$EXISTP" ]; then if [ $? != 0 ]; then cat >>/kernel/drv/fp.conf << EOF # This entry must be the last one in the fp.conf file @@ -251,8 +270,8 @@ fi fi - if [ -z "$need_bootscript" ]; then - need_bootscript=0 + if [ $need_bootscript -gt 0 ]; then + need_bootscript=1 if [ "x$MACH" = "xi386" -a "x$new_bootpath" != "x" ]; then #only update bootpath for x86. cp $BOOTENV_FILE $SAVEDIR @@ -263,11 +282,13 @@ # The service will run during the next reboot and will do # the actual job of modifying the system files. # - svcadm disable -t $STMSINSTANCE - svccfg -f - << EOF + $SVCADM disable -t $STMSINSTANCE + $SVCCFG -f - << EOF select $STMSINSTANCE setprop general/enabled = true EOF + else + need_bootscript=0 fi build_recover $need_bootscript @@ -411,11 +432,14 @@ # for each driver that we support, grab the list # of controllers attached to the system. + echo "" echo "WARNING: stmsboot operates on each supported multipath-capable controller" echo " detected in a host. In your system, these controllers are" - for WARNDRV in fp mpt; do - $GREP "$WARNDRV.$" /etc/path_to_inst | $AWK -F"\"" '{print "/devices"$2}' + for WARNDRV in `echo $SUPPORTED_DRIVERS| $SED -e"s,|, ,g"`; do + for i in `$STMSBOOTUTIL -D $WARNDRV -n | $SED -e"s,|, ,g"`; do + $GREP "$i.*$WARNDRV.$" /etc/path_to_inst | $AWK -F"\"" '{print "/devices"$2}' + done; done; echo "" @@ -423,38 +447,16 @@ echo "and re-invoke with -D { fp | mpt } to specify which controllers you wish" echo "to modify your multipathing configuration for." - echo + echo "" gettext "Do you wish to continue? [y/n] (default: y) " 1>&2 read response - if [ "x$response" -ne "xY" -a "x$response" -ne "xy" ]; then + if [ "x$response" != "xY" -a "x$response" != "xy" ]; then exit fi } -# Function to setup the CLIENT_TYPE_PHCI string based on -# the list of drivers that we're operating on. The variable -# depends upon the pathname of the parent node in the -# device tree, which can be different on x86/x64 and sparc. -# Oh, if we only had OBP on x86/x64! -build_parent_list() { - - # stmsboot_util -n provides us with the name of the - # node containing "fp" or "sas-$d", and helpfully - # appends "/[ssd|sd]@" as appropriate - - d=$1; - - TLIST=`$STMSBOOTUTIL -D $d -n` - if [ "x$TLIST" != "x" ]; then - CLIENT_TYPE_PHCI="$TLIST|$CLIENT_TYPE_PHCI" - else - CLIENT_TYPE_PHCI="$CLIENT_TYPE_PHCI" - fi -} - - cmd=none # process options @@ -501,16 +503,16 @@ fi # If the old sun4u-specific SMF method is found, remove it -/usr/sbin/svccfg -s "platform/sun4u/mpxio-upgrade:default" < /dev/null > /dev/null 2>&1 -if [ $? -ne 0 ]; then - /usr/sbin/svccfg delete "platform/sun4u/mpxio-upgrade:default" > /dev/null 2>&1 +$SVCCFG -s "platform/sun4u/mpxio-upgrade:default" < /dev/null > /dev/null 2>&1 +if [ $? -eq 0 ]; then + $SVCCFG delete "platform/sun4u/mpxio-upgrade:default" > /dev/null 2>&1 fi # now import the new service, if necessary -/usr/bin/svcprop -q $STMSINSTANCE < /dev/null > /dev/null 2>&1 +$SVCPROP -q $STMSINSTANCE < /dev/null > /dev/null 2>&1 if [ $? -ne 0 ]; then if [ -f /var/svc/manifest/system/device/mpxio-upgrade.xml ]; then - /usr/sbin/svccfg import /var/svc/manifest/system/device/mpxio-upgrade.xml + $SVCCFG import /var/svc/manifest/system/device/mpxio-upgrade.xml if [ $? -ne 0 ]; then fmt=`gettext "Unable to import %s service"` printf "$fmt\n" "$STMSINSTANCE" 1>&2 @@ -536,6 +538,31 @@ exit 1 fi + # if the user has left the system with the mpxio-upgrade service + # in a temporarily disabled state (ie, service is armed for the next + # reboot), then let them know. We need to ensure that the system is + # is in a sane state before allowing any further invocations, so + # try to get the system admin to do so + + ISARMED=`$SVCS -l $STMSINSTANCE |$GREP "enabled.*temporary"` + if [ $? -eq 0 ]; then + echo "" + echo "You need the reboot the system in order to complete" + echo "the previous invocation of stmsboot." + echo "" + echo "Do you wish to reboot the system now? (y/n, default y) \c" + read response + + if [ "x$response" = "xY" -o "x$response" = "xy" ]; then + /usr/sbin/reboot + else + /bin/echo "" + /bin/echo "Please reboot this system before continuing" + /bin/echo "" + exit 1 + fi + fi + if [ -d $SAVEDIR ]; then # # keep a copy of the last saved files, useful for manual
--- a/usr/src/cmd/stmsboot/stmsboot_util.c Thu Apr 19 17:02:25 2007 -0700 +++ b/usr/src/cmd/stmsboot/stmsboot_util.c Thu Apr 19 17:27:52 2007 -0700 @@ -57,17 +57,14 @@ #ifdef sparc #define DISK_NODE_NAME "ssd" #define DISK_DRV_NAME "ssd" -#define SLASH_DISK_AT "/ssd@" #else /* sparc */ #define DISK_NODE_NAME "disk" #define DISK_DRV_NAME "sd" -#define SLASH_DISK_AT "/disk@" #endif #define DISK_AT_G "disk@g" #define SLASH_FP_AT "/fp@" #define SLASH_SCSI_VHCI "/scsi_vhci" -#define SLASH_SD_AT "/sd@" #define DEV_DSK "/dev/dsk/" #define DEV_RDSK "/dev/rdsk/" #define SYS_FILENAME_LEN 256 @@ -376,6 +373,7 @@ } clean_exit(0); + /*NOTREACHED*/ } /* @@ -1682,7 +1680,7 @@ /* * This function traverses the device tree looking for nodes * which have "drivername" as a property. We return a list of - * these nodes, with SLASH_DISK_AT appended. + * these nodes, without duplicate entries. * Since there can be many different pci/pcie devices that all * share the same driver but which have different pci vid/did * combinations, we have to be smart about returning only those @@ -1692,12 +1690,14 @@ static void list_nodes(char *drivername) { - char *aliaslist; - char *mpxprop = NULL; di_node_t devroot = DI_NODE_NIL; di_node_t thisnode = DI_NODE_NIL; + char *aliaslist; + char *iitype = NULL; /* the "initiator-interconnect-type" property */ int *intprop = NULL; int i = 1; /* fencepost */ + int irval = 0; + int crval = 0; /* * Since the "fp" driver enumerates with its own name, @@ -1728,31 +1728,36 @@ di_node_name(thisnode)); /* We check the child node for drvprop */ - if ((di_prop_lookup_ints(DDI_DEV_T_ANY, - di_child_node(thisnode), drvprop, - &intprop) > -1) || - (((di_prop_lookup_strings(DDI_DEV_T_ANY, - thisnode, "mpxio-disable", &mpxprop) > -1) && - strcmp(di_driver_name(thisnode), - drivername)) == 0)) { + irval = di_prop_lookup_ints(DDI_DEV_T_ANY, + di_child_node(thisnode), drvprop, &intprop); + /* and this node for the correct initiator type */ + crval = di_prop_lookup_strings(DDI_DEV_T_ANY, + thisnode, "initiator-interconnect-type", &iitype); + + /* + * examine the return codes from di_prop_lookup*() + * functions to guard against library errors + */ + if ((irval > -1) || ((crval > -1) && + (strncmp(iitype, "SATA", 4) == 0))) { if (strstr(aliaslist, - di_node_name(thisnode)) - == (char *)NULL) { + di_node_name(thisnode)) == (char *)NULL) { char *nname; nname = di_node_name(thisnode); if (i) { (void) snprintf(aliaslist, - strlen(nname), "%s", nname); + strlen(nname) + 1, "%s", nname); --i; } else { if (strstr(aliaslist, di_node_name(thisnode)) == (char *)NULL) { + /* add 2 for the n-1 + "|" */ (void) snprintf(aliaslist, - strlen(nname) + + strlen(nname) + 2 + strlen(aliaslist), "%s|%s", aliaslist, nname);