[ENBD] Kernel oops (nbd-2.4.31) or failed connections
Anders Blomdell
anders.blomdell at control.lth.se
Mon May 24 03:34:21 MDT 2004
> I do not believe the window will be so common that it merits closing.
> It will be rare. And the open, if it succeeds, will have to find the
> device still there, and then have it be killed by the other thread, for
> harm to be done ... looks very unlikely.
If this is your position on how to write server code, I'll not use enbd
8^(
> I'll study that section of code a bit to see if there's a short section
> that can be protected. Essentially, we don't want to start protecting
> all accesses to the device with a semaphore!
Nope, but the following is a must:
open:
down(enbd_sem);
if (enbd_dev[nbd] == NULL) {
enbd_dev[nbd] = kmalloc(...);
...
enbd_dev[nbd]->refcnt++;
}
up(enbd_sem);
release:
to_be_destroyed = NULL;
down(enbd_sem);
// can enbd_dev[nbd] be NULL??
enbd_dev[nbd]->refcnt--;
if (enbd_dev[nbd]->refcnt <= 0) {
to_be_destroyed = enbd_dev[nbd];
enbd_dev[nbd] = NULL;
}
up(enbd_sem);
if (to_be_destroyed) {
enbd_destroy(to_be_destroyed);
}
Regards
Anders Blomdell
More information about the ENBD
mailing list