diff options
Diffstat (limited to 'drivers/md/dm-snap-persistent.c')
-rw-r--r-- | drivers/md/dm-snap-persistent.c | 47 |
1 files changed, 24 insertions, 23 deletions
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; |