Rework CTL frontend & backend options to use nv(3), allow creating multiple
authorMarcelo Araujo <araujo@FreeBSD.org>
Thu, 10 May 2018 03:50:20 +0000 (03:50 +0000)
committerMarcelo Araujo <araujo@FreeBSD.org>
Thu, 10 May 2018 03:50:20 +0000 (03:50 +0000)
commit8951f05525ee4e9a93cc568dccd154405aae7419
tree503e8ca76afeb0231224fd5f2522663ca24ca5f6
parent3429b518c9bfbce5a16d76949d75a843567ba2de
Rework CTL frontend & backend options to use nv(3), allow creating multiple
ioctl frontend ports.

This revision introduces two changes to CTL:
- Changes the way options are passed to CTL_LUN_REQ and CTL_PORT_REQ ioctls.
  Removes ctl_be_arg structure and associated logic and replaces it with
  nv(3)-based logic for passing in and out arguments.
- Allows creating multiple ioctl frontend ports using either ctladm(8) or
  ctld(8).
  New frontend ports are represented by /dev/cam/ctl<pp>.<vp> nodes, eg /dev/cam/ctl5.3.
  Those device nodes respond only to CTL_IO ioctl.

New command-line options for ctladm:
# creates new ioctl frontend port with using free pp and vp=0
ctladm port -c
# creates new ioctl frontend port with pp=10 and vp=0
ctladm port -c -O pp=10
# creates new ioctl frontend port with pp=11 and vp=12
ctladm port -c -O pp=11 -O vp=12
# removes port with number 4 (it's a "targ_port" number, not pp number)
ctladm port -r -p 4

New syntax for ctl.conf:
target ... {
    port ioctl/<pp>
    ...
}

target ... {
    port ioctl/<pp>/<vp>
    ...

Note: Most of this work was made by jceel@, thank you.

Submitted by: jceel
Reworked by: myself
Reviewed by: mav (earlier versions and recently during the rework)
Obtained from:  FreeNAS and TrueOS
Relnotes: Yes
Sponsored by: iXsystems Inc.
Differential Revision: https://reviews.freebsd.org/D9299
22 files changed:
sys/cam/ctl/ctl.c
sys/cam/ctl/ctl.h
sys/cam/ctl/ctl_backend.c
sys/cam/ctl/ctl_backend.h
sys/cam/ctl/ctl_backend_block.c
sys/cam/ctl/ctl_backend_ramdisk.c
sys/cam/ctl/ctl_frontend.c
sys/cam/ctl/ctl_frontend.h
sys/cam/ctl/ctl_frontend_ioctl.c
sys/cam/ctl/ctl_frontend_iscsi.c
sys/cam/ctl/ctl_ioctl.h
sys/cam/ctl/ctl_tpc.c
sys/sys/param.h
usr.sbin/ctladm/Makefile
usr.sbin/ctladm/ctladm.8
usr.sbin/ctladm/ctladm.c
usr.sbin/ctld/Makefile
usr.sbin/ctld/ctld.c
usr.sbin/ctld/ctld.h
usr.sbin/ctld/kernel.c
usr.sbin/ctld/parse.y
usr.sbin/ctld/uclparse.c