Re: [PATCH] Fix race with shared tag queue maps

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linus Torvalds <torvalds@...>
Cc: <linux-kernel@...>, <linux-scsi@...>, <orgis@...>, <arekm@...>, <ed.lin@...>, Andrew Morton <akpm@...>, <James.Bottomley@...>
Date: Thursday, September 13, 2007 - 11:22 am

On Thu, Sep 13 2007, Linus Torvalds wrote:

My bad, I think I added the smp_mb__before_clear_bit() when it was
__test_and_set_bit() like in the first hunk.

diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index a15845c..dfc9f22 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -1075,12 +1075,6 @@ void blk_queue_end_tag(struct request_queue *q, struct request *rq)
 		 */
 		return;
 
-	if (unlikely(!__test_and_clear_bit(tag, bqt->tag_map))) {
-		printk(KERN_ERR "%s: attempt to clear non-busy tag (%d)\n",
-		       __FUNCTION__, tag);
-		return;
-	}
-
 	list_del_init(&rq->queuelist);
 	rq->cmd_flags &= ~REQ_QUEUED;
 	rq->tag = -1;
@@ -1090,6 +1084,18 @@ void blk_queue_end_tag(struct request_queue *q, struct request *rq)
 		       __FUNCTION__, tag);
 
 	bqt->tag_index[tag] = NULL;
+
+	if (unlikely(!test_and_clear_bit(tag, bqt->tag_map))) {
+		printk(KERN_ERR "%s: attempt to clear non-busy tag (%d)\n",
+		       __FUNCTION__, tag);
+		return;
+	}
+
+	/*
+	 * Ensure ordering between ->tag_index[tag] clear and tag clear
+	 */
+	smp_mb__after_clear_bit();
+
 	bqt->busy--;
 }
 

-- 
Jens Axboe

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Fix race with shared tag queue maps, Jens Axboe, (Thu Sep 13, 8:26 am)
Re: [PATCH] Fix race with shared tag queue maps, Arkadiusz Miskiewicz, (Fri Sep 14, 2:19 am)
Re: [PATCH] Fix race with shared tag queue maps, Linus Torvalds, (Thu Sep 13, 11:16 am)
Re: [PATCH] Fix race with shared tag queue maps, Jens Axboe, (Thu Sep 13, 11:22 am)
Re: [PATCH] Fix race with shared tag queue maps, Linus Torvalds, (Thu Sep 13, 11:42 am)
Re: [PATCH] Fix race with shared tag queue maps, Jens Axboe, (Fri Sep 14, 3:47 am)