On 2020-05-28 00:52, Hannes Reinecke wrote: > On 5/28/20 9:24 AM, Daniel Wagner wrote: >> Is there a special reason why don't use xa_for_each to iterate through >> all >> entries? >> > This entire function is completely daft. > It says 'scsi_remove_target()', but for some weird reason fails to pass > in the target it want to delete, so it has to go round in circles trying > to figure out which target to delete. > There probably had been an obscure reason for this, but with the current > code it's just pointless. > So that's the next thing to fix (after all of this): use a struct > scsi_target as argument for this function, then this entire loop can go. Please be careful when modifying this code. I remember that it took multiple iterations to get this code right. See e.g. commit 81b6c9998979 ("scsi: core: check for device state in __scsi_remove_target()"). See also commit fbce4d97fd43 ("scsi: fixup kernel warning during rmmod()"). See also commit f9279c968c25 ("scsi: Add STARGET_CREATED_REMOVE state to scsi_target_state"). The only reason I can think of why that loop exists is that @dev may be associated with multiple targets (struct scsi_target) at the same time. Is that something that can happen? Thanks, Bart.