f7e20b2
From 68c07ef0b9d9731c040880e0db3570f48a85f9b8 Mon Sep 17 00:00:00 2001
f7e20b2
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
f7e20b2
Date: Fri, 28 Jan 2011 13:06:00 +0100
f7e20b2
Subject: [PATCH 47/61] wait for completion of any pending actions affecting device
f7e20b2
f7e20b2
Delay I/O operations until all pending requests against the common I/O layer
f7e20b2
have been completed. The kernel now provides /proc/cio_settle file and a write
f7e20b2
there will be blocked until all requests are completed.
f7e20b2
---
f7e20b2
 zconf/chccwdev   |    5 +++++
f7e20b2
 zconf/chchp      |    5 +++++
f7e20b2
 zconf/cio_ignore |    9 +++++++++
f7e20b2
 3 files changed, 19 insertions(+), 0 deletions(-)
f7e20b2
f7e20b2
diff --git a/zconf/chccwdev b/zconf/chccwdev
f7e20b2
index d2a697b..03985a1 100755
f7e20b2
--- a/zconf/chccwdev
f7e20b2
+++ b/zconf/chccwdev
f7e20b2
@@ -28,6 +28,7 @@
f7e20b2
 #==============================================================================
f7e20b2
 CMD=$(basename $0)
f7e20b2
 MAX_RETRIES=5
f7e20b2
+CIO_SETTLE="/proc/cio_settle"
f7e20b2
 
f7e20b2
 if [ "$(cat /proc/filesystems|grep sysfs)" = "" ]; then
f7e20b2
 	echo "ERROR: $CMD requires sysfs support!" >&2
f7e20b2
@@ -160,6 +161,10 @@ while [ $# -gt 0 ]; do
f7e20b2
 	shift
f7e20b2
 done
f7e20b2
 
f7e20b2
+if [ -w $CIO_SETTLE ] ; then
f7e20b2
+	echo 1 > $CIO_SETTLE
f7e20b2
+fi
f7e20b2
+
f7e20b2
 #
f7e20b2
 # Parse the BUSIDLIST and expand the ranges and short IDs.
f7e20b2
 #
f7e20b2
diff --git a/zconf/chchp b/zconf/chchp
f7e20b2
index 520ce3f..4a62579 100755
f7e20b2
--- a/zconf/chchp
f7e20b2
+++ b/zconf/chchp
f7e20b2
@@ -30,6 +30,7 @@ VERSION="%S390_TOOLS_VERSION%"
f7e20b2
 TOOLNAME=${0##*/}
f7e20b2
 MAX_CHPID_CSS=255
f7e20b2
 MAX_CHPID_ID=255
f7e20b2
+CIO_SETTLE="/proc/cio_settle"
f7e20b2
 
f7e20b2
 # Print help text
f7e20b2
 function print_help()
f7e20b2
@@ -408,3 +409,7 @@ for CHPID in $CHPID_LIST ; do
f7e20b2
 	get_chpid_id TO_ID $CHPID_TO
f7e20b2
 	loop_chpids $FROM_CSS $FROM_ID $TO_CSS $TO_ID perform_command
f7e20b2
 done
f7e20b2
+
f7e20b2
+if [ -w $CIO_SETTLE ] ; then
f7e20b2
+	echo 1 > $CIO_SETTLE
f7e20b2
+fi
f7e20b2
diff --git a/zconf/cio_ignore b/zconf/cio_ignore
f7e20b2
index 71dccb1..476c481 100755
f7e20b2
--- a/zconf/cio_ignore
f7e20b2
+++ b/zconf/cio_ignore
f7e20b2
@@ -8,6 +8,8 @@
f7e20b2
 
f7e20b2
 VERSION="%S390_TOOLS_VERSION%"
f7e20b2
 BLACKLIST="/proc/cio_ignore"
f7e20b2
+CIO_SETTLE="/proc/cio_settle"
f7e20b2
+WAIT_FOR_CIO=0
f7e20b2
 SYSINFO="/proc/sysinfo"
f7e20b2
 CONSDRV="/sys/bus/ccw/drivers/3215"
f7e20b2
 MAXCSSID=0
f7e20b2
@@ -706,9 +708,11 @@ while [ $# -gt 0 ] ; do
f7e20b2
 	-r|--remove)
f7e20b2
 		shift
f7e20b2
 		remove_device $1
f7e20b2
+		WAIT_FOR_CIO=1
f7e20b2
 		;;
f7e20b2
 	-R|--remove-all)
f7e20b2
 		remove_all_devices
f7e20b2
+		WAIT_FOR_CIO=1
f7e20b2
 		;;
f7e20b2
 	-l|--list)
f7e20b2
 		list_blacklisted 1
f7e20b2
@@ -724,6 +728,7 @@ while [ $# -gt 0 ] ; do
f7e20b2
 		;;
f7e20b2
 	-p|--purge)
f7e20b2
 		purge
f7e20b2
+		WAIT_FOR_CIO=1
f7e20b2
 		;;
f7e20b2
 	*)
f7e20b2
 		warn "invalid option '$1'"
f7e20b2
@@ -734,4 +739,8 @@ while [ $# -gt 0 ] ; do
f7e20b2
 	shift
f7e20b2
 done
f7e20b2
 
f7e20b2
+if [ \( -w $CIO_SETTLE \) -a $WAIT_FOR_CIO = 1 ] ; then
f7e20b2
+	echo 1 > $CIO_SETTLE
f7e20b2
+fi
f7e20b2
+
f7e20b2
 exit 0
f7e20b2
-- 
f7e20b2
1.7.3.5
f7e20b2