Skip to contentSkip to conversation

DASD: send 'change' uevents

PATCH In review Hannes Reinecke 2 participants 2 messages Oct 24, 2008 – Oct 26, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 DASD: send 'change' uevents

Hi Martin,

this patch modifies the DASD driver to sent out 'change' events whenever the internal state machine transitions in or out of the 'ready' state. This is required for udev so that vol_id and friends can actually read from the disk.

Please apply.

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)

DASD: Send 'change' uevents

A DASD is only useable after the internal state machine transitioned to 'ready', way after the device has been added to sysfs. So we need to send out a 'change' event here to notify udev.

drivers/s390/block/dasd.c +23 -2
index 0a225cc..447fcdc 100644
@@ -335,7 +335,9 @@ static int dasd_state_unfmt_to_basic(struct dasd_device *device)
 static int
 dasd_state_ready_to_online(struct dasd_device * device)
 {
-	int rc;
+	int rc, i;
+	struct gendisk *disk = device->bdev->bd_disk;
+	struct hd_struct *p;
 
 	if (device->discipline->ready_to_online) {
 		rc = device->discipline->ready_to_online(device);
@@ -345,6 +347,15 @@ dasd_state_ready_to_online(struct dasd_device * device)
 	device->state = DASD_STATE_ONLINE;
 	if (device->block)
 		dasd_schedule_block_bh(device->block);
+
+	kobject_uevent(&disk->kobj, KOBJ_CHANGE);
+	/* send uevents for all partitions */
+	for (i = 1; i < disk->minors; i++) {
+		p = disk->part[i-1];
+		if (!p || !p->nr_sects)
+			continue;
+		kobject_uevent(&p->kobj, KOBJ_CHANGE);
+	}
 	return 0;
 }
 
@@ -353,7 +364,9 @@ dasd_state_ready_to_online(struct dasd_device * device)
  */
 static int dasd_state_online_to_ready(struct dasd_device *device)
 {
-	int rc;
+	int rc, i;
+	struct gendisk *disk = device->bdev->bd_disk;
+	struct hd_struct *p;
 
 	if (device->discipline->online_to_ready) {
 		rc = device->discipline->online_to_ready(device);
@@ -361,6 +374,14 @@ static int dasd_state_online_to_ready(struct dasd_device *device)
 			return rc;
 	}
 	device->state = DASD_STATE_READY;
+	/* send uevents for all partitions */
+	for (i = 1; i < disk->minors; i++) {
+		p = disk->part[i-1];
+		if (!p || !p->nr_sects)
+			continue;
+		kobject_uevent(&p->kobj, KOBJ_CHANGE);
+	}
+	kobject_uevent(&disk->kobj, KOBJ_CHANGE);
 	return 0;
 }
 
#1 lore raw

Hi Hannes,

Quoted 6 lines · Hannes Reinecke

this patch modifies the DASD driver to sent out 'change' events whenever the internal state machine transitions in or out of the 'ready' state. This is required for udev so that vol_id and friends can actually read from the disk.

Please apply.

Looks reasonable to me. Stefan can you take a look at this please?

Signature · 4 lines
blue skies,
  Martin.

"Reality continues to ruin my life." - Calvin.