All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gioh Kim <gi-oh.kim@ionos.com>
To: linux-rdma@vger.kernel.org
Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com,
	jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com,
	Gioh Kim <gi-oh.kim@cloud.ionos.com>,
	Jack Wang <jinpu.wang@cloud.ionos.com>
Subject: [PATCH for-next 03/22] RDMA/rtrs-clt: Inject a fault at request processing
Date: Thu, 25 Mar 2021 16:32:49 +0100	[thread overview]
Message-ID: <20210325153308.1214057-4-gi-oh.kim@ionos.com> (raw)
In-Reply-To: <20210325153308.1214057-1-gi-oh.kim@ionos.com>

From: Gioh Kim <gi-oh.kim@cloud.ionos.com>

If the fault-injection is enabled, it does not sent a request to the
server and returns error.

Signed-off-by: Gioh Kim <gi-oh.kim@cloud.ionos.com>
Signed-off-by: Jack Wang <jinpu.wang@cloud.ionos.com>
---
 drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c | 44 ++++++++++++++++++++
 drivers/infiniband/ulp/rtrs/rtrs-clt.c       |  7 ++++
 drivers/infiniband/ulp/rtrs/rtrs-clt.h       | 13 ++++++
 3 files changed, 64 insertions(+)

diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c b/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c
index b6a0abf40589..d168bd08037a 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c
@@ -480,3 +480,47 @@ void rtrs_clt_destroy_sysfs_root(struct rtrs_clt *clt)
 		kobject_put(clt->kobj_paths);
 	}
 }
+
+#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
+void rtrs_clt_fault_inject_init(struct rtrs_clt_fault_inject *fault_inject,
+				struct rtrs_clt_sess *sess)
+{
+	char str[NAME_MAX];
+	int cnt;
+
+	cnt = sockaddr_to_str((struct sockaddr *)&sess->s.src_addr,
+			      str, sizeof(str));
+	cnt += scnprintf(str + cnt, sizeof(str) - cnt, "@");
+	sockaddr_to_str((struct sockaddr *)&sess->s.dst_addr,
+			str + cnt, sizeof(str) - cnt);
+
+	rtrs_fault_inject_init(&fault_inject->fj, str, -EBUSY);
+	/* injection points */
+	rtrs_fault_inject_add(fault_inject->fj.dir,
+			      "fail-request", &fault_inject->fail_request);
+}
+
+void rtrs_clt_fault_inject_final(struct rtrs_clt_fault_inject *fault_inject)
+{
+	rtrs_fault_inject_final(&fault_inject->fj);
+}
+
+int rtrs_clt_should_fail_request(struct rtrs_clt_fault_inject *fault_inject)
+{
+	if (fault_inject->fail_request && should_fail(&fault_inject->fj.attr, 1))
+		return fault_inject->fj.status;
+	return 0;
+}
+#else
+void rtrs_clt_fault_inject_init(struct rtrs_clt_fault_inject *fault_inject,
+				struct rtrs_clt_sess *sess)
+{
+}
+void rtrs_clt_fault_inject_final(struct rtrs_clt_fault_inject *fault_inject)
+{
+}
+int rtrs_clt_should_fail_request(struct rtrs_clt_fault_inject *fault_inject)
+{
+	return 0;
+}
+#endif
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
index f95955fc2992..4f7690137e42 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -1472,6 +1472,7 @@ static struct rtrs_clt_sess *alloc_sess(struct rtrs_clt *clt,
 
 void free_sess(struct rtrs_clt_sess *sess)
 {
+	rtrs_clt_fault_inject_final(&sess->fault_inject);
 	free_percpu(sess->mp_skip_entry);
 	mutex_destroy(&sess->init_mutex);
 	kfree(sess->s.con);
@@ -2689,6 +2690,8 @@ struct rtrs_clt *rtrs_clt_open(struct rtrs_clt_ops *ops,
 			free_sess(sess);
 			goto close_all_sess;
 		}
+
+		rtrs_clt_fault_inject_init(&sess->fault_inject, sess);
 	}
 	err = alloc_permits(clt);
 	if (err)
@@ -2861,6 +2864,10 @@ int rtrs_clt_request(int dir, struct rtrs_clt_req_ops *ops,
 		if (unlikely(READ_ONCE(sess->state) != RTRS_CLT_CONNECTED))
 			continue;
 
+		err = rtrs_clt_should_fail_request(&sess->fault_inject);
+		if (unlikely(err))
+			continue;
+
 		if (unlikely(usr_len + hdr_len > sess->max_hdr_size)) {
 			rtrs_wrn_rl(sess->clt,
 				     "%s request failed, user message size is %zu and header length %zu, but max size is %u\n",
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.h b/drivers/infiniband/ulp/rtrs/rtrs-clt.h
index 692bc83e1f09..59ea2ec44fe5 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.h
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.h
@@ -12,6 +12,7 @@
 
 #include <linux/device.h>
 #include "rtrs-pri.h"
+#include "rtrs-fault.h"
 
 /**
  * enum rtrs_clt_state - Client states.
@@ -122,6 +123,13 @@ struct rtrs_rbuf {
 	u32 rkey;
 };
 
+struct rtrs_clt_fault_inject {
+#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
+	struct rtrs_fault_inject fj;
+	bool fail_request;
+#endif
+};
+
 struct rtrs_clt_sess {
 	struct rtrs_sess	s;
 	struct rtrs_clt	*clt;
@@ -150,6 +158,7 @@ struct rtrs_clt_sess {
 	char                    hca_name[IB_DEVICE_NAME_MAX];
 	struct list_head __percpu
 				*mp_skip_entry;
+	struct rtrs_clt_fault_inject	fault_inject;
 };
 
 struct rtrs_clt {
@@ -250,4 +259,8 @@ int rtrs_clt_create_sess_files(struct rtrs_clt_sess *sess);
 void rtrs_clt_destroy_sess_files(struct rtrs_clt_sess *sess,
 				  const struct attribute *sysfs_self);
 
+void rtrs_clt_fault_inject_init(struct rtrs_clt_fault_inject *fault_inject,
+				struct rtrs_clt_sess *sess);
+void rtrs_clt_fault_inject_final(struct rtrs_clt_fault_inject *fault_inject);
+int rtrs_clt_should_fail_request(struct rtrs_clt_fault_inject *fault_inject);
 #endif /* RTRS_CLT_H */
-- 
2.25.1


  parent reply	other threads:[~2021-03-25 15:34 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-25 15:32 [PATCH for-next 00/22] Misc update for rtrs Gioh Kim
2021-03-25 15:32 ` [PATCH for-next 01/22] MAINTAINERS: Change maintainer for rtrs module Gioh Kim
2021-03-25 15:32 ` [PATCH for-next 02/22] RDMA/rtrs: Enable the fault-injection Gioh Kim
2021-03-25 15:32 ` Gioh Kim [this message]
2021-03-25 15:32 ` [PATCH for-next 04/22] RDMA/rtrs-srv: Inject a fault at heart-beat sending Gioh Kim
2021-03-25 15:32 ` [PATCH for-next 05/22] docs: fault-injection: Add fault-injection manual of RTRS Gioh Kim
2021-04-01 18:37   ` Jason Gunthorpe
2021-04-01 19:06     ` Gioh Kim
2021-03-25 15:32 ` [PATCH for-next 06/22] RDMA/rtrs-clt: Break if one sess is connected in rtrs_clt_is_connected Gioh Kim
2021-04-01 18:38   ` Jason Gunthorpe
2021-04-06 10:23     ` Gioh Kim
2021-04-06 12:51       ` Jason Gunthorpe
2021-04-06 12:53         ` Gioh Kim
2021-04-06 12:59           ` Gioh Kim
2021-03-25 15:32 ` [PATCH for-next 07/22] RDMA/rtrs-clt: Remove redundant code from rtrs_clt_read_req Gioh Kim
2021-03-25 15:32 ` [PATCH for-next 08/22] RDMA/rtrs: Kill the put label in rtrs_srv_create_once_sysfs_root_folders Gioh Kim
2021-03-25 15:32 ` [PATCH for-next 09/22] RDMA/rtrs: Remove sessname and sess_kobj from rtrs_attrs Gioh Kim
2021-03-25 15:32 ` [PATCH for-next 10/22] RDMA/rtrs: Cleanup the code in rtrs_srv_rdma_cm_handler Gioh Kim
2021-03-25 15:32 ` [PATCH for-next 11/22] RDMA/rtrs-clt: Close rtrs client conn before destroying rtrs clt session files Gioh Kim
2021-03-25 15:32 ` [PATCH for-next 12/22] RDMA/rtrs-clt: Check state of the rtrs_clt_sess before reading its stats Gioh Kim
2021-04-01 18:44   ` Jason Gunthorpe
2021-04-06  8:55     ` Gioh Kim
2021-04-08 12:04       ` Jason Gunthorpe
2021-04-08 12:08         ` Gioh Kim
2021-04-08 13:45         ` Jinpu Wang
2021-04-08 13:50           ` Jason Gunthorpe
2021-04-08 14:44             ` Gioh Kim
2021-04-08 14:51               ` Jason Gunthorpe
2021-04-12  8:41                 ` Gioh Kim
2021-03-25 15:32 ` [PATCH for-next 13/22] RDMA/rtrs: New function converting rtrs_addr to string Gioh Kim
2021-03-25 15:33 ` [PATCH for-next 14/22] RDMA/rtrs-clt: Print more info when an error happens Gioh Kim
2021-04-01 18:46   ` Jason Gunthorpe
2021-04-01 19:09     ` Gioh Kim
2021-03-25 15:33 ` [PATCH for-next 15/22] RDMA/rtrs-srv: More debugging info when fail to send reply Gioh Kim
2021-03-25 15:33 ` [PATCH for-next 16/22] RDMA/rtrs-srv: Report temporary sessname for error message Gioh Kim
2021-03-25 15:33 ` [PATCH for-next 17/22] RDMA/rtrs: cleanup unused variable Gioh Kim
2021-04-01 18:50   ` Jason Gunthorpe
2021-03-25 15:33 ` [PATCH for-next 18/22] RDMA/rtrs-clt: Simplify error message Gioh Kim
2021-03-25 15:33 ` [PATCH for-next 19/22] RDMA/rtrs-clt: Cap max_io_size Gioh Kim
2021-03-25 15:33 ` [PATCH for-next 20/22] RDMA/rtrs-clt: Add a minimum latency multipath policy Gioh Kim
2021-03-25 15:33 ` [PATCH for-next 21/22] RDMA/rtrs-clt: new sysfs attribute to print the latency of each path Gioh Kim
2021-03-25 15:33 ` [PATCH for-next 22/22] Documentation/ABI/rtrs-clt: Add descriptions for min-latency policy Gioh Kim
2021-04-01 19:04 ` [PATCH for-next 00/22] Misc update for rtrs Jason Gunthorpe
2021-04-06  9:04   ` Gioh Kim

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=20210325153308.1214057-4-gi-oh.kim@ionos.com \
    --to=gi-oh.kim@ionos.com \
    --cc=bvanassche@acm.org \
    --cc=dledford@redhat.com \
    --cc=gi-oh.kim@cloud.ionos.com \
    --cc=haris.iqbal@ionos.com \
    --cc=jgg@ziepe.ca \
    --cc=jinpu.wang@cloud.ionos.com \
    --cc=jinpu.wang@ionos.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.