From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRKMn-0001RK-4l for qemu-devel@nongnu.org; Thu, 04 Feb 2016 08:54:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRKMi-0004u3-6I for qemu-devel@nongnu.org; Thu, 04 Feb 2016 08:54:37 -0500 Received: from mx2.suse.de ([195.135.220.15]:53570) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRKMh-0004tX-Nr for qemu-devel@nongnu.org; Thu, 04 Feb 2016 08:54:32 -0500 References: <56B2754B.7030809@redhat.com> <56B28B1C.7060202@redhat.com> <56B28E8B.1030107@redhat.com> <56B326B4.1020407@redhat.com> <56B3550C.1010003@redhat.com> From: Hannes Reinecke Message-ID: <56B35816.80900@suse.de> Date: Thu, 4 Feb 2016 14:54:30 +0100 MIME-Version: 1.0 In-Reply-To: <56B3550C.1010003@redhat.com> Content-Type: multipart/mixed; boundary="------------060903000706060203080502" Subject: Re: [Qemu-devel] sda abort with virtio-scsi List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jim Minter , Paolo Bonzini , qemu-devel This is a multi-part message in MIME format. --------------060903000706060203080502 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/04/2016 02:41 PM, Jim Minter wrote: > FWIW, I've now done: >=20 > echo 300 >/sys/block/sda/device/timeout >=20 > Not entirely sure whether it would help or not, but so far I haven't > had a recurrence. >=20 Can you try with the attached patch? Should work as well, but you shouldn't need to tweak anything. Cheers, Hannes --=20 Dr. Hannes Reinecke Teamlead Storage & Networking hare@suse.de +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg GF: F. Imend=C3=B6rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG N=C3=BCrnberg) --------------060903000706060203080502 Content-Type: text/x-patch; name="0001-virtio_scsi-Implement-eh_timed_out-callback.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-virtio_scsi-Implement-eh_timed_out-callback.patch" >>From 330b4f056957eed60cb3cd1bfa1486ba7db96d8d Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Wed, 18 Nov 2015 10:33:13 +0100 Subject: [PATCH] virtio_scsi: Implement eh_timed_out callback If a command timeout occurs on the host the SCSI error handling is entered, which typically takes quite some time until to error is resolved and the command can be returned to the guest. This error handling typically overflows any timeout the guest might have been set on that command, causing the guest to abort the command. However, command aborts from the guest is tricky, and, in most cases, downright impossible. So instead this patch implements an eh_timed_out callback to virtio_scsi, which will issue a QUERY TASK TMF. If that succeeds the command is still active on the host, and the guest command timeout is reset. References: bsc#936530 Signed-off-by: Hannes Reinecke --- drivers/scsi/virtio_scsi.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 595af1a..f712db5 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -543,6 +543,33 @@ static int virtscsi_abort(struct scsi_cmnd *sc) return virtscsi_tmf(vscsi, cmd); } +static enum blk_eh_timer_return virtscsi_timed_out(struct scsi_cmnd *sc) +{ + struct virtio_scsi *vscsi = shost_priv(sc->device->host); + struct virtio_scsi_cmd *cmd; + + scmd_printk(KERN_INFO, sc, "timeout\n"); + cmd = mempool_alloc(virtscsi_cmd_pool, GFP_NOIO); + if (!cmd) + return FAILED; + + memset(cmd, 0, sizeof(*cmd)); + cmd->sc = sc; + cmd->req.tmf = (struct virtio_scsi_ctrl_tmf_req){ + .type = VIRTIO_SCSI_T_TMF, + .subtype = VIRTIO_SCSI_T_TMF_QUERY_TASK, + .lun[0] = 1, + .lun[1] = sc->device->id, + .lun[2] = (sc->device->lun >> 8) | 0x40, + .lun[3] = sc->device->lun & 0xff, + .tag = (unsigned long)sc, + }; + if (virtscsi_tmf(vscsi, cmd) == FAILED) + return BLK_EH_NOT_HANDLED; + + return BLK_EH_RESET_TIMER; +} + static struct scsi_host_template virtscsi_host_template = { .module = THIS_MODULE, .name = "Virtio SCSI HBA", @@ -551,6 +578,7 @@ static struct scsi_host_template virtscsi_host_template = { .this_id = -1, .eh_abort_handler = virtscsi_abort, .eh_device_reset_handler = virtscsi_device_reset, + .eh_timed_out = virtscsi_timed_out, .can_queue = 1024, .dma_boundary = UINT_MAX, -- 1.8.5.6 --------------060903000706060203080502--