Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2254720imm; Mon, 28 May 2018 04:52:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpPFU5N2bSgE8tFdDMCQoZBJnaauXolOF5VNwftGRhtD5DoPaG5zm0AzP/zmH+xa7CbwNUK X-Received: by 2002:a63:6e88:: with SMTP id j130-v6mr10225132pgc.200.1527508344875; Mon, 28 May 2018 04:52:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527508344; cv=none; d=google.com; s=arc-20160816; b=qj8rNMsOyS2FUkkibz5dbz/zU9bFfhFzspOxCGa3r7V+OFI+8Crjs16/vNl5LDTY5w rs8TRBjQoXq4QHXe8vzuj6B5cxq91WFqXt3xt7EomZfHgWePGMAKTP9ysz7QNB+UciLE wCc6c6wFiaNLMN+lonjI/gCRWElC0LLl2L9CUsZaicaPiLvQyNx82C+V1pZj1JMuSPY0 jGc2DYQvAOQdVgW2p5/lz27mg8RgDn0NJZF7tACJKZnVDIytkLAHTTKcS3D7k1Lqsx4s EI6X9UiAuExunojTRUTfgWubRWl8kN8HtA3YvqM5h0iPNJqjyDvrKs02MzqqfPmo13eR dNuw== 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:dkim-signature :arc-authentication-results; bh=MY3FZjYyNINuKPtBohiTsU1LqnhqPVaBCSNwJ3IijP0=; b=k3T3LphchEXZCZkYWuveNSfiw3fl9uzr23F1ipgC+VMljsh9TjG5cdxq7BEXghTpeh kqCuT1JsKO6f6nTDdIkwJ+dCRdh3tHO1VedYCZYLUr2rpeWaWKguOP+d/nxidA/Qp1LP kGUy9/prTwJ++o/YsFIVJtHRd05JFLGU8PkaAvkVbk1qp7ng8AgaJSi0JdvH3hqvS8XE HwHUuUak2OF2w69EQzxld00Ovc8j4nSSkIl5Jv7SEFqfv+U0OU5q6l/2Sawv7M+iXnH9 OSi7V2s8GSKg2asz7xdgW9+rW31GKuEGH9Y2i8qtw4plNQnbtBsVs+8zBoAhn43KfCHE T8bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=d9A0zPVe; 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 j15-v6si7517505pga.252.2018.05.28.04.51.40; Mon, 28 May 2018 04:52:24 -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; dkim=pass header.i=@kernel.org header.s=default header.b=d9A0zPVe; 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 S1423815AbeE1LJs (ORCPT + 99 others); Mon, 28 May 2018 07:09:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:57710 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423301AbeE1LJm (ORCPT ); Mon, 28 May 2018 07:09:42 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D045920845; Mon, 28 May 2018 11:09:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505782; bh=J07uXo7PcVtL2uCykxKSd5+sVvfBMUGLMy3VYwlurmg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d9A0zPVeaGOhx5IFUGzeZNrepfTHM0/c1iGlj/eTEo7qJsEPw1/jhpevf3NfEkRFk LNgYptMwMoTYv6A01DPyvRRRrR2N37wK+/0Nb+QKWYTKHJKKhgmTm7ulkCxU+zsmX6 NKxg2C80ZOqRdWEolp2JjfD0o1Lr/3k8qw6gpiJg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Smart , Sagi Grimberg , Keith Busch , Jens Axboe , Sasha Levin Subject: [PATCH 4.16 127/272] nvme_fc: fix abort race on teardown with lld reject Date: Mon, 28 May 2018 12:02:40 +0200 Message-Id: <20180528100251.791786807@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100240.256525891@linuxfoundation.org> References: <20180528100240.256525891@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.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: James Smart [ Upstream commit b12740d316fa89f3f6191b71f986cf3b9383d379 ] Another abort race: An io request is started, becomes active, and is attempted to be started with the lldd. At the same time the controller is stopped/torndown and an itterator is run to abort the ios. As the io is active, it is added to the outstanding aborted io count. However on the original io request thread, the driver ends up rejecting the io due to the condition that induced the controller teardown. The driver reject path didn't check whether it was in the outstanding io count. This left the count outstanding stopping controller teardown. Correct by, in the driver reject case, setting the state to inactive and checking whether it was in the outstanding io count. Signed-off-by: James Smart Reviewed-by: Sagi Grimberg Signed-off-by: Keith Busch Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/host/fc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -2191,7 +2191,7 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl struct nvme_fc_cmd_iu *cmdiu = &op->cmd_iu; struct nvme_command *sqe = &cmdiu->sqe; u32 csn; - int ret; + int ret, opstate; /* * before attempting to send the io, check to see if we believe @@ -2269,6 +2269,9 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl queue->lldd_handle, &op->fcp_req); if (ret) { + opstate = atomic_xchg(&op->state, FCPOP_STATE_COMPLETE); + __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); + if (!(op->flags & FCOP_FLAGS_AEN)) nvme_fc_unmap_data(ctrl, op->rq, op);