Skip to contentSkip to conversation

blkfront: add uevent for size change

PATCH In review Marc Olson 2 participants 5 messages Apr 11, 2017 – Apr 12, 2017

Subsystems (3)
lore
Share & tools
lore

Marc Olson

author
#0 lore raw

PATCH 1/1 blkfront: add uevent for size change

When a blkfront device is resized from dom0, emit a KOBJ_CHANGE uevent to notify the guest about the change. This allows for custom udev rules, such as automatically resizing a filesystem, when an event occurs.

---
 drivers/block/xen-blkfront.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/block/xen-blkfront.c +3 -0
index 2fee2ee..66abf9c 100644
@@ -1996,6 +1996,7 @@ static void blkfront_connect(struct blkfront_info *info)
 	unsigned long sector_size;
 	unsigned int physical_sector_size;
 	unsigned int binfo;
+	char *envp[] = { "RESIZE=1", NULL };
 	int err;
 
 	switch (info->connected) {
@@ -2012,6 +2013,8 @@ static void blkfront_connect(struct blkfront_info *info)
 		       sectors);
 		set_capacity(info->gd, sectors);
 		revalidate_disk(info->gd);
+		kobject_uevent_env(&disk_to_dev(info->gd)->kobj,
+				   KOBJ_CHANGE, envp);
 
 		return;
 	case BLKIF_STATE_SUSPENDED:
Signature · 1 line
2.7.4
#1 lore raw
Quoted 3 lines · Marc Olson

When a blkfront device is resized from dom0, emit a KOBJ_CHANGE uevent to notify the guest about the change. This allows for custom udev rules, such as automatically resizing a filesystem, when an event occurs.

Looks pretty reasonable.

Could you confirm what the udevadm --monitor --kernel --udev emits when this happens?

Thanks!

Quoted 30 lines
---
 drivers/block/xen-blkfront.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/block/xen-blkfront.c +3 -0
index 2fee2ee..66abf9c 100644
@@ -1996,6 +1996,7 @@ static void blkfront_connect(struct blkfront_info *info)
 	unsigned long sector_size;
 	unsigned int physical_sector_size;
 	unsigned int binfo;
+	char *envp[] = { "RESIZE=1", NULL };
 	int err;
 
 	switch (info->connected) {
@@ -2012,6 +2013,8 @@ static void blkfront_connect(struct blkfront_info *info)
 		       sectors);
 		set_capacity(info->gd, sectors);
 		revalidate_disk(info->gd);
+		kobject_uevent_env(&disk_to_dev(info->gd)->kobj,
+				   KOBJ_CHANGE, envp);
 
 		return;
 	case BLKIF_STATE_SUSPENDED:
Signature · 1 line
2.7.4
author
#2 lore raw
Quoted 8 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Marc Olson

When a blkfront device is resized from dom0, emit a KOBJ_CHANGE uevent to notify the guest about the change. This allows for custom udev rules, such as automatically resizing a filesystem, when an event occurs.

Looks pretty reasonable.

Could you confirm what the udevadm --monitor --kernel --udev emits when this happens?

Relevant output:

KERNEL[577.206230] change /devices/vbd-51728/block/xvdb (block)
UDEV [577.226218] change /devices/vbd-51728/block/xvdb (block)

Of course, this is missing without the patch.

/marc

Quoted 28 lines

Thanks!

Quoted 25 lines
---
 drivers/block/xen-blkfront.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/block/xen-blkfront.c +3 -0
index 2fee2ee..66abf9c 100644
@@ -1996,6 +1996,7 @@ static void blkfront_connect(struct blkfront_info *info)
 	unsigned long sector_size;
 	unsigned int physical_sector_size;
 	unsigned int binfo;
+	char *envp[] = { "RESIZE=1", NULL };
 	int err;
 
 	switch (info->connected) {
@@ -2012,6 +2013,8 @@ static void blkfront_connect(struct blkfront_info *info)
 		       sectors);
 		set_capacity(info->gd, sectors);
 		revalidate_disk(info->gd);
+		kobject_uevent_env(&disk_to_dev(info->gd)->kobj,
+				   KOBJ_CHANGE, envp);
 
Quoted 6 lines
Quoted 5 lines
drivers/block/xen-blkfront.c +0 -0
 		return;
 	case BLKIF_STATE_SUSPENDED:
Signature · 1 line
2.7.4

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

author
#3 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 8 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Marc Olson

When a blkfront device is resized from dom0, emit a KOBJ_CHANGE uevent to notify the guest about the change. This allows for custom udev rules, such as automatically resizing a filesystem, when an event occurs.

Looks pretty reasonable.

Could you confirm what the udevadm --monitor --kernel --udev emits when this happens?

Relevant output:

KERNEL[577.206230] change /devices/vbd-51728/block/xvdb (block)
UDEV [577.226218] change /devices/vbd-51728/block/xvdb (block)

Of course, this is missing without the patch.

/marc

Quoted 34 lines

Thanks!

Quoted 30 lines
---
 drivers/block/xen-blkfront.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/block/xen-blkfront.c +3 -0
index 2fee2ee..66abf9c 100644
@@ -1996,6 +1996,7 @@ static void blkfront_connect(struct blkfront_info *info)
 	unsigned long sector_size;
 	unsigned int physical_sector_size;
 	unsigned int binfo;
+	char *envp[] = { "RESIZE=1", NULL };
 	int err;
 
 	switch (info->connected) {
@@ -2012,6 +2013,8 @@ static void blkfront_connect(struct blkfront_info *info)
 		       sectors);
 		set_capacity(info->gd, sectors);
 		revalidate_disk(info->gd);
+		kobject_uevent_env(&disk_to_dev(info->gd)->kobj,
+				   KOBJ_CHANGE, envp);
 
 		return;
 	case BLKIF_STATE_SUSPENDED:
Signature · 1 line
2.7.4
#4 lore raw
In reply to Marc Olson
Quoted 3 lines · Marc Olson

When a blkfront device is resized from dom0, emit a KOBJ_CHANGE uevent to notify the guest about the change. This allows for custom udev rules, such as automatically resizing a filesystem, when an event occurs.

Looks pretty reasonable.

Could you confirm what the udevadm --monitor --kernel --udev emits when this happens?

Thanks!

Quoted 30 lines
---
 drivers/block/xen-blkfront.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/block/xen-blkfront.c +3 -0
index 2fee2ee..66abf9c 100644
@@ -1996,6 +1996,7 @@ static void blkfront_connect(struct blkfront_info *info)
 	unsigned long sector_size;
 	unsigned int physical_sector_size;
 	unsigned int binfo;
+	char *envp[] = { "RESIZE=1", NULL };
 	int err;
 
 	switch (info->connected) {
@@ -2012,6 +2013,8 @@ static void blkfront_connect(struct blkfront_info *info)
 		       sectors);
 		set_capacity(info->gd, sectors);
 		revalidate_disk(info->gd);
+		kobject_uevent_env(&disk_to_dev(info->gd)->kobj,
+				   KOBJ_CHANGE, envp);
 
 		return;
 	case BLKIF_STATE_SUSPENDED:
Signature · 1 line
2.7.4

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel