On Wed, 27 Apr 2011 18:17:14 +1000 NeilBrown <neilb@xxxxxxx> wrote: > I manage to reproduce something very similar and I think I know what is > happening. It appears to be fixed by this change to driver/md/md.c > > @@ -4340,8 +4344,8 @@ static int md_alloc(dev_t dev, char *name) > * remove it now. > */ > disk->flags |= GENHD_FL_EXT_DEVT; > - add_disk(disk); > mddev->gendisk = disk; > + add_disk(disk); > error = kobject_init_and_add(&mddev->kobj, &md_ktype, > &disk_to_dev(disk)->kobj, "%s", "md"); > if (error) { > > > However I need to think through the sequence of events in the morning and > make sure it all makes sense and there isn't some other race hiding in there. > > Thanks again for the report. > On reflection over dinner, I think I should move the add_disk right to the end just before the mutex_unlock. I'm not sure it makes a big practical difference but it will be easier to justify. So if you could test this one instead please that would be great. The rationale is that as soon as we call add_disk, get_gendisk will return the disk rather than coming through to md_probe and blocking on the mutex. So we want everything set up properly before calling add_disk. Thanks, NeilBrown diff --git a/drivers/md/md.c b/drivers/md/md.c index 818313e..6ab5bfb 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -4340,7 +4340,6 @@ static int md_alloc(dev_t dev, char *name) * remove it now. */ disk->flags |= GENHD_FL_EXT_DEVT; - add_disk(disk); mddev->gendisk = disk; error = kobject_init_and_add(&mddev->kobj, &md_ktype, &disk_to_dev(disk)->kobj, "%s", "md"); @@ -4357,6 +4356,7 @@ static int md_alloc(dev_t dev, char *name) printk(KERN_DEBUG "pointless warning\n"); blk_queue_flush(mddev->queue, REQ_FLUSH | REQ_FUA); + add_disk(disk); abort: mutex_unlock(&disks_mutex); if (!error && mddev->kobj.sd) { -- To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html