From: Akinobu Mita <mita@miraclelinux.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@osdl.org, Akinobu Mita <mita@miraclelinux.com>,
Jens Axboe <axboe@suse.de>, Greg KH <greg@kroah.com>
Subject: [patch 1/3] use kref for blk_queue_tag
Date: Wed, 26 Apr 2006 10:11:00 +0800 [thread overview]
Message-ID: <20060426021121.260553000@localhost.localdomain> (raw)
In-Reply-To: 20060426021059.235216000@localhost.localdomain
[-- Attachment #1: blk-queue-tag-use-kref.patch --]
[-- Type: text/plain, Size: 2369 bytes --]
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
--
next prev parent reply other threads:[~2006-04-26 2:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-26 2:10 [patch 0/3] use kref Akinobu Mita
2006-04-26 2:11 ` Akinobu Mita [this message]
2006-04-26 2:42 ` [patch 1/3] use kref for blk_queue_tag Nick Piggin
2006-04-26 5:17 ` Greg KH
2006-04-26 2:11 ` [patch 2/3] use kref for io_context Akinobu Mita
2006-04-26 2:11 ` [patch 3/3] use kref for bio Akinobu Mita
2006-04-26 2:26 ` Al Viro
2006-04-26 5:13 ` Jens Axboe
2006-04-26 5:18 ` Greg KH
2006-04-26 7:20 ` Akinobu Mita
2006-04-26 7:39 ` Al Viro
2006-04-26 9:29 ` Nick Piggin
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=20060426021121.260553000@localhost.localdomain \
--to=mita@miraclelinux.com \
--cc=akpm@osdl.org \
--cc=axboe@suse.de \
--cc=greg@kroah.com \
--cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.