[ENBD] /proc/nbdinfo

Peter T. Breuer ptb at it.uc3m.es
Wed Jan 7 09:53:11 MST 2004


"Also sprach Peter T. Breuer:"
> There are some race conditions leading up to the destroy, btw.

I might add that there is no obvious way to get rid of them completely.
I can see why I did not insert that code myself.

The main problem is that when we do kfree(lo), there may still be other
processes executing a spinlock wait on &lo->meta_lock, for example.
They will be threads who are hoping to talk to the device but haven't
yet got in there, being locked out by our occupation of all the
device-specific locks. 

They'll get very ill if the spinlock they are spinning on is returned
to the kernel heap!

This will happen if you try and open the device just after having sent
the "reset" order, for example.

The best I can do is take the driver semaphore, look at the reference
counter under write lock (must be zero), vamoosh the device, then
release the driver semaphore.

I really would feel better if you would perhaps just do something like


        
        write_lock(&lo->meta_lock);
        if (atomic_read(&lo->refcnt) > 0) {
             write_unlock(&lo->meta_lock);
             return;
        }

        lo->nslot = 0;
        atomic_set(&lo->flags, 0)
        write_unlock(&lo->meta_lock);

and see how that goes. I suspect it will make things LOOK the way you
want them to look. If not quite, we can get there in a couple more
iterations. 


Peter




More information about the ENBD mailing list