• Mike Christie's avatar
    scsi: target: vhost-scsi: Convert to new submission API · eb929804
    Mike Christie authored
    target_submit_cmd_map_sgls() is being removed, so convert vhost-scsi to the
    new submission API. This has it use target_init_cmd(),
    target_submit_prep(), target_submit() because we need to have LIO core map
    sgls which is now done in target_submit_prep(), and in the next patches we
    will do the target_submit step from the LIO workqueue.
    
    Note: vhost-scsi never calls target_stop_session() so
    target_submit_cmd_map_sgls() never failed (in the new API target_init_cmd()
    handles target_stop_session() being called when cmds are being
    submitted). If it were to have used target_stop_session() and got an error,
    we would have hit a refcount bug like xen and usb, because it does:
    
    if (rc < 0) {
    	transport_send_check_condition_and_sense(se_cmd,
    			TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0);
    	transport_generic_free_cmd(se_cmd, 0);
    }
    
    transport_send_check_condition_and_sense() calls queue_status which does
    transport_generic_free_cmd(), and then we do an extra
    transport_generic_free_cmd() call above which would have dropped the
    refcount to -1 and the refcount code would spit out errors.
    
    Link: https://lore.kernel.org/r/20210227170006.5077-12-michael.christie@oracle.com
    Cc: "Michael S. Tsirkin" <mst@redhat.com>
    Cc: Stefan Hajnoczi <stefanha@redhat.com>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Signed-off-by: default avatarMike Christie <michael.christie@oracle.com>
    Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
    eb929804
scsi.c 65.7 KB