Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1432410 > unrolled thread
| Started by | Fam Zheng <famz@redhat.com> |
|---|---|
| First post | 2016-06-28 04:40 +0200 |
| Last post | 2016-06-29 03:30 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] virtio-blk: Generate uevent after attribute available Fam Zheng <famz@redhat.com> - 2016-06-28 04:40 +0200
Re: [PATCH] virtio-blk: Generate uevent after attribute available Christoph Hellwig <hch@infradead.org> - 2016-06-28 14:40 +0200
Re: [PATCH] virtio-blk: Generate uevent after attribute available Fam Zheng <famz@redhat.com> - 2016-06-29 03:30 +0200
| From | Fam Zheng <famz@redhat.com> |
|---|---|
| Date | 2016-06-28 04:40 +0200 |
| Subject | [PATCH] virtio-blk: Generate uevent after attribute available |
| Message-ID | <rOR6p-EK-5@gated-at.bofh.it> |
Userspace listens to the KOBJ_ADD uevent generated in add_disk. At that
point we haven't created the serial attribute file, therefore depending
on how fast udev reacts, the /dev/disk/by-id/ entry doesn't always get
created.
This race condition can be easily reproduced by hot plugging a number of
virtio-blk disks.
Also in systemd, there used to be a related workaround in udev rules
called 'WAIT_FOR="serial"', but it is removed in later versions.
Now let's generate a KOBJ_CHANGE event after the attributes are ready.
Signed-off-by: Fam Zheng <famz@redhat.com>
---
drivers/block/virtio_blk.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 42758b5..5056007 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -567,6 +567,7 @@ static int virtblk_probe(struct virtio_device *vdev)
{
struct virtio_blk *vblk;
struct request_queue *q;
+ struct device *ddev;
int err, index;
u64 cap;
@@ -746,6 +747,8 @@ static int virtblk_probe(struct virtio_device *vdev)
&dev_attr_cache_type_ro);
if (err)
goto out_del_disk;
+ ddev = disk_to_dev(vblk->disk);
+ kobject_uevent(&ddev->kobj, KOBJ_CHANGE);
return 0;
out_del_disk:
--
2.9.0
[toc] | [next] | [standalone]
| From | Christoph Hellwig <hch@infradead.org> |
|---|---|
| Date | 2016-06-28 14:40 +0200 |
| Message-ID | <rP0t4-730-37@gated-at.bofh.it> |
| In reply to | #1432410 |
On Tue, Jun 28, 2016 at 10:39:15AM +0800, Fam Zheng wrote: > Userspace listens to the KOBJ_ADD uevent generated in add_disk. At that > point we haven't created the serial attribute file, therefore depending > on how fast udev reacts, the /dev/disk/by-id/ entry doesn't always get > created. > > This race condition can be easily reproduced by hot plugging a number of > virtio-blk disks. > > Also in systemd, there used to be a related workaround in udev rules > called 'WAIT_FOR="serial"', but it is removed in later versions. > > Now let's generate a KOBJ_CHANGE event after the attributes are ready. The same race is present in other drivers as well, e.g. nvme. Please find a way to make this work properly without needing to hack every driver to send events manually.
[toc] | [prev] | [next] | [standalone]
| From | Fam Zheng <famz@redhat.com> |
|---|---|
| Date | 2016-06-29 03:30 +0200 |
| Message-ID | <rPcud-65h-3@gated-at.bofh.it> |
| In reply to | #1432958 |
On Tue, 06/28 04:45, Christoph Hellwig wrote: > On Tue, Jun 28, 2016 at 10:39:15AM +0800, Fam Zheng wrote: > > Userspace listens to the KOBJ_ADD uevent generated in add_disk. At that > > point we haven't created the serial attribute file, therefore depending > > on how fast udev reacts, the /dev/disk/by-id/ entry doesn't always get > > created. > > > > This race condition can be easily reproduced by hot plugging a number of > > virtio-blk disks. > > > > Also in systemd, there used to be a related workaround in udev rules > > called 'WAIT_FOR="serial"', but it is removed in later versions. > > > > Now let's generate a KOBJ_CHANGE event after the attributes are ready. > > The same race is present in other drivers as well, e.g. nvme. Please > find a way to make this work properly without needing to hack every > driver to send events manually. OK, I'll take a look today! Fam
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web