diff options
| author | Mikulas Patocka <mpatocka@redhat.com> | 2012-12-21 15:23:38 -0500 |
|---|---|---|
| committer | Alasdair G Kergon <agk@redhat.com> | 2012-12-21 15:23:38 -0500 |
| commit | 39cf0ed27ec70626e416c2f4780ea0449d405941 (patch) | |
| tree | 3ccd2ada4c4b09e59076304a45e1e267602931f3 /drivers/md | |
| parent | c0820cf5ad09522bdd9ff68e84841a09c9f339d8 (diff) | |
dm raid1: use per_bio_data
Replace read_record_pool with per_bio_data in dm-raid1.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md')
| -rw-r--r-- | drivers/md/dm-raid1.c | 39 |
1 files changed, 5 insertions, 34 deletions
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c index cec5f9b3a278..b4bc287bea7e 100644 --- a/drivers/md/dm-raid1.c +++ b/drivers/md/dm-raid1.c | |||
| @@ -61,7 +61,6 @@ struct mirror_set { | |||
| 61 | struct dm_region_hash *rh; | 61 | struct dm_region_hash *rh; |
| 62 | struct dm_kcopyd_client *kcopyd_client; | 62 | struct dm_kcopyd_client *kcopyd_client; |
| 63 | struct dm_io_client *io_client; | 63 | struct dm_io_client *io_client; |
| 64 | mempool_t *read_record_pool; | ||
| 65 | 64 | ||
| 66 | /* recovery */ | 65 | /* recovery */ |
| 67 | region_t nr_regions; | 66 | region_t nr_regions; |
| @@ -139,14 +138,11 @@ static void dispatch_bios(void *context, struct bio_list *bio_list) | |||
| 139 | queue_bio(ms, bio, WRITE); | 138 | queue_bio(ms, bio, WRITE); |
| 140 | } | 139 | } |
| 141 | 140 | ||
| 142 | #define MIN_READ_RECORDS 20 | ||
| 143 | struct dm_raid1_read_record { | 141 | struct dm_raid1_read_record { |
| 144 | struct mirror *m; | 142 | struct mirror *m; |
| 145 | struct dm_bio_details details; | 143 | struct dm_bio_details details; |
| 146 | }; | 144 | }; |
| 147 | 145 | ||
| 148 | static struct kmem_cache *_dm_raid1_read_record_cache; | ||
| 149 | |||
| 150 | /* | 146 | /* |
| 151 | * Every mirror should look like this one. | 147 | * Every mirror should look like this one. |
| 152 | */ | 148 | */ |
| @@ -876,19 +872,9 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors, | |||
| 876 | atomic_set(&ms->suspend, 0); | 872 | atomic_set(&ms->suspend, 0); |
| 877 | atomic_set(&ms->default_mirror, DEFAULT_MIRROR); | 873 | atomic_set(&ms->default_mirror, DEFAULT_MIRROR); |
| 878 | 874 | ||
| 879 | ms->read_record_pool = mempool_create_slab_pool(MIN_READ_RECORDS, | ||
| 880 | _dm_raid1_read_record_cache); | ||
| 881 | |||
| 882 | if (!ms->read_record_pool) { | ||
| 883 | ti->error = "Error creating mirror read_record_pool"; | ||
| 884 | kfree(ms); | ||
| 885 | return NULL; | ||
| 886 | } | ||
| 887 | |||
| 888 | ms->io_client = dm_io_client_create(); | 875 | ms->io_client = dm_io_client_create(); |
| 889 | if (IS_ERR(ms->io_client)) { | 876 | if (IS_ERR(ms->io_client)) { |
| 890 | ti->error = "Error creating dm_io client"; | 877 | ti->error = "Error creating dm_io client"; |
| 891 | mempool_destroy(ms->read_record_pool); | ||
| 892 | kfree(ms); | 878 | kfree(ms); |
| 893 | return NULL; | 879 | return NULL; |
| 894 | } | 880 | } |
| @@ -900,7 +886,6 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors, | |||
| 900 | if (IS_ERR(ms->rh)) { | 886 | if (IS_ERR(ms->rh)) { |
| 901 | ti->error = "Error creating dirty region hash"; | 887 | ti->error = "Error creating dirty region hash"; |
| 902 | dm_io_client_destroy(ms->io_client); | 888 | dm_io_client_destroy(ms->io_client); |
| 903 | mempool_destroy(ms->read_record_pool); | ||
| 904 | kfree(ms); | 889 | kfree(ms); |
| 905 | return NULL; | 890 | return NULL; |
| 906 | } | 891 | } |
| @@ -916,7 +901,6 @@ static void free_context(struct mirror_set *ms, struct dm_target *ti, | |||
| 916 | 901 | ||
| 917 | dm_io_client_destroy(ms->io_client); | 902 | dm_io_client_destroy(ms->io_client); |
| 918 | dm_region_hash_destroy(ms->rh); | 903 | dm_region_hash_destroy(ms->rh); |
| 919 | mempool_destroy(ms->read_record_pool); | ||
| 920 | kfree(ms); | 904 | kfree(ms); |
| 921 | } | 905 | } |
| 922 | 906 | ||
| @@ -1088,6 +1072,7 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
| 1088 | 1072 | ||
| 1089 | ti->num_flush_requests = 1; | 1073 | ti->num_flush_requests = 1; |
| 1090 | ti->num_discard_requests = 1; | 1074 | ti->num_discard_requests = 1; |
| 1075 | ti->per_bio_data_size = sizeof(struct dm_raid1_read_record); | ||
| 1091 | ti->discard_zeroes_data_unsupported = true; | 1076 | ti->discard_zeroes_data_unsupported = true; |
| 1092 | 1077 | ||
| 1093 | ms->kmirrord_wq = alloc_workqueue("kmirrord", | 1078 | ms->kmirrord_wq = alloc_workqueue("kmirrord", |
| @@ -1161,7 +1146,7 @@ static int mirror_map(struct dm_target *ti, struct bio *bio, | |||
| 1161 | int r, rw = bio_rw(bio); | 1146 | int r, rw = bio_rw(bio); |
| 1162 | struct mirror *m; | 1147 | struct mirror *m; |
| 1163 | struct mirror_set *ms = ti->private; | 1148 | struct mirror_set *ms = ti->private; |
| 1164 | struct dm_raid1_read_record *read_record = NULL; | 1149 | struct dm_raid1_read_record *read_record; |
| 1165 | struct dm_dirty_log *log = dm_rh_dirty_log(ms->rh); | 1150 | struct dm_dirty_log *log = dm_rh_dirty_log(ms->rh); |
| 1166 | 1151 | ||
| 1167 | if (rw == WRITE) { | 1152 | if (rw == WRITE) { |
| @@ -1194,7 +1179,7 @@ static int mirror_map(struct dm_target *ti, struct bio *bio, | |||
| 1194 | if (unlikely(!m)) | 1179 | if (unlikely(!m)) |
| 1195 | return -EIO; | 1180 | return -EIO; |
| 1196 | 1181 | ||
| 1197 | read_record = mempool_alloc(ms->read_record_pool, GFP_NOIO); | 1182 | read_record = dm_per_bio_data(bio, sizeof(struct dm_raid1_read_record)); |
| 1198 | dm_bio_record(&read_record->details, bio); | 1183 | dm_bio_record(&read_record->details, bio); |
| 1199 | map_context->ptr = read_record; | 1184 | map_context->ptr = read_record; |
| 1200 | read_record->m = m; | 1185 | read_record->m = m; |
| @@ -1254,7 +1239,6 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio, | |||
| 1254 | bd = &read_record->details; | 1239 | bd = &read_record->details; |
| 1255 | 1240 | ||
| 1256 | dm_bio_restore(bd, bio); | 1241 | dm_bio_restore(bd, bio); |
| 1257 | mempool_free(read_record, ms->read_record_pool); | ||
| 1258 | map_context->ptr = NULL; | 1242 | map_context->ptr = NULL; |
| 1259 | queue_bio(ms, bio, rw); | 1243 | queue_bio(ms, bio, rw); |
| 1260 | return DM_ENDIO_INCOMPLETE; | 1244 | return DM_ENDIO_INCOMPLETE; |
| @@ -1263,10 +1247,7 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio, | |||
| 1263 | } | 1247 | } |
| 1264 | 1248 | ||
| 1265 | out: | 1249 | out: |
| 1266 | if (read_record) { | 1250 | map_context->ptr = NULL; |
| 1267 | mempool_free(read_record, ms->read_record_pool); | ||
| 1268 | map_context->ptr = NULL; | ||
| 1269 | } | ||
| 1270 | 1251 | ||
| 1271 | return error; | 1252 | return error; |
| 1272 | } | 1253 | } |
| @@ -1420,7 +1401,7 @@ static int mirror_iterate_devices(struct dm_target *ti, | |||
| 1420 | 1401 | ||
| 1421 | static struct target_type mirror_target = { | 1402 | static struct target_type mirror_target = { |
| 1422 | .name = "mirror", | 1403 | .name = "mirror", |
| 1423 | .version = {1, 12, 1}, | 1404 | .version = {1, 13, 1}, |
| 1424 | .module = THIS_MODULE, | 1405 | .module = THIS_MODULE, |
| 1425 | .ctr = mirror_ctr, | 1406 | .ctr = mirror_ctr, |
| 1426 | .dtr = mirror_dtr, | 1407 | .dtr = mirror_dtr, |
| @@ -1437,13 +1418,6 @@ static int __init dm_mirror_init(void) | |||
| 1437 | { | 1418 | { |
| 1438 | int r; | 1419 | int r; |
| 1439 | 1420 | ||
| 1440 | _dm_raid1_read_record_cache = KMEM_CACHE(dm_raid1_read_record, 0); | ||
| 1441 | if (!_dm_raid1_read_record_cache) { | ||
| 1442 | DMERR("Can't allocate dm_raid1_read_record cache"); | ||
| 1443 | r = -ENOMEM; | ||
| 1444 | goto bad_cache; | ||
| 1445 | } | ||
| 1446 | |||
| 1447 | r = dm_register_target(&mirror_target); | 1421 | r = dm_register_target(&mirror_target); |
| 1448 | if (r < 0) { | 1422 | if (r < 0) { |
| 1449 | DMERR("Failed to register mirror target"); | 1423 | DMERR("Failed to register mirror target"); |
| @@ -1453,15 +1427,12 @@ static int __init dm_mirror_init(void) | |||
| 1453 | return 0; | 1427 | return 0; |
| 1454 | 1428 | ||
| 1455 | bad_target: | 1429 | bad_target: |
| 1456 | kmem_cache_destroy(_dm_raid1_read_record_cache); | ||
| 1457 | bad_cache: | ||
| 1458 | return r; | 1430 | return r; |
| 1459 | } | 1431 | } |
| 1460 | 1432 | ||
| 1461 | static void __exit dm_mirror_exit(void) | 1433 | static void __exit dm_mirror_exit(void) |
| 1462 | { | 1434 | { |
| 1463 | dm_unregister_target(&mirror_target); | 1435 | dm_unregister_target(&mirror_target); |
| 1464 | kmem_cache_destroy(_dm_raid1_read_record_cache); | ||
| 1465 | } | 1436 | } |
| 1466 | 1437 | ||
| 1467 | /* Module hooks */ | 1438 | /* Module hooks */ |
