From: Wouter Verhelst <w@uter.be>
To: Markus Pargmann <mpa@pengutronix.de>,
nbd-general <nbd-general@lists.sourceforge.net>,
lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH v2] nbd: Issue a uevent when disconnecting
Date: Tue, 2 Feb 2016 16:27:00 +0100 [thread overview]
Message-ID: <20160202152700.GA7562@grep.be> (raw)
In-Reply-To: <1453566230-5786-1-git-send-email-w@uter.be>
There already is a uevent by default when closing a device upon connect
of the device. However, the same isn't true on disconnect.
This makes it hard for userspace to keep track of whether a device is
connected, since we are notified when the connection is created, but not
when it is removed again.
Explicitly issue a "change" uevent to remedy.
[v2: incorporate feedback from udev maintainer and make sure that we
issue a uevent upon connect as well as disconnect, rather than connect
only]
Signed-off-by: Wouter Verhelst <w@uter.be>
---
drivers/block/nbd.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index e4c5cc1..04d9563 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -417,6 +417,8 @@ static int nbd_thread_recv(struct nbd_device *nbd)
spin_unlock_irqrestore(&nbd->tasks_lock, flags);
ret = device_create_file(disk_to_dev(nbd->disk), &pid_attr);
+ kobject_uevent(&disk_to_dev(nbd->disk)->kobj, KOBJ_CHANGE);
+
if (ret) {
dev_err(disk_to_dev(nbd->disk), "device_create_file failed!\n");
@@ -438,6 +440,7 @@ static int nbd_thread_recv(struct nbd_device *nbd)
}
device_remove_file(disk_to_dev(nbd->disk), &pid_attr);
+ kobject_uevent(&disk_to_dev(nbd->disk)->kobj, KOBJ_CHANGE);
spin_lock_irqsave(&nbd->tasks_lock, flags);
nbd->task_recv = NULL;
--
2.7.0
next prev parent reply other threads:[~2016-02-02 15:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-23 16:23 [PATCH] Issue a uevent when disconnecting Wouter Verhelst
2016-02-02 15:27 ` Wouter Verhelst [this message]
2016-02-05 9:03 ` [PATCH v2] nbd: " Markus Pargmann
2016-02-05 9:42 ` Wouter Verhelst
2016-02-12 14:49 ` Markus Pargmann
2016-02-05 9:04 ` [PATCH] nbd: Create size change events for userspace Markus Pargmann
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=20160202152700.GA7562@grep.be \
--to=w@uter.be \
--cc=linux-kernel@vger.kernel.org \
--cc=mpa@pengutronix.de \
--cc=nbd-general@lists.sourceforge.net \
/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