cfq-iosched: fix issue with rq-rq merging and fifo list ordering
cfq uses rq->start_time as the fifo indicator, but that field may get modified prior to cfq doing it's fifo list adjustment when a request gets merged with another request. This can cause the fifo list to become unordered. Reported-by: Corrado Zoccolo <czoccolo@gmail.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
This commit is contained in:
		
					parent
					
						
							
								374576a8b6
							
						
					
				
			
			
				commit
				
					
						30996f40bf
					
				
			
		
					 1 changed files with 7 additions and 8 deletions
				
			
		| 
						 | 
					@ -827,8 +827,10 @@ cfq_merged_requests(struct request_queue *q, struct request *rq,
 | 
				
			||||||
	 * reposition in fifo if next is older than rq
 | 
						 * reposition in fifo if next is older than rq
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	if (!list_empty(&rq->queuelist) && !list_empty(&next->queuelist) &&
 | 
						if (!list_empty(&rq->queuelist) && !list_empty(&next->queuelist) &&
 | 
				
			||||||
	    time_before(next->start_time, rq->start_time))
 | 
						    time_before(rq_fifo_time(next), rq_fifo_time(rq))) {
 | 
				
			||||||
		list_move(&rq->queuelist, &next->queuelist);
 | 
							list_move(&rq->queuelist, &next->queuelist);
 | 
				
			||||||
 | 
							rq_set_fifo_time(rq, rq_fifo_time(next));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cfq_remove_request(next);
 | 
						cfq_remove_request(next);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1129,9 +1131,7 @@ static void cfq_dispatch_insert(struct request_queue *q, struct request *rq)
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static struct request *cfq_check_fifo(struct cfq_queue *cfqq)
 | 
					static struct request *cfq_check_fifo(struct cfq_queue *cfqq)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct cfq_data *cfqd = cfqq->cfqd;
 | 
						struct request *rq = NULL;
 | 
				
			||||||
	struct request *rq;
 | 
					 | 
				
			||||||
	int fifo;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (cfq_cfqq_fifo_expire(cfqq))
 | 
						if (cfq_cfqq_fifo_expire(cfqq))
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
| 
						 | 
					@ -1141,13 +1141,11 @@ static struct request *cfq_check_fifo(struct cfq_queue *cfqq)
 | 
				
			||||||
	if (list_empty(&cfqq->fifo))
 | 
						if (list_empty(&cfqq->fifo))
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fifo = cfq_cfqq_sync(cfqq);
 | 
					 | 
				
			||||||
	rq = rq_entry_fifo(cfqq->fifo.next);
 | 
						rq = rq_entry_fifo(cfqq->fifo.next);
 | 
				
			||||||
 | 
						if (time_before(jiffies, rq_fifo_time(rq)))
 | 
				
			||||||
	if (time_before(jiffies, rq->start_time + cfqd->cfq_fifo_expire[fifo]))
 | 
					 | 
				
			||||||
		rq = NULL;
 | 
							rq = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cfq_log_cfqq(cfqd, cfqq, "fifo=%p", rq);
 | 
						cfq_log_cfqq(cfqq->cfqd, cfqq, "fifo=%p", rq);
 | 
				
			||||||
	return rq;
 | 
						return rq;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2130,6 +2128,7 @@ static void cfq_insert_request(struct request_queue *q, struct request *rq)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cfq_add_rq_rb(rq);
 | 
						cfq_add_rq_rb(rq);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						rq_set_fifo_time(rq, jiffies + cfqd->cfq_fifo_expire[rq_is_sync(rq)]);
 | 
				
			||||||
	list_add_tail(&rq->queuelist, &cfqq->fifo);
 | 
						list_add_tail(&rq->queuelist, &cfqq->fifo);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cfq_rq_enqueued(cfqd, cfqq, rq);
 | 
						cfq_rq_enqueued(cfqd, cfqq, rq);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue