From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752121AbcBEJDy (ORCPT ); Fri, 5 Feb 2016 04:03:54 -0500 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:34635 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752054AbcBEJDp (ORCPT ); Fri, 5 Feb 2016 04:03:45 -0500 From: Markus Pargmann To: Wouter Verhelst Cc: nbd-general , lkml Subject: Re: [PATCH v2] nbd: Issue a uevent when disconnecting Date: Fri, 05 Feb 2016 10:03:41 +0100 Message-ID: <5247002.OuBHJMaBYj@adelgunde> User-Agent: KMail/4.14.1 (Linux/3.16.0-4-amd64; KDE/4.14.2; x86_64; ; ) In-Reply-To: <20160202152700.GA7562@grep.be> References: <1453566230-5786-1-git-send-email-w@uter.be> <20160202152700.GA7562@grep.be> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2305209.s0fsl49tvi"; micalg="pgp-sha256"; protocol="application/pgp-signature" X-SA-Exim-Connect-IP: 2001:67c:670:100:a61f:72ff:fe68:75ba X-SA-Exim-Mail-From: mpa@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --nextPart2305209.s0fsl49tvi Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="us-ascii" 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 conne= ct > of the device. However, the same isn't true on disconnect. >=20 > 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. >=20 > Explicitly issue a "change" uevent to remedy. >=20 > [v2: incorporate feedback from udev maintainer and make sure that we > issue a uevent upon connect as well as disconnect, rather than connec= t > 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 wit= h another uevent. Does this work for you as well? I will send the patch as reply. Thanks, Markus >=20 > Signed-off-by: Wouter Verhelst > --- > drivers/block/nbd.c | 3 +++ > 1 file changed, 3 insertions(+) >=20 > 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= ) > =09spin_unlock_irqrestore(&nbd->tasks_lock, flags); > =20 > =09ret =3D device_create_file(disk_to_dev(nbd->disk), &pid_attr); > +=09kobject_uevent(&disk_to_dev(nbd->disk)->kobj, KOBJ_CHANGE); > + > =09if (ret) { > =09=09dev_err(disk_to_dev(nbd->disk), "device_create_file failed!\n"= ); > =20 > @@ -438,6 +440,7 @@ static int nbd_thread_recv(struct nbd_device *nbd= ) > =09} > =20 > =09device_remove_file(disk_to_dev(nbd->disk), &pid_attr); > +=09kobject_uevent(&disk_to_dev(nbd->disk)->kobj, KOBJ_CHANGE); > =20 > =09spin_lock_irqsave(&nbd->tasks_lock, flags); > =09nbd->task_recv =3D NULL; >=20 =2D-=20 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-555= 5 | --nextPart2305209.s0fsl49tvi Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJWtGVtAAoJEEpcgKtcEGQQ5dQQAI1zIeuNRrUAu1TqaQ38i/6D urMs56ofBUkPfbpYh5WA6BGBoCt7Ak5dlLRkvlEhXZsvphf3x2I6ldwSsrE4nEmP Zrvb0CDqePWS+iUaUye2Ez3G9bbhF1bTW6VPnHYHKbD2g3orqBmY2BWEZJq/67tz 0/DADsGdZx6lkOAXYxSyJlVlFOkAt7HvTOC3vgijyFNmgflo+Yisg4GLRDoEj/aa i3qgMBEbTAvGAPnM86WWOVBwNgPvX0l1vn3m7N8URojxQXOWES2VM/BlNSdke2Ez oIh1C+soLNgbJvdKNO8A1NYqWGWW84SfFgQLDzwf5igpgxiv5YhPz5lzeBy/YLUV eiL6VjAZfDm2tAyTQ9+3wXy1YQFMkT6/GQfzk0THjvpPnhl5nXkIEDwG5TMYIt+q QISMfTwrp2/e0XaAMlVVcjZ9kS0GRBM12XlgQGRkHBvEs5HpE2ZPwCA4TpwzmKOt wdo93MY4EV0y/rAgsqIO0vyR1F9ikbactuWbWIgAeGMOtw7339SMVru6lFugWt/4 hmsK5+2BesDJuFCcRvcLiaII3rkZ+BjpkJiRHaWpLqpilCdNnOvKhUFS/TubuUsM AJqOKYYbqHSs3b4YrMZRQHL+W1FpEJy5cqvd03LBfp40IAZAx12fBcoFDCzje3D1 b12tm4vhQq24+5hXKXQu =UA/D -----END PGP SIGNATURE----- --nextPart2305209.s0fsl49tvi--