From patchwork Tue Jul 25 14:14:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steffen Maier X-Patchwork-Id: 9862111 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 E1A8D600F5 for ; Tue, 25 Jul 2017 14:15:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4C7427F94 for ; Tue, 25 Jul 2017 14:15:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9A3A285DB; Tue, 25 Jul 2017 14:15:15 +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 6BABB27F94 for ; Tue, 25 Jul 2017 14:15:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752005AbdGYOPM (ORCPT ); Tue, 25 Jul 2017 10:15:12 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57285 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752013AbdGYOPK (ORCPT ); Tue, 25 Jul 2017 10:15:10 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6PEAFaE000636 for ; Tue, 25 Jul 2017 10:15:09 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 2bx3b2mb7r-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 25 Jul 2017 10:15:09 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 25 Jul 2017 15:15:07 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 25 Jul 2017 15:15:05 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6PEF4d153805272; Tue, 25 Jul 2017 14:15:04 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A13F24C04E; Tue, 25 Jul 2017 15:12:37 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 652174C050; Tue, 25 Jul 2017 15:12:37 +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:37 +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 8/9] zfcp: fix waiting for rport(s) unblock in eh_host_reset_handler Date: Tue, 25 Jul 2017 16:14:26 +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-0008-0000-0000-00000483E869 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17072514-0009-0000-0000-00001E110B19 Message-Id: <20170725141427.35258-9-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 v2.6.30 commit 63caf367e1c9 ("[SCSI] zfcp: Improve reliability of SCSI eh handlers in zfcp") added calls to zfcp_erp_wait() within eh_abort_handler(), eh_device_reset_handler(), eh_target_reset_handler() in order to synchronize with zfcp recovery completion before returning from a scsi_eh callback (e.g. with SUCCESS) to prevent eh escalation. v2.6.33 commit af4de36d911a ("[SCSI] zfcp: Block scsi_eh thread for rport state BLOCKED") introduced the use of fc_block_scsi_eh() for eh_abort_handler(), eh_device_reset_handler(), eh_target_reset_handler(), and eh_host_reset_handler(), because zfcp_erp_wait() from above commit is not sufficient. The use in zfcp_task_mgmt_function() is correct even for a LUN reset, as described in commit 6f2ce1c6af37 ("scsi: zfcp: fix rport unblock race with LUN recovery"). However, the one call in zfcp_scsi_eh_host_reset_handler() waiting for just one arbitrary port of the arbitrary scsi_cmnd seems insufficient as the preceding adapter recovery could have recovered multiple ports for which we all should wait to unblock (or have run into FAST_IO_FAIL). Therefore, we now wait for all ports of the adapter with this fix. NB: We cannot easily wait for an event because there is a time window between zfcp_erp_wait() returned and zfcp_erp_try_rport_unblock() as part of zfcp_erp_action_cleanup() actually scheduled rport_work which will unblock an rport in zfcp_scsi_rport_work() asynchronously. Hence a flush_work() could come early before queue_work() was even done. v2.6.35 commit a1dbfddd02d2 ("[SCSI] zfcp: Pass return code from fc_block_scsi_eh to scsi eh") fixed v2.6.33 for the FAST_IO_FAIL case. Signed-off-by: Steffen Maier Fixes: af4de36d911a ("[SCSI] zfcp: Block scsi_eh thread for rport state BLOCKED") Fixes: a1dbfddd02d2 ("[SCSI] zfcp: Pass return code from fc_block_scsi_eh to scsi eh") Reviewed-by: Hannes Reinecke --- drivers/s390/scsi/zfcp_scsi.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index 8e96196fa877..11cf33ea8c14 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c @@ -338,16 +338,29 @@ 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 zfcp_port *port; - int ret; + int ret = SUCCESS; zfcp_erp_adapter_reopen(adapter, 0, "schrh_1"); zfcp_erp_wait(adapter); - port = zfcp_sdev->port; - ret = port->rport ? fc_block_rport(port->rport) : 0; - if (ret) - return ret; + /* after internal recovery, wait for async unblock of rport(s) */ + read_lock(&adapter->port_list_lock); + list_for_each_entry(port, &adapter->port_list, list) { + int fc_ret; + + if (!port->rport) + continue; + + fc_ret = fc_block_rport(port->rport); + /* Any rport ran into fast_io_fail_tmo: FAST_IO_FAIL. + * To let pending requests bubble up, even if too many + * because of other rports without this timeout. + */ + if (fc_ret) + ret = fc_ret; + } + read_unlock(&adapter->port_list_lock); - return SUCCESS; + return ret; } struct scsi_transport_template *zfcp_scsi_transport_template;