1 --- linux-2.6.9-67/drivers/md/raid5.c 2007-11-21 21:12:50.000000000 -0700
2 +++ linux-2.6.9-55.0.12/drivers/md/raid5.c 2007-11-02 01:10:35.000000000 -0700
4 * This macro is used to determine the 'next' bio in the list, given the sector
5 * of the current stripe+device
7 -#define r5_next_bio(bio, sect) ( ( (bio)->bi_sector + ((bio)->bi_size>>9) < sect + STRIPE_SECTORS) ? (bio)->bi_next : NULL)
8 +#define r5_next_bio(bio, sect) ( ( bio->bi_sector + (bio->bi_size>>9) < sect + STRIPE_SECTORS) ? bio->bi_next : NULL)
10 * The following can be used to debug the driver
12 @@ -232,7 +232,6 @@ static struct stripe_head *__find_stripe
15 static void unplug_slaves(mddev_t *mddev);
16 -static void raid5_unplug_device(request_queue_t *q);
18 static struct stripe_head *get_active_stripe(raid5_conf_t *conf, sector_t sector,
19 int pd_idx, int noblock)
20 @@ -727,10 +726,6 @@ static void compute_parity(struct stripe
21 ptr[count++] = page_address(sh->dev[i].page);
22 chosen = sh->dev[i].towrite;
23 sh->dev[i].towrite = NULL;
25 - if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags))
26 - wake_up(&conf->wait_for_overlap);
28 if (sh->dev[i].written) BUG();
29 sh->dev[i].written = chosen;
31 @@ -743,10 +738,6 @@ static void compute_parity(struct stripe
32 if (i!=pd_idx && sh->dev[i].towrite) {
33 chosen = sh->dev[i].towrite;
34 sh->dev[i].towrite = NULL;
36 - if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags))
37 - wake_up(&conf->wait_for_overlap);
39 if (sh->dev[i].written) BUG();
40 sh->dev[i].written = chosen;
42 @@ -803,7 +794,7 @@ static void compute_parity(struct stripe
43 * toread/towrite point to the first in a chain.
44 * The bi_next chain must be in order.
46 -static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, int forwrite)
47 +static void add_stripe_bio (struct stripe_head *sh, struct bio *bi, int dd_idx, int forwrite)
50 raid5_conf_t *conf = sh->raid_conf;
51 @@ -820,13 +811,10 @@ static int add_stripe_bio(struct stripe_
53 bip = &sh->dev[dd_idx].toread;
54 while (*bip && (*bip)->bi_sector < bi->bi_sector) {
55 - if ((*bip)->bi_sector + ((*bip)->bi_size >> 9) > bi->bi_sector)
57 + BUG_ON((*bip)->bi_sector + ((*bip)->bi_size >> 9) > bi->bi_sector);
58 bip = & (*bip)->bi_next;
60 - if (*bip && (*bip)->bi_sector < bi->bi_sector + ((bi->bi_size)>>9))
63 +/* FIXME do I need to worry about overlapping bion */
64 if (*bip && bi->bi_next && (*bip) != bi->bi_next)
67 @@ -841,7 +829,7 @@ static int add_stripe_bio(struct stripe_
68 (unsigned long long)sh->sector, dd_idx);
71 - /* check if page is covered */
72 + /* check if page is coverred */
73 sector_t sector = sh->dev[dd_idx].sector;
74 for (bi=sh->dev[dd_idx].towrite;
75 sector < sh->dev[dd_idx].sector + STRIPE_SECTORS &&
76 @@ -853,13 +841,6 @@ static int add_stripe_bio(struct stripe_
77 if (sector >= sh->dev[dd_idx].sector + STRIPE_SECTORS)
78 set_bit(R5_OVERWRITE, &sh->dev[dd_idx].flags);
83 - set_bit(R5_Overlap, &sh->dev[dd_idx].flags);
84 - spin_unlock_irq(&conf->device_lock);
85 - spin_unlock(&sh->lock);
90 @@ -920,8 +901,6 @@ static void handle_stripe(struct stripe_
91 spin_lock_irq(&conf->device_lock);
94 - if (test_and_clear_bit(R5_Overlap, &dev->flags))
95 - wake_up(&conf->wait_for_overlap);
96 spin_unlock_irq(&conf->device_lock);
97 while (rbi && rbi->bi_sector < dev->sector + STRIPE_SECTORS) {
98 copy_data(0, rbi, dev->page, dev->sector);
99 @@ -969,9 +948,6 @@ static void handle_stripe(struct stripe_
100 sh->dev[i].towrite = NULL;
103 - if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags))
104 - wake_up(&conf->wait_for_overlap);
106 while (bi && bi->bi_sector < sh->dev[i].sector + STRIPE_SECTORS){
107 struct bio *nextbi = r5_next_bio(bi, sh->dev[i].sector);
108 clear_bit(BIO_UPTODATE, &bi->bi_flags);
109 @@ -1000,8 +976,6 @@ static void handle_stripe(struct stripe_
110 if (!test_bit(R5_Insync, &sh->dev[i].flags)) {
111 bi = sh->dev[i].toread;
112 sh->dev[i].toread = NULL;
113 - if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags))
114 - wake_up(&conf->wait_for_overlap);
116 while (bi && bi->bi_sector < sh->dev[i].sector + STRIPE_SECTORS){
117 struct bio *nextbi = r5_next_bio(bi, sh->dev[i].sector);
118 @@ -1441,7 +1415,6 @@ static int make_request (request_queue_t
119 if ( bio_data_dir(bi) == WRITE )
120 md_write_start(mddev);
121 for (;logical_sector < last_sector; logical_sector += STRIPE_SECTORS) {
124 new_sector = raid5_compute_sector(logical_sector,
125 raid_disks, data_disks, &dd_idx, &pd_idx, conf);
126 @@ -1450,28 +1423,17 @@ static int make_request (request_queue_t
127 (unsigned long long)new_sector,
128 (unsigned long long)logical_sector);
131 - prepare_to_wait(&conf->wait_for_overlap, &w, TASK_UNINTERRUPTIBLE);
132 sh = get_active_stripe(conf, new_sector, pd_idx, (bi->bi_rw&RWA_MASK));
134 - if (!add_stripe_bio(sh, bi, dd_idx, (bi->bi_rw&RW_MASK))) {
135 - /* Add failed due to overlap. Flush everything
138 - raid5_unplug_device(mddev->queue);
139 - release_stripe(sh);
143 - finish_wait(&conf->wait_for_overlap, &w);
145 + add_stripe_bio(sh, bi, dd_idx, (bi->bi_rw&RW_MASK));
147 raid5_plug_device(conf);
152 /* cannot get stripe for read-ahead, just give-up */
153 clear_bit(BIO_UPTODATE, &bi->bi_flags);
154 - finish_wait(&conf->wait_for_overlap, &w);
158 @@ -1619,7 +1581,6 @@ static int run (mddev_t *mddev)
160 conf->device_lock = SPIN_LOCK_UNLOCKED;
161 init_waitqueue_head(&conf->wait_for_stripe);
162 - init_waitqueue_head(&conf->wait_for_overlap);
163 INIT_LIST_HEAD(&conf->handle_list);
164 INIT_LIST_HEAD(&conf->delayed_list);
165 INIT_LIST_HEAD(&conf->inactive_list);
166 --- linux-2.6.9-67/include/linux/raid/raid5.h 2007-11-21 21:12:41.000000000 -0700
167 +++ linux-2.6.9-55.0.12/include/linux/raid/raid5.h 2004-10-18 15:54:55.000000000 -0600
168 @@ -152,7 +152,6 @@ struct stripe_head {
169 #define R5_Wantread 4 /* want to schedule a read */
170 #define R5_Wantwrite 5
171 #define R5_Syncio 6 /* this io need to be accounted as resync io */
172 -#define R5_Overlap 7 /* There is a pending overlapping request on this block */
176 @@ -220,7 +219,6 @@ struct raid5_private_data {
177 atomic_t active_stripes;
178 struct list_head inactive_list;
179 wait_queue_head_t wait_for_stripe;
180 - wait_queue_head_t wait_for_overlap;
181 int inactive_blocked; /* release of inactive stripes blocked,
182 * waiting for 25% to be free
184 --- linux-2.6.9-67/drivers/md/raid6main.c 2007-11-21 21:12:41.000000000 -0700
185 +++ linux-2.6.9-55.0.12/drivers/md/raid6main.c 2007-11-02 01:10:20.000000000 -0700
187 * This macro is used to determine the 'next' bio in the list, given the sector
188 * of the current stripe+device
190 -#define r5_next_bio(bio, sect) ( ( (bio)->bi_sector + ((bio)->bi_size>>9) < sect + STRIPE_SECTORS) ? (bio)->bi_next : NULL)
191 +#define r5_next_bio(bio, sect) ( ( bio->bi_sector + (bio->bi_size>>9) < sect + STRIPE_SECTORS) ? bio->bi_next : NULL)
193 * The following can be used to debug the driver
195 @@ -740,10 +740,6 @@ static void compute_parity(struct stripe
196 if ( i != pd_idx && i != qd_idx && sh->dev[i].towrite ) {
197 chosen = sh->dev[i].towrite;
198 sh->dev[i].towrite = NULL;
200 - if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags))
201 - wake_up(&conf->wait_for_overlap);
203 if (sh->dev[i].written) BUG();
204 sh->dev[i].written = chosen;
206 @@ -902,7 +898,7 @@ static void compute_block_2(struct strip
207 * toread/towrite point to the first in a chain.
208 * The bi_next chain must be in order.
210 -static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, int forwrite)
211 +static void add_stripe_bio (struct stripe_head *sh, struct bio *bi, int dd_idx, int forwrite)
214 raid6_conf_t *conf = sh->raid_conf;
215 @@ -919,13 +915,10 @@ static int add_stripe_bio(struct stripe_
217 bip = &sh->dev[dd_idx].toread;
218 while (*bip && (*bip)->bi_sector < bi->bi_sector) {
219 - if ((*bip)->bi_sector + ((*bip)->bi_size >> 9) > bi->bi_sector)
221 - bip = &(*bip)->bi_next;
222 + BUG_ON((*bip)->bi_sector + ((*bip)->bi_size >> 9) > bi->bi_sector);
223 + bip = & (*bip)->bi_next;
225 - if (*bip && (*bip)->bi_sector < bi->bi_sector + ((bi->bi_size)>>9))
228 +/* FIXME do I need to worry about overlapping bion */
229 if (*bip && bi->bi_next && (*bip) != bi->bi_next)
232 @@ -940,7 +933,7 @@ static int add_stripe_bio(struct stripe_
233 (unsigned long long)sh->sector, dd_idx);
236 - /* check if page is covered */
237 + /* check if page is coverred */
238 sector_t sector = sh->dev[dd_idx].sector;
239 for (bi=sh->dev[dd_idx].towrite;
240 sector < sh->dev[dd_idx].sector + STRIPE_SECTORS &&
241 @@ -952,13 +945,6 @@ static int add_stripe_bio(struct stripe_
242 if (sector >= sh->dev[dd_idx].sector + STRIPE_SECTORS)
243 set_bit(R5_OVERWRITE, &sh->dev[dd_idx].flags);
248 - set_bit(R5_Overlap, &sh->dev[dd_idx].flags);
249 - spin_unlock_irq(&conf->device_lock);
250 - spin_unlock(&sh->lock);
255 @@ -1022,8 +1008,6 @@ static void handle_stripe(struct stripe_
256 spin_lock_irq(&conf->device_lock);
259 - if (test_and_clear_bit(R5_Overlap, &dev->flags))
260 - wake_up(&conf->wait_for_overlap);
261 spin_unlock_irq(&conf->device_lock);
262 while (rbi && rbi->bi_sector < dev->sector + STRIPE_SECTORS) {
263 copy_data(0, rbi, dev->page, dev->sector);
264 @@ -1073,9 +1057,6 @@ static void handle_stripe(struct stripe_
265 sh->dev[i].towrite = NULL;
268 - if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags))
269 - wake_up(&conf->wait_for_overlap);
271 while (bi && bi->bi_sector < sh->dev[i].sector + STRIPE_SECTORS){
272 struct bio *nextbi = r5_next_bio(bi, sh->dev[i].sector);
273 clear_bit(BIO_UPTODATE, &bi->bi_flags);
274 @@ -1104,8 +1085,6 @@ static void handle_stripe(struct stripe_
275 if (!test_bit(R5_Insync, &sh->dev[i].flags)) {
276 bi = sh->dev[i].toread;
277 sh->dev[i].toread = NULL;
278 - if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags))
279 - wake_up(&conf->wait_for_overlap);
281 while (bi && bi->bi_sector < sh->dev[i].sector + STRIPE_SECTORS){
282 struct bio *nextbi = r5_next_bio(bi, sh->dev[i].sector);
283 @@ -1597,7 +1576,6 @@ static int make_request (request_queue_t
284 if ( bio_data_dir(bi) == WRITE )
285 md_write_start(mddev);
286 for (;logical_sector < last_sector; logical_sector += STRIPE_SECTORS) {
289 new_sector = raid6_compute_sector(logical_sector,
290 raid_disks, data_disks, &dd_idx, &pd_idx, conf);
291 @@ -1606,27 +1584,17 @@ static int make_request (request_queue_t
292 (unsigned long long)new_sector,
293 (unsigned long long)logical_sector);
296 - prepare_to_wait(&conf->wait_for_overlap, &w, TASK_UNINTERRUPTIBLE);
297 sh = get_active_stripe(conf, new_sector, pd_idx, (bi->bi_rw&RWA_MASK));
299 - if (!add_stripe_bio(sh, bi, dd_idx, (bi->bi_rw&RW_MASK))) {
300 - /* Add failed due to overlap. Flush everything
303 - raid6_unplug_device(mddev->queue);
304 - release_stripe(sh);
308 - finish_wait(&conf->wait_for_overlap, &w);
310 + add_stripe_bio(sh, bi, dd_idx, (bi->bi_rw&RW_MASK));
312 raid6_plug_device(conf);
316 /* cannot get stripe for read-ahead, just give-up */
317 clear_bit(BIO_UPTODATE, &bi->bi_flags);
318 - finish_wait(&conf->wait_for_overlap, &w);
322 @@ -1774,7 +1742,6 @@ static int run (mddev_t *mddev)
324 conf->device_lock = SPIN_LOCK_UNLOCKED;
325 init_waitqueue_head(&conf->wait_for_stripe);
326 - init_waitqueue_head(&conf->wait_for_overlap);
327 INIT_LIST_HEAD(&conf->handle_list);
328 INIT_LIST_HEAD(&conf->delayed_list);
329 INIT_LIST_HEAD(&conf->inactive_list);