From: Herbert Xu Here is an updated patch which removes the active_req wait in nbd_clear_queue and the associated memory barrier. I've also clarified this in the comment. Signed-off-by: Herbert Xu Cc: Cc: Paul Clements Signed-off-by: Andrew Morton --- drivers/block/nbd.c | 11 +++++++---- linux/nbd.h | 0 2 files changed, 7 insertions(+), 4 deletions(-) diff -puN drivers/block/nbd.c~nbd-fix-tx-rx-race-condition-update drivers/block/nbd.c --- devel/drivers/block/nbd.c~nbd-fix-tx-rx-race-condition-update 2005-11-19 16:25:04.000000000 -0800 +++ devel-akpm/drivers/block/nbd.c 2005-11-19 16:25:04.000000000 -0800 @@ -403,12 +403,15 @@ static void nbd_clear_que(struct nbd_dev BUG_ON(lo->magic != LO_MAGIC); /* - * lo->sock == NULL guarantees that the queue will not grow beyond the - * current active request. + * Because we have set lo->sock to NULL under the tx_lock, all + * modifications to the list must have completed by now. For + * the same reason, the active_req must be NULL. + * + * As a consequence, we don't need to take the spin lock while + * purging the list here. */ BUG_ON(lo->sock); - wait_event(lo->active_wq, !lo->active_req); - smp_rmb(); + BUG_ON(lo->active_req); while (!list_empty(&lo->queue_head)) { req = list_entry(lo->queue_head.next, struct request, diff -puN include/linux/nbd.h~nbd-fix-tx-rx-race-condition-update include/linux/nbd.h _