Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5454527ybl; Tue, 10 Dec 2019 06:22:01 -0800 (PST) X-Google-Smtp-Source: APXvYqz6tMCHcfuyFSRUFqKgobC+DkK03Aj/TspxPkTBzE9ovxUs3zTjedjdyPP8f8SED58BN0FO X-Received: by 2002:aca:aa0d:: with SMTP id t13mr4231760oie.18.1575987721359; Tue, 10 Dec 2019 06:22:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575987721; cv=none; d=google.com; s=arc-20160816; b=lu2pjVhdKwpBlFjOQcN45WlNuX/76/uXdVD6nl9whjgL4nzszPnAGZTVoIi2ae+r4U ZcYWdEq/Sfl2n4t8/OvDV1LVwQvQ9lKrUzyYNhID1XP8/AkMpybuCB3l+BKL/uZd3ZjI RnQt1ruDFeFB04sZwbvlrWAWbsbtaUggPhH144B7Eq50AFXN9wq9TydFT8WDbdkFuJJx 9pPv00RQfmnV2TfDAbg6oWEwZ/+vPZzPtLyUWQc7Coj1A9xYAdb8D9tf7d8N0u9ThWRT dLjjNOKfa9+HHweAd4WJbhKSVnyYKsZptZY1MRzeNuq9SO9Q1KQ5srAl7O6oZfyn6HRB 2uXA== 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:mime-version:user-agent:date:message-id:subject :from:cc:to:dkim-signature; bh=Nm+vTenSP3nTEJzZ9gsyRgT1MaP/K0w7mP6Ts8dGVRY=; b=VzJmAv3h+LQEMJ8/O5N0h8stEix+3e3qagPlK4kGAW+WVW/mZTOOQVCKlJa9e4hM97 TYPic4oNWG+0EE0AXB5U+0b46jUBGcIZdE6y2ekFZCiD032JJIBDo6jaSSCw9yYSZPFF 8q9aarovgfUWyrivew8jvKZbrWHZmy8ruvOVi+d2bEACp6Ew9BMZyNxqn++QrHH4ByKe emXlFdyhl9RoqFoNWbudv5Db/iO9bvORLP8ho7FPbJof4+QF5Z5bKN09XDOodzB6k5ra 8KRVXyUREH2sl6W7IwfDfzd88Mvuk9R79ZvR96ZSe9DtVYmYGELBd+9Xbgg1+WcGVHw4 E9SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=MoeXIuQ9; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q18si1947508otc.189.2019.12.10.06.21.48; Tue, 10 Dec 2019 06:22:01 -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=@gmx.net header.s=badeba3b8450 header.b=MoeXIuQ9; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727407AbfLJOVS (ORCPT + 99 others); Tue, 10 Dec 2019 09:21:18 -0500 Received: from mout.gmx.net ([212.227.15.15]:60369 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727061AbfLJOVR (ORCPT ); Tue, 10 Dec 2019 09:21:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1575987668; bh=l1pRmOq+rpXSKUIG2EqcAf4rtoRv+wFY83lHK/cc0ss=; h=X-UI-Sender-Class:To:Cc:From:Subject:Date; b=MoeXIuQ9aoji2vM/cBGhRbGcw5PFEnIzgr2TGYFbQaKxOIo440i+kinAxB3Vvl6hB GQeurd3BVO2tbT8eUtI7n1JVHvj/WPY6QFRgFmN7YXyYZIU6UqHgKaw0symMDuJxGV tYQjI3/jvc2kqbvg+7WAKDaYtntIIptftCH5cZZY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [172.17.64.14] ([192.166.200.216]) by mail.gmx.com (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mkpf3-1hsNwp24qN-00mL6u; Tue, 10 Dec 2019 15:21:08 +0100 To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jejb@linux.ibm.com, martin.petersen@oracle.com From: Arne Jansen Subject: [PATCH] scsi_lib: ratelimit printk in scsi_prep_state_check Message-ID: Date: Tue, 10 Dec 2019 15:21:07 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:kBrkFfIaI15TPM1yAM1i/LI3rFsPSOELhgHQ3tMx16sfCOTd2qm unORwUNeOwrhwkrLBt8IhPxtSJIKrR77XZb95as8xDhICmuopXcteJNC4nyQnD6Hxyy0wbN XO1Fpa+4Lw4LAhAxn8pz6WpcA5yEOYDuIFxA7lgIvJ5nbqLUsRzFmcmOArAByY9N0Gvezrm Wgp6P/7D26r7OZhUAXBAQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:tevy09w2tzs=:PerOjC1B7+FXqVAbkGXzJy EhAE3G31EvOf6r5xxQEp2YBCIGTd2fDP5Us9C0QvqaahxfKJTnyqORc+XV7BFAf3Z9xukFYpO 22PQzNXgj16m3i24apJnAu1FCJEUyZGyuh3vnOUK+nr/RtT+rLpvuAZD3cUPhdIttAOB1Zle6 6H77Jh5Z/VWFlpinUQq8M7Y6MVjUkaCApPXzOZbb2xSL7zxaLOMIDcYLDZs61yvIP4EPKluEH V/kYL0k7e37BfcpaHOVjODWOD4IZAxb+WYx8drH3fXNG6qTQlUvH1qmYW+EWU6lIHvXEyLnZX GHe6o7ADRqbj179fd72JA0nBgcL7bVG3kL5VrtiItEAz3e5Z7B5jRZ4uuAMX1x6MHEZjAvk3b Lec8IkaUwzYvt3iVknGdl+qYz6glnlkoMZrwO8iLcV7gF5I1qAiYHBMKsVeBq3Uj8lIDjAqhz WmGEIK1fJRJAIC0+fDNO4TmaUuF83wKKL3Airf2DVJPBjC1y6fQSgVkjaSP3VckluWoJU8Y/b RHrN/gbdEnzJRCm2YaaAD+nidvDKXak4BaUFLFjTfb5yltAizUvRE0U7kzMYZymF/kNU+TPys f2NDGj8pc8QeLZHq1oe7fuGRD2Rvfv6TBnNAjyDGA785pCBgqRNQFF0T0yhoj/WWTEIsko1UC lRnuymy8VJsBC79uJpRuNvmNeP3g4x3Uk8FKvpUF93st8QkE+zMSwba6kjhK4EPs6DB23H+QW nlqbF8u29de9vEk0M8O8pYeLcC6Mc/CVUtra7xu1J7UWAgssFBToEK5ecYTIQ25uEEwmuezhi MLkAdVacrtryxenistqwBcLLwJB9p+RwtOxFmLJQKIvlTXkR/NP7b3UNZvMK3yUFR000SgZrT Rcyzn+QR0Abq9H3CvxPzEezdwJjwdq+rYgc61mlGWK1HRy5Oq0hZSBj3OU86JbEjDjqTXCfuK lGHdqtDnya/k7YnzOq0brndMlh1asMehXLl5N2uU0cu7ir0hLRmFumEJTmCxWtznDPzWtM4tj VMx5llVEXFYZ+JMx6Xw8AhGhfXw/NHUCVRH5b2xPJH/U8nHH8oqObqfEFyjACyqCKu4GpcF74 kfSIBof9SCRoFQUde8GciSmBv+8CqEEO/oAkdvYDQyG4BgphIYeKta8T4pwgrfS7+9G1KqBic KFr/QIil3PmLRZ8mm3J5m1EMx4la5VCID+wt3YDX1hIkt+tgJ2Bd6NkEdkPAu36hh0tLp1p1j wkpXBlgGCzYoiSs9eu/59RKNyzypP6gaKKH2ycCPqsVme52KXP9eJoy8pl3Q= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org scsi_prep_state_check is called with the queue_lock held, called from scsi_internal_device_unblock. The same lock is also acquired in softirq context from scsi_end_request. If the output overwhelms the serial console, the machine effectively comes to a halt, even triggering a hardware watchdog. This patch ratelimits the output. Signed-off-by: Arne Jansen =2D-- drivers/scsi/scsi_lib.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 3e7a45d0daca..33432108d6aa 100644 =2D-- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1232,6 +1232,10 @@ static blk_status_t scsi_setup_cmnd(struct scsi_device *sdev, static blk_status_t scsi_prep_state_check(struct scsi_device *sdev, struct request *req) { + static DEFINE_RATELIMIT_STATE(_rs, + DEFAULT_RATELIMIT_INTERVAL, + DEFAULT_RATELIMIT_BURST); + switch (sdev->sdev_state) { case SDEV_OFFLINE: case SDEV_TRANSPORT_OFFLINE: @@ -1240,16 +1244,18 @@ scsi_prep_state_check(struct scsi_device *sdev, struct request *req) * commands. The device must be brought online * before trying any recovery commands. */ - sdev_printk(KERN_ERR, sdev, - "rejecting I/O to offline device\n"); + if (__ratelimit(&_rs)) + sdev_printk(KERN_ERR, sdev, + "rejecting I/O to offline device\n"); return BLK_STS_IOERR; case SDEV_DEL: /* * If the device is fully deleted, we refuse to * process any commands as well. */ - sdev_printk(KERN_ERR, sdev, - "rejecting I/O to dead device\n"); + if (__ratelimit(&_rs)) + sdev_printk(KERN_ERR, sdev, + "rejecting I/O to dead device\n"); return BLK_STS_IOERR; case SDEV_BLOCK: case SDEV_CREATED_BLOCK: =2D- 2.11.0