aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/scsi/zfcp_fc.c
diff options
context:
space:
mode:
authorSwen Schillig <swen@vnet.ibm.com>2009-11-24 10:53:59 -0500
committerJames Bottomley <James.Bottomley@suse.de>2009-12-04 13:02:02 -0500
commitf3450c7b917201bb49d67032e9f60d5125675d6a (patch)
tree404b1c23490b0a5ba3d6cbbb14e64381a12a108a /drivers/s390/scsi/zfcp_fc.c
parentecf0c7721b104c0ce9c8ca534c911f6310cf92a8 (diff)
[SCSI] zfcp: Replace local reference counting with common kref
Replace the local reference counting by already available mechanisms offered by kref. Where possible existing device structures were used, including the same functionality. Signed-off-by: Swen Schillig <swen@vnet.ibm.com> Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/s390/scsi/zfcp_fc.c')
-rw-r--r--drivers/s390/scsi/zfcp_fc.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c
index c7efdc51df63..6fa1bcbec0a9 100644
--- a/drivers/s390/scsi/zfcp_fc.c
+++ b/drivers/s390/scsi/zfcp_fc.c
@@ -134,6 +134,8 @@ static void zfcp_fc_wka_port_force_offline(struct zfcp_wka_port *wka)
134 134
135void zfcp_fc_wka_ports_force_offline(struct zfcp_wka_ports *gs) 135void zfcp_fc_wka_ports_force_offline(struct zfcp_wka_ports *gs)
136{ 136{
137 if (!gs)
138 return;
137 zfcp_fc_wka_port_force_offline(&gs->ms); 139 zfcp_fc_wka_port_force_offline(&gs->ms);
138 zfcp_fc_wka_port_force_offline(&gs->ts); 140 zfcp_fc_wka_port_force_offline(&gs->ts);
139 zfcp_fc_wka_port_force_offline(&gs->ds); 141 zfcp_fc_wka_port_force_offline(&gs->ds);
@@ -356,7 +358,7 @@ void zfcp_fc_port_did_lookup(struct work_struct *work)
356 358
357 zfcp_erp_port_reopen(port, 0, "fcgpn_3", NULL); 359 zfcp_erp_port_reopen(port, 0, "fcgpn_3", NULL);
358out: 360out:
359 zfcp_port_put(port); 361 put_device(&port->sysfs_device);
360} 362}
361 363
362/** 364/**
@@ -365,9 +367,9 @@ out:
365 */ 367 */
366void zfcp_fc_trigger_did_lookup(struct zfcp_port *port) 368void zfcp_fc_trigger_did_lookup(struct zfcp_port *port)
367{ 369{
368 zfcp_port_get(port); 370 get_device(&port->sysfs_device);
369 if (!queue_work(port->adapter->work_queue, &port->gid_pn_work)) 371 if (!queue_work(port->adapter->work_queue, &port->gid_pn_work))
370 zfcp_port_put(port); 372 put_device(&port->sysfs_device);
371} 373}
372 374
373/** 375/**
@@ -426,7 +428,7 @@ static void zfcp_fc_adisc_handler(unsigned long data)
426 zfcp_scsi_schedule_rport_register(port); 428 zfcp_scsi_schedule_rport_register(port);
427 out: 429 out:
428 atomic_clear_mask(ZFCP_STATUS_PORT_LINK_TEST, &port->status); 430 atomic_clear_mask(ZFCP_STATUS_PORT_LINK_TEST, &port->status);
429 zfcp_port_put(port); 431 put_device(&port->sysfs_device);
430 kfree(adisc); 432 kfree(adisc);
431} 433}
432 434
@@ -468,7 +470,7 @@ void zfcp_fc_link_test_work(struct work_struct *work)
468 container_of(work, struct zfcp_port, test_link_work); 470 container_of(work, struct zfcp_port, test_link_work);
469 int retval; 471 int retval;
470 472
471 zfcp_port_get(port); 473 get_device(&port->sysfs_device);
472 port->rport_task = RPORT_DEL; 474 port->rport_task = RPORT_DEL;
473 zfcp_scsi_rport_work(&port->rport_work); 475 zfcp_scsi_rport_work(&port->rport_work);
474 476
@@ -487,7 +489,7 @@ void zfcp_fc_link_test_work(struct work_struct *work)
487 zfcp_erp_port_forced_reopen(port, 0, "fcltwk1", NULL); 489 zfcp_erp_port_forced_reopen(port, 0, "fcltwk1", NULL);
488 490
489out: 491out:
490 zfcp_port_put(port); 492 put_device(&port->sysfs_device);
491} 493}
492 494
493/** 495/**
@@ -500,9 +502,9 @@ out:
500 */ 502 */
501void zfcp_fc_test_link(struct zfcp_port *port) 503void zfcp_fc_test_link(struct zfcp_port *port)
502{ 504{
503 zfcp_port_get(port); 505 get_device(&port->sysfs_device);
504 if (!queue_work(port->adapter->work_queue, &port->test_link_work)) 506 if (!queue_work(port->adapter->work_queue, &port->test_link_work))
505 zfcp_port_put(port); 507 put_device(&port->sysfs_device);
506} 508}
507 509
508static void zfcp_free_sg_env(struct zfcp_gpn_ft *gpn_ft, int buf_num) 510static void zfcp_free_sg_env(struct zfcp_gpn_ft *gpn_ft, int buf_num)
@@ -576,7 +578,7 @@ static int zfcp_fc_send_gpn_ft(struct zfcp_gpn_ft *gpn_ft,
576 return ret; 578 return ret;
577} 579}
578 580
579static void zfcp_fc_validate_port(struct zfcp_port *port) 581static void zfcp_fc_validate_port(struct zfcp_port *port, struct list_head *lh)
580{ 582{
581 if (!(atomic_read(&port->status) & ZFCP_STATUS_COMMON_NOESC)) 583 if (!(atomic_read(&port->status) & ZFCP_STATUS_COMMON_NOESC))
582 return; 584 return;
@@ -584,13 +586,11 @@ static void zfcp_fc_validate_port(struct zfcp_port *port)
584 atomic_clear_mask(ZFCP_STATUS_COMMON_NOESC, &port->status); 586 atomic_clear_mask(ZFCP_STATUS_COMMON_NOESC, &port->status);
585 587
586 if ((port->supported_classes != 0) || 588 if ((port->supported_classes != 0) ||
587 !list_empty(&port->unit_list)) { 589 !list_empty(&port->unit_list))
588 zfcp_port_put(port);
589 return; 590 return;
590 } 591
591 zfcp_erp_port_shutdown(port, 0, "fcpval1", NULL); 592 atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status);
592 zfcp_port_put(port); 593 list_move_tail(&port->list, lh);
593 zfcp_port_dequeue(port);
594} 594}
595 595
596static int zfcp_fc_eval_gpn_ft(struct zfcp_gpn_ft *gpn_ft, int max_entries) 596static 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)
602 struct zfcp_adapter *adapter = ct->wka_port->adapter; 602 struct zfcp_adapter *adapter = ct->wka_port->adapter;
603 struct zfcp_port *port, *tmp; 603 struct zfcp_port *port, *tmp;
604 unsigned long flags; 604 unsigned long flags;
605 LIST_HEAD(remove_lh);
605 u32 d_id; 606 u32 d_id;
606 int ret = 0, x, last = 0; 607 int ret = 0, x, last = 0;
607 608
@@ -652,9 +653,16 @@ static int zfcp_fc_eval_gpn_ft(struct zfcp_gpn_ft *gpn_ft, int max_entries)
652 zfcp_erp_wait(adapter); 653 zfcp_erp_wait(adapter);
653 write_lock_irqsave(&adapter->port_list_lock, flags); 654 write_lock_irqsave(&adapter->port_list_lock, flags);
654 list_for_each_entry_safe(port, tmp, &adapter->port_list, list) 655 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);
656 write_unlock_irqrestore(&adapter->port_list_lock, flags); 657 write_unlock_irqrestore(&adapter->port_list_lock, flags);
657 mutex_unlock(&zfcp_data.config_mutex); 658 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
658 return ret; 666 return ret;
659} 667}
660 668
@@ -763,7 +771,7 @@ int zfcp_fc_execute_els_fc_job(struct fc_bsg_job *job)
763 } 771 }
764 772
765 els_fc_job->els.d_id = port->d_id; 773 els_fc_job->els.d_id = port->d_id;
766 zfcp_port_put(port); 774 put_device(&port->sysfs_device);
767 } else { 775 } else {
768 port_did = job->request->rqst_data.h_els.port_id; 776 port_did = job->request->rqst_data.h_els.port_id;
769 els_fc_job->els.d_id = (port_did[0] << 16) + 777 els_fc_job->els.d_id = (port_did[0] << 16) +