linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gioh Kim <gi-oh.kim@ionos.com>
To: linux-block@vger.kernel.org
Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me,
	bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com,
	Md Haris Iqbal <haris.iqbal@cloud.ionos.com>,
	Gioh Kim <gi-oh.kim@ionos.com>
Subject: [PATCHv2 for-next 21/24] block/rnbd-clt: Generate kobject_uevent when the rnbd device state changes
Date: Tue, 30 Mar 2021 09:37:49 +0200	[thread overview]
Message-ID: <20210330073752.1465613-22-gi-oh.kim@ionos.com> (raw)
In-Reply-To: <20210330073752.1465613-1-gi-oh.kim@ionos.com>

From: Md Haris Iqbal <haris.iqbal@cloud.ionos.com>

When an RTRS session state changes, the transport layer generates an event
to RNBD. Then RNBD will change the state of the RNBD client device
accordingly.

This commit add kobject_uevent when the RNBD device state changes. With
this udev rules can be configured to react accordingly.

Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Gioh Kim <gi-oh.kim@ionos.com>
---
 drivers/block/rnbd/rnbd-clt-sysfs.c | 1 +
 drivers/block/rnbd/rnbd-clt.c       | 9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c
index 9ea4da7f894a..630351574d1b 100644
--- a/drivers/block/rnbd/rnbd-clt-sysfs.c
+++ b/drivers/block/rnbd/rnbd-clt-sysfs.c
@@ -491,6 +491,7 @@ static int rnbd_clt_add_dev_kobj(struct rnbd_clt_dev *dev)
 			      ret);
 		kobject_put(&dev->kobj);
 	}
+	kobject_uevent(gd_kobj, KOBJ_ONLINE);
 
 	return ret;
 }
diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c
index 998cadd73d47..6f3ca2e3bc02 100644
--- a/drivers/block/rnbd/rnbd-clt.c
+++ b/drivers/block/rnbd/rnbd-clt.c
@@ -110,6 +110,7 @@ static int rnbd_clt_change_capacity(struct rnbd_clt_dev *dev,
 static int process_msg_open_rsp(struct rnbd_clt_dev *dev,
 				struct rnbd_msg_open_rsp *rsp)
 {
+	struct kobject *gd_kobj;
 	int err = 0;
 
 	mutex_lock(&dev->lock);
@@ -128,6 +129,8 @@ static int process_msg_open_rsp(struct rnbd_clt_dev *dev,
 		 */
 		if (dev->nsectors != nsectors)
 			rnbd_clt_change_capacity(dev, nsectors);
+		gd_kobj = &disk_to_dev(dev->gd)->kobj;
+		kobject_uevent(gd_kobj, KOBJ_ONLINE);
 		rnbd_clt_info(dev, "Device online, device remapped successfully\n");
 	}
 	err = rnbd_clt_set_dev_attr(dev, rsp);
@@ -654,14 +657,18 @@ static int send_msg_sess_info(struct rnbd_clt_session *sess, enum wait_type wait
 static void set_dev_states_to_disconnected(struct rnbd_clt_session *sess)
 {
 	struct rnbd_clt_dev *dev;
+	struct kobject *gd_kobj;
 
 	mutex_lock(&sess->lock);
 	list_for_each_entry(dev, &sess->devs_list, list) {
 		rnbd_clt_err(dev, "Device disconnected.\n");
 
 		mutex_lock(&dev->lock);
-		if (dev->dev_state == DEV_STATE_MAPPED)
+		if (dev->dev_state == DEV_STATE_MAPPED) {
 			dev->dev_state = DEV_STATE_MAPPED_DISCONNECTED;
+			gd_kobj = &disk_to_dev(dev->gd)->kobj;
+			kobject_uevent(gd_kobj, KOBJ_OFFLINE);
+		}
 		mutex_unlock(&dev->lock);
 	}
 	mutex_unlock(&sess->lock);
-- 
2.25.1


  parent reply	other threads:[~2021-03-30  7:39 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-30  7:37 [PATCHv2 for-next 00/24] Misc update for rnbd Gioh Kim
2021-03-30  7:37 ` [PATCHv2 for-next 01/24] MAINTAINERS: Change maintainer for rnbd module Gioh Kim
2021-03-30  7:37 ` [PATCHv2 for-next 02/24] Documentation/sysfs-block-rnbd: Add descriptions for remap_device and resize Gioh Kim
2021-03-30  7:37 ` [PATCHv2 for-next 03/24] block/rnbd: Enable the fault-injection Gioh Kim
2021-03-30  7:37 ` [PATCHv2 for-next 04/24] block/rnbd-srv: Inject a fault at bio processing Gioh Kim
2021-03-30  7:37 ` [PATCHv2 for-next 05/24] block/rnbd-clt: Inject some fault points Gioh Kim
2021-03-30  7:37 ` [PATCHv2 for-next 06/24] docs: fault-injection: Add fault-injection manual of RNBD Gioh Kim
2021-03-30  7:37 ` [PATCHv2 for-next 07/24] docs: Add RTRS/RNBD to the index of fault-injection Gioh Kim
2021-03-30  7:37 ` [PATCHv2 for-next 08/24] block/rnbd-clt: Remove some arguments from insert_dev_if_not_exists_devpath Gioh Kim
2021-03-30 23:50   ` Chaitanya Kulkarni
2021-03-30  7:37 ` [PATCHv2 for-next 09/24] block/rnbd-clt: Remove some arguments from rnbd_client_setup_device Gioh Kim
2021-03-30 23:51   ` Chaitanya Kulkarni
2021-03-30  7:37 ` [PATCHv2 for-next 10/24] block/rnbd-clt: Move add_disk(dev->gd) to rnbd_clt_setup_gen_disk Gioh Kim
2021-03-30 23:55   ` Chaitanya Kulkarni
2021-03-31  6:32     ` Gioh Kim
2021-03-30  7:37 ` [PATCHv2 for-next 11/24] block/rnbd: Kill rnbd_clt_destroy_default_group Gioh Kim
2021-03-30 23:56   ` Chaitanya Kulkarni
2021-03-30  7:37 ` [PATCHv2 for-next 12/24] block/rnbd: Kill destroy_device_cb Gioh Kim
2021-03-30 23:56   ` Chaitanya Kulkarni
2021-03-30  7:37 ` [PATCHv2 for-next 13/24] block/rnbd-clt: Replace {NO_WAIT,WAIT} with RTRS_PERMIT_{WAIT,NOWAIT} Gioh Kim
2021-03-31  0:01   ` Chaitanya Kulkarni
2021-03-30  7:37 ` [PATCHv2 for-next 14/24] block/rnbd-srv: Prevent a deadlock generated by accessing sysfs in parallel Gioh Kim
2021-03-30  7:37 ` [PATCHv2 for-next 15/24] block/rnbd-srv: Remove force_close file after holding a lock Gioh Kim
2021-03-30  7:37 ` [PATCHv2 for-next 16/24] block/rnbd-clt: Improve find_or_create_sess() return check Gioh Kim
2021-03-30  7:37 ` [PATCHv2 for-next 17/24] block/rnbd-clt: Fix missing a memory free when unloading the module Gioh Kim
2021-03-30  7:37 ` [PATCHv2 for-next 18/24] block/rnbd-clt: Support polling mode for IO latency optimization Gioh Kim
2021-03-30  7:37 ` [PATCHv2 for-next 19/24] Documentation/ABI/rnbd-clt: Add description for nr_poll_queues Gioh Kim
2021-03-30  7:37 ` [PATCHv2 for-next 20/24] block/rnbd-srv: Remove unused arguments of rnbd_srv_rdma_ev Gioh Kim
2021-03-31  0:07   ` Chaitanya Kulkarni
2021-03-30  7:37 ` Gioh Kim [this message]
2021-03-30  7:37 ` [PATCHv2 for-next 22/24] block/rnbd-clt: Remove max_segment_size Gioh Kim
2021-03-30  7:37 ` [PATCHv2 for-next 23/24] block/rnbd-clt-sysfs: Remove copy buffer overlap in rnbd_clt_get_path_name Gioh Kim
2021-03-31  0:08   ` Chaitanya Kulkarni
2021-03-30  7:37 ` [PATCHv2 for-next 24/24] block/rnbd: Use strscpy instead of strlcpy Gioh Kim
2021-03-31  0:09   ` Chaitanya Kulkarni
2021-04-01 19:22 ` [PATCHv2 for-next 00/24] Misc update for rnbd Jason Gunthorpe

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=20210330073752.1465613-22-gi-oh.kim@ionos.com \
    --to=gi-oh.kim@ionos.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=haris.iqbal@cloud.ionos.com \
    --cc=haris.iqbal@ionos.com \
    --cc=hch@infradead.org \
    --cc=jinpu.wang@ionos.com \
    --cc=linux-block@vger.kernel.org \
    --cc=sagi@grimberg.me \
    /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;
as well as URLs for NNTP newsgroup(s).