Commit 05aea6e7e497ab418239ae54fe5966d52cbd8550
Committed by
James Bottomley
1 parent
613640e4e1
Exists in
master
and in
7 other branches
[SCSI] target: Remove unnecessary hba_dev_list walk and se_clear_dev_ports legacy code
This patch removes a legacy struct se_hba->hba_dev_list -> se_release_device_for_hba() list walk in core_delete_hba(), which is no longer required while using configfs VFS level parent/child struct config_group dependency referencing. The reason is because any struct se_hba->hba_dev_list-> struct se_device members are going to have to be released via: rmdir /sys/kernel/config/target/core/$HBA/* before rmdir release of struct se_hba via target_core_configfs.c: target_core_call_delhbafromtarget() -> core_delete_hba() rmdir /sys/kernel/config/target/core/$HBA to release struct se_hba in core_delete_hba(). This patch also removes the legacy se_clear_dev_ports() function, which is left-over pre-configfs shutdown logic for when se_free_virtual_device() was responsible for walking struct se_device->dev_sep_list and calling core_dev_del_lun() for each individual active struct se_port->se_lun. The reason this can be removed is because all struct se_device->dev_sep_list -> struct se_port communication is done via configfs symlinks, which means that an target fabric module's endpoints containg active struct se_port(s) will have to be released via target_core_fabric_configfs.c: target_fabric_port_unlink() via: unlink /sys/kernel/config/target/$FABRIC_MOD/$ENDPOINT/tpgt_$TPGT/lun/lun_$LUN_ID/<symlink> before rmdir release of struct se_device in target_core_configfs.c: target_core_drop_subdev() -> se_free_virtual_device() can happen via: rmdir /sys/kernel/config/target/core/$HBA/* to release struct se_subsystem_dev in target_core_drop_subdev() Reported-by: Stefan Richter <stefanr@s5r6.in-berlin.de> Reported-by: Fubo Chen <fubo.chen@gmail.com> Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Showing 2 changed files with 4 additions and 50 deletions Side-by-side Diff
drivers/target/target_core_device.c
... | ... | @@ -779,49 +779,14 @@ |
779 | 779 | return; |
780 | 780 | } |
781 | 781 | |
782 | -/* | |
783 | - * Called with struct se_hba->device_lock held. | |
784 | - */ | |
785 | -void se_clear_dev_ports(struct se_device *dev) | |
786 | -{ | |
787 | - struct se_hba *hba = dev->se_hba; | |
788 | - struct se_lun *lun; | |
789 | - struct se_portal_group *tpg; | |
790 | - struct se_port *sep, *sep_tmp; | |
791 | - | |
792 | - spin_lock(&dev->se_port_lock); | |
793 | - list_for_each_entry_safe(sep, sep_tmp, &dev->dev_sep_list, sep_list) { | |
794 | - spin_unlock(&dev->se_port_lock); | |
795 | - spin_unlock(&hba->device_lock); | |
796 | - | |
797 | - lun = sep->sep_lun; | |
798 | - tpg = sep->sep_tpg; | |
799 | - spin_lock(&lun->lun_sep_lock); | |
800 | - if (lun->lun_se_dev == NULL) { | |
801 | - spin_unlock(&lun->lun_sep_lock); | |
802 | - continue; | |
803 | - } | |
804 | - spin_unlock(&lun->lun_sep_lock); | |
805 | - | |
806 | - core_dev_del_lun(tpg, lun->unpacked_lun); | |
807 | - | |
808 | - spin_lock(&hba->device_lock); | |
809 | - spin_lock(&dev->se_port_lock); | |
810 | - } | |
811 | - spin_unlock(&dev->se_port_lock); | |
812 | - | |
813 | - return; | |
814 | -} | |
815 | - | |
816 | 782 | /* se_free_virtual_device(): |
817 | 783 | * |
818 | 784 | * Used for IBLOCK, RAMDISK, and FILEIO Transport Drivers. |
819 | 785 | */ |
820 | 786 | int se_free_virtual_device(struct se_device *dev, struct se_hba *hba) |
821 | 787 | { |
822 | - spin_lock(&hba->device_lock); | |
823 | - se_clear_dev_ports(dev); | |
824 | - spin_unlock(&hba->device_lock); | |
788 | + if (!list_empty(&dev->dev_sep_list)) | |
789 | + dump_stack(); | |
825 | 790 | |
826 | 791 | core_alua_free_lu_gp_mem(dev); |
827 | 792 | se_release_device_for_hba(dev); |
drivers/target/target_core_hba.c
... | ... | @@ -151,19 +151,8 @@ |
151 | 151 | int |
152 | 152 | core_delete_hba(struct se_hba *hba) |
153 | 153 | { |
154 | - struct se_device *dev, *dev_tmp; | |
155 | - | |
156 | - spin_lock(&hba->device_lock); | |
157 | - list_for_each_entry_safe(dev, dev_tmp, &hba->hba_dev_list, dev_list) { | |
158 | - | |
159 | - se_clear_dev_ports(dev); | |
160 | - spin_unlock(&hba->device_lock); | |
161 | - | |
162 | - se_release_device_for_hba(dev); | |
163 | - | |
164 | - spin_lock(&hba->device_lock); | |
165 | - } | |
166 | - spin_unlock(&hba->device_lock); | |
154 | + if (!list_empty(&hba->hba_dev_list)) | |
155 | + dump_stack(); | |
167 | 156 | |
168 | 157 | hba->transport->detach_hba(hba); |
169 | 158 |