svn commit: r287756 - head/sys/cam/ctl
Alexander Motin
mav at FreeBSD.org
Sun Sep 13 14:52:33 UTC 2015
Author: mav
Date: Sun Sep 13 14:52:31 2015
New Revision: 287756
URL: https://svnweb.freebsd.org/changeset/base/287756
Log:
Report INQUIRY DATA HAS CHANGED for related LUNs on port on-/offline.
Modified:
head/sys/cam/ctl/ctl.c
head/sys/cam/ctl/ctl.h
head/sys/cam/ctl/ctl_error.c
head/sys/cam/ctl/ctl_frontend.c
Modified: head/sys/cam/ctl/ctl.c
==============================================================================
--- head/sys/cam/ctl/ctl.c Sun Sep 13 14:24:12 2015 (r287755)
+++ head/sys/cam/ctl/ctl.c Sun Sep 13 14:52:31 2015 (r287756)
@@ -405,14 +405,6 @@ static int ctl_scsiio_lun_check(struct c
const struct ctl_cmd_entry *entry,
struct ctl_scsiio *ctsio);
static void ctl_failover_lun(struct ctl_lun *lun);
-static void ctl_est_ua(struct ctl_lun *lun, uint32_t initidx, ctl_ua_type ua);
-static void ctl_est_ua_port(struct ctl_lun *lun, int port, uint32_t except,
- ctl_ua_type ua);
-static void ctl_est_ua_all(struct ctl_lun *lun, uint32_t except, ctl_ua_type ua);
-static void ctl_clr_ua(struct ctl_lun *lun, uint32_t initidx, ctl_ua_type ua);
-static void ctl_clr_ua_all(struct ctl_lun *lun, uint32_t except, ctl_ua_type ua);
-static void ctl_clr_ua_allluns(struct ctl_softc *ctl_softc, uint32_t initidx,
- ctl_ua_type ua_type);
static int ctl_scsiio_precheck(struct ctl_softc *ctl_softc,
struct ctl_scsiio *ctsio);
static int ctl_scsiio(struct ctl_scsiio *ctsio);
@@ -802,6 +794,7 @@ static void
ctl_isc_port_sync(struct ctl_softc *softc, union ctl_ha_msg *msg, int len)
{
struct ctl_port *port;
+ struct ctl_lun *lun;
int i, new;
port = softc->ctl_ports[msg->hdr.nexus.targ_port];
@@ -877,6 +870,15 @@ ctl_isc_port_sync(struct ctl_softc *soft
__func__);
}
}
+ mtx_lock(&softc->ctl_lock);
+ STAILQ_FOREACH(lun, &softc->lun_list, links) {
+ if (ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
+ continue;
+ mtx_lock(&lun->lun_lock);
+ ctl_est_ua_all(lun, -1, CTL_UA_INQ_CHANGE);
+ mtx_unlock(&lun->lun_lock);
+ }
+ mtx_unlock(&softc->ctl_lock);
}
/*
@@ -1199,7 +1201,7 @@ ctl_copy_sense_data_back(union ctl_io *s
dest->hdr.status = src->io_hdr.status;
}
-static void
+void
ctl_est_ua(struct ctl_lun *lun, uint32_t initidx, ctl_ua_type ua)
{
struct ctl_softc *softc = lun->ctl_softc;
@@ -1214,7 +1216,7 @@ ctl_est_ua(struct ctl_lun *lun, uint32_t
pu[initidx % CTL_MAX_INIT_PER_PORT] |= ua;
}
-static void
+void
ctl_est_ua_port(struct ctl_lun *lun, int port, uint32_t except, ctl_ua_type ua)
{
int i;
@@ -1229,7 +1231,7 @@ ctl_est_ua_port(struct ctl_lun *lun, int
}
}
-static void
+void
ctl_est_ua_all(struct ctl_lun *lun, uint32_t except, ctl_ua_type ua)
{
struct ctl_softc *softc = lun->ctl_softc;
@@ -1240,7 +1242,7 @@ ctl_est_ua_all(struct ctl_lun *lun, uint
ctl_est_ua_port(lun, i, except, ua);
}
-static void
+void
ctl_clr_ua(struct ctl_lun *lun, uint32_t initidx, ctl_ua_type ua)
{
struct ctl_softc *softc = lun->ctl_softc;
@@ -1255,7 +1257,7 @@ ctl_clr_ua(struct ctl_lun *lun, uint32_t
pu[initidx % CTL_MAX_INIT_PER_PORT] &= ~ua;
}
-static void
+void
ctl_clr_ua_all(struct ctl_lun *lun, uint32_t except, ctl_ua_type ua)
{
struct ctl_softc *softc = lun->ctl_softc;
@@ -1273,7 +1275,7 @@ ctl_clr_ua_all(struct ctl_lun *lun, uint
}
}
-static void
+void
ctl_clr_ua_allluns(struct ctl_softc *ctl_softc, uint32_t initidx,
ctl_ua_type ua_type)
{
Modified: head/sys/cam/ctl/ctl.h
==============================================================================
--- head/sys/cam/ctl/ctl.h Sun Sep 13 14:24:12 2015 (r287755)
+++ head/sys/cam/ctl/ctl.h Sun Sep 13 14:52:31 2015 (r287756)
@@ -120,6 +120,7 @@ typedef enum {
CTL_UA_LUN_CHANGE = 0x0020,
CTL_UA_MODE_CHANGE = 0x0040,
CTL_UA_LOG_CHANGE = 0x0080,
+ CTL_UA_INQ_CHANGE = 0x0100,
CTL_UA_RES_PREEMPT = 0x0400,
CTL_UA_RES_RELEASE = 0x0800,
CTL_UA_REG_PREEMPT = 0x1000,
@@ -138,6 +139,10 @@ struct ctl_page_index;
SYSCTL_DECL(_kern_cam_ctl);
#endif
+struct ctl_lun;
+struct ctl_port;
+struct ctl_softc;
+
/*
* Put a string into an sbuf, escaping characters that are illegal or not
* recommended in XML. Note this doesn't escape everything, just > < and &.
@@ -174,9 +179,17 @@ void ctl_config_write_done(union ctl_io
void ctl_portDB_changed(int portnum);
int ctl_ioctl_io(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
struct thread *td);
-struct ctl_lun;
+
+void ctl_est_ua(struct ctl_lun *lun, uint32_t initidx, ctl_ua_type ua);
+void ctl_est_ua_port(struct ctl_lun *lun, int port, uint32_t except,
+ ctl_ua_type ua);
+void ctl_est_ua_all(struct ctl_lun *lun, uint32_t except, ctl_ua_type ua);
+void ctl_clr_ua(struct ctl_lun *lun, uint32_t initidx, ctl_ua_type ua);
+void ctl_clr_ua_all(struct ctl_lun *lun, uint32_t except, ctl_ua_type ua);
+void ctl_clr_ua_allluns(struct ctl_softc *ctl_softc, uint32_t initidx,
+ ctl_ua_type ua_type);
+
void ctl_isc_announce_lun(struct ctl_lun *lun);
-struct ctl_port;
void ctl_isc_announce_port(struct ctl_port *port);
/*
Modified: head/sys/cam/ctl/ctl_error.c
==============================================================================
--- head/sys/cam/ctl/ctl_error.c Sun Sep 13 14:24:12 2015 (r287755)
+++ head/sys/cam/ctl/ctl_error.c Sun Sep 13 14:52:31 2015 (r287756)
@@ -446,6 +446,11 @@ ctl_build_ua(struct ctl_lun *lun, uint32
asc = 0x2A;
ascq = 0x02;
break;
+ case CTL_UA_INQ_CHANGE:
+ /* 3Fh/03h INQUIRY DATA HAS CHANGED */
+ asc = 0x3F;
+ ascq = 0x03;
+ break;
case CTL_UA_RES_PREEMPT:
/* 2Ah/03h RESERVATIONS PREEMPTED */
asc = 0x2A;
Modified: head/sys/cam/ctl/ctl_frontend.c
==============================================================================
--- head/sys/cam/ctl/ctl_frontend.c Sun Sep 13 14:24:12 2015 (r287755)
+++ head/sys/cam/ctl/ctl_frontend.c Sun Sep 13 14:52:31 2015 (r287756)
@@ -328,8 +328,16 @@ ctl_port_online(struct ctl_port *port)
}
if (port->port_online != NULL)
port->port_online(port->onoff_arg);
- /* XXX KDM need a lock here? */
+ mtx_lock(&softc->ctl_lock);
port->status |= CTL_PORT_STATUS_ONLINE;
+ STAILQ_FOREACH(lun, &softc->lun_list, links) {
+ if (ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
+ continue;
+ mtx_lock(&lun->lun_lock);
+ ctl_est_ua_all(lun, -1, CTL_UA_INQ_CHANGE);
+ mtx_unlock(&lun->lun_lock);
+ }
+ mtx_unlock(&softc->ctl_lock);
ctl_isc_announce_port(port);
}
@@ -355,8 +363,16 @@ ctl_port_offline(struct ctl_port *port)
port->lun_disable(port->targ_lun_arg, lun->lun);
}
}
- /* XXX KDM need a lock here? */
+ mtx_lock(&softc->ctl_lock);
port->status &= ~CTL_PORT_STATUS_ONLINE;
+ STAILQ_FOREACH(lun, &softc->lun_list, links) {
+ if (ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
+ continue;
+ mtx_lock(&lun->lun_lock);
+ ctl_est_ua_all(lun, -1, CTL_UA_INQ_CHANGE);
+ mtx_unlock(&lun->lun_lock);
+ }
+ mtx_unlock(&softc->ctl_lock);
ctl_isc_announce_port(port);
}
More information about the svn-src-all
mailing list