lkml.org 
[lkml]   [2006]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch 1/3] use kref for blk_queue_tag
Use kref for reference counter of blk_queue_tag.

Signed-off-by: Akinobu Mita <mita@miraclelinux.com>
CC: Jens Axboe <axboe@suse.de>
CC: Greg KH <greg@kroah.com>

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 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/

\
 
 \ /
  Last update: 2006-04-26 04:14    [W:0.076 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site