diff options
| -rw-r--r-- | drivers/md/dm-snap.c | 43 |
1 files changed, 8 insertions, 35 deletions
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index 223e7ebf24f7..5e88bc437be0 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c | |||
| @@ -79,7 +79,6 @@ struct dm_snapshot { | |||
| 79 | 79 | ||
| 80 | /* Chunks with outstanding reads */ | 80 | /* Chunks with outstanding reads */ |
| 81 | spinlock_t tracked_chunk_lock; | 81 | spinlock_t tracked_chunk_lock; |
| 82 | mempool_t *tracked_chunk_pool; | ||
| 83 | struct hlist_head tracked_chunk_hash[DM_TRACKED_CHUNK_HASH_SIZE]; | 82 | struct hlist_head tracked_chunk_hash[DM_TRACKED_CHUNK_HASH_SIZE]; |
| 84 | 83 | ||
| 85 | /* The on disk metadata handler */ | 84 | /* The on disk metadata handler */ |
| @@ -191,13 +190,11 @@ struct dm_snap_tracked_chunk { | |||
| 191 | chunk_t chunk; | 190 | chunk_t chunk; |
| 192 | }; | 191 | }; |
| 193 | 192 | ||
| 194 | static struct kmem_cache *tracked_chunk_cache; | ||
| 195 | |||
| 196 | static struct dm_snap_tracked_chunk *track_chunk(struct dm_snapshot *s, | 193 | static struct dm_snap_tracked_chunk *track_chunk(struct dm_snapshot *s, |
| 194 | struct bio *bio, | ||
| 197 | chunk_t chunk) | 195 | chunk_t chunk) |
| 198 | { | 196 | { |
| 199 | struct dm_snap_tracked_chunk *c = mempool_alloc(s->tracked_chunk_pool, | 197 | struct dm_snap_tracked_chunk *c = dm_per_bio_data(bio, sizeof(struct dm_snap_tracked_chunk)); |
| 200 | GFP_NOIO); | ||
| 201 | 198 | ||
| 202 | c->chunk = chunk; | 199 | c->chunk = chunk; |
| 203 | 200 | ||
| @@ -217,8 +214,6 @@ static void stop_tracking_chunk(struct dm_snapshot *s, | |||
| 217 | spin_lock_irqsave(&s->tracked_chunk_lock, flags); | 214 | spin_lock_irqsave(&s->tracked_chunk_lock, flags); |
| 218 | hlist_del(&c->node); | 215 | hlist_del(&c->node); |
| 219 | spin_unlock_irqrestore(&s->tracked_chunk_lock, flags); | 216 | spin_unlock_irqrestore(&s->tracked_chunk_lock, flags); |
| 220 | |||
| 221 | mempool_free(c, s->tracked_chunk_pool); | ||
| 222 | } | 217 | } |
| 223 | 218 | ||
| 224 | static int __chunk_is_tracked(struct dm_snapshot *s, chunk_t chunk) | 219 | static int __chunk_is_tracked(struct dm_snapshot *s, chunk_t chunk) |
| @@ -1119,14 +1114,6 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
| 1119 | goto bad_pending_pool; | 1114 | goto bad_pending_pool; |
| 1120 | } | 1115 | } |
| 1121 | 1116 | ||
| 1122 | s->tracked_chunk_pool = mempool_create_slab_pool(MIN_IOS, | ||
| 1123 | tracked_chunk_cache); | ||
| 1124 | if (!s->tracked_chunk_pool) { | ||
| 1125 | ti->error = "Could not allocate tracked_chunk mempool for " | ||
| 1126 | "tracking reads"; | ||
| 1127 | goto bad_tracked_chunk_pool; | ||
| 1128 | } | ||
| 1129 | |||
| 1130 | for (i = 0; i < DM_TRACKED_CHUNK_HASH_SIZE; i++) | 1117 | for (i = 0; i < DM_TRACKED_CHUNK_HASH_SIZE; i++) |
| 1131 | INIT_HLIST_HEAD(&s->tracked_chunk_hash[i]); | 1118 | INIT_HLIST_HEAD(&s->tracked_chunk_hash[i]); |
| 1132 | 1119 | ||
| @@ -1134,6 +1121,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
| 1134 | 1121 | ||
| 1135 | ti->private = s; | 1122 | ti->private = s; |
| 1136 | ti->num_flush_requests = num_flush_requests; | 1123 | ti->num_flush_requests = num_flush_requests; |
| 1124 | ti->per_bio_data_size = sizeof(struct dm_snap_tracked_chunk); | ||
| 1137 | 1125 | ||
| 1138 | /* Add snapshot to the list of snapshots for this origin */ | 1126 | /* Add snapshot to the list of snapshots for this origin */ |
| 1139 | /* Exceptions aren't triggered till snapshot_resume() is called */ | 1127 | /* Exceptions aren't triggered till snapshot_resume() is called */ |
| @@ -1182,9 +1170,6 @@ bad_read_metadata: | |||
| 1182 | unregister_snapshot(s); | 1170 | unregister_snapshot(s); |
| 1183 | 1171 | ||
| 1184 | bad_load_and_register: | 1172 | bad_load_and_register: |
| 1185 | mempool_destroy(s->tracked_chunk_pool); | ||
| 1186 | |||
| 1187 | bad_tracked_chunk_pool: | ||
| 1188 | mempool_destroy(s->pending_pool); | 1173 | mempool_destroy(s->pending_pool); |
| 1189 | 1174 | ||
| 1190 | bad_pending_pool: | 1175 | bad_pending_pool: |
| @@ -1289,8 +1274,6 @@ static void snapshot_dtr(struct dm_target *ti) | |||
| 1289 | BUG_ON(!hlist_empty(&s->tracked_chunk_hash[i])); | 1274 | BUG_ON(!hlist_empty(&s->tracked_chunk_hash[i])); |
| 1290 | #endif | 1275 | #endif |
| 1291 | 1276 | ||
| 1292 | mempool_destroy(s->tracked_chunk_pool); | ||
| 1293 | |||
| 1294 | __free_exceptions(s); | 1277 | __free_exceptions(s); |
| 1295 | 1278 | ||
| 1296 | mempool_destroy(s->pending_pool); | 1279 | mempool_destroy(s->pending_pool); |
| @@ -1669,7 +1652,7 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio, | |||
| 1669 | } | 1652 | } |
| 1670 | } else { | 1653 | } else { |
| 1671 | bio->bi_bdev = s->origin->bdev; | 1654 | bio->bi_bdev = s->origin->bdev; |
| 1672 | map_context->ptr = track_chunk(s, chunk); | 1655 | map_context->ptr = track_chunk(s, bio, chunk); |
| 1673 | } | 1656 | } |
| 1674 | 1657 | ||
| 1675 | out_unlock: | 1658 | out_unlock: |
| @@ -1732,7 +1715,7 @@ static int snapshot_merge_map(struct dm_target *ti, struct bio *bio, | |||
| 1732 | remap_exception(s, e, bio, chunk); | 1715 | remap_exception(s, e, bio, chunk); |
| 1733 | 1716 | ||
| 1734 | if (bio_rw(bio) == WRITE) | 1717 | if (bio_rw(bio) == WRITE) |
| 1735 | map_context->ptr = track_chunk(s, chunk); | 1718 | map_context->ptr = track_chunk(s, bio, chunk); |
| 1736 | goto out_unlock; | 1719 | goto out_unlock; |
| 1737 | } | 1720 | } |
| 1738 | 1721 | ||
| @@ -2192,7 +2175,7 @@ static int origin_iterate_devices(struct dm_target *ti, | |||
| 2192 | 2175 | ||
| 2193 | static struct target_type origin_target = { | 2176 | static struct target_type origin_target = { |
| 2194 | .name = "snapshot-origin", | 2177 | .name = "snapshot-origin", |
| 2195 | .version = {1, 7, 1}, | 2178 | .version = {1, 8, 0}, |
| 2196 | .module = THIS_MODULE, | 2179 | .module = THIS_MODULE, |
| 2197 | .ctr = origin_ctr, | 2180 | .ctr = origin_ctr, |
| 2198 | .dtr = origin_dtr, | 2181 | .dtr = origin_dtr, |
| @@ -2205,7 +2188,7 @@ static struct target_type origin_target = { | |||
| 2205 | 2188 | ||
| 2206 | static struct target_type snapshot_target = { | 2189 | static struct target_type snapshot_target = { |
| 2207 | .name = "snapshot", | 2190 | .name = "snapshot", |
| 2208 | .version = {1, 10, 0}, | 2191 | .version = {1, 11, 0}, |
| 2209 | .module = THIS_MODULE, | 2192 | .module = THIS_MODULE, |
| 2210 | .ctr = snapshot_ctr, | 2193 | .ctr = snapshot_ctr, |
| 2211 | .dtr = snapshot_dtr, | 2194 | .dtr = snapshot_dtr, |
| @@ -2219,7 +2202,7 @@ static struct target_type snapshot_target = { | |||
| 2219 | 2202 | ||
| 2220 | static struct target_type merge_target = { | 2203 | static struct target_type merge_target = { |
| 2221 | .name = dm_snapshot_merge_target_name, | 2204 | .name = dm_snapshot_merge_target_name, |
| 2222 | .version = {1, 1, 0}, | 2205 | .version = {1, 2, 0}, |
| 2223 | .module = THIS_MODULE, | 2206 | .module = THIS_MODULE, |
| 2224 | .ctr = snapshot_ctr, | 2207 | .ctr = snapshot_ctr, |
| 2225 | .dtr = snapshot_dtr, | 2208 | .dtr = snapshot_dtr, |
| @@ -2280,17 +2263,8 @@ static int __init dm_snapshot_init(void) | |||
| 2280 | goto bad_pending_cache; | 2263 | goto bad_pending_cache; |
| 2281 | } | 2264 | } |
| 2282 | 2265 | ||
| 2283 | tracked_chunk_cache = KMEM_CACHE(dm_snap_tracked_chunk, 0); | ||
| 2284 | if (!tracked_chunk_cache) { | ||
| 2285 | DMERR("Couldn't create cache to track chunks in use."); | ||
| 2286 | r = -ENOMEM; | ||
| 2287 | goto bad_tracked_chunk_cache; | ||
| 2288 | } | ||
| 2289 | |||
| 2290 | return 0; | 2266 | return 0; |
| 2291 | 2267 | ||
| 2292 | bad_tracked_chunk_cache: | ||
| 2293 | kmem_cache_destroy(pending_cache); | ||
| 2294 | bad_pending_cache: | 2268 | bad_pending_cache: |
| 2295 | kmem_cache_destroy(exception_cache); | 2269 | kmem_cache_destroy(exception_cache); |
| 2296 | bad_exception_cache: | 2270 | bad_exception_cache: |
| @@ -2316,7 +2290,6 @@ static void __exit dm_snapshot_exit(void) | |||
| 2316 | exit_origin_hash(); | 2290 | exit_origin_hash(); |
| 2317 | kmem_cache_destroy(pending_cache); | 2291 | kmem_cache_destroy(pending_cache); |
| 2318 | kmem_cache_destroy(exception_cache); | 2292 | kmem_cache_destroy(exception_cache); |
| 2319 | kmem_cache_destroy(tracked_chunk_cache); | ||
| 2320 | 2293 | ||
| 2321 | dm_exception_store_exit(); | 2294 | dm_exception_store_exit(); |
| 2322 | } | 2295 | } |
