The geom_gate API provides 2 distinct paths for exchanging error details between the kernel and the userland client: Including an error code in the g_gate_ctl_io structure passed in the ioctl(2) call or having the ioctl(2) call return -1. The latter reflects errors in the ioctl(2) call itself whilst the former reflects errors within the geom_gate instance.
The G_GATE_CMD_START ioctl blocks waiting for an I/O request to be directed to the geom_gate instance and the wait can fail (necessitating an error return) if the geom_gate instance is destroyed or if the msleep(9) fails. The code previously treated both error cases indentically: Returning ECANCELED as a geom_gate instance error (which the ggatec treats as a fatal error). Whilst this is the correct behaviour if the geom_gate instance is destroyed, a msleep(9) failure is unrelated to the geom_gate instance itself and should be reported as an ioctl(2) "failure". The distinction is important because msleep(9) can return ERESTART, which means the system call should be retried (and this will occur automatically as part of the generic syscall return processing).
The attached patch changes the msleep(9) handling to directly return the error code from msleep(9), which ensures ERESTART is correctly handled, rather than being treated as a fatal error.