On Tue, Sep 17, 2019 at 02:44:09PM -0500, Mike Christie wrote: > On 09/17/2019 01:40 PM, Josef Bacik wrote: > >>> + nbd->destroy_complete = &destroy_complete; > >> > >> Also, without the mutex part of the v3 patch, we could race and > >> nbd_dev_remove could have passed the destroy_complete check already, so > >> below we will wait forever. > >> > > > > Oh hmm you're right, > > I think I am actually wrong about that part too now :) I had forgot > about the idr removal under the mutex when making my original comment. > > If nbd_put grabs the mutex first then it will do idr_remove under the > mutex. If nbd_genl_connect then runs, idr_find/idr_for_each will fail > and we will allocate a new nbd device and NBD_DISCONNECT_REQUESTED will > not be set. > > If nbd_genl_connect grabs the mutex first, then idr_find/idr_for_each > will succeed and we will set the completion. nbd_put will then grab the > mutex and call nbd_remove_dev and see the completion. Lol we're all wrong. I had it in my head that complete() just did a set_bit() so wait_on_completion() would not wait, but it does the x->done++/x->done-- thing, so cool we're good here. Thanks, Josef