1 Index: linux-2.6.18-92.1.17/drivers/md/raid5.c
2 ===================================================================
3 --- linux-2.6.18-92.1.17.orig/drivers/md/raid5.c
4 +++ linux-2.6.18-92.1.17/drivers/md/raid5.c
5 @@ -1277,7 +1277,26 @@ static void compute_block_2(struct strip
10 + * The whole idea is to collect all bio's and then issue them
11 + * disk by disk to assist merging a bit -bzzz
13 +static void raid5_flush_bios(raid5_conf_t *conf, struct bio *bios[], int raid_disks)
15 + struct bio *bio, *nbio;
18 + for (i = 0; i < raid_disks; i++) {
21 + nbio = bio->bi_next;
22 + bio->bi_next = NULL;
23 + generic_make_request(bio);
31 * Each stripe/dev can have one or more bion attached.
32 @@ -1392,7 +1411,7 @@ static int stripe_to_pdidx(sector_t stri
36 -static void handle_stripe5(struct stripe_head *sh)
37 +static void handle_stripe5(struct stripe_head *sh, struct bio *bios[])
39 raid5_conf_t *conf = sh->raid_conf;
40 int disks = sh->disks;
41 @@ -1939,7 +1958,11 @@ static void handle_stripe5(struct stripe
42 test_bit(R5_ReWrite, &sh->dev[i].flags))
43 atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
44 atomic_inc(&conf->out_reqs_in_queue);
45 - generic_make_request(bi);
47 + bi->bi_next = bios[i];
50 + generic_make_request(bi);
53 set_bit(STRIPE_DEGRADED, &sh->state);
54 @@ -1951,7 +1974,7 @@ static void handle_stripe5(struct stripe
58 -static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page)
59 +static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page, struct bio *bios[])
61 raid6_conf_t *conf = sh->raid_conf;
62 int disks = conf->raid_disks;
63 @@ -2499,7 +2522,11 @@ static void handle_stripe6(struct stripe
65 test_bit(R5_ReWrite, &sh->dev[i].flags))
66 atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
67 - generic_make_request(bi);
69 + bi->bi_next = bios[i];
72 + generic_make_request(bi);
73 atomic_inc(&conf->out_reqs_in_queue);
76 @@ -2512,12 +2539,12 @@ static void handle_stripe6(struct stripe
80 -static void handle_stripe(struct stripe_head *sh, struct page *tmp_page)
81 +static void handle_stripe(struct stripe_head *sh, struct page *tmp_page, struct bio *bios[])
83 if (sh->raid_conf->level == 6)
84 - handle_stripe6(sh, tmp_page);
85 + handle_stripe6(sh, tmp_page, bios);
88 + handle_stripe5(sh, bios);
92 @@ -2670,6 +2697,7 @@ static int make_request(request_queue_t
93 int stripes_per_chunk, sectors_per_block;
94 int sectors_per_stripe;
96 + struct bio *bios[MD_SB_DISKS];
99 int disks, data_disks;
100 @@ -2698,6 +2726,7 @@ static int make_request(request_queue_t
101 sectors = bi->bi_size >> 9;
102 stripes_per_chunk = conf->chunk_size / STRIPE_SIZE;
104 + memset(&bios, 0, sizeof(bios));
106 /* stripe by stripe handle needs a stable raid layout, so if this
107 * reuqest covers the expanding region, wait it over.
108 @@ -2756,8 +2785,10 @@ retry:
109 * the raid layout has been changed, we have to redo the
110 * whole bio because we don't which sectors in it has been
111 * done, and which is not done. -jay */
112 - if (raid5_redo_bio(conf, bi, disks, logical_sector))
113 + if (raid5_redo_bio(conf, bi, disks, logical_sector)) {
114 + raid5_flush_bios(conf, bios, disks);
118 if (test_bit(STRIPE_EXPANDING, &sh->state)) {
119 /* Stripe is busy expanding or
120 @@ -2766,6 +2797,7 @@ retry:
124 + raid5_flush_bios(conf, bios, disks);
125 raid5_unplug_device(mddev->queue);
128 @@ -2784,17 +2816,19 @@ retry:
130 if (r_sector >= mddev->suspend_lo &&
131 r_sector < mddev->suspend_hi) {
132 - handle_stripe(sh, NULL);
133 + handle_stripe(sh, NULL, NULL);
136 + raid5_flush_bios(conf, bios, disks);
141 if (!add_stripe_bio(sh, bi, dd_idx, (bi->bi_rw&RW_MASK))) {
142 - handle_stripe(sh, NULL);
143 + handle_stripe(sh, NULL, NULL);
146 + raid5_flush_bios(conf, bios, disks);
147 raid5_unplug_device(mddev->queue);
150 @@ -2810,7 +2844,7 @@ retry:
151 r_sector += sectors_per_chunk;
154 - handle_stripe(sh, NULL);
155 + handle_stripe(sh, NULL, bios);
159 @@ -2820,6 +2854,9 @@ retry:
163 + /* flush all of the bios */
164 + raid5_flush_bios(conf, bios, disks);
166 spin_lock_irq(&conf->device_lock);
167 remaining = --bi->bi_phys_segments;
168 spin_unlock_irq(&conf->device_lock);
169 @@ -3035,7 +3072,7 @@ static inline sector_t sync_request(mdde
170 clear_bit(STRIPE_INSYNC, &sh->state);
171 spin_unlock(&sh->lock);
173 - handle_stripe(sh, NULL);
174 + handle_stripe(sh, NULL, NULL);
177 return STRIPE_SECTORS;
178 @@ -3091,7 +3128,7 @@ static void raid5d (mddev_t *mddev)
181 atomic_inc(&conf->handled_in_raid5d);
182 - handle_stripe(sh, conf->spare_page);
183 + handle_stripe(sh, conf->spare_page, NULL);
186 spin_lock_irq(&conf->device_lock);