提交 b3589fd4 编写于 作者: M Matthew Wilcox 提交者: Roland Dreier

IB/srp: Change target_mutex to a spinlock

The SRP driver never sleeps while holding target_mutex, and it's just
used to protect some simple list operations, so hold times will be
short.  So just convert it to a spinlock, which is smaller and faster.
Signed-off-by: NMatthew Wilcox <matthew@wil.cx>
Signed-off-by: NRoland Dreier <rolandd@cisco.com>
上级 549c5fc2
...@@ -361,9 +361,9 @@ static void srp_remove_work(void *target_ptr) ...@@ -361,9 +361,9 @@ static void srp_remove_work(void *target_ptr)
target->state = SRP_TARGET_REMOVED; target->state = SRP_TARGET_REMOVED;
spin_unlock_irq(target->scsi_host->host_lock); spin_unlock_irq(target->scsi_host->host_lock);
mutex_lock(&target->srp_host->target_mutex); spin_lock(&target->srp_host->target_lock);
list_del(&target->list); list_del(&target->list);
mutex_unlock(&target->srp_host->target_mutex); spin_unlock(&target->srp_host->target_lock);
scsi_remove_host(target->scsi_host); scsi_remove_host(target->scsi_host);
ib_destroy_cm_id(target->cm_id); ib_destroy_cm_id(target->cm_id);
...@@ -1450,9 +1450,9 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target) ...@@ -1450,9 +1450,9 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
if (scsi_add_host(target->scsi_host, host->dev->dev->dma_device)) if (scsi_add_host(target->scsi_host, host->dev->dev->dma_device))
return -ENODEV; return -ENODEV;
mutex_lock(&host->target_mutex); spin_lock(&host->target_lock);
list_add_tail(&target->list, &host->target_list); list_add_tail(&target->list, &host->target_list);
mutex_unlock(&host->target_mutex); spin_unlock(&host->target_lock);
target->state = SRP_TARGET_LIVE; target->state = SRP_TARGET_LIVE;
...@@ -1724,7 +1724,7 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port) ...@@ -1724,7 +1724,7 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port)
return NULL; return NULL;
INIT_LIST_HEAD(&host->target_list); INIT_LIST_HEAD(&host->target_list);
mutex_init(&host->target_mutex); spin_lock_init(&host->target_lock);
init_completion(&host->released); init_completion(&host->released);
host->dev = device; host->dev = device;
host->port = port; host->port = port;
...@@ -1866,14 +1866,14 @@ static void srp_remove_one(struct ib_device *device) ...@@ -1866,14 +1866,14 @@ static void srp_remove_one(struct ib_device *device)
* Mark all target ports as removed, so we stop queueing * Mark all target ports as removed, so we stop queueing
* commands and don't try to reconnect. * commands and don't try to reconnect.
*/ */
mutex_lock(&host->target_mutex); spin_lock(&host->target_lock);
list_for_each_entry(target, &host->target_list, list) { list_for_each_entry(target, &host->target_list, list) {
spin_lock_irqsave(target->scsi_host->host_lock, flags); spin_lock_irqsave(target->scsi_host->host_lock, flags);
if (target->state != SRP_TARGET_REMOVED) if (target->state != SRP_TARGET_REMOVED)
target->state = SRP_TARGET_REMOVED; target->state = SRP_TARGET_REMOVED;
spin_unlock_irqrestore(target->scsi_host->host_lock, flags); spin_unlock_irqrestore(target->scsi_host->host_lock, flags);
} }
mutex_unlock(&host->target_mutex); spin_unlock(&host->target_lock);
/* /*
* Wait for any reconnection tasks that may have * Wait for any reconnection tasks that may have
......
...@@ -99,7 +99,7 @@ struct srp_host { ...@@ -99,7 +99,7 @@ struct srp_host {
u8 port; u8 port;
struct class_device class_dev; struct class_device class_dev;
struct list_head target_list; struct list_head target_list;
struct mutex target_mutex; spinlock_t target_lock;
struct completion released; struct completion released;
struct list_head list; struct list_head list;
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册