Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2827204pxv; Mon, 12 Jul 2021 02:56:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqGhE9wfncrmnIgT4Y3vs650P2Qh2P3+MduNfn5XqkMaLBOTVL3wEFobbcR02nEmtR3NNK X-Received: by 2002:a05:6602:1216:: with SMTP id y22mr6963934iot.22.1626083763849; Mon, 12 Jul 2021 02:56:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626083763; cv=none; d=google.com; s=arc-20160816; b=e/egb3WD/vTgZryboDDu/A2b9lKcE6WXNEfoJsQJldD16wPRQrFf4FLzPnCCuVfsKR JTDWRLrM1gFpcb5nnYqYnRzjENM8L0R88lkKf4OjLhFa3TXwF730U+7Dh0rZfF7LW2K4 K1AlTGXn3XiWHnzapSs1Mis/1I4oFhEFmBTaCzHnoNc4MclnYswukwLUgNbixEKiWEeQ WfXL2N4F6zVZmGDufiq4GPGj3Nk7uG7dj0GSc6wBV8LaYGHprqUxMdrM/dnudjJC+WhO spO08BEFeYahEfenyW5XZyK/UwDEIo0KpUGlxDDofNR4WOs2LGzbEN+RYWal7Qjh0+B7 m4ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=H+0E1SDdvSqbZ9ElB7A7HTC/22NNlB8wPXC+1QCMXFo=; b=xaDogj3lA8H2pbTBg/F4lZjrNcWULJf69V8dZhL/doA7h+Ond07zf8BzlFxiODgR1p bV9NSe0tBekcEWJeZuGhWk0fMIfLHJnWnb6OBWxJkVxgiB10YT4c6s7CohF4C0Tx943w 1BVGzFsYTGquDdav523WZ+2bsZEXRe9iHd0t7WG09bOk4x1dRKgdMO8Z2LQQVGatanqz 9Ch8RJQC61Ig9q7tZG7wR68PJbeJ2YOqQZlQo4oZiJchMJI75qKZSPt7hem0zWeCGBnv nZy9sLL/BD08IM9Dpd1VHusBOaMttb0kuh7Pq9Mp2NxxkCf1jQIHRc3UpheERDXY1j4t e8rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WrR3LkDY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k14si16029079iol.64.2021.07.12.02.55.52; Mon, 12 Jul 2021 02:56:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WrR3LkDY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242081AbhGLG7o (ORCPT + 99 others); Mon, 12 Jul 2021 02:59:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:39704 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238954AbhGLGob (ORCPT ); Mon, 12 Jul 2021 02:44:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5845961008; Mon, 12 Jul 2021 06:40:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626072027; bh=MZzqfv3cG0jwKxocEjfCzBeR/+AZnBvF9fr5yZCQoZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WrR3LkDYM5URW0O+q9tfj6gqDyf9efacARuTq/xXRLBSPgNAxcr/bSzoImOCfuVKU 4SGN1zF4tGpz8PAsbU35Ey7r7keF3T4fdarqitfNNWwzhmrzkxj82o+WzwTtoPQJNS EipH4sJgyPxvzuWyvC9USXbe4w6MQRbGNHpO0tjc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Md Haris Iqbal , Gioh Kim , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.10 322/593] RDMA/rtrs-clt: Check state of the rtrs_clt_sess before reading its stats Date: Mon, 12 Jul 2021 08:08:02 +0200 Message-Id: <20210712060921.052077478@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Md Haris Iqbal [ Upstream commit 41db63a7efe1c8c2dd282c1849a6ebfbbedbaf67 ] When get_next_path_min_inflight is called to select the next path, it iterates over the list of available rtrs_clt_sess (paths). It then reads the number of inflight IOs for that path to select one which has the least inflight IO. But it may so happen that rtrs_clt_sess (path) is no longer in the connected state because closing or error recovery paths can change the status of the rtrs_clt_Sess. For example, the client sent the heart-beat and did not get the response, it would change the session status and stop IO processing. The added checking of this patch can prevent accessing the broken path and generating duplicated error messages. It is ok if the status is changed after checking the status because the error recovery path does not free memory and only tries to reconnection. And also it is ok if the session is closed after checking the status because closing the session changes the session status and flush all IO beforing free memory. If the session is being accessed for IO processing, the closing session will wait. Fixes: 6a98d71daea18 ("RDMA/rtrs: client: main functionality") Link: https://lore.kernel.org/r/20210528113018.52290-13-jinpu.wang@ionos.com Signed-off-by: Md Haris Iqbal Reviewed-by: Gioh Kim Signed-off-by: Gioh Kim Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 7db550ba25d7..7d7dcc0a0458 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -811,6 +811,9 @@ static struct rtrs_clt_sess *get_next_path_min_inflight(struct path_it *it) int inflight; list_for_each_entry_rcu(sess, &clt->paths_list, s.entry) { + if (unlikely(READ_ONCE(sess->state) != RTRS_CLT_CONNECTED)) + continue; + if (unlikely(!list_empty(raw_cpu_ptr(sess->mp_skip_entry)))) continue; -- 2.30.2