Skip to content

Commit 00f9d62

Browse files
johnpgarrymartinkpetersen
authored andcommitted
scsi: scsi_debug: Don't iter all shosts in clear_luns_changed_on_target()
In clear_luns_changed_on_target(), we iter all devices for all shosts to conditionally clear the SDEBUG_UA_LUNS_CHANGED flag in the per-device uas_bm. One condition to see whether we clear the flag is to test whether the host for the device under consideration is the same as the matching device's (devip) host. This check will only ever pass for devices for the same shost, so only iter the devices for the matching device shost. We can now drop the spinlock'ing of the sdebug_host_list_lock in the same function. This will allow us to use a mutex instead of the spinlock for the global shost lock, as clear_luns_changed_on_target() could be called in non-blocking context, in scsi_debug_queuecommand() -> make_ua() -> clear_luns_changed_on_target() (which is why required a spinlock). Signed-off-by: John Garry <john.g.garry@oracle.com> Link: https://lore.kernel.org/r/20230327074310.1862889-3-john.g.garry@oracle.com Acked-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 6500d20 commit 00f9d62

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

drivers/scsi/scsi_debug.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,18 +1063,15 @@ static void all_config_cdb_len(void)
10631063

10641064
static void clear_luns_changed_on_target(struct sdebug_dev_info *devip)
10651065
{
1066-
struct sdebug_host_info *sdhp;
1066+
struct sdebug_host_info *sdhp = devip->sdbg_host;
10671067
struct sdebug_dev_info *dp;
10681068

1069-
spin_lock(&sdebug_host_list_lock);
1070-
list_for_each_entry(sdhp, &sdebug_host_list, host_list) {
1071-
list_for_each_entry(dp, &sdhp->dev_info_list, dev_list) {
1072-
if ((devip->sdbg_host == dp->sdbg_host) &&
1073-
(devip->target == dp->target))
1074-
clear_bit(SDEBUG_UA_LUNS_CHANGED, dp->uas_bm);
1069+
list_for_each_entry(dp, &sdhp->dev_info_list, dev_list) {
1070+
if ((devip->sdbg_host == dp->sdbg_host) &&
1071+
(devip->target == dp->target)) {
1072+
clear_bit(SDEBUG_UA_LUNS_CHANGED, dp->uas_bm);
10751073
}
10761074
}
1077-
spin_unlock(&sdebug_host_list_lock);
10781075
}
10791076

10801077
static int make_ua(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)

0 commit comments

Comments
 (0)