From patchwork Wed Nov 22 18:58:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 10070779 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 DBD5C60595 for ; Wed, 22 Nov 2017 18:59:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D04EE29D74 for ; Wed, 22 Nov 2017 18:59:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4FF029D96; Wed, 22 Nov 2017 18:59: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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 8055229D9A for ; Wed, 22 Nov 2017 18:59:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752073AbdKVS7O (ORCPT ); Wed, 22 Nov 2017 13:59:14 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:49079 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752051AbdKVS7N (ORCPT ); Wed, 22 Nov 2017 13:59:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=nyq/tHFl9ggiMasFh3U6dDnQwHgnoWqubWQbnP4sw+k=; b=ZGLLZ0f6o8gDuGOYYsCqxQQNo MkgYoW23QiYU65yiLSubcnKjA5d2alS0kiD1gzDRjVCVxuRJzORcInhoXEd8MqOnGUTQ0DGPtREJ/ 3QKkbdN0jg/RK7iG71lKsfI/rBLkPZu0Q7zdQdg8LjToOPHL37ZJQUbsHXvi4w7RjGxHLf23BcK1Q MB1zzcjFZDV08Bq+L1i6WQwQrvowBXPK6QyCfD9m/yDCEB/s2Kr2ZrvKdcn4KOFOoSn6/JiEHlxe1 HZOfS09mX8uONenovKlE65Oocb5J8S0zyWggr9hXDF0+LjsLoRQZV2b1Y4NgcPf7Th1aBhBMe8DeA b9HO6rXIQ==; Received: from bzq-82-81-101-184.red.bezeqint.net ([82.81.101.184] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1eHaEo-0001dJ-4i; Wed, 22 Nov 2017 18:59:10 +0000 From: Sagi Grimberg To: linux-nvme@lists.infradead.org Cc: linux-rdma@vger.kernel.org, Christoph Hellwig , Max Gurtuvoy Subject: [PATCH v5 4/4] nvme-rdma: Check remotely invalidated rkey matches our expected rkey Date: Wed, 22 Nov 2017 20:58:38 +0200 Message-Id: <20171122185838.28855-5-sagi@grimberg.me> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171122185838.28855-1-sagi@grimberg.me> References: <20171122185838.28855-1-sagi@grimberg.me> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If we got a remote invalidation on a bogus rkey, this is a protocol error. fail if it happened. Signed-off-by: Sagi Grimberg --- drivers/nvme/host/rdma.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index 2ed6fd0d5551..581a85cb5ee7 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -1336,8 +1336,13 @@ static int nvme_rdma_process_nvme_rsp(struct nvme_rdma_queue *queue, req->status = cqe->status; req->result = cqe->result; - if ((wc->wc_flags & IB_WC_WITH_INVALIDATE) && - wc->ex.invalidate_rkey == req->mr->rkey) { + if (wc->wc_flags & IB_WC_WITH_INVALIDATE) { + if (unlikely(wc->ex.invalidate_rkey != req->mr->rkey)) { + dev_err(queue->ctrl->ctrl.device, + "Bogus remote invalidation for rkey %#x\n", + req->mr->rkey); + nvme_rdma_error_recovery(queue->ctrl); + } req->mr->need_inval = false; } else if (req->mr->need_inval) { ret = nvme_rdma_inv_rkey(queue, req);