diff options
author | Joe Thornber <ejt@redhat.com> | 2012-07-27 10:08:09 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2012-07-27 10:08:09 -0400 |
commit | 384ef0e62e409e52c80adef5b1ff83075377c19e (patch) | |
tree | 734db218c323e88a303f64218661286f94f9e52a /drivers/md/dm-thin-metadata.c | |
parent | eb04cf634fc2d5e3bc8fe88fbf434eda4921d875 (diff) |
dm persistent data: tidy transaction manager creation fns
Tidy the transaction manager creation functions.
They no longer lock the superblock. Superblock locking is pulled out to
the caller.
Also export dm_bm_write_lock_zero.
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 | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c index c8f36227fd7b..4aadeae3af67 100644 --- a/drivers/md/dm-thin-metadata.c +++ b/drivers/md/dm-thin-metadata.c | |||
@@ -418,8 +418,7 @@ static int init_pmd(struct dm_pool_metadata *pmd, | |||
418 | struct dm_block *sblock; | 418 | struct dm_block *sblock; |
419 | 419 | ||
420 | if (create) { | 420 | if (create) { |
421 | r = dm_tm_create_with_sm(bm, THIN_SUPERBLOCK_LOCATION, | 421 | r = dm_tm_create_with_sm(bm, THIN_SUPERBLOCK_LOCATION, &tm, &sm); |
422 | &sb_validator, &tm, &sm, &sblock); | ||
423 | if (r < 0) { | 422 | if (r < 0) { |
424 | DMERR("tm_create_with_sm failed"); | 423 | DMERR("tm_create_with_sm failed"); |
425 | return r; | 424 | return r; |
@@ -428,38 +427,51 @@ static int init_pmd(struct dm_pool_metadata *pmd, | |||
428 | data_sm = dm_sm_disk_create(tm, nr_blocks); | 427 | data_sm = dm_sm_disk_create(tm, nr_blocks); |
429 | if (IS_ERR(data_sm)) { | 428 | if (IS_ERR(data_sm)) { |
430 | DMERR("sm_disk_create failed"); | 429 | DMERR("sm_disk_create failed"); |
431 | dm_tm_unlock(tm, sblock); | ||
432 | r = PTR_ERR(data_sm); | 430 | r = PTR_ERR(data_sm); |
433 | goto bad; | 431 | goto bad; |
434 | } | 432 | } |
433 | |||
434 | /* | ||
435 | * We cycle the superblock to let the validator do its stuff. | ||
436 | */ | ||
437 | r = dm_bm_write_lock_zero(bm, THIN_SUPERBLOCK_LOCATION, &sb_validator, &sblock); | ||
438 | if (r < 0) { | ||
439 | DMERR("couldn't lock superblock"); | ||
440 | goto bad; | ||
441 | } | ||
442 | |||
443 | dm_bm_unlock(sblock); | ||
444 | |||
435 | } else { | 445 | } else { |
436 | struct thin_disk_superblock *disk_super = NULL; | 446 | struct thin_disk_superblock *disk_super; |
437 | size_t space_map_root_offset = | 447 | |
438 | offsetof(struct thin_disk_superblock, metadata_space_map_root); | 448 | r = dm_bm_read_lock(bm, THIN_SUPERBLOCK_LOCATION, &sb_validator, &sblock); |
449 | if (r < 0) { | ||
450 | DMERR("couldn't read superblock"); | ||
451 | return r; | ||
452 | } | ||
439 | 453 | ||
454 | disk_super = dm_block_data(sblock); | ||
440 | r = dm_tm_open_with_sm(bm, THIN_SUPERBLOCK_LOCATION, | 455 | r = dm_tm_open_with_sm(bm, THIN_SUPERBLOCK_LOCATION, |
441 | &sb_validator, space_map_root_offset, | 456 | disk_super->metadata_space_map_root, |
442 | SPACE_MAP_ROOT_SIZE, &tm, &sm, &sblock); | 457 | sizeof(disk_super->metadata_space_map_root), |
458 | &tm, &sm); | ||
443 | if (r < 0) { | 459 | if (r < 0) { |
444 | DMERR("tm_open_with_sm failed"); | 460 | DMERR("tm_open_with_sm failed"); |
461 | dm_bm_unlock(sblock); | ||
445 | return r; | 462 | return r; |
446 | } | 463 | } |
447 | 464 | ||
448 | disk_super = dm_block_data(sblock); | ||
449 | data_sm = dm_sm_disk_open(tm, disk_super->data_space_map_root, | 465 | data_sm = dm_sm_disk_open(tm, disk_super->data_space_map_root, |
450 | sizeof(disk_super->data_space_map_root)); | 466 | sizeof(disk_super->data_space_map_root)); |
451 | if (IS_ERR(data_sm)) { | 467 | if (IS_ERR(data_sm)) { |
452 | DMERR("sm_disk_open failed"); | 468 | DMERR("sm_disk_open failed"); |
469 | dm_bm_unlock(sblock); | ||
453 | r = PTR_ERR(data_sm); | 470 | r = PTR_ERR(data_sm); |
454 | goto bad; | 471 | goto bad; |
455 | } | 472 | } |
456 | } | ||
457 | |||
458 | 473 | ||
459 | r = dm_tm_unlock(tm, sblock); | 474 | dm_bm_unlock(sblock); |
460 | if (r < 0) { | ||
461 | DMERR("couldn't unlock superblock"); | ||
462 | goto bad_data_sm; | ||
463 | } | 475 | } |
464 | 476 | ||
465 | pmd->bm = bm; | 477 | pmd->bm = bm; |