Index: share/man/man4/Makefile =================================================================== --- share/man/man4/Makefile +++ share/man/man4/Makefile @@ -884,6 +884,7 @@ .endif .if ${MK_ISCSI} != "no" +MAN+= cfiscsi.4 MAN+= iscsi.4 MAN+= iscsi_initiator.4 MAN+= iser.4 Index: share/man/man4/cfiscsi.4 =================================================================== --- share/man/man4/cfiscsi.4 +++ share/man/man4/cfiscsi.4 @@ -1,5 +1,6 @@ .\" Copyright (c) 2013 Edward Tomasz Napierala .\" Copyright (c) 2015-2017 Alexander Motin +.\" Copyright (c) 2017 Ngie Cooper .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -23,111 +24,36 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: head/share/man/man4/ctl.4 315561 2017-03-19 15:53:17Z trasz $ -.Dd March 19, 2017 -.Dt CTL 4 +.\" $FreeBSD: head/share/man/man4/cfiscsi.4 315561 2017-03-19 15:53:17Z trasz $ +.Dd March 22, 2017 +.Dt CFISCSI 4 .Os .Sh NAME -.Nm ctl -.Nd CAM Target Layer / iSCSI target subsystem +.Nm cfiscsi +.Nd CAM Target Layer iSCSI target frontend .Sh SYNOPSIS To compile this driver into the kernel, -place the following line in your +place the following lines in your kernel configuration file: .Bd -ragged -offset indent -.Cd "device iscsi" +.Cd "device cfiscsi" .Cd "device ctl" +.Cd "device iscsi" .Ed .Pp Alternatively, to load the driver as a module at boot time, place the following line in .Xr loader.conf 5 : .Bd -literal -offset indent -ctl_load="YES" +cfiscsi_load="YES" .Ed .Sh DESCRIPTION The .Nm -subsystem provides SCSI target devices emulation. -It supports features such as: -.Pp -.Bl -bullet -compact -.It -Disk, CD-ROM and processor device emulation -.It -Tagged queueing -.It -SCSI task attribute support (ordered, head of queue, simple tags) -.It -SCSI implicit command ordering support -.It -Full task management support (abort, query, reset, etc.) -.It -Support for multiple ports, initiators, targets and backing stores -.It -Support for VMWare VAAI and Microsoft ODX offload (COMPARE AND WRITE, -XCOPY, POPULATE TOKEN/WRITE USING TOKEN, WRITE SAME and UNMAP) -.It -Persistent reservation support -.It -Extensive VPD/mode/log pages support -.It -Featured error reporting, error injection and basic SMART support -.It -High Availability clustering support with ALUA -.It -All I/O handled in-kernel, no userland context switch overhead -.El -.Pp -The -.Nm -subsystem includes multiple frontends to provide access using different -transport protocols and implementations: -.Bl -tag -width cfumass -.It camsim -Provides access for local system via virtual initiator mode -.Xr CAM 4 -SIM. -.It camtgt -Provides access for remote systems via target mode -.Xr CAM 4 -SIMs, such as Fibre Channel -.Xr isp 4 +subsystem provides iSCSI target device emulation via +.Xr ctl 4 and -.Xr mpt 4 . -.It cfumass -Provides access for remote systems via USB Mass Storage Class -Bulk Only (BBB) Transport. -.It ha -Internal frontend used to receive requests from other node ports in -High Availability cluster. -.It ioctl -Provides access for local user-level applications via -.Xr ioctl 2 -based API. -.It iscsi -Combined with -.Xr iscsi 4 -and -.Xr ctld 8 , -provides access for remote systems via iSCSI protocol. -.It tpc -Internal frontend used to receive requests from Third Party Copy engine, -implementing copy offload operations. -.El -.Pp -The -.Nm -subsystem includes two backends to create logical units using different -kinds of backing stores: -.Bl -tag -width ramdisk -.It block -Stores data in ZFS ZVOLs, files or raw block devices. -.It ramdisk -Stores data in RAM, that makes it mostly useful for performance testing. -Depending on configured capacity can work as black hole, thin or thick -provisioned disk. -.El +.Xr iscsi 4 . .Sh SYSCTL VARIABLES The following variables are available as both .Xr sysctl 8 @@ -135,65 +61,6 @@ .Xr loader 8 tunables: .Bl -tag -width indent -.It Va kern.cam.ctl.debug -Bit mask of enabled CTL log levels: -.Bl -tag -offset indent -compact -.It 1 -log commands with errors; -.It 2 -log all commands; -.It 4 -log data for commands other then READ/WRITE. -.El -Defaults to 0. -.It Va kern.cam.ctl.ha_id -Specifies unique position of this node within High Availability cluster. -Default is 0 -- no HA, 1 and 2 -- HA enabled at specified position. -.It Va kern.cam.ctl.ha_mode -Specifies High Availability cluster operation mode: -.Bl -tag -offset indent -compact -.It 0 -Active/Standby -- primary node has backend access and processes requests, -while secondary can only do basic LUN discovery and reservation; -.It 1 -Active/Active -- both nodes have backend access and process requests, -while secondary node synchronizes processing with primary one; -.It 2 -Active/Active -- primary node has backend access and processes requests, -while secondary node forwards all requests and data to primary one; -.El -All above modes require established connection between HA cluster nodes. -If connection is not configured, secondary node will report Unavailable -state; if configured but not established -- Transitioning state. -Defaults to 0. -.It Va kern.cam.ctl.ha_peer -String value, specifying method to establish connection to peer HA node. -Can be "listen IP:port", "connect IP:port" or empty. -.It Va kern.cam.ctl.ha_link -Reports present state of connection between HA cluster nodes: -.Bl -tag -offset indent -compact -.It 0 -not configured; -.It 1 -configured but not established; -.It 2 -established. -.El -.It Va kern.cam.ctl.ha_role -Specifies default role of this node: -.Bl -tag -offset indent -compact -.It 0 -primary; -.It 1 -secondary. -.El -This role can be overridden on per-LUN basis using "ha_role" LUN option, -so that for one LUN one node is primary, while for another -- another. -Role change from primary to secondary for HA modes 0 and 2 closes backends, -the opposite change -- opens. -If there is no primary node (both nodes are secondary, or secondary node has -no connection to primary one), secondary node(s) report Transitioning state. -State with two primary nodes is illegal (split brain condition). .It Va kern.cam.ctl.iscsi.debug Verbosity level for log messages from the kernel part of iSCSI target. Set to 0 to disable logging or 1 to warn about potential problems. @@ -212,19 +79,26 @@ Defaults to 5. .El .Sh SEE ALSO -.Xr cfumass 4 , -.Xr ctladm 8 , -.Xr ctld 8 , -.Xr ctlstat 8 +.Xr ctl 4 , +.Xr iscsi 4 .Sh HISTORY The .Nm subsystem first appeared in -.Fx 9.1 . +.Fx 10.0 +as part of the +.Xr ctl 4 +driver. +It was split off of +.Xr ctl 4 +in +.Fx 12.0 . .Sh AUTHORS +.An -nosplit The .Nm -subsystem was originally written by -.An Kenneth Merry Aq Mt ken@FreeBSD.org . -Later work was done by -.An Alexander Motin Aq Mt mav@FreeBSD.org . +subsystem was developed by +.An Edward Tomasz Napierala Aq Mt trasz@FreeBSD.org +under sponsorship from the FreeBSD Foundation. +This manpage was written by +.An Ngie Cooper Aq Mt ngie@FreeBSD.org . Index: share/man/man4/ctl.4 =================================================================== --- share/man/man4/ctl.4 +++ share/man/man4/ctl.4 @@ -24,18 +24,17 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd March 19, 2017 +.Dd March 22, 2017 .Dt CTL 4 .Os .Sh NAME .Nm ctl -.Nd CAM Target Layer / iSCSI target subsystem +.Nd CAM Target Layer .Sh SYNOPSIS To compile this driver into the kernel, place the following line in your kernel configuration file: .Bd -ragged -offset indent -.Cd "device iscsi" .Cd "device ctl" .Ed .Pp @@ -106,11 +105,8 @@ .Xr ioctl 2 based API. .It iscsi -Combined with -.Xr iscsi 4 -and -.Xr ctld 8 , -provides access for remote systems via iSCSI protocol. +Provides access for remote systems via the iSCSI protocol using +.Xr cfiscsi 4 . .It tpc Internal frontend used to receive requests from Third Party Copy engine, implementing copy offload operations. @@ -194,24 +190,9 @@ If there is no primary node (both nodes are secondary, or secondary node has no connection to primary one), secondary node(s) report Transitioning state. State with two primary nodes is illegal (split brain condition). -.It Va kern.cam.ctl.iscsi.debug -Verbosity level for log messages from the kernel part of iSCSI target. -Set to 0 to disable logging or 1 to warn about potential problems. -Larger values enable debugging output. -Defaults to 1. -.It Va kern.cam.ctl.iscsi.maxtags -The number of outstanding commands to advertise to each iSCSI initiator. -Current implementation is not very accurate, so do not set this below 2. -Defaults to 256. -.It Va kern.cam.ctl.iscsi.ping_timeout -The number of seconds to wait for the iSCSI initiator to respond to a NOP-In -PDU. -In the event that there is no response within that time the session gets -forcibly terminated. -Set to 0 to disable sending NOP-In PDUs. -Defaults to 5. .El .Sh SEE ALSO +.Xr cfiscsi 4 , .Xr cfumass 4 , .Xr ctladm 8 , .Xr ctld 8 , Index: sys/conf/files =================================================================== --- sys/conf/files +++ sys/conf/files @@ -102,7 +102,7 @@ cam/ctl/ctl_frontend.c optional ctl cam/ctl/ctl_frontend_cam_sim.c optional ctl cam/ctl/ctl_frontend_ioctl.c optional ctl -cam/ctl/ctl_frontend_iscsi.c optional ctl +cam/ctl/ctl_frontend_iscsi.c optional ctl cfiscsi cam/ctl/ctl_ha.c optional ctl cam/ctl/ctl_scsi_all.c optional ctl cam/ctl/ctl_tpc.c optional ctl @@ -1780,10 +1780,10 @@ compile-with "${NORMAL_FW}" \ no-obj no-implicit-rule \ clean "ipw_monitor.fw" -dev/iscsi/icl.c optional iscsi | ctl -dev/iscsi/icl_conn_if.m optional iscsi | ctl -dev/iscsi/icl_soft.c optional iscsi | ctl -dev/iscsi/icl_soft_proxy.c optional iscsi | ctl +dev/iscsi/icl.c optional iscsi +dev/iscsi/icl_conn_if.m optional cfiscsi | iscsi +dev/iscsi/icl_soft.c optional iscsi +dev/iscsi/icl_soft_proxy.c optional iscsi dev/iscsi/iscsi.c optional iscsi scbus dev/iscsi_initiator/iscsi.c optional iscsi_initiator scbus dev/iscsi_initiator/iscsi_subr.c optional iscsi_initiator scbus Index: sys/modules/Makefile =================================================================== --- sys/modules/Makefile +++ sys/modules/Makefile @@ -471,6 +471,7 @@ .endif .if ${MK_ISCSI} != "no" || defined(ALL_MODULES) +SUBDIR+= cfiscsi SUBDIR+= iscsi SUBDIR+= iscsi_initiator .endif Index: sys/modules/cfiscsi/Makefile =================================================================== --- sys/modules/cfiscsi/Makefile +++ sys/modules/cfiscsi/Makefile @@ -2,32 +2,11 @@ .PATH: ${SRCTOP}/sys/cam/ctl -KMOD= ctl - -SRCS= ctl.c -SRCS+= ctl_backend.c -SRCS+= ctl_backend_block.c -SRCS+= ctl_backend_ramdisk.c -SRCS+= ctl_cmd_table.c -SRCS+= ctl_frontend.c -SRCS+= ctl_frontend_cam_sim.c -SRCS+= ctl_frontend_ioctl.c -SRCS+= ctl_frontend_iscsi.c -SRCS+= ctl_ha.c -SRCS+= ctl_scsi_all.c -SRCS+= ctl_tpc.c -SRCS+= ctl_tpc_local.c -SRCS+= ctl_error.c -SRCS+= ctl_util.c -SRCS+= scsi_ctl.c -SRCS+= bus_if.h -SRCS+= device_if.h -SRCS+= vnode_if.h -SRCS+= icl_conn_if.h -SRCS+= opt_cam.h +KMOD= cfiscsi #CFLAGS+=-DICL_KERNEL_PROXY -MFILES= kern/bus_if.m kern/device_if.m dev/iscsi/icl_conn_if.m +MFILES= dev/iscsi/icl_conn_if.m +SRCS= ctl_frontend_iscsi.c icl_conn_if.h .include Index: sys/modules/ctl/Makefile =================================================================== --- sys/modules/ctl/Makefile +++ sys/modules/ctl/Makefile @@ -12,7 +12,6 @@ SRCS+= ctl_frontend.c SRCS+= ctl_frontend_cam_sim.c SRCS+= ctl_frontend_ioctl.c -SRCS+= ctl_frontend_iscsi.c SRCS+= ctl_ha.c SRCS+= ctl_scsi_all.c SRCS+= ctl_tpc.c @@ -23,11 +22,10 @@ SRCS+= bus_if.h SRCS+= device_if.h SRCS+= vnode_if.h -SRCS+= icl_conn_if.h SRCS+= opt_cam.h #CFLAGS+=-DICL_KERNEL_PROXY -MFILES= kern/bus_if.m kern/device_if.m dev/iscsi/icl_conn_if.m +MFILES= kern/bus_if.m kern/device_if.m .include Index: usr.sbin/ctladm/Makefile =================================================================== --- usr.sbin/ctladm/Makefile +++ usr.sbin/ctladm/Makefile @@ -1,5 +1,7 @@ # $FreeBSD$ +.include + PROG= ctladm SRCS= ctladm.c util.c ctl_util.c ctl_scsi_all.c .PATH: ${SRCTOP}/sys/cam/ctl @@ -17,4 +19,8 @@ LIBADD= cam sbuf bsdxml util MAN= ctladm.8 +.if ${MK_ISCSI} != "no" +CFLAGS+= -DWANT_ISCSI +.endif + .include Index: usr.sbin/ctladm/ctladm.c =================================================================== --- usr.sbin/ctladm/ctladm.c +++ usr.sbin/ctladm/ctladm.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -4152,6 +4153,13 @@ retval = 1; goto bailout; } +#ifdef WANT_ISCSI + else { + if (modfind("ctlcfiscsi") == -1 && + kldload("cfiscsi") == -1) + warn("couldn't load cfiscsi"); + } +#endif } else if ((command != CTLADM_CMD_HELP) && ((cmdargs & CTLADM_ARG_DEVICE) == 0)) { fprintf(stderr, "%s: you must specify a device with the " Index: usr.sbin/ctld/Makefile =================================================================== --- usr.sbin/ctld/Makefile +++ usr.sbin/ctld/Makefile @@ -1,5 +1,7 @@ # $FreeBSD$ +.include + CFLAGS+=-I${SRCTOP}/contrib/libucl/include .PATH: ${SRCTOP}/contrib/libucl/include @@ -21,4 +23,8 @@ WARNS?= 6 NO_WMISSING_VARIABLE_DECLARATIONS= +.if ${MK_ISCSI} != "no" +CFLAGS+= -DWANT_ISCSI +.endif + .include Index: usr.sbin/ctld/kernel.c =================================================================== --- usr.sbin/ctld/kernel.c +++ usr.sbin/ctld/kernel.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -90,6 +91,14 @@ } if (ctl_fd < 0) log_err(1, "failed to open %s", CTL_DEFAULT_DEV); +#ifdef WANT_ISCSI + else { + saved_errno = errno; + if (modfind("ctlcfiscsi") == -1 && kldload("cfiscsi") == -1) + log_warn("couldn't load cfiscsi"); + errno = saved_errno; + } +#endif } /*