Received: by 10.223.164.202 with SMTP id h10csp4838807wrb; Tue, 21 Nov 2017 00:07:21 -0800 (PST) X-Google-Smtp-Source: AGs4zMZlP0eXgqYIrHJ8iNIEp9517hyQ7QR2u4kl09HEKbR2fePlnBymqFX38L7bUvS0aInl2fG4 X-Received: by 10.84.129.1 with SMTP id 1mr16674729plb.40.1511251641162; Tue, 21 Nov 2017 00:07:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511251641; cv=none; d=google.com; s=arc-20160816; b=FZGpS4VrayRgr8INQcZ8SSqRSVEBmkCy87I9nGv/t2nqbrgbvfUU9t5LHgpKqlC+XA 1tpcWPeoqw1TKpZppQYqpAFYXXzxulUbpVSGaBOR3WjNUVnG2nva0C7FxFfbIIbADbPI vGXmJZK+OS9O3EYNkhfM+WSWwSTNpH3zo0nDlgbZjVy8q1EMlIsA8hbNQPWrdEJs8noz 5tZ80ql5K1xDZzAUu2UIoip0AmMysAFnLxuqT8vrQiwtO+fKgsj+HVHD7BSTO80VIQvE v/WaofkPUJJhxBAtmaLuMj+gWuaHeVaigd0/JiX/Xju9nED06ulSMqE4ftRv0H+fzcqS 51yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput: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=lqfs403iqyaG0ljYd6gbXaL/Sk/+9vkzKMjPwRjMxqI=; b=h+GsETZONqgSrJuapJ9WLZbqDk/EtW9chL8CxJhuZwDr9w8+NnhdcbXgMZlQg2u54E A8fXLgP4jor3gE3/4VuDRL6cMLD92FxDUjIXT+wzB3Bn1kaiJKT795PY30R9CHTOvfs0 5VOygDpPGU5zcrxvFCkcwQ2FvNHin7fAFAEtqMM5DhjMBMnuTnd5f3vGA4PSLTZWRtWQ KbMvp6dVWPrU/QdGUv1baWvFd/yk6ZzmIOMJKFS/q1QC6VMhWXvLfvOQvnC7EFyNQBZK 3r4XV1dGXGlGXYUa6DxOH3dkDRw9NFutyPTuBe7dnLrByMiBWMmCxj0P59EuE2I5wwQC cU/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=R5/0O563; 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=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si9975150pgp.487.2017.11.21.00.07.10; Tue, 21 Nov 2017 00:07:21 -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=@virtuozzo.com header.s=selector1 header.b=R5/0O563; 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=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751337AbdKUIGd (ORCPT + 73 others); Tue, 21 Nov 2017 03:06:33 -0500 Received: from mail-eopbgr50119.outbound.protection.outlook.com ([40.107.5.119]:28457 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751151AbdKUIGb (ORCPT ); Tue, 21 Nov 2017 03:06:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=lqfs403iqyaG0ljYd6gbXaL/Sk/+9vkzKMjPwRjMxqI=; b=R5/0O563LXR3clw36/qablYPNmzQmF08JEw5V+bSAd/WJO7GkKYsIJpko8lRRR30ePS29KOLAJnCk6uWXMGlkEW/izUyIpkeUArcN+LDvnHFkPU8B/w+hZ0QzEEzQ1U+RZe4TQWKeo+UvY2cWBPnpsikNehiSgyFzDM4Ss12Fv4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ptikhomirov@virtuozzo.com; Received: from [172.16.24.163] (195.214.232.6) by DB5PR08MB0966.eurprd08.prod.outlook.com (2603:10a6:0:13::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.239.5; Tue, 21 Nov 2017 08:06:26 +0000 Subject: Re: [PATCH] scsi_error: ensure EH wakes up on error to prevent host getting stuck To: Stuart Hayes , "James E.J. Bottomley" , "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Joshua_Giles@Dell.com References: From: Pavel Tikhomirov Message-ID: Date: Tue, 21 Nov 2017 11:06:23 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR0401CA0048.eurprd04.prod.outlook.com (2603:10a6:3:19::16) To DB5PR08MB0966.eurprd08.prod.outlook.com (2603:10a6:0:13::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 04161650-a945-4fe9-51fd-08d530b6c427 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(4534020)(4602075)(7168020)(4627115)(201703031133081)(201702281549075)(2017052603258);SRVR:DB5PR08MB0966; X-Microsoft-Exchange-Diagnostics: 1;DB5PR08MB0966;3:G5Jz/4mdVFl1J4U74L8EKcBouwNNKeHgi4kqcNgQw23SvfLsaXSSljOCoSOi7tkYgrGtNh2xpbutBl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n3ZNfB/Pg7gPx+3sE8/sgZ6Ej8Or9gLQelPRcbqoVC/YAMxkX6vd0Zj7Yp+R6Cxe/dWSZMsI3VpcteI5PezmtDuWwFnZgtGTLu/CkaOlaqQ12jfBZ6d4s7NE8eq/Y9X8FtLI+Rl4NQa/uKujP9PHkxTz9fXFbvtPCRNEEUEfVRhXlj4oc=;4:oSpY1e4kaaYCxWfhmxPphiJ/yS8sCKEGB71Rk20iR21/A7D9RMTzhj1DDUJYUhbqgWvQe/l74udZJvL2UMOB0CriUKv+CzzDv6cxrwVhIB5t6VuEsVQvfwGrjIyje3trj7ECjV0aXeZHeKnldY7ld/h3tHUpQTRKF9S4ivVKz+yh2sZeCOduT+GODA67IIYqmML4Ds1DhQdMMAj8gOGt3bLFmCfDEDwR7BCqev5ET0qcqY+vM2+IHlZpvd16KKcHBjfwi5MCVuyOkPbkj3Hhhu+TbuO+dkjQIhVlH62GjGRG2f86wparS1367ScVVJCD X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(6538939549742); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(3231022)(100000703101)(100105400095)(6041248)(20161123560025)(20161123562025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DB5PR08MB0966;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DB5PR08MB0966; X-Forefront-PRVS: 049897979A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(6049001)(376002)(346002)(377424004)(24454002)(189002)(199003)(47776003)(6246003)(229853002)(50466002)(39060400002)(33646002)(2906002)(66066001)(65956001)(65806001)(53546010)(6486002)(77096006)(7736002)(4326008)(305945005)(31696002)(86362001)(5660300001)(65826007)(53936002)(6666003)(2950100002)(6306002)(64126003)(106356001)(105586002)(8666007)(8676002)(230700001)(55236003)(68736007)(81156014)(81166006)(189998001)(25786009)(67846002)(23676003)(478600001)(31686004)(97736004)(8936002)(110136005)(36756003)(58126008)(101416001)(966005)(83506002)(50986999)(76176999)(54356999)(4001150100001)(16576012)(316002)(16526018)(3846002)(6116002);DIR:OUT;SFP:1102;SCL:1;SRVR:DB5PR08MB0966;H:[172.16.24.163];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtEQjVQUjA4TUIwOTY2OzIzOkpudVMwUElkbTVCcFpPTkQ3aXVuYlRxbThu?= =?utf-8?B?UFJKUHZMOVZ3Q200YVNKL09FbDJyKzB4YVBmbExCYTI3TFE2MlA4MWNvdmdT?= =?utf-8?B?Z053Rmd4eWFyKy9JY01FeG5ZZkMzbisvSWM1R2JEZmhHQ2JGUXBhN3YzbjMx?= =?utf-8?B?eG9WUzc5aGt3b21CTmJSQ2tDdjF5c1ZxNEozN1FSK3NnL0ZwSWhuNVJSMTdZ?= =?utf-8?B?bXIyTEd0NmJpZWgxYXJLWE9DbjVKMGFRTGxaMVRMdUNSb2YwVjJRZnBrV2FL?= =?utf-8?B?WWlHQjUrWUtFT3JoUmhKMVNlZUsxYjI3d0F0dmh0dnBYcysyOW9qWHE4dUc3?= =?utf-8?B?akRRTGJhYUVCcTAxOGwzNWJyWk4xbEVvMktMQ1o1aVVkVkIyZ3JJVmorbHli?= =?utf-8?B?alg4bzhOd3N3SHFKQ3JnZ3VSWVJmcTBMOHpidk1ybFN3djJmSlVnOTRNbkxI?= =?utf-8?B?ODlSRXBqV1lhbTdOdko3Z09LNWdPdmFjVnlrSEFyZlA3UmJHK0toS21NSEo3?= =?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JgpfJqGxCQHMncFcMW7jZVZy699EezeIHMoZmU+YcXiH8YIt8=;5:qjx/T6BAWpvdjolApwNnlUsvPrjuAZRMr67dnpLO0i5gGlwSEOZaL7qt4TSj1w01NYEt/rTf8jAE4rHSk+GDGKjax/sZJp/HZzG1AIAHvXDmg1jFFs4slDuOup/+PVa3J2tn85ZEH5/OsFKy3iJRccjPxRNX8cbWzZrqNSyuzpU=;24:7apO3SfNA3+DUMJZy1XaloF+CcFj1+4p1JQrlc//0lz36kHmac42B8aerEX+2IESiGqaTG9VhpVLoOnztLDpJEnHCQCTPOf8OJP4qGujE70=;7:ng6XJHcp9KNrr6xHpo6IdmCH/A5xgugZeAyR2B9J0A9z2OVcWx4tbsyD0IDwdfvY8NiUm0JAzbEJSehv22rsSUh7hNVAcE63NzBJetHZiopTxB2AAW6m1kvGcZPk/vSZzVAIQsjiNo/44LkIZXW+6s5VNxf+S/6cuWNWYMQxAp+kMtMqJN754RD2YRBnqXv4nv/knMkz4NpNoJBiinYg8PWL7eE9mnCjJXRf66nSH4ZyMrMC7LGj9Z0c/yaps0r4 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DB5PR08MB0966;20:YfuoxXXHZv0SBoGBOvw5kOJBmPFbRTJ80z1//y9/reGM8P3m1hDECAH8c4F1s7rlvUYDiiIiSyVFTKtWEFmU8kw3gkVQPEr6DcHi93yImTWOSQPH1oyUpRvPzTtlTGDJMpJGbc3Xp9yHzG9xm92mF9a+VAJiOQ6za+V1G0uIORA= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2017 08:06:26.9635 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 04161650-a945-4fe9-51fd-08d530b6c427 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR08MB0966 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/20/2017 10:11 PM, Stuart Hayes wrote: > When a command is added to the host's error handler command queue, there is a chance that the error handler will not be woken up. This can happen when one CPU is running scsi_eh_scmd_add() at the same time as another CPU is running scsi_device_unbusy() for a different command on the same host. Each function changes one value, and then looks at the value of a variable that the other function has just changed, but if they both see stale data, neither will actually wake up the error handle > > In scsi_eh_scmd_add, host_failed is incremented, then scsi_eh_wakeup() is called, which sees that host_busy is still 2, so it doesn't actually wake up the handler. Meanwhile, in scsi_device_unbusy(), host_busy is decremented, and then it sees that host_failed is 0, so it doesn't even call scsi_eh_wakeup(). If in scsi_eh_scmd_add() we call scsi_eh_wakeup() it is done under spinlock, so we have implied memory barrier here. All stores which we've done before we had released the lock will be seen by any other thread in same critical section if the thread took spinlock after us. So later scsi_device_unbusy() in it's scsi_eh_wakeup() also sees host_failed==1. Actually the problem is that in scsi_device_unbusy() the check below: if (unlikely(scsi_host_in_recovery(shost) && (shost->host_failed || shost->host_eh_scheduled)) is not under same spinlock, so that host_failed can be actually be 0 at these point and we never get to scsi_eh_wakeup, which my patch "scsi/eh: fix hang adding ehandler wakeups after decrementing host_busy" also fixes by putting these check under proper lock and thus the implied barrier is added and we don't need actual barrier here. Please see "LOCK ACQUISITION FUNCTIONS" Documentation/memory-barriers.txt for further information about implied memory barriers. > > Signed-off-by: Stuart Hyaes > > --- > diff -pur linux-4.14/drivers/scsi/scsi_error.c linux-4.14-stu/drivers/scsi/scsi_error.c > --- linux-4.14/drivers/scsi/scsi_error.c 2017-11-12 12:46:13.000000000 -0600 > +++ linux-4.14-stu/drivers/scsi/scsi_error.c 2017-11-17 14:22:19.230867923 -0600 > @@ -243,6 +243,10 @@ void scsi_eh_scmd_add(struct scsi_cmnd * > scsi_eh_reset(scmd); > list_add_tail(&scmd->eh_entry, &shost->eh_cmd_q); > shost->host_failed++; > + /* > + * See scsi_device_unbusy() for explanation of smp_mb(). > + */ > + smp_mb(); > scsi_eh_wakeup(shost); > spin_unlock_irqrestore(shost->host_lock, flags); > } > diff -pur linux-4.14/drivers/scsi/scsi_lib.c linux-4.14-stu/drivers/scsi/scsi_lib.c > --- linux-4.14/drivers/scsi/scsi_lib.c 2017-11-12 12:46:13.000000000 -0600 > +++ linux-4.14-stu/drivers/scsi/scsi_lib.c 2017-11-17 14:22:15.814867833 -0600 > @@ -325,6 +325,15 @@ void scsi_device_unbusy(struct scsi_devi > unsigned long flags; > > atomic_dec(&shost->host_busy); > + > + /* This function changes host_busy and looks at host_failed, while > + * scsi_eh_scmd_add() updates host_failed and looks at host_busy (in > + * scsi_eh_wakeup())... if these happen simultaneously without the smp > + * memory barrier, each can see the old value, such that neither will > + * wake up the error handler, which can cause the host controller to > + * be hung forever. > + */ > + smp_mb(); > if (starget->can_queue > 0) > atomic_dec(&starget->target_busy); > > > > --- > This email has been checked for viruses by Avast antivirus software. > https://www.avast.com/antivirus > -- Best regards, Tikhomirov Pavel Software Developer, Virtuozzo. From 1584613463347175903@xxx Mon Nov 20 19:12:41 +0000 2017 X-GM-THRID: 1584613463347175903 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread