Skip to content

Commit

Permalink
target: Make se_dev_check_online() locking IRQ-safe
Browse files Browse the repository at this point in the history
se_dev_check_online() is called from transport_lookup_cmd_lun(), which
as discussed before may be called from interrupt context.  So it needs
to use spin_lock_irqsave() instead of spin_lock_irq() to avoid
enabling interrupts at the wrong time.

Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
  • Loading branch information
Roland Dreier authored and Nicholas Bellinger committed Jul 22, 2011
1 parent 78faae3 commit 56e34ee
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/target/target_core_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -813,12 +813,13 @@ static void se_dev_stop(struct se_device *dev)

int se_dev_check_online(struct se_device *dev)
{
unsigned long flags;
int ret;

spin_lock_irq(&dev->dev_status_lock);
spin_lock_irqsave(&dev->dev_status_lock, flags);
ret = ((dev->dev_status & TRANSPORT_DEVICE_ACTIVATED) ||
(dev->dev_status & TRANSPORT_DEVICE_DEACTIVATED)) ? 0 : 1;
spin_unlock_irq(&dev->dev_status_lock);
spin_unlock_irqrestore(&dev->dev_status_lock, flags);

return ret;
}
Expand Down

0 comments on commit 56e34ee

Please sign in to comment.