Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 316819
b: refs/heads/master
c: b29a4f3
h: refs/heads/master
i:
  316817: 6158797
  316815: 83b48a3
v: v3
  • Loading branch information
Vasu Dev authored and James Bottomley committed Jul 20, 2012
1 parent 55580f7 commit d50343d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 44 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 33a2285d96b5e7b9500612ec623bf4313397bb53
refs/heads/master: b29a4f309fb58165ebfcca0fba504ae90ec4cfa6
96 changes: 53 additions & 43 deletions trunk/drivers/scsi/libfc/fc_exch.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,52 @@ static void fc_exch_release(struct fc_exch *ep)
}
}

/**
* fc_exch_timer_cancel() - cancel exch timer
* @ep: The exchange whose timer to be canceled
*/
static inline void fc_exch_timer_cancel(struct fc_exch *ep)
{
if (cancel_delayed_work(&ep->timeout_work)) {
FC_EXCH_DBG(ep, "Exchange timer canceled\n");
atomic_dec(&ep->ex_refcnt); /* drop hold for timer */
}
}

/**
* fc_exch_timer_set_locked() - Start a timer for an exchange w/ the
* the exchange lock held
* @ep: The exchange whose timer will start
* @timer_msec: The timeout period
*
* Used for upper level protocols to time out the exchange.
* The timer is cancelled when it fires or when the exchange completes.
*/
static inline void fc_exch_timer_set_locked(struct fc_exch *ep,
unsigned int timer_msec)
{
if (ep->state & (FC_EX_RST_CLEANUP | FC_EX_DONE))
return;

FC_EXCH_DBG(ep, "Exchange timer armed : %d msecs\n", timer_msec);

if (queue_delayed_work(fc_exch_workqueue, &ep->timeout_work,
msecs_to_jiffies(timer_msec)))
fc_exch_hold(ep); /* hold for timer */
}

/**
* fc_exch_timer_set() - Lock the exchange and set the timer
* @ep: The exchange whose timer will start
* @timer_msec: The timeout period
*/
static void fc_exch_timer_set(struct fc_exch *ep, unsigned int timer_msec)
{
spin_lock_bh(&ep->ex_lock);
fc_exch_timer_set_locked(ep, timer_msec);
spin_unlock_bh(&ep->ex_lock);
}

/**
* fc_exch_done_locked() - Complete an exchange with the exchange lock held
* @ep: The exchange that is complete
Expand All @@ -354,8 +400,7 @@ static int fc_exch_done_locked(struct fc_exch *ep)

if (!(ep->esb_stat & ESB_ST_REC_QUAL)) {
ep->state |= FC_EX_DONE;
if (cancel_delayed_work(&ep->timeout_work))
atomic_dec(&ep->ex_refcnt); /* drop hold for timer */
fc_exch_timer_cancel(ep);
rc = 0;
}
return rc;
Expand Down Expand Up @@ -418,40 +463,6 @@ static void fc_exch_delete(struct fc_exch *ep)
fc_exch_release(ep); /* drop hold for exch in mp */
}

/**
* fc_exch_timer_set_locked() - Start a timer for an exchange w/ the
* the exchange lock held
* @ep: The exchange whose timer will start
* @timer_msec: The timeout period
*
* Used for upper level protocols to time out the exchange.
* The timer is cancelled when it fires or when the exchange completes.
*/
static inline void fc_exch_timer_set_locked(struct fc_exch *ep,
unsigned int timer_msec)
{
if (ep->state & (FC_EX_RST_CLEANUP | FC_EX_DONE))
return;

FC_EXCH_DBG(ep, "Exchange timer armed\n");

if (queue_delayed_work(fc_exch_workqueue, &ep->timeout_work,
msecs_to_jiffies(timer_msec)))
fc_exch_hold(ep); /* hold for timer */
}

/**
* fc_exch_timer_set() - Lock the exchange and set the timer
* @ep: The exchange whose timer will start
* @timer_msec: The timeout period
*/
static void fc_exch_timer_set(struct fc_exch *ep, unsigned int timer_msec)
{
spin_lock_bh(&ep->ex_lock);
fc_exch_timer_set_locked(ep, timer_msec);
spin_unlock_bh(&ep->ex_lock);
}

/**
* fc_seq_send() - Send a frame using existing sequence/exchange pair
* @lport: The local port that the exchange will be sent on
Expand Down Expand Up @@ -1544,8 +1555,10 @@ static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp)
FC_EXCH_DBG(ep, "exch: BLS rctl %x - %s\n", fh->fh_r_ctl,
fc_exch_rctl_name(fh->fh_r_ctl));

if (cancel_delayed_work_sync(&ep->timeout_work))
if (cancel_delayed_work_sync(&ep->timeout_work)) {
FC_EXCH_DBG(ep, "Exchange timer canceled\n");
fc_exch_release(ep); /* release from pending timer hold */
}

spin_lock_bh(&ep->ex_lock);
switch (fh->fh_r_ctl) {
Expand Down Expand Up @@ -1732,8 +1745,7 @@ static void fc_exch_reset(struct fc_exch *ep)
spin_lock_bh(&ep->ex_lock);
fc_exch_abort_locked(ep, 0);
ep->state |= FC_EX_RST_CLEANUP;
if (cancel_delayed_work(&ep->timeout_work))
atomic_dec(&ep->ex_refcnt); /* drop hold for timer */
fc_exch_timer_cancel(ep);
resp = ep->resp;
ep->resp = NULL;
if (ep->esb_stat & ESB_ST_REC_QUAL)
Expand Down Expand Up @@ -2128,10 +2140,8 @@ static void fc_exch_els_rrq(struct fc_frame *fp)
ep->esb_stat &= ~ESB_ST_REC_QUAL;
atomic_dec(&ep->ex_refcnt); /* drop hold for rec qual */
}
if (ep->esb_stat & ESB_ST_COMPLETE) {
if (cancel_delayed_work(&ep->timeout_work))
atomic_dec(&ep->ex_refcnt); /* drop timer hold */
}
if (ep->esb_stat & ESB_ST_COMPLETE)
fc_exch_timer_cancel(ep);

spin_unlock_bh(&ep->ex_lock);

Expand Down

0 comments on commit d50343d

Please sign in to comment.