CTL: Allow userland supply tags via ioctl frontend.

Before this ioctl frontend always replaced tags with sequential ones.
It was done for ctladm, that can not keep track of global tag list.
But in case of virtio-scsi in bhyve we can pass provided tags as-is.
It should be on virtio-scsi initiator to provide us valid tags.  It
should allow proper task management, error reporting, etc.  In case
of several virtio-scsi devices, they should use different CTL ports
or initiator IDs to avoid conflicts, but this is expected by design.

PR:	267539
This commit is contained in:
Alexander Motin 2022-12-03 12:05:05 -05:00
parent fcdcfa2189
commit 7467a69536
3 changed files with 6 additions and 3 deletions

View File

@ -632,8 +632,9 @@ ctl_ioctl_io(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
*/
io->io_hdr.nexus.targ_port = cfi->port.targ_port;
io->io_hdr.flags |= CTL_FLAG_USER_REQ;
if ((io->io_hdr.io_type == CTL_IO_SCSI) &&
(io->scsiio.tag_type != CTL_TAG_UNTAGGED))
if ((io->io_hdr.flags & CTL_FLAG_USER_TAG) == 0 &&
io->io_hdr.io_type == CTL_IO_SCSI &&
io->scsiio.tag_type != CTL_TAG_UNTAGGED)
io->scsiio.tag_num = atomic_fetchadd_int(&cfi->cur_tag_num, 1);
retval = cfi_submit_wait(io);

View File

@ -88,7 +88,7 @@ typedef enum {
CTL_FLAG_DATA_OUT = 0x00000002, /* DATA OUT */
CTL_FLAG_DATA_NONE = 0x00000003, /* no data */
CTL_FLAG_DATA_MASK = 0x00000003,
CTL_FLAG_DO_AUTOSENSE = 0x00000020, /* grab sense info */
CTL_FLAG_USER_TAG = 0x00000020, /* userland provides tag */
CTL_FLAG_USER_REQ = 0x00000040, /* request came from userland */
CTL_FLAG_ALLOCATED = 0x00000100, /* data space allocated */
CTL_FLAG_ABORT_STATUS = 0x00000400, /* return TASK ABORTED status */

View File

@ -406,6 +406,7 @@ pci_vtscsi_tmf_handle(struct pci_vtscsi_softc *sc,
io->io_hdr.nexus.targ_lun = pci_vtscsi_get_lun(tmf->lun);
io->taskio.tag_type = CTL_TAG_SIMPLE;
io->taskio.tag_num = tmf->id;
io->io_hdr.flags |= CTL_FLAG_USER_TAG;
switch (tmf->subtype) {
case VIRTIO_SCSI_T_TMF_ABORT_TASK:
@ -520,6 +521,7 @@ pci_vtscsi_request_handle(struct pci_vtscsi_queue *q, struct iovec *iov_in,
io->scsiio.sense_len = sc->vss_config.sense_size;
io->scsiio.tag_num = cmd_rd->id;
io->io_hdr.flags |= CTL_FLAG_USER_TAG;
switch (cmd_rd->task_attr) {
case VIRTIO_SCSI_S_ORDERED:
io->scsiio.tag_type = CTL_TAG_ORDERED;