"umountiscsi.sh" tries to unmount "/" root partition on "service open-iscsi stop" command if no block device assigned to iscsi device!

Bug #1325359 reported by annunaki2k2
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
open-iscsi (Ubuntu)
New
Undecided
Unassigned

Bug Description

Whilst trying to debug open-iscsi on Trusty (because it doesn't appear to be allocating a block-device to iSCSI assocaitions out of the box - a separate issue), it became apparent that I could not simply stop the open-iscsi device because when you do, but when no block device is associated with the iscsi session, it tries to un-mount "/" and obviously fails:

shared iscsi # /etc/init.d/open-iscsi stop
 * Unmounting iscsi-backed filesystems umount: /: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
 * Could not unmount /
                                                                                                                                                                                                                                                                          [fail]
invoke-rc.d: initscript umountiscsi.sh, action "stop" failed.
 * Couldn't unmount all iSCSI devices. Cannot stop iSCSI service

The script responsible for this it "umountiscsi.sh", and installed as part of the open-iscsi package, and is run on stop by the init script to try and unmount any iscsi volumes before pulling down the iscsi daemon.

The section of code responsible is this:
    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`"
                        for DEVICE in $DOS_PARTITIONS; do
                                #log_progress_msg $DEVICE
                                #echo $DEVICE
                                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

I attach a very simple patch that fixes this - please include and push upstream.

Tags: patch
Revision history for this message
annunaki2k2 (russell-knighton) wrote :
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "Patch to sanity check the block device returned is valid." seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.