Thanks for the patch. We were thinking that requests can take a referenceon io queues and io queues can take a reference on io groups. That shouldmake sure that io groups don't go away as long as active requests arepresent.

But there seems to be a small window while allocating the new requestwhere request gets allocated from a group first and then later it ismapped to that group and queue is created. IOW, in get_request_wait(), we allocate a request from a particular group and set rq->rl, thendrop the queue lock and later call elv_set_request() which again mapsthe request to the group saves rq->iog and creates new queue. This windowis troublesome because request can be mapped to a particular group at thetime of allocation and during set_request() it can go to a differentgroup as queue lock was dropped and group might have disappeared.

In this case probably it might make sense that request also takes areference on groups. At the same time it looks too much that request takesa reference on queue as well as group object. Ideas are welcome on howto handle it...