Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3311229imu; Sun, 11 Nov 2018 12:07:25 -0800 (PST) X-Google-Smtp-Source: AJdET5f/To1pGF42zkF7wXfjQx2BE7jVkqA6qfp5TxHoiRmlyXN4R3k2isuhdqTTbLgL4WvzenmN X-Received: by 2002:a17:902:244:: with SMTP id 62-v6mr17582996plc.280.1541966845244; Sun, 11 Nov 2018 12:07:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541966845; cv=none; d=google.com; s=arc-20160816; b=1GW5rLQz8ktNu9gxZIr/6cS8wByP6gYZpm8okafPWeowl/xaJtTuq90VKLkeBG8pYM /AS6h5A2Vf2sHDnsQ5y8k5KbhH0T6onLTU5h6Kwf0Kgo49+8GXq0nh4D3hDP/Vt0XWvu TRdC77JaN42hVNtjlPZrWcZWxYfSQ5Yz0iqNLxucbDIhd6fW1Ua/G68mYCZwACQJDhxc 1ttpK9LyViEGzc0gCv3b/W12JZ9pC+YCxp1o+nSQOG24c4AtUJlpJOAgGAO6+IbwV4gN bELfYolmuPk9TRXVSrIH9UYVdMPu0LpY8Db4LnR90Gn3jsvdRVBf30S76dyus3lP5N8E tt/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=MI55n73oN4Z9ruQ0KJXj41qmGYPy/CsPUlS1rxyWf8Y=; b=JSnwDnu7Nud2SGFKF+vBwQQ4ejq/6xgbEEXnfZddQaVEqlBy8Ph10REtxUDB+83N/9 ijRtw3sT4s6GSsMLlGrVC5e71GlwHi/5okJqHe4wiZ3KoMZzzM8StZTFsPZe5OTIoM+4 T4Lvt4xy7cBG0rUaDVNQGNF+nByrPscrq6QRDUkDdw3pdtM6AbEETTLJTD48TKrriWnj E/3kxMvNeKBzsHVHy1TsWjLITNqeXrbeeukfPKuzEX9rA6B3c9Ev5cAyA4Ii5eYpGG2k BHa+gwlKk4zONUiFQvU1tnv2/r0rHnODkMQEi4cZCSE69iQEte/4r1xHjY4BVGZP/gks C56g== 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 f184-v6si723294pfc.224.2018.11.11.12.07.10; Sun, 11 Nov 2018 12:07:25 -0800 (PST) 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 S1730954AbeKLF4T (ORCPT + 99 others); Mon, 12 Nov 2018 00:56:19 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:52036 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727449AbeKLF4T (ORCPT ); Mon, 12 Nov 2018 00:56:19 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvt9-0000oM-96; Sun, 11 Nov 2018 19:59:19 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsP-0001R6-EM; Sun, 11 Nov 2018 19:58:33 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Benjamin Block" , "Steffen Maier" , "Martin K. Petersen" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 063/366] scsi: zfcp: fix missing REC trigger trace on terminate_rport_io early return In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 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") Reviewed-by: Benjamin Block Signed-off-by: Martin K. Petersen Signed-off-by: Ben Hutchings --- 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 @@ -282,6 +282,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 @@ -624,6 +624,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 */); } }