提交 afeee514 编写于 作者: K Kent Overstreet 提交者: Jens Axboe

md: convert to bioset_init()/mempool_init()

Convert md to embedded bio sets.
Signed-off-by: NKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
上级 d19936a2
...@@ -214,7 +214,7 @@ static bool faulty_make_request(struct mddev *mddev, struct bio *bio) ...@@ -214,7 +214,7 @@ static bool faulty_make_request(struct mddev *mddev, struct bio *bio)
} }
} }
if (failit) { if (failit) {
struct bio *b = bio_clone_fast(bio, GFP_NOIO, mddev->bio_set); struct bio *b = bio_clone_fast(bio, GFP_NOIO, &mddev->bio_set);
bio_set_dev(b, conf->rdev->bdev); bio_set_dev(b, conf->rdev->bdev);
b->bi_private = bio; b->bi_private = bio;
......
...@@ -269,7 +269,7 @@ static bool linear_make_request(struct mddev *mddev, struct bio *bio) ...@@ -269,7 +269,7 @@ static bool linear_make_request(struct mddev *mddev, struct bio *bio)
if (unlikely(bio_end_sector(bio) > end_sector)) { if (unlikely(bio_end_sector(bio) > end_sector)) {
/* This bio crosses a device boundary, so we have to split it */ /* This bio crosses a device boundary, so we have to split it */
struct bio *split = bio_split(bio, end_sector - bio_sector, struct bio *split = bio_split(bio, end_sector - bio_sector,
GFP_NOIO, mddev->bio_set); GFP_NOIO, &mddev->bio_set);
bio_chain(split, bio); bio_chain(split, bio);
generic_make_request(bio); generic_make_request(bio);
bio = split; bio = split;
......
...@@ -80,7 +80,7 @@ static void multipath_end_bh_io(struct multipath_bh *mp_bh, blk_status_t status) ...@@ -80,7 +80,7 @@ static void multipath_end_bh_io(struct multipath_bh *mp_bh, blk_status_t status)
bio->bi_status = status; bio->bi_status = status;
bio_endio(bio); bio_endio(bio);
mempool_free(mp_bh, conf->pool); mempool_free(mp_bh, &conf->pool);
} }
static void multipath_end_request(struct bio *bio) static void multipath_end_request(struct bio *bio)
...@@ -117,7 +117,7 @@ static bool multipath_make_request(struct mddev *mddev, struct bio * bio) ...@@ -117,7 +117,7 @@ static bool multipath_make_request(struct mddev *mddev, struct bio * bio)
return true; return true;
} }
mp_bh = mempool_alloc(conf->pool, GFP_NOIO); mp_bh = mempool_alloc(&conf->pool, GFP_NOIO);
mp_bh->master_bio = bio; mp_bh->master_bio = bio;
mp_bh->mddev = mddev; mp_bh->mddev = mddev;
...@@ -125,7 +125,7 @@ static bool multipath_make_request(struct mddev *mddev, struct bio * bio) ...@@ -125,7 +125,7 @@ static bool multipath_make_request(struct mddev *mddev, struct bio * bio)
mp_bh->path = multipath_map(conf); mp_bh->path = multipath_map(conf);
if (mp_bh->path < 0) { if (mp_bh->path < 0) {
bio_io_error(bio); bio_io_error(bio);
mempool_free(mp_bh, conf->pool); mempool_free(mp_bh, &conf->pool);
return true; return true;
} }
multipath = conf->multipaths + mp_bh->path; multipath = conf->multipaths + mp_bh->path;
...@@ -378,6 +378,7 @@ static int multipath_run (struct mddev *mddev) ...@@ -378,6 +378,7 @@ static int multipath_run (struct mddev *mddev)
struct multipath_info *disk; struct multipath_info *disk;
struct md_rdev *rdev; struct md_rdev *rdev;
int working_disks; int working_disks;
int ret;
if (md_check_no_bitmap(mddev)) if (md_check_no_bitmap(mddev))
return -EINVAL; return -EINVAL;
...@@ -431,9 +432,9 @@ static int multipath_run (struct mddev *mddev) ...@@ -431,9 +432,9 @@ static int multipath_run (struct mddev *mddev)
} }
mddev->degraded = conf->raid_disks - working_disks; mddev->degraded = conf->raid_disks - working_disks;
conf->pool = mempool_create_kmalloc_pool(NR_RESERVED_BUFS, ret = mempool_init_kmalloc_pool(&conf->pool, NR_RESERVED_BUFS,
sizeof(struct multipath_bh)); sizeof(struct multipath_bh));
if (conf->pool == NULL) if (ret)
goto out_free_conf; goto out_free_conf;
mddev->thread = md_register_thread(multipathd, mddev, mddev->thread = md_register_thread(multipathd, mddev,
...@@ -455,7 +456,7 @@ static int multipath_run (struct mddev *mddev) ...@@ -455,7 +456,7 @@ static int multipath_run (struct mddev *mddev)
return 0; return 0;
out_free_conf: out_free_conf:
mempool_destroy(conf->pool); mempool_exit(&conf->pool);
kfree(conf->multipaths); kfree(conf->multipaths);
kfree(conf); kfree(conf);
mddev->private = NULL; mddev->private = NULL;
...@@ -467,7 +468,7 @@ static void multipath_free(struct mddev *mddev, void *priv) ...@@ -467,7 +468,7 @@ static void multipath_free(struct mddev *mddev, void *priv)
{ {
struct mpconf *conf = priv; struct mpconf *conf = priv;
mempool_destroy(conf->pool); mempool_exit(&conf->pool);
kfree(conf->multipaths); kfree(conf->multipaths);
kfree(conf); kfree(conf);
} }
......
...@@ -13,7 +13,7 @@ struct mpconf { ...@@ -13,7 +13,7 @@ struct mpconf {
spinlock_t device_lock; spinlock_t device_lock;
struct list_head retry_list; struct list_head retry_list;
mempool_t *pool; mempool_t pool;
}; };
/* /*
......
...@@ -193,10 +193,10 @@ struct bio *bio_alloc_mddev(gfp_t gfp_mask, int nr_iovecs, ...@@ -193,10 +193,10 @@ struct bio *bio_alloc_mddev(gfp_t gfp_mask, int nr_iovecs,
{ {
struct bio *b; struct bio *b;
if (!mddev || !mddev->bio_set) if (!mddev || !bioset_initialized(&mddev->bio_set))
return bio_alloc(gfp_mask, nr_iovecs); return bio_alloc(gfp_mask, nr_iovecs);
b = bio_alloc_bioset(gfp_mask, nr_iovecs, mddev->bio_set); b = bio_alloc_bioset(gfp_mask, nr_iovecs, &mddev->bio_set);
if (!b) if (!b)
return NULL; return NULL;
return b; return b;
...@@ -205,10 +205,10 @@ EXPORT_SYMBOL_GPL(bio_alloc_mddev); ...@@ -205,10 +205,10 @@ EXPORT_SYMBOL_GPL(bio_alloc_mddev);
static struct bio *md_bio_alloc_sync(struct mddev *mddev) static struct bio *md_bio_alloc_sync(struct mddev *mddev)
{ {
if (!mddev || !mddev->sync_set) if (!mddev || !bioset_initialized(&mddev->sync_set))
return bio_alloc(GFP_NOIO, 1); return bio_alloc(GFP_NOIO, 1);
return bio_alloc_bioset(GFP_NOIO, 1, mddev->sync_set); return bio_alloc_bioset(GFP_NOIO, 1, &mddev->sync_set);
} }
/* /*
...@@ -510,7 +510,10 @@ static void mddev_delayed_delete(struct work_struct *ws); ...@@ -510,7 +510,10 @@ static void mddev_delayed_delete(struct work_struct *ws);
static void mddev_put(struct mddev *mddev) static void mddev_put(struct mddev *mddev)
{ {
struct bio_set *bs = NULL, *sync_bs = NULL; struct bio_set bs, sync_bs;
memset(&bs, 0, sizeof(bs));
memset(&sync_bs, 0, sizeof(sync_bs));
if (!atomic_dec_and_lock(&mddev->active, &all_mddevs_lock)) if (!atomic_dec_and_lock(&mddev->active, &all_mddevs_lock))
return; return;
...@@ -521,8 +524,8 @@ static void mddev_put(struct mddev *mddev) ...@@ -521,8 +524,8 @@ static void mddev_put(struct mddev *mddev)
list_del_init(&mddev->all_mddevs); list_del_init(&mddev->all_mddevs);
bs = mddev->bio_set; bs = mddev->bio_set;
sync_bs = mddev->sync_set; sync_bs = mddev->sync_set;
mddev->bio_set = NULL; memset(&mddev->bio_set, 0, sizeof(mddev->bio_set));
mddev->sync_set = NULL; memset(&mddev->sync_set, 0, sizeof(mddev->sync_set));
if (mddev->gendisk) { if (mddev->gendisk) {
/* We did a probe so need to clean up. Call /* We did a probe so need to clean up. Call
* queue_work inside the spinlock so that * queue_work inside the spinlock so that
...@@ -535,10 +538,8 @@ static void mddev_put(struct mddev *mddev) ...@@ -535,10 +538,8 @@ static void mddev_put(struct mddev *mddev)
kfree(mddev); kfree(mddev);
} }
spin_unlock(&all_mddevs_lock); spin_unlock(&all_mddevs_lock);
if (bs) bioset_exit(&bs);
bioset_free(bs); bioset_exit(&sync_bs);
if (sync_bs)
bioset_free(sync_bs);
} }
static void md_safemode_timeout(struct timer_list *t); static void md_safemode_timeout(struct timer_list *t);
...@@ -2123,7 +2124,7 @@ int md_integrity_register(struct mddev *mddev) ...@@ -2123,7 +2124,7 @@ int md_integrity_register(struct mddev *mddev)
bdev_get_integrity(reference->bdev)); bdev_get_integrity(reference->bdev));
pr_debug("md: data integrity enabled on %s\n", mdname(mddev)); pr_debug("md: data integrity enabled on %s\n", mdname(mddev));
if (bioset_integrity_create(mddev->bio_set, BIO_POOL_SIZE)) { if (bioset_integrity_create(&mddev->bio_set, BIO_POOL_SIZE)) {
pr_err("md: failed to create integrity pool for %s\n", pr_err("md: failed to create integrity pool for %s\n",
mdname(mddev)); mdname(mddev));
return -EINVAL; return -EINVAL;
...@@ -5497,17 +5498,15 @@ int md_run(struct mddev *mddev) ...@@ -5497,17 +5498,15 @@ int md_run(struct mddev *mddev)
sysfs_notify_dirent_safe(rdev->sysfs_state); sysfs_notify_dirent_safe(rdev->sysfs_state);
} }
if (mddev->bio_set == NULL) { if (!bioset_initialized(&mddev->bio_set)) {
mddev->bio_set = bioset_create(BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS); err = bioset_init(&mddev->bio_set, BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS);
if (!mddev->bio_set) if (err)
return -ENOMEM; return err;
} }
if (mddev->sync_set == NULL) { if (!bioset_initialized(&mddev->sync_set)) {
mddev->sync_set = bioset_create(BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS); err = bioset_init(&mddev->sync_set, BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS);
if (!mddev->sync_set) { if (err)
err = -ENOMEM;
goto abort; goto abort;
}
} }
spin_lock(&pers_lock); spin_lock(&pers_lock);
...@@ -5668,14 +5667,8 @@ int md_run(struct mddev *mddev) ...@@ -5668,14 +5667,8 @@ int md_run(struct mddev *mddev)
return 0; return 0;
abort: abort:
if (mddev->bio_set) { bioset_exit(&mddev->bio_set);
bioset_free(mddev->bio_set); bioset_exit(&mddev->sync_set);
mddev->bio_set = NULL;
}
if (mddev->sync_set) {
bioset_free(mddev->sync_set);
mddev->sync_set = NULL;
}
return err; return err;
} }
...@@ -5888,14 +5881,8 @@ void md_stop(struct mddev *mddev) ...@@ -5888,14 +5881,8 @@ void md_stop(struct mddev *mddev)
* This is called from dm-raid * This is called from dm-raid
*/ */
__md_stop(mddev); __md_stop(mddev);
if (mddev->bio_set) { bioset_exit(&mddev->bio_set);
bioset_free(mddev->bio_set); bioset_exit(&mddev->sync_set);
mddev->bio_set = NULL;
}
if (mddev->sync_set) {
bioset_free(mddev->sync_set);
mddev->sync_set = NULL;
}
} }
EXPORT_SYMBOL_GPL(md_stop); EXPORT_SYMBOL_GPL(md_stop);
......
...@@ -452,8 +452,8 @@ struct mddev { ...@@ -452,8 +452,8 @@ struct mddev {
struct attribute_group *to_remove; struct attribute_group *to_remove;
struct bio_set *bio_set; struct bio_set bio_set;
struct bio_set *sync_set; /* for sync operations like struct bio_set sync_set; /* for sync operations like
* metadata and bitmap writes * metadata and bitmap writes
*/ */
......
...@@ -479,7 +479,7 @@ static void raid0_handle_discard(struct mddev *mddev, struct bio *bio) ...@@ -479,7 +479,7 @@ static void raid0_handle_discard(struct mddev *mddev, struct bio *bio)
if (bio_end_sector(bio) > zone->zone_end) { if (bio_end_sector(bio) > zone->zone_end) {
struct bio *split = bio_split(bio, struct bio *split = bio_split(bio,
zone->zone_end - bio->bi_iter.bi_sector, GFP_NOIO, zone->zone_end - bio->bi_iter.bi_sector, GFP_NOIO,
mddev->bio_set); &mddev->bio_set);
bio_chain(split, bio); bio_chain(split, bio);
generic_make_request(bio); generic_make_request(bio);
bio = split; bio = split;
...@@ -582,7 +582,8 @@ static bool raid0_make_request(struct mddev *mddev, struct bio *bio) ...@@ -582,7 +582,8 @@ static bool raid0_make_request(struct mddev *mddev, struct bio *bio)
sector = bio_sector; sector = bio_sector;
if (sectors < bio_sectors(bio)) { if (sectors < bio_sectors(bio)) {
struct bio *split = bio_split(bio, sectors, GFP_NOIO, mddev->bio_set); struct bio *split = bio_split(bio, sectors, GFP_NOIO,
&mddev->bio_set);
bio_chain(split, bio); bio_chain(split, bio);
generic_make_request(bio); generic_make_request(bio);
bio = split; bio = split;
......
...@@ -221,7 +221,7 @@ static void free_r1bio(struct r1bio *r1_bio) ...@@ -221,7 +221,7 @@ static void free_r1bio(struct r1bio *r1_bio)
struct r1conf *conf = r1_bio->mddev->private; struct r1conf *conf = r1_bio->mddev->private;
put_all_bios(conf, r1_bio); put_all_bios(conf, r1_bio);
mempool_free(r1_bio, conf->r1bio_pool); mempool_free(r1_bio, &conf->r1bio_pool);
} }
static void put_buf(struct r1bio *r1_bio) static void put_buf(struct r1bio *r1_bio)
...@@ -236,7 +236,7 @@ static void put_buf(struct r1bio *r1_bio) ...@@ -236,7 +236,7 @@ static void put_buf(struct r1bio *r1_bio)
rdev_dec_pending(conf->mirrors[i].rdev, r1_bio->mddev); rdev_dec_pending(conf->mirrors[i].rdev, r1_bio->mddev);
} }
mempool_free(r1_bio, conf->r1buf_pool); mempool_free(r1_bio, &conf->r1buf_pool);
lower_barrier(conf, sect); lower_barrier(conf, sect);
} }
...@@ -1178,7 +1178,7 @@ alloc_r1bio(struct mddev *mddev, struct bio *bio) ...@@ -1178,7 +1178,7 @@ alloc_r1bio(struct mddev *mddev, struct bio *bio)
struct r1conf *conf = mddev->private; struct r1conf *conf = mddev->private;
struct r1bio *r1_bio; struct r1bio *r1_bio;
r1_bio = mempool_alloc(conf->r1bio_pool, GFP_NOIO); r1_bio = mempool_alloc(&conf->r1bio_pool, GFP_NOIO);
/* Ensure no bio records IO_BLOCKED */ /* Ensure no bio records IO_BLOCKED */
memset(r1_bio->bios, 0, conf->raid_disks * sizeof(r1_bio->bios[0])); memset(r1_bio->bios, 0, conf->raid_disks * sizeof(r1_bio->bios[0]));
init_r1bio(r1_bio, mddev, bio); init_r1bio(r1_bio, mddev, bio);
...@@ -1268,7 +1268,7 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio, ...@@ -1268,7 +1268,7 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
if (max_sectors < bio_sectors(bio)) { if (max_sectors < bio_sectors(bio)) {
struct bio *split = bio_split(bio, max_sectors, struct bio *split = bio_split(bio, max_sectors,
gfp, conf->bio_split); gfp, &conf->bio_split);
bio_chain(split, bio); bio_chain(split, bio);
generic_make_request(bio); generic_make_request(bio);
bio = split; bio = split;
...@@ -1278,7 +1278,7 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio, ...@@ -1278,7 +1278,7 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
r1_bio->read_disk = rdisk; r1_bio->read_disk = rdisk;
read_bio = bio_clone_fast(bio, gfp, mddev->bio_set); read_bio = bio_clone_fast(bio, gfp, &mddev->bio_set);
r1_bio->bios[rdisk] = read_bio; r1_bio->bios[rdisk] = read_bio;
...@@ -1439,7 +1439,7 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, ...@@ -1439,7 +1439,7 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
if (max_sectors < bio_sectors(bio)) { if (max_sectors < bio_sectors(bio)) {
struct bio *split = bio_split(bio, max_sectors, struct bio *split = bio_split(bio, max_sectors,
GFP_NOIO, conf->bio_split); GFP_NOIO, &conf->bio_split);
bio_chain(split, bio); bio_chain(split, bio);
generic_make_request(bio); generic_make_request(bio);
bio = split; bio = split;
...@@ -1479,9 +1479,9 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, ...@@ -1479,9 +1479,9 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
if (r1_bio->behind_master_bio) if (r1_bio->behind_master_bio)
mbio = bio_clone_fast(r1_bio->behind_master_bio, mbio = bio_clone_fast(r1_bio->behind_master_bio,
GFP_NOIO, mddev->bio_set); GFP_NOIO, &mddev->bio_set);
else else
mbio = bio_clone_fast(bio, GFP_NOIO, mddev->bio_set); mbio = bio_clone_fast(bio, GFP_NOIO, &mddev->bio_set);
if (r1_bio->behind_master_bio) { if (r1_bio->behind_master_bio) {
if (test_bit(WriteMostly, &conf->mirrors[i].rdev->flags)) if (test_bit(WriteMostly, &conf->mirrors[i].rdev->flags))
...@@ -1657,8 +1657,7 @@ static void close_sync(struct r1conf *conf) ...@@ -1657,8 +1657,7 @@ static void close_sync(struct r1conf *conf)
_allow_barrier(conf, idx); _allow_barrier(conf, idx);
} }
mempool_destroy(conf->r1buf_pool); mempool_exit(&conf->r1buf_pool);
conf->r1buf_pool = NULL;
} }
static int raid1_spare_active(struct mddev *mddev) static int raid1_spare_active(struct mddev *mddev)
...@@ -2348,10 +2347,10 @@ static int narrow_write_error(struct r1bio *r1_bio, int i) ...@@ -2348,10 +2347,10 @@ static int narrow_write_error(struct r1bio *r1_bio, int i)
if (test_bit(R1BIO_BehindIO, &r1_bio->state)) { if (test_bit(R1BIO_BehindIO, &r1_bio->state)) {
wbio = bio_clone_fast(r1_bio->behind_master_bio, wbio = bio_clone_fast(r1_bio->behind_master_bio,
GFP_NOIO, GFP_NOIO,
mddev->bio_set); &mddev->bio_set);
} else { } else {
wbio = bio_clone_fast(r1_bio->master_bio, GFP_NOIO, wbio = bio_clone_fast(r1_bio->master_bio, GFP_NOIO,
mddev->bio_set); &mddev->bio_set);
} }
bio_set_op_attrs(wbio, REQ_OP_WRITE, 0); bio_set_op_attrs(wbio, REQ_OP_WRITE, 0);
...@@ -2564,17 +2563,15 @@ static int init_resync(struct r1conf *conf) ...@@ -2564,17 +2563,15 @@ static int init_resync(struct r1conf *conf)
int buffs; int buffs;
buffs = RESYNC_WINDOW / RESYNC_BLOCK_SIZE; buffs = RESYNC_WINDOW / RESYNC_BLOCK_SIZE;
BUG_ON(conf->r1buf_pool); BUG_ON(mempool_initialized(&conf->r1buf_pool));
conf->r1buf_pool = mempool_create(buffs, r1buf_pool_alloc, r1buf_pool_free,
conf->poolinfo); return mempool_init(&conf->r1buf_pool, buffs, r1buf_pool_alloc,
if (!conf->r1buf_pool) r1buf_pool_free, conf->poolinfo);
return -ENOMEM;
return 0;
} }
static struct r1bio *raid1_alloc_init_r1buf(struct r1conf *conf) static struct r1bio *raid1_alloc_init_r1buf(struct r1conf *conf)
{ {
struct r1bio *r1bio = mempool_alloc(conf->r1buf_pool, GFP_NOIO); struct r1bio *r1bio = mempool_alloc(&conf->r1buf_pool, GFP_NOIO);
struct resync_pages *rps; struct resync_pages *rps;
struct bio *bio; struct bio *bio;
int i; int i;
...@@ -2617,7 +2614,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr, ...@@ -2617,7 +2614,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
int idx = sector_to_idx(sector_nr); int idx = sector_to_idx(sector_nr);
int page_idx = 0; int page_idx = 0;
if (!conf->r1buf_pool) if (!mempool_initialized(&conf->r1buf_pool))
if (init_resync(conf)) if (init_resync(conf))
return 0; return 0;
...@@ -2953,14 +2950,13 @@ static struct r1conf *setup_conf(struct mddev *mddev) ...@@ -2953,14 +2950,13 @@ static struct r1conf *setup_conf(struct mddev *mddev)
if (!conf->poolinfo) if (!conf->poolinfo)
goto abort; goto abort;
conf->poolinfo->raid_disks = mddev->raid_disks * 2; conf->poolinfo->raid_disks = mddev->raid_disks * 2;
conf->r1bio_pool = mempool_create(NR_RAID1_BIOS, r1bio_pool_alloc, err = mempool_init(&conf->r1bio_pool, NR_RAID1_BIOS, r1bio_pool_alloc,
r1bio_pool_free, r1bio_pool_free, conf->poolinfo);
conf->poolinfo); if (err)
if (!conf->r1bio_pool)
goto abort; goto abort;
conf->bio_split = bioset_create(BIO_POOL_SIZE, 0, 0); err = bioset_init(&conf->bio_split, BIO_POOL_SIZE, 0, 0);
if (!conf->bio_split) if (err)
goto abort; goto abort;
conf->poolinfo->mddev = mddev; conf->poolinfo->mddev = mddev;
...@@ -3033,7 +3029,7 @@ static struct r1conf *setup_conf(struct mddev *mddev) ...@@ -3033,7 +3029,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
abort: abort:
if (conf) { if (conf) {
mempool_destroy(conf->r1bio_pool); mempool_exit(&conf->r1bio_pool);
kfree(conf->mirrors); kfree(conf->mirrors);
safe_put_page(conf->tmppage); safe_put_page(conf->tmppage);
kfree(conf->poolinfo); kfree(conf->poolinfo);
...@@ -3041,8 +3037,7 @@ static struct r1conf *setup_conf(struct mddev *mddev) ...@@ -3041,8 +3037,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
kfree(conf->nr_waiting); kfree(conf->nr_waiting);
kfree(conf->nr_queued); kfree(conf->nr_queued);
kfree(conf->barrier); kfree(conf->barrier);
if (conf->bio_split) bioset_exit(&conf->bio_split);
bioset_free(conf->bio_split);
kfree(conf); kfree(conf);
} }
return ERR_PTR(err); return ERR_PTR(err);
...@@ -3144,7 +3139,7 @@ static void raid1_free(struct mddev *mddev, void *priv) ...@@ -3144,7 +3139,7 @@ static void raid1_free(struct mddev *mddev, void *priv)
{ {
struct r1conf *conf = priv; struct r1conf *conf = priv;
mempool_destroy(conf->r1bio_pool); mempool_exit(&conf->r1bio_pool);
kfree(conf->mirrors); kfree(conf->mirrors);
safe_put_page(conf->tmppage); safe_put_page(conf->tmppage);
kfree(conf->poolinfo); kfree(conf->poolinfo);
...@@ -3152,8 +3147,7 @@ static void raid1_free(struct mddev *mddev, void *priv) ...@@ -3152,8 +3147,7 @@ static void raid1_free(struct mddev *mddev, void *priv)
kfree(conf->nr_waiting); kfree(conf->nr_waiting);
kfree(conf->nr_queued); kfree(conf->nr_queued);
kfree(conf->barrier); kfree(conf->barrier);
if (conf->bio_split) bioset_exit(&conf->bio_split);
bioset_free(conf->bio_split);
kfree(conf); kfree(conf);
} }
...@@ -3199,13 +3193,17 @@ static int raid1_reshape(struct mddev *mddev) ...@@ -3199,13 +3193,17 @@ static int raid1_reshape(struct mddev *mddev)
* At the same time, we "pack" the devices so that all the missing * At the same time, we "pack" the devices so that all the missing
* devices have the higher raid_disk numbers. * devices have the higher raid_disk numbers.
*/ */
mempool_t *newpool, *oldpool; mempool_t newpool, oldpool;
struct pool_info *newpoolinfo; struct pool_info *newpoolinfo;
struct raid1_info *newmirrors; struct raid1_info *newmirrors;
struct r1conf *conf = mddev->private; struct r1conf *conf = mddev->private;
int cnt, raid_disks; int cnt, raid_disks;
unsigned long flags; unsigned long flags;
int d, d2; int d, d2;
int ret;
memset(&newpool, 0, sizeof(newpool));
memset(&oldpool, 0, sizeof(oldpool));
/* Cannot change chunk_size, layout, or level */ /* Cannot change chunk_size, layout, or level */
if (mddev->chunk_sectors != mddev->new_chunk_sectors || if (mddev->chunk_sectors != mddev->new_chunk_sectors ||
...@@ -3237,17 +3235,17 @@ static int raid1_reshape(struct mddev *mddev) ...@@ -3237,17 +3235,17 @@ static int raid1_reshape(struct mddev *mddev)
newpoolinfo->mddev = mddev; newpoolinfo->mddev = mddev;
newpoolinfo->raid_disks = raid_disks * 2; newpoolinfo->raid_disks = raid_disks * 2;
newpool = mempool_create(NR_RAID1_BIOS, r1bio_pool_alloc, ret = mempool_init(&newpool, NR_RAID1_BIOS, r1bio_pool_alloc,
r1bio_pool_free, newpoolinfo); r1bio_pool_free, newpoolinfo);
if (!newpool) { if (ret) {
kfree(newpoolinfo); kfree(newpoolinfo);
return -ENOMEM; return ret;
} }
newmirrors = kzalloc(sizeof(struct raid1_info) * raid_disks * 2, newmirrors = kzalloc(sizeof(struct raid1_info) * raid_disks * 2,
GFP_KERNEL); GFP_KERNEL);
if (!newmirrors) { if (!newmirrors) {
kfree(newpoolinfo); kfree(newpoolinfo);
mempool_destroy(newpool); mempool_exit(&newpool);
return -ENOMEM; return -ENOMEM;
} }
...@@ -3287,7 +3285,7 @@ static int raid1_reshape(struct mddev *mddev) ...@@ -3287,7 +3285,7 @@ static int raid1_reshape(struct mddev *mddev)
set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
md_wakeup_thread(mddev->thread); md_wakeup_thread(mddev->thread);
mempool_destroy(oldpool); mempool_exit(&oldpool);
return 0; return 0;
} }
......
...@@ -118,10 +118,10 @@ struct r1conf { ...@@ -118,10 +118,10 @@ struct r1conf {
* mempools - it changes when the array grows or shrinks * mempools - it changes when the array grows or shrinks
*/ */
struct pool_info *poolinfo; struct pool_info *poolinfo;
mempool_t *r1bio_pool; mempool_t r1bio_pool;
mempool_t *r1buf_pool; mempool_t r1buf_pool;
struct bio_set *bio_split; struct bio_set bio_split;
/* temporary buffer to synchronous IO when attempting to repair /* temporary buffer to synchronous IO when attempting to repair
* a read error. * a read error.
......
...@@ -291,14 +291,14 @@ static void free_r10bio(struct r10bio *r10_bio) ...@@ -291,14 +291,14 @@ static void free_r10bio(struct r10bio *r10_bio)
struct r10conf *conf = r10_bio->mddev->private; struct r10conf *conf = r10_bio->mddev->private;
put_all_bios(conf, r10_bio); put_all_bios(conf, r10_bio);
mempool_free(r10_bio, conf->r10bio_pool); mempool_free(r10_bio, &conf->r10bio_pool);
} }
static void put_buf(struct r10bio *r10_bio) static void put_buf(struct r10bio *r10_bio)
{ {
struct r10conf *conf = r10_bio->mddev->private; struct r10conf *conf = r10_bio->mddev->private;
mempool_free(r10_bio, conf->r10buf_pool); mempool_free(r10_bio, &conf->r10buf_pool);
lower_barrier(conf); lower_barrier(conf);
} }
...@@ -1204,7 +1204,7 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio, ...@@ -1204,7 +1204,7 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio,
(unsigned long long)r10_bio->sector); (unsigned long long)r10_bio->sector);
if (max_sectors < bio_sectors(bio)) { if (max_sectors < bio_sectors(bio)) {
struct bio *split = bio_split(bio, max_sectors, struct bio *split = bio_split(bio, max_sectors,
gfp, conf->bio_split); gfp, &conf->bio_split);
bio_chain(split, bio); bio_chain(split, bio);
generic_make_request(bio); generic_make_request(bio);
bio = split; bio = split;
...@@ -1213,7 +1213,7 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio, ...@@ -1213,7 +1213,7 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio,
} }
slot = r10_bio->read_slot; slot = r10_bio->read_slot;
read_bio = bio_clone_fast(bio, gfp, mddev->bio_set); read_bio = bio_clone_fast(bio, gfp, &mddev->bio_set);
r10_bio->devs[slot].bio = read_bio; r10_bio->devs[slot].bio = read_bio;
r10_bio->devs[slot].rdev = rdev; r10_bio->devs[slot].rdev = rdev;
...@@ -1261,7 +1261,7 @@ static void raid10_write_one_disk(struct mddev *mddev, struct r10bio *r10_bio, ...@@ -1261,7 +1261,7 @@ static void raid10_write_one_disk(struct mddev *mddev, struct r10bio *r10_bio,
} else } else
rdev = conf->mirrors[devnum].rdev; rdev = conf->mirrors[devnum].rdev;
mbio = bio_clone_fast(bio, GFP_NOIO, mddev->bio_set); mbio = bio_clone_fast(bio, GFP_NOIO, &mddev->bio_set);
if (replacement) if (replacement)
r10_bio->devs[n_copy].repl_bio = mbio; r10_bio->devs[n_copy].repl_bio = mbio;
else else
...@@ -1509,7 +1509,7 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio, ...@@ -1509,7 +1509,7 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio,
if (r10_bio->sectors < bio_sectors(bio)) { if (r10_bio->sectors < bio_sectors(bio)) {
struct bio *split = bio_split(bio, r10_bio->sectors, struct bio *split = bio_split(bio, r10_bio->sectors,
GFP_NOIO, conf->bio_split); GFP_NOIO, &conf->bio_split);
bio_chain(split, bio); bio_chain(split, bio);
generic_make_request(bio); generic_make_request(bio);
bio = split; bio = split;
...@@ -1533,7 +1533,7 @@ static void __make_request(struct mddev *mddev, struct bio *bio, int sectors) ...@@ -1533,7 +1533,7 @@ static void __make_request(struct mddev *mddev, struct bio *bio, int sectors)
struct r10conf *conf = mddev->private; struct r10conf *conf = mddev->private;
struct r10bio *r10_bio; struct r10bio *r10_bio;
r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO); r10_bio = mempool_alloc(&conf->r10bio_pool, GFP_NOIO);
r10_bio->master_bio = bio; r10_bio->master_bio = bio;
r10_bio->sectors = sectors; r10_bio->sectors = sectors;
...@@ -1732,8 +1732,7 @@ static void close_sync(struct r10conf *conf) ...@@ -1732,8 +1732,7 @@ static void close_sync(struct r10conf *conf)
wait_barrier(conf); wait_barrier(conf);
allow_barrier(conf); allow_barrier(conf);
mempool_destroy(conf->r10buf_pool); mempool_exit(&conf->r10buf_pool);
conf->r10buf_pool = NULL;
} }
static int raid10_spare_active(struct mddev *mddev) static int raid10_spare_active(struct mddev *mddev)
...@@ -2583,7 +2582,7 @@ static int narrow_write_error(struct r10bio *r10_bio, int i) ...@@ -2583,7 +2582,7 @@ static int narrow_write_error(struct r10bio *r10_bio, int i)
if (sectors > sect_to_write) if (sectors > sect_to_write)
sectors = sect_to_write; sectors = sect_to_write;
/* Write at 'sector' for 'sectors' */ /* Write at 'sector' for 'sectors' */
wbio = bio_clone_fast(bio, GFP_NOIO, mddev->bio_set); wbio = bio_clone_fast(bio, GFP_NOIO, &mddev->bio_set);
bio_trim(wbio, sector - bio->bi_iter.bi_sector, sectors); bio_trim(wbio, sector - bio->bi_iter.bi_sector, sectors);
wsector = r10_bio->devs[i].addr + (sector - r10_bio->sector); wsector = r10_bio->devs[i].addr + (sector - r10_bio->sector);
wbio->bi_iter.bi_sector = wsector + wbio->bi_iter.bi_sector = wsector +
...@@ -2816,25 +2815,25 @@ static void raid10d(struct md_thread *thread) ...@@ -2816,25 +2815,25 @@ static void raid10d(struct md_thread *thread)
static int init_resync(struct r10conf *conf) static int init_resync(struct r10conf *conf)
{ {
int buffs; int ret, buffs, i;
int i;
buffs = RESYNC_WINDOW / RESYNC_BLOCK_SIZE; buffs = RESYNC_WINDOW / RESYNC_BLOCK_SIZE;
BUG_ON(conf->r10buf_pool); BUG_ON(mempool_initialized(&conf->r10buf_pool));
conf->have_replacement = 0; conf->have_replacement = 0;
for (i = 0; i < conf->geo.raid_disks; i++) for (i = 0; i < conf->geo.raid_disks; i++)
if (conf->mirrors[i].replacement) if (conf->mirrors[i].replacement)
conf->have_replacement = 1; conf->have_replacement = 1;
conf->r10buf_pool = mempool_create(buffs, r10buf_pool_alloc, r10buf_pool_free, conf); ret = mempool_init(&conf->r10buf_pool, buffs,
if (!conf->r10buf_pool) r10buf_pool_alloc, r10buf_pool_free, conf);
return -ENOMEM; if (ret)
return ret;
conf->next_resync = 0; conf->next_resync = 0;
return 0; return 0;
} }
static struct r10bio *raid10_alloc_init_r10buf(struct r10conf *conf) static struct r10bio *raid10_alloc_init_r10buf(struct r10conf *conf)
{ {
struct r10bio *r10bio = mempool_alloc(conf->r10buf_pool, GFP_NOIO); struct r10bio *r10bio = mempool_alloc(&conf->r10buf_pool, GFP_NOIO);
struct rsync_pages *rp; struct rsync_pages *rp;
struct bio *bio; struct bio *bio;
int nalloc; int nalloc;
...@@ -2945,7 +2944,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr, ...@@ -2945,7 +2944,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
sector_t chunk_mask = conf->geo.chunk_mask; sector_t chunk_mask = conf->geo.chunk_mask;
int page_idx = 0; int page_idx = 0;
if (!conf->r10buf_pool) if (!mempool_initialized(&conf->r10buf_pool))
if (init_resync(conf)) if (init_resync(conf))
return 0; return 0;
...@@ -3699,13 +3698,13 @@ static struct r10conf *setup_conf(struct mddev *mddev) ...@@ -3699,13 +3698,13 @@ static struct r10conf *setup_conf(struct mddev *mddev)
conf->geo = geo; conf->geo = geo;
conf->copies = copies; conf->copies = copies;
conf->r10bio_pool = mempool_create(NR_RAID10_BIOS, r10bio_pool_alloc, err = mempool_init(&conf->r10bio_pool, NR_RAID10_BIOS, r10bio_pool_alloc,
r10bio_pool_free, conf); r10bio_pool_free, conf);
if (!conf->r10bio_pool) if (err)
goto out; goto out;
conf->bio_split = bioset_create(BIO_POOL_SIZE, 0, 0); err = bioset_init(&conf->bio_split, BIO_POOL_SIZE, 0, 0);
if (!conf->bio_split) if (err)
goto out; goto out;
calc_sectors(conf, mddev->dev_sectors); calc_sectors(conf, mddev->dev_sectors);
...@@ -3733,6 +3732,7 @@ static struct r10conf *setup_conf(struct mddev *mddev) ...@@ -3733,6 +3732,7 @@ static struct r10conf *setup_conf(struct mddev *mddev)
init_waitqueue_head(&conf->wait_barrier); init_waitqueue_head(&conf->wait_barrier);
atomic_set(&conf->nr_pending, 0); atomic_set(&conf->nr_pending, 0);
err = -ENOMEM;
conf->thread = md_register_thread(raid10d, mddev, "raid10"); conf->thread = md_register_thread(raid10d, mddev, "raid10");
if (!conf->thread) if (!conf->thread)
goto out; goto out;
...@@ -3742,11 +3742,10 @@ static struct r10conf *setup_conf(struct mddev *mddev) ...@@ -3742,11 +3742,10 @@ static struct r10conf *setup_conf(struct mddev *mddev)
out: out:
if (conf) { if (conf) {
mempool_destroy(conf->r10bio_pool); mempool_exit(&conf->r10bio_pool);
kfree(conf->mirrors); kfree(conf->mirrors);
safe_put_page(conf->tmppage); safe_put_page(conf->tmppage);
if (conf->bio_split) bioset_exit(&conf->bio_split);
bioset_free(conf->bio_split);
kfree(conf); kfree(conf);
} }
return ERR_PTR(err); return ERR_PTR(err);
...@@ -3953,7 +3952,7 @@ static int raid10_run(struct mddev *mddev) ...@@ -3953,7 +3952,7 @@ static int raid10_run(struct mddev *mddev)
out_free_conf: out_free_conf:
md_unregister_thread(&mddev->thread); md_unregister_thread(&mddev->thread);
mempool_destroy(conf->r10bio_pool); mempool_exit(&conf->r10bio_pool);
safe_put_page(conf->tmppage); safe_put_page(conf->tmppage);
kfree(conf->mirrors); kfree(conf->mirrors);
kfree(conf); kfree(conf);
...@@ -3966,13 +3965,12 @@ static void raid10_free(struct mddev *mddev, void *priv) ...@@ -3966,13 +3965,12 @@ static void raid10_free(struct mddev *mddev, void *priv)
{ {
struct r10conf *conf = priv; struct r10conf *conf = priv;
mempool_destroy(conf->r10bio_pool); mempool_exit(&conf->r10bio_pool);
safe_put_page(conf->tmppage); safe_put_page(conf->tmppage);
kfree(conf->mirrors); kfree(conf->mirrors);
kfree(conf->mirrors_old); kfree(conf->mirrors_old);
kfree(conf->mirrors_new); kfree(conf->mirrors_new);
if (conf->bio_split) bioset_exit(&conf->bio_split);
bioset_free(conf->bio_split);
kfree(conf); kfree(conf);
} }
...@@ -4543,7 +4541,7 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, ...@@ -4543,7 +4541,7 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr,
* on all the target devices. * on all the target devices.
*/ */
// FIXME // FIXME
mempool_free(r10_bio, conf->r10buf_pool); mempool_free(r10_bio, &conf->r10buf_pool);
set_bit(MD_RECOVERY_INTR, &mddev->recovery); set_bit(MD_RECOVERY_INTR, &mddev->recovery);
return sectors_done; return sectors_done;
} }
......
...@@ -93,10 +93,10 @@ struct r10conf { ...@@ -93,10 +93,10 @@ struct r10conf {
*/ */
wait_queue_head_t wait_barrier; wait_queue_head_t wait_barrier;
mempool_t *r10bio_pool; mempool_t r10bio_pool;
mempool_t *r10buf_pool; mempool_t r10buf_pool;
struct page *tmppage; struct page *tmppage;
struct bio_set *bio_split; struct bio_set bio_split;
/* When taking over an array from a different personality, we store /* When taking over an array from a different personality, we store
* the new thread here until we fully activate the array. * the new thread here until we fully activate the array.
......
...@@ -125,9 +125,9 @@ struct r5l_log { ...@@ -125,9 +125,9 @@ struct r5l_log {
struct list_head no_mem_stripes; /* pending stripes, -ENOMEM */ struct list_head no_mem_stripes; /* pending stripes, -ENOMEM */
struct kmem_cache *io_kc; struct kmem_cache *io_kc;
mempool_t *io_pool; mempool_t io_pool;
struct bio_set *bs; struct bio_set bs;
mempool_t *meta_pool; mempool_t meta_pool;
struct md_thread *reclaim_thread; struct md_thread *reclaim_thread;
unsigned long reclaim_target; /* number of space that need to be unsigned long reclaim_target; /* number of space that need to be
...@@ -579,7 +579,7 @@ static void r5l_log_endio(struct bio *bio) ...@@ -579,7 +579,7 @@ static void r5l_log_endio(struct bio *bio)
md_error(log->rdev->mddev, log->rdev); md_error(log->rdev->mddev, log->rdev);
bio_put(bio); bio_put(bio);
mempool_free(io->meta_page, log->meta_pool); mempool_free(io->meta_page, &log->meta_pool);
spin_lock_irqsave(&log->io_list_lock, flags); spin_lock_irqsave(&log->io_list_lock, flags);
__r5l_set_io_unit_state(io, IO_UNIT_IO_END); __r5l_set_io_unit_state(io, IO_UNIT_IO_END);
...@@ -748,7 +748,7 @@ static void r5l_submit_current_io(struct r5l_log *log) ...@@ -748,7 +748,7 @@ static void r5l_submit_current_io(struct r5l_log *log)
static struct bio *r5l_bio_alloc(struct r5l_log *log) static struct bio *r5l_bio_alloc(struct r5l_log *log)
{ {
struct bio *bio = bio_alloc_bioset(GFP_NOIO, BIO_MAX_PAGES, log->bs); struct bio *bio = bio_alloc_bioset(GFP_NOIO, BIO_MAX_PAGES, &log->bs);
bio_set_op_attrs(bio, REQ_OP_WRITE, 0); bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
bio_set_dev(bio, log->rdev->bdev); bio_set_dev(bio, log->rdev->bdev);
...@@ -780,7 +780,7 @@ static struct r5l_io_unit *r5l_new_meta(struct r5l_log *log) ...@@ -780,7 +780,7 @@ static struct r5l_io_unit *r5l_new_meta(struct r5l_log *log)
struct r5l_io_unit *io; struct r5l_io_unit *io;
struct r5l_meta_block *block; struct r5l_meta_block *block;
io = mempool_alloc(log->io_pool, GFP_ATOMIC); io = mempool_alloc(&log->io_pool, GFP_ATOMIC);
if (!io) if (!io)
return NULL; return NULL;
memset(io, 0, sizeof(*io)); memset(io, 0, sizeof(*io));
...@@ -791,7 +791,7 @@ static struct r5l_io_unit *r5l_new_meta(struct r5l_log *log) ...@@ -791,7 +791,7 @@ static struct r5l_io_unit *r5l_new_meta(struct r5l_log *log)
bio_list_init(&io->flush_barriers); bio_list_init(&io->flush_barriers);
io->state = IO_UNIT_RUNNING; io->state = IO_UNIT_RUNNING;
io->meta_page = mempool_alloc(log->meta_pool, GFP_NOIO); io->meta_page = mempool_alloc(&log->meta_pool, GFP_NOIO);
block = page_address(io->meta_page); block = page_address(io->meta_page);
clear_page(block); clear_page(block);
block->magic = cpu_to_le32(R5LOG_MAGIC); block->magic = cpu_to_le32(R5LOG_MAGIC);
...@@ -1223,7 +1223,7 @@ static bool r5l_complete_finished_ios(struct r5l_log *log) ...@@ -1223,7 +1223,7 @@ static bool r5l_complete_finished_ios(struct r5l_log *log)
log->next_checkpoint = io->log_start; log->next_checkpoint = io->log_start;
list_del(&io->log_sibling); list_del(&io->log_sibling);
mempool_free(io, log->io_pool); mempool_free(io, &log->io_pool);
r5l_run_no_mem_stripe(log); r5l_run_no_mem_stripe(log);
found = true; found = true;
...@@ -1647,7 +1647,7 @@ static int r5l_recovery_allocate_ra_pool(struct r5l_log *log, ...@@ -1647,7 +1647,7 @@ static int r5l_recovery_allocate_ra_pool(struct r5l_log *log,
{ {
struct page *page; struct page *page;
ctx->ra_bio = bio_alloc_bioset(GFP_KERNEL, BIO_MAX_PAGES, log->bs); ctx->ra_bio = bio_alloc_bioset(GFP_KERNEL, BIO_MAX_PAGES, &log->bs);
if (!ctx->ra_bio) if (!ctx->ra_bio)
return -ENOMEM; return -ENOMEM;
...@@ -3066,6 +3066,7 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev) ...@@ -3066,6 +3066,7 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev)
struct request_queue *q = bdev_get_queue(rdev->bdev); struct request_queue *q = bdev_get_queue(rdev->bdev);
struct r5l_log *log; struct r5l_log *log;
char b[BDEVNAME_SIZE]; char b[BDEVNAME_SIZE];
int ret;
pr_debug("md/raid:%s: using device %s as journal\n", pr_debug("md/raid:%s: using device %s as journal\n",
mdname(conf->mddev), bdevname(rdev->bdev, b)); mdname(conf->mddev), bdevname(rdev->bdev, b));
...@@ -3111,16 +3112,16 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev) ...@@ -3111,16 +3112,16 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev)
if (!log->io_kc) if (!log->io_kc)
goto io_kc; goto io_kc;
log->io_pool = mempool_create_slab_pool(R5L_POOL_SIZE, log->io_kc); ret = mempool_init_slab_pool(&log->io_pool, R5L_POOL_SIZE, log->io_kc);
if (!log->io_pool) if (ret)
goto io_pool; goto io_pool;
log->bs = bioset_create(R5L_POOL_SIZE, 0, BIOSET_NEED_BVECS); ret = bioset_init(&log->bs, R5L_POOL_SIZE, 0, BIOSET_NEED_BVECS);
if (!log->bs) if (ret)
goto io_bs; goto io_bs;
log->meta_pool = mempool_create_page_pool(R5L_POOL_SIZE, 0); ret = mempool_init_page_pool(&log->meta_pool, R5L_POOL_SIZE, 0);
if (!log->meta_pool) if (ret)
goto out_mempool; goto out_mempool;
spin_lock_init(&log->tree_lock); spin_lock_init(&log->tree_lock);
...@@ -3155,11 +3156,11 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev) ...@@ -3155,11 +3156,11 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev)
rcu_assign_pointer(conf->log, NULL); rcu_assign_pointer(conf->log, NULL);
md_unregister_thread(&log->reclaim_thread); md_unregister_thread(&log->reclaim_thread);
reclaim_thread: reclaim_thread:
mempool_destroy(log->meta_pool); mempool_exit(&log->meta_pool);
out_mempool: out_mempool:
bioset_free(log->bs); bioset_exit(&log->bs);
io_bs: io_bs:
mempool_destroy(log->io_pool); mempool_exit(&log->io_pool);
io_pool: io_pool:
kmem_cache_destroy(log->io_kc); kmem_cache_destroy(log->io_kc);
io_kc: io_kc:
...@@ -3178,9 +3179,9 @@ void r5l_exit_log(struct r5conf *conf) ...@@ -3178,9 +3179,9 @@ void r5l_exit_log(struct r5conf *conf)
wake_up(&conf->mddev->sb_wait); wake_up(&conf->mddev->sb_wait);
flush_work(&log->disable_writeback_work); flush_work(&log->disable_writeback_work);
md_unregister_thread(&log->reclaim_thread); md_unregister_thread(&log->reclaim_thread);
mempool_destroy(log->meta_pool); mempool_exit(&log->meta_pool);
bioset_free(log->bs); bioset_exit(&log->bs);
mempool_destroy(log->io_pool); mempool_exit(&log->io_pool);
kmem_cache_destroy(log->io_kc); kmem_cache_destroy(log->io_kc);
kfree(log); kfree(log);
} }
...@@ -105,9 +105,9 @@ struct ppl_conf { ...@@ -105,9 +105,9 @@ struct ppl_conf {
atomic64_t seq; /* current log write sequence number */ atomic64_t seq; /* current log write sequence number */
struct kmem_cache *io_kc; struct kmem_cache *io_kc;
mempool_t *io_pool; mempool_t io_pool;
struct bio_set *bs; struct bio_set bs;
struct bio_set *flush_bs; struct bio_set flush_bs;
/* used only for recovery */ /* used only for recovery */
int recovered_entries; int recovered_entries;
...@@ -244,7 +244,7 @@ static struct ppl_io_unit *ppl_new_iounit(struct ppl_log *log, ...@@ -244,7 +244,7 @@ static struct ppl_io_unit *ppl_new_iounit(struct ppl_log *log,
struct ppl_header *pplhdr; struct ppl_header *pplhdr;
struct page *header_page; struct page *header_page;
io = mempool_alloc(ppl_conf->io_pool, GFP_NOWAIT); io = mempool_alloc(&ppl_conf->io_pool, GFP_NOWAIT);
if (!io) if (!io)
return NULL; return NULL;
...@@ -503,7 +503,7 @@ static void ppl_submit_iounit(struct ppl_io_unit *io) ...@@ -503,7 +503,7 @@ static void ppl_submit_iounit(struct ppl_io_unit *io)
struct bio *prev = bio; struct bio *prev = bio;
bio = bio_alloc_bioset(GFP_NOIO, BIO_MAX_PAGES, bio = bio_alloc_bioset(GFP_NOIO, BIO_MAX_PAGES,
ppl_conf->bs); &ppl_conf->bs);
bio->bi_opf = prev->bi_opf; bio->bi_opf = prev->bi_opf;
bio_copy_dev(bio, prev); bio_copy_dev(bio, prev);
bio->bi_iter.bi_sector = bio_end_sector(prev); bio->bi_iter.bi_sector = bio_end_sector(prev);
...@@ -570,7 +570,7 @@ static void ppl_io_unit_finished(struct ppl_io_unit *io) ...@@ -570,7 +570,7 @@ static void ppl_io_unit_finished(struct ppl_io_unit *io)
list_del(&io->log_sibling); list_del(&io->log_sibling);
spin_unlock(&log->io_list_lock); spin_unlock(&log->io_list_lock);
mempool_free(io, ppl_conf->io_pool); mempool_free(io, &ppl_conf->io_pool);
spin_lock(&ppl_conf->no_mem_stripes_lock); spin_lock(&ppl_conf->no_mem_stripes_lock);
if (!list_empty(&ppl_conf->no_mem_stripes)) { if (!list_empty(&ppl_conf->no_mem_stripes)) {
...@@ -642,7 +642,7 @@ static void ppl_do_flush(struct ppl_io_unit *io) ...@@ -642,7 +642,7 @@ static void ppl_do_flush(struct ppl_io_unit *io)
struct bio *bio; struct bio *bio;
char b[BDEVNAME_SIZE]; char b[BDEVNAME_SIZE];
bio = bio_alloc_bioset(GFP_NOIO, 0, ppl_conf->flush_bs); bio = bio_alloc_bioset(GFP_NOIO, 0, &ppl_conf->flush_bs);
bio_set_dev(bio, bdev); bio_set_dev(bio, bdev);
bio->bi_private = io; bio->bi_private = io;
bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH; bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
...@@ -1246,11 +1246,9 @@ static void __ppl_exit_log(struct ppl_conf *ppl_conf) ...@@ -1246,11 +1246,9 @@ static void __ppl_exit_log(struct ppl_conf *ppl_conf)
kfree(ppl_conf->child_logs); kfree(ppl_conf->child_logs);
if (ppl_conf->bs) bioset_exit(&ppl_conf->bs);
bioset_free(ppl_conf->bs); bioset_exit(&ppl_conf->flush_bs);
if (ppl_conf->flush_bs) mempool_exit(&ppl_conf->io_pool);
bioset_free(ppl_conf->flush_bs);
mempool_destroy(ppl_conf->io_pool);
kmem_cache_destroy(ppl_conf->io_kc); kmem_cache_destroy(ppl_conf->io_kc);
kfree(ppl_conf); kfree(ppl_conf);
...@@ -1387,24 +1385,18 @@ int ppl_init_log(struct r5conf *conf) ...@@ -1387,24 +1385,18 @@ int ppl_init_log(struct r5conf *conf)
goto err; goto err;
} }
ppl_conf->io_pool = mempool_create(conf->raid_disks, ppl_io_pool_alloc, ret = mempool_init(&ppl_conf->io_pool, conf->raid_disks, ppl_io_pool_alloc,
ppl_io_pool_free, ppl_conf->io_kc); ppl_io_pool_free, ppl_conf->io_kc);
if (!ppl_conf->io_pool) { if (ret)
ret = -ENOMEM;
goto err; goto err;
}
ppl_conf->bs = bioset_create(conf->raid_disks, 0, BIOSET_NEED_BVECS); ret = bioset_init(&ppl_conf->bs, conf->raid_disks, 0, BIOSET_NEED_BVECS);
if (!ppl_conf->bs) { if (ret)
ret = -ENOMEM;
goto err; goto err;
}
ppl_conf->flush_bs = bioset_create(conf->raid_disks, 0, 0); ret = bioset_init(&ppl_conf->flush_bs, conf->raid_disks, 0, 0);
if (!ppl_conf->flush_bs) { if (ret)
ret = -ENOMEM;
goto err; goto err;
}
ppl_conf->count = conf->raid_disks; ppl_conf->count = conf->raid_disks;
ppl_conf->child_logs = kcalloc(ppl_conf->count, sizeof(struct ppl_log), ppl_conf->child_logs = kcalloc(ppl_conf->count, sizeof(struct ppl_log),
......
...@@ -5192,7 +5192,7 @@ static int raid5_read_one_chunk(struct mddev *mddev, struct bio *raid_bio) ...@@ -5192,7 +5192,7 @@ static int raid5_read_one_chunk(struct mddev *mddev, struct bio *raid_bio)
/* /*
* use bio_clone_fast to make a copy of the bio * use bio_clone_fast to make a copy of the bio
*/ */
align_bi = bio_clone_fast(raid_bio, GFP_NOIO, mddev->bio_set); align_bi = bio_clone_fast(raid_bio, GFP_NOIO, &mddev->bio_set);
if (!align_bi) if (!align_bi)
return 0; return 0;
/* /*
...@@ -5277,7 +5277,7 @@ static struct bio *chunk_aligned_read(struct mddev *mddev, struct bio *raid_bio) ...@@ -5277,7 +5277,7 @@ static struct bio *chunk_aligned_read(struct mddev *mddev, struct bio *raid_bio)
if (sectors < bio_sectors(raid_bio)) { if (sectors < bio_sectors(raid_bio)) {
struct r5conf *conf = mddev->private; struct r5conf *conf = mddev->private;
split = bio_split(raid_bio, sectors, GFP_NOIO, conf->bio_split); split = bio_split(raid_bio, sectors, GFP_NOIO, &conf->bio_split);
bio_chain(split, raid_bio); bio_chain(split, raid_bio);
generic_make_request(raid_bio); generic_make_request(raid_bio);
raid_bio = split; raid_bio = split;
...@@ -6773,8 +6773,7 @@ static void free_conf(struct r5conf *conf) ...@@ -6773,8 +6773,7 @@ static void free_conf(struct r5conf *conf)
if (conf->disks[i].extra_page) if (conf->disks[i].extra_page)
put_page(conf->disks[i].extra_page); put_page(conf->disks[i].extra_page);
kfree(conf->disks); kfree(conf->disks);
if (conf->bio_split) bioset_exit(&conf->bio_split);
bioset_free(conf->bio_split);
kfree(conf->stripe_hashtbl); kfree(conf->stripe_hashtbl);
kfree(conf->pending_data); kfree(conf->pending_data);
kfree(conf); kfree(conf);
...@@ -6853,6 +6852,7 @@ static struct r5conf *setup_conf(struct mddev *mddev) ...@@ -6853,6 +6852,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
int i; int i;
int group_cnt, worker_cnt_per_group; int group_cnt, worker_cnt_per_group;
struct r5worker_group *new_group; struct r5worker_group *new_group;
int ret;
if (mddev->new_level != 5 if (mddev->new_level != 5
&& mddev->new_level != 4 && mddev->new_level != 4
...@@ -6950,8 +6950,8 @@ static struct r5conf *setup_conf(struct mddev *mddev) ...@@ -6950,8 +6950,8 @@ static struct r5conf *setup_conf(struct mddev *mddev)
goto abort; goto abort;
} }
conf->bio_split = bioset_create(BIO_POOL_SIZE, 0, 0); ret = bioset_init(&conf->bio_split, BIO_POOL_SIZE, 0, 0);
if (!conf->bio_split) if (ret)
goto abort; goto abort;
conf->mddev = mddev; conf->mddev = mddev;
......
...@@ -669,7 +669,7 @@ struct r5conf { ...@@ -669,7 +669,7 @@ struct r5conf {
int pool_size; /* number of disks in stripeheads in pool */ int pool_size; /* number of disks in stripeheads in pool */
spinlock_t device_lock; spinlock_t device_lock;
struct disk_info *disks; struct disk_info *disks;
struct bio_set *bio_split; struct bio_set bio_split;
/* When taking over an array from a different personality, we store /* When taking over an array from a different personality, we store
* the new thread here until we fully activate the array. * the new thread here until we fully activate the array.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册