diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 546: sdmux fixes found while stress testing

Message ID 20130129042019.22599.8527.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Andy Doan Jan. 29, 2013, 4:20 a.m. UTC
Merge authors:
  Andy Doan (doanac)
Related merge proposals:
  https://code.launchpad.net/~doanac/lava-dispatcher/sdmux-fixes/+merge/145285
  proposed by: Andy Doan (doanac)
------------------------------------------------------------
revno: 546 [merge]
committer: Andy Doan <andy.doan@linaro.org>
branch nick: lava-dispatcher
timestamp: Mon 2013-01-28 22:19:10 -0600
message:
  sdmux fixes found while stress testing
modified:
  lava_dispatcher/device/sdmux.py
  lava_dispatcher/device/sdmux.sh


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_dispatcher/device/sdmux.py'
--- lava_dispatcher/device/sdmux.py	2013-01-16 23:27:28 +0000
+++ lava_dispatcher/device/sdmux.py	2013-01-28 23:59:47 +0000
@@ -46,6 +46,20 @@ 
 )
 
 
+def _flush_files(mntdir):
+    """
+    calls to umount can fail because the files haven't completely been written
+    to disk. This helps make sure that happens and eliminates a warning
+    """
+    for f in os.listdir('/proc/self/fd'):
+        # check for existances since listdir will include an fd for itself
+        if os.path.exists(f):
+            path = os.path.realpath('/proc/self/fd/%s' % f)
+            if path.startswith(mntdir):
+                os.fsync(int(f))
+                os.close(int(f))
+
+
 class SDMuxTarget(Target):
     """
     This adds support for the "sd mux" device. An SD-MUX device is a piece of
@@ -188,11 +202,12 @@ 
             finally:
                 logging.info('unmounting sdmux')
                 try:
+                    _flush_files(mntdir)
                     subprocess.check_call(['umount', device])
                 except subprocess.CalledProcessError:
-                    logging.exception('umount failed, re-try in 5 seconds')
-                    time.sleep(5)
-                    if subprocess.call(['umount', device]) == 0:
+                    logging.exception('umount failed, re-try in 10 seconds')
+                    time.sleep(10)
+                    if subprocess.call(['umount', device]) != 0:
                         logging.error(
                             'Unable to unmount sdmux device %s', device)
 

=== modified file 'lava_dispatcher/device/sdmux.sh'
--- lava_dispatcher/device/sdmux.sh	2013-01-04 00:03:43 +0000
+++ lava_dispatcher/device/sdmux.sh	2013-01-28 23:59:47 +0000
@@ -51,7 +51,7 @@ 
 			echo "<sdmux script> already on" 1>&2
 		else
 			echo -n "${ID}" > /sys/bus/usb/drivers/usb/bind
-			sleep 2
+			sleep 4
 		fi
 		device_path=`ls $DIR 2>/dev/null`
 		if [ $? -ne 0 ] ; then
@@ -63,7 +63,9 @@ 
 	elif [ $ACTION = "off" ] ; then
 		echo "<sdmux script> Powering off sdmux: $ID"
 		echo -n "${ID}" > /sys/bus/usb/drivers/usb/unbind
+		sleep 1
 		echo -n '0' > /sys/bus/usb/devices/$ID/power/autosuspend_delay_ms
+		sleep 1
 		echo -n 'auto' > /sys/bus/usb/devices/$ID/power/control
 		sleep 2
 	elif [ $ACTION = "deventry" ] ; then