public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Abhijeet Joglekar <ajoglekar@nuovasystems.com>
To: jens.axboe@oracle.com
Cc: linux-scsi@vger.kernel.org, ajoglekar@nuovasystems.com
Subject: [RFC][PATCH] blk-tag: Use atomic_t type for bqt->busy.
Date: Mon, 25 Aug 2008 18:03:30 -0700	[thread overview]
Message-ID: <20080826010306.27375.59063.stgit@feynman.nuovasystems.com> (raw)
In-Reply-To: <20080826005856.27375.59152.stgit@feynman.nuovasystems.com>

blk-tag: Use atomic_t type for bqt->busy.

bqt->busy is an integer that keeps count of number of outstanding tags. For
host-wide shared tag map, busy is accessed in a queue lock (not host lock)
which corrupts the busy value. Change busy to atomic_t and use atomic
macros to access it.

Signed-off-by: Abhijeet Joglekar <abjoglek@cisco.com>
---
 block/blk-tag.c        |    8 ++++----
 include/linux/blkdev.h |    2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)


diff --git a/block/blk-tag.c b/block/blk-tag.c
index 32667be..8f37d08 100644
--- a/block/blk-tag.c
+++ b/block/blk-tag.c
@@ -38,7 +38,7 @@ static int __blk_free_tags(struct blk_queue_tag *bqt)
 
 	retval = atomic_dec_and_test(&bqt->refcnt);
 	if (retval) {
-		BUG_ON(bqt->busy);
+		BUG_ON(atomic_read(&bqt->busy));
 
 		kfree(bqt->tag_index);
 		bqt->tag_index = NULL;
@@ -147,7 +147,7 @@ static struct blk_queue_tag *__blk_queue_init_tags(struct request_queue *q,
 	if (init_tag_map(q, tags, depth))
 		goto fail;
 
-	tags->busy = 0;
+	atomic_set(&tags->busy, 0);
 	atomic_set(&tags->refcnt, 1);
 	return tags;
 fail:
@@ -313,7 +313,7 @@ void blk_queue_end_tag(struct request_queue *q, struct request *rq)
 	 * unlock memory barrier semantics.
 	 */
 	clear_bit_unlock(tag, bqt->tag_map);
-	bqt->busy--;
+	atomic_dec(&bqt->busy);
 }
 EXPORT_SYMBOL(blk_queue_end_tag);
 
@@ -368,7 +368,7 @@ int blk_queue_start_tag(struct request_queue *q, struct request *rq)
 	bqt->tag_index[tag] = rq;
 	blkdev_dequeue_request(rq);
 	list_add(&rq->queuelist, &q->tag_busy_list);
-	bqt->busy++;
+	atomic_inc(&bqt->busy);
 	return 0;
 }
 EXPORT_SYMBOL(blk_queue_start_tag);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 88d6808..106531e 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -274,7 +274,7 @@ enum blk_queue_state {
 struct blk_queue_tag {
 	struct request **tag_index;	/* map of busy tags */
 	unsigned long *tag_map;		/* bit map of free/busy tags */
-	int busy;			/* current depth */
+	atomic_t busy;			/* current depth */
 	int max_depth;			/* what we will send to device */
 	int real_max_depth;		/* what the array can hold */
 	atomic_t refcnt;		/* map can be shared */



  reply	other threads:[~2008-08-26  1:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-26  1:03 [RFC] [PATCH] Potential bug fix for blk_tag_queue Abhijeet Joglekar
2008-08-26  1:03 ` Abhijeet Joglekar [this message]
2008-08-26  2:46 ` Matthew Wilcox
2008-08-26  7:00   ` Jens Axboe
2008-08-26  7:49     ` Abhijeet Joglekar
2008-08-26  8:58       ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080826010306.27375.59063.stgit@feynman.nuovasystems.com \
    --to=ajoglekar@nuovasystems.com \
    --cc=jens.axboe@oracle.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox