Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761569AbXIMPWt (ORCPT ); Thu, 13 Sep 2007 11:22:49 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750866AbXIMPWj (ORCPT ); Thu, 13 Sep 2007 11:22:39 -0400 Received: from brick.kernel.dk ([87.55.233.238]:28659 "EHLO kernel.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756203AbXIMPWi (ORCPT ); Thu, 13 Sep 2007 11:22:38 -0400 Date: Thu, 13 Sep 2007 17:22:23 +0200 From: Jens Axboe To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, orgis@agnld.uni-potsdam.de, arekm@maven.pl, ed.lin@promise.com, Andrew Morton , James.Bottomley@SteelEye.com Subject: Re: [PATCH] Fix race with shared tag queue maps Message-ID: <20070913152222.GS25592@kernel.dk> References: <20070913122652.GK25592@kernel.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1886 Lines: 68 On Thu, Sep 13 2007, Linus Torvalds wrote: > > > On Thu, 13 Sep 2007, Jens Axboe wrote: > > + > > + /* > > + * Ensure ordering with tag section > > + */ > > + smp_mb__before_clear_bit(); > > + > > + if (unlikely(!test_and_clear_bit(tag, bqt->tag_map))) { > > You don't need the "smp_mb__before_clear_bit()" there. > > The regular "clear_bit()" needs it, but the "test_and_xxx()" versions are > architecturally defined to be memory barriers, exactly because they are > regularly used for locking. > > This is even documented - see Documentation/atomic_ops.txt. 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 - 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/