Bogdan Harjoc wrote:
Hi, It may well be the case that I misunderstood the description in the README for the uniprocessor deadlock problem, but from what I can tell, appending NBD_CMD_WRITE requests to a queue and returning with err=0 immediately instead of eventually blocking while calling write(2) should avoid the deadlock (would having to touch the swap device change anything ?). Although probably not that useful in general, I would be grateful for any comments on whether it should work or not.
I am not sure that the deadlock described in the README even exists, this looks to me like just another instance of the memory inversion deadlock problem which manifests in at least one form in NBD: 1. The daemon may use a syscall that allocates memory (e.g., write) 2. But the kernel is completely out of memory 3. So the daemon blocks 4. But the kernel needs to write out dirty memory over the blocked daemon 5. Oops. The solution to this is not pretty. It starts with memlock_all and continues with hackery to give the daemon access to some of the kernel memory normally reserved for the vm system. I will be coding up an in-kernel NBD-like daemon pretty soon which attempts to address this and other problems. As for fixing it in user space... good luck. It's possible but you won't get it done this afternoon. Regards, Daniel