On (24/10/03 06:43), Christoph Hellwig wrote: > .. actually, we still clear QUEUE_FLAG_DYING early. Something like > the pathc below (plus proper comments) should sort it out: > > diff --git a/block/genhd.c b/block/genhd.c > index 1c05dd4c6980b5..9a1e18fbb136cf 100644 > --- a/block/genhd.c > +++ b/block/genhd.c > @@ -589,9 +589,6 @@ static void __blk_mark_disk_dead(struct gendisk *disk) > if (test_and_set_bit(GD_DEAD, &disk->state)) > return; > > - if (test_bit(GD_OWNS_QUEUE, &disk->state)) > - blk_queue_flag_set(QUEUE_FLAG_DYING, disk->queue); > - > /* > * Stop buffered writers from dirtying pages that can't be written out. > */ > @@ -673,6 +670,9 @@ void del_gendisk(struct gendisk *disk) > drop_partition(part); > mutex_unlock(&disk->open_mutex); > > + if (test_bit(GD_OWNS_QUEUE, &disk->state)) > + blk_queue_flag_set(QUEUE_FLAG_DYING, disk->queue); So that mutex_lock(&disk->open_mutex) right before it potentially can deadlock (I think it will). My idea, thus far, was to if (test_bit(GD_OWNS_QUEUE, &disk->state)) } blk_queue_flag_set(QUEUE_FLAG_DYING, disk->queue); blk_kick_queue_enter(disk->queue); // this one simply wake_up_all(&q->mq_freeze_wq); // if the queue has QUEUE_FLAG_DYING } in del_gendisk() before the very first time del_gendisk() attempts to mutex_lock(&disk->open_mutex), because that mutex is already locked forever. > if (!(disk->flags & GENHD_FL_HIDDEN)) { > sysfs_remove_link(&disk_to_dev(disk)->kobj, "bdi");