aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target/target_core_stat.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/target/target_core_stat.c')
-rw-r--r--drivers/target/target_core_stat.c611
1 files changed, 267 insertions, 344 deletions
diff --git a/drivers/target/target_core_stat.c b/drivers/target/target_core_stat.c
index 03538994d2f7..20ed5d2e151a 100644
--- a/drivers/target/target_core_stat.c
+++ b/drivers/target/target_core_stat.c
@@ -33,14 +33,10 @@
33#include <linux/proc_fs.h> 33#include <linux/proc_fs.h>
34#include <linux/seq_file.h> 34#include <linux/seq_file.h>
35#include <linux/configfs.h> 35#include <linux/configfs.h>
36#include <scsi/scsi.h>
37#include <scsi/scsi_device.h>
38#include <scsi/scsi_host.h>
39 36
40#include <target/target_core_base.h> 37#include <target/target_core_base.h>
41#include <target/target_core_backend.h> 38#include <target/target_core_backend.h>
42#include <target/target_core_fabric.h> 39#include <target/target_core_fabric.h>
43#include <target/target_core_configfs.h>
44#include <target/configfs_macros.h> 40#include <target/configfs_macros.h>
45 41
46#include "target_core_internal.h" 42#include "target_core_internal.h"
@@ -107,7 +103,7 @@ static ssize_t target_stat_scsi_dev_show_attr_ports(
107 struct se_device *dev = 103 struct se_device *dev =
108 container_of(sgrps, struct se_device, dev_stat_grps); 104 container_of(sgrps, struct se_device, dev_stat_grps);
109 105
110 return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_port_count); 106 return snprintf(page, PAGE_SIZE, "%u\n", dev->export_count);
111} 107}
112DEV_STAT_SCSI_DEV_ATTR_RO(ports); 108DEV_STAT_SCSI_DEV_ATTR_RO(ports);
113 109
@@ -543,20 +539,14 @@ static ssize_t target_stat_scsi_port_show_attr_inst(
543 struct se_port_stat_grps *pgrps, char *page) 539 struct se_port_stat_grps *pgrps, char *page)
544{ 540{
545 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 541 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
546 struct se_port *sep; 542 struct se_device *dev;
547 struct se_device *dev = lun->lun_se_dev; 543 ssize_t ret = -ENODEV;
548 struct se_hba *hba; 544
549 ssize_t ret; 545 rcu_read_lock();
550 546 dev = rcu_dereference(lun->lun_se_dev);
551 spin_lock(&lun->lun_sep_lock); 547 if (dev)
552 sep = lun->lun_sep; 548 ret = snprintf(page, PAGE_SIZE, "%u\n", dev->hba_index);
553 if (!sep) { 549 rcu_read_unlock();
554 spin_unlock(&lun->lun_sep_lock);
555 return -ENODEV;
556 }
557 hba = dev->se_hba;
558 ret = snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index);
559 spin_unlock(&lun->lun_sep_lock);
560 return ret; 550 return ret;
561} 551}
562DEV_STAT_SCSI_PORT_ATTR_RO(inst); 552DEV_STAT_SCSI_PORT_ATTR_RO(inst);
@@ -565,18 +555,14 @@ static ssize_t target_stat_scsi_port_show_attr_dev(
565 struct se_port_stat_grps *pgrps, char *page) 555 struct se_port_stat_grps *pgrps, char *page)
566{ 556{
567 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 557 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
568 struct se_port *sep; 558 struct se_device *dev;
569 struct se_device *dev = lun->lun_se_dev; 559 ssize_t ret = -ENODEV;
570 ssize_t ret; 560
571 561 rcu_read_lock();
572 spin_lock(&lun->lun_sep_lock); 562 dev = rcu_dereference(lun->lun_se_dev);
573 sep = lun->lun_sep; 563 if (dev)
574 if (!sep) { 564 ret = snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index);
575 spin_unlock(&lun->lun_sep_lock); 565 rcu_read_unlock();
576 return -ENODEV;
577 }
578 ret = snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index);
579 spin_unlock(&lun->lun_sep_lock);
580 return ret; 566 return ret;
581} 567}
582DEV_STAT_SCSI_PORT_ATTR_RO(dev); 568DEV_STAT_SCSI_PORT_ATTR_RO(dev);
@@ -585,17 +571,14 @@ static ssize_t target_stat_scsi_port_show_attr_indx(
585 struct se_port_stat_grps *pgrps, char *page) 571 struct se_port_stat_grps *pgrps, char *page)
586{ 572{
587 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 573 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
588 struct se_port *sep; 574 struct se_device *dev;
589 ssize_t ret; 575 ssize_t ret = -ENODEV;
590 576
591 spin_lock(&lun->lun_sep_lock); 577 rcu_read_lock();
592 sep = lun->lun_sep; 578 dev = rcu_dereference(lun->lun_se_dev);
593 if (!sep) { 579 if (dev)
594 spin_unlock(&lun->lun_sep_lock); 580 ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_rtpi);
595 return -ENODEV; 581 rcu_read_unlock();
596 }
597 ret = snprintf(page, PAGE_SIZE, "%u\n", sep->sep_index);
598 spin_unlock(&lun->lun_sep_lock);
599 return ret; 582 return ret;
600} 583}
601DEV_STAT_SCSI_PORT_ATTR_RO(indx); 584DEV_STAT_SCSI_PORT_ATTR_RO(indx);
@@ -604,21 +587,14 @@ static ssize_t target_stat_scsi_port_show_attr_role(
604 struct se_port_stat_grps *pgrps, char *page) 587 struct se_port_stat_grps *pgrps, char *page)
605{ 588{
606 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 589 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
607 struct se_device *dev = lun->lun_se_dev; 590 struct se_device *dev;
608 struct se_port *sep; 591 ssize_t ret = -ENODEV;
609 ssize_t ret; 592
610 593 rcu_read_lock();
611 if (!dev) 594 dev = rcu_dereference(lun->lun_se_dev);
612 return -ENODEV; 595 if (dev)
613 596 ret = snprintf(page, PAGE_SIZE, "%s%u\n", "Device", dev->dev_index);
614 spin_lock(&lun->lun_sep_lock); 597 rcu_read_unlock();
615 sep = lun->lun_sep;
616 if (!sep) {
617 spin_unlock(&lun->lun_sep_lock);
618 return -ENODEV;
619 }
620 ret = snprintf(page, PAGE_SIZE, "%s%u\n", "Device", dev->dev_index);
621 spin_unlock(&lun->lun_sep_lock);
622 return ret; 598 return ret;
623} 599}
624DEV_STAT_SCSI_PORT_ATTR_RO(role); 600DEV_STAT_SCSI_PORT_ATTR_RO(role);
@@ -627,18 +603,16 @@ static ssize_t target_stat_scsi_port_show_attr_busy_count(
627 struct se_port_stat_grps *pgrps, char *page) 603 struct se_port_stat_grps *pgrps, char *page)
628{ 604{
629 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 605 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
630 struct se_port *sep; 606 struct se_device *dev;
631 ssize_t ret; 607 ssize_t ret = -ENODEV;
632 608
633 spin_lock(&lun->lun_sep_lock); 609 rcu_read_lock();
634 sep = lun->lun_sep; 610 dev = rcu_dereference(lun->lun_se_dev);
635 if (!sep) { 611 if (dev) {
636 spin_unlock(&lun->lun_sep_lock); 612 /* FIXME: scsiPortBusyStatuses */
637 return -ENODEV; 613 ret = snprintf(page, PAGE_SIZE, "%u\n", 0);
638 } 614 }
639 /* FIXME: scsiPortBusyStatuses */ 615 rcu_read_unlock();
640 ret = snprintf(page, PAGE_SIZE, "%u\n", 0);
641 spin_unlock(&lun->lun_sep_lock);
642 return ret; 616 return ret;
643} 617}
644DEV_STAT_SCSI_PORT_ATTR_RO(busy_count); 618DEV_STAT_SCSI_PORT_ATTR_RO(busy_count);
@@ -686,20 +660,14 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_inst(
686 struct se_port_stat_grps *pgrps, char *page) 660 struct se_port_stat_grps *pgrps, char *page)
687{ 661{
688 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 662 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
689 struct se_device *dev = lun->lun_se_dev; 663 struct se_device *dev;
690 struct se_port *sep; 664 ssize_t ret = -ENODEV;
691 struct se_hba *hba; 665
692 ssize_t ret; 666 rcu_read_lock();
693 667 dev = rcu_dereference(lun->lun_se_dev);
694 spin_lock(&lun->lun_sep_lock); 668 if (dev)
695 sep = lun->lun_sep; 669 ret = snprintf(page, PAGE_SIZE, "%u\n", dev->hba_index);
696 if (!sep) { 670 rcu_read_unlock();
697 spin_unlock(&lun->lun_sep_lock);
698 return -ENODEV;
699 }
700 hba = dev->se_hba;
701 ret = snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index);
702 spin_unlock(&lun->lun_sep_lock);
703 return ret; 671 return ret;
704} 672}
705DEV_STAT_SCSI_TGT_PORT_ATTR_RO(inst); 673DEV_STAT_SCSI_TGT_PORT_ATTR_RO(inst);
@@ -708,18 +676,14 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_dev(
708 struct se_port_stat_grps *pgrps, char *page) 676 struct se_port_stat_grps *pgrps, char *page)
709{ 677{
710 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 678 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
711 struct se_device *dev = lun->lun_se_dev; 679 struct se_device *dev;
712 struct se_port *sep; 680 ssize_t ret = -ENODEV;
713 ssize_t ret; 681
714 682 rcu_read_lock();
715 spin_lock(&lun->lun_sep_lock); 683 dev = rcu_dereference(lun->lun_se_dev);
716 sep = lun->lun_sep; 684 if (dev)
717 if (!sep) { 685 ret = snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index);
718 spin_unlock(&lun->lun_sep_lock); 686 rcu_read_unlock();
719 return -ENODEV;
720 }
721 ret = snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index);
722 spin_unlock(&lun->lun_sep_lock);
723 return ret; 687 return ret;
724} 688}
725DEV_STAT_SCSI_TGT_PORT_ATTR_RO(dev); 689DEV_STAT_SCSI_TGT_PORT_ATTR_RO(dev);
@@ -728,17 +692,14 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_indx(
728 struct se_port_stat_grps *pgrps, char *page) 692 struct se_port_stat_grps *pgrps, char *page)
729{ 693{
730 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 694 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
731 struct se_port *sep; 695 struct se_device *dev;
732 ssize_t ret; 696 ssize_t ret = -ENODEV;
733 697
734 spin_lock(&lun->lun_sep_lock); 698 rcu_read_lock();
735 sep = lun->lun_sep; 699 dev = rcu_dereference(lun->lun_se_dev);
736 if (!sep) { 700 if (dev)
737 spin_unlock(&lun->lun_sep_lock); 701 ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_rtpi);
738 return -ENODEV; 702 rcu_read_unlock();
739 }
740 ret = snprintf(page, PAGE_SIZE, "%u\n", sep->sep_index);
741 spin_unlock(&lun->lun_sep_lock);
742 return ret; 703 return ret;
743} 704}
744DEV_STAT_SCSI_TGT_PORT_ATTR_RO(indx); 705DEV_STAT_SCSI_TGT_PORT_ATTR_RO(indx);
@@ -747,21 +708,17 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_name(
747 struct se_port_stat_grps *pgrps, char *page) 708 struct se_port_stat_grps *pgrps, char *page)
748{ 709{
749 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 710 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
750 struct se_port *sep; 711 struct se_portal_group *tpg = lun->lun_tpg;
751 struct se_portal_group *tpg; 712 struct se_device *dev;
752 ssize_t ret; 713 ssize_t ret = -ENODEV;
753 714
754 spin_lock(&lun->lun_sep_lock); 715 rcu_read_lock();
755 sep = lun->lun_sep; 716 dev = rcu_dereference(lun->lun_se_dev);
756 if (!sep) { 717 if (dev)
757 spin_unlock(&lun->lun_sep_lock); 718 ret = snprintf(page, PAGE_SIZE, "%sPort#%u\n",
758 return -ENODEV; 719 tpg->se_tpg_tfo->get_fabric_name(),
759 } 720 lun->lun_rtpi);
760 tpg = sep->sep_tpg; 721 rcu_read_unlock();
761
762 ret = snprintf(page, PAGE_SIZE, "%sPort#%u\n",
763 tpg->se_tpg_tfo->get_fabric_name(), sep->sep_index);
764 spin_unlock(&lun->lun_sep_lock);
765 return ret; 722 return ret;
766} 723}
767DEV_STAT_SCSI_TGT_PORT_ATTR_RO(name); 724DEV_STAT_SCSI_TGT_PORT_ATTR_RO(name);
@@ -770,22 +727,17 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_port_index(
770 struct se_port_stat_grps *pgrps, char *page) 727 struct se_port_stat_grps *pgrps, char *page)
771{ 728{
772 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 729 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
773 struct se_port *sep; 730 struct se_portal_group *tpg = lun->lun_tpg;
774 struct se_portal_group *tpg; 731 struct se_device *dev;
775 ssize_t ret; 732 ssize_t ret = -ENODEV;
776 733
777 spin_lock(&lun->lun_sep_lock); 734 rcu_read_lock();
778 sep = lun->lun_sep; 735 dev = rcu_dereference(lun->lun_se_dev);
779 if (!sep) { 736 if (dev)
780 spin_unlock(&lun->lun_sep_lock); 737 ret = snprintf(page, PAGE_SIZE, "%s%s%d\n",
781 return -ENODEV; 738 tpg->se_tpg_tfo->tpg_get_wwn(tpg), "+t+",
782 } 739 tpg->se_tpg_tfo->tpg_get_tag(tpg));
783 tpg = sep->sep_tpg; 740 rcu_read_unlock();
784
785 ret = snprintf(page, PAGE_SIZE, "%s%s%d\n",
786 tpg->se_tpg_tfo->tpg_get_wwn(tpg), "+t+",
787 tpg->se_tpg_tfo->tpg_get_tag(tpg));
788 spin_unlock(&lun->lun_sep_lock);
789 return ret; 741 return ret;
790} 742}
791DEV_STAT_SCSI_TGT_PORT_ATTR_RO(port_index); 743DEV_STAT_SCSI_TGT_PORT_ATTR_RO(port_index);
@@ -794,18 +746,15 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_in_cmds(
794 struct se_port_stat_grps *pgrps, char *page) 746 struct se_port_stat_grps *pgrps, char *page)
795{ 747{
796 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 748 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
797 struct se_port *sep; 749 struct se_device *dev;
798 ssize_t ret; 750 ssize_t ret = -ENODEV;
799 751
800 spin_lock(&lun->lun_sep_lock); 752 rcu_read_lock();
801 sep = lun->lun_sep; 753 dev = rcu_dereference(lun->lun_se_dev);
802 if (!sep) { 754 if (dev)
803 spin_unlock(&lun->lun_sep_lock); 755 ret = snprintf(page, PAGE_SIZE, "%lu\n",
804 return -ENODEV; 756 atomic_long_read(&lun->lun_stats.cmd_pdus));
805 } 757 rcu_read_unlock();
806
807 ret = snprintf(page, PAGE_SIZE, "%llu\n", sep->sep_stats.cmd_pdus);
808 spin_unlock(&lun->lun_sep_lock);
809 return ret; 758 return ret;
810} 759}
811DEV_STAT_SCSI_TGT_PORT_ATTR_RO(in_cmds); 760DEV_STAT_SCSI_TGT_PORT_ATTR_RO(in_cmds);
@@ -814,19 +763,15 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_write_mbytes(
814 struct se_port_stat_grps *pgrps, char *page) 763 struct se_port_stat_grps *pgrps, char *page)
815{ 764{
816 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 765 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
817 struct se_port *sep; 766 struct se_device *dev;
818 ssize_t ret; 767 ssize_t ret = -ENODEV;
819 768
820 spin_lock(&lun->lun_sep_lock); 769 rcu_read_lock();
821 sep = lun->lun_sep; 770 dev = rcu_dereference(lun->lun_se_dev);
822 if (!sep) { 771 if (dev)
823 spin_unlock(&lun->lun_sep_lock); 772 ret = snprintf(page, PAGE_SIZE, "%u\n",
824 return -ENODEV; 773 (u32)(atomic_long_read(&lun->lun_stats.rx_data_octets) >> 20));
825 } 774 rcu_read_unlock();
826
827 ret = snprintf(page, PAGE_SIZE, "%u\n",
828 (u32)(sep->sep_stats.rx_data_octets >> 20));
829 spin_unlock(&lun->lun_sep_lock);
830 return ret; 775 return ret;
831} 776}
832DEV_STAT_SCSI_TGT_PORT_ATTR_RO(write_mbytes); 777DEV_STAT_SCSI_TGT_PORT_ATTR_RO(write_mbytes);
@@ -835,19 +780,15 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_read_mbytes(
835 struct se_port_stat_grps *pgrps, char *page) 780 struct se_port_stat_grps *pgrps, char *page)
836{ 781{
837 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 782 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
838 struct se_port *sep; 783 struct se_device *dev;
839 ssize_t ret; 784 ssize_t ret = -ENODEV;
840 785
841 spin_lock(&lun->lun_sep_lock); 786 rcu_read_lock();
842 sep = lun->lun_sep; 787 dev = rcu_dereference(lun->lun_se_dev);
843 if (!sep) { 788 if (dev)
844 spin_unlock(&lun->lun_sep_lock); 789 ret = snprintf(page, PAGE_SIZE, "%u\n",
845 return -ENODEV; 790 (u32)(atomic_long_read(&lun->lun_stats.tx_data_octets) >> 20));
846 } 791 rcu_read_unlock();
847
848 ret = snprintf(page, PAGE_SIZE, "%u\n",
849 (u32)(sep->sep_stats.tx_data_octets >> 20));
850 spin_unlock(&lun->lun_sep_lock);
851 return ret; 792 return ret;
852} 793}
853DEV_STAT_SCSI_TGT_PORT_ATTR_RO(read_mbytes); 794DEV_STAT_SCSI_TGT_PORT_ATTR_RO(read_mbytes);
@@ -856,19 +797,16 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_hs_in_cmds(
856 struct se_port_stat_grps *pgrps, char *page) 797 struct se_port_stat_grps *pgrps, char *page)
857{ 798{
858 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 799 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
859 struct se_port *sep; 800 struct se_device *dev;
860 ssize_t ret; 801 ssize_t ret = -ENODEV;
861 802
862 spin_lock(&lun->lun_sep_lock); 803 rcu_read_lock();
863 sep = lun->lun_sep; 804 dev = rcu_dereference(lun->lun_se_dev);
864 if (!sep) { 805 if (dev) {
865 spin_unlock(&lun->lun_sep_lock); 806 /* FIXME: scsiTgtPortHsInCommands */
866 return -ENODEV; 807 ret = snprintf(page, PAGE_SIZE, "%u\n", 0);
867 } 808 }
868 809 rcu_read_unlock();
869 /* FIXME: scsiTgtPortHsInCommands */
870 ret = snprintf(page, PAGE_SIZE, "%u\n", 0);
871 spin_unlock(&lun->lun_sep_lock);
872 return ret; 810 return ret;
873} 811}
874DEV_STAT_SCSI_TGT_PORT_ATTR_RO(hs_in_cmds); 812DEV_STAT_SCSI_TGT_PORT_ATTR_RO(hs_in_cmds);
@@ -922,21 +860,14 @@ static ssize_t target_stat_scsi_transport_show_attr_inst(
922 struct se_port_stat_grps *pgrps, char *page) 860 struct se_port_stat_grps *pgrps, char *page)
923{ 861{
924 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 862 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
925 struct se_device *dev = lun->lun_se_dev; 863 struct se_device *dev;
926 struct se_port *sep; 864 ssize_t ret = -ENODEV;
927 struct se_hba *hba; 865
928 ssize_t ret; 866 rcu_read_lock();
929 867 dev = rcu_dereference(lun->lun_se_dev);
930 spin_lock(&lun->lun_sep_lock); 868 if (dev)
931 sep = lun->lun_sep; 869 ret = snprintf(page, PAGE_SIZE, "%u\n", dev->hba_index);
932 if (!sep) { 870 rcu_read_unlock();
933 spin_unlock(&lun->lun_sep_lock);
934 return -ENODEV;
935 }
936
937 hba = dev->se_hba;
938 ret = snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index);
939 spin_unlock(&lun->lun_sep_lock);
940 return ret; 871 return ret;
941} 872}
942DEV_STAT_SCSI_TRANSPORT_ATTR_RO(inst); 873DEV_STAT_SCSI_TRANSPORT_ATTR_RO(inst);
@@ -945,21 +876,18 @@ static ssize_t target_stat_scsi_transport_show_attr_device(
945 struct se_port_stat_grps *pgrps, char *page) 876 struct se_port_stat_grps *pgrps, char *page)
946{ 877{
947 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 878 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
948 struct se_port *sep; 879 struct se_device *dev;
949 struct se_portal_group *tpg; 880 struct se_portal_group *tpg = lun->lun_tpg;
950 ssize_t ret; 881 ssize_t ret = -ENODEV;
951 882
952 spin_lock(&lun->lun_sep_lock); 883 rcu_read_lock();
953 sep = lun->lun_sep; 884 dev = rcu_dereference(lun->lun_se_dev);
954 if (!sep) { 885 if (dev) {
955 spin_unlock(&lun->lun_sep_lock); 886 /* scsiTransportType */
956 return -ENODEV; 887 ret = snprintf(page, PAGE_SIZE, "scsiTransport%s\n",
888 tpg->se_tpg_tfo->get_fabric_name());
957 } 889 }
958 tpg = sep->sep_tpg; 890 rcu_read_unlock();
959 /* scsiTransportType */
960 ret = snprintf(page, PAGE_SIZE, "scsiTransport%s\n",
961 tpg->se_tpg_tfo->get_fabric_name());
962 spin_unlock(&lun->lun_sep_lock);
963 return ret; 891 return ret;
964} 892}
965DEV_STAT_SCSI_TRANSPORT_ATTR_RO(device); 893DEV_STAT_SCSI_TRANSPORT_ATTR_RO(device);
@@ -968,20 +896,16 @@ static ssize_t target_stat_scsi_transport_show_attr_indx(
968 struct se_port_stat_grps *pgrps, char *page) 896 struct se_port_stat_grps *pgrps, char *page)
969{ 897{
970 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 898 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
971 struct se_port *sep; 899 struct se_device *dev;
972 struct se_portal_group *tpg; 900 struct se_portal_group *tpg = lun->lun_tpg;
973 ssize_t ret; 901 ssize_t ret = -ENODEV;
974 902
975 spin_lock(&lun->lun_sep_lock); 903 rcu_read_lock();
976 sep = lun->lun_sep; 904 dev = rcu_dereference(lun->lun_se_dev);
977 if (!sep) { 905 if (dev)
978 spin_unlock(&lun->lun_sep_lock); 906 ret = snprintf(page, PAGE_SIZE, "%u\n",
979 return -ENODEV; 907 tpg->se_tpg_tfo->tpg_get_inst_index(tpg));
980 } 908 rcu_read_unlock();
981 tpg = sep->sep_tpg;
982 ret = snprintf(page, PAGE_SIZE, "%u\n",
983 tpg->se_tpg_tfo->tpg_get_inst_index(tpg));
984 spin_unlock(&lun->lun_sep_lock);
985 return ret; 909 return ret;
986} 910}
987DEV_STAT_SCSI_TRANSPORT_ATTR_RO(indx); 911DEV_STAT_SCSI_TRANSPORT_ATTR_RO(indx);
@@ -990,26 +914,22 @@ static ssize_t target_stat_scsi_transport_show_attr_dev_name(
990 struct se_port_stat_grps *pgrps, char *page) 914 struct se_port_stat_grps *pgrps, char *page)
991{ 915{
992 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 916 struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
993 struct se_device *dev = lun->lun_se_dev; 917 struct se_device *dev;
994 struct se_port *sep; 918 struct se_portal_group *tpg = lun->lun_tpg;
995 struct se_portal_group *tpg;
996 struct t10_wwn *wwn; 919 struct t10_wwn *wwn;
997 ssize_t ret; 920 ssize_t ret = -ENODEV;
998 921
999 spin_lock(&lun->lun_sep_lock); 922 rcu_read_lock();
1000 sep = lun->lun_sep; 923 dev = rcu_dereference(lun->lun_se_dev);
1001 if (!sep) { 924 if (dev) {
1002 spin_unlock(&lun->lun_sep_lock); 925 wwn = &dev->t10_wwn;
1003 return -ENODEV; 926 /* scsiTransportDevName */
927 ret = snprintf(page, PAGE_SIZE, "%s+%s\n",
928 tpg->se_tpg_tfo->tpg_get_wwn(tpg),
929 (strlen(wwn->unit_serial)) ? wwn->unit_serial :
930 wwn->vendor);
1004 } 931 }
1005 tpg = sep->sep_tpg; 932 rcu_read_unlock();
1006 wwn = &dev->t10_wwn;
1007 /* scsiTransportDevName */
1008 ret = snprintf(page, PAGE_SIZE, "%s+%s\n",
1009 tpg->se_tpg_tfo->tpg_get_wwn(tpg),
1010 (strlen(wwn->unit_serial)) ? wwn->unit_serial :
1011 wwn->vendor);
1012 spin_unlock(&lun->lun_sep_lock);
1013 return ret; 933 return ret;
1014} 934}
1015DEV_STAT_SCSI_TRANSPORT_ATTR_RO(dev_name); 935DEV_STAT_SCSI_TRANSPORT_ATTR_RO(dev_name);
@@ -1085,17 +1005,17 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_inst(
1085 struct se_portal_group *tpg; 1005 struct se_portal_group *tpg;
1086 ssize_t ret; 1006 ssize_t ret;
1087 1007
1088 spin_lock_irq(&nacl->device_list_lock); 1008 rcu_read_lock();
1089 deve = nacl->device_list[lacl->mapped_lun]; 1009 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1090 if (!deve->se_lun || !deve->se_lun_acl) { 1010 if (!deve) {
1091 spin_unlock_irq(&nacl->device_list_lock); 1011 rcu_read_unlock();
1092 return -ENODEV; 1012 return -ENODEV;
1093 } 1013 }
1094 tpg = nacl->se_tpg; 1014 tpg = nacl->se_tpg;
1095 /* scsiInstIndex */ 1015 /* scsiInstIndex */
1096 ret = snprintf(page, PAGE_SIZE, "%u\n", 1016 ret = snprintf(page, PAGE_SIZE, "%u\n",
1097 tpg->se_tpg_tfo->tpg_get_inst_index(tpg)); 1017 tpg->se_tpg_tfo->tpg_get_inst_index(tpg));
1098 spin_unlock_irq(&nacl->device_list_lock); 1018 rcu_read_unlock();
1099 return ret; 1019 return ret;
1100} 1020}
1101DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(inst); 1021DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(inst);
@@ -1110,16 +1030,16 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_dev(
1110 struct se_lun *lun; 1030 struct se_lun *lun;
1111 ssize_t ret; 1031 ssize_t ret;
1112 1032
1113 spin_lock_irq(&nacl->device_list_lock); 1033 rcu_read_lock();
1114 deve = nacl->device_list[lacl->mapped_lun]; 1034 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1115 if (!deve->se_lun || !deve->se_lun_acl) { 1035 if (!deve) {
1116 spin_unlock_irq(&nacl->device_list_lock); 1036 rcu_read_unlock();
1117 return -ENODEV; 1037 return -ENODEV;
1118 } 1038 }
1119 lun = deve->se_lun; 1039 lun = rcu_dereference(deve->se_lun);
1120 /* scsiDeviceIndex */ 1040 /* scsiDeviceIndex */
1121 ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_se_dev->dev_index); 1041 ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_index);
1122 spin_unlock_irq(&nacl->device_list_lock); 1042 rcu_read_unlock();
1123 return ret; 1043 return ret;
1124} 1044}
1125DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(dev); 1045DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(dev);
@@ -1134,16 +1054,16 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_port(
1134 struct se_portal_group *tpg; 1054 struct se_portal_group *tpg;
1135 ssize_t ret; 1055 ssize_t ret;
1136 1056
1137 spin_lock_irq(&nacl->device_list_lock); 1057 rcu_read_lock();
1138 deve = nacl->device_list[lacl->mapped_lun]; 1058 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1139 if (!deve->se_lun || !deve->se_lun_acl) { 1059 if (!deve) {
1140 spin_unlock_irq(&nacl->device_list_lock); 1060 rcu_read_unlock();
1141 return -ENODEV; 1061 return -ENODEV;
1142 } 1062 }
1143 tpg = nacl->se_tpg; 1063 tpg = nacl->se_tpg;
1144 /* scsiAuthIntrTgtPortIndex */ 1064 /* scsiAuthIntrTgtPortIndex */
1145 ret = snprintf(page, PAGE_SIZE, "%u\n", tpg->se_tpg_tfo->tpg_get_tag(tpg)); 1065 ret = snprintf(page, PAGE_SIZE, "%u\n", tpg->se_tpg_tfo->tpg_get_tag(tpg));
1146 spin_unlock_irq(&nacl->device_list_lock); 1066 rcu_read_unlock();
1147 return ret; 1067 return ret;
1148} 1068}
1149DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(port); 1069DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(port);
@@ -1157,15 +1077,15 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_indx(
1157 struct se_dev_entry *deve; 1077 struct se_dev_entry *deve;
1158 ssize_t ret; 1078 ssize_t ret;
1159 1079
1160 spin_lock_irq(&nacl->device_list_lock); 1080 rcu_read_lock();
1161 deve = nacl->device_list[lacl->mapped_lun]; 1081 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1162 if (!deve->se_lun || !deve->se_lun_acl) { 1082 if (!deve) {
1163 spin_unlock_irq(&nacl->device_list_lock); 1083 rcu_read_unlock();
1164 return -ENODEV; 1084 return -ENODEV;
1165 } 1085 }
1166 /* scsiAuthIntrIndex */ 1086 /* scsiAuthIntrIndex */
1167 ret = snprintf(page, PAGE_SIZE, "%u\n", nacl->acl_index); 1087 ret = snprintf(page, PAGE_SIZE, "%u\n", nacl->acl_index);
1168 spin_unlock_irq(&nacl->device_list_lock); 1088 rcu_read_unlock();
1169 return ret; 1089 return ret;
1170} 1090}
1171DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(indx); 1091DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(indx);
@@ -1179,15 +1099,15 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_dev_or_port(
1179 struct se_dev_entry *deve; 1099 struct se_dev_entry *deve;
1180 ssize_t ret; 1100 ssize_t ret;
1181 1101
1182 spin_lock_irq(&nacl->device_list_lock); 1102 rcu_read_lock();
1183 deve = nacl->device_list[lacl->mapped_lun]; 1103 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1184 if (!deve->se_lun || !deve->se_lun_acl) { 1104 if (!deve) {
1185 spin_unlock_irq(&nacl->device_list_lock); 1105 rcu_read_unlock();
1186 return -ENODEV; 1106 return -ENODEV;
1187 } 1107 }
1188 /* scsiAuthIntrDevOrPort */ 1108 /* scsiAuthIntrDevOrPort */
1189 ret = snprintf(page, PAGE_SIZE, "%u\n", 1); 1109 ret = snprintf(page, PAGE_SIZE, "%u\n", 1);
1190 spin_unlock_irq(&nacl->device_list_lock); 1110 rcu_read_unlock();
1191 return ret; 1111 return ret;
1192} 1112}
1193DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(dev_or_port); 1113DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(dev_or_port);
@@ -1201,15 +1121,15 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_intr_name(
1201 struct se_dev_entry *deve; 1121 struct se_dev_entry *deve;
1202 ssize_t ret; 1122 ssize_t ret;
1203 1123
1204 spin_lock_irq(&nacl->device_list_lock); 1124 rcu_read_lock();
1205 deve = nacl->device_list[lacl->mapped_lun]; 1125 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1206 if (!deve->se_lun || !deve->se_lun_acl) { 1126 if (!deve) {
1207 spin_unlock_irq(&nacl->device_list_lock); 1127 rcu_read_unlock();
1208 return -ENODEV; 1128 return -ENODEV;
1209 } 1129 }
1210 /* scsiAuthIntrName */ 1130 /* scsiAuthIntrName */
1211 ret = snprintf(page, PAGE_SIZE, "%s\n", nacl->initiatorname); 1131 ret = snprintf(page, PAGE_SIZE, "%s\n", nacl->initiatorname);
1212 spin_unlock_irq(&nacl->device_list_lock); 1132 rcu_read_unlock();
1213 return ret; 1133 return ret;
1214} 1134}
1215DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(intr_name); 1135DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(intr_name);
@@ -1223,15 +1143,15 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_map_indx(
1223 struct se_dev_entry *deve; 1143 struct se_dev_entry *deve;
1224 ssize_t ret; 1144 ssize_t ret;
1225 1145
1226 spin_lock_irq(&nacl->device_list_lock); 1146 rcu_read_lock();
1227 deve = nacl->device_list[lacl->mapped_lun]; 1147 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1228 if (!deve->se_lun || !deve->se_lun_acl) { 1148 if (!deve) {
1229 spin_unlock_irq(&nacl->device_list_lock); 1149 rcu_read_unlock();
1230 return -ENODEV; 1150 return -ENODEV;
1231 } 1151 }
1232 /* FIXME: scsiAuthIntrLunMapIndex */ 1152 /* FIXME: scsiAuthIntrLunMapIndex */
1233 ret = snprintf(page, PAGE_SIZE, "%u\n", 0); 1153 ret = snprintf(page, PAGE_SIZE, "%u\n", 0);
1234 spin_unlock_irq(&nacl->device_list_lock); 1154 rcu_read_unlock();
1235 return ret; 1155 return ret;
1236} 1156}
1237DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(map_indx); 1157DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(map_indx);
@@ -1245,15 +1165,15 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_att_count(
1245 struct se_dev_entry *deve; 1165 struct se_dev_entry *deve;
1246 ssize_t ret; 1166 ssize_t ret;
1247 1167
1248 spin_lock_irq(&nacl->device_list_lock); 1168 rcu_read_lock();
1249 deve = nacl->device_list[lacl->mapped_lun]; 1169 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1250 if (!deve->se_lun || !deve->se_lun_acl) { 1170 if (!deve) {
1251 spin_unlock_irq(&nacl->device_list_lock); 1171 rcu_read_unlock();
1252 return -ENODEV; 1172 return -ENODEV;
1253 } 1173 }
1254 /* scsiAuthIntrAttachedTimes */ 1174 /* scsiAuthIntrAttachedTimes */
1255 ret = snprintf(page, PAGE_SIZE, "%u\n", deve->attach_count); 1175 ret = snprintf(page, PAGE_SIZE, "%u\n", deve->attach_count);
1256 spin_unlock_irq(&nacl->device_list_lock); 1176 rcu_read_unlock();
1257 return ret; 1177 return ret;
1258} 1178}
1259DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(att_count); 1179DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(att_count);
@@ -1267,15 +1187,16 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_num_cmds(
1267 struct se_dev_entry *deve; 1187 struct se_dev_entry *deve;
1268 ssize_t ret; 1188 ssize_t ret;
1269 1189
1270 spin_lock_irq(&nacl->device_list_lock); 1190 rcu_read_lock();
1271 deve = nacl->device_list[lacl->mapped_lun]; 1191 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1272 if (!deve->se_lun || !deve->se_lun_acl) { 1192 if (!deve) {
1273 spin_unlock_irq(&nacl->device_list_lock); 1193 rcu_read_unlock();
1274 return -ENODEV; 1194 return -ENODEV;
1275 } 1195 }
1276 /* scsiAuthIntrOutCommands */ 1196 /* scsiAuthIntrOutCommands */
1277 ret = snprintf(page, PAGE_SIZE, "%u\n", deve->total_cmds); 1197 ret = snprintf(page, PAGE_SIZE, "%lu\n",
1278 spin_unlock_irq(&nacl->device_list_lock); 1198 atomic_long_read(&deve->total_cmds));
1199 rcu_read_unlock();
1279 return ret; 1200 return ret;
1280} 1201}
1281DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(num_cmds); 1202DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(num_cmds);
@@ -1289,15 +1210,16 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_read_mbytes(
1289 struct se_dev_entry *deve; 1210 struct se_dev_entry *deve;
1290 ssize_t ret; 1211 ssize_t ret;
1291 1212
1292 spin_lock_irq(&nacl->device_list_lock); 1213 rcu_read_lock();
1293 deve = nacl->device_list[lacl->mapped_lun]; 1214 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1294 if (!deve->se_lun || !deve->se_lun_acl) { 1215 if (!deve) {
1295 spin_unlock_irq(&nacl->device_list_lock); 1216 rcu_read_unlock();
1296 return -ENODEV; 1217 return -ENODEV;
1297 } 1218 }
1298 /* scsiAuthIntrReadMegaBytes */ 1219 /* scsiAuthIntrReadMegaBytes */
1299 ret = snprintf(page, PAGE_SIZE, "%u\n", (u32)(deve->read_bytes >> 20)); 1220 ret = snprintf(page, PAGE_SIZE, "%u\n",
1300 spin_unlock_irq(&nacl->device_list_lock); 1221 (u32)(atomic_long_read(&deve->read_bytes) >> 20));
1222 rcu_read_unlock();
1301 return ret; 1223 return ret;
1302} 1224}
1303DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(read_mbytes); 1225DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(read_mbytes);
@@ -1311,15 +1233,16 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_write_mbytes(
1311 struct se_dev_entry *deve; 1233 struct se_dev_entry *deve;
1312 ssize_t ret; 1234 ssize_t ret;
1313 1235
1314 spin_lock_irq(&nacl->device_list_lock); 1236 rcu_read_lock();
1315 deve = nacl->device_list[lacl->mapped_lun]; 1237 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1316 if (!deve->se_lun || !deve->se_lun_acl) { 1238 if (!deve) {
1317 spin_unlock_irq(&nacl->device_list_lock); 1239 rcu_read_unlock();
1318 return -ENODEV; 1240 return -ENODEV;
1319 } 1241 }
1320 /* scsiAuthIntrWrittenMegaBytes */ 1242 /* scsiAuthIntrWrittenMegaBytes */
1321 ret = snprintf(page, PAGE_SIZE, "%u\n", (u32)(deve->write_bytes >> 20)); 1243 ret = snprintf(page, PAGE_SIZE, "%u\n",
1322 spin_unlock_irq(&nacl->device_list_lock); 1244 (u32)(atomic_long_read(&deve->write_bytes) >> 20));
1245 rcu_read_unlock();
1323 return ret; 1246 return ret;
1324} 1247}
1325DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(write_mbytes); 1248DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(write_mbytes);
@@ -1333,15 +1256,15 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_hs_num_cmds(
1333 struct se_dev_entry *deve; 1256 struct se_dev_entry *deve;
1334 ssize_t ret; 1257 ssize_t ret;
1335 1258
1336 spin_lock_irq(&nacl->device_list_lock); 1259 rcu_read_lock();
1337 deve = nacl->device_list[lacl->mapped_lun]; 1260 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1338 if (!deve->se_lun || !deve->se_lun_acl) { 1261 if (!deve) {
1339 spin_unlock_irq(&nacl->device_list_lock); 1262 rcu_read_unlock();
1340 return -ENODEV; 1263 return -ENODEV;
1341 } 1264 }
1342 /* FIXME: scsiAuthIntrHSOutCommands */ 1265 /* FIXME: scsiAuthIntrHSOutCommands */
1343 ret = snprintf(page, PAGE_SIZE, "%u\n", 0); 1266 ret = snprintf(page, PAGE_SIZE, "%u\n", 0);
1344 spin_unlock_irq(&nacl->device_list_lock); 1267 rcu_read_unlock();
1345 return ret; 1268 return ret;
1346} 1269}
1347DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(hs_num_cmds); 1270DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(hs_num_cmds);
@@ -1355,16 +1278,16 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_creation_time(
1355 struct se_dev_entry *deve; 1278 struct se_dev_entry *deve;
1356 ssize_t ret; 1279 ssize_t ret;
1357 1280
1358 spin_lock_irq(&nacl->device_list_lock); 1281 rcu_read_lock();
1359 deve = nacl->device_list[lacl->mapped_lun]; 1282 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1360 if (!deve->se_lun || !deve->se_lun_acl) { 1283 if (!deve) {
1361 spin_unlock_irq(&nacl->device_list_lock); 1284 rcu_read_unlock();
1362 return -ENODEV; 1285 return -ENODEV;
1363 } 1286 }
1364 /* scsiAuthIntrLastCreation */ 1287 /* scsiAuthIntrLastCreation */
1365 ret = snprintf(page, PAGE_SIZE, "%u\n", (u32)(((u32)deve->creation_time - 1288 ret = snprintf(page, PAGE_SIZE, "%u\n", (u32)(((u32)deve->creation_time -
1366 INITIAL_JIFFIES) * 100 / HZ)); 1289 INITIAL_JIFFIES) * 100 / HZ));
1367 spin_unlock_irq(&nacl->device_list_lock); 1290 rcu_read_unlock();
1368 return ret; 1291 return ret;
1369} 1292}
1370DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(creation_time); 1293DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(creation_time);
@@ -1378,15 +1301,15 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_row_status(
1378 struct se_dev_entry *deve; 1301 struct se_dev_entry *deve;
1379 ssize_t ret; 1302 ssize_t ret;
1380 1303
1381 spin_lock_irq(&nacl->device_list_lock); 1304 rcu_read_lock();
1382 deve = nacl->device_list[lacl->mapped_lun]; 1305 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1383 if (!deve->se_lun || !deve->se_lun_acl) { 1306 if (!deve) {
1384 spin_unlock_irq(&nacl->device_list_lock); 1307 rcu_read_unlock();
1385 return -ENODEV; 1308 return -ENODEV;
1386 } 1309 }
1387 /* FIXME: scsiAuthIntrRowStatus */ 1310 /* FIXME: scsiAuthIntrRowStatus */
1388 ret = snprintf(page, PAGE_SIZE, "Ready\n"); 1311 ret = snprintf(page, PAGE_SIZE, "Ready\n");
1389 spin_unlock_irq(&nacl->device_list_lock); 1312 rcu_read_unlock();
1390 return ret; 1313 return ret;
1391} 1314}
1392DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(row_status); 1315DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(row_status);
@@ -1451,17 +1374,17 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_inst(
1451 struct se_portal_group *tpg; 1374 struct se_portal_group *tpg;
1452 ssize_t ret; 1375 ssize_t ret;
1453 1376
1454 spin_lock_irq(&nacl->device_list_lock); 1377 rcu_read_lock();
1455 deve = nacl->device_list[lacl->mapped_lun]; 1378 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1456 if (!deve->se_lun || !deve->se_lun_acl) { 1379 if (!deve) {
1457 spin_unlock_irq(&nacl->device_list_lock); 1380 rcu_read_unlock();
1458 return -ENODEV; 1381 return -ENODEV;
1459 } 1382 }
1460 tpg = nacl->se_tpg; 1383 tpg = nacl->se_tpg;
1461 /* scsiInstIndex */ 1384 /* scsiInstIndex */
1462 ret = snprintf(page, PAGE_SIZE, "%u\n", 1385 ret = snprintf(page, PAGE_SIZE, "%u\n",
1463 tpg->se_tpg_tfo->tpg_get_inst_index(tpg)); 1386 tpg->se_tpg_tfo->tpg_get_inst_index(tpg));
1464 spin_unlock_irq(&nacl->device_list_lock); 1387 rcu_read_unlock();
1465 return ret; 1388 return ret;
1466} 1389}
1467DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(inst); 1390DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(inst);
@@ -1476,16 +1399,16 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_dev(
1476 struct se_lun *lun; 1399 struct se_lun *lun;
1477 ssize_t ret; 1400 ssize_t ret;
1478 1401
1479 spin_lock_irq(&nacl->device_list_lock); 1402 rcu_read_lock();
1480 deve = nacl->device_list[lacl->mapped_lun]; 1403 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1481 if (!deve->se_lun || !deve->se_lun_acl) { 1404 if (!deve) {
1482 spin_unlock_irq(&nacl->device_list_lock); 1405 rcu_read_unlock();
1483 return -ENODEV; 1406 return -ENODEV;
1484 } 1407 }
1485 lun = deve->se_lun; 1408 lun = rcu_dereference(deve->se_lun);
1486 /* scsiDeviceIndex */ 1409 /* scsiDeviceIndex */
1487 ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_se_dev->dev_index); 1410 ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_index);
1488 spin_unlock_irq(&nacl->device_list_lock); 1411 rcu_read_unlock();
1489 return ret; 1412 return ret;
1490} 1413}
1491DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(dev); 1414DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(dev);
@@ -1500,16 +1423,16 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_port(
1500 struct se_portal_group *tpg; 1423 struct se_portal_group *tpg;
1501 ssize_t ret; 1424 ssize_t ret;
1502 1425
1503 spin_lock_irq(&nacl->device_list_lock); 1426 rcu_read_lock();
1504 deve = nacl->device_list[lacl->mapped_lun]; 1427 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1505 if (!deve->se_lun || !deve->se_lun_acl) { 1428 if (!deve) {
1506 spin_unlock_irq(&nacl->device_list_lock); 1429 rcu_read_unlock();
1507 return -ENODEV; 1430 return -ENODEV;
1508 } 1431 }
1509 tpg = nacl->se_tpg; 1432 tpg = nacl->se_tpg;
1510 /* scsiPortIndex */ 1433 /* scsiPortIndex */
1511 ret = snprintf(page, PAGE_SIZE, "%u\n", tpg->se_tpg_tfo->tpg_get_tag(tpg)); 1434 ret = snprintf(page, PAGE_SIZE, "%u\n", tpg->se_tpg_tfo->tpg_get_tag(tpg));
1512 spin_unlock_irq(&nacl->device_list_lock); 1435 rcu_read_unlock();
1513 return ret; 1436 return ret;
1514} 1437}
1515DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port); 1438DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port);
@@ -1549,15 +1472,15 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_port_auth_indx(
1549 struct se_dev_entry *deve; 1472 struct se_dev_entry *deve;
1550 ssize_t ret; 1473 ssize_t ret;
1551 1474
1552 spin_lock_irq(&nacl->device_list_lock); 1475 rcu_read_lock();
1553 deve = nacl->device_list[lacl->mapped_lun]; 1476 deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
1554 if (!deve->se_lun || !deve->se_lun_acl) { 1477 if (!deve) {
1555 spin_unlock_irq(&nacl->device_list_lock); 1478 rcu_read_unlock();
1556 return -ENODEV; 1479 return -ENODEV;
1557 } 1480 }
1558 /* scsiAttIntrPortAuthIntrIdx */ 1481 /* scsiAttIntrPortAuthIntrIdx */
1559 ret = snprintf(page, PAGE_SIZE, "%u\n", nacl->acl_index); 1482 ret = snprintf(page, PAGE_SIZE, "%u\n", nacl->acl_index);
1560 spin_unlock_irq(&nacl->device_list_lock); 1483 rcu_read_unlock();
1561 return ret; 1484 return ret;
1562} 1485}
1563DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port_auth_indx); 1486DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port_auth_indx);