From patchwork Thu Feb 4 13:54:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 8221951 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E72309F37A for ; Thu, 4 Feb 2016 14:00:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 714CA200E3 for ; Thu, 4 Feb 2016 14:00:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C071C20357 for ; Thu, 4 Feb 2016 14:00:01 +0000 (UTC) Received: from localhost ([::1]:41978 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRKS1-0001Nf-9p for patchwork-qemu-devel@patchwork.kernel.org; Thu, 04 Feb 2016 09:00:01 -0500 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 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A28B4ADA1; Thu, 4 Feb 2016 13:54:30 +0000 (UTC) To: Jim Minter , Paolo Bonzini , qemu-devel 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 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <56B3550C.1010003@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 195.135.220.15 Subject: Re: [Qemu-devel] sda abort with virtio-scsi X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 02/04/2016 02:41 PM, Jim Minter wrote: > FWIW, I've now done: > > echo 300 >/sys/block/sda/device/timeout > > Not entirely sure whether it would help or not, but so far I haven't > had a recurrence. > Can you try with the attached patch? Should work as well, but you shouldn't need to tweak anything. Cheers, Hannes 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