Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] libfc: add exch timer debug info

Add exch timeout info to have debug log with exch timeout
value to match with retries, also add debug info
on exch timer cancel.

Added common fc_exch_timer_cancel() func and grouped this
along with fc_exch_timer_set() function, so that
added debug code is not repeated.

Signed-off-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>

authored by

Vasu Dev and committed by
James Bottomley
b29a4f30 33a2285d

+53 -43
+53 -43
drivers/scsi/libfc/fc_exch.c
··· 334 334 } 335 335 336 336 /** 337 + * fc_exch_timer_cancel() - cancel exch timer 338 + * @ep: The exchange whose timer to be canceled 339 + */ 340 + static inline void fc_exch_timer_cancel(struct fc_exch *ep) 341 + { 342 + if (cancel_delayed_work(&ep->timeout_work)) { 343 + FC_EXCH_DBG(ep, "Exchange timer canceled\n"); 344 + atomic_dec(&ep->ex_refcnt); /* drop hold for timer */ 345 + } 346 + } 347 + 348 + /** 349 + * fc_exch_timer_set_locked() - Start a timer for an exchange w/ the 350 + * the exchange lock held 351 + * @ep: The exchange whose timer will start 352 + * @timer_msec: The timeout period 353 + * 354 + * Used for upper level protocols to time out the exchange. 355 + * The timer is cancelled when it fires or when the exchange completes. 356 + */ 357 + static inline void fc_exch_timer_set_locked(struct fc_exch *ep, 358 + unsigned int timer_msec) 359 + { 360 + if (ep->state & (FC_EX_RST_CLEANUP | FC_EX_DONE)) 361 + return; 362 + 363 + FC_EXCH_DBG(ep, "Exchange timer armed : %d msecs\n", timer_msec); 364 + 365 + if (queue_delayed_work(fc_exch_workqueue, &ep->timeout_work, 366 + msecs_to_jiffies(timer_msec))) 367 + fc_exch_hold(ep); /* hold for timer */ 368 + } 369 + 370 + /** 371 + * fc_exch_timer_set() - Lock the exchange and set the timer 372 + * @ep: The exchange whose timer will start 373 + * @timer_msec: The timeout period 374 + */ 375 + static void fc_exch_timer_set(struct fc_exch *ep, unsigned int timer_msec) 376 + { 377 + spin_lock_bh(&ep->ex_lock); 378 + fc_exch_timer_set_locked(ep, timer_msec); 379 + spin_unlock_bh(&ep->ex_lock); 380 + } 381 + 382 + /** 337 383 * fc_exch_done_locked() - Complete an exchange with the exchange lock held 338 384 * @ep: The exchange that is complete 339 385 */ ··· 400 354 401 355 if (!(ep->esb_stat & ESB_ST_REC_QUAL)) { 402 356 ep->state |= FC_EX_DONE; 403 - if (cancel_delayed_work(&ep->timeout_work)) 404 - atomic_dec(&ep->ex_refcnt); /* drop hold for timer */ 357 + fc_exch_timer_cancel(ep); 405 358 rc = 0; 406 359 } 407 360 return rc; ··· 461 416 list_del(&ep->ex_list); 462 417 spin_unlock_bh(&pool->lock); 463 418 fc_exch_release(ep); /* drop hold for exch in mp */ 464 - } 465 - 466 - /** 467 - * fc_exch_timer_set_locked() - Start a timer for an exchange w/ the 468 - * the exchange lock held 469 - * @ep: The exchange whose timer will start 470 - * @timer_msec: The timeout period 471 - * 472 - * Used for upper level protocols to time out the exchange. 473 - * The timer is cancelled when it fires or when the exchange completes. 474 - */ 475 - static inline void fc_exch_timer_set_locked(struct fc_exch *ep, 476 - unsigned int timer_msec) 477 - { 478 - if (ep->state & (FC_EX_RST_CLEANUP | FC_EX_DONE)) 479 - return; 480 - 481 - FC_EXCH_DBG(ep, "Exchange timer armed\n"); 482 - 483 - if (queue_delayed_work(fc_exch_workqueue, &ep->timeout_work, 484 - msecs_to_jiffies(timer_msec))) 485 - fc_exch_hold(ep); /* hold for timer */ 486 - } 487 - 488 - /** 489 - * fc_exch_timer_set() - Lock the exchange and set the timer 490 - * @ep: The exchange whose timer will start 491 - * @timer_msec: The timeout period 492 - */ 493 - static void fc_exch_timer_set(struct fc_exch *ep, unsigned int timer_msec) 494 - { 495 - spin_lock_bh(&ep->ex_lock); 496 - fc_exch_timer_set_locked(ep, timer_msec); 497 - spin_unlock_bh(&ep->ex_lock); 498 419 } 499 420 500 421 /** ··· 1555 1544 FC_EXCH_DBG(ep, "exch: BLS rctl %x - %s\n", fh->fh_r_ctl, 1556 1545 fc_exch_rctl_name(fh->fh_r_ctl)); 1557 1546 1558 - if (cancel_delayed_work_sync(&ep->timeout_work)) 1547 + if (cancel_delayed_work_sync(&ep->timeout_work)) { 1548 + FC_EXCH_DBG(ep, "Exchange timer canceled\n"); 1559 1549 fc_exch_release(ep); /* release from pending timer hold */ 1550 + } 1560 1551 1561 1552 spin_lock_bh(&ep->ex_lock); 1562 1553 switch (fh->fh_r_ctl) { ··· 1745 1732 spin_lock_bh(&ep->ex_lock); 1746 1733 fc_exch_abort_locked(ep, 0); 1747 1734 ep->state |= FC_EX_RST_CLEANUP; 1748 - if (cancel_delayed_work(&ep->timeout_work)) 1749 - atomic_dec(&ep->ex_refcnt); /* drop hold for timer */ 1735 + fc_exch_timer_cancel(ep); 1750 1736 resp = ep->resp; 1751 1737 ep->resp = NULL; 1752 1738 if (ep->esb_stat & ESB_ST_REC_QUAL) ··· 2140 2128 ep->esb_stat &= ~ESB_ST_REC_QUAL; 2141 2129 atomic_dec(&ep->ex_refcnt); /* drop hold for rec qual */ 2142 2130 } 2143 - if (ep->esb_stat & ESB_ST_COMPLETE) { 2144 - if (cancel_delayed_work(&ep->timeout_work)) 2145 - atomic_dec(&ep->ex_refcnt); /* drop timer hold */ 2146 - } 2131 + if (ep->esb_stat & ESB_ST_COMPLETE) 2132 + fc_exch_timer_cancel(ep); 2147 2133 2148 2134 spin_unlock_bh(&ep->ex_lock); 2149 2135