diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2019-08-18 02:43:53 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2019-08-18 02:43:53 +0000 |
commit | 21f6041b9f55877f1422eafceedc7c051f64adda (patch) | |
tree | 541865687945b7a65cc006d917b1ec061535184d /sys/scsi | |
parent | 2184f9b2763511968645631dbac6a8e7ab86574a (diff) |
When activating or detaching a target don't search the scsi_link SLIST
for each target:lun. Just travese the SLIST once taking care of relevant
scsi_link's as they are encountered.
ok jmatthew@
Diffstat (limited to 'sys/scsi')
-rw-r--r-- | sys/scsi/scsiconf.c | 54 |
1 files changed, 37 insertions, 17 deletions
diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c index 181f8302d41..6fbe29c6824 100644 --- a/sys/scsi/scsiconf.c +++ b/sys/scsi/scsiconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.c,v 1.201 2019/08/18 00:58:54 krw Exp $ */ +/* $OpenBSD: scsiconf.c,v 1.202 2019/08/18 02:43:52 krw Exp $ */ /* $NetBSD: scsiconf.c,v 1.57 1996/05/02 01:09:01 neil Exp $ */ /* @@ -73,6 +73,8 @@ int scsi_probedev(struct scsibus_softc *, int, int); void scsi_add_link(struct scsibus_softc *, struct scsi_link *); void scsi_remove_link(struct scsibus_softc *, struct scsi_link *); +int scsi_activate_link(struct scsibus_softc *, struct scsi_link *, int); +int scsi_detach_link(struct scsibus_softc *, struct scsi_link *, int); void scsi_devid(struct scsi_link *); int scsi_devid_pg80(struct scsi_link *); @@ -226,12 +228,15 @@ scsi_activate_bus(struct scsibus_softc *sb, int act) int scsi_activate_target(struct scsibus_softc *sb, int target, int act) { - int lun, r, rv = 0; + struct scsi_link *link; + int r, rv = 0; - for (lun = 0; lun < sb->adapter_link->luns; lun++) { - r = scsi_activate_lun(sb, target, lun, act); - if (r) - rv = r; + SLIST_FOREACH(link, &sb->sc_link_list, bus_list) { + if (link->target == target) { + r = scsi_activate_link(sb, link, act); + if (r) + rv = r; + } } return (rv); } @@ -240,13 +245,20 @@ int scsi_activate_lun(struct scsibus_softc *sb, int target, int lun, int act) { struct scsi_link *link; - struct device *dev; - int rv = 0; link = scsi_get_link(sb, target, lun); if (link == NULL) return (0); + return (scsi_activate_link(sb, link, act)); +} + +int +scsi_activate_link(struct scsibus_softc *sb, struct scsi_link *link, int act) +{ + struct device *dev; + int rv = 0; + dev = link->device_softc; switch (act) { case DVACT_DEACTIVATE: @@ -454,19 +466,19 @@ int scsi_detach_target(struct scsibus_softc *sb, int target, int flags) { struct scsi_link *alink = sb->adapter_link; - int lun, r, rv = 0; + struct scsi_link *link, *tmp; + int r, rv = 0; if (target < 0 || target >= alink->adapter_buswidth || target == alink->adapter_target) return (ENXIO); - for (lun = 0; lun < alink->luns; lun++) { /* nicer backwards? */ - if (scsi_get_link(sb, target, lun) == NULL) - continue; - - r = scsi_detach_lun(sb, target, lun, flags); - if (r != 0 && r != ENXIO) - rv = r; + SLIST_FOREACH_SAFE(link, &sb->sc_link_list, bus_list, tmp) { + if (link->target == target) { + r = scsi_detach_link(sb, link, flags); + if (r != 0 && r != ENXIO) + rv = r; + } } return (rv); @@ -477,7 +489,6 @@ scsi_detach_lun(struct scsibus_softc *sb, int target, int lun, int flags) { struct scsi_link *alink = sb->adapter_link; struct scsi_link *link; - int rv; if (target < 0 || target >= alink->adapter_buswidth || target == alink->adapter_target || @@ -488,6 +499,15 @@ scsi_detach_lun(struct scsibus_softc *sb, int target, int lun, int flags) if (link == NULL) return (ENXIO); + return (scsi_detach_link(sb, link, flags)); +} + +int +scsi_detach_link(struct scsibus_softc *sb, struct scsi_link *link, int flags) +{ + struct scsi_link *alink = sb->adapter_link; + int rv; + if (((flags & DETACH_FORCE) == 0) && (link->flags & SDEV_OPEN)) return (EBUSY); |