From patchwork Mon Jul 10 22:47:35 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: 9833843 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 2337860393 for ; Mon, 10 Jul 2017 22:48:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 161EF28505 for ; Mon, 10 Jul 2017 22:48:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0ADB72847D; Mon, 10 Jul 2017 22:48:20 +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=unavailable 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 68DB3283CF for ; Mon, 10 Jul 2017 22:48:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754927AbdGJWsO (ORCPT ); Mon, 10 Jul 2017 18:48:14 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54375 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755044AbdGJWsJ (ORCPT ); Mon, 10 Jul 2017 18:48:09 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6AMYQ3P060014 for ; Mon, 10 Jul 2017 18:47:54 -0400 Received: from e24smtp02.br.ibm.com (e24smtp02.br.ibm.com [32.104.18.86]) by mx0b-001b2d01.pphosted.com with ESMTP id 2bm48ysbrd-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 10 Jul 2017 18:47:53 -0400 Received: from localhost by e24smtp02.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 10 Jul 2017 19:47:51 -0300 Received: from d24relay02.br.ibm.com (9.13.39.42) by e24smtp02.br.ibm.com (10.172.0.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 10 Jul 2017 19:47:50 -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 v6AMlnZX8978804; Mon, 10 Jul 2017 19:47:49 -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 v6AMlnAZ009494; Mon, 10 Jul 2017 19:47:50 -0300 Received: from t440.ibm.com ([9.85.207.174]) by d24av04.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v6AMldAK009404; Mon, 10 Jul 2017 19:47:47 -0300 From: Mauricio Faria de Oliveira To: jejb@linux.vnet.ibm.com, martin.petersen@oracle.com Cc: hare@suse.de, bart.vanassche@sandisk.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] scsi: scsi_dh_alua: print changes to RTPG state of all PGs Date: Mon, 10 Jul 2017 19:47:35 -0300 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1499726857-7875-1-git-send-email-mauricfo@linux.vnet.ibm.com> References: <1499726857-7875-1-git-send-email-mauricfo@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17071022-0020-0000-0000-000002BEE36A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071022-0021-0000-0000-000030DE0F0C Message-Id: <1499726857-7875-3-git-send-email-mauricfo@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-10_08:, , 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-1703280000 definitions=main-1707100389 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. However, it reports that _only_ for the current port group. 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 of such changes for all port groups, when it occurs. It's possible to distinguish between the messages printed for the current and other PGs by the 'supports' (supported states) part, which is only printed for the current PG. Signed-off-by: Mauricio Faria de Oliveira --- v2: - use lockdep_assert_held() instead of documenting locking conventions (Bart Van Assche ) - define two functions (with/without supported states information) (Bart Van Assche ) - simplify which device is used for printing the messages (use the evaluated scsi device and tell which PG the info is for) - call the print functions from nearby places (right after modifying the PG data) drivers/scsi/device_handler/scsi_dh_alua.c | 63 +++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c index a1cf3d6aa853..937341ddb767 100644 --- a/drivers/scsi/device_handler/scsi_dh_alua.c +++ b/drivers/scsi/device_handler/scsi_dh_alua.c @@ -529,6 +529,49 @@ static int alua_tur(struct scsi_device *sdev) } /* + * alua_rtpg_print - Print REPORT TARGET GROUP STATES information + * (without supported states) + * @sdev: the device evaluated (source of information). + * @pg: the port group associated with the information. + */ +static void alua_rtpg_print(struct scsi_device *sdev, + struct alua_port_group *pg) +{ + lockdep_assert_held(&pg->lock); + + sdev_printk(KERN_INFO, sdev, + "%s: port group %02x state %c %s\n", + ALUA_DH_NAME, pg->group_id, print_alua_state(pg->state), + pg->pref ? "preferred" : "non-preferred"); +} + +/* + * alua_rtpg_print_supported - Print REPORT TARGET GROUP STATES information + * (with supported states) + * @sdev: the device evaluated (source of information). + * @pg: the port group associated with the information. + * @supported_states: the supported states information. + */ +static void alua_rtpg_print_supported(struct scsi_device *sdev, + struct alua_port_group *pg, + int supported_states) +{ + lockdep_assert_held(&pg->lock); + + sdev_printk(KERN_INFO, sdev, + "%s: port group %02x state %c %s supports %c%c%c%c%c%c%c\n", + ALUA_DH_NAME, pg->group_id, print_alua_state(pg->state), + pg->pref ? "preferred" : "non-preferred", + supported_states & TPGS_SUPPORT_TRANSITION ? 'T' : 't', + supported_states & TPGS_SUPPORT_OFFLINE ? 'O' : 'o', + supported_states & TPGS_SUPPORT_LBA_DEPENDENT ? 'L' : 'l', + supported_states & TPGS_SUPPORT_UNAVAILABLE ? 'U' : 'u', + supported_states & TPGS_SUPPORT_STANDBY ? 'S' : 's', + supported_states & TPGS_SUPPORT_NONOPTIMIZED ? 'N' : 'n', + supported_states & TPGS_SUPPORT_OPTIMIZED ? 'A' : 'a'); +} + +/* * alua_rtpg - Evaluate REPORT TARGET GROUP STATES * @sdev: the device to be evaluated. * @@ -540,7 +583,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg) { struct scsi_sense_hdr sense_hdr; struct alua_port_group *tmp_pg; - int len, k, off, valid_states = 0, bufflen = ALUA_RTPG_SIZE; + int len, k, off, bufflen = ALUA_RTPG_SIZE; unsigned char *desc, *buff; unsigned err, retval; unsigned int tpg_desc_tbl_off; @@ -674,9 +717,12 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg) h->sdev->access_state = desc[0]; } rcu_read_unlock(); + + if (tmp_pg == pg) + alua_rtpg_print_supported(sdev, tmp_pg, desc[1]); + else + alua_rtpg_print(sdev, tmp_pg); } - if (tmp_pg == pg) - valid_states = desc[1]; spin_unlock_irqrestore(&tmp_pg->lock, flags); } kref_put(&tmp_pg->kref, release_port_group); @@ -685,17 +731,6 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg) } spin_lock_irqsave(&pg->lock, flags); - sdev_printk(KERN_INFO, sdev, - "%s: port group %02x state %c %s supports %c%c%c%c%c%c%c\n", - ALUA_DH_NAME, pg->group_id, print_alua_state(pg->state), - pg->pref ? "preferred" : "non-preferred", - valid_states&TPGS_SUPPORT_TRANSITION?'T':'t', - valid_states&TPGS_SUPPORT_OFFLINE?'O':'o', - valid_states&TPGS_SUPPORT_LBA_DEPENDENT?'L':'l', - valid_states&TPGS_SUPPORT_UNAVAILABLE?'U':'u', - valid_states&TPGS_SUPPORT_STANDBY?'S':'s', - valid_states&TPGS_SUPPORT_NONOPTIMIZED?'N':'n', - valid_states&TPGS_SUPPORT_OPTIMIZED?'A':'a'); switch (pg->state) { case SCSI_ACCESS_STATE_TRANSITIONING: