IB/srp: Make writing the add_target sysfs attr interruptible
authorBart Van Assche <bart.vanassche@sandisk.com>
Mon, 21 Nov 2016 21:58:18 +0000 (13:58 -0800)
committerDoug Ledford <dledford@redhat.com>
Wed, 14 Dec 2016 18:31:47 +0000 (13:31 -0500)
Avoid that shutdown of srp_daemon is delayed if add_target_mutex is
held by another process.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/ulp/srp/ib_srp.c

index bb9d73daadfafdb738346323584d69097c3ef371..8ddc071231931157ec459a6db4a0947d7b05f539 100644 (file)
@@ -3299,7 +3299,9 @@ static ssize_t srp_create_target(struct device *dev,
         */
        scsi_host_get(target->scsi_host);
 
-       mutex_lock(&host->add_target_mutex);
+       ret = mutex_lock_interruptible(&host->add_target_mutex);
+       if (ret < 0)
+               goto put;
 
        ret = srp_parse_options(buf, target);
        if (ret)
@@ -3455,6 +3457,7 @@ connected:
 out:
        mutex_unlock(&host->add_target_mutex);
 
+put:
        scsi_host_put(target->scsi_host);
        if (ret < 0)
                scsi_host_put(target->scsi_host);