From patchwork Tue Apr 11 01:18:00 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: 9674429 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 C89D96020C for ; Tue, 11 Apr 2017 01:18:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7957283E1 for ; Tue, 11 Apr 2017 01:18:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AAFCA284DD; Tue, 11 Apr 2017 01:18:37 +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 4F7FA283E1 for ; Tue, 11 Apr 2017 01:18:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753172AbdDKBSg (ORCPT ); Mon, 10 Apr 2017 21:18:36 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:41827 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753155AbdDKBSg (ORCPT ); Mon, 10 Apr 2017 21:18:36 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3B1DkPg037646 for ; Mon, 10 Apr 2017 21:18:20 -0400 Received: from e24smtp04.br.ibm.com (e24smtp04.br.ibm.com [32.104.18.25]) by mx0b-001b2d01.pphosted.com with ESMTP id 29rj2uxskp-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 10 Apr 2017 21:18:20 -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:18 -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:15 -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 v3B1IEYj35651782 for ; Mon, 10 Apr 2017 22:18:14 -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 v3B1IDTH017626 for ; Mon, 10 Apr 2017 22:18:13 -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 v3B1I281017487; Mon, 10 Apr 2017 22:18:11 -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 3/4] scsi: scsi_dh_alua: print changes to RTPG state of other PGs too Date: Mon, 10 Apr 2017 22:18:00 -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-000001A9B856 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17041101-0029-0000-0000-000014A9C363 Message-Id: <1491873481-23900-4-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 Currently, alua_rtpg() can change the 'state' and 'preferred' values for the current port group _and_ of other port groups present in the response buffer/descriptors. However, it reports such changes _only_ for the current port group (i.e., only for 'pg' but not for 'tmp_pg'). This might cause uncertainty and confusion when going through the kernel logs for analyzing/debugging scsi_dh_alua behavior, which is not helpful during support and development scenarios. So, print such changes for other port groups than the current one. This requires finding a scsi_device to call sdev_printk() with for that other port group. Using 'tmp_pg->rtpg_sdev' is not an option because in that 'if' conditional the 'tmp_pg' is not in the ALUA_PG_RUNNING state, so that pointer may be NULL. So the for-loop over the tmp->pg device_handler structures is used to find a valid scsi_device that is associated to this port group. Signed-off-by: Mauricio Faria de Oliveira --- drivers/scsi/device_handler/scsi_dh_alua.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c index 0d3508f2e285..c2c9173fd883 100644 --- a/drivers/scsi/device_handler/scsi_dh_alua.c +++ b/drivers/scsi/device_handler/scsi_dh_alua.c @@ -688,6 +688,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg) if ((tmp_pg == pg) || !(tmp_pg->flags & ALUA_PG_RUNNING)) { struct alua_dh_data *h; + struct scsi_device *tmp_pg_sdev = NULL; tmp_pg->state = desc[0] & 0x0f; tmp_pg->pref = desc[0] >> 7; @@ -697,6 +698,17 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg) /* h->sdev should always be valid */ BUG_ON(!h->sdev); h->sdev->access_state = desc[0]; + + /* + * If tmp_pg is not the running pg, and its worker + * is not running, tmp_pg->rtpg_sdev might be NULL. + * Use another/one associated scsi_device to print + * its RTPG information. + */ + if ((tmp_pg != pg) && !tmp_pg_sdev) { + tmp_pg_sdev = h->sdev; + alua_rtpg_print(tmp_pg_sdev, tmp_pg, NULL); + } } rcu_read_unlock(); }