Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3001827imm; Sun, 1 Jul 2018 10:04:08 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdJADbhLVMxuNYI3DS6UPZO+3qERDsOHzQR77Bra0qv7ekCzV9N3Uh85La+Me8uj5GilbUp X-Received: by 2002:a17:902:7407:: with SMTP id g7-v6mr15416228pll.85.1530464648866; Sun, 01 Jul 2018 10:04:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530464648; cv=none; d=google.com; s=arc-20160816; b=T+D8P7fGU/JPXBZo+RzG9SkbgCBM3FLAPJbKtUf49v+FLZpTz37DyKXpiMRXZxdaDJ IynLHjY3DAlBTjceQ6t00a8ngF6/sznoj4tbgYHn0aLdIdEKPpdHHN3hcJGZDu3NOnxl ixwXRFZ9bV1vdAKAP6TIOOxWGmVGJIYG6eO4RM4TPlcevBxpAudZpSkNuN92col/a2Cw mflq6WolfZqCO9/cnbM3IIjRWWYvcBpZ09mzvnC4qrtbZoJmuH1Xtqy9SCV/j8/fhgR2 fgdKIf0UyQibCTuDmqZUsw4inQCmWXt+1yRlQaMJd68OauybJBM2fs25+vAE98CKkHlG yZ4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=fsOh1T9zfu+D/H9taeLGut67SyCt5xHfnDPGbXXM6gc=; b=Tqshh3cmcq5kc+nkV6madJ5jKJ5tISn0TSvKYok8znUkfCe0RmYwWEQchSI15a2i5z 2cU9a6t1SfkP6xkVLwVdk/JSfHabfSJO+AoOkDwgzG/2DzOPhvsc2YD+K+uL1MEjmwDF 5EKcald4EDiICOwD1idaaKH5RxRBzmKX6/naJxiK5rvb3cCe5owf1KMBWcZ01ON/8mJ0 ZbrlnHIK4M6ezGysBGmgpdM1bMYzcuFXIwujJgj/QggY6lKbUgOp+uF5CWNGyjQuu7hs Mlz6FLu/j2pL5HzSTFbSVbmvnGTzJ/L2FROHh1zRHjwF0FD6ASJk6n64015Gy8dS4fw4 I5hA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a95-v6si14162732pla.401.2018.07.01.10.03.54; Sun, 01 Jul 2018 10:04:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753901AbeGARDF (ORCPT + 99 others); Sun, 1 Jul 2018 13:03:05 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37760 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032296AbeGAQnF (ORCPT ); Sun, 1 Jul 2018 12:43:05 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6ED81A73; Sun, 1 Jul 2018 16:43:04 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steffen Maier , Benjamin Block , "Martin K. Petersen" Subject: [PATCH 4.17 141/220] scsi: zfcp: fix missing REC trigger trace on terminate_rport_io early return Date: Sun, 1 Jul 2018 18:22:45 +0200 Message-Id: <20180701160914.201960002@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Steffen Maier commit 96d9270499471545048ed8a6d7f425a49762283d upstream. get_device() and its internally used kobject_get() only return NULL if they get passed NULL as argument. zfcp_get_port_by_wwpn() loops over adapter->port_list so the iteration variable port is always non-NULL. Struct device is embedded in struct zfcp_port so &port->dev is always non-NULL. This is the argument to get_device(). However, if we get an fc_rport in terminate_rport_io() for which we cannot find a match within zfcp_get_port_by_wwpn(), the latter can return NULL. v2.6.30 commit 70932935b61e ("[SCSI] zfcp: Fix oops when port disappears") introduced an early return without adding a trace record for this case. Even if we don't need recovery in this case, for debugging we should still see that our callback was invoked originally by scsi_transport_fc. Example trace record formatted with zfcpdbf from s390-tools: Timestamp : ... Area : REC Subarea : 00 Level : 1 Exception : - CPU ID : .. Caller : 0x... Record ID : 1 Tag : sctrpin SCSI terminate rport I/O, no zfcp port LUN : 0xffffffffffffffff none (invalid) WWPN : 0x WWPN D_ID : 0x N_Port-ID Adapter status : 0x... Port status : 0xffffffff unknown (-1) LUN status : 0x00000000 none (invalid) Ready count : 0x... Running count : 0x... ERP want : 0x03 ZFCP_ERP_ACTION_REOPEN_PORT_FORCED ERP need : 0xc0 ZFCP_ERP_ACTION_NONE Signed-off-by: Steffen Maier Fixes: 70932935b61e ("[SCSI] zfcp: Fix oops when port disappears") Cc: #2.6.38+ Reviewed-by: Benjamin Block Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/s390/scsi/zfcp_erp.c | 20 ++++++++++++++++++++ drivers/s390/scsi/zfcp_ext.h | 3 +++ drivers/s390/scsi/zfcp_scsi.c | 5 +++++ 3 files changed, 28 insertions(+) --- a/drivers/s390/scsi/zfcp_erp.c +++ b/drivers/s390/scsi/zfcp_erp.c @@ -283,6 +283,26 @@ static int zfcp_erp_action_enqueue(int w return retval; } +void zfcp_erp_port_forced_no_port_dbf(char *id, struct zfcp_adapter *adapter, + u64 port_name, u32 port_id) +{ + unsigned long flags; + static /* don't waste stack */ struct zfcp_port tmpport; + + write_lock_irqsave(&adapter->erp_lock, flags); + /* Stand-in zfcp port with fields just good enough for + * zfcp_dbf_rec_trig() and zfcp_dbf_set_common(). + * Under lock because tmpport is static. + */ + atomic_set(&tmpport.status, -1); /* unknown */ + tmpport.wwpn = port_name; + tmpport.d_id = port_id; + zfcp_dbf_rec_trig(id, adapter, &tmpport, NULL, + ZFCP_ERP_ACTION_REOPEN_PORT_FORCED, + ZFCP_ERP_ACTION_NONE); + write_unlock_irqrestore(&adapter->erp_lock, flags); +} + static int _zfcp_erp_adapter_reopen(struct zfcp_adapter *adapter, int clear_mask, char *id) { --- a/drivers/s390/scsi/zfcp_ext.h +++ b/drivers/s390/scsi/zfcp_ext.h @@ -58,6 +58,9 @@ extern void zfcp_dbf_scsi_eh(char *tag, /* zfcp_erp.c */ extern void zfcp_erp_set_adapter_status(struct zfcp_adapter *, u32); extern void zfcp_erp_clear_adapter_status(struct zfcp_adapter *, u32); +extern void zfcp_erp_port_forced_no_port_dbf(char *id, + struct zfcp_adapter *adapter, + u64 port_name, u32 port_id); extern void zfcp_erp_adapter_reopen(struct zfcp_adapter *, int, char *); extern void zfcp_erp_adapter_shutdown(struct zfcp_adapter *, int, char *); extern void zfcp_erp_set_port_status(struct zfcp_port *, u32); --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c @@ -605,6 +605,11 @@ static void zfcp_scsi_terminate_rport_io if (port) { zfcp_erp_port_forced_reopen(port, 0, "sctrpi1"); put_device(&port->dev); + } else { + zfcp_erp_port_forced_no_port_dbf( + "sctrpin", adapter, + rport->port_name /* zfcp_scsi_rport_register */, + rport->port_id /* zfcp_scsi_rport_register */); } }