Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 24507
b: refs/heads/master
c: e8a9905
h: refs/heads/master
i:
  24505: 1f55b13
  24503: 40da974
v: v3
  • Loading branch information
Andreas Mohr authored and Jens Axboe committed Mar 28, 2006
1 parent 208f5d5 commit 936e1c4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e2d74ac0664c89757bde8fb18c98cd7bf53da61c
refs/heads/master: e8a99053ea82a4b4375049886cf1db64d7dcd755
50 changes: 32 additions & 18 deletions trunk/block/cfq-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,16 @@ static int cfq_queue_empty(request_queue_t *q)
/*
* Lifted from AS - choose which of crq1 and crq2 that is best served now.
* We choose the request that is closest to the head right now. Distance
* behind the head are penalized and only allowed to a certain extent.
* behind the head is penalized and only allowed to a certain extent.
*/
static struct cfq_rq *
cfq_choose_req(struct cfq_data *cfqd, struct cfq_rq *crq1, struct cfq_rq *crq2)
{
sector_t last, s1, s2, d1 = 0, d2 = 0;
int r1_wrap = 0, r2_wrap = 0; /* requests are behind the disk head */
unsigned long back_max;
#define CFQ_RQ1_WRAP 0x01 /* request 1 wraps */
#define CFQ_RQ2_WRAP 0x02 /* request 2 wraps */
unsigned wrap = 0; /* bit mask: requests behind the disk head? */

if (crq1 == NULL || crq1 == crq2)
return crq2;
Expand Down Expand Up @@ -385,35 +387,47 @@ cfq_choose_req(struct cfq_data *cfqd, struct cfq_rq *crq1, struct cfq_rq *crq2)
else if (s1 + back_max >= last)
d1 = (last - s1) * cfqd->cfq_back_penalty;
else
r1_wrap = 1;
wrap |= CFQ_RQ1_WRAP;

if (s2 >= last)
d2 = s2 - last;
else if (s2 + back_max >= last)
d2 = (last - s2) * cfqd->cfq_back_penalty;
else
r2_wrap = 1;
wrap |= CFQ_RQ2_WRAP;

/* Found required data */
if (!r1_wrap && r2_wrap)
return crq1;
else if (!r2_wrap && r1_wrap)
return crq2;
else if (r1_wrap && r2_wrap) {
/* both behind the head */
if (s1 <= s2)

/*
* By doing switch() on the bit mask "wrap" we avoid having to
* check two variables for all permutations: --> faster!
*/
switch (wrap) {
case 0: /* common case for CFQ: crq1 and crq2 not wrapped */
if (d1 < d2)
return crq1;
else
else if (d2 < d1)
return crq2;
}
else {
if (s1 >= s2)
return crq1;
else
return crq2;
}

/* Both requests in front of the head */
if (d1 < d2)
case CFQ_RQ2_WRAP:
return crq1;
else if (d2 < d1)
case CFQ_RQ1_WRAP:
return crq2;
else {
if (s1 >= s2)
case (CFQ_RQ1_WRAP|CFQ_RQ2_WRAP): /* both crqs wrapped */
default:
/*
* Since both rqs are wrapped,
* start with the one that's further behind head
* (--> only *one* back seek required),
* since back seek takes more time than forward.
*/
if (s1 <= s2)
return crq1;
else
return crq2;
Expand Down

0 comments on commit 936e1c4

Please sign in to comment.