diff options
author | Jing Huang <huangj@brocade.com> | 2010-03-19 14:07:09 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-04-11 10:24:20 -0400 |
commit | 42b426ecb453cf49c3d16cf1d7a5e5d8cab9869d (patch) | |
tree | 42ca564f37e62c7797cea8816ac934e5347ea757 /drivers/scsi/bfa | |
parent | b3522f08ec7011aed0abc477bfedd00d189e9cd6 (diff) |
[SCSI] bfa: protect idr using bfad_mutex
idr is a global resource, protect it with global bfad_mutex.
Signed-off-by: Jing Huang <huangj@brocade.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/bfa')
-rw-r--r-- | drivers/scsi/bfa/bfad.c | 2 | ||||
-rw-r--r-- | drivers/scsi/bfa/bfad_drv.h | 1 | ||||
-rw-r--r-- | drivers/scsi/bfa/bfad_im.c | 13 |
3 files changed, 11 insertions, 5 deletions
diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c index 0baeabadb5b2..d4fc4287ebd3 100644 --- a/drivers/scsi/bfa/bfad.c +++ b/drivers/scsi/bfa/bfad.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <fcb/bfa_fcb.h> | 33 | #include <fcb/bfa_fcb.h> |
34 | 34 | ||
35 | BFA_TRC_FILE(LDRV, BFAD); | 35 | BFA_TRC_FILE(LDRV, BFAD); |
36 | static DEFINE_MUTEX(bfad_mutex); | 36 | DEFINE_MUTEX(bfad_mutex); |
37 | LIST_HEAD(bfad_list); | 37 | LIST_HEAD(bfad_list); |
38 | static int bfad_inst; | 38 | static int bfad_inst; |
39 | int bfad_supported_fc4s; | 39 | int bfad_supported_fc4s; |
diff --git a/drivers/scsi/bfa/bfad_drv.h b/drivers/scsi/bfa/bfad_drv.h index 0639aedcb610..6c920c1b53a4 100644 --- a/drivers/scsi/bfa/bfad_drv.h +++ b/drivers/scsi/bfa/bfad_drv.h | |||
@@ -293,5 +293,6 @@ extern struct list_head bfad_list; | |||
293 | extern int bfa_lun_queue_depth; | 293 | extern int bfa_lun_queue_depth; |
294 | extern int bfad_supported_fc4s; | 294 | extern int bfad_supported_fc4s; |
295 | extern int bfa_linkup_delay; | 295 | extern int bfa_linkup_delay; |
296 | extern struct mutex bfad_mutex; | ||
296 | 297 | ||
297 | #endif /* __BFAD_DRV_H__ */ | 298 | #endif /* __BFAD_DRV_H__ */ |
diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c index f263891b8cc6..5b7cf539e50b 100644 --- a/drivers/scsi/bfa/bfad_im.c +++ b/drivers/scsi/bfa/bfad_im.c | |||
@@ -518,7 +518,9 @@ bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port, | |||
518 | { | 518 | { |
519 | int error = 1; | 519 | int error = 1; |
520 | 520 | ||
521 | mutex_lock(&bfad_mutex); | ||
521 | if (!idr_pre_get(&bfad_im_port_index, GFP_KERNEL)) { | 522 | if (!idr_pre_get(&bfad_im_port_index, GFP_KERNEL)) { |
523 | mutex_unlock(&bfad_mutex); | ||
522 | printk(KERN_WARNING "idr_pre_get failure\n"); | 524 | printk(KERN_WARNING "idr_pre_get failure\n"); |
523 | goto out; | 525 | goto out; |
524 | } | 526 | } |
@@ -526,10 +528,13 @@ bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port, | |||
526 | error = idr_get_new(&bfad_im_port_index, im_port, | 528 | error = idr_get_new(&bfad_im_port_index, im_port, |
527 | &im_port->idr_id); | 529 | &im_port->idr_id); |
528 | if (error) { | 530 | if (error) { |
531 | mutex_unlock(&bfad_mutex); | ||
529 | printk(KERN_WARNING "idr_get_new failure\n"); | 532 | printk(KERN_WARNING "idr_get_new failure\n"); |
530 | goto out; | 533 | goto out; |
531 | } | 534 | } |
532 | 535 | ||
536 | mutex_unlock(&bfad_mutex); | ||
537 | |||
533 | im_port->shost = bfad_os_scsi_host_alloc(im_port, bfad); | 538 | im_port->shost = bfad_os_scsi_host_alloc(im_port, bfad); |
534 | if (!im_port->shost) { | 539 | if (!im_port->shost) { |
535 | error = 1; | 540 | error = 1; |
@@ -563,7 +568,9 @@ bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port, | |||
563 | out_fc_rel: | 568 | out_fc_rel: |
564 | scsi_host_put(im_port->shost); | 569 | scsi_host_put(im_port->shost); |
565 | out_free_idr: | 570 | out_free_idr: |
571 | mutex_lock(&bfad_mutex); | ||
566 | idr_remove(&bfad_im_port_index, im_port->idr_id); | 572 | idr_remove(&bfad_im_port_index, im_port->idr_id); |
573 | mutex_unlock(&bfad_mutex); | ||
567 | out: | 574 | out: |
568 | return error; | 575 | return error; |
569 | } | 576 | } |
@@ -571,8 +578,6 @@ out: | |||
571 | void | 578 | void |
572 | bfad_im_scsi_host_free(struct bfad_s *bfad, struct bfad_im_port_s *im_port) | 579 | bfad_im_scsi_host_free(struct bfad_s *bfad, struct bfad_im_port_s *im_port) |
573 | { | 580 | { |
574 | unsigned long flags; | ||
575 | |||
576 | bfa_trc(bfad, bfad->inst_no); | 581 | bfa_trc(bfad, bfad->inst_no); |
577 | bfa_log(bfad->logmod, BFA_LOG_LINUX_SCSI_HOST_FREE, | 582 | bfa_log(bfad->logmod, BFA_LOG_LINUX_SCSI_HOST_FREE, |
578 | im_port->shost->host_no); | 583 | im_port->shost->host_no); |
@@ -582,9 +587,9 @@ bfad_im_scsi_host_free(struct bfad_s *bfad, struct bfad_im_port_s *im_port) | |||
582 | scsi_remove_host(im_port->shost); | 587 | scsi_remove_host(im_port->shost); |
583 | scsi_host_put(im_port->shost); | 588 | scsi_host_put(im_port->shost); |
584 | 589 | ||
585 | spin_lock_irqsave(&bfad->bfad_lock, flags); | 590 | mutex_lock(&bfad_mutex); |
586 | idr_remove(&bfad_im_port_index, im_port->idr_id); | 591 | idr_remove(&bfad_im_port_index, im_port->idr_id); |
587 | spin_unlock_irqrestore(&bfad->bfad_lock, flags); | 592 | mutex_unlock(&bfad_mutex); |
588 | } | 593 | } |
589 | 594 | ||
590 | static void | 595 | static void |