[Pkg-iscsi-maintainers] Bug#765431: open-iscsi: umountiscsi.sh script does not properly check while traverse sysfs structure

Ritesh Raj Sarraf rrs at researchut.com
Mon Oct 20 04:32:18 UTC 2014


Thanks for the detailed analysis. I'll look into it very soon.

s3nt fr0m a $martph0ne, excuse typ0s
On Oct 20, 2014 9:03 AM, "dmitry" <dmitry at bti.secna.ru> wrote:

> Hello !
> 17.10.2014 00:44, Ritesh Raj Sarraf пишет:
>
>> On Thursday 16 October 2014 09:10 AM, Dmitry Danilov wrote:
>>
>>>
>>>>      Yes, as I see, BLOCK_FILE variable should serves that.
>>>
>>
>> Sorry. But I'm not understanding this correct. Are  you saying we don't
>> need the
>> patch ?
>>
>> --
>> Ritesh Raj Sarraf
>> RESEARCHUT -http://www.researchut.com
>> "Necessity is the mother of invention."
>>
>>  I think we need a patch.
>
> Let's look at problem again:
>
> What we have:
>
> system:
>
> root at archive:~# uname -a
> Linux archive 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u3 x86_64 GNU/Linux
>
> root at archive:~# lsb_release -a
> No LSB modules are available.
> Distributor ID: Debian
> Description:    Debian GNU/Linux 7.6 (wheezy)
> Release:        7.6
> Codename:       wheezy
>
> mounted partitions:
>
> root at archive:~# mount
> sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
> proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
> udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_
> inodes=62130,mode=755)
> devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,
> gid=5,mode=620,ptmxmode=000)
> tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=50896k,mode=755)
> /dev/disk/by-uuid/51c02def-2358-4270-a76d-3161633a1b22 on / type ext4
> (rw,relatime,errors=remount-ro,user_xattr,barrier=1,data=ordered)
> tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
> tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,
> relatime,size=296960k)
> /dev/sdb1 on /mnt/sites_backup type ext4 (rw,relatime,user_xattr,acl,
> barrier=1,data=ordered,_netdev)
> /dev/sda1 on /mnt/sites_backup#2 type ext4 (rw,relatime,user_xattr,
> barrier=1,stripe=128,data=ordered,_netdev)
>
>
> Trying to restart|stop open-iscsi as if we have a new configured target:
>
> root at archive:~# /etc/init.d/open-iscsi restart
> [....] Unmounting iscsi-backed filesystems: Unmounting all devices marked
> _netdevumount: /: device is busy.
>         (In some cases useful info about processes that use
>          the device is found by lsof(8) or fuser(1))
> [warn] Could not unmount / ... (warning).
>  failed!
> invoke-rc.d: initscript umountiscsi.sh, action "stop" failed.
> [FAIL] Couldn't unmount all iSCSI devices. Cannot stop iSCSI service ...
> failed!
> root at archive:~#
>
> From initscript errors : umountiscsi trying to unmount "/" partition --
> Why?
>
> Inspect the situation:
>
> Adding -x parameter to umountiscsi.sh
>
> And try to restart service:
> root at archive:~# /etc/init.d/open-iscsi restart
>
> Look on exerpt output(full report in attached file):
>
> Here (the cause of problem):
> + [ -d /sys/devices/platform/host4/iscsi_host ]
> + [ -d /sys/devices/platform/host4/session1/target4:0:0 ]
> + sed s/.*block\///
> + echo /sys/devices/platform/host4/session1/target*/*:*/block/*
> + BLOCK_DEV=*
> + awk /^\/dev\/*/ { print $2; }
> + DOS_PARTITIONS=/
> + umount /
> umount: /: device is busy.
>         (In some cases useful info about processes that use
>          the device is found by lsof(8) or fuser(1))
> + exit_status=1
>
> I think, shell expansion leds to that, so that is why I suggest code to
> test BLOCK_DEV
> variable as empty 'directory' in sysfs i.e. :
>
> +                       if  ! [ -d $BLOCK_FILE ]; then
> +                               continue
> +                       fi
>
>
>
> And another view to the same problem:
>
> Code snippet for debug purposes (taken from 'umountiscsi.sh' file)
> contains only traverse sysfs section:
>
> root at archive:~# cat traverse.sh
>
> #!/bin/sh -x
>
>     for HOST_DIR in /sys/devices/platform/host*; do
> if ! [ -d $HOST_DIR/iscsi_host* ]; then
>     continue
> fi
>         for SESSION_DIR in $HOST_DIR/session*; do
>         if ! [ -d $SESSION_DIR/target* ]; then
>                 continue
>         fi
>         for BLOCK_FILE in $SESSION_DIR/target*/*\:*/block/*; do
>                 BLOCK_DEV=`echo "$BLOCK_FILE" | sed 's/.*block\///'`
>                 DOS_PARTITIONS="`awk "/^\/dev\/$BLOCK_DEV/ { print \\$2;
> }" < /proc/mounts`"
>                 echo DEBUG:${BLOCK_FILE}
>                 echo DEBUG:${DOS_PARTITIONS}
>                 for DEVICE in $DOS_PARTITIONS; do
>                         #log_progress_msg $DEVICE
>                         #echo $DEVICE
>                         echo umount ${DEVICE}
>                         exit_status=$?
>                         if ! [ $exit_status -eq 0 ]; then
>                                 umount_fail=1
>                                 log_warning_msg "Could not unmount $DEVICE"
>                         fi
>                 done
>         done
> done
>     done
>
> Output with trace mode i.e. bin/sh -x:
>
> root at archive:~# ./traverse.sh
> + [ -d /sys/devices/platform/host4/iscsi_host ]
> + [ -d /sys/devices/platform/host4/session1/target4:0:0 ]
> + sed s/.*block\///
> + echo /sys/devices/platform/host4/session1/target*/*:*/block/*
> + BLOCK_DEV=*
> + awk /^\/dev\/*/ { print $2; }
> + DOS_PARTITIONS=/
> + echo DEBUG:/sys/devices/platform/host4/session1/target*/*:*/block/*
> DEBUG:/sys/devices/platform/host4/session1/target*/*:*/block/*
> + echo DEBUG:/
> DEBUG:/
> + echo umount /
> umount /
> + exit_status=0
> + [ 0 -eq 0 ]
> + [ -d /sys/devices/platform/host5/iscsi_host ]
> + [ -d /sys/devices/platform/host5/session2/target5:0:0 ]
> + sed s/.*block\///
> + echo /sys/devices/platform/host5/session2/target5:0:0/5:0:0:0/block/sdb
> + BLOCK_DEV=sdb
> + awk /^\/dev\/sdb/ { print $2; }
> + DOS_PARTITIONS=
> + echo DEBUG:/sys/devices/platform/host5/session2/target5:0:0/5:
> 0:0:0/block/sdb
> DEBUG:/sys/devices/platform/host5/session2/target5:0:0/5:0:0:0/block/sdb
> + echo DEBUG:
> DEBUG:
> + [ -d /sys/devices/platform/host6/iscsi_host ]
> + [ -d /sys/devices/platform/host6/session3/target6:0:0 ]
> + sed s/.*block\///
> + echo /sys/devices/platform/host6/session3/target6:0:0/6:0:0:0/block/sda
> + BLOCK_DEV=sda
> + awk /^\/dev\/sda/ { print $2; }
> + DOS_PARTITIONS=
> + echo DEBUG:/sys/devices/platform/host6/session3/target6:0:0/6:
> 0:0:0/block/sda
> DEBUG:/sys/devices/platform/host6/session3/target6:0:0/6:0:0:0/block/sda
> + echo DEBUG:
> DEBUG:
> root at archive:~#
>
>
> Output without dash trace mode:
>
> root at archive:~# ./traverse.sh
> DEBUG:/sys/devices/platform/host4/session1/target*/*:*/block/*
> DEBUG:/
> umount /
> DEBUG:/sys/devices/platform/host5/session2/target5:0:0/5:0:0:0/block/sdb
> DEBUG:
> DEBUG:/sys/devices/platform/host6/session3/target6:0:0/6:0:0:0/block/sda
> DEBUG:
> root at archive:~#
>
> --
> Dmitry Danilov.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-iscsi-maintainers/attachments/20141020/2a24784b/attachment-0001.html>


More information about the Pkg-iscsi-maintainers mailing list