mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chad Talbott <ctalbott@google.com>
To: vgoyal@redhat.com, jens.axboe@oracle.com
Cc: mrubin@google.com, guijianfeng@cn.fujitsu.com,
	Li Zefan <lizf@cn.fujitsu.com>,
	linux-kernel@vger.kernel.org, dpshah@google.com,
	Nauman Rafique <nauman@google.com>
Subject: [PATCH 2/4] Adds an RCU-protected pointer to request_queue that makes it easy to
Date: Thu, 25 Mar 2010 11:04:28 -0700	[thread overview]
Message-ID: <20100325180428.25299.27250.stgit@meat.mtv.corp.google.com> (raw)
In-Reply-To: <20100325180310.25299.64877.stgit@meat.mtv.corp.google.com>

find the gendisk that the queue manages.
---
 block/blk-cgroup.c     |   10 ++++++----
 block/blk-sysfs.c      |    4 ++++
 include/linux/blkdev.h |    6 ++++++
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 917957d..809451f 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -179,16 +179,18 @@ static int blkiocg_##__VAR##_read(struct cgroup *cgroup,		\
 	struct blkio_cgroup *blkcg;					\
 	struct blkio_group *blkg;					\
 	struct hlist_node *n;						\
+	struct gendisk *disk;						\
 									\
 	if (!cgroup_lock_live_group(cgroup))				\
 		return -ENODEV;						\
 									\
 	blkcg = cgroup_to_blkio_cgroup(cgroup);				\
 	rcu_read_lock();						\
-	hlist_for_each_entry_rcu(blkg, n, &blkcg->blkg_list, blkcg_node) {\
-		if (blkg->dev)						\
-			seq_printf(m, "%u:%u %lu\n", MAJOR(blkg->dev),	\
-				 MINOR(blkg->dev), blkg->__VAR);	\
+	hlist_for_each_entry_rcu(blkg, n, &blkcg->blkg_list, blkcg_node) { \
+		disk = rcu_dereference(blkg->queue->disk);		\
+		if (disk)						\
+			seq_printf(m, "%s %lu\n", disk->disk_name,	\
+				   blkg->__VAR);			\
 	}								\
 	rcu_read_unlock();						\
 	cgroup_unlock();						\
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 2ae2cb3..14cab6a 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -484,6 +484,8 @@ int blk_register_queue(struct gendisk *disk)
 	if (!q->request_fn)
 		return 0;
 
+	rcu_assign_pointer(q->disk, disk);
+
 	ret = elv_register_queue(q);
 	if (ret) {
 		kobject_uevent(&q->kobj, KOBJ_REMOVE);
@@ -505,6 +507,8 @@ void blk_unregister_queue(struct gendisk *disk)
 	if (q->request_fn)
 		elv_unregister_queue(q);
 
+	rcu_assign_pointer(q->disk, NULL);
+
 	kobject_uevent(&q->kobj, KOBJ_REMOVE);
 	kobject_del(&q->kobj);
 	blk_trace_remove_sysfs(disk_to_dev(disk));
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index ebd22db..e531cf2 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -441,6 +441,12 @@ struct request_queue
 #if defined(CONFIG_BLK_DEV_BSG)
 	struct bsg_class_device bsg_dev;
 #endif
+
+	/*
+	 * an RCU-protected pointer that can be NULL when devices are
+	 * removed
+	 */
+	struct gendisk		*disk;
 };
 
 #define QUEUE_FLAG_CLUSTER	0	/* cluster several segments into 1 */


  parent reply	other threads:[~2010-03-25 18:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-25 18:04 [PATCH 0/4] io-controller: Use names rather than major:minor Chad Talbott
2010-03-25 18:04 ` [PATCH 1/4] blkio_group key change: void * -> request_queue * Chad Talbott
2010-03-25 23:25   ` Vivek Goyal
2010-03-26  0:17     ` Chad Talbott
2010-03-25 18:04 ` Chad Talbott [this message]
2010-03-25 23:02   ` [PATCH 2/4] Adds an RCU-protected pointer to request_queue that makes it easy to Vivek Goyal
2010-03-25 18:04 ` [PATCH 3/4] io-controller: Add a new interface "weight_device" for IO-Controller Chad Talbott
2010-03-25 18:04 ` [PATCH 4/4] Use disk-names to set blkio.weight_device policy Chad Talbott
2010-03-26  1:31 ` [PATCH 0/4] io-controller: Use names rather than major:minor Gui Jianfeng
2010-03-26 15:20   ` Vivek Goyal
2010-03-26 22:54     ` Chad Talbott
2010-03-26 23:21       ` Divyesh Shah
2010-03-27  0:28         ` Vivek Goyal
2010-03-27  0:20       ` Vivek Goyal
2010-03-27  0:24         ` Vivek Goyal
2010-03-27  0:30           ` Vivek Goyal

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=20100325180428.25299.27250.stgit@meat.mtv.corp.google.com \
    --to=ctalbott@google.com \
    --cc=dpshah@google.com \
    --cc=guijianfeng@cn.fujitsu.com \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=mrubin@google.com \
    --cc=nauman@google.com \
    --cc=vgoyal@redhat.com \
    /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

Powered by JetHome