Commit 39cf0ed2 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Alasdair G Kergon

dm raid1: use per_bio_data

Replace read_record_pool with per_bio_data in dm-raid1.
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
parent c0820cf5
...@@ -61,7 +61,6 @@ struct mirror_set { ...@@ -61,7 +61,6 @@ struct mirror_set {
struct dm_region_hash *rh; struct dm_region_hash *rh;
struct dm_kcopyd_client *kcopyd_client; struct dm_kcopyd_client *kcopyd_client;
struct dm_io_client *io_client; struct dm_io_client *io_client;
mempool_t *read_record_pool;
/* recovery */ /* recovery */
region_t nr_regions; region_t nr_regions;
...@@ -139,14 +138,11 @@ static void dispatch_bios(void *context, struct bio_list *bio_list) ...@@ -139,14 +138,11 @@ static void dispatch_bios(void *context, struct bio_list *bio_list)
queue_bio(ms, bio, WRITE); queue_bio(ms, bio, WRITE);
} }
#define MIN_READ_RECORDS 20
struct dm_raid1_read_record { struct dm_raid1_read_record {
struct mirror *m; struct mirror *m;
struct dm_bio_details details; struct dm_bio_details details;
}; };
static struct kmem_cache *_dm_raid1_read_record_cache;
/* /*
* Every mirror should look like this one. * Every mirror should look like this one.
*/ */
...@@ -876,19 +872,9 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors, ...@@ -876,19 +872,9 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors,
atomic_set(&ms->suspend, 0); atomic_set(&ms->suspend, 0);
atomic_set(&ms->default_mirror, DEFAULT_MIRROR); atomic_set(&ms->default_mirror, DEFAULT_MIRROR);
ms->read_record_pool = mempool_create_slab_pool(MIN_READ_RECORDS,
_dm_raid1_read_record_cache);
if (!ms->read_record_pool) {
ti->error = "Error creating mirror read_record_pool";
kfree(ms);
return NULL;
}
ms->io_client = dm_io_client_create(); ms->io_client = dm_io_client_create();
if (IS_ERR(ms->io_client)) { if (IS_ERR(ms->io_client)) {
ti->error = "Error creating dm_io client"; ti->error = "Error creating dm_io client";
mempool_destroy(ms->read_record_pool);
kfree(ms); kfree(ms);
return NULL; return NULL;
} }
...@@ -900,7 +886,6 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors, ...@@ -900,7 +886,6 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors,
if (IS_ERR(ms->rh)) { if (IS_ERR(ms->rh)) {
ti->error = "Error creating dirty region hash"; ti->error = "Error creating dirty region hash";
dm_io_client_destroy(ms->io_client); dm_io_client_destroy(ms->io_client);
mempool_destroy(ms->read_record_pool);
kfree(ms); kfree(ms);
return NULL; return NULL;
} }
...@@ -916,7 +901,6 @@ static void free_context(struct mirror_set *ms, struct dm_target *ti, ...@@ -916,7 +901,6 @@ static void free_context(struct mirror_set *ms, struct dm_target *ti,
dm_io_client_destroy(ms->io_client); dm_io_client_destroy(ms->io_client);
dm_region_hash_destroy(ms->rh); dm_region_hash_destroy(ms->rh);
mempool_destroy(ms->read_record_pool);
kfree(ms); kfree(ms);
} }
...@@ -1088,6 +1072,7 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -1088,6 +1072,7 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv)
ti->num_flush_requests = 1; ti->num_flush_requests = 1;
ti->num_discard_requests = 1; ti->num_discard_requests = 1;
ti->per_bio_data_size = sizeof(struct dm_raid1_read_record);
ti->discard_zeroes_data_unsupported = true; ti->discard_zeroes_data_unsupported = true;
ms->kmirrord_wq = alloc_workqueue("kmirrord", ms->kmirrord_wq = alloc_workqueue("kmirrord",
...@@ -1161,7 +1146,7 @@ static int mirror_map(struct dm_target *ti, struct bio *bio, ...@@ -1161,7 +1146,7 @@ static int mirror_map(struct dm_target *ti, struct bio *bio,
int r, rw = bio_rw(bio); int r, rw = bio_rw(bio);
struct mirror *m; struct mirror *m;
struct mirror_set *ms = ti->private; struct mirror_set *ms = ti->private;
struct dm_raid1_read_record *read_record = NULL; struct dm_raid1_read_record *read_record;
struct dm_dirty_log *log = dm_rh_dirty_log(ms->rh); struct dm_dirty_log *log = dm_rh_dirty_log(ms->rh);
if (rw == WRITE) { if (rw == WRITE) {
...@@ -1194,7 +1179,7 @@ static int mirror_map(struct dm_target *ti, struct bio *bio, ...@@ -1194,7 +1179,7 @@ static int mirror_map(struct dm_target *ti, struct bio *bio,
if (unlikely(!m)) if (unlikely(!m))
return -EIO; return -EIO;
read_record = mempool_alloc(ms->read_record_pool, GFP_NOIO); read_record = dm_per_bio_data(bio, sizeof(struct dm_raid1_read_record));
dm_bio_record(&read_record->details, bio); dm_bio_record(&read_record->details, bio);
map_context->ptr = read_record; map_context->ptr = read_record;
read_record->m = m; read_record->m = m;
...@@ -1254,7 +1239,6 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio, ...@@ -1254,7 +1239,6 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio,
bd = &read_record->details; bd = &read_record->details;
dm_bio_restore(bd, bio); dm_bio_restore(bd, bio);
mempool_free(read_record, ms->read_record_pool);
map_context->ptr = NULL; map_context->ptr = NULL;
queue_bio(ms, bio, rw); queue_bio(ms, bio, rw);
return DM_ENDIO_INCOMPLETE; return DM_ENDIO_INCOMPLETE;
...@@ -1263,10 +1247,7 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio, ...@@ -1263,10 +1247,7 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio,
} }
out: out:
if (read_record) {
mempool_free(read_record, ms->read_record_pool);
map_context->ptr = NULL; map_context->ptr = NULL;
}
return error; return error;
} }
...@@ -1420,7 +1401,7 @@ static int mirror_iterate_devices(struct dm_target *ti, ...@@ -1420,7 +1401,7 @@ static int mirror_iterate_devices(struct dm_target *ti,
static struct target_type mirror_target = { static struct target_type mirror_target = {
.name = "mirror", .name = "mirror",
.version = {1, 12, 1}, .version = {1, 13, 1},
.module = THIS_MODULE, .module = THIS_MODULE,
.ctr = mirror_ctr, .ctr = mirror_ctr,
.dtr = mirror_dtr, .dtr = mirror_dtr,
...@@ -1437,13 +1418,6 @@ static int __init dm_mirror_init(void) ...@@ -1437,13 +1418,6 @@ static int __init dm_mirror_init(void)
{ {
int r; int r;
_dm_raid1_read_record_cache = KMEM_CACHE(dm_raid1_read_record, 0);
if (!_dm_raid1_read_record_cache) {
DMERR("Can't allocate dm_raid1_read_record cache");
r = -ENOMEM;
goto bad_cache;
}
r = dm_register_target(&mirror_target); r = dm_register_target(&mirror_target);
if (r < 0) { if (r < 0) {
DMERR("Failed to register mirror target"); DMERR("Failed to register mirror target");
...@@ -1453,15 +1427,12 @@ static int __init dm_mirror_init(void) ...@@ -1453,15 +1427,12 @@ static int __init dm_mirror_init(void)
return 0; return 0;
bad_target: bad_target:
kmem_cache_destroy(_dm_raid1_read_record_cache);
bad_cache:
return r; return r;
} }
static void __exit dm_mirror_exit(void) static void __exit dm_mirror_exit(void)
{ {
dm_unregister_target(&mirror_target); dm_unregister_target(&mirror_target);
kmem_cache_destroy(_dm_raid1_read_record_cache);
} }
/* Module hooks */ /* Module hooks */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment