Received: by 10.223.164.202 with SMTP id h10csp5834568wrb; Tue, 21 Nov 2017 16:50:37 -0800 (PST) X-Google-Smtp-Source: AGs4zMZFa9060KUAPtjRjIQhsyMqYuqXJ0DYQcMric2pzUkEvUgMJiCuq+FkVYPN6jtzsn9Cy6sL X-Received: by 10.99.110.203 with SMTP id j194mr9410577pgc.92.1511311837367; Tue, 21 Nov 2017 16:50:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511311837; cv=none; d=google.com; s=arc-20160816; b=d//bY85HDH1MUXMVqG3g6boGhDlX2eZzaF76dUdiEXEN7f/opHvZzKA6e2k5b0wcPt 3y+DJoeKVFLXmDH1YdaL09E29N42Edfv+Tdxv3a2RJxn6NFX1b1FwKN5F9peeesz8K3j s+xSLGtL8rVOUNlfBQnmyY0Ya3kZsvIHtqGu5mDYMcTpsSCc0/k2jbtvuugrCRF8BZL4 BXCBzkivp5tVTqo5uJU3pjNWmpueimaw4BWW8IlrT1RxIkP/F1S6+ebkRPL78NX7uUaA KlHmxWLhX2kez+aM+F5ARgHhaEgYiUTImg8nK5et1apbRd7IXCs/RgM4agS4xZGtIF48 2ToA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=KF5cx3Ei48j9q0Ki+45KDgJvLyB4HAUOa0MBTBD7/zQ=; b=RxrxVfgnY1g/2FNnCtVbQoJ2lMDcIqq84lUQj52YAa2d8KE4r1uLDrYG5v/HQNaJgT 4L5zDY/cC0vXJ0Kh1d1LOfIqFruFUYBizCWcKbsDxBNGm2vbwB+5y2H1LhFKusb3Srv1 5nHdGZF9dCF48owHp1akrXxGfxSg+KXShLH2nsdlPugzKJgCgOPwgvTZZM0eMJ2cQ5bn N+t9tgj8wc1Z3DmBABChcUSid173Pb6TBN7W75Ug+pcyFIQpiwJQTCFNAE3pcDg62CfO kYPRg4CTWusqbSnQWQoGQs/xB03MW5D4WBC52f/b1x+7/MOqz9jr7ps4fqD7Fv01psqU AZ6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=txTlT/Ji; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q75si13063287pfg.61.2017.11.21.16.50.25; Tue, 21 Nov 2017 16:50:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=txTlT/Ji; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751504AbdKVAts (ORCPT + 75 others); Tue, 21 Nov 2017 19:49:48 -0500 Received: from mail-ot0-f194.google.com ([74.125.82.194]:45583 "EHLO mail-ot0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751408AbdKVAtq (ORCPT ); Tue, 21 Nov 2017 19:49:46 -0500 Received: by mail-ot0-f194.google.com with SMTP id u10so12179073otc.12; Tue, 21 Nov 2017 16:49:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=KF5cx3Ei48j9q0Ki+45KDgJvLyB4HAUOa0MBTBD7/zQ=; b=txTlT/Ji12d0eh7HS5JENQevixTJuZ9Wk4Lwv25nm366Y28KdyfNOcPSasBKlx5gkH 4KfjhXMAzS/lIhQ/sK4E5Vo/YW22jr1msBvDrD6d2OtTx4LVAKgzUzgEjG8suFzvXmc4 AoRzB29/j3SkrzsD3E39YzpgzDNjt19wzhN5uG8wCpncc4EWpMjsi/0vmdm12BZJEErV Sa8YTIiBjzVunEHyGCn7BGPBjAFfGbMayXaQ2/NkFo0pFF85v2DfI8mkCtAFZciZ/uL+ BNquCgas6ejjlX8QVaPMUCCkVo7PRpUbBrK9tZy9QlghNBC3lVVTxsx7cyPcCgrdhJOS m8iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=KF5cx3Ei48j9q0Ki+45KDgJvLyB4HAUOa0MBTBD7/zQ=; b=Cy0IN2YAplxpTIbfVadMHmNXBRwt6vypfgv/m87uHcOnJvn9tIQ0TxDU8JdxNJAOHT L4OiccDrv/muppLMNxf4fmK+tVRdPrP5eH7TLBxKUmrPNL9VU0XkhpNqJx5P1B8OmvOR W4gLN7ONPAMfhzVdXYIscFXSiu+lrbqr9Xy5IRXjKEJNiC9Hz0ar1ZgfRD8PMWfDH/TA Hc7qcVBBKrE+gY0zvVbxecebwT+iFgz+qn/44IuOE7o5wwzDw6EZrSzHKwuZC2pb4B4/ ACNHqTIEq1kIyw/Z6R+zUgFu1Izd3UAidbNnp8jRP0XV+9RRVv37VEMFsMBbLNi4po/E eqRg== X-Gm-Message-State: AJaThX6ScdOaJzO7UnSwxhhTyoS2QpO94wlh/hK5fzW7zWjIwbauLhLu +aKweRVohKGom0LJLZSc8tk= X-Received: by 10.157.4.227 with SMTP id 90mr13047059otm.325.1511311785806; Tue, 21 Nov 2017 16:49:45 -0800 (PST) Received: from [192.168.0.2] (cpe-24-27-59-32.austin.res.rr.com. [24.27.59.32]) by smtp.gmail.com with ESMTPSA id w4sm6476090ote.21.2017.11.21.16.49.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Nov 2017 16:49:44 -0800 (PST) Subject: Re: [PATCH] scsi/eh: fix hang adding ehandler wakeups after decrementing host_busy To: Pavel Tikhomirov Cc: "James E . J . Bottomley" , "Martin K . Petersen" , Christoph Hellwig , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Konstantin Khorenko , devel@openvz.org References: <20170905125424.15412-1-ptikhomirov@virtuozzo.com> <496d6c6e-565b-9ebb-59b4-d4b17e0d9a62@virtuozzo.com> <9941b46c-72be-e171-2e4b-cb12ac5c439d@gmail.com> <753b79c1-1127-c431-e411-1ff47eea0e98@virtuozzo.com> From: Stuart Hayes Message-ID: <173c0be5-e4ab-452d-e5f6-2852147eb040@gmail.com> Date: Tue, 21 Nov 2017 18:49:42 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <753b79c1-1127-c431-e411-1ff47eea0e98@virtuozzo.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Antivirus: Avast (VPS 171121-4, 11/21/2017), Outbound message X-Antivirus-Status: Clean Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org My apologies... yes, your patch also fixes my issue. I was looking at the two new places from which you were calling scsi_eh_wakeup(), and didn't notice that you moved the spinlock in scsi_device_unbusy()... moving the spinlock in scsi_device_unbusy() also should the issue I'm seeing, given that scsi_eh_scmd_add() also uses the spinlock. I tested your patch on my issue, and it did indeed fix my issue. So you can add... Tested-by: Stuart Hayes Thanks Stuart On 11/21/2017 2:09 AM, Pavel Tikhomirov wrote: > My patch should also fix your issue too, please see explanation in reply to your patch. Do your testing show that it doesn't? > > Thanks, Pavel. > > On 11/21/2017 09:10 AM, Stuart Hayes wrote: >> Pavel, >> >> It turns out that the error handler on our systems was not getting woken up for a different reason... I submitted a patch earlier today that fixes the issue I were seeing (I CCed you on the patch). >> >> Before I got my hands on the failing system and was able to root cause it, I was pretty sure that your patch was going to fix our issue, because after I examined the code paths, I couldn't find any other reason that the error handler would not get woken up.  I tried forcing the bug that your patch fixes to occur, by compiling in some mdelay()s in a key place or two in the scsi code, but it never failed for me that way.  With my patch, several systems that previously failed in 10 minutes or less successfully ran for many days. >> >> Thanks, >> Stuart >> >> On 11/9/2017 8:54 AM, Pavel Tikhomirov wrote: >>>> Are there any issues with this patch (https://patchwork.kernel.org/patch/9938919/) that Pavel Tikhomirov submitted back in September?  I am willing to help if there's anything I can do to help get it accepted. >>> >>> Hi, Stuart, I asked James Bottomley about the patch status offlist and it seems that the problem is - patch lacks testing and review. I would highly appreciate review from your side and anyone who wants to participate! >>> >>> And if you can confirm that the patch solves the problem on your environment with no side effects please add "Tested-by:" tag also. >>> >>> Thanks, Pavel >>> >>> On 09/05/2017 03:54 PM, Pavel Tikhomirov wrote: >>>> We have a problem on several our nodes with scsi EH. Imagine such an >>>> order of execution of two threads: >>>> >>>> CPU1 scsi_eh_scmd_add        CPU2 scsi_host_queue_ready >>>> /* shost->host_busy == 1 initialy */ >>>> >>>>                  if (shost->shost_state == SHOST_RECOVERY) >>>>                      /* does not get here */ >>>>                      return 0; >>>> >>>> lock(shost->host_lock); >>>> shost->shost_state = SHOST_RECOVERY; >>>> >>>>                  busy = shost->host_busy++; >>>>                  /* host->can_queue == 1 initialy, busy == 1 >>>>                   * - go to starved label */ >>>>                  lock(shost->host_lock) /* wait */ >>>> >>>> shost->host_failed++; >>>> /* shost->host_busy == 2, shost->host_failed == 1 */ >>>> call scsi_eh_wakeup(shost) { >>>>      if (host_busy == host_failed) { >>>>          /* does not get here */ >>>>          wake_up_process(shost->ehandler) >>>>      } >>>> } >>>> unlock(shost->host_lock) >>>> >>>>                  /* acquire lock */ >>>>                  shost->host_busy--; >>>> >>>> Finaly we do not wakeup scsi_error_handler and all other commands >>>> coming will hang as we are in never ending recovery state as there >>>> is no one left to wakeup handler. >>>> >>>> So scsi disc in these host becomes unresponsive and all bio on node >>>> hangs. (We trigger these problem when scsi cmnds to DVD drive timeout.) >>>> >>>> Main idea of the fix is to try to do wake up every time we decrement >>>> host_busy or increment host_failed(the latter is already OK). >>>> >>>> Now the very *last* one of busy threads getting host_lock after >>>> decrementing host_busy will see all write operations on host's >>>> shost_state, host_busy and host_failed completed thanks to implied >>>> memory barriers on spin_lock/unlock, so at the time of busy==failed >>>> we will trigger wakeup in at least one thread. (Thats why putting >>>> recovery and failed checks under lock) >>>> >>>> Signed-off-by: Pavel Tikhomirov >>>> --- >>>>    drivers/scsi/scsi_lib.c | 21 +++++++++++++++++---- >>>>    1 file changed, 17 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c >>>> index f6097b89d5d3..6c99221d60aa 100644 >>>> --- a/drivers/scsi/scsi_lib.c >>>> +++ b/drivers/scsi/scsi_lib.c >>>> @@ -320,12 +320,11 @@ void scsi_device_unbusy(struct scsi_device *sdev) >>>>        if (starget->can_queue > 0) >>>>            atomic_dec(&starget->target_busy); >>>>    +    spin_lock_irqsave(shost->host_lock, flags); >>>>        if (unlikely(scsi_host_in_recovery(shost) && >>>> -             (shost->host_failed || shost->host_eh_scheduled))) { >>>> -        spin_lock_irqsave(shost->host_lock, flags); >>>> +             (shost->host_failed || shost->host_eh_scheduled))) >>>>            scsi_eh_wakeup(shost); >>>> -        spin_unlock_irqrestore(shost->host_lock, flags); >>>> -    } >>>> +    spin_unlock_irqrestore(shost->host_lock, flags); >>>>          atomic_dec(&sdev->device_busy); >>>>    } >>>> @@ -1503,6 +1502,13 @@ static inline int scsi_host_queue_ready(struct request_queue *q, >>>>        spin_unlock_irq(shost->host_lock); >>>>    out_dec: >>>>        atomic_dec(&shost->host_busy); >>>> + >>>> +    spin_lock_irq(shost->host_lock); >>>> +    if (unlikely(scsi_host_in_recovery(shost) && >>>> +             (shost->host_failed || shost->host_eh_scheduled))) >>>> +        scsi_eh_wakeup(shost); >>>> +    spin_unlock_irq(shost->host_lock); >>>> + >>>>        return 0; >>>>    } >>>>    @@ -1964,6 +1970,13 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx, >>>>      out_dec_host_busy: >>>>        atomic_dec(&shost->host_busy); >>>> + >>>> +    spin_lock_irq(shost->host_lock); >>>> +    if (unlikely(scsi_host_in_recovery(shost) && >>>> +             (shost->host_failed || shost->host_eh_scheduled))) >>>> +        scsi_eh_wakeup(shost); >>>> +    spin_unlock_irq(shost->host_lock); >>>> + >>>>    out_dec_target_busy: >>>>        if (scsi_target(sdev)->can_queue > 0) >>>>            atomic_dec(&scsi_target(sdev)->target_busy); >>>> >>> >> >> --- >> This email has been checked for viruses by Avast antivirus software. >> https://www.avast.com/antivirus >> From 1584695360679565819@xxx Tue Nov 21 16:54:24 +0000 2017 X-GM-THRID: 1577704452897311330 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread