Re: [PATCH] scsi: mpt3sas: make sysfs error messages ratelimited

From: Joe Perches
Date: Fri Sep 14 2018 - 07:27:12 EST


On Fri, 2018-09-07 at 11:39 +0100, Colin King wrote:
> From: Colin Ian King <colin.king@xxxxxxxxxxxxx>
>
> It is possible to heavily spam the kernel logs with messages by
> excessive reading of the mpt3sas sysfs files. Make the error messages
> ratelimited to reduce the spamming effect.
[]
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
[]
> @@ -2958,7 +2958,7 @@ _ctl_BRM_status_show(struct device *cdev, struct device_attribute *attr,
> ssize_t rc = 0;
>
> if (!ioc->is_warpdrive) {
> - pr_err(MPT3SAS_FMT "%s: BRM attribute is only for"
> + pr_err_ratelimited(MPT3SAS_FMT "%s: BRM attribute is only for"
> " warpdrive\n", ioc->name, __func__);
> goto out;
> }

trivia:

All the uses of MPT3SAS_FMT in drivers/scsi/mpt3sas/ seem
not nice. It obfuscate the format and arguments.

Perhaps better would be create ioc_<level> macros.