Add_disk () hangs on insmod

I am writing a Linux block device driver, and I have a lot of work with initialization. However, when I finally call add_disk() , the module freezes during insmod .

The negative snippet is here:

 set_capacity(gendisk, dev->nsectors); add_disk(gendisk); //this line is never reached 
+6
source share
1 answer

This seems to be caused by setting the capacity with set_capacity() before adding the disk. According to this mailing list , add_disk should be called in gendisk with gendisk->capacity = 0 , otherwise it hangs in check_partition() .

The following will appear:

 set_capacity(gendisk, 0) add_disk(gendisk); set_capacity(gendisk, dev->nsectors); 
+6
source

All Articles