Il 10/06/2013 03:40, Hannes Reinecke ha scritto: > Any TMF might be take longer as expected, or not return at all. > So we need to use 'wait_for_completion_timeout' when sending > a TMF to protect against these cases. > > Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx> > Signed-off-by: Hannes Reinecke <hare@xxxxxxx> > --- > drivers/scsi/virtio_scsi.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c > index 1efd219..abfc684 100644 > --- a/drivers/scsi/virtio_scsi.c > +++ b/drivers/scsi/virtio_scsi.c > @@ -30,6 +30,7 @@ > #define VIRTIO_SCSI_MEMPOOL_SZ 64 > #define VIRTIO_SCSI_EVENT_LEN 8 > #define VIRTIO_SCSI_VQ_BASE 2 > +#define VIRTIO_SCSI_TMF_TIMEOUT 30 > > /* Command queue element */ > struct virtio_scsi_cmd { > @@ -597,8 +598,10 @@ static int virtscsi_tmf(struct virtio_scsi *vscsi, struct virtio_scsi_cmd *cmd) > GFP_NOIO) < 0) > goto out; > > - wait_for_completion(&comp); > - if (cmd->resp.tmf.response == VIRTIO_SCSI_S_OK || > + if (wait_for_completion_timeout(&comp, > + VIRTIO_SCSI_TMF_TIMEOUT * HZ) == 0) > + ret = FAILED; > + else if (cmd->resp.tmf.response == VIRTIO_SCSI_S_OK || > cmd->resp.tmf.response == VIRTIO_SCSI_S_FUNCTION_SUCCEEDED) > ret = SUCCESS; > > Acked-by: Paolo Bonzini <pbonzini@xxxxxxxxxx> -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html