@@ -134,6 +134,8 @@ static void zfcp_fc_wka_port_force_offline(struct zfcp_wka_port *wka)
134134
135135void zfcp_fc_wka_ports_force_offline (struct zfcp_wka_ports * gs )
136136{
137+ if (!gs )
138+ return ;
137139 zfcp_fc_wka_port_force_offline (& gs -> ms );
138140 zfcp_fc_wka_port_force_offline (& gs -> ts );
139141 zfcp_fc_wka_port_force_offline (& gs -> ds );
@@ -356,7 +358,7 @@ void zfcp_fc_port_did_lookup(struct work_struct *work)
356358
357359 zfcp_erp_port_reopen (port , 0 , "fcgpn_3" , NULL );
358360out :
359- zfcp_port_put ( port );
361+ put_device ( & port -> sysfs_device );
360362}
361363
362364/**
@@ -365,9 +367,9 @@ void zfcp_fc_port_did_lookup(struct work_struct *work)
365367 */
366368void zfcp_fc_trigger_did_lookup (struct zfcp_port * port )
367369{
368- zfcp_port_get ( port );
370+ get_device ( & port -> sysfs_device );
369371 if (!queue_work (port -> adapter -> work_queue , & port -> gid_pn_work ))
370- zfcp_port_put ( port );
372+ put_device ( & port -> sysfs_device );
371373}
372374
373375/**
@@ -426,7 +428,7 @@ static void zfcp_fc_adisc_handler(unsigned long data)
426428 zfcp_scsi_schedule_rport_register (port );
427429 out :
428430 atomic_clear_mask (ZFCP_STATUS_PORT_LINK_TEST , & port -> status );
429- zfcp_port_put ( port );
431+ put_device ( & port -> sysfs_device );
430432 kfree (adisc );
431433}
432434
@@ -468,7 +470,7 @@ void zfcp_fc_link_test_work(struct work_struct *work)
468470 container_of (work , struct zfcp_port , test_link_work );
469471 int retval ;
470472
471- zfcp_port_get ( port );
473+ get_device ( & port -> sysfs_device );
472474 port -> rport_task = RPORT_DEL ;
473475 zfcp_scsi_rport_work (& port -> rport_work );
474476
@@ -487,7 +489,7 @@ void zfcp_fc_link_test_work(struct work_struct *work)
487489 zfcp_erp_port_forced_reopen (port , 0 , "fcltwk1" , NULL );
488490
489491out :
490- zfcp_port_put ( port );
492+ put_device ( & port -> sysfs_device );
491493}
492494
493495/**
@@ -500,9 +502,9 @@ void zfcp_fc_link_test_work(struct work_struct *work)
500502 */
501503void zfcp_fc_test_link (struct zfcp_port * port )
502504{
503- zfcp_port_get ( port );
505+ get_device ( & port -> sysfs_device );
504506 if (!queue_work (port -> adapter -> work_queue , & port -> test_link_work ))
505- zfcp_port_put ( port );
507+ put_device ( & port -> sysfs_device );
506508}
507509
508510static void zfcp_free_sg_env (struct zfcp_gpn_ft * gpn_ft , int buf_num )
@@ -576,21 +578,19 @@ static int zfcp_fc_send_gpn_ft(struct zfcp_gpn_ft *gpn_ft,
576578 return ret ;
577579}
578580
579- static void zfcp_fc_validate_port (struct zfcp_port * port )
581+ static void zfcp_fc_validate_port (struct zfcp_port * port , struct list_head * lh )
580582{
581583 if (!(atomic_read (& port -> status ) & ZFCP_STATUS_COMMON_NOESC ))
582584 return ;
583585
584586 atomic_clear_mask (ZFCP_STATUS_COMMON_NOESC , & port -> status );
585587
586588 if ((port -> supported_classes != 0 ) ||
587- !list_empty (& port -> unit_list )) {
588- zfcp_port_put (port );
589+ !list_empty (& port -> unit_list ))
589590 return ;
590- }
591- zfcp_erp_port_shutdown (port , 0 , "fcpval1" , NULL );
592- zfcp_port_put (port );
593- zfcp_port_dequeue (port );
591+
592+ atomic_set_mask (ZFCP_STATUS_COMMON_REMOVE , & port -> status );
593+ list_move_tail (& port -> list , lh );
594594}
595595
596596static int zfcp_fc_eval_gpn_ft (struct zfcp_gpn_ft * gpn_ft , int max_entries )
@@ -602,6 +602,7 @@ static int zfcp_fc_eval_gpn_ft(struct zfcp_gpn_ft *gpn_ft, int max_entries)
602602 struct zfcp_adapter * adapter = ct -> wka_port -> adapter ;
603603 struct zfcp_port * port , * tmp ;
604604 unsigned long flags ;
605+ LIST_HEAD (remove_lh );
605606 u32 d_id ;
606607 int ret = 0 , x , last = 0 ;
607608
@@ -652,9 +653,16 @@ static int zfcp_fc_eval_gpn_ft(struct zfcp_gpn_ft *gpn_ft, int max_entries)
652653 zfcp_erp_wait (adapter );
653654 write_lock_irqsave (& adapter -> port_list_lock , flags );
654655 list_for_each_entry_safe (port , tmp , & adapter -> port_list , list )
655- zfcp_fc_validate_port (port );
656+ zfcp_fc_validate_port (port , & remove_lh );
656657 write_unlock_irqrestore (& adapter -> port_list_lock , flags );
657658 mutex_unlock (& zfcp_data .config_mutex );
659+
660+ list_for_each_entry_safe (port , tmp , & remove_lh , list ) {
661+ zfcp_erp_port_shutdown (port , 0 , "fcegpf2" , NULL );
662+ zfcp_device_unregister (& port -> sysfs_device ,
663+ & zfcp_sysfs_port_attrs );
664+ }
665+
658666 return ret ;
659667}
660668
@@ -763,7 +771,7 @@ int zfcp_fc_execute_els_fc_job(struct fc_bsg_job *job)
763771 }
764772
765773 els_fc_job -> els .d_id = port -> d_id ;
766- zfcp_port_put ( port );
774+ put_device ( & port -> sysfs_device );
767775 } else {
768776 port_did = job -> request -> rqst_data .h_els .port_id ;
769777 els_fc_job -> els .d_id = (port_did [0 ] << 16 ) +
0 commit comments