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

[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>

authored by

Christof Schmitt and committed by
James Bottomley
aa0fec62 7337891f

+28 -17
+17 -6
drivers/s390/scsi/zfcp_dbf.c
··· 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)); ··· 694 698 r->u.thread.running = running; 695 699 debug_event(adapter->rec_dbf, 6, r, sizeof(*r)); 696 700 spin_unlock_irqrestore(&adapter->rec_dbf_lock, flags); 701 + } 702 + 703 + /** 704 + * zfcp_rec_dbf_event_thread - trace event related to recovery thread operation 705 + * @id2: identifier for event 706 + * @adapter: adapter 707 + * This function assumes that the caller does not hold erp_lock. 708 + */ 709 + void zfcp_rec_dbf_event_thread_lock(u8 id2, struct zfcp_adapter *adapter) 710 + { 711 + unsigned long flags; 712 + 713 + read_lock_irqsave(&adapter->erp_lock, flags); 714 + zfcp_rec_dbf_event_thread(id2, adapter); 715 + read_unlock_irqrestore(&adapter->erp_lock, flags); 697 716 } 698 717 699 718 static void zfcp_rec_dbf_event_target(u8 id2, void *ref,
+9 -9
drivers/s390/scsi/zfcp_erp.c
··· 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 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, ··· 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); ··· 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", ··· 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 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,
+2 -2
drivers/s390/scsi/zfcp_ext.h
··· 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);