LKML Archive mirror
 help / color / mirror / Atom feed
From: Markus Pargmann <mpa@pengutronix.de>
To: Wouter Verhelst <w@uter.be>
Cc: nbd-general <nbd-general@lists.sourceforge.net>,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] nbd: Issue a uevent when disconnecting
Date: Fri, 05 Feb 2016 10:03:41 +0100	[thread overview]
Message-ID: <5247002.OuBHJMaBYj@adelgunde> (raw)
In-Reply-To: <20160202152700.GA7562@grep.be>

[-- Attachment #1: Type: text/plain, Size: 2258 bytes --]

Hi Wouter,

On Tuesday, February 02, 2016 04:27:00 PM Wouter Verhelst wrote:
> 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]

The systemd people had the same feedback. Basically the device is not
marked as ready until a uevent is received. My idea was to use the size
property consistently. If the device is connected the size is correctly
changed and a uevent is created. On disconnect the size is set to 0 with
another uevent.

Does this work for you as well? I will send the patch as reply.

Thanks,

Markus

> 
> 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;
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-02-05  9:03 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 ` [PATCH v2] nbd: " Wouter Verhelst
2016-02-05  9:03   ` Markus Pargmann [this message]
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=5247002.OuBHJMaBYj@adelgunde \
    --to=mpa@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nbd-general@lists.sourceforge.net \
    --cc=w@uter.be \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).