diff options
author | mav <mav@FreeBSD.org> | 2014-07-15 17:10:48 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2014-07-15 17:10:48 +0000 |
commit | 100d0f0aa6e25177e25a030a8ecb3c3154c95549 (patch) | |
tree | 10f6840e8c090ae213d342d6c52ed801afd83354 /sys/cam/ctl | |
parent | 247c4d205304f59552dd4f5ed2727409e52c64df (diff) | |
download | FreeBSD-src-100d0f0aa6e25177e25a030a8ecb3c3154c95549.zip FreeBSD-src-100d0f0aa6e25177e25a030a8ecb3c3154c95549.tar.gz |
MFC r268328:
Close race in r268291 between port destruction, delayed by sessions
teardown, and new port creation during `service ctld restart`.
Close it by returning iSCSI port internal state, that allows to identify
dying ports, which should not be counted as existing, from really alive.
Diffstat (limited to 'sys/cam/ctl')
-rw-r--r-- | sys/cam/ctl/ctl.c | 5 | ||||
-rw-r--r-- | sys/cam/ctl/ctl_frontend.h | 2 | ||||
-rw-r--r-- | sys/cam/ctl/ctl_frontend_iscsi.c | 13 |
3 files changed, 20 insertions, 0 deletions
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index a8de281..5289aa8f 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -3254,6 +3254,11 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, if (retval != 0) break; + if (port->port_info != NULL) { + retval = port->port_info(port->onoff_arg, sb); + if (retval != 0) + break; + } STAILQ_FOREACH(opt, &port->options, links) { retval = sbuf_printf(sb, "\t<%s>%s</%s>\n", opt->name, opt->value, opt->name); diff --git a/sys/cam/ctl/ctl_frontend.h b/sys/cam/ctl/ctl_frontend.h index cb08962..2582ecc 100644 --- a/sys/cam/ctl/ctl_frontend.h +++ b/sys/cam/ctl/ctl_frontend.h @@ -49,6 +49,7 @@ typedef enum { typedef int (*fe_init_t)(void); typedef void (*fe_shutdown_t)(void); typedef void (*port_func_t)(void *onoff_arg); +typedef int (*port_info_func_t)(void *onoff_arg, struct sbuf *sb); typedef int (*lun_func_t)(void *arg, struct ctl_id targ_id, int lun_id); typedef uint32_t (*lun_map_func_t)(void *arg, uint32_t lun_id); typedef int (*fe_ioctl_t)(struct cdev *dev, u_long cmd, caddr_t addr, int flag, @@ -214,6 +215,7 @@ struct ctl_port { int virtual_port; /* passed to CTL */ port_func_t port_online; /* passed to CTL */ port_func_t port_offline; /* passed to CTL */ + port_info_func_t port_info; /* passed to CTL */ void *onoff_arg; /* passed to CTL */ lun_func_t lun_enable; /* passed to CTL */ lun_func_t lun_disable; /* passed to CTL */ diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c index 8f70611..557b0a9 100644 --- a/sys/cam/ctl/ctl_frontend_iscsi.c +++ b/sys/cam/ctl/ctl_frontend_iscsi.c @@ -149,6 +149,7 @@ SYSCTL_INT(_kern_cam_ctl_iscsi, OID_AUTO, maxcmdsn_delta, CTLFLAG_RWTUN, int cfiscsi_init(void); static void cfiscsi_online(void *arg); static void cfiscsi_offline(void *arg); +static int cfiscsi_info(void *arg, struct sbuf *sb); static int cfiscsi_lun_enable(void *arg, struct ctl_id target_id, int lun_id); static int cfiscsi_lun_disable(void *arg, @@ -1415,6 +1416,17 @@ cfiscsi_offline(void *arg) #endif } +static int +cfiscsi_info(void *arg, struct sbuf *sb) +{ + struct cfiscsi_target *ct = (struct cfiscsi_target *)arg; + int retval; + + retval = sbuf_printf(sb, "\t<cfiscsi_state>%d</cfiscsi_state>\n", + ct->ct_state); + return (retval); +} + static void cfiscsi_ioctl_handoff(struct ctl_iscsi *ci) { @@ -1997,6 +2009,7 @@ cfiscsi_ioctl_port_create(struct ctl_req *req) port->virtual_port = strtoul(tag, NULL, 0); port->port_online = cfiscsi_online; port->port_offline = cfiscsi_offline; + port->port_info = cfiscsi_info; port->onoff_arg = ct; port->lun_enable = cfiscsi_lun_enable; port->lun_disable = cfiscsi_lun_disable; |