]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[S390] cio: introduce purge function for /proc/cio_ignore
authorPeter Oberparleiter <peter.oberparleiter@de.ibm.com>
Fri, 10 Oct 2008 19:33:06 +0000 (21:33 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Fri, 10 Oct 2008 19:33:47 +0000 (21:33 +0200)
Allow users to remove blacklisted ccw devices by using the
/proc/cio_ignore interface:

  echo purge > /proc/cio_ignore

will remove all devices which are offline and blacklisted.

Signed-off-by: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/cio/blacklist.c
drivers/s390/cio/device.c
drivers/s390/cio/device.h

index 0bfcbbe375c4b4640f50bf14e61ce1f6beae3062..2f547b840ef011f70fef2e559bd571d5b66d616e 100644 (file)
@@ -24,6 +24,7 @@
 #include "cio.h"
 #include "cio_debug.h"
 #include "css.h"
+#include "device.h"
 
 /*
  * "Blacklisting" of certain devices:
@@ -191,9 +192,9 @@ static int blacklist_parse_parameters(char *str, range_action action,
                        rc = blacklist_range(ra, from_ssid, to_ssid, from, to,
                                             msgtrigger);
                        if (rc)
-                               totalrc = 1;
+                               totalrc = -EINVAL;
                } else
-                       totalrc = 1;
+                       totalrc = -EINVAL;
        }
 
        return totalrc;
@@ -240,8 +241,10 @@ static int blacklist_parse_proc_parameters(char *buf)
                rc = blacklist_parse_parameters(buf, free, 0);
        else if (strcmp("add", parm) == 0)
                rc = blacklist_parse_parameters(buf, add, 0);
+       else if (strcmp("purge", parm) == 0)
+               return ccw_purge_blacklisted();
        else
-               return 1;
+               return -EINVAL;
 
        css_schedule_reprobe();
 
@@ -353,7 +356,7 @@ cio_ignore_write(struct file *file, const char __user *user_buf,
        }
        ret = blacklist_parse_proc_parameters(buf);
        if (ret)
-               rc = -EINVAL;
+               rc = ret;
        else
                rc = user_len;
 
index 38a79ecfc743edff2eaee6b746c4a16c2ec18796..8575d263b13e18b54c2f6957d615db37a930cd97 100644 (file)
@@ -31,6 +31,7 @@
 #include "device.h"
 #include "ioasm.h"
 #include "io_sch.h"
+#include "blacklist.h"
 
 static struct timer_list recovery_timer;
 static DEFINE_SPINLOCK(recovery_lock);
@@ -1470,6 +1471,45 @@ static void ccw_device_schedule_recovery(void)
        spin_unlock_irqrestore(&recovery_lock, flags);
 }
 
+static int purge_fn(struct device *dev, void *data)
+{
+       struct ccw_device *cdev = to_ccwdev(dev);
+       struct ccw_device_private *priv = cdev->private;
+       int unreg;
+
+       spin_lock_irq(cdev->ccwlock);
+       unreg = is_blacklisted(priv->dev_id.ssid, priv->dev_id.devno) &&
+               (priv->state == DEV_STATE_OFFLINE);
+       spin_unlock_irq(cdev->ccwlock);
+       if (!unreg)
+               goto out;
+       if (!get_device(&cdev->dev))
+               goto out;
+       CIO_MSG_EVENT(3, "ccw: purging 0.%x.%04x\n", priv->dev_id.ssid,
+                     priv->dev_id.devno);
+       PREPARE_WORK(&cdev->private->kick_work, ccw_device_call_sch_unregister);
+       queue_work(slow_path_wq, &cdev->private->kick_work);
+
+out:
+       /* Abort loop in case of pending signal. */
+       if (signal_pending(current))
+               return -EINTR;
+
+       return 0;
+}
+
+/**
+ * ccw_purge_blacklisted - purge unused, blacklisted devices
+ *
+ * Unregister all ccw devices that are offline and on the blacklist.
+ */
+int ccw_purge_blacklisted(void)
+{
+       CIO_MSG_EVENT(2, "ccw: purging blacklisted devices\n");
+       bus_for_each_dev(&ccw_bus_type, NULL, NULL, purge_fn);
+       return 0;
+}
+
 static void device_set_disconnected(struct ccw_device *cdev)
 {
        if (!cdev)
index 6f5c3f2b3587d8f72d98aa781f9f2cbd6dfd50d3..104ed669db43946a0656fe5adaac51a8374cc4f1 100644 (file)
@@ -86,6 +86,7 @@ int ccw_device_is_orphan(struct ccw_device *);
 int ccw_device_recognition(struct ccw_device *);
 int ccw_device_online(struct ccw_device *);
 int ccw_device_offline(struct ccw_device *);
+int ccw_purge_blacklisted(void);
 
 /* Function prototypes for device status and basic sense stuff. */
 void ccw_device_accumulate_irb(struct ccw_device *, struct irb *);