From patchwork Tue Apr 11 01:17:59 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: 9674421 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 A234B6020C for ; Tue, 11 Apr 2017 01:18:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91795284D8 for ; Tue, 11 Apr 2017 01:18:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86846284E7; Tue, 11 Apr 2017 01:18:22 +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 2D975284D8 for ; Tue, 11 Apr 2017 01:18:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753125AbdDKBST (ORCPT ); Mon, 10 Apr 2017 21:18:19 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:44309 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753046AbdDKBSS (ORCPT ); Mon, 10 Apr 2017 21:18:18 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3B1Gp1F047987 for ; Mon, 10 Apr 2017 21:18:17 -0400 Received: from e24smtp04.br.ibm.com (e24smtp04.br.ibm.com [32.104.18.25]) by mx0a-001b2d01.pphosted.com with ESMTP id 29rmq6hadq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 10 Apr 2017 21:18:17 -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:14 -0300 Received: from d24relay04.br.ibm.com (9.18.232.146) 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:12 -0300 Received: from d24av04.br.ibm.com (d24av04.br.ibm.com [9.8.31.97]) by d24relay04.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3B1IB8J41550058 for ; Mon, 10 Apr 2017 22:18:11 -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 v3B1IAGT017605 for ; Mon, 10 Apr 2017 22:18:11 -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 v3B1I280017487; Mon, 10 Apr 2017 22:18:08 -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 2/4] scsi: scsi_dh_alua: create alua_rtpg_print() for alua_rtpg() sdev_printk Date: Mon, 10 Apr 2017 22:17:59 -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-000001A9B854 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17041101-0029-0000-0000-000014A9C360 Message-Id: <1491873481-23900-3-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 Factor out the sdev_printk() statement with the RTPG information in alua_rtpg() into a new function, alua_rtpg_print(), that will also be used in the following patch. The only functional difference is that the 'valid_states' value is now referenced via a pointer, and can be NULL (optional), in which case the 'valid_states' information is not printed. That is for the following patch too. Signed-off-by: Mauricio Faria de Oliveira --- drivers/scsi/device_handler/scsi_dh_alua.c | 43 ++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c index 5e5a33cac951..0d3508f2e285 100644 --- a/drivers/scsi/device_handler/scsi_dh_alua.c +++ b/drivers/scsi/device_handler/scsi_dh_alua.c @@ -523,6 +523,37 @@ static int alua_tur(struct scsi_device *sdev) } /* + * alua_rtpg_print - Print REPORT TARGET GROUP STATES information + * @sdev: the device evaluated (or associated with this port group). + * @pg: the port group the information is associated with. + * @valid_states: pointer to valid_states value. + * (optional; e.g., obtained via another port group) + * + * Must be called with pg->lock held. + */ +static void alua_rtpg_print(struct scsi_device *sdev, struct alua_port_group *pg, + int *valid_states) +{ + if (valid_states) + 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'); + else + 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 - Evaluate REPORT TARGET GROUP STATES * @sdev: the device to be evaluated. * @@ -679,17 +710,7 @@ 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'); + alua_rtpg_print(sdev, pg, &valid_states); switch (pg->state) { case SCSI_ACCESS_STATE_TRANSITIONING: