diff options
Diffstat (limited to 'block/cfq-iosched.c')
| -rw-r--r-- | block/cfq-iosched.c | 203 | 
1 files changed, 105 insertions, 98 deletions
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index dabb9d02cf9..cadc3784174 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c @@ -908,7 +908,7 @@ static inline void cfq_schedule_dispatch(struct cfq_data *cfqd)  {  	if (cfqd->busy_queues) {  		cfq_log(cfqd, "schedule dispatch"); -		kblockd_schedule_work(cfqd->queue, &cfqd->unplug_work); +		kblockd_schedule_work(&cfqd->unplug_work);  	}  } @@ -1508,6 +1508,29 @@ static void cfq_init_cfqg_base(struct cfq_group *cfqg)  }  #ifdef CONFIG_CFQ_GROUP_IOSCHED +static void cfqg_stats_init(struct cfqg_stats *stats) +{ +	blkg_rwstat_init(&stats->service_bytes); +	blkg_rwstat_init(&stats->serviced); +	blkg_rwstat_init(&stats->merged); +	blkg_rwstat_init(&stats->service_time); +	blkg_rwstat_init(&stats->wait_time); +	blkg_rwstat_init(&stats->queued); + +	blkg_stat_init(&stats->sectors); +	blkg_stat_init(&stats->time); + +#ifdef CONFIG_DEBUG_BLK_CGROUP +	blkg_stat_init(&stats->unaccounted_time); +	blkg_stat_init(&stats->avg_queue_size_sum); +	blkg_stat_init(&stats->avg_queue_size_samples); +	blkg_stat_init(&stats->dequeue); +	blkg_stat_init(&stats->group_wait_time); +	blkg_stat_init(&stats->idle_time); +	blkg_stat_init(&stats->empty_time); +#endif +} +  static void cfq_pd_init(struct blkcg_gq *blkg)  {  	struct cfq_group *cfqg = blkg_to_cfqg(blkg); @@ -1515,6 +1538,8 @@ static void cfq_pd_init(struct blkcg_gq *blkg)  	cfq_init_cfqg_base(cfqg);  	cfqg->weight = blkg->blkcg->cfq_weight;  	cfqg->leaf_weight = blkg->blkcg->cfq_leaf_weight; +	cfqg_stats_init(&cfqg->stats); +	cfqg_stats_init(&cfqg->dead_stats);  }  static void cfq_pd_offline(struct blkcg_gq *blkg) @@ -1607,11 +1632,11 @@ static u64 cfqg_prfill_weight_device(struct seq_file *sf,  	return __blkg_prfill_u64(sf, pd, cfqg->dev_weight);  } -static int cfqg_print_weight_device(struct cgroup_subsys_state *css, -				    struct cftype *cft, struct seq_file *sf) +static int cfqg_print_weight_device(struct seq_file *sf, void *v)  { -	blkcg_print_blkgs(sf, css_to_blkcg(css), cfqg_prfill_weight_device, -			  &blkcg_policy_cfq, 0, false); +	blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), +			  cfqg_prfill_weight_device, &blkcg_policy_cfq, +			  0, false);  	return 0;  } @@ -1625,34 +1650,31 @@ static u64 cfqg_prfill_leaf_weight_device(struct seq_file *sf,  	return __blkg_prfill_u64(sf, pd, cfqg->dev_leaf_weight);  } -static int cfqg_print_leaf_weight_device(struct cgroup_subsys_state *css, -					 struct cftype *cft, -					 struct seq_file *sf) +static int cfqg_print_leaf_weight_device(struct seq_file *sf, void *v)  { -	blkcg_print_blkgs(sf, css_to_blkcg(css), cfqg_prfill_leaf_weight_device, -			  &blkcg_policy_cfq, 0, false); +	blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), +			  cfqg_prfill_leaf_weight_device, &blkcg_policy_cfq, +			  0, false);  	return 0;  } -static int cfq_print_weight(struct cgroup_subsys_state *css, struct cftype *cft, -			    struct seq_file *sf) +static int cfq_print_weight(struct seq_file *sf, void *v)  { -	seq_printf(sf, "%u\n", css_to_blkcg(css)->cfq_weight); +	seq_printf(sf, "%u\n", css_to_blkcg(seq_css(sf))->cfq_weight);  	return 0;  } -static int cfq_print_leaf_weight(struct cgroup_subsys_state *css, -				 struct cftype *cft, struct seq_file *sf) +static int cfq_print_leaf_weight(struct seq_file *sf, void *v)  { -	seq_printf(sf, "%u\n", css_to_blkcg(css)->cfq_leaf_weight); +	seq_printf(sf, "%u\n", css_to_blkcg(seq_css(sf))->cfq_leaf_weight);  	return 0;  } -static int __cfqg_set_weight_device(struct cgroup_subsys_state *css, -				    struct cftype *cft, const char *buf, -				    bool is_leaf_weight) +static ssize_t __cfqg_set_weight_device(struct kernfs_open_file *of, +					char *buf, size_t nbytes, loff_t off, +					bool is_leaf_weight)  { -	struct blkcg *blkcg = css_to_blkcg(css); +	struct blkcg *blkcg = css_to_blkcg(of_css(of));  	struct blkg_conf_ctx ctx;  	struct cfq_group *cfqg;  	int ret; @@ -1675,19 +1697,19 @@ static int __cfqg_set_weight_device(struct cgroup_subsys_state *css,  	}  	blkg_conf_finish(&ctx); -	return ret; +	return ret ?: nbytes;  } -static int cfqg_set_weight_device(struct cgroup_subsys_state *css, -				  struct cftype *cft, const char *buf) +static ssize_t cfqg_set_weight_device(struct kernfs_open_file *of, +				      char *buf, size_t nbytes, loff_t off)  { -	return __cfqg_set_weight_device(css, cft, buf, false); +	return __cfqg_set_weight_device(of, buf, nbytes, off, false);  } -static int cfqg_set_leaf_weight_device(struct cgroup_subsys_state *css, -				       struct cftype *cft, const char *buf) +static ssize_t cfqg_set_leaf_weight_device(struct kernfs_open_file *of, +					   char *buf, size_t nbytes, loff_t off)  { -	return __cfqg_set_weight_device(css, cft, buf, true); +	return __cfqg_set_weight_device(of, buf, nbytes, off, true);  }  static int __cfq_set_weight(struct cgroup_subsys_state *css, struct cftype *cft, @@ -1737,23 +1759,17 @@ static int cfq_set_leaf_weight(struct cgroup_subsys_state *css,  	return __cfq_set_weight(css, cft, val, true);  } -static int cfqg_print_stat(struct cgroup_subsys_state *css, struct cftype *cft, -			   struct seq_file *sf) +static int cfqg_print_stat(struct seq_file *sf, void *v)  { -	struct blkcg *blkcg = css_to_blkcg(css); - -	blkcg_print_blkgs(sf, blkcg, blkg_prfill_stat, &blkcg_policy_cfq, -			  cft->private, false); +	blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), blkg_prfill_stat, +			  &blkcg_policy_cfq, seq_cft(sf)->private, false);  	return 0;  } -static int cfqg_print_rwstat(struct cgroup_subsys_state *css, -			     struct cftype *cft, struct seq_file *sf) +static int cfqg_print_rwstat(struct seq_file *sf, void *v)  { -	struct blkcg *blkcg = css_to_blkcg(css); - -	blkcg_print_blkgs(sf, blkcg, blkg_prfill_rwstat, &blkcg_policy_cfq, -			  cft->private, true); +	blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), blkg_prfill_rwstat, +			  &blkcg_policy_cfq, seq_cft(sf)->private, true);  	return 0;  } @@ -1773,23 +1789,19 @@ static u64 cfqg_prfill_rwstat_recursive(struct seq_file *sf,  	return __blkg_prfill_rwstat(sf, pd, &sum);  } -static int cfqg_print_stat_recursive(struct cgroup_subsys_state *css, -				     struct cftype *cft, struct seq_file *sf) +static int cfqg_print_stat_recursive(struct seq_file *sf, void *v)  { -	struct blkcg *blkcg = css_to_blkcg(css); - -	blkcg_print_blkgs(sf, blkcg, cfqg_prfill_stat_recursive, -			  &blkcg_policy_cfq, cft->private, false); +	blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), +			  cfqg_prfill_stat_recursive, &blkcg_policy_cfq, +			  seq_cft(sf)->private, false);  	return 0;  } -static int cfqg_print_rwstat_recursive(struct cgroup_subsys_state *css, -				       struct cftype *cft, struct seq_file *sf) +static int cfqg_print_rwstat_recursive(struct seq_file *sf, void *v)  { -	struct blkcg *blkcg = css_to_blkcg(css); - -	blkcg_print_blkgs(sf, blkcg, cfqg_prfill_rwstat_recursive, -			  &blkcg_policy_cfq, cft->private, true); +	blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), +			  cfqg_prfill_rwstat_recursive, &blkcg_policy_cfq, +			  seq_cft(sf)->private, true);  	return 0;  } @@ -1803,20 +1815,18 @@ static u64 cfqg_prfill_avg_queue_size(struct seq_file *sf,  	if (samples) {  		v = blkg_stat_read(&cfqg->stats.avg_queue_size_sum); -		do_div(v, samples); +		v = div64_u64(v, samples);  	}  	__blkg_prfill_u64(sf, pd, v);  	return 0;  }  /* print avg_queue_size */ -static int cfqg_print_avg_queue_size(struct cgroup_subsys_state *css, -				     struct cftype *cft, struct seq_file *sf) +static int cfqg_print_avg_queue_size(struct seq_file *sf, void *v)  { -	struct blkcg *blkcg = css_to_blkcg(css); - -	blkcg_print_blkgs(sf, blkcg, cfqg_prfill_avg_queue_size, -			  &blkcg_policy_cfq, 0, false); +	blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), +			  cfqg_prfill_avg_queue_size, &blkcg_policy_cfq, +			  0, false);  	return 0;  }  #endif	/* CONFIG_DEBUG_BLK_CGROUP */ @@ -1826,14 +1836,13 @@ static struct cftype cfq_blkcg_files[] = {  	{  		.name = "weight_device",  		.flags = CFTYPE_ONLY_ON_ROOT, -		.read_seq_string = cfqg_print_leaf_weight_device, -		.write_string = cfqg_set_leaf_weight_device, -		.max_write_len = 256, +		.seq_show = cfqg_print_leaf_weight_device, +		.write = cfqg_set_leaf_weight_device,  	},  	{  		.name = "weight",  		.flags = CFTYPE_ONLY_ON_ROOT, -		.read_seq_string = cfq_print_leaf_weight, +		.seq_show = cfq_print_leaf_weight,  		.write_u64 = cfq_set_leaf_weight,  	}, @@ -1841,26 +1850,24 @@ static struct cftype cfq_blkcg_files[] = {  	{  		.name = "weight_device",  		.flags = CFTYPE_NOT_ON_ROOT, -		.read_seq_string = cfqg_print_weight_device, -		.write_string = cfqg_set_weight_device, -		.max_write_len = 256, +		.seq_show = cfqg_print_weight_device, +		.write = cfqg_set_weight_device,  	},  	{  		.name = "weight",  		.flags = CFTYPE_NOT_ON_ROOT, -		.read_seq_string = cfq_print_weight, +		.seq_show = cfq_print_weight,  		.write_u64 = cfq_set_weight,  	},  	{  		.name = "leaf_weight_device", -		.read_seq_string = cfqg_print_leaf_weight_device, -		.write_string = cfqg_set_leaf_weight_device, -		.max_write_len = 256, +		.seq_show = cfqg_print_leaf_weight_device, +		.write = cfqg_set_leaf_weight_device,  	},  	{  		.name = "leaf_weight", -		.read_seq_string = cfq_print_leaf_weight, +		.seq_show = cfq_print_leaf_weight,  		.write_u64 = cfq_set_leaf_weight,  	}, @@ -1868,114 +1875,114 @@ static struct cftype cfq_blkcg_files[] = {  	{  		.name = "time",  		.private = offsetof(struct cfq_group, stats.time), -		.read_seq_string = cfqg_print_stat, +		.seq_show = cfqg_print_stat,  	},  	{  		.name = "sectors",  		.private = offsetof(struct cfq_group, stats.sectors), -		.read_seq_string = cfqg_print_stat, +		.seq_show = cfqg_print_stat,  	},  	{  		.name = "io_service_bytes",  		.private = offsetof(struct cfq_group, stats.service_bytes), -		.read_seq_string = cfqg_print_rwstat, +		.seq_show = cfqg_print_rwstat,  	},  	{  		.name = "io_serviced",  		.private = offsetof(struct cfq_group, stats.serviced), -		.read_seq_string = cfqg_print_rwstat, +		.seq_show = cfqg_print_rwstat,  	},  	{  		.name = "io_service_time",  		.private = offsetof(struct cfq_group, stats.service_time), -		.read_seq_string = cfqg_print_rwstat, +		.seq_show = cfqg_print_rwstat,  	},  	{  		.name = "io_wait_time",  		.private = offsetof(struct cfq_group, stats.wait_time), -		.read_seq_string = cfqg_print_rwstat, +		.seq_show = cfqg_print_rwstat,  	},  	{  		.name = "io_merged",  		.private = offsetof(struct cfq_group, stats.merged), -		.read_seq_string = cfqg_print_rwstat, +		.seq_show = cfqg_print_rwstat,  	},  	{  		.name = "io_queued",  		.private = offsetof(struct cfq_group, stats.queued), -		.read_seq_string = cfqg_print_rwstat, +		.seq_show = cfqg_print_rwstat,  	},  	/* the same statictics which cover the cfqg and its descendants */  	{  		.name = "time_recursive",  		.private = offsetof(struct cfq_group, stats.time), -		.read_seq_string = cfqg_print_stat_recursive, +		.seq_show = cfqg_print_stat_recursive,  	},  	{  		.name = "sectors_recursive",  		.private = offsetof(struct cfq_group, stats.sectors), -		.read_seq_string = cfqg_print_stat_recursive, +		.seq_show = cfqg_print_stat_recursive,  	},  	{  		.name = "io_service_bytes_recursive",  		.private = offsetof(struct cfq_group, stats.service_bytes), -		.read_seq_string = cfqg_print_rwstat_recursive, +		.seq_show = cfqg_print_rwstat_recursive,  	},  	{  		.name = "io_serviced_recursive",  		.private = offsetof(struct cfq_group, stats.serviced), -		.read_seq_string = cfqg_print_rwstat_recursive, +		.seq_show = cfqg_print_rwstat_recursive,  	},  	{  		.name = "io_service_time_recursive",  		.private = offsetof(struct cfq_group, stats.service_time), -		.read_seq_string = cfqg_print_rwstat_recursive, +		.seq_show = cfqg_print_rwstat_recursive,  	},  	{  		.name = "io_wait_time_recursive",  		.private = offsetof(struct cfq_group, stats.wait_time), -		.read_seq_string = cfqg_print_rwstat_recursive, +		.seq_show = cfqg_print_rwstat_recursive,  	},  	{  		.name = "io_merged_recursive",  		.private = offsetof(struct cfq_group, stats.merged), -		.read_seq_string = cfqg_print_rwstat_recursive, +		.seq_show = cfqg_print_rwstat_recursive,  	},  	{  		.name = "io_queued_recursive",  		.private = offsetof(struct cfq_group, stats.queued), -		.read_seq_string = cfqg_print_rwstat_recursive, +		.seq_show = cfqg_print_rwstat_recursive,  	},  #ifdef CONFIG_DEBUG_BLK_CGROUP  	{  		.name = "avg_queue_size", -		.read_seq_string = cfqg_print_avg_queue_size, +		.seq_show = cfqg_print_avg_queue_size,  	},  	{  		.name = "group_wait_time",  		.private = offsetof(struct cfq_group, stats.group_wait_time), -		.read_seq_string = cfqg_print_stat, +		.seq_show = cfqg_print_stat,  	},  	{  		.name = "idle_time",  		.private = offsetof(struct cfq_group, stats.idle_time), -		.read_seq_string = cfqg_print_stat, +		.seq_show = cfqg_print_stat,  	},  	{  		.name = "empty_time",  		.private = offsetof(struct cfq_group, stats.empty_time), -		.read_seq_string = cfqg_print_stat, +		.seq_show = cfqg_print_stat,  	},  	{  		.name = "dequeue",  		.private = offsetof(struct cfq_group, stats.dequeue), -		.read_seq_string = cfqg_print_stat, +		.seq_show = cfqg_print_stat,  	},  	{  		.name = "unaccounted_time",  		.private = offsetof(struct cfq_group, stats.unaccounted_time), -		.read_seq_string = cfqg_print_stat, +		.seq_show = cfqg_print_stat,  	},  #endif	/* CONFIG_DEBUG_BLK_CGROUP */  	{ }	/* terminate */ @@ -2357,10 +2364,10 @@ cfq_merged_requests(struct request_queue *q, struct request *rq,  	 * reposition in fifo if next is older than rq  	 */  	if (!list_empty(&rq->queuelist) && !list_empty(&next->queuelist) && -	    time_before(rq_fifo_time(next), rq_fifo_time(rq)) && +	    time_before(next->fifo_time, rq->fifo_time) &&  	    cfqq == RQ_CFQQ(next)) {  		list_move(&rq->queuelist, &next->queuelist); -		rq_set_fifo_time(rq, rq_fifo_time(next)); +		rq->fifo_time = next->fifo_time;  	}  	if (cfqq->next_rq == next) @@ -2804,7 +2811,7 @@ static struct request *cfq_check_fifo(struct cfq_queue *cfqq)  		return NULL;  	rq = rq_entry_fifo(cfqq->fifo.next); -	if (time_before(jiffies, rq_fifo_time(rq))) +	if (time_before(jiffies, rq->fifo_time))  		rq = NULL;  	cfq_log_cfqq(cfqq->cfqd, cfqq, "fifo=%p", rq); @@ -3917,7 +3924,7 @@ static void cfq_insert_request(struct request_queue *q, struct request *rq)  	cfq_log_cfqq(cfqd, cfqq, "insert_request");  	cfq_init_prio_data(cfqq, RQ_CIC(rq)); -	rq_set_fifo_time(rq, jiffies + cfqd->cfq_fifo_expire[rq_is_sync(rq)]); +	rq->fifo_time = jiffies + cfqd->cfq_fifo_expire[rq_is_sync(rq)];  	list_add_tail(&rq->queuelist, &cfqq->fifo);  	cfq_add_rq_rb(rq);  	cfqg_stats_update_io_add(RQ_CFQG(rq), cfqd->serving_group, @@ -4358,7 +4365,7 @@ static int cfq_init_queue(struct request_queue *q, struct elevator_type *e)  	if (!eq)  		return -ENOMEM; -	cfqd = kmalloc_node(sizeof(*cfqd), GFP_KERNEL | __GFP_ZERO, q->node); +	cfqd = kzalloc_node(sizeof(*cfqd), GFP_KERNEL, q->node);  	if (!cfqd) {  		kobject_put(&eq->kobj);  		return -ENOMEM; @@ -4453,7 +4460,7 @@ out_free:  static ssize_t  cfq_var_show(unsigned int var, char *page)  { -	return sprintf(page, "%d\n", var); +	return sprintf(page, "%u\n", var);  }  static ssize_t  | 
