@@ -255,7 +255,7 @@ static void free_r1bio(struct r1bio *r1_bio)
255
255
struct r1conf * conf = r1_bio -> mddev -> private ;
256
256
257
257
put_all_bios (conf , r1_bio );
258
- mempool_free (r1_bio , & conf -> r1bio_pool );
258
+ mempool_free (r1_bio , conf -> r1bio_pool );
259
259
}
260
260
261
261
static void put_buf (struct r1bio * r1_bio )
@@ -1305,9 +1305,8 @@ alloc_r1bio(struct mddev *mddev, struct bio *bio)
1305
1305
struct r1conf * conf = mddev -> private ;
1306
1306
struct r1bio * r1_bio ;
1307
1307
1308
- r1_bio = mempool_alloc (& conf -> r1bio_pool , GFP_NOIO );
1309
- /* Ensure no bio records IO_BLOCKED */
1310
- memset (r1_bio -> bios , 0 , conf -> raid_disks * sizeof (r1_bio -> bios [0 ]));
1308
+ r1_bio = mempool_alloc (conf -> r1bio_pool , GFP_NOIO );
1309
+ memset (r1_bio , 0 , offsetof(struct r1bio , bios [conf -> raid_disks * 2 ]));
1311
1310
init_r1bio (r1_bio , mddev , bio );
1312
1311
return r1_bio ;
1313
1312
}
@@ -3085,6 +3084,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
3085
3084
int i ;
3086
3085
struct raid1_info * disk ;
3087
3086
struct md_rdev * rdev ;
3087
+ size_t r1bio_size ;
3088
3088
int err = - ENOMEM ;
3089
3089
3090
3090
conf = kzalloc (sizeof (struct r1conf ), GFP_KERNEL );
@@ -3125,9 +3125,10 @@ static struct r1conf *setup_conf(struct mddev *mddev)
3125
3125
if (!conf -> poolinfo )
3126
3126
goto abort ;
3127
3127
conf -> poolinfo -> raid_disks = mddev -> raid_disks * 2 ;
3128
- err = mempool_init (& conf -> r1bio_pool , NR_RAID_BIOS , r1bio_pool_alloc ,
3129
- rbio_pool_free , conf -> poolinfo );
3130
- if (err )
3128
+
3129
+ r1bio_size = offsetof(struct r1bio , bios [mddev -> raid_disks * 2 ]);
3130
+ conf -> r1bio_pool = mempool_create_kmalloc_pool (NR_RAID_BIOS , r1bio_size );
3131
+ if (!conf -> r1bio_pool )
3131
3132
goto abort ;
3132
3133
3133
3134
err = bioset_init (& conf -> bio_split , BIO_POOL_SIZE , 0 , 0 );
@@ -3198,7 +3199,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
3198
3199
3199
3200
abort :
3200
3201
if (conf ) {
3201
- mempool_exit ( & conf -> r1bio_pool );
3202
+ mempool_destroy ( conf -> r1bio_pool );
3202
3203
kfree (conf -> mirrors );
3203
3204
safe_put_page (conf -> tmppage );
3204
3205
kfree (conf -> poolinfo );
@@ -3311,7 +3312,7 @@ static void raid1_free(struct mddev *mddev, void *priv)
3311
3312
{
3312
3313
struct r1conf * conf = priv ;
3313
3314
3314
- mempool_exit ( & conf -> r1bio_pool );
3315
+ mempool_destroy ( conf -> r1bio_pool );
3315
3316
kfree (conf -> mirrors );
3316
3317
safe_put_page (conf -> tmppage );
3317
3318
kfree (conf -> poolinfo );
@@ -3367,17 +3368,14 @@ static int raid1_reshape(struct mddev *mddev)
3367
3368
* At the same time, we "pack" the devices so that all the missing
3368
3369
* devices have the higher raid_disk numbers.
3369
3370
*/
3370
- mempool_t newpool , oldpool ;
3371
+ mempool_t * newpool , * oldpool ;
3371
3372
struct pool_info * newpoolinfo ;
3373
+ size_t new_r1bio_size ;
3372
3374
struct raid1_info * newmirrors ;
3373
3375
struct r1conf * conf = mddev -> private ;
3374
3376
int cnt , raid_disks ;
3375
3377
unsigned long flags ;
3376
3378
int d , d2 ;
3377
- int ret ;
3378
-
3379
- memset (& newpool , 0 , sizeof (newpool ));
3380
- memset (& oldpool , 0 , sizeof (oldpool ));
3381
3379
3382
3380
/* Cannot change chunk_size, layout, or level */
3383
3381
if (mddev -> chunk_sectors != mddev -> new_chunk_sectors ||
@@ -3409,18 +3407,18 @@ static int raid1_reshape(struct mddev *mddev)
3409
3407
newpoolinfo -> mddev = mddev ;
3410
3408
newpoolinfo -> raid_disks = raid_disks * 2 ;
3411
3409
3412
- ret = mempool_init ( & newpool , NR_RAID_BIOS , r1bio_pool_alloc ,
3413
- rbio_pool_free , newpoolinfo );
3414
- if (ret ) {
3410
+ new_r1bio_size = offsetof( struct r1bio , bios [ raid_disks * 2 ]);
3411
+ newpool = mempool_create_kmalloc_pool ( NR_RAID_BIOS , new_r1bio_size );
3412
+ if (! newpool ) {
3415
3413
kfree (newpoolinfo );
3416
- return ret ;
3414
+ return - ENOMEM ;
3417
3415
}
3418
3416
newmirrors = kzalloc (array3_size (sizeof (struct raid1_info ),
3419
3417
raid_disks , 2 ),
3420
3418
GFP_KERNEL );
3421
3419
if (!newmirrors ) {
3422
3420
kfree (newpoolinfo );
3423
- mempool_exit ( & newpool );
3421
+ mempool_destroy ( newpool );
3424
3422
return - ENOMEM ;
3425
3423
}
3426
3424
@@ -3429,7 +3427,6 @@ static int raid1_reshape(struct mddev *mddev)
3429
3427
/* ok, everything is stopped */
3430
3428
oldpool = conf -> r1bio_pool ;
3431
3429
conf -> r1bio_pool = newpool ;
3432
- init_waitqueue_head (& conf -> r1bio_pool .wait );
3433
3430
3434
3431
for (d = d2 = 0 ; d < conf -> raid_disks ; d ++ ) {
3435
3432
struct md_rdev * rdev = conf -> mirrors [d ].rdev ;
@@ -3461,7 +3458,7 @@ static int raid1_reshape(struct mddev *mddev)
3461
3458
set_bit (MD_RECOVERY_NEEDED , & mddev -> recovery );
3462
3459
md_wakeup_thread (mddev -> thread );
3463
3460
3464
- mempool_exit ( & oldpool );
3461
+ mempool_destroy ( oldpool );
3465
3462
return 0 ;
3466
3463
}
3467
3464
0 commit comments