On 4/3/25 1:29 AM, Dongli Zhang wrote: > 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@xxxxxxxxxx> > Signed-off-by: Dongli Zhang <dongli.zhang@xxxxxxxxxx> > --- > Changed since v1: > - Don't allocate log buffer during initialization. Allocate during > - VHOST_SET_FEATURES or VHOST_SCSI_SET_ENDPOINT. > - Re-order if staments in vhost_scsi_log_write(). > - Log after vhost_scsi_send_status() as well. > Changed since v2: > - Merge PATCH 6 and PATCH 7 from v2 as one patch. > - Don't pre-allocate log buffer in > VHOST_SET_FEATURES/VHOST_SCSI_SET_ENDPOINT. Allocate for only once in > submission path in runtime. Reclaim int > VHOST_SET_FEATURES/VHOST_SCSI_SET_ENDPOINT. > - Encapsulate the one-time on-demand per-cmd log buffer alloc/copy in a > helper, as suggested by Mike. Reviewed-by: Mike Christie <michael.christie@xxxxxxxxxx>