]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
1 | From b5663ba405fe3e51176ddb6c91a5e186590c26b5 Mon Sep 17 00:00:00 2001 |
2 | From: NeilBrown <neilb@suse.de> | |
3 | Date: Tue, 31 Mar 2009 14:39:38 +1100 | |
4 | Subject: [PATCH] md/raid5: simplify interface for init_stripe and get_active_stripe | |
5 | ||
6 | Rather than passing 'pd_idx' and 'disks' to these functions, just pass | |
7 | 'previous' which tells whether to use the 'previous' or 'current' | |
8 | geometry during a reshape, and let init_stripe calculate | |
9 | disks and pd_idx and anything else it might need. | |
10 | ||
11 | This is not a substantial simplification and even adds a division. | |
12 | However we will shortly be adding more complexity to init_stripe | |
13 | to handle more interesting 'reshape' activities, and without this | |
14 | change, the interface to these functions would get very complex. | |
15 | ||
16 | Signed-off-by: NeilBrown <neilb@suse.de> | |
17 | --- | |
18 | drivers/md/raid5.c | 43 ++++++++++++++++++++++--------------------- | |
19 | 1 file changed, 22 insertions(+), 21 deletions(-) | |
20 | ||
21 | --- linux-2.6.27-SLE11_BRANCH.orig/drivers/md/raid5.c | |
22 | +++ linux-2.6.27-SLE11_BRANCH/drivers/md/raid5.c | |
23 | @@ -276,8 +276,9 @@ static int grow_buffers(struct stripe_he | |
24 | } | |
25 | ||
26 | static void raid5_build_block (struct stripe_head *sh, int i); | |
27 | +static int stripe_to_pdidx(sector_t stripe, raid5_conf_t *conf, int disks); | |
28 | ||
29 | -static void init_stripe(struct stripe_head *sh, sector_t sector, int pd_idx, int disks) | |
30 | +static void init_stripe(struct stripe_head *sh, sector_t sector, int previous) | |
31 | { | |
32 | raid5_conf_t *conf = sh->raid_conf; | |
33 | int i; | |
34 | @@ -292,11 +293,11 @@ static void init_stripe(struct stripe_he | |
35 | ||
36 | remove_hash(sh); | |
37 | ||
38 | + sh->disks = previous ? conf->previous_raid_disks : conf->raid_disks; | |
39 | sh->sector = sector; | |
40 | - sh->pd_idx = pd_idx; | |
41 | + sh->pd_idx = stripe_to_pdidx(sector, conf, sh->disks); | |
42 | sh->state = 0; | |
43 | ||
44 | - sh->disks = disks; | |
45 | ||
46 | for (i = sh->disks; i--; ) { | |
47 | struct r5dev *dev = &sh->dev[i]; | |
48 | @@ -332,10 +333,12 @@ static struct stripe_head *__find_stripe | |
49 | static void unplug_slaves(mddev_t *mddev); | |
50 | static void raid5_unplug_device(struct request_queue *q); | |
51 | ||
52 | -static struct stripe_head *get_active_stripe(raid5_conf_t *conf, sector_t sector, int disks, | |
53 | - int pd_idx, int noblock) | |
54 | +static struct stripe_head * | |
55 | +get_active_stripe(raid5_conf_t *conf, sector_t sector, | |
56 | + int previous, int noblock) | |
57 | { | |
58 | struct stripe_head *sh; | |
59 | + int disks = previous ? conf->previous_raid_disks : conf->raid_disks; | |
60 | ||
61 | pr_debug("get_stripe, sector %llu\n", (unsigned long long)sector); | |
62 | ||
63 | @@ -363,7 +366,7 @@ static struct stripe_head *get_active_st | |
64 | ); | |
65 | conf->inactive_blocked = 0; | |
66 | } else | |
67 | - init_stripe(sh, sector, pd_idx, disks); | |
68 | + init_stripe(sh, sector, previous); | |
69 | } else { | |
70 | if (atomic_read(&sh->count)) { | |
71 | BUG_ON(!list_empty(&sh->lru)); | |
72 | @@ -2481,8 +2484,7 @@ static void handle_stripe_expansion(raid | |
73 | conf->raid_disks - | |
74 | conf->max_degraded, &dd_idx, | |
75 | &pd_idx, conf); | |
76 | - sh2 = get_active_stripe(conf, s, conf->raid_disks, | |
77 | - pd_idx, 1); | |
78 | + sh2 = get_active_stripe(conf, s, 0, 1); | |
79 | if (sh2 == NULL) | |
80 | /* so far only the early blocks of this stripe | |
81 | * have been requested. When later blocks | |
82 | @@ -3412,8 +3414,10 @@ static int make_request(struct request_q | |
83 | for (;logical_sector < last_sector; logical_sector += STRIPE_SECTORS) { | |
84 | DEFINE_WAIT(w); | |
85 | int disks, data_disks; | |
86 | + int previous; | |
87 | ||
88 | retry: | |
89 | + previous = 0; | |
90 | prepare_to_wait(&conf->wait_for_overlap, &w, TASK_UNINTERRUPTIBLE); | |
91 | if (likely(conf->expand_progress == MaxSector)) | |
92 | disks = conf->raid_disks; | |
93 | @@ -3428,9 +3432,10 @@ static int make_request(struct request_q | |
94 | */ | |
95 | spin_lock_irq(&conf->device_lock); | |
96 | disks = conf->raid_disks; | |
97 | - if (logical_sector >= conf->expand_progress) | |
98 | + if (logical_sector >= conf->expand_progress) { | |
99 | disks = conf->previous_raid_disks; | |
100 | - else { | |
101 | + previous = 1; | |
102 | + } else { | |
103 | if (logical_sector >= conf->expand_lo) { | |
104 | spin_unlock_irq(&conf->device_lock); | |
105 | schedule(); | |
106 | @@ -3447,7 +3452,8 @@ static int make_request(struct request_q | |
107 | (unsigned long long)new_sector, | |
108 | (unsigned long long)logical_sector); | |
109 | ||
110 | - sh = get_active_stripe(conf, new_sector, disks, pd_idx, (bi->bi_rw&RWA_MASK)); | |
111 | + sh = get_active_stripe(conf, new_sector, previous, | |
112 | + (bi->bi_rw&RWA_MASK)); | |
113 | if (sh) { | |
114 | if (unlikely(conf->expand_progress != MaxSector)) { | |
115 | /* expansion might have moved on while waiting for a | |
116 | @@ -3581,9 +3587,7 @@ static sector_t reshape_request(mddev_t | |
117 | for (i=0; i < conf->chunk_size/512; i+= STRIPE_SECTORS) { | |
118 | int j; | |
119 | int skipped = 0; | |
120 | - pd_idx = stripe_to_pdidx(sector_nr+i, conf, conf->raid_disks); | |
121 | - sh = get_active_stripe(conf, sector_nr+i, | |
122 | - conf->raid_disks, pd_idx, 0); | |
123 | + sh = get_active_stripe(conf, sector_nr+i, 0, 0); | |
124 | set_bit(STRIPE_EXPANDING, &sh->state); | |
125 | atomic_inc(&conf->reshape_stripes); | |
126 | /* If any of this stripe is beyond the end of the old | |
127 | @@ -3631,10 +3635,7 @@ static sector_t reshape_request(mddev_t | |
128 | if (last_sector >= (mddev->size<<1)) | |
129 | last_sector = (mddev->size<<1)-1; | |
130 | while (first_sector <= last_sector) { | |
131 | - pd_idx = stripe_to_pdidx(first_sector, conf, | |
132 | - conf->previous_raid_disks); | |
133 | - sh = get_active_stripe(conf, first_sector, | |
134 | - conf->previous_raid_disks, pd_idx, 0); | |
135 | + sh = get_active_stripe(conf, first_sector, 1, 0); | |
136 | set_bit(STRIPE_EXPAND_SOURCE, &sh->state); | |
137 | set_bit(STRIPE_HANDLE, &sh->state); | |
138 | release_stripe(sh); | |
139 | @@ -3724,9 +3725,9 @@ static inline sector_t sync_request(mdde | |
140 | bitmap_cond_end_sync(mddev->bitmap, sector_nr); | |
141 | ||
142 | pd_idx = stripe_to_pdidx(sector_nr, conf, raid_disks); | |
143 | - sh = get_active_stripe(conf, sector_nr, raid_disks, pd_idx, 1); | |
144 | + sh = get_active_stripe(conf, sector_nr, 0, 1); | |
145 | if (sh == NULL) { | |
146 | - sh = get_active_stripe(conf, sector_nr, raid_disks, pd_idx, 0); | |
147 | + sh = get_active_stripe(conf, sector_nr, 0, 0); | |
148 | /* make sure we don't swamp the stripe cache if someone else | |
149 | * is trying to get access | |
150 | */ | |
151 | @@ -3792,7 +3793,7 @@ static int retry_aligned_read(raid5_con | |
152 | /* already done this stripe */ | |
153 | continue; | |
154 | ||
155 | - sh = get_active_stripe(conf, sector, conf->raid_disks, pd_idx, 1); | |
156 | + sh = get_active_stripe(conf, sector, 0, 1); | |
157 | ||
158 | if (!sh) { | |
159 | /* failed to get a stripe - must wait */ |