lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100325180428.25299.27250.stgit@meat.mtv.corp.google.com>
Date:	Thu, 25 Mar 2010 11:04:28 -0700
From:	Chad Talbott <ctalbott@...gle.com>
To:	vgoyal@...hat.com, jens.axboe@...cle.com
Cc:	mrubin@...gle.com, guijianfeng@...fujitsu.com,
	Li Zefan <lizf@...fujitsu.com>, linux-kernel@...r.kernel.org,
	dpshah@...gle.com, Nauman Rafique <nauman@...gle.com>
Subject: [PATCH 2/4] Adds an RCU-protected pointer to request_queue that makes
	it easy to

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

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ