linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-next 0/2] Misc RNBD update
@ 2022-07-07 14:31 Md Haris Iqbal
  2022-07-07 14:31 ` [PATCH for-next 1/2] block/rnbd-srv: Set keep_id to true after mutex_trylock Md Haris Iqbal
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Md Haris Iqbal @ 2022-07-07 14:31 UTC (permalink / raw)
  To: linux-block; +Cc: axboe, hch, sagi, bvanassche, haris.iqbal, jinpu.wang

Hi Jens,

Please consider to include following change for next merge window.
 - Fixes a minor bug
 - Removes a list, and replaces its use with an existing xarray

Md Haris Iqbal (2):
  block/rnbd-srv: Set keep_id to true after mutex_trylock
  block/rnbd-srv: Replace sess_dev_list with index_idr

 drivers/block/rnbd/rnbd-srv.c | 20 +++++++++-----------
 drivers/block/rnbd/rnbd-srv.h |  4 ----
 2 files changed, 9 insertions(+), 15 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH for-next 1/2] block/rnbd-srv: Set keep_id to true after mutex_trylock
  2022-07-07 14:31 [PATCH for-next 0/2] Misc RNBD update Md Haris Iqbal
@ 2022-07-07 14:31 ` Md Haris Iqbal
  2022-07-07 14:31 ` [PATCH for-next 2/2] block/rnbd-srv: Replace sess_dev_list with index_idr Md Haris Iqbal
  2022-07-07 23:29 ` [PATCH for-next 0/2] Misc RNBD update Jens Axboe
  2 siblings, 0 replies; 9+ messages in thread
From: Md Haris Iqbal @ 2022-07-07 14:31 UTC (permalink / raw)
  To: linux-block
  Cc: axboe, hch, sagi, bvanassche, haris.iqbal, jinpu.wang, gi-oh.kim

After setting keep_id if the mutex trylock fails, the keep_id stays set
for the rest of the sess_dev lifetime.

Therefore, set keep_id to true after mutex_trylock succeeds, so that a
failure of trylock does'nt touch keep_id.

Fixes: b168e1d85cf3 ("block/rnbd-srv: Prevent a deadlock generated by accessing sysfs in parallel")
Cc: gi-oh.kim@ionos.com
Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
---
 drivers/block/rnbd/rnbd-srv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c
index beaef43a67b9..cf9e29a08db2 100644
--- a/drivers/block/rnbd/rnbd-srv.c
+++ b/drivers/block/rnbd/rnbd-srv.c
@@ -323,10 +323,11 @@ void rnbd_srv_sess_dev_force_close(struct rnbd_srv_sess_dev *sess_dev,
 {
 	struct rnbd_srv_session	*sess = sess_dev->sess;
 
-	sess_dev->keep_id = true;
 	/* It is already started to close by client's close message. */
 	if (!mutex_trylock(&sess->lock))
 		return;
+
+	sess_dev->keep_id = true;
 	/* first remove sysfs itself to avoid deadlock */
 	sysfs_remove_file_self(&sess_dev->kobj, &attr->attr);
 	rnbd_srv_destroy_dev_session_sysfs(sess_dev);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH for-next 2/2] block/rnbd-srv: Replace sess_dev_list with index_idr
  2022-07-07 14:31 [PATCH for-next 0/2] Misc RNBD update Md Haris Iqbal
  2022-07-07 14:31 ` [PATCH for-next 1/2] block/rnbd-srv: Set keep_id to true after mutex_trylock Md Haris Iqbal
@ 2022-07-07 14:31 ` Md Haris Iqbal
  2022-07-07 23:29 ` [PATCH for-next 0/2] Misc RNBD update Jens Axboe
  2 siblings, 0 replies; 9+ messages in thread
From: Md Haris Iqbal @ 2022-07-07 14:31 UTC (permalink / raw)
  To: linux-block
  Cc: axboe, hch, sagi, bvanassche, haris.iqbal, jinpu.wang, Aleksei Marov

The structure rnbd_srv_session maintains a list and an xarray of
rnbd_srv_dev. There is no need to keep both as one of them can serve the
purpose.

Since one of the places where the lookup of rnbd_srv_dev using
rnbd_srv_session is IO path, an xarray would serve us better than a list
traversal. Hence remove sess_dev_list from rnbd_srv_session, and replace
its uses from xarray.

Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
Reviewed-by: Aleksei Marov <aleksei.marov@ionos.com>
Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
---
 drivers/block/rnbd/rnbd-srv.c | 17 +++++++----------
 drivers/block/rnbd/rnbd-srv.h |  4 ----
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c
index cf9e29a08db2..9a80fbce775a 100644
--- a/drivers/block/rnbd/rnbd-srv.c
+++ b/drivers/block/rnbd/rnbd-srv.c
@@ -224,7 +224,6 @@ void rnbd_destroy_sess_dev(struct rnbd_srv_sess_dev *sess_dev, bool keep_id)
 	wait_for_completion(&dc); /* wait for inflights to drop to zero */
 
 	rnbd_dev_close(sess_dev->rnbd_dev);
-	list_del(&sess_dev->sess_list);
 	mutex_lock(&sess_dev->dev->lock);
 	list_del(&sess_dev->dev_list);
 	if (sess_dev->open_flags & FMODE_WRITE)
@@ -239,14 +238,14 @@ void rnbd_destroy_sess_dev(struct rnbd_srv_sess_dev *sess_dev, bool keep_id)
 
 static void destroy_sess(struct rnbd_srv_session *srv_sess)
 {
-	struct rnbd_srv_sess_dev *sess_dev, *tmp;
+	struct rnbd_srv_sess_dev *sess_dev;
+	unsigned long index;
 
-	if (list_empty(&srv_sess->sess_dev_list))
+	if (xa_empty(&srv_sess->index_idr))
 		goto out;
 
 	mutex_lock(&srv_sess->lock);
-	list_for_each_entry_safe(sess_dev, tmp, &srv_sess->sess_dev_list,
-				 sess_list)
+	xa_for_each(&srv_sess->index_idr, index, sess_dev)
 		rnbd_srv_destroy_dev_session_sysfs(sess_dev);
 	mutex_unlock(&srv_sess->lock);
 
@@ -281,7 +280,6 @@ static int create_sess(struct rtrs_srv_sess *rtrs)
 
 	srv_sess->queue_depth = rtrs_srv_get_queue_depth(rtrs);
 	xa_init_flags(&srv_sess->index_idr, XA_FLAGS_ALLOC);
-	INIT_LIST_HEAD(&srv_sess->sess_dev_list);
 	mutex_init(&srv_sess->lock);
 	mutex_lock(&sess_lock);
 	list_add(&srv_sess->list, &sess_list);
@@ -667,11 +665,12 @@ static struct rnbd_srv_sess_dev *
 find_srv_sess_dev(struct rnbd_srv_session *srv_sess, const char *dev_name)
 {
 	struct rnbd_srv_sess_dev *sess_dev;
+	unsigned long index;
 
-	if (list_empty(&srv_sess->sess_dev_list))
+	if (xa_empty(&srv_sess->index_idr))
 		return NULL;
 
-	list_for_each_entry(sess_dev, &srv_sess->sess_dev_list, sess_list)
+	xa_for_each(&srv_sess->index_idr, index, sess_dev)
 		if (!strcmp(sess_dev->pathname, dev_name))
 			return sess_dev;
 
@@ -782,8 +781,6 @@ static int process_msg_open(struct rnbd_srv_session *srv_sess,
 	list_add(&srv_sess_dev->dev_list, &srv_dev->sess_dev_list);
 	mutex_unlock(&srv_dev->lock);
 
-	list_add(&srv_sess_dev->sess_list, &srv_sess->sess_dev_list);
-
 	rnbd_srv_info(srv_sess_dev, "Opened device '%s'\n", srv_dev->id);
 
 	kfree(full_path);
diff --git a/drivers/block/rnbd/rnbd-srv.h b/drivers/block/rnbd/rnbd-srv.h
index be2ae486d407..30e403557c67 100644
--- a/drivers/block/rnbd/rnbd-srv.h
+++ b/drivers/block/rnbd/rnbd-srv.h
@@ -25,8 +25,6 @@ struct rnbd_srv_session {
 	int			queue_depth;
 
 	struct xarray		index_idr;
-	/* List of struct rnbd_srv_sess_dev */
-	struct list_head        sess_dev_list;
 	struct mutex		lock;
 	u8			ver;
 };
@@ -48,8 +46,6 @@ struct rnbd_srv_dev {
 struct rnbd_srv_sess_dev {
 	/* Entry inside rnbd_srv_dev struct */
 	struct list_head		dev_list;
-	/* Entry inside rnbd_srv_session struct */
-	struct list_head		sess_list;
 	struct rnbd_dev			*rnbd_dev;
 	struct rnbd_srv_session		*sess;
 	struct rnbd_srv_dev		*dev;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH for-next 0/2] Misc RNBD update
  2022-07-07 14:31 [PATCH for-next 0/2] Misc RNBD update Md Haris Iqbal
  2022-07-07 14:31 ` [PATCH for-next 1/2] block/rnbd-srv: Set keep_id to true after mutex_trylock Md Haris Iqbal
  2022-07-07 14:31 ` [PATCH for-next 2/2] block/rnbd-srv: Replace sess_dev_list with index_idr Md Haris Iqbal
@ 2022-07-07 23:29 ` Jens Axboe
  2 siblings, 0 replies; 9+ messages in thread
From: Jens Axboe @ 2022-07-07 23:29 UTC (permalink / raw)
  To: haris.iqbal, linux-block; +Cc: hch, bvanassche, sagi, jinpu.wang

On Thu, 7 Jul 2022 16:31:20 +0200, Md Haris Iqbal wrote:
> Please consider to include following change for next merge window.
>  - Fixes a minor bug
>  - Removes a list, and replaces its use with an existing xarray
> 
> Md Haris Iqbal (2):
>   block/rnbd-srv: Set keep_id to true after mutex_trylock
>   block/rnbd-srv: Replace sess_dev_list with index_idr
> 
> [...]

Applied, thanks!

[1/2] block/rnbd-srv: Set keep_id to true after mutex_trylock
      commit: 5ba7b490d9fce87b2aea9de27e13da6ef5300a17
[2/2] block/rnbd-srv: Replace sess_dev_list with index_idr
      commit: cf9db9e0f6fd15aa044d32e4018c3a572534a9a7

Best regards,
-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH for-next 0/2] Misc RNBD update
  2022-01-14 15:58 Md Haris Iqbal
  2022-01-26 13:57 ` Haris Iqbal
@ 2022-01-26 14:01 ` Jens Axboe
  1 sibling, 0 replies; 9+ messages in thread
From: Jens Axboe @ 2022-01-26 14:01 UTC (permalink / raw)
  To: Md Haris Iqbal, linux-block; +Cc: hch, jinpu.wang, bvanassche, sagi

On Fri, 14 Jan 2022 16:58:53 +0100, Md Haris Iqbal wrote:
> Please consider to include following change for next merge window.
>  - fixes warning generated from checkpatch
>  - removes rotational param from RNBD device
> 
> Gioh Kim (2):
>   block/rnbd-clt: fix CHECK:BRACES warning
>   block/rnbd: client device does not care queue/rotational
> 
> [...]

Applied, thanks!

[1/2] block/rnbd-clt: fix CHECK:BRACES warning
      commit: 7cb0c32efbae2a7000f74243d8b4cab35d669cbd
[2/2] block/rnbd: client device does not care queue/rotational
      commit: de53a6a82aad3010d7e9c3151cba5e4e46b6ec32

Best regards,
-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH for-next 0/2] Misc RNBD update
  2022-01-14 15:58 Md Haris Iqbal
@ 2022-01-26 13:57 ` Haris Iqbal
  2022-01-26 14:01 ` Jens Axboe
  1 sibling, 0 replies; 9+ messages in thread
From: Haris Iqbal @ 2022-01-26 13:57 UTC (permalink / raw)
  To: linux-block; +Cc: axboe, hch, sagi, bvanassche, jinpu.wang

On Fri, Jan 14, 2022 at 4:58 PM Md Haris Iqbal <haris.iqbal@ionos.com> wrote:
>
> Hi Jens,
>
> Please consider to include following change for next merge window.
>  - fixes warning generated from checkpatch
>  - removes rotational param from RNBD device

Ping.

>
> Gioh Kim (2):
>   block/rnbd-clt: fix CHECK:BRACES warning
>   block/rnbd: client device does not care queue/rotational
>
>  drivers/block/rnbd/rnbd-clt.c   | 15 ++++++++-------
>  drivers/block/rnbd/rnbd-clt.h   |  1 -
>  drivers/block/rnbd/rnbd-proto.h |  4 ++--
>  drivers/block/rnbd/rnbd-srv.c   |  1 -
>  4 files changed, 10 insertions(+), 11 deletions(-)
>
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH for-next 0/2] Misc RNBD update
@ 2022-01-14 15:58 Md Haris Iqbal
  2022-01-26 13:57 ` Haris Iqbal
  2022-01-26 14:01 ` Jens Axboe
  0 siblings, 2 replies; 9+ messages in thread
From: Md Haris Iqbal @ 2022-01-14 15:58 UTC (permalink / raw)
  To: linux-block; +Cc: axboe, hch, sagi, bvanassche, haris.iqbal, jinpu.wang

Hi Jens,

Please consider to include following change for next merge window.
 - fixes warning generated from checkpatch
 - removes rotational param from RNBD device

Gioh Kim (2):
  block/rnbd-clt: fix CHECK:BRACES warning
  block/rnbd: client device does not care queue/rotational

 drivers/block/rnbd/rnbd-clt.c   | 15 ++++++++-------
 drivers/block/rnbd/rnbd-clt.h   |  1 -
 drivers/block/rnbd/rnbd-proto.h |  4 ++--
 drivers/block/rnbd/rnbd-srv.c   |  1 -
 4 files changed, 10 insertions(+), 11 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH for-next 0/2] Misc RNBD update
  2021-07-26 11:59 Jack Wang
@ 2021-07-27 22:48 ` Jens Axboe
  0 siblings, 0 replies; 9+ messages in thread
From: Jens Axboe @ 2021-07-27 22:48 UTC (permalink / raw)
  To: Jack Wang, linux-block; +Cc: hch, sagi, bvanassche, haris.iqbal

On 7/26/21 5:59 AM, Jack Wang wrote:
> Hi Jens,
> 
> Please consider to include following change for next merge window.
> - one fix for wrong api usage.> - one sysfs_emit conversion for sysfs access.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH for-next 0/2] Misc RNBD update
@ 2021-07-26 11:59 Jack Wang
  2021-07-27 22:48 ` Jens Axboe
  0 siblings, 1 reply; 9+ messages in thread
From: Jack Wang @ 2021-07-26 11:59 UTC (permalink / raw)
  To: linux-block; +Cc: axboe, hch, sagi, bvanassche, haris.iqbal, jinpu.wang

Hi Jens,

Please consider to include following change for next merge window.
- one fix for wrong api usage.
- one sysfs_emit conversion for sysfs access.

Regards!

Gioh Kim (1):
  block/rnbd-clt: Use put_cpu_ptr after get_cpu_ptr

Md Haris Iqbal (1):
  block/rnbd: Use sysfs_emit instead of s*printf function for sysfs show

 drivers/block/rnbd/rnbd-clt-sysfs.c | 33 +++++++++++++----------------
 drivers/block/rnbd/rnbd-clt.c       |  2 +-
 drivers/block/rnbd/rnbd-srv-sysfs.c | 14 ++++++------
 3 files changed, 23 insertions(+), 26 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-07-07 23:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-07 14:31 [PATCH for-next 0/2] Misc RNBD update Md Haris Iqbal
2022-07-07 14:31 ` [PATCH for-next 1/2] block/rnbd-srv: Set keep_id to true after mutex_trylock Md Haris Iqbal
2022-07-07 14:31 ` [PATCH for-next 2/2] block/rnbd-srv: Replace sess_dev_list with index_idr Md Haris Iqbal
2022-07-07 23:29 ` [PATCH for-next 0/2] Misc RNBD update Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2022-01-14 15:58 Md Haris Iqbal
2022-01-26 13:57 ` Haris Iqbal
2022-01-26 14:01 ` Jens Axboe
2021-07-26 11:59 Jack Wang
2021-07-27 22:48 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).