Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Md Haris Iqbal <haris.iqbal@ionos.com>
To: linux-rdma@vger.kernel.org
Cc: bvanassche@acm.org, leon@kernel.org, jgg@ziepe.ca,
	haris.iqbal@ionos.com, jinpu.wang@ionos.com,
	Santosh Kumar Pradhan <santosh.pradhan@ionos.com>,
	Grzegorz Prajsner <grzegorz.prajsner@ionos.com>
Subject: [PATCH for-next 6/9] RDMA/rtrs-srv: Destroy path files after making sure no IOs in-flight
Date: Wed, 15 Nov 2023 16:27:46 +0100	[thread overview]
Message-ID: <20231115152749.424301-7-haris.iqbal@ionos.com> (raw)
In-Reply-To: <20231115152749.424301-1-haris.iqbal@ionos.com>

Destroying path files may lead to the freeing of rdma_stats. This creates
the following race.

An IO is in-flight, or has just passed the session state check in
process_read/process_write. The close_work gets triggered and the function
rtrs_srv_close_work() starts and does destroy path which frees the
rdma_stats. After this the function process_read/process_write resumes and
tries to update the stats through the function rtrs_srv_update_rdma_stats

This commit solves the problem by moving the destroy path function to a
later point. This point makes sure any inflights are completed. This is
done by qp drain, and waiting for all in-flights through ops_id.

Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
Signed-off-by: Santosh Kumar Pradhan <santosh.pradhan@ionos.com>
Signed-off-by: Grzegorz Prajsner <grzegorz.prajsner@ionos.com>
---
 drivers/infiniband/ulp/rtrs/rtrs-srv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c
index 925b71481c62..1d33efb8fb03 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c
@@ -1532,7 +1532,6 @@ static void rtrs_srv_close_work(struct work_struct *work)
 
 	srv_path = container_of(work, typeof(*srv_path), close_work);
 
-	rtrs_srv_destroy_path_files(srv_path);
 	rtrs_srv_stop_hb(srv_path);
 
 	for (i = 0; i < srv_path->s.con_num; i++) {
@@ -1552,6 +1551,8 @@ static void rtrs_srv_close_work(struct work_struct *work)
 	/* Wait for all completion */
 	wait_for_completion(&srv_path->complete_done);
 
+	rtrs_srv_destroy_path_files(srv_path);
+
 	/* Notify upper layer if we are the last path */
 	rtrs_srv_path_down(srv_path);
 
-- 
2.25.1


  parent reply	other threads:[~2023-11-15 15:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-15 15:27 [PATCH for-next 0/9] Misc patches for RTRS Md Haris Iqbal
2023-11-15 15:27 ` [PATCH for-next 1/9] RDMA/rtrs-clt: Add warning logs for RDMA events Md Haris Iqbal
2023-11-15 15:27 ` [PATCH for-next 2/9] RDMA/rtrs-srv: Do not unconditionally enable irq Md Haris Iqbal
2023-11-15 15:27 ` [PATCH for-next 3/9] RDMA/rtrs-clt: Start hb after path_up Md Haris Iqbal
2023-11-15 15:27 ` [PATCH for-next 4/9] RDMA/rtrs-srv: Check return values while processing info request Md Haris Iqbal
2023-11-15 15:27 ` [PATCH for-next 5/9] RDMA/rtrs-srv: Free srv_mr iu only when always_invalidate is true Md Haris Iqbal
2023-11-15 15:27 ` Md Haris Iqbal [this message]
2023-11-15 15:27 ` [PATCH for-next 7/9] RDMA/rtrs-clt: Fix the max_send_wr setting Md Haris Iqbal
2023-11-15 15:27 ` [PATCH for-next 8/9] RDMA/rtrs-clt: Remove the warnings for req in_use check Md Haris Iqbal
2023-11-15 15:27 ` [PATCH for-next 9/9] RDMA/rtrs: use %pe to print errors Md Haris Iqbal
2023-11-19 13:00 ` [PATCH for-next 0/9] Misc patches for RTRS Leon Romanovsky
2023-11-20 12:10   ` Haris Iqbal
2023-11-19 13:01 ` (subset) " Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231115152749.424301-7-haris.iqbal@ionos.com \
    --to=haris.iqbal@ionos.com \
    --cc=bvanassche@acm.org \
    --cc=grzegorz.prajsner@ionos.com \
    --cc=jgg@ziepe.ca \
    --cc=jinpu.wang@ionos.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=santosh.pradhan@ionos.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox