Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp965526ybb; Wed, 8 Apr 2020 13:30:50 -0700 (PDT) X-Google-Smtp-Source: APiQypIuS4gpjw6CipR6VvsslWuQslUpZWkQXy5YSpo2DNvnGGT7OEXrkMgbcmO/vCAx66oofdcK X-Received: by 2002:a05:6830:160c:: with SMTP id g12mr7090525otr.335.1586377850741; Wed, 08 Apr 2020 13:30:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586377850; cv=none; d=google.com; s=arc-20160816; b=vACCMwSQu3FsfFf1BIpCFf/oEjOLABovJwMNsjCYOWGCIO8nsGPvxPKCjX5Nf0Jr+B 4ISNzcKBJGk2Za1RBpEJb+iSUcJjrwGsMiRmhXYPDY8bLN04TUdsQUdpPPYTWon0vc9L 82Ry0C4MJhDD4uBXrp/WwBl2tWvq/6iCYApWNT58wxhYyqK/68arBGlguz5kkZOl0EM6 bFmc+YZhyZOBKWkF6sr8RGvX/eVgDEZlevZAj77PmDYjglPASYzYDgHZxnU7xscJc1vl sdR7yS6/yVQNU9SxvC82M/+H4XxmvHe1OU82F06uix8J+aYONzF1Ipkm3MexJBWdT2yD hiIg== 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:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=7CvAUIVz+j5eQxkWwgrZLmBoQHc38XJ7xtY6pC6wqtQ=; b=OOfnSB6XWhYTxYrVvqe24/pMXnpNwIZnV8nOZyBp1zQxZNdtSF3JUEhl3pL34Th837 lEJK64zvyYV8giKGFUt4WcK4mR+7b8zDnWgHxeyLUTh6syoG86Pp3VmsxnX8P2VPN7+r VJ0l5xW1ReYyPK2TC1K5I4sjsSYUMc51wN4sVOAoGP+6ok4cDS7HHMtTU2sgUO/D4nyZ Xtzj1EkxPsEig+BVITd2hC3stm6iqQaG+S15v/stR8zKcrxHjqFiuF4/ZbNrpVcgI5FA Vz9qJ1Nd1ObCx1oUaccqR290kwgC5KAlMKP1yYqSIkC0VTDWuYH8J1HL0vC/q/fwD5sF 6wmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Jzq9wlMc; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c20si2719584otn.247.2020.04.08.13.30.37; Wed, 08 Apr 2020 13:30:50 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=Jzq9wlMc; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729878AbgDHTQh (ORCPT + 99 others); Wed, 8 Apr 2020 15:16:37 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:24136 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728209AbgDHTQg (ORCPT ); Wed, 8 Apr 2020 15:16:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586373395; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7CvAUIVz+j5eQxkWwgrZLmBoQHc38XJ7xtY6pC6wqtQ=; b=Jzq9wlMcoNYSUCg82JajFpzpeDs5NksxRR5UoA4Bw5n4rnP/lCDDsLWpxOZL12GGDFCH3v BMawgZTBnSa7B61mV19h8zD9Q16F220HV1GVvfZhuVBpkkae3ln85bAeYVh8vEGeQL/o6M +FT1ZFWF3Cj4hu5vXdc4Y0cW8YJrOaE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-125-1wkKQxUHMoaod1zr0jnyWg-1; Wed, 08 Apr 2020 15:16:30 -0400 X-MC-Unique: 1wkKQxUHMoaod1zr0jnyWg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 726931005509; Wed, 8 Apr 2020 19:16:29 +0000 (UTC) Received: from ovpn-113-89.phx2.redhat.com (ovpn-113-89.phx2.redhat.com [10.3.113.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDFF75D9C9; Wed, 8 Apr 2020 19:16:28 +0000 (UTC) Message-ID: <120ce7f4cd1fd070e1f7c353223c21b8e4f29337.camel@redhat.com> Subject: Re: [PATCH] scsi: core: Rate limit "rejecting I/O" messages From: "Ewan D. Milne" To: Daniel Wagner , linux-scsi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "James E.J. Bottomley" , "Martin K. Petersen" Date: Wed, 08 Apr 2020 15:16:27 -0400 In-Reply-To: <20200408171012.76890-1-dwagner@suse.de> References: <20200408171012.76890-1-dwagner@suse.de> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2020-04-08 at 19:10 +0200, Daniel Wagner wrote: > Prevent excessive logging by rate limiting the "rejecting I/O" > messages. For example in setups where remote syslog is used the link > is saturated by those messages when a storage controller/disk > misbehaves. > > Cc: "James E.J. Bottomley" > Cc: "Martin K. Petersen" > Signed-off-by: Daniel Wagner > --- > drivers/scsi/scsi_lib.c | 4 ++-- > include/scsi/scsi_device.h | 10 ++++++++++ > 2 files changed, 12 insertions(+), 2 deletions(-) > > diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c > index 47835c4b4ee0..01c35c58c6f3 100644 > --- a/drivers/scsi/scsi_lib.c > +++ b/drivers/scsi/scsi_lib.c > @@ -1217,7 +1217,7 @@ scsi_prep_state_check(struct scsi_device *sdev, > struct request *req) > */ > if (!sdev->offline_already) { > sdev->offline_already = true; > - sdev_printk(KERN_ERR, sdev, > + sdev_printk_ratelimited(KERN_ERR, sdev, > "rejecting I/O to offline > device\n"); I would really prefer we not do it this way if at all possible. It loses information we may need to debug SAN outage problems. The reason I didn't use ratelimit is that the ratelimit structure is per-instance of the ratelimit call here, not per-device. So this doesn't work right -- it will drop messages for other devices. > } > return BLK_STS_IOERR; > @@ -1226,7 +1226,7 @@ scsi_prep_state_check(struct scsi_device *sdev, > struct request *req) > * If the device is fully deleted, we refuse to > * process any commands as well. > */ > - sdev_printk(KERN_ERR, sdev, > + sdev_printk_ratelimited(KERN_ERR, sdev, > "rejecting I/O to dead device\n"); I practice I hardly see this message, do you actually have a case where this happens? If so perhaps add another flag similar to offline_already? The offline message happens a *lot*, we get a ton of them for each active device when the queues are unblocked when a target goes away. -Ewan > return BLK_STS_IOERR; > case SDEV_BLOCK: > diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h > index c3cba2aaf934..8be40b0e1b8f 100644 > --- a/include/scsi/scsi_device.h > +++ b/include/scsi/scsi_device.h > @@ -257,6 +257,16 @@ sdev_prefix_printk(const char *, const struct > scsi_device *, const char *, > #define sdev_printk(l, sdev, fmt, a...) > \ > sdev_prefix_printk(l, sdev, NULL, fmt, ##a) > > +#define sdev_printk_ratelimited(l, sdev, fmt, a...) > \ > +({ > \ > + static DEFINE_RATELIMIT_STATE(_rs, > \ > + DEFAULT_RATELIMIT_INTERVAL, \ > + DEFAULT_RATELIMIT_BURST); > \ > + > \ > + if (__ratelimit(&_rs)) > \ > + sdev_prefix_printk(l, sdev, NULL, fmt, ##a); > \ > +}) > + > __printf(3, 4) void > scmd_printk(const char *, const struct scsi_cmnd *, const char *, > ...); >