[SCSI] libfc: Move host_lock usage into ramp_up/down routines
The host_lock is still used to protect the can_queue value in the Scsi_Host, but it doesn't need to be held and released by each caller. This patch moves the lock usage into the fc_fcp_can_queue_ramp_up and fc_fcp_can_queue_ramp_down routines. Signed-off-by: Robert Love <robert.w.love@intel.com> Tested-by: Ross Brattain <ross.b.brattain@intel.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
This commit is contained in:
committed by
James Bottomley
parent
63ce249994
commit
9c8cce8e41
@@ -335,22 +335,23 @@ static void fc_fcp_ddp_done(struct fc_fcp_pkt *fsp)
|
|||||||
/**
|
/**
|
||||||
* fc_fcp_can_queue_ramp_up() - increases can_queue
|
* fc_fcp_can_queue_ramp_up() - increases can_queue
|
||||||
* @lport: lport to ramp up can_queue
|
* @lport: lport to ramp up can_queue
|
||||||
*
|
|
||||||
* Locking notes: Called with Scsi_Host lock held
|
|
||||||
*/
|
*/
|
||||||
static void fc_fcp_can_queue_ramp_up(struct fc_lport *lport)
|
static void fc_fcp_can_queue_ramp_up(struct fc_lport *lport)
|
||||||
{
|
{
|
||||||
struct fc_fcp_internal *si = fc_get_scsi_internal(lport);
|
struct fc_fcp_internal *si = fc_get_scsi_internal(lport);
|
||||||
|
unsigned long flags;
|
||||||
int can_queue;
|
int can_queue;
|
||||||
|
|
||||||
|
spin_lock_irqsave(lport->host->host_lock, flags);
|
||||||
|
|
||||||
if (si->last_can_queue_ramp_up_time &&
|
if (si->last_can_queue_ramp_up_time &&
|
||||||
(time_before(jiffies, si->last_can_queue_ramp_up_time +
|
(time_before(jiffies, si->last_can_queue_ramp_up_time +
|
||||||
FC_CAN_QUEUE_PERIOD)))
|
FC_CAN_QUEUE_PERIOD)))
|
||||||
return;
|
goto unlock;
|
||||||
|
|
||||||
if (time_before(jiffies, si->last_can_queue_ramp_down_time +
|
if (time_before(jiffies, si->last_can_queue_ramp_down_time +
|
||||||
FC_CAN_QUEUE_PERIOD))
|
FC_CAN_QUEUE_PERIOD))
|
||||||
return;
|
goto unlock;
|
||||||
|
|
||||||
si->last_can_queue_ramp_up_time = jiffies;
|
si->last_can_queue_ramp_up_time = jiffies;
|
||||||
|
|
||||||
@@ -362,6 +363,9 @@ static void fc_fcp_can_queue_ramp_up(struct fc_lport *lport)
|
|||||||
lport->host->can_queue = can_queue;
|
lport->host->can_queue = can_queue;
|
||||||
shost_printk(KERN_ERR, lport->host, "libfc: increased "
|
shost_printk(KERN_ERR, lport->host, "libfc: increased "
|
||||||
"can_queue to %d.\n", can_queue);
|
"can_queue to %d.\n", can_queue);
|
||||||
|
|
||||||
|
unlock:
|
||||||
|
spin_unlock_irqrestore(lport->host->host_lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -373,18 +377,19 @@ static void fc_fcp_can_queue_ramp_up(struct fc_lport *lport)
|
|||||||
* commands complete or timeout, then try again with a reduced
|
* commands complete or timeout, then try again with a reduced
|
||||||
* can_queue. Eventually we will hit the point where we run
|
* can_queue. Eventually we will hit the point where we run
|
||||||
* on all reserved structs.
|
* on all reserved structs.
|
||||||
*
|
|
||||||
* Locking notes: Called with Scsi_Host lock held
|
|
||||||
*/
|
*/
|
||||||
static void fc_fcp_can_queue_ramp_down(struct fc_lport *lport)
|
static void fc_fcp_can_queue_ramp_down(struct fc_lport *lport)
|
||||||
{
|
{
|
||||||
struct fc_fcp_internal *si = fc_get_scsi_internal(lport);
|
struct fc_fcp_internal *si = fc_get_scsi_internal(lport);
|
||||||
|
unsigned long flags;
|
||||||
int can_queue;
|
int can_queue;
|
||||||
|
|
||||||
|
spin_lock_irqsave(lport->host->host_lock, flags);
|
||||||
|
|
||||||
if (si->last_can_queue_ramp_down_time &&
|
if (si->last_can_queue_ramp_down_time &&
|
||||||
(time_before(jiffies, si->last_can_queue_ramp_down_time +
|
(time_before(jiffies, si->last_can_queue_ramp_down_time +
|
||||||
FC_CAN_QUEUE_PERIOD)))
|
FC_CAN_QUEUE_PERIOD)))
|
||||||
return;
|
goto unlock;
|
||||||
|
|
||||||
si->last_can_queue_ramp_down_time = jiffies;
|
si->last_can_queue_ramp_down_time = jiffies;
|
||||||
|
|
||||||
@@ -395,6 +400,9 @@ static void fc_fcp_can_queue_ramp_down(struct fc_lport *lport)
|
|||||||
lport->host->can_queue = can_queue;
|
lport->host->can_queue = can_queue;
|
||||||
shost_printk(KERN_ERR, lport->host, "libfc: Could not allocate frame.\n"
|
shost_printk(KERN_ERR, lport->host, "libfc: Could not allocate frame.\n"
|
||||||
"Reducing can_queue to %d.\n", can_queue);
|
"Reducing can_queue to %d.\n", can_queue);
|
||||||
|
|
||||||
|
unlock:
|
||||||
|
spin_unlock_irqrestore(lport->host->host_lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -409,16 +417,13 @@ static inline struct fc_frame *fc_fcp_frame_alloc(struct fc_lport *lport,
|
|||||||
size_t len)
|
size_t len)
|
||||||
{
|
{
|
||||||
struct fc_frame *fp;
|
struct fc_frame *fp;
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
fp = fc_frame_alloc(lport, len);
|
fp = fc_frame_alloc(lport, len);
|
||||||
if (likely(fp))
|
if (likely(fp))
|
||||||
return fp;
|
return fp;
|
||||||
|
|
||||||
/* error case */
|
/* error case */
|
||||||
spin_lock_irqsave(lport->host->host_lock, flags);
|
|
||||||
fc_fcp_can_queue_ramp_down(lport);
|
fc_fcp_can_queue_ramp_down(lport);
|
||||||
spin_unlock_irqrestore(lport->host->host_lock, flags);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user