Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2835427pxv; Mon, 12 Jul 2021 03:07:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4nhaE6MkpPvRB9wqbbvZFwn35KV/hNerOgu0VYBlYHArNccKgIi/iTlwZQCtJNv+kjm9+ X-Received: by 2002:a05:6602:2145:: with SMTP id y5mr11324506ioy.10.1626084458139; Mon, 12 Jul 2021 03:07:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626084458; cv=none; d=google.com; s=arc-20160816; b=wUmqHPgDbTIZyVohG34IwoYMkGbRJXuiEvnDr9eompqV6Kw7AgZWdkfvN60fqFvReM 9a1nE3JnvlOGhVtkAIKW165+EJKtAirfDXB33hWMNqtVBFDeNV1AWiBhAOiKgbuX3UQ4 2pK9d7OJ4+bCLatZ8gd8JW2AR7Hh+3WHxA5MFGoJpJXizcEzSXX5RHBnOW4F2jfwpM8M IQXcdR7Man81KBUyJ/jkF5WW47UZw07p8HoZFNZxE8qPuGsdsA/P+njc2/gRzHrrjrZT 25s3uYCoyvxkHfUGwqMQBKsLYlYL2VUWXbhpaXLR6QHNR7UiLWa41OpZvthjmwtvYLuC Ialw== 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=yCktr6ySimoD2T3RT+nAUwtyY7+vOEHGQeEdgitesn4=; b=jRLz3BJaY6tQMMNBT6kjAjDfoxg/Eoa9P/A+wzEZFDcO3tlHGBWnlLrFwIlieWWMVf f7m3SSJJYeMb/LtaBi3iFmg3iMHiaHDzuJwjmctoGBtEGEr6r9uzwtEmxhuTlshesoNB RLai/Lg5SoU5U8NShXKOefBdV/SyPd6JblMAKGnyLtgkgUhgcrYHHw2SGzOCadnBiXLB kgZHaYyOh8TRBrsAIetZkzUC99lOvqo1qhJ9BNK19a4lqSENNfUiMjQlTCguQ/ViuQtH dXc4a5dGH2YpntpfUSJ9p9bDaMzdq3P8ObGvsvJ7HlSIrxzwt+AFdSd460qzgQpBO89Z YaOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cm8cKMck; 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 n2si18628136jaj.36.2021.07.12.03.07.26; Mon, 12 Jul 2021 03:07:38 -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=cm8cKMck; 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 S1346623AbhGLHsF (ORCPT + 99 others); Mon, 12 Jul 2021 03:48:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:48022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240067AbhGLHOA (ORCPT ); Mon, 12 Jul 2021 03:14:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8CA0D61151; Mon, 12 Jul 2021 07:11:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626073861; bh=ZHPtdMtLw+LRQMoNHxOGGo1Ztxl6VU7JJPy7gPvtOSA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cm8cKMckuf2PgEad02UpJ/gJmRoN6BwxKVHL77AOqk35k0lO/EoA7+6mw9nh2xvl0 GxRLmCr491TFmTsGM8R8PfAs7K3R/YeM+WFYxjFV7ILe8Ojkup2KtdJ2BL3MrCn60L lo50biayHLvs2M7hOulsDr0Y4H/ddXar8hDxx4VU= 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.12 383/700] RDMA/rtrs-clt: Check state of the rtrs_clt_sess before reading its stats Date: Mon, 12 Jul 2021 08:07:46 +0200 Message-Id: <20210712061017.119323222@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@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 959ba0462ef0..cb6f5c7610a0 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -805,6 +805,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