Commit aa0fec62391cd429385e7f3f9fc4a1fb8e2d1218

Authored by Christof Schmitt
Committed by James Bottomley
1 parent 7337891f38

[SCSI] zfcp: Fix sparse warning by providing new entry in dbf

drivers/s390/scsi/zfcp_dbf.c:692:2: warning: context imbalance in
'zfcp_rec_dbf_event_thread' - different lock contexts for basic block

Replace the parameter indicating if the lock is held with a new entry
function that only acquires the lock. This makes the lock handling
more visible and removes the sparse warning.

Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
Signed-off-by: Martin Peschke <mp3@de.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>

Showing 3 changed files with 28 additions and 17 deletions Side-by-side Diff

drivers/s390/scsi/zfcp_dbf.c
... ... @@ -670,24 +670,20 @@
670 670 * zfcp_rec_dbf_event_thread - trace event related to recovery thread operation
671 671 * @id2: identifier for event
672 672 * @adapter: adapter
673   - * @lock: non-zero value indicates that erp_lock has not yet been acquired
  673 + * This function assumes that the caller is holding erp_lock.
674 674 */
675   -void zfcp_rec_dbf_event_thread(u8 id2, struct zfcp_adapter *adapter, int lock)
  675 +void zfcp_rec_dbf_event_thread(u8 id2, struct zfcp_adapter *adapter)
676 676 {
677 677 struct zfcp_rec_dbf_record *r = &adapter->rec_dbf_buf;
678 678 unsigned long flags = 0;
679 679 struct list_head *entry;
680 680 unsigned ready = 0, running = 0, total;
681 681  
682   - if (lock)
683   - read_lock_irqsave(&adapter->erp_lock, flags);
684 682 list_for_each(entry, &adapter->erp_ready_head)
685 683 ready++;
686 684 list_for_each(entry, &adapter->erp_running_head)
687 685 running++;
688 686 total = adapter->erp_total_count;
689   - if (lock)
690   - read_unlock_irqrestore(&adapter->erp_lock, flags);
691 687  
692 688 spin_lock_irqsave(&adapter->rec_dbf_lock, flags);
693 689 memset(r, 0, sizeof(*r));
... ... @@ -698,6 +694,21 @@
698 694 r->u.thread.running = running;
699 695 debug_event(adapter->rec_dbf, 6, r, sizeof(*r));
700 696 spin_unlock_irqrestore(&adapter->rec_dbf_lock, flags);
  697 +}
  698 +
  699 +/**
  700 + * zfcp_rec_dbf_event_thread - trace event related to recovery thread operation
  701 + * @id2: identifier for event
  702 + * @adapter: adapter
  703 + * This function assumes that the caller does not hold erp_lock.
  704 + */
  705 +void zfcp_rec_dbf_event_thread_lock(u8 id2, struct zfcp_adapter *adapter)
  706 +{
  707 + unsigned long flags;
  708 +
  709 + read_lock_irqsave(&adapter->erp_lock, flags);
  710 + zfcp_rec_dbf_event_thread(id2, adapter);
  711 + read_unlock_irqrestore(&adapter->erp_lock, flags);
701 712 }
702 713  
703 714 static void zfcp_rec_dbf_event_target(u8 id2, void *ref,
drivers/s390/scsi/zfcp_erp.c
... ... @@ -783,7 +783,7 @@
783 783  
784 784 zfcp_erp_action_to_ready(erp_action);
785 785 up(&adapter->erp_ready_sem);
786   - zfcp_rec_dbf_event_thread(2, adapter, 0);
  786 + zfcp_rec_dbf_event_thread(2, adapter);
787 787 }
788 788  
789 789 /*
... ... @@ -995,7 +995,7 @@
995 995  
996 996 atomic_set_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL, &adapter->status);
997 997 up(&adapter->erp_ready_sem);
998   - zfcp_rec_dbf_event_thread(2, adapter, 1);
  998 + zfcp_rec_dbf_event_thread_lock(2, adapter);
999 999  
1000 1000 wait_event(adapter->erp_thread_wqh,
1001 1001 !atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP,
1002 1002  
... ... @@ -1050,9 +1050,9 @@
1050 1050 * no action in 'ready' queue to be processed and
1051 1051 * thread is not to be killed
1052 1052 */
1053   - zfcp_rec_dbf_event_thread(4, adapter, 1);
  1053 + zfcp_rec_dbf_event_thread_lock(4, adapter);
1054 1054 down_interruptible(&adapter->erp_ready_sem);
1055   - zfcp_rec_dbf_event_thread(5, adapter, 1);
  1055 + zfcp_rec_dbf_event_thread_lock(5, adapter);
1056 1056 }
1057 1057  
1058 1058 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status);
1059 1059  
... ... @@ -2062,9 +2062,9 @@
2062 2062 * _must_ be the one belonging to the 'exchange config
2063 2063 * data' request.
2064 2064 */
2065   - zfcp_rec_dbf_event_thread(6, adapter, 1);
  2065 + zfcp_rec_dbf_event_thread_lock(6, adapter);
2066 2066 down(&adapter->erp_ready_sem);
2067   - zfcp_rec_dbf_event_thread(7, adapter, 1);
  2067 + zfcp_rec_dbf_event_thread_lock(7, adapter);
2068 2068 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
2069 2069 ZFCP_LOG_INFO("error: exchange of configuration data "
2070 2070 "for adapter %s timed out\n",
2071 2071  
... ... @@ -2118,9 +2118,9 @@
2118 2118 }
2119 2119  
2120 2120 ret = ZFCP_ERP_SUCCEEDED;
2121   - zfcp_rec_dbf_event_thread(8, adapter, 1);
  2121 + zfcp_rec_dbf_event_thread_lock(8, adapter);
2122 2122 down(&adapter->erp_ready_sem);
2123   - zfcp_rec_dbf_event_thread(9, adapter, 1);
  2123 + zfcp_rec_dbf_event_thread_lock(9, adapter);
2124 2124 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
2125 2125 ZFCP_LOG_INFO("error: exchange port data timed out (adapter "
2126 2126 "%s)\n", zfcp_get_busid_by_adapter(adapter));
... ... @@ -2876,7 +2876,7 @@
2876 2876 /* finally put it into 'ready' queue and kick erp thread */
2877 2877 list_add_tail(&erp_action->list, &adapter->erp_ready_head);
2878 2878 up(&adapter->erp_ready_sem);
2879   - zfcp_rec_dbf_event_thread(1, adapter, 0);
  2879 + zfcp_rec_dbf_event_thread(1, adapter);
2880 2880 retval = 0;
2881 2881 out:
2882 2882 zfcp_rec_dbf_event_trigger(id, ref, want, need, erp_action,
drivers/s390/scsi/zfcp_ext.h
... ... @@ -169,8 +169,8 @@
169 169 extern void zfcp_erp_unit_access_changed(struct zfcp_unit *, u8, void *);
170 170  
171 171 /******************************** AUX ****************************************/
172   -extern void zfcp_rec_dbf_event_thread(u8 id, struct zfcp_adapter *adapter,
173   - int lock);
  172 +extern void zfcp_rec_dbf_event_thread(u8 id, struct zfcp_adapter *adapter);
  173 +extern void zfcp_rec_dbf_event_thread_lock(u8 id, struct zfcp_adapter *adapter);
174 174 extern void zfcp_rec_dbf_event_adapter(u8 id, void *ref, struct zfcp_adapter *);
175 175 extern void zfcp_rec_dbf_event_port(u8 id, void *ref, struct zfcp_port *port);
176 176 extern void zfcp_rec_dbf_event_unit(u8 id, void *ref, struct zfcp_unit *unit);