diff mbox series

[for-next,01/10] RDMA/rtrs-clt: During add_path change for_new_clt according to path_num

Message ID 20210730131832.118865-2-jinpu.wang@ionos.com (mailing list archive)
State Changes Requested
Headers show
Series Misc update for RTRS | expand

Commit Message

Jinpu Wang July 30, 2021, 1:18 p.m. UTC
From: Md Haris Iqbal <haris.iqbal@ionos.com>

When all the paths are removed for a session, the addition of the first
path is like a new session for the storage server.

Hence, for_new_clt has to be set to 1.

Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
---
 drivers/infiniband/ulp/rtrs/rtrs-clt.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Leon Romanovsky Aug. 2, 2021, 6:40 a.m. UTC | #1
On Fri, Jul 30, 2021 at 03:18:23PM +0200, Jack Wang wrote:
> From: Md Haris Iqbal <haris.iqbal@ionos.com>
> 
> When all the paths are removed for a session, the addition of the first
> path is like a new session for the storage server.
> 
> Hence, for_new_clt has to be set to 1.
> 
> Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
> Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
> ---
>  drivers/infiniband/ulp/rtrs/rtrs-clt.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> index ece3205531b8..e048bfa12755 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> @@ -3083,6 +3083,15 @@ int rtrs_clt_create_path_from_sysfs(struct rtrs_clt *clt,
>  	if (IS_ERR(sess))
>  		return PTR_ERR(sess);
>  
> +	if (clt->paths_num == 0) {

Don't you need some protection to read paths_num?
rcu_read_lock() or mutex_lock?

Thanks
Haris Iqbal Aug. 2, 2021, 2:17 p.m. UTC | #2
On Mon, Aug 2, 2021 at 8:40 AM Leon Romanovsky <leon@kernel.org> wrote:
>
> On Fri, Jul 30, 2021 at 03:18:23PM +0200, Jack Wang wrote:
> > From: Md Haris Iqbal <haris.iqbal@ionos.com>
> >
> > When all the paths are removed for a session, the addition of the first
> > path is like a new session for the storage server.
> >
> > Hence, for_new_clt has to be set to 1.
> >
> > Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
> > Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
> > ---
> >  drivers/infiniband/ulp/rtrs/rtrs-clt.c | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> >
> > diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> > index ece3205531b8..e048bfa12755 100644
> > --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> > +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> > @@ -3083,6 +3083,15 @@ int rtrs_clt_create_path_from_sysfs(struct rtrs_clt *clt,
> >       if (IS_ERR(sess))
> >               return PTR_ERR(sess);
> >
> > +     if (clt->paths_num == 0) {
>
> Don't you need some protection to read paths_num?
> rcu_read_lock() or mutex_lock?

Good catch. The lock should be added.

Thanks

>
> Thanks
diff mbox series

Patch

diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
index ece3205531b8..e048bfa12755 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -3083,6 +3083,15 @@  int rtrs_clt_create_path_from_sysfs(struct rtrs_clt *clt,
 	if (IS_ERR(sess))
 		return PTR_ERR(sess);
 
+	if (clt->paths_num == 0) {
+		/*
+		 * When all the paths are removed for a session,
+		 * the addition of the first path is like a new session for
+		 * the storage server
+		 */
+		sess->for_new_clt = 1;
+	}
+
 	/*
 	 * It is totally safe to add path in CONNECTING state: coming
 	 * IO will never grab it.  Also it is very important to add