aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVivek Goyal <vgoyal@redhat.com>2012-03-05 16:15:10 -0500
committerJens Axboe <axboe@kernel.dk>2012-03-06 15:27:22 -0500
commit92616b5b3a7c7fa8148df82e7ff6183056f2bfc8 (patch)
treeb204b7df4753e9508cf15d278688dc9c307761fa
parent7a4dd281ec66224f802093962d1d903d86b09560 (diff)
blkcg: skip blkg printing if q isn't associated with disk
blk-cgroup printing code currently assumes that there is a device/disk associated with every queue in the system, but modules like floppy, can instantiate request queues without registering disk which can lead to oops. Skip the queue/blkg which don't have dev/disk associated with them. -tj: Factored out backing_dev_info check into blkg_dev_name(). Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--block/blk-cgroup.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 8742af3be84b..76942360872b 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -951,13 +951,24 @@ static int blkiocg_file_write(struct cgroup *cgrp, struct cftype *cft,
951 return ret; 951 return ret;
952} 952}
953 953
954static const char *blkg_dev_name(struct blkio_group *blkg)
955{
956 /* some drivers (floppy) instantiate a queue w/o disk registered */
957 if (blkg->q->backing_dev_info.dev)
958 return dev_name(blkg->q->backing_dev_info.dev);
959 return NULL;
960}
961
954static void blkio_print_group_conf(struct cftype *cft, struct blkio_group *blkg, 962static void blkio_print_group_conf(struct cftype *cft, struct blkio_group *blkg,
955 struct seq_file *m) 963 struct seq_file *m)
956{ 964{
957 const char *dname = dev_name(blkg->q->backing_dev_info.dev); 965 const char *dname = blkg_dev_name(blkg);
958 int fileid = BLKIOFILE_ATTR(cft->private); 966 int fileid = BLKIOFILE_ATTR(cft->private);
959 int rw = WRITE; 967 int rw = WRITE;
960 968
969 if (!dname)
970 return;
971
961 switch (blkg->plid) { 972 switch (blkg->plid) {
962 case BLKIO_POLICY_PROP: 973 case BLKIO_POLICY_PROP:
963 if (blkg->conf.weight) 974 if (blkg->conf.weight)
@@ -1049,9 +1060,9 @@ static int blkio_read_blkg_stats(struct blkio_cgroup *blkcg,
1049 1060
1050 rcu_read_lock(); 1061 rcu_read_lock();
1051 hlist_for_each_entry_rcu(blkg, n, &blkcg->blkg_list, blkcg_node) { 1062 hlist_for_each_entry_rcu(blkg, n, &blkcg->blkg_list, blkcg_node) {
1052 const char *dname = dev_name(blkg->q->backing_dev_info.dev); 1063 const char *dname = blkg_dev_name(blkg);
1053 1064
1054 if (BLKIOFILE_POLICY(cft->private) != blkg->plid) 1065 if (!dname || BLKIOFILE_POLICY(cft->private) != blkg->plid)
1055 continue; 1066 continue;
1056 if (pcpu) 1067 if (pcpu)
1057 cgroup_total += blkio_get_stat_cpu(blkg, cb, dname, 1068 cgroup_total += blkio_get_stat_cpu(blkg, cb, dname,