[patch 1/3] use kref for blk_queue_tag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use kref for reference counter of blk_queue_tag.

Signed-off-by: Akinobu Mita <[email protected]>
CC: Jens Axboe <[email protected]>
CC: Greg KH <[email protected]>

 block/ll_rw_blk.c      |   35 ++++++++++++++++++++---------------
 include/linux/blkdev.h |    2 +-
 2 files changed, 21 insertions(+), 16 deletions(-)

Index: 2.6-git/block/ll_rw_blk.c
===================================================================
--- 2.6-git.orig/block/ll_rw_blk.c
+++ 2.6-git/block/ll_rw_blk.c
@@ -848,6 +848,23 @@ struct request *blk_queue_find_tag(reque
 
 EXPORT_SYMBOL(blk_queue_find_tag);
 
+static void release_blk_queue_tag(struct kref *kref)
+{
+	struct blk_queue_tag *bqt = container_of(kref, struct blk_queue_tag,
+			kref);
+
+	BUG_ON(bqt->busy);
+	BUG_ON(!list_empty(&bqt->busy_list));
+
+	kfree(bqt->tag_index);
+	bqt->tag_index = NULL;
+
+	kfree(bqt->tag_map);
+	bqt->tag_map = NULL;
+
+	kfree(bqt);
+}
+
 /**
  * __blk_queue_free_tags - release tag maintenance info
  * @q:  the request queue for the device
@@ -863,19 +880,7 @@ static void __blk_queue_free_tags(reques
 	if (!bqt)
 		return;
 
-	if (atomic_dec_and_test(&bqt->refcnt)) {
-		BUG_ON(bqt->busy);
-		BUG_ON(!list_empty(&bqt->busy_list));
-
-		kfree(bqt->tag_index);
-		bqt->tag_index = NULL;
-
-		kfree(bqt->tag_map);
-		bqt->tag_map = NULL;
-
-		kfree(bqt);
-	}
-
+	kref_put(&bqt->kref, release_blk_queue_tag);
 	q->queue_tags = NULL;
 	q->queue_flags &= ~(1 << QUEUE_FLAG_QUEUED);
 }
@@ -951,14 +956,14 @@ int blk_queue_init_tags(request_queue_t 
 
 		INIT_LIST_HEAD(&tags->busy_list);
 		tags->busy = 0;
-		atomic_set(&tags->refcnt, 1);
+		kref_init(&tags->kref);
 	} else if (q->queue_tags) {
 		if ((rc = blk_queue_resize_tags(q, depth)))
 			return rc;
 		set_bit(QUEUE_FLAG_QUEUED, &q->queue_flags);
 		return 0;
 	} else
-		atomic_inc(&tags->refcnt);
+		kref_get(&tags->kref);
 
 	/*
 	 * assign it, all done
Index: 2.6-git/include/linux/blkdev.h
===================================================================
--- 2.6-git.orig/include/linux/blkdev.h
+++ 2.6-git/include/linux/blkdev.h
@@ -315,7 +315,7 @@ struct blk_queue_tag {
 	int 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 */
+	struct kref kref;		/* map can be shared */
 };
 
 struct request_queue

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

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux