Re: PATCH: Fix nbd on 2.1.118 SMP kernels

Linus Torvalds (torvalds@transmeta.com)
Thu, 27 Aug 1998 11:40:43 -0700 (PDT)


On Thu, 27 Aug 1998, Stephen C. Tweedie wrote:
>
> The fix is to replace some of the spin_lock_irq/spin_unlock_irq pairs
> with irqsave/irqrestore versions, and to forcibly drop the io request
> spinlock inside do_nbd_request before calling out to the network.

It's otherwise ok, but this part is certainly buggy:

> @@ -296,7 +303,12 @@
> #endif
> req->errors = 0;
>
> + spin_unlock_irq(&io_request_lock);
> nbd_send_req(lo->sock, req); /* Why does this block? */
> + spin_lock_irq(&io_request_lock);
> +
> + if (CURRENT != req)
> + FAIL("CURRENT was modified");
> CURRENT = CURRENT->next;
> req->next = NULL;
> if (lo->head == NULL) {

If you drop the io-request lock, and then not expect CURRENT to change,
you're just fooling yourself. That's like saying "oh, btw, I now let
people change the CURRENT queue, but by God if anybody actually does so
I'll panic". That's just too stupid for me to accept as a patch.

As far as I can tell, the code will unlink the request immediately
afterwards anyway, so the fix is to just unlink it _before_ dropping the
IO request lock, so that we don't have to worry about the request lists
any more.

Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html