[NBD] Use per-device semaphore instead of BKL

From: Herbert Xu (herbert_at_gondor.apana.org.au)
Date: 11/20/05

  • Next message: Rogério Brito: "Re: Does Linux support powering down SATA drives?"
    Date:	Sun, 20 Nov 2005 12:58:07 +1100
    To: Paul Clements <paul.clements@steeleye.com>
    
    
    

    On Sun, Nov 20, 2005 at 09:34:19AM +1100, herbert wrote:
    >
    > This is intentional actually. nbd_clear_queue never races against
    > nbd_find_request because the ioctl is protected by the BKL. If it
    > weren't, then we have much worse problems to worry about (e.g.,
    > while you're clearing the queue someone else could have set the
    > socket again and started queueing requests).

    Actually, we do have bigger problems :) The BKL is dropped every
    time you sleep, and nbd_do_it is definitely a frequent sleeper :)

    This isn't really an issue in practice though because the NBD
    client program is single-threaded and doesn't share its file
    descriptors with anyone else.

    However, we shouldn't make it too easy for the user to shoot himself
    in the foot. If he's going to do that, let him at least pay for the
    bullet :)

    So here is a patch to use a per-device semaphore instead of the
    BKL to protect the ioctl's against each other.

    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

    Cheers,

    -- 
    Visit Openswan at http://www.openswan.org/
    Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
    Home Page: http://gondor.apana.org.au/~herbert/
    PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
    
    

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/



  • Next message: Rogério Brito: "Re: Does Linux support powering down SATA drives?"

    Relevant Pages


    Loading