vscsi(4) and iscsid - iSCSI initiator the OpenBSD way - Claudio Jeker
Channel: EuroBSDcon
Date: 2019-10-14

Abstract:

In the beginning large storage networks had to be built with Fibre Channel. Since Fibre Channel is expensive an alternative way to attach block-level devices to servers was searched. A protocol using Ethernet or TCP/IP would be a good cost-effective alternative since there is already an extensive Ethernet infrastructure available in data centers. iSCSI is a protocol that transport SCSI commands and data over TCP. It combines two very popular protocols — SCSI for block level I/O and TCP/IP for remote communication. While many iSCSI implementations are inside the kernel the one implemented in OpenBSD is written in userland similar to the NetBSD initiator. But unlike NetBSD’s, OpenBSD’s version does not use a userland filesystem to hook the iSCSI disks into the kernel. Instead access is performed via vscsi(4) — a virtual scsibus — which allows userland to talk directly to the kernel SCSI midlayer. Vscsi is implemented in roughly 600 lines of code exporting the scsibus to userland via 6 ioctl(2) plus the possibility to use poll(2) or kqueue(2) to allow simple I/O multiplexing. The vscsi device uses these ioctls to issue commands and send or receive data from the kernel. The use of this interface it is fairly simple and makes it possible to write an iSCSI initiator in userland. The userland process can offload all the complex SCSI protocol handling to vscsi and the kernel and “only” needs to implement the session establishment and error recovery. The presentation will give a quick introduction to the iSCSI protocol, the vscsi(4) interface is explained including sample code and the design and implementation of iscsid is illustrated. It will also cover the chicken and egg issues having to rely on a userland process for accessing disks and their file systems and how OpenBSD solved the startup and shutdown handling.

Speaker biography:

Claudio Jeker is a long time OpenBSD developer doing mostly crazy networking stuff. After writing various privilege separated daemons I was “forced” by David Gwynne to write iscsid. The initial proof of concept was all hacked up during f2k9 — the filesystem hackathon — in Stockholm.