diff options
author | Joe Thornber <ejt@redhat.com> | 2012-07-27 10:08:12 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2012-07-27 10:08:12 -0400 |
commit | d6332814e343c76097ff10ed8225069e6392022f (patch) | |
tree | dcd4c0a1db3f91e90cb985833dc3ab424e24a0ab /drivers/md/dm-thin-metadata.c | |
parent | 583ceee2ed1d171718aee348163f2ed25d461772 (diff) |
dm thin metadata: use struct dm_pool_metadata members in __open_or_format_metadata
Clean up __open_or_format_metadata in dm-thin-metadata by using struct
dm_pool_metadata members to replace local variables.
Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm-thin-metadata.c')
-rw-r--r-- | drivers/md/dm-thin-metadata.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c index 9f7c1e01dda2..dceec441ef30 100644 --- a/drivers/md/dm-thin-metadata.c +++ b/drivers/md/dm-thin-metadata.c | |||
@@ -486,31 +486,29 @@ bad_locked: | |||
486 | } | 486 | } |
487 | 487 | ||
488 | static int __open_or_format_metadata(struct dm_pool_metadata *pmd, | 488 | static int __open_or_format_metadata(struct dm_pool_metadata *pmd, |
489 | struct dm_block_manager *bm, | ||
490 | dm_block_t nr_blocks, int create) | 489 | dm_block_t nr_blocks, int create) |
491 | { | 490 | { |
492 | int r; | 491 | int r; |
493 | struct dm_space_map *sm, *data_sm; | ||
494 | struct dm_transaction_manager *tm; | ||
495 | struct dm_block *sblock; | 492 | struct dm_block *sblock; |
496 | 493 | ||
497 | if (create) { | 494 | if (create) { |
498 | r = dm_tm_create_with_sm(bm, THIN_SUPERBLOCK_LOCATION, &tm, &sm); | 495 | r = dm_tm_create_with_sm(pmd->bm, THIN_SUPERBLOCK_LOCATION, |
496 | &pmd->tm, &pmd->metadata_sm); | ||
499 | if (r < 0) { | 497 | if (r < 0) { |
500 | DMERR("tm_create_with_sm failed"); | 498 | DMERR("tm_create_with_sm failed"); |
501 | return r; | 499 | return r; |
502 | } | 500 | } |
503 | 501 | ||
504 | data_sm = dm_sm_disk_create(tm, nr_blocks); | 502 | pmd->data_sm = dm_sm_disk_create(pmd->tm, nr_blocks); |
505 | if (IS_ERR(data_sm)) { | 503 | if (IS_ERR(pmd->data_sm)) { |
506 | DMERR("sm_disk_create failed"); | 504 | DMERR("sm_disk_create failed"); |
507 | r = PTR_ERR(data_sm); | 505 | r = PTR_ERR(pmd->data_sm); |
508 | goto bad; | 506 | goto bad; |
509 | } | 507 | } |
510 | } else { | 508 | } else { |
511 | struct thin_disk_superblock *disk_super; | 509 | struct thin_disk_superblock *disk_super; |
512 | 510 | ||
513 | r = dm_bm_read_lock(bm, THIN_SUPERBLOCK_LOCATION, | 511 | r = dm_bm_read_lock(pmd->bm, THIN_SUPERBLOCK_LOCATION, |
514 | &sb_validator, &sblock); | 512 | &sb_validator, &sblock); |
515 | if (r < 0) { | 513 | if (r < 0) { |
516 | DMERR("couldn't read superblock"); | 514 | DMERR("couldn't read superblock"); |
@@ -518,33 +516,29 @@ static int __open_or_format_metadata(struct dm_pool_metadata *pmd, | |||
518 | } | 516 | } |
519 | 517 | ||
520 | disk_super = dm_block_data(sblock); | 518 | disk_super = dm_block_data(sblock); |
521 | r = dm_tm_open_with_sm(bm, THIN_SUPERBLOCK_LOCATION, | 519 | r = dm_tm_open_with_sm(pmd->bm, THIN_SUPERBLOCK_LOCATION, |
522 | disk_super->metadata_space_map_root, | 520 | disk_super->metadata_space_map_root, |
523 | sizeof(disk_super->metadata_space_map_root), | 521 | sizeof(disk_super->metadata_space_map_root), |
524 | &tm, &sm); | 522 | &pmd->tm, &pmd->metadata_sm); |
525 | if (r < 0) { | 523 | if (r < 0) { |
526 | DMERR("tm_open_with_sm failed"); | 524 | DMERR("tm_open_with_sm failed"); |
527 | dm_bm_unlock(sblock); | 525 | dm_bm_unlock(sblock); |
528 | return r; | 526 | return r; |
529 | } | 527 | } |
530 | 528 | ||
531 | data_sm = dm_sm_disk_open(tm, disk_super->data_space_map_root, | 529 | pmd->data_sm = dm_sm_disk_open(pmd->tm, disk_super->data_space_map_root, |
532 | sizeof(disk_super->data_space_map_root)); | 530 | sizeof(disk_super->data_space_map_root)); |
533 | if (IS_ERR(data_sm)) { | 531 | if (IS_ERR(pmd->data_sm)) { |
534 | DMERR("sm_disk_open failed"); | 532 | DMERR("sm_disk_open failed"); |
535 | dm_bm_unlock(sblock); | 533 | dm_bm_unlock(sblock); |
536 | r = PTR_ERR(data_sm); | 534 | r = PTR_ERR(pmd->data_sm); |
537 | goto bad; | 535 | goto bad; |
538 | } | 536 | } |
539 | 537 | ||
540 | dm_bm_unlock(sblock); | 538 | dm_bm_unlock(sblock); |
541 | } | 539 | } |
542 | 540 | ||
543 | pmd->bm = bm; | 541 | pmd->nb_tm = dm_tm_create_non_blocking_clone(pmd->tm); |
544 | pmd->metadata_sm = sm; | ||
545 | pmd->data_sm = data_sm; | ||
546 | pmd->tm = tm; | ||
547 | pmd->nb_tm = dm_tm_create_non_blocking_clone(tm); | ||
548 | if (!pmd->nb_tm) { | 542 | if (!pmd->nb_tm) { |
549 | DMERR("could not create clone tm"); | 543 | DMERR("could not create clone tm"); |
550 | r = -ENOMEM; | 544 | r = -ENOMEM; |
@@ -578,10 +572,10 @@ static int __open_or_format_metadata(struct dm_pool_metadata *pmd, | |||
578 | return 0; | 572 | return 0; |
579 | 573 | ||
580 | bad_data_sm: | 574 | bad_data_sm: |
581 | dm_sm_destroy(data_sm); | 575 | dm_sm_destroy(pmd->data_sm); |
582 | bad: | 576 | bad: |
583 | dm_tm_destroy(tm); | 577 | dm_tm_destroy(pmd->tm); |
584 | dm_sm_destroy(sm); | 578 | dm_sm_destroy(pmd->metadata_sm); |
585 | 579 | ||
586 | return r; | 580 | return r; |
587 | } | 581 | } |
@@ -605,7 +599,7 @@ static int __create_persistent_data_objects(struct dm_pool_metadata *pmd, | |||
605 | return r; | 599 | return r; |
606 | } | 600 | } |
607 | 601 | ||
608 | r = __open_or_format_metadata(pmd, pmd->bm, nr_blocks, *create); | 602 | r = __open_or_format_metadata(pmd, nr_blocks, *create); |
609 | if (r) | 603 | if (r) |
610 | dm_block_manager_destroy(pmd->bm); | 604 | dm_block_manager_destroy(pmd->bm); |
611 | 605 | ||