@@ -61,7 +61,6 @@ struct mirror_set {
61
61
struct dm_region_hash * rh ;
62
62
struct dm_kcopyd_client * kcopyd_client ;
63
63
struct dm_io_client * io_client ;
64
- mempool_t * read_record_pool ;
65
64
66
65
/* recovery */
67
66
region_t nr_regions ;
@@ -139,14 +138,11 @@ static void dispatch_bios(void *context, struct bio_list *bio_list)
139
138
queue_bio (ms , bio , WRITE );
140
139
}
141
140
142
- #define MIN_READ_RECORDS 20
143
141
struct dm_raid1_read_record {
144
142
struct mirror * m ;
145
143
struct dm_bio_details details ;
146
144
};
147
145
148
- static struct kmem_cache * _dm_raid1_read_record_cache ;
149
-
150
146
/*
151
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
872
atomic_set (& ms -> suspend , 0 );
877
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
875
ms -> io_client = dm_io_client_create ();
889
876
if (IS_ERR (ms -> io_client )) {
890
877
ti -> error = "Error creating dm_io client" ;
891
- mempool_destroy (ms -> read_record_pool );
892
878
kfree (ms );
893
879
return NULL ;
894
880
}
@@ -900,7 +886,6 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors,
900
886
if (IS_ERR (ms -> rh )) {
901
887
ti -> error = "Error creating dirty region hash" ;
902
888
dm_io_client_destroy (ms -> io_client );
903
- mempool_destroy (ms -> read_record_pool );
904
889
kfree (ms );
905
890
return NULL ;
906
891
}
@@ -916,7 +901,6 @@ static void free_context(struct mirror_set *ms, struct dm_target *ti,
916
901
917
902
dm_io_client_destroy (ms -> io_client );
918
903
dm_region_hash_destroy (ms -> rh );
919
- mempool_destroy (ms -> read_record_pool );
920
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
1073
ti -> num_flush_requests = 1 ;
1090
1074
ti -> num_discard_requests = 1 ;
1075
+ ti -> per_bio_data_size = sizeof (struct dm_raid1_read_record );
1091
1076
ti -> discard_zeroes_data_unsupported = true;
1092
1077
1093
1078
ms -> kmirrord_wq = alloc_workqueue ("kmirrord" ,
@@ -1161,7 +1146,7 @@ static int mirror_map(struct dm_target *ti, struct bio *bio,
1161
1146
int r , rw = bio_rw (bio );
1162
1147
struct mirror * m ;
1163
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
1150
struct dm_dirty_log * log = dm_rh_dirty_log (ms -> rh );
1166
1151
1167
1152
if (rw == WRITE ) {
@@ -1194,7 +1179,7 @@ static int mirror_map(struct dm_target *ti, struct bio *bio,
1194
1179
if (unlikely (!m ))
1195
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
1183
dm_bio_record (& read_record -> details , bio );
1199
1184
map_context -> ptr = read_record ;
1200
1185
read_record -> m = m ;
@@ -1254,7 +1239,6 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio,
1254
1239
bd = & read_record -> details ;
1255
1240
1256
1241
dm_bio_restore (bd , bio );
1257
- mempool_free (read_record , ms -> read_record_pool );
1258
1242
map_context -> ptr = NULL ;
1259
1243
queue_bio (ms , bio , rw );
1260
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
1249
out :
1266
- if (read_record ) {
1267
- mempool_free (read_record , ms -> read_record_pool );
1268
- map_context -> ptr = NULL ;
1269
- }
1250
+ map_context -> ptr = NULL ;
1270
1251
1271
1252
return error ;
1272
1253
}
@@ -1420,7 +1401,7 @@ static int mirror_iterate_devices(struct dm_target *ti,
1420
1401
1421
1402
static struct target_type mirror_target = {
1422
1403
.name = "mirror" ,
1423
- .version = {1 , 12 , 1 },
1404
+ .version = {1 , 13 , 1 },
1424
1405
.module = THIS_MODULE ,
1425
1406
.ctr = mirror_ctr ,
1426
1407
.dtr = mirror_dtr ,
@@ -1437,13 +1418,6 @@ static int __init dm_mirror_init(void)
1437
1418
{
1438
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
1421
r = dm_register_target (& mirror_target );
1448
1422
if (r < 0 ) {
1449
1423
DMERR ("Failed to register mirror target" );
@@ -1453,15 +1427,12 @@ static int __init dm_mirror_init(void)
1453
1427
return 0 ;
1454
1428
1455
1429
bad_target :
1456
- kmem_cache_destroy (_dm_raid1_read_record_cache );
1457
- bad_cache :
1458
1430
return r ;
1459
1431
}
1460
1432
1461
1433
static void __exit dm_mirror_exit (void )
1462
1434
{
1463
1435
dm_unregister_target (& mirror_target );
1464
- kmem_cache_destroy (_dm_raid1_read_record_cache );
1465
1436
}
1466
1437
1467
1438
/* Module hooks */
0 commit comments