From patchwork Tue Apr 11 01:18:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauricio Faria de Oliveira X-Patchwork-Id: 9674427 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1FFBF60383 for ; Tue, 11 Apr 2017 01:18:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F526283E1 for ; Tue, 11 Apr 2017 01:18:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01378284D8; Tue, 11 Apr 2017 01:18:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90AC2284D8 for ; Tue, 11 Apr 2017 01:18:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753165AbdDKBS1 (ORCPT ); Mon, 10 Apr 2017 21:18:27 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:46529 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753155AbdDKBSZ (ORCPT ); Mon, 10 Apr 2017 21:18:25 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3B1DqOd029316 for ; Mon, 10 Apr 2017 21:18:24 -0400 Received: from e24smtp04.br.ibm.com (e24smtp04.br.ibm.com [32.104.18.25]) by mx0b-001b2d01.pphosted.com with ESMTP id 29rm8x2a0t-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 10 Apr 2017 21:18:24 -0400 Received: from localhost by e24smtp04.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 10 Apr 2017 22:18:22 -0300 Received: from d24relay02.br.ibm.com (9.18.232.42) by e24smtp04.br.ibm.com (10.172.0.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 10 Apr 2017 22:18:20 -0300 Received: from d24av04.br.ibm.com (d24av04.br.ibm.com [9.8.31.97]) by d24relay02.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3B1IIf620054334 for ; Mon, 10 Apr 2017 22:18:19 -0300 Received: from d24av04.br.ibm.com (localhost [127.0.0.1]) by d24av04.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v3B1IH3v017691 for ; Mon, 10 Apr 2017 22:18:17 -0300 Received: from t440.ibm.com ([9.85.135.93]) by d24av04.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v3B1I282017487; Mon, 10 Apr 2017 22:18:13 -0300 From: Mauricio Faria de Oliveira To: hare@suse.de, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, bart.vanassche@sandisk.com Subject: [PATCH 4/4] scsi: scsi_dh_alua: do not print target port group state if it remains unavailable Date: Mon, 10 Apr 2017 22:18:01 -0300 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1491873481-23900-1-git-send-email-mauricfo@linux.vnet.ibm.com> References: <1491873481-23900-1-git-send-email-mauricfo@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17041101-0028-0000-0000-000001A9B85B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17041101-0029-0000-0000-000014A9C368 Message-Id: <1491873481-23900-5-git-send-email-mauricfo@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-10_17:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1704110009 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Path checkers will periodically check all paths to a target port group in unavailable state more often (as they are 'failed'), possibly for a long or indefinite period of time, or for a large number of paths. That might end up flooding the kernel log with the scsi_dh_alua target port group state messages, which are triggered by the rtpg recheck scheduled in alua_check_sense(). So, modify alua_rtpg() not to print such message when that unavailable state remains (i.e., the target port group state did not transition to or from the unavailable state). All other cases continue to be printed. Signed-off-by: Mauricio Faria de Oliveira --- drivers/scsi/device_handler/scsi_dh_alua.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c index c2c9173fd883..8025e024c011 100644 --- a/drivers/scsi/device_handler/scsi_dh_alua.c +++ b/drivers/scsi/device_handler/scsi_dh_alua.c @@ -554,6 +554,17 @@ static void alua_rtpg_print(struct scsi_device *sdev, struct alua_port_group *pg } /* + * alua_state_remains - Whether a RTPG state remains the same across 2 values. + * @state: the state value to check for. + * @old_state: the old state value. + * @new_state: the new state value. + */ +static bool alua_state_remains(int state, int old_state, int new_state) +{ + return ((old_state == state) && (new_state == state)); +} + +/* * alua_rtpg - Evaluate REPORT TARGET GROUP STATES * @sdev: the device to be evaluated. * @@ -571,6 +582,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg) unsigned int tpg_desc_tbl_off; unsigned char orig_transition_tmo; unsigned long flags; + int orig_state; if (!pg->expiry) { unsigned long transition_tmo = ALUA_FAILOVER_TIMEOUT * HZ; @@ -656,6 +668,8 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg) goto retry; } + orig_state = pg->state; + orig_transition_tmo = pg->transition_tmo; if ((buff[4] & RTPG_FMT_MASK) == RTPG_FMT_EXT_HDR && buff[5] != 0) pg->transition_tmo = buff[5]; @@ -689,6 +703,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg) !(tmp_pg->flags & ALUA_PG_RUNNING)) { struct alua_dh_data *h; struct scsi_device *tmp_pg_sdev = NULL; + int tmp_pg_orig_state = tmp_pg->state; tmp_pg->state = desc[0] & 0x0f; tmp_pg->pref = desc[0] >> 7; @@ -704,8 +719,11 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg) * is not running, tmp_pg->rtpg_sdev might be NULL. * Use another/one associated scsi_device to print * its RTPG information. + * Don't print it if state remains 'unavailable'. */ - if ((tmp_pg != pg) && !tmp_pg_sdev) { + if ((tmp_pg != pg) && !tmp_pg_sdev && + !alua_state_remains(SCSI_ACCESS_STATE_UNAVAILABLE, + tmp_pg_orig_state, tmp_pg->state)) { tmp_pg_sdev = h->sdev; alua_rtpg_print(tmp_pg_sdev, tmp_pg, NULL); } @@ -722,7 +740,11 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg) } spin_lock_irqsave(&pg->lock, flags); - alua_rtpg_print(sdev, pg, &valid_states); + + /* Print RTPG information (except if state remains 'unavailable'). */ + if (likely(!alua_state_remains(SCSI_ACCESS_STATE_UNAVAILABLE, + orig_state, pg->state))) + alua_rtpg_print(sdev, pg, &valid_states); switch (pg->state) { case SCSI_ACCESS_STATE_TRANSITIONING: