Whamcloud - gitweb
b=18649 set wait_recovery_complete() MAX value to max recovery time estimated
[fs/lustre-release.git] / lustre / kernel_patches / patches / rollback-raid5ch-to-55.patch
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
3 @@ -49,7 +49,7 @@
4   * This macro is used to determine the 'next' bio in the list, given the sector
5   * of the current stripe+device
6   */
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)
9  /*
10   * The following can be used to debug the driver
11   */
12 @@ -232,7 +232,6 @@ static struct stripe_head *__find_stripe
13  }
14  
15  static void unplug_slaves(mddev_t *mddev);
16 -static void raid5_unplug_device(request_queue_t *q);
17  
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;
24 -
25 -                               if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags))
26 -                                       wake_up(&conf->wait_for_overlap);
27 -
28                                 if (sh->dev[i].written) BUG();
29                                 sh->dev[i].written = chosen;
30                                 check_xor();
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;
35 -
36 -                               if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags))
37 -                                       wake_up(&conf->wait_for_overlap);
38 -
39                                 if (sh->dev[i].written) BUG();
40                                 sh->dev[i].written = chosen;
41                         }
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.
45   */
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)
48  {
49         struct bio **bip;
50         raid5_conf_t *conf = sh->raid_conf;
51 @@ -820,13 +811,10 @@ static int add_stripe_bio(struct stripe_
52         else
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)
56 -                       goto overlap;
57 +               BUG_ON((*bip)->bi_sector + ((*bip)->bi_size >> 9) > bi->bi_sector);
58                 bip = & (*bip)->bi_next;
59         }
60 -       if (*bip && (*bip)->bi_sector < bi->bi_sector + ((bi->bi_size)>>9))
61 -               goto overlap;
62 -
63 +/* FIXME do I need to worry about overlapping bion */
64         if (*bip && bi->bi_next && (*bip) != bi->bi_next)
65                 BUG();
66         if (*bip)
67 @@ -841,7 +829,7 @@ static int add_stripe_bio(struct stripe_
68                 (unsigned long long)sh->sector, dd_idx);
69  
70         if (forwrite) {
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);
79         }
80 -       return 1;
81 -
82 - overlap:
83 -       set_bit(R5_Overlap, &sh->dev[dd_idx].flags);
84 -       spin_unlock_irq(&conf->device_lock);
85 -       spin_unlock(&sh->lock);
86 -       return 0;
87  }
88  
89  
90 @@ -920,8 +901,6 @@ static void handle_stripe(struct stripe_
91                         spin_lock_irq(&conf->device_lock);
92                         rbi = dev->toread;
93                         dev->toread = NULL;
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;
101                         if (bi) to_write--;
102  
103 -                       if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags))
104 -                               wake_up(&conf->wait_for_overlap);
105 -
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);
115                                 if (bi) to_read--;
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) {
122 -               DEFINE_WAIT(w);
123                 
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);
129  
130 -       retry:
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));
133                 if (sh) {
134 -                       if (!add_stripe_bio(sh, bi, dd_idx, (bi->bi_rw&RW_MASK))) {
135 -                               /* Add failed due to overlap.  Flush everything
136 -                                * and wait a while
137 -                                */
138 -                               raid5_unplug_device(mddev->queue);
139 -                               release_stripe(sh);
140 -                               schedule();
141 -                               goto retry;
142 -                       }
143 -                       finish_wait(&conf->wait_for_overlap, &w);
144 +
145 +                       add_stripe_bio(sh, bi, dd_idx, (bi->bi_rw&RW_MASK));
146 +
147                         raid5_plug_device(conf);
148                         handle_stripe(sh);
149                         release_stripe(sh);
150 -
151                 } else {
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);
155                         break;
156                 }
157                         
158 @@ -1619,7 +1581,6 @@ static int run (mddev_t *mddev)
159  
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 */
173  
174  /*
175   * Write method
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
183                                                          */        
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
186 @@ -54,7 +54,7 @@
187   * This macro is used to determine the 'next' bio in the list, given the sector
188   * of the current stripe+device
189   */
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)
192  /*
193   * The following can be used to debug the driver
194   */
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;
199 -
200 -                               if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags))
201 -                                       wake_up(&conf->wait_for_overlap);
202 -
203                                 if (sh->dev[i].written) BUG();
204                                 sh->dev[i].written = chosen;
205                         }
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.
209   */
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)
212  {
213         struct bio **bip;
214         raid6_conf_t *conf = sh->raid_conf;
215 @@ -919,13 +915,10 @@ static int add_stripe_bio(struct stripe_
216         else
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)
220 -                       goto overlap;
221 -               bip = &(*bip)->bi_next;
222 +               BUG_ON((*bip)->bi_sector + ((*bip)->bi_size >> 9) > bi->bi_sector);
223 +               bip = & (*bip)->bi_next;
224         }
225 -       if (*bip && (*bip)->bi_sector < bi->bi_sector + ((bi->bi_size)>>9))
226 -               goto overlap;
227 -
228 +/* FIXME do I need to worry about overlapping bion */
229         if (*bip && bi->bi_next && (*bip) != bi->bi_next)
230                 BUG();
231         if (*bip)
232 @@ -940,7 +933,7 @@ static int add_stripe_bio(struct stripe_
233                 (unsigned long long)sh->sector, dd_idx);
234  
235         if (forwrite) {
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);
244         }
245 -       return 1;
246 -
247 - overlap:
248 -       set_bit(R5_Overlap, &sh->dev[dd_idx].flags);
249 -       spin_unlock_irq(&conf->device_lock);
250 -       spin_unlock(&sh->lock);
251 -       return 0;
252  }
253  
254  
255 @@ -1022,8 +1008,6 @@ static void handle_stripe(struct stripe_
256                         spin_lock_irq(&conf->device_lock);
257                         rbi = dev->toread;
258                         dev->toread = NULL;
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;
266                         if (bi) to_write--;
267  
268 -                       if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags))
269 -                               wake_up(&conf->wait_for_overlap);
270 -
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);
280                                 if (bi) to_read--;
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) {
287 -               DEFINE_WAIT(w);
288  
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);
294  
295 -       retry:
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));
298                 if (sh) {
299 -                       if (!add_stripe_bio(sh, bi, dd_idx, (bi->bi_rw&RW_MASK))) {
300 -                               /* Add failed due to overlap.  Flush everything
301 -                                * and wait a while
302 -                                */
303 -                               raid6_unplug_device(mddev->queue);
304 -                               release_stripe(sh);
305 -                               schedule();
306 -                               goto retry;
307 -                       }
308 -                       finish_wait(&conf->wait_for_overlap, &w);
309 +
310 +                       add_stripe_bio(sh, bi, dd_idx, (bi->bi_rw&RW_MASK));
311 +
312                         raid6_plug_device(conf);
313                         handle_stripe(sh);
314                         release_stripe(sh);
315                 } else {
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);
319                         break;
320                 }
321  
322 @@ -1774,7 +1742,6 @@ static int run (mddev_t *mddev)
323  
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);