From patchwork Tue Jul 25 14:14:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steffen Maier X-Patchwork-Id: 9862113 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 A09AD600F5 for ; Tue, 25 Jul 2017 14:15:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9412C27F94 for ; Tue, 25 Jul 2017 14:15:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 88F57285DB; Tue, 25 Jul 2017 14:15:18 +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 24DC127F94 for ; Tue, 25 Jul 2017 14:15:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752378AbdGYOPP (ORCPT ); Tue, 25 Jul 2017 10:15:15 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:38200 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752385AbdGYOPO (ORCPT ); Tue, 25 Jul 2017 10:15:14 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6PEEs8B145520 for ; Tue, 25 Jul 2017 10:15:13 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bx6c2c1wn-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 25 Jul 2017 10:15:13 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 25 Jul 2017 15:15:11 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 25 Jul 2017 15:15:08 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6PEF7j938731862; Tue, 25 Jul 2017 14:15:07 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9E1944C044; Tue, 25 Jul 2017 15:12:40 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 69DE14C040; Tue, 25 Jul 2017 15:12:40 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 25 Jul 2017 15:12:40 +0100 (BST) From: Steffen Maier To: linux-scsi@vger.kernel.org, Hannes Reinecke Cc: linux-s390@vger.kernel.org, Steffen Maier , Benjamin Block Subject: [RFC 9/9] zfcp: decouple our scsi_eh callbacks from scsi_cmnd Date: Tue, 25 Jul 2017 16:14:27 +0200 X-Mailer: git-send-email 2.11.2 In-Reply-To: <20170725141427.35258-1-maier@linux.vnet.ibm.com> References: <20170725141427.35258-1-maier@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17072514-0012-0000-0000-00000565F1CA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17072514-0013-0000-0000-000018DAD621 Message-Id: <20170725141427.35258-10-maier@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-25_07:, , 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-1706020000 definitions=main-1707250227 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 zfcp_scsi_eh_device_reset_handler() now only depends on scsi_device. zfcp_scsi_eh_target_reset_handler() now only depends on scsi_target. zfcp_scsi_eh_host_reset_handler() now only depends on Scsi_Host. All derive other objects from these intended callback arguments. Actually change the signature of zfcp_task_mgmt_function() used by zfcp_scsi_eh_device_reset_handler() & zfcp_scsi_eh_target_reset_handler(). Since it was prepared in a previous patch, we only need to delete some local auto variables which are now the intended arguments. Signed-off-by: Steffen Maier Reviewed-by: Hannes Reinecke --- drivers/s390/scsi/zfcp_scsi.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index 11cf33ea8c14..4cb38cfd46e3 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c @@ -266,11 +266,17 @@ static void zfcp_scsi_forget_cmnds(struct zfcp_port *port, write_unlock_irqrestore(&adapter->abort_lock, flags); } -static int zfcp_task_mgmt_function(struct scsi_cmnd *scpnt, u8 tm_flags) +/** + * zfcp_task_mgmt_function() - Synchronously send a task management function. + * @port: Pointer to zfcp port indicating scope. + * @sdev: Pointer to SCSI device as scope, or %NULL if scope is only port. + * @tm_flags: Task management flags, + * here we only handle %FCP_TMF_TGT_RESET or %FCP_TMF_LUN_RESET. + */ +static int zfcp_task_mgmt_function(struct zfcp_port *port, + struct scsi_device *sdev, u8 tm_flags) { - struct scsi_device *sdev = scpnt->device; - struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); - struct zfcp_port *port = zfcp_sdev->port; + struct zfcp_scsi_dev *zfcp_sdev = sdev ? sdev_to_zfcp(sdev) : NULL; struct zfcp_adapter *adapter = port->adapter; unsigned int scsi_id = port->starget_id; u64 scsi_lun = ZFCP_DBF_INVALID_LUN; @@ -325,18 +331,36 @@ static int zfcp_task_mgmt_function(struct scsi_cmnd *scpnt, u8 tm_flags) static int zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt) { - return zfcp_task_mgmt_function(scpnt, FCP_TMF_LUN_RESET); + struct scsi_device *sdev = scpnt->device; + struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); + struct zfcp_port *port = zfcp_sdev->port; + + return zfcp_task_mgmt_function(port, sdev, FCP_TMF_LUN_RESET); } static int zfcp_scsi_eh_target_reset_handler(struct scsi_cmnd *scpnt) { - return zfcp_task_mgmt_function(scpnt, FCP_TMF_TGT_RESET); + struct scsi_target *starget = scsi_target(scpnt->device); + struct fc_rport *rport = starget_to_rport(starget); + struct zfcp_adapter *adapter = + (struct zfcp_adapter *)rport_to_shost(rport)->hostdata[0]; + struct zfcp_port *port = zfcp_get_port_by_wwpn(adapter, + rport->port_name); + if (!port) { + zfcp_dbf_scsi_devreset("nopt", adapter, FCP_TMF_TGT_RESET, + NULL, port->starget_id, + ZFCP_DBF_INVALID_LUN); + return 0; + } + + return zfcp_task_mgmt_function(port, NULL, FCP_TMF_TGT_RESET); } static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt) { - struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scpnt->device); - struct zfcp_adapter *adapter = zfcp_sdev->port->adapter; + struct Scsi_Host *shost = scpnt->device->host; + struct zfcp_adapter *adapter = + (struct zfcp_adapter *)shost->hostdata[0]; struct zfcp_port *port; int ret = SUCCESS;