Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 146457 Details for
Bug 212265
lvm'd multipath'd iscsi luns don't shutdown properly
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
Latest script to remove all iscsi based dm device maps
iscsi-remove-maps.sh (text/plain), 5.19 KB, created by
Dave Wysochanski
on 2007-01-24 20:34:26 UTC
(
hide
)
Description:
Latest script to remove all iscsi based dm device maps
Filename:
MIME Type:
Creator:
Dave Wysochanski
Created:
2007-01-24 20:34:26 UTC
Size:
5.19 KB
patch
obsolete
>#!/bin/sh ># ># NOTE: logic borrowed from various other sources > ># ># Description: Determine whether passed in device is either one of the ># devices in the passed in array, or is part of a dm device ># map that has one of these special devices at a leaf node ># in the dm tree ># ># Parameters: ># $1 - device in question, in the following format: "major:minor" ># $2 - array of special devices to check; each entry is kernel name, ># e.g. "sda" ># ># Return Values: ># 1 - is a special device in the array, or is part of dm map that contains ># one of these special devices as a leaf node ># 0 - not in the array of special devices, and not part of a dm map with ># any of the special devices at leaf nodes ># ># FIXME: needs to return an array of dependencies so we can use "dmsetup remove" ># on them in the right order ># >is_special_or_in_special_map() >{ > dev_mm=$1 > special_dev_names=$2 > > # > # First, check to see if this is a dm-device. If it is, we need > # to go through the tree to a leaf node > # > major=`echo $dev_mm | awk -F ":" '{ print $1 }'` > minor=`echo $dev_mm | awk -F ":" '{ print $2 }'` > dmcmd=`dmsetup deps -j $major -m $minor >& /dev/null` > # > # FIXME: Catch potential infinite recursion > # > # one danger here would be infinite recursion if, for some reason, > # the above dmsetup cmd would always return success... > # For this reason, we might want to consider a max depth variable > # or some other infinite recursion technique > # > if [ $? -eq 0 ]; then > # This is a dm device > # dependencies line looks like this: > # # dmsetup deps iscsi--vg0-iscsi--stripe--lv0 > # 3 dependencies : (253, 2) (253, 3) (253, 4) > deps=`dmsetup deps -j $major -m $minor | perl -ne 'if (/^\d+\s*dependencies\s*:\s*(.*)/) { $x = $1; $x =~ tr/[(,)]/[ , ]/; $x =~ s/,\s+/:/g; print $x; }'` > for dep in $deps; do > # need recursion here > is_special_or_in_special_map $dep $special_dev_names > if [ $? -eq 1 ]; then > return 1 > fi > done > # if we get here, then we know we are not an iscsi device or dm > # device with iscsi dependencies > return 0 > fi > > # > # Ok, leaf node, so check to see if it's iscsi > # > # FIXME: inefficient since we're going through all sd's > # Might be some fancy way we could use grep to do one compare... > # > this_special=`cat /proc/partitions | grep -E "^[ \t]+$major[ \t]+$minor[ \t]+" | awk '{ print $4 }'` > i=0 > while [ $i -lt $no_special_devices ]; do > dev_name=${special_devices[$i]} > if [ "$this_special" == "$dev_name" ]; then > return 1; > fi > let "i += 1" > done > > # no match found > return 0 >} > ># ># Description: Fill in a list of host ids for a given proc_name value ># ># Parameters: ># $1 - proc name to search for ># ># Return: ># array of host ids stored in 'host_ids' array ># >declare -a host_ids >SCSI_HOST=/sys/class/scsi_host >find_host_ids() >{ > name_to_find=$1 > i=0 > hosts=`ls -1 $SCSI_HOST/` > for host in $hosts; do > host=$SCSI_HOST/$host > proc_name=`cat $host/proc_name` > if [ "$proc_name" = "$name_to_find" ]; then > host_no=${host:${#SCSI_HOST} + 5} > host_ids[$i]=$host_no > let "i += 1" > fi > done >} > > ># ># Description: Fill in an array of special device names ># for a given proc_name value ># ># Parameters: ># $1 - proc name to search for ># ># Return: ># array of special device names stored in 'special_devices' array ># >declare -a special_devices >CLASS_PATH=/sys/class/iscsi_transport >find_special_devices() >{ > find_host_ids $1 > no_hosts=${#host_ids[*]} > i=0 > j=0 > while [ $i -lt $no_hosts ]; do > target=$CLASS_PATH/target${host_ids[$i]}:0:0 > > if [ -e $target ]; then > luns=`ls -d $target/device/${host_ids[$i]}:0:0* | sort --field-separator=: --key=6 -n 2> /dev/null` > for lun in $luns; do > if [ -h $lun/block ]; then > device=`ls -l $lun/block` > elif [ -h $lun/tape ]; then > device=`ls -l $lun/tape` > fi > if [ "$device" ]; then > device=`echo $device | awk -F ' ' '{print $NF}'` > device=${device##[.]*[/]} > special_devices[$j]=$device > let "j += 1" > fi > done > fi > let "i += 1" > done >} > > >deactivate_dms() >{ > maps=0 > dev_maps=`dmsetup table | awk '{print $1}' | sed -e "s/://"` > > echo "Searching for special maps" > for dev_map in $dev_maps; do > # check to see if "cat /sys/block/$dev_sd/dev" > # is an iscsi-based device map, and if so, save > # the "mpathN" device > major_minor=`dmsetup info $dev_map | grep "^Major, minor" | awk '{ print $3 ":" $4 }' | tr -d ","` > is_special_or_in_special_map $major_minor $special_devices > if [ $? -eq 1 ]; then > echo dmsetup remove tree $dev_map > let "maps += 1" > else > echo $dev_map _IS NOT_ in special devices array or part of dm map > fi > done > echo "Found" $maps "maps" >} > ># ># Find iscsi devices. We'll use these later to ># determine which dm maps have iscsi at a leaf node ># >find_special_devices "iscsi-sfnet" >no_special_devices=${#special_devices[*]} > > ># ># Now get a list of dm device maps and go through them ># listing which ones are iscsi based. For each iscsi-based ># dm map, we need to remove the map from the top of the ># tree down to the iscsi node. This is a bit tricky. ># >deactivate_dms >echo Found $no_special_devices iscsi devices > > > > ># list devices - debug code >#i=0 >#while [ $i -lt $no_special_devices ]; do ># echo ${special_devices[$i]} ># let "i += 1" >#done
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 212265
:
139412
|
139417
|
139418
|
139480
|
145748
|
145749
|
146233
|
146264
|
146457
|
411163
|
411399