Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2863915pxv; Mon, 12 Jul 2021 03:54:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsBd3Trzd4+ZqF+bpToEXE/7jTvCkcBSK+JF2/3lPUXiLiAuYku39uOWMXKTHDR5mQxi4F X-Received: by 2002:a92:2a05:: with SMTP id r5mr34926732ile.69.1626087266623; Mon, 12 Jul 2021 03:54:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626087266; cv=none; d=google.com; s=arc-20160816; b=dNs46bjyaXdUfu5lpASzzDMwk9WS9BfYiHbVHCkK9AJO85/cdsLFuWhryoahR7h3ZO HfLycvjqOpLRo4Lh0eMKxKkNTGFOCbS2fM+qvvODM1WoEXv6UjzBcjIRXOxtA4aT10Vn QENdnR6C2qNCXT+ZLMXZqlbmaa6IRJgLCpCgaCITQtcuzFmpu0acUsh0JpDgvM39Yhti okBrMYVeNLQzz1YXy16F22WlYzx6HAxWm3C8Wcqj/LpxYKKUE9vOxHJlpBNvXNLU32PG gZii0eH1YThjqosV18+28SOGTb1ksyWx0Ebl7nUQfN/HGQjFscV530qM1kqvc+EPNCQo qu0w== 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=MFh4Pl6fYWO7yuj3E4/4Xz9sdSF0CcJ/ftXwZDkeeYk=; b=w800LSNtbpqU4g9B8GaNBcJeqXky52SywM38eLtxeRD0VbI+Gz0yTodKBax2xBdlui xMMS9uTAYuyzwyn1s2cl66EluczSly0PVAn2ilpf6+clXciXTl97xsjsxcXr5xBGiNFP wZ4DGCN1bjJ32zENVw9ylJQP/oNJWHSv7gufswwkv/Zw7duPyop7KeqCe59/ziWR5JxH wqH6i00wA/IwSPk7olXiLlPBHz3ONjwU4XkS3AKvZiR+gSmGVHkCAjPvNXciwhcX6+// FFyVHPQLmD8il9PdYC4fg41zgYqdg28esuJmWx/8NlH4qHZUPATFVa8VaPG3ELB4bxEL uHIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kyHU27gO; 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 x14si18337177jat.20.2021.07.12.03.54.15; Mon, 12 Jul 2021 03:54:26 -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=kyHU27gO; 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 S1350548AbhGLImc (ORCPT + 99 others); Mon, 12 Jul 2021 04:42:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:37894 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350647AbhGLHvM (ORCPT ); Mon, 12 Jul 2021 03:51:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A2F4161C31; Mon, 12 Jul 2021 07:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626076025; bh=RzlQ6reBUB4IWa8Kauy0MswGDKw9aaN/XJLSrh7/6dw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kyHU27gOq27/GeRdtC+JIzCEf6Ul3MSAz40eFbKeOe/xsZ59/MF+kLRkdUvEr+e6n Iz+p45uAEreWmAOVKpmJrYqcQiOrSaI/U/OHRwscvuprlSjigt8toJb9X+zd/3Nj54 30RZe1cLwoAxB0d/zUVU7qAYLhrqQc1ntUbPc25k= 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.13 429/800] RDMA/rtrs-clt: Check state of the rtrs_clt_sess before reading its stats Date: Mon, 12 Jul 2021 08:07:32 +0200 Message-Id: <20210712061012.735221061@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060912.995381202@linuxfoundation.org> References: <20210712060912.995381202@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 0a794d748a7a..a563c9b9d52c 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -814,6 +814,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