From: Hannes Reinecke <hare@suse.de>
Subject: kernel crash in netlink_broadcast
References: bnc#620654,bnc#600043
Patch-Mainline: N/A

During I/O stress tests EMC ran into this kernel crash in
dequeue_task(), invoked from:

Call Trace: <IRQ> <ffffffff8012dc57>{sys_sched_yield+93}
       <ffffffff802a7c49>{netlink_broadcast+877}
       <ffffffff88038266>{:scsi_mod:scsi_check_sense+375}
       <ffffffff880384b5>{:scsi_mod:scsi_decide_disposition+197}
       <ffffffff8803a883>{:scsi_mod:scsi_softirq_done+42}
       <ffffffff801f1a71>{blk_done_softirq+119}

Rather than trying to figure out why the error occured during task
scheduling it's actually easier to disable the scsi sense netlink
messages altogether, as they are rarely used anyway.
Long-term we should probably switch to using a work queue for
these type of events to get them out of the fast path, but
for now this will do.

This patch adds a module parameter 'scsi_sense_events', defaulting
to 0. If set to '1' netlink messages for sense events will be enabled.

Signed-off-by: Hannes Reinecke <hare@suse.de>

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 41266ec..0ad844d 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -218,6 +218,11 @@ static inline void scsi_eh_prt_fail_stats(struct Scsi_Host *shost,
 #endif
 
 #ifdef CONFIG_SCSI_NETLINK
+int scsi_sense_events = 0;
+
+module_param(scsi_sense_events, int, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(scsi_sense_events, "Post SCSI sense codes via netlink");
+
 /**
  * scsi_post_sense_event - called to post a 'Sense Code' event
  *
@@ -238,6 +243,9 @@ static void scsi_post_sense_event(struct scsi_device *sdev,
 	u32 len, skblen;
 	int err;
 
+	if (!scsi_sense_events)
+		return;
+
 	if (!scsi_nl_sock) {
 		err = -ENOENT;
 		goto send_fail;
