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

annunaki2k2 russell at knighton.me.uk
Sun Jun 1 12:16:05 UTC 2014


Public bug reported:

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.

** Affects: open-iscsi (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: patch

** Patch added: "Patch to sanity check the block device returned is valid."
   https://bugs.launchpad.net/bugs/1325359/+attachment/4123716/+files/umountiscsi.sh_no_block_association.patch

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to open-iscsi in Ubuntu.
https://bugs.launchpad.net/bugs/1325359

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

Status in “open-iscsi” package in Ubuntu:
  New

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.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/open-iscsi/+bug/1325359/+subscriptions



More information about the foundations-bugs mailing list