vhost-scsi: log I/O queue write descriptors
authorDongli Zhang <dongli.zhang@oracle.com>
Thu, 3 Apr 2025 06:29:51 +0000 (23:29 -0700)
committerMichael S. Tsirkin <mst@redhat.com>
Sun, 18 May 2025 21:25:24 +0000 (17:25 -0400)
commitc2c5c259aad628b3e0b4def7d9c02faad92eda11
tree1fad71d6d8c80dc6fe8a7717fb6e7b6bb94b124b
parente5e6b15b0dadfce456dbd04d2ab564be4d939f6f
vhost-scsi: log I/O queue write descriptors

Log write descriptors for the I/O queue, leveraging vhost_scsi_get_desc()
and vhost_get_vq_desc() to retrieve the array of write descriptors to
obtain the log buffer.

In addition, introduce a vhost-scsi specific function to log vring
descriptors. In this function, the 'partial' argument is set to false, and
the 'len' argument is set to 0, because vhost-scsi always logs all pages
shared by a vring descriptor. Add WARN_ON_ONCE() since vhost-scsi doesn't
support VIRTIO_F_ACCESS_PLATFORM.

The per-cmd log buffer is allocated on demand in the submission path after
VHOST_F_LOG_ALL is set. Return -ENOMEM on allocation failure, in order to
send SAM_STAT_TASK_SET_FULL to the guest.

It isn't reclaimed in the completion path. Instead, it is reclaimed when
VHOST_F_LOG_ALL is removed, or during VHOST_SCSI_SET_ENDPOINT when all
commands are destroyed.

Store the log buffer during the submission path and log it in the
completion path. Logging is also required in the error handling path of the
submission process.

Suggested-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Message-Id: <20250403063028.16045-7-dongli.zhang@oracle.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Mike Christie <michael.christie@oracle.com>
drivers/vhost/scsi.c