@@ -127,10 +127,9 @@ static inline struct r1bio *get_resync_r1bio(struct bio *bio)
127
127
return get_resync_pages (bio )-> raid_bio ;
128
128
}
129
129
130
- static void * r1bio_pool_alloc (gfp_t gfp_flags , void * data )
130
+ static void * r1bio_pool_alloc (gfp_t gfp_flags , struct r1conf * conf )
131
131
{
132
- struct pool_info * pi = data ;
133
- int size = offsetof(struct r1bio , bios [pi -> raid_disks ]);
132
+ int size = offsetof(struct r1bio , bios [conf -> raid_disks * 2 ]);
134
133
135
134
/* allocate a r1bio with room for raid_disks entries in the bios array */
136
135
return kzalloc (size , gfp_flags );
@@ -145,26 +144,26 @@ static void * r1bio_pool_alloc(gfp_t gfp_flags, void *data)
145
144
146
145
static void * r1buf_pool_alloc (gfp_t gfp_flags , void * data )
147
146
{
148
- struct pool_info * pi = data ;
147
+ struct r1conf * conf = data ;
149
148
struct r1bio * r1_bio ;
150
149
struct bio * bio ;
151
150
int need_pages ;
152
151
int j ;
153
152
struct resync_pages * rps ;
154
153
155
- r1_bio = r1bio_pool_alloc (gfp_flags , pi );
154
+ r1_bio = r1bio_pool_alloc (gfp_flags , conf );
156
155
if (!r1_bio )
157
156
return NULL ;
158
157
159
- rps = kmalloc_array (pi -> raid_disks , sizeof (struct resync_pages ),
158
+ rps = kmalloc_array (conf -> raid_disks * 2 , sizeof (struct resync_pages ),
160
159
gfp_flags );
161
160
if (!rps )
162
161
goto out_free_r1bio ;
163
162
164
163
/*
165
164
* Allocate bios : 1 for reading, n-1 for writing
166
165
*/
167
- for (j = pi -> raid_disks ; j -- ; ) {
166
+ for (j = conf -> raid_disks * 2 ; j -- ; ) {
168
167
bio = bio_kmalloc (RESYNC_PAGES , gfp_flags );
169
168
if (!bio )
170
169
goto out_free_bio ;
@@ -177,11 +176,11 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
177
176
* If this is a user-requested check/repair, allocate
178
177
* RESYNC_PAGES for each bio.
179
178
*/
180
- if (test_bit (MD_RECOVERY_REQUESTED , & pi -> mddev -> recovery ))
181
- need_pages = pi -> raid_disks ;
179
+ if (test_bit (MD_RECOVERY_REQUESTED , & conf -> mddev -> recovery ))
180
+ need_pages = conf -> raid_disks * 2 ;
182
181
else
183
182
need_pages = 1 ;
184
- for (j = 0 ; j < pi -> raid_disks ; j ++ ) {
183
+ for (j = 0 ; j < conf -> raid_disks * 2 ; j ++ ) {
185
184
struct resync_pages * rp = & rps [j ];
186
185
187
186
bio = r1_bio -> bios [j ];
@@ -207,7 +206,7 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
207
206
resync_free_pages (& rps [j ]);
208
207
209
208
out_free_bio :
210
- while (++ j < pi -> raid_disks ) {
209
+ while (++ j < conf -> raid_disks * 2 ) {
211
210
bio_uninit (r1_bio -> bios [j ]);
212
211
kfree (r1_bio -> bios [j ]);
213
212
}
@@ -220,12 +219,12 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
220
219
221
220
static void r1buf_pool_free (void * __r1_bio , void * data )
222
221
{
223
- struct pool_info * pi = data ;
222
+ struct r1conf * conf = data ;
224
223
int i ;
225
224
struct r1bio * r1bio = __r1_bio ;
226
225
struct resync_pages * rp = NULL ;
227
226
228
- for (i = pi -> raid_disks ; i -- ; ) {
227
+ for (i = conf -> raid_disks * 2 ; i -- ; ) {
229
228
rp = get_resync_pages (r1bio -> bios [i ]);
230
229
resync_free_pages (rp );
231
230
bio_uninit (r1bio -> bios [i ]);
@@ -2746,7 +2745,7 @@ static int init_resync(struct r1conf *conf)
2746
2745
BUG_ON (mempool_initialized (& conf -> r1buf_pool ));
2747
2746
2748
2747
return mempool_init (& conf -> r1buf_pool , buffs , r1buf_pool_alloc ,
2749
- r1buf_pool_free , conf -> poolinfo );
2748
+ r1buf_pool_free , conf );
2750
2749
}
2751
2750
2752
2751
static struct r1bio * raid1_alloc_init_r1buf (struct r1conf * conf )
@@ -2756,7 +2755,7 @@ static struct r1bio *raid1_alloc_init_r1buf(struct r1conf *conf)
2756
2755
struct bio * bio ;
2757
2756
int i ;
2758
2757
2759
- for (i = conf -> poolinfo -> raid_disks ; i -- ; ) {
2758
+ for (i = conf -> raid_disks * 2 ; i -- ; ) {
2760
2759
bio = r1bio -> bios [i ];
2761
2760
rps = bio -> bi_private ;
2762
2761
bio_reset (bio , NULL , 0 );
@@ -3121,11 +3120,6 @@ static struct r1conf *setup_conf(struct mddev *mddev)
3121
3120
if (!conf -> tmppage )
3122
3121
goto abort ;
3123
3122
3124
- conf -> poolinfo = kzalloc (sizeof (* conf -> poolinfo ), GFP_KERNEL );
3125
- if (!conf -> poolinfo )
3126
- goto abort ;
3127
- conf -> poolinfo -> raid_disks = mddev -> raid_disks * 2 ;
3128
-
3129
3123
r1bio_size = offsetof(struct r1bio , bios [mddev -> raid_disks * 2 ]);
3130
3124
conf -> r1bio_pool = mempool_create_kmalloc_pool (NR_RAID_BIOS , r1bio_size );
3131
3125
if (!conf -> r1bio_pool )
@@ -3135,8 +3129,6 @@ static struct r1conf *setup_conf(struct mddev *mddev)
3135
3129
if (err )
3136
3130
goto abort ;
3137
3131
3138
- conf -> poolinfo -> mddev = mddev ;
3139
-
3140
3132
err = - EINVAL ;
3141
3133
spin_lock_init (& conf -> device_lock );
3142
3134
conf -> raid_disks = mddev -> raid_disks ;
@@ -3202,7 +3194,6 @@ static struct r1conf *setup_conf(struct mddev *mddev)
3202
3194
mempool_destroy (conf -> r1bio_pool );
3203
3195
kfree (conf -> mirrors );
3204
3196
safe_put_page (conf -> tmppage );
3205
- kfree (conf -> poolinfo );
3206
3197
kfree (conf -> nr_pending );
3207
3198
kfree (conf -> nr_waiting );
3208
3199
kfree (conf -> nr_queued );
@@ -3315,7 +3306,6 @@ static void raid1_free(struct mddev *mddev, void *priv)
3315
3306
mempool_destroy (conf -> r1bio_pool );
3316
3307
kfree (conf -> mirrors );
3317
3308
safe_put_page (conf -> tmppage );
3318
- kfree (conf -> poolinfo );
3319
3309
kfree (conf -> nr_pending );
3320
3310
kfree (conf -> nr_waiting );
3321
3311
kfree (conf -> nr_queued );
@@ -3369,7 +3359,6 @@ static int raid1_reshape(struct mddev *mddev)
3369
3359
* devices have the higher raid_disk numbers.
3370
3360
*/
3371
3361
mempool_t * newpool , * oldpool ;
3372
- struct pool_info * newpoolinfo ;
3373
3362
size_t new_r1bio_size ;
3374
3363
struct raid1_info * newmirrors ;
3375
3364
struct r1conf * conf = mddev -> private ;
@@ -3401,23 +3390,15 @@ static int raid1_reshape(struct mddev *mddev)
3401
3390
return - EBUSY ;
3402
3391
}
3403
3392
3404
- newpoolinfo = kmalloc (sizeof (* newpoolinfo ), GFP_KERNEL );
3405
- if (!newpoolinfo )
3406
- return - ENOMEM ;
3407
- newpoolinfo -> mddev = mddev ;
3408
- newpoolinfo -> raid_disks = raid_disks * 2 ;
3409
-
3410
3393
new_r1bio_size = offsetof(struct r1bio , bios [raid_disks * 2 ]);
3411
3394
newpool = mempool_create_kmalloc_pool (NR_RAID_BIOS , new_r1bio_size );
3412
3395
if (!newpool ) {
3413
- kfree (newpoolinfo );
3414
3396
return - ENOMEM ;
3415
3397
}
3416
3398
newmirrors = kzalloc (array3_size (sizeof (struct raid1_info ),
3417
3399
raid_disks , 2 ),
3418
3400
GFP_KERNEL );
3419
3401
if (!newmirrors ) {
3420
- kfree (newpoolinfo );
3421
3402
mempool_destroy (newpool );
3422
3403
return - ENOMEM ;
3423
3404
}
@@ -3443,8 +3424,6 @@ static int raid1_reshape(struct mddev *mddev)
3443
3424
}
3444
3425
kfree (conf -> mirrors );
3445
3426
conf -> mirrors = newmirrors ;
3446
- kfree (conf -> poolinfo );
3447
- conf -> poolinfo = newpoolinfo ;
3448
3427
3449
3428
spin_lock_irqsave (& conf -> device_lock , flags );
3450
3429
mddev -> degraded += (raid_disks - conf -> raid_disks );
0 commit comments