summaryrefslogtreecommitdiffstats
path: root/sys/cam
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2015-10-05 09:09:48 +0000
committermav <mav@FreeBSD.org>2015-10-05 09:09:48 +0000
commite563859fd225709afe1ce093768f0858d6782dad (patch)
tree3973588e0f198a002cfa35cf817e830e5feb5a04 /sys/cam
parentd17612b5d04d7a92dac3120a609a6e0629a1b5a9 (diff)
downloadFreeBSD-src-e563859fd225709afe1ce093768f0858d6782dad.zip
FreeBSD-src-e563859fd225709afe1ce093768f0858d6782dad.tar.gz
MFC r287754: Report CTL_UA_LUN_CHANGE on LUN map change.
Diffstat (limited to 'sys/cam')
-rw-r--r--sys/cam/ctl/ctl.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c
index 6a5c2f3..cb8007e 100644
--- a/sys/cam/ctl/ctl.c
+++ b/sys/cam/ctl/ctl.c
@@ -408,6 +408,8 @@ static int ctl_scsiio_lun_check(struct ctl_lun *lun,
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);
@@ -1215,24 +1217,32 @@ ctl_est_ua(struct ctl_lun *lun, uint32_t initidx, ctl_ua_type ua)
}
static void
-ctl_est_ua_all(struct ctl_lun *lun, uint32_t except, ctl_ua_type ua)
+ctl_est_ua_port(struct ctl_lun *lun, int port, uint32_t except, ctl_ua_type ua)
{
- struct ctl_softc *softc = lun->ctl_softc;
- int i, j;
+ int i;
mtx_assert(&lun->lun_lock, MA_OWNED);
- for (i = softc->port_min; i < softc->port_max; i++) {
- if (lun->pending_ua[i] == NULL)
+ if (lun->pending_ua[port] == NULL)
+ return;
+ for (i = 0; i < CTL_MAX_INIT_PER_PORT; i++) {
+ if (port * CTL_MAX_INIT_PER_PORT + i == except)
continue;
- for (j = 0; j < CTL_MAX_INIT_PER_PORT; j++) {
- if (i * CTL_MAX_INIT_PER_PORT + j == except)
- continue;
- lun->pending_ua[i][j] |= ua;
- }
+ lun->pending_ua[port][i] |= ua;
}
}
static void
+ctl_est_ua_all(struct ctl_lun *lun, uint32_t except, ctl_ua_type ua)
+{
+ struct ctl_softc *softc = lun->ctl_softc;
+ int i;
+
+ mtx_assert(&lun->lun_lock, MA_OWNED);
+ for (i = softc->port_min; i < softc->port_max; i++)
+ ctl_est_ua_port(lun, i, except, ua);
+}
+
+static void
ctl_clr_ua(struct ctl_lun *lun, uint32_t initidx, ctl_ua_type ua)
{
struct ctl_softc *softc = lun->ctl_softc;
@@ -2117,6 +2127,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
struct thread *td)
{
struct ctl_softc *softc;
+ struct ctl_lun *lun;
int retval;
softc = control_softc;
@@ -2275,7 +2286,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
break;
}
case CTL_DUMP_OOA: {
- struct ctl_lun *lun;
union ctl_io *io;
char printbuf[128];
struct sbuf sb;
@@ -2312,7 +2322,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
break;
}
case CTL_GET_OOA: {
- struct ctl_lun *lun;
struct ctl_ooa *ooa_hdr;
struct ctl_ooa_entry *entries;
uint32_t cur_fill_num;
@@ -2404,7 +2413,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
}
case CTL_CHECK_OOA: {
union ctl_io *io;
- struct ctl_lun *lun;
struct ctl_ooa_info *ooa_info;
@@ -2437,9 +2445,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
}
case CTL_DELAY_IO: {
struct ctl_io_delay_info *delay_info;
-#ifdef CTL_IO_DELAY
- struct ctl_lun *lun;
-#endif /* CTL_IO_DELAY */
delay_info = (struct ctl_io_delay_info *)addr;
@@ -2530,7 +2535,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
case CTL_SETSYNC:
case CTL_GETSYNC: {
struct ctl_sync_info *sync_info;
- struct ctl_lun *lun;
sync_info = (struct ctl_sync_info *)addr;
@@ -2560,7 +2564,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
}
case CTL_GETSTATS: {
struct ctl_stats *stats;
- struct ctl_lun *lun;
int i;
stats = (struct ctl_stats *)addr;
@@ -2596,7 +2599,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
}
case CTL_ERROR_INJECT: {
struct ctl_error_desc *err_desc, *new_err_desc;
- struct ctl_lun *lun;
err_desc = (struct ctl_error_desc *)addr;
@@ -2643,7 +2645,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
}
case CTL_ERROR_INJECT_DELETE: {
struct ctl_error_desc *delete_desc, *desc, *desc2;
- struct ctl_lun *lun;
int delete_done;
delete_desc = (struct ctl_error_desc *)addr;
@@ -2687,8 +2688,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
mtx_lock(&softc->ctl_lock);
printf("CTL Persistent Reservation information start:\n");
for (i = 0; i < CTL_MAX_LUNS; i++) {
- struct ctl_lun *lun;
-
lun = softc->ctl_luns[i];
if ((lun == NULL)
@@ -2782,7 +2781,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
}
case CTL_LUN_LIST: {
struct sbuf *sb;
- struct ctl_lun *lun;
struct ctl_lun_list *list;
struct ctl_option *opt;
@@ -3155,6 +3153,13 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
mtx_unlock(&softc->ctl_lock);
return (ENXIO);
}
+ 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_port(lun, lm->port, -1, CTL_UA_LUN_CHANGE);
+ mtx_unlock(&lun->lun_lock);
+ }
mtx_unlock(&softc->ctl_lock); // XXX: port_enable sleeps
if (lm->plun < CTL_MAX_LUNS) {
if (lm->lun == UINT32_MAX)
OpenPOWER on IntegriCloud