diff options
-rw-r--r-- | drivers/md/dm-exception-store.c | 6 | ||||
-rw-r--r-- | drivers/md/dm-exception-store.h | 7 | ||||
-rw-r--r-- | drivers/md/dm-snap-persistent.c | 47 | ||||
-rw-r--r-- | drivers/md/dm-snap-transient.c | 4 | ||||
-rw-r--r-- | drivers/md/dm-snap.c | 47 | ||||
-rw-r--r-- | drivers/md/dm-snap.h | 9 |
6 files changed, 67 insertions, 53 deletions
diff --git a/drivers/md/dm-exception-store.c b/drivers/md/dm-exception-store.c index fe0cfa677139..59c949b53106 100644 --- a/drivers/md/dm-exception-store.c +++ b/drivers/md/dm-exception-store.c | |||
@@ -138,6 +138,8 @@ int dm_exception_store_type_unregister(struct dm_exception_store_type *type) | |||
138 | EXPORT_SYMBOL(dm_exception_store_type_unregister); | 138 | EXPORT_SYMBOL(dm_exception_store_type_unregister); |
139 | 139 | ||
140 | int dm_exception_store_create(const char *type_name, struct dm_target *ti, | 140 | int dm_exception_store_create(const char *type_name, struct dm_target *ti, |
141 | chunk_t chunk_size, chunk_t chunk_mask, | ||
142 | chunk_t chunk_shift, | ||
141 | struct dm_exception_store **store) | 143 | struct dm_exception_store **store) |
142 | { | 144 | { |
143 | int r = 0; | 145 | int r = 0; |
@@ -157,6 +159,10 @@ int dm_exception_store_create(const char *type_name, struct dm_target *ti, | |||
157 | tmp_store->type = type; | 159 | tmp_store->type = type; |
158 | tmp_store->ti = ti; | 160 | tmp_store->ti = ti; |
159 | 161 | ||
162 | tmp_store->chunk_size = chunk_size; | ||
163 | tmp_store->chunk_mask = chunk_mask; | ||
164 | tmp_store->chunk_shift = chunk_shift; | ||
165 | |||
160 | r = type->ctr(tmp_store, 0, NULL); | 166 | r = type->ctr(tmp_store, 0, NULL); |
161 | if (r) { | 167 | if (r) { |
162 | put_type(type); | 168 | put_type(type); |
diff --git a/drivers/md/dm-exception-store.h b/drivers/md/dm-exception-store.h index 4b7f7d441f5f..449a1e48f7aa 100644 --- a/drivers/md/dm-exception-store.h +++ b/drivers/md/dm-exception-store.h | |||
@@ -99,6 +99,11 @@ struct dm_exception_store { | |||
99 | 99 | ||
100 | struct dm_snapshot *snap; | 100 | struct dm_snapshot *snap; |
101 | 101 | ||
102 | /* Size of data blocks saved - must be a power of 2 */ | ||
103 | chunk_t chunk_size; | ||
104 | chunk_t chunk_mask; | ||
105 | chunk_t chunk_shift; | ||
106 | |||
102 | void *context; | 107 | void *context; |
103 | }; | 108 | }; |
104 | 109 | ||
@@ -149,6 +154,8 @@ int dm_exception_store_type_register(struct dm_exception_store_type *type); | |||
149 | int dm_exception_store_type_unregister(struct dm_exception_store_type *type); | 154 | int dm_exception_store_type_unregister(struct dm_exception_store_type *type); |
150 | 155 | ||
151 | int dm_exception_store_create(const char *type_name, struct dm_target *ti, | 156 | int dm_exception_store_create(const char *type_name, struct dm_target *ti, |
157 | chunk_t chunk_size, chunk_t chunk_mask, | ||
158 | chunk_t chunk_shift, | ||
152 | struct dm_exception_store **store); | 159 | struct dm_exception_store **store); |
153 | void dm_exception_store_destroy(struct dm_exception_store *store); | 160 | void dm_exception_store_destroy(struct dm_exception_store *store); |
154 | 161 | ||
diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c index e85b7a186a13..c3c58159b6e8 100644 --- a/drivers/md/dm-snap-persistent.c +++ b/drivers/md/dm-snap-persistent.c | |||
@@ -141,7 +141,7 @@ static int alloc_area(struct pstore *ps) | |||
141 | int r = -ENOMEM; | 141 | int r = -ENOMEM; |
142 | size_t len; | 142 | size_t len; |
143 | 143 | ||
144 | len = ps->snap->chunk_size << SECTOR_SHIFT; | 144 | len = ps->snap->store->chunk_size << SECTOR_SHIFT; |
145 | 145 | ||
146 | /* | 146 | /* |
147 | * Allocate the chunk_size block of memory that will hold | 147 | * Allocate the chunk_size block of memory that will hold |
@@ -190,8 +190,8 @@ static int chunk_io(struct pstore *ps, chunk_t chunk, int rw, int metadata) | |||
190 | { | 190 | { |
191 | struct dm_io_region where = { | 191 | struct dm_io_region where = { |
192 | .bdev = ps->snap->cow->bdev, | 192 | .bdev = ps->snap->cow->bdev, |
193 | .sector = ps->snap->chunk_size * chunk, | 193 | .sector = ps->snap->store->chunk_size * chunk, |
194 | .count = ps->snap->chunk_size, | 194 | .count = ps->snap->store->chunk_size, |
195 | }; | 195 | }; |
196 | struct dm_io_request io_req = { | 196 | struct dm_io_request io_req = { |
197 | .bi_rw = rw, | 197 | .bi_rw = rw, |
@@ -247,15 +247,15 @@ static int area_io(struct pstore *ps, int rw) | |||
247 | 247 | ||
248 | static void zero_memory_area(struct pstore *ps) | 248 | static void zero_memory_area(struct pstore *ps) |
249 | { | 249 | { |
250 | memset(ps->area, 0, ps->snap->chunk_size << SECTOR_SHIFT); | 250 | memset(ps->area, 0, ps->snap->store->chunk_size << SECTOR_SHIFT); |
251 | } | 251 | } |
252 | 252 | ||
253 | static int zero_disk_area(struct pstore *ps, chunk_t area) | 253 | static int zero_disk_area(struct pstore *ps, chunk_t area) |
254 | { | 254 | { |
255 | struct dm_io_region where = { | 255 | struct dm_io_region where = { |
256 | .bdev = ps->snap->cow->bdev, | 256 | .bdev = ps->snap->cow->bdev, |
257 | .sector = ps->snap->chunk_size * area_location(ps, area), | 257 | .sector = ps->snap->store->chunk_size * area_location(ps, area), |
258 | .count = ps->snap->chunk_size, | 258 | .count = ps->snap->store->chunk_size, |
259 | }; | 259 | }; |
260 | struct dm_io_request io_req = { | 260 | struct dm_io_request io_req = { |
261 | .bi_rw = WRITE, | 261 | .bi_rw = WRITE, |
@@ -278,16 +278,17 @@ static int read_header(struct pstore *ps, int *new_snapshot) | |||
278 | /* | 278 | /* |
279 | * Use default chunk size (or hardsect_size, if larger) if none supplied | 279 | * Use default chunk size (or hardsect_size, if larger) if none supplied |
280 | */ | 280 | */ |
281 | if (!ps->snap->chunk_size) { | 281 | if (!ps->snap->store->chunk_size) { |
282 | ps->snap->chunk_size = max(DM_CHUNK_SIZE_DEFAULT_SECTORS, | 282 | ps->snap->store->chunk_size = max(DM_CHUNK_SIZE_DEFAULT_SECTORS, |
283 | bdev_hardsect_size(ps->snap->cow->bdev) >> 9); | 283 | bdev_hardsect_size(ps->snap->cow->bdev) >> 9); |
284 | ps->snap->chunk_mask = ps->snap->chunk_size - 1; | 284 | ps->snap->store->chunk_mask = ps->snap->store->chunk_size - 1; |
285 | ps->snap->chunk_shift = ffs(ps->snap->chunk_size) - 1; | 285 | ps->snap->store->chunk_shift = ffs(ps->snap->store->chunk_size) |
286 | - 1; | ||
286 | chunk_size_supplied = 0; | 287 | chunk_size_supplied = 0; |
287 | } | 288 | } |
288 | 289 | ||
289 | ps->io_client = dm_io_client_create(sectors_to_pages(ps->snap-> | 290 | ps->io_client = dm_io_client_create(sectors_to_pages(ps->snap-> |
290 | chunk_size)); | 291 | store->chunk_size)); |
291 | if (IS_ERR(ps->io_client)) | 292 | if (IS_ERR(ps->io_client)) |
292 | return PTR_ERR(ps->io_client); | 293 | return PTR_ERR(ps->io_client); |
293 | 294 | ||
@@ -317,22 +318,22 @@ static int read_header(struct pstore *ps, int *new_snapshot) | |||
317 | ps->version = le32_to_cpu(dh->version); | 318 | ps->version = le32_to_cpu(dh->version); |
318 | chunk_size = le32_to_cpu(dh->chunk_size); | 319 | chunk_size = le32_to_cpu(dh->chunk_size); |
319 | 320 | ||
320 | if (!chunk_size_supplied || ps->snap->chunk_size == chunk_size) | 321 | if (!chunk_size_supplied || ps->snap->store->chunk_size == chunk_size) |
321 | return 0; | 322 | return 0; |
322 | 323 | ||
323 | DMWARN("chunk size %llu in device metadata overrides " | 324 | DMWARN("chunk size %llu in device metadata overrides " |
324 | "table chunk size of %llu.", | 325 | "table chunk size of %llu.", |
325 | (unsigned long long)chunk_size, | 326 | (unsigned long long)chunk_size, |
326 | (unsigned long long)ps->snap->chunk_size); | 327 | (unsigned long long)ps->snap->store->chunk_size); |
327 | 328 | ||
328 | /* We had a bogus chunk_size. Fix stuff up. */ | 329 | /* We had a bogus chunk_size. Fix stuff up. */ |
329 | free_area(ps); | 330 | free_area(ps); |
330 | 331 | ||
331 | ps->snap->chunk_size = chunk_size; | 332 | ps->snap->store->chunk_size = chunk_size; |
332 | ps->snap->chunk_mask = chunk_size - 1; | 333 | ps->snap->store->chunk_mask = chunk_size - 1; |
333 | ps->snap->chunk_shift = ffs(chunk_size) - 1; | 334 | ps->snap->store->chunk_shift = ffs(chunk_size) - 1; |
334 | 335 | ||
335 | r = dm_io_client_resize(sectors_to_pages(ps->snap->chunk_size), | 336 | r = dm_io_client_resize(sectors_to_pages(ps->snap->store->chunk_size), |
336 | ps->io_client); | 337 | ps->io_client); |
337 | if (r) | 338 | if (r) |
338 | return r; | 339 | return r; |
@@ -349,13 +350,13 @@ static int write_header(struct pstore *ps) | |||
349 | { | 350 | { |
350 | struct disk_header *dh; | 351 | struct disk_header *dh; |
351 | 352 | ||
352 | memset(ps->area, 0, ps->snap->chunk_size << SECTOR_SHIFT); | 353 | memset(ps->area, 0, ps->snap->store->chunk_size << SECTOR_SHIFT); |
353 | 354 | ||
354 | dh = (struct disk_header *) ps->area; | 355 | dh = (struct disk_header *) ps->area; |
355 | dh->magic = cpu_to_le32(SNAP_MAGIC); | 356 | dh->magic = cpu_to_le32(SNAP_MAGIC); |
356 | dh->valid = cpu_to_le32(ps->valid); | 357 | dh->valid = cpu_to_le32(ps->valid); |
357 | dh->version = cpu_to_le32(ps->version); | 358 | dh->version = cpu_to_le32(ps->version); |
358 | dh->chunk_size = cpu_to_le32(ps->snap->chunk_size); | 359 | dh->chunk_size = cpu_to_le32(ps->snap->store->chunk_size); |
359 | 360 | ||
360 | return chunk_io(ps, 0, WRITE, 1); | 361 | return chunk_io(ps, 0, WRITE, 1); |
361 | } | 362 | } |
@@ -474,7 +475,7 @@ static struct pstore *get_info(struct dm_exception_store *store) | |||
474 | static void persistent_fraction_full(struct dm_exception_store *store, | 475 | static void persistent_fraction_full(struct dm_exception_store *store, |
475 | sector_t *numerator, sector_t *denominator) | 476 | sector_t *numerator, sector_t *denominator) |
476 | { | 477 | { |
477 | *numerator = get_info(store)->next_free * store->snap->chunk_size; | 478 | *numerator = get_info(store)->next_free * store->chunk_size; |
478 | *denominator = get_dev_size(store->snap->cow->bdev); | 479 | *denominator = get_dev_size(store->snap->cow->bdev); |
479 | } | 480 | } |
480 | 481 | ||
@@ -507,8 +508,8 @@ static int persistent_read_metadata(struct dm_exception_store *store, | |||
507 | /* | 508 | /* |
508 | * Now we know correct chunk_size, complete the initialisation. | 509 | * Now we know correct chunk_size, complete the initialisation. |
509 | */ | 510 | */ |
510 | ps->exceptions_per_area = (ps->snap->chunk_size << SECTOR_SHIFT) / | 511 | ps->exceptions_per_area = (ps->snap->store->chunk_size << SECTOR_SHIFT) |
511 | sizeof(struct disk_exception); | 512 | / sizeof(struct disk_exception); |
512 | ps->callbacks = dm_vcalloc(ps->exceptions_per_area, | 513 | ps->callbacks = dm_vcalloc(ps->exceptions_per_area, |
513 | sizeof(*ps->callbacks)); | 514 | sizeof(*ps->callbacks)); |
514 | if (!ps->callbacks) | 515 | if (!ps->callbacks) |
@@ -567,7 +568,7 @@ static int persistent_prepare_exception(struct dm_exception_store *store, | |||
567 | sector_t size = get_dev_size(store->snap->cow->bdev); | 568 | sector_t size = get_dev_size(store->snap->cow->bdev); |
568 | 569 | ||
569 | /* Is there enough room ? */ | 570 | /* Is there enough room ? */ |
570 | if (size < ((ps->next_free + 1) * store->snap->chunk_size)) | 571 | if (size < ((ps->next_free + 1) * store->chunk_size)) |
571 | return -ENOSPC; | 572 | return -ENOSPC; |
572 | 573 | ||
573 | e->new_chunk = ps->next_free; | 574 | e->new_chunk = ps->next_free; |
diff --git a/drivers/md/dm-snap-transient.c b/drivers/md/dm-snap-transient.c index 51bc4a78ce9a..c542ababb418 100644 --- a/drivers/md/dm-snap-transient.c +++ b/drivers/md/dm-snap-transient.c | |||
@@ -42,11 +42,11 @@ static int transient_prepare_exception(struct dm_exception_store *store, | |||
42 | struct transient_c *tc = store->context; | 42 | struct transient_c *tc = store->context; |
43 | sector_t size = get_dev_size(store->snap->cow->bdev); | 43 | sector_t size = get_dev_size(store->snap->cow->bdev); |
44 | 44 | ||
45 | if (size < (tc->next_free + store->snap->chunk_size)) | 45 | if (size < (tc->next_free + store->chunk_size)) |
46 | return -1; | 46 | return -1; |
47 | 47 | ||
48 | e->new_chunk = sector_to_chunk(store->snap, tc->next_free); | 48 | e->new_chunk = sector_to_chunk(store->snap, tc->next_free); |
49 | tc->next_free += store->snap->chunk_size; | 49 | tc->next_free += store->chunk_size; |
50 | 50 | ||
51 | return 0; | 51 | return 0; |
52 | } | 52 | } |
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index 4429c2a1d6fb..7a90fed033fe 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c | |||
@@ -468,7 +468,7 @@ static int calc_max_buckets(void) | |||
468 | /* | 468 | /* |
469 | * Allocate room for a suitable hash table. | 469 | * Allocate room for a suitable hash table. |
470 | */ | 470 | */ |
471 | static int init_hash_tables(struct dm_snapshot *s) | 471 | static int init_hash_tables(struct dm_snapshot *s, chunk_t chunk_shift) |
472 | { | 472 | { |
473 | sector_t hash_size, cow_dev_size, origin_dev_size, max_buckets; | 473 | sector_t hash_size, cow_dev_size, origin_dev_size, max_buckets; |
474 | 474 | ||
@@ -480,7 +480,7 @@ static int init_hash_tables(struct dm_snapshot *s) | |||
480 | origin_dev_size = get_dev_size(s->origin->bdev); | 480 | origin_dev_size = get_dev_size(s->origin->bdev); |
481 | max_buckets = calc_max_buckets(); | 481 | max_buckets = calc_max_buckets(); |
482 | 482 | ||
483 | hash_size = min(origin_dev_size, cow_dev_size) >> s->chunk_shift; | 483 | hash_size = min(origin_dev_size, cow_dev_size) >> chunk_shift; |
484 | hash_size = min(hash_size, max_buckets); | 484 | hash_size = min(hash_size, max_buckets); |
485 | 485 | ||
486 | hash_size = rounddown_pow_of_two(hash_size); | 486 | hash_size = rounddown_pow_of_two(hash_size); |
@@ -515,19 +515,20 @@ static ulong round_up(ulong n, ulong size) | |||
515 | } | 515 | } |
516 | 516 | ||
517 | static int set_chunk_size(struct dm_snapshot *s, const char *chunk_size_arg, | 517 | static int set_chunk_size(struct dm_snapshot *s, const char *chunk_size_arg, |
518 | char **error) | 518 | chunk_t *chunk_size, chunk_t *chunk_mask, |
519 | chunk_t *chunk_shift, char **error) | ||
519 | { | 520 | { |
520 | unsigned long chunk_size; | 521 | unsigned long chunk_size_ulong; |
521 | char *value; | 522 | char *value; |
522 | 523 | ||
523 | chunk_size = simple_strtoul(chunk_size_arg, &value, 10); | 524 | chunk_size_ulong = simple_strtoul(chunk_size_arg, &value, 10); |
524 | if (*chunk_size_arg == '\0' || *value != '\0') { | 525 | if (*chunk_size_arg == '\0' || *value != '\0') { |
525 | *error = "Invalid chunk size"; | 526 | *error = "Invalid chunk size"; |
526 | return -EINVAL; | 527 | return -EINVAL; |
527 | } | 528 | } |
528 | 529 | ||
529 | if (!chunk_size) { | 530 | if (!chunk_size_ulong) { |
530 | s->chunk_size = s->chunk_mask = s->chunk_shift = 0; | 531 | *chunk_size = *chunk_mask = *chunk_shift = 0; |
531 | return 0; | 532 | return 0; |
532 | } | 533 | } |
533 | 534 | ||
@@ -535,23 +536,23 @@ static int set_chunk_size(struct dm_snapshot *s, const char *chunk_size_arg, | |||
535 | * Chunk size must be multiple of page size. Silently | 536 | * Chunk size must be multiple of page size. Silently |
536 | * round up if it's not. | 537 | * round up if it's not. |
537 | */ | 538 | */ |
538 | chunk_size = round_up(chunk_size, PAGE_SIZE >> 9); | 539 | chunk_size_ulong = round_up(chunk_size_ulong, PAGE_SIZE >> 9); |
539 | 540 | ||
540 | /* Check chunk_size is a power of 2 */ | 541 | /* Check chunk_size is a power of 2 */ |
541 | if (!is_power_of_2(chunk_size)) { | 542 | if (!is_power_of_2(chunk_size_ulong)) { |
542 | *error = "Chunk size is not a power of 2"; | 543 | *error = "Chunk size is not a power of 2"; |
543 | return -EINVAL; | 544 | return -EINVAL; |
544 | } | 545 | } |
545 | 546 | ||
546 | /* Validate the chunk size against the device block size */ | 547 | /* Validate the chunk size against the device block size */ |
547 | if (chunk_size % (bdev_hardsect_size(s->cow->bdev) >> 9)) { | 548 | if (chunk_size_ulong % (bdev_hardsect_size(s->cow->bdev) >> 9)) { |
548 | *error = "Chunk size is not a multiple of device blocksize"; | 549 | *error = "Chunk size is not a multiple of device blocksize"; |
549 | return -EINVAL; | 550 | return -EINVAL; |
550 | } | 551 | } |
551 | 552 | ||
552 | s->chunk_size = chunk_size; | 553 | *chunk_size = chunk_size_ulong; |
553 | s->chunk_mask = chunk_size - 1; | 554 | *chunk_mask = chunk_size_ulong - 1; |
554 | s->chunk_shift = ffs(chunk_size) - 1; | 555 | *chunk_shift = ffs(chunk_size_ulong) - 1; |
555 | 556 | ||
556 | return 0; | 557 | return 0; |
557 | } | 558 | } |
@@ -567,6 +568,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
567 | char persistent; | 568 | char persistent; |
568 | char *origin_path; | 569 | char *origin_path; |
569 | char *cow_path; | 570 | char *cow_path; |
571 | chunk_t chunk_size, chunk_mask, chunk_shift; | ||
570 | 572 | ||
571 | if (argc != 4) { | 573 | if (argc != 4) { |
572 | ti->error = "requires exactly 4 arguments"; | 574 | ti->error = "requires exactly 4 arguments"; |
@@ -606,7 +608,8 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
606 | goto bad2; | 608 | goto bad2; |
607 | } | 609 | } |
608 | 610 | ||
609 | r = set_chunk_size(s, argv[3], &ti->error); | 611 | r = set_chunk_size(s, argv[3], &chunk_size, &chunk_mask, &chunk_shift, |
612 | &ti->error); | ||
610 | if (r) | 613 | if (r) |
611 | goto bad3; | 614 | goto bad3; |
612 | 615 | ||
@@ -617,13 +620,14 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
617 | spin_lock_init(&s->pe_lock); | 620 | spin_lock_init(&s->pe_lock); |
618 | 621 | ||
619 | /* Allocate hash table for COW data */ | 622 | /* Allocate hash table for COW data */ |
620 | if (init_hash_tables(s)) { | 623 | if (init_hash_tables(s, chunk_shift)) { |
621 | ti->error = "Unable to allocate hash table space"; | 624 | ti->error = "Unable to allocate hash table space"; |
622 | r = -ENOMEM; | 625 | r = -ENOMEM; |
623 | goto bad3; | 626 | goto bad3; |
624 | } | 627 | } |
625 | 628 | ||
626 | r = dm_exception_store_create(argv[2], ti, &s->store); | 629 | r = dm_exception_store_create(argv[2], ti, chunk_size, chunk_mask, |
630 | chunk_shift, &s->store); | ||
627 | if (r) { | 631 | if (r) { |
628 | ti->error = "Couldn't create exception store"; | 632 | ti->error = "Couldn't create exception store"; |
629 | r = -EINVAL; | 633 | r = -EINVAL; |
@@ -680,7 +684,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
680 | } | 684 | } |
681 | 685 | ||
682 | ti->private = s; | 686 | ti->private = s; |
683 | ti->split_io = s->chunk_size; | 687 | ti->split_io = s->store->chunk_size; |
684 | 688 | ||
685 | return 0; | 689 | return 0; |
686 | 690 | ||
@@ -955,7 +959,7 @@ static void start_copy(struct dm_snap_pending_exception *pe) | |||
955 | 959 | ||
956 | src.bdev = bdev; | 960 | src.bdev = bdev; |
957 | src.sector = chunk_to_sector(s, pe->e.old_chunk); | 961 | src.sector = chunk_to_sector(s, pe->e.old_chunk); |
958 | src.count = min(s->chunk_size, dev_size - src.sector); | 962 | src.count = min(s->store->chunk_size, dev_size - src.sector); |
959 | 963 | ||
960 | dest.bdev = s->cow->bdev; | 964 | dest.bdev = s->cow->bdev; |
961 | dest.sector = chunk_to_sector(s, pe->e.new_chunk); | 965 | dest.sector = chunk_to_sector(s, pe->e.new_chunk); |
@@ -1021,7 +1025,7 @@ static void remap_exception(struct dm_snapshot *s, struct dm_snap_exception *e, | |||
1021 | bio->bi_bdev = s->cow->bdev; | 1025 | bio->bi_bdev = s->cow->bdev; |
1022 | bio->bi_sector = chunk_to_sector(s, dm_chunk_number(e->new_chunk) + | 1026 | bio->bi_sector = chunk_to_sector(s, dm_chunk_number(e->new_chunk) + |
1023 | (chunk - e->old_chunk)) + | 1027 | (chunk - e->old_chunk)) + |
1024 | (bio->bi_sector & s->chunk_mask); | 1028 | (bio->bi_sector & s->store->chunk_mask); |
1025 | } | 1029 | } |
1026 | 1030 | ||
1027 | static int snapshot_map(struct dm_target *ti, struct bio *bio, | 1031 | static int snapshot_map(struct dm_target *ti, struct bio *bio, |
@@ -1166,7 +1170,7 @@ static int snapshot_status(struct dm_target *ti, status_type_t type, | |||
1166 | snprintf(result, maxlen, "%s %s %s %llu", | 1170 | snprintf(result, maxlen, "%s %s %s %llu", |
1167 | snap->origin->name, snap->cow->name, | 1171 | snap->origin->name, snap->cow->name, |
1168 | snap->store->type->name, | 1172 | snap->store->type->name, |
1169 | (unsigned long long)snap->chunk_size); | 1173 | (unsigned long long)snap->store->chunk_size); |
1170 | break; | 1174 | break; |
1171 | } | 1175 | } |
1172 | 1176 | ||
@@ -1377,7 +1381,8 @@ static void origin_resume(struct dm_target *ti) | |||
1377 | o = __lookup_origin(dev->bdev); | 1381 | o = __lookup_origin(dev->bdev); |
1378 | if (o) | 1382 | if (o) |
1379 | list_for_each_entry (snap, &o->snapshots, list) | 1383 | list_for_each_entry (snap, &o->snapshots, list) |
1380 | chunk_size = min_not_zero(chunk_size, snap->chunk_size); | 1384 | chunk_size = min_not_zero(chunk_size, |
1385 | snap->store->chunk_size); | ||
1381 | up_read(&_origins_lock); | 1386 | up_read(&_origins_lock); |
1382 | 1387 | ||
1383 | ti->split_io = chunk_size; | 1388 | ti->split_io = chunk_size; |
diff --git a/drivers/md/dm-snap.h b/drivers/md/dm-snap.h index 93cd8ee8997f..c2e4ebedbd49 100644 --- a/drivers/md/dm-snap.h +++ b/drivers/md/dm-snap.h | |||
@@ -32,11 +32,6 @@ struct dm_snapshot { | |||
32 | /* List of snapshots per Origin */ | 32 | /* List of snapshots per Origin */ |
33 | struct list_head list; | 33 | struct list_head list; |
34 | 34 | ||
35 | /* Size of data blocks saved - must be a power of 2 */ | ||
36 | chunk_t chunk_size; | ||
37 | chunk_t chunk_mask; | ||
38 | chunk_t chunk_shift; | ||
39 | |||
40 | /* You can't use a snapshot if this is 0 (e.g. if full) */ | 35 | /* You can't use a snapshot if this is 0 (e.g. if full) */ |
41 | int valid; | 36 | int valid; |
42 | 37 | ||
@@ -84,12 +79,12 @@ static inline sector_t get_dev_size(struct block_device *bdev) | |||
84 | 79 | ||
85 | static inline chunk_t sector_to_chunk(struct dm_snapshot *s, sector_t sector) | 80 | static inline chunk_t sector_to_chunk(struct dm_snapshot *s, sector_t sector) |
86 | { | 81 | { |
87 | return (sector & ~s->chunk_mask) >> s->chunk_shift; | 82 | return (sector & ~s->store->chunk_mask) >> s->store->chunk_shift; |
88 | } | 83 | } |
89 | 84 | ||
90 | static inline sector_t chunk_to_sector(struct dm_snapshot *s, chunk_t chunk) | 85 | static inline sector_t chunk_to_sector(struct dm_snapshot *s, chunk_t chunk) |
91 | { | 86 | { |
92 | return chunk << s->chunk_shift; | 87 | return chunk << s->store->chunk_shift; |
93 | } | 88 | } |
94 | 89 | ||
95 | static inline int bdev_equal(struct block_device *lhs, struct block_device *rhs) | 90 | static inline int bdev_equal(struct block_device *lhs, struct block_device *rhs) |