diff options
author | Joe Thornber <ejt@redhat.com> | 2012-07-27 10:08:08 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2012-07-27 10:08:08 -0400 |
commit | 41675aea32949786cf002c4ab179b85144d3423b (patch) | |
tree | d721f9383bc9c7614106188f12e3781fe85dc3e4 | |
parent | 0ac55489d9e3898987b2ae305844cf2af86e6b8d (diff) |
dm thin metadata: factor __setup_btree_details out of init_pmd
Factor __setup_btree_details out of init_pmd in dm-thin-metadata.
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>
-rw-r--r-- | drivers/md/dm-thin-metadata.c | 74 |
1 files changed, 39 insertions, 35 deletions
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c index 31f9827dfb5..82b82c318f1 100644 --- a/drivers/md/dm-thin-metadata.c +++ b/drivers/md/dm-thin-metadata.c | |||
@@ -371,6 +371,44 @@ static int superblock_all_zeroes(struct dm_block_manager *bm, int *result) | |||
371 | return dm_bm_unlock(b); | 371 | return dm_bm_unlock(b); |
372 | } | 372 | } |
373 | 373 | ||
374 | static void __setup_btree_details(struct dm_pool_metadata *pmd) | ||
375 | { | ||
376 | pmd->info.tm = pmd->tm; | ||
377 | pmd->info.levels = 2; | ||
378 | pmd->info.value_type.context = pmd->data_sm; | ||
379 | pmd->info.value_type.size = sizeof(__le64); | ||
380 | pmd->info.value_type.inc = data_block_inc; | ||
381 | pmd->info.value_type.dec = data_block_dec; | ||
382 | pmd->info.value_type.equal = data_block_equal; | ||
383 | |||
384 | memcpy(&pmd->nb_info, &pmd->info, sizeof(pmd->nb_info)); | ||
385 | pmd->nb_info.tm = pmd->nb_tm; | ||
386 | |||
387 | pmd->tl_info.tm = pmd->tm; | ||
388 | pmd->tl_info.levels = 1; | ||
389 | pmd->tl_info.value_type.context = &pmd->info; | ||
390 | pmd->tl_info.value_type.size = sizeof(__le64); | ||
391 | pmd->tl_info.value_type.inc = subtree_inc; | ||
392 | pmd->tl_info.value_type.dec = subtree_dec; | ||
393 | pmd->tl_info.value_type.equal = subtree_equal; | ||
394 | |||
395 | pmd->bl_info.tm = pmd->tm; | ||
396 | pmd->bl_info.levels = 1; | ||
397 | pmd->bl_info.value_type.context = pmd->data_sm; | ||
398 | pmd->bl_info.value_type.size = sizeof(__le64); | ||
399 | pmd->bl_info.value_type.inc = data_block_inc; | ||
400 | pmd->bl_info.value_type.dec = data_block_dec; | ||
401 | pmd->bl_info.value_type.equal = data_block_equal; | ||
402 | |||
403 | pmd->details_info.tm = pmd->tm; | ||
404 | pmd->details_info.levels = 1; | ||
405 | pmd->details_info.value_type.context = NULL; | ||
406 | pmd->details_info.value_type.size = sizeof(struct disk_device_details); | ||
407 | pmd->details_info.value_type.inc = NULL; | ||
408 | pmd->details_info.value_type.dec = NULL; | ||
409 | pmd->details_info.value_type.equal = NULL; | ||
410 | } | ||
411 | |||
374 | static int init_pmd(struct dm_pool_metadata *pmd, | 412 | static int init_pmd(struct dm_pool_metadata *pmd, |
375 | struct dm_block_manager *bm, | 413 | struct dm_block_manager *bm, |
376 | dm_block_t nr_blocks, int create) | 414 | dm_block_t nr_blocks, int create) |
@@ -436,41 +474,7 @@ static int init_pmd(struct dm_pool_metadata *pmd, | |||
436 | goto bad_data_sm; | 474 | goto bad_data_sm; |
437 | } | 475 | } |
438 | 476 | ||
439 | pmd->info.tm = tm; | 477 | __setup_btree_details(pmd); |
440 | pmd->info.levels = 2; | ||
441 | pmd->info.value_type.context = pmd->data_sm; | ||
442 | pmd->info.value_type.size = sizeof(__le64); | ||
443 | pmd->info.value_type.inc = data_block_inc; | ||
444 | pmd->info.value_type.dec = data_block_dec; | ||
445 | pmd->info.value_type.equal = data_block_equal; | ||
446 | |||
447 | memcpy(&pmd->nb_info, &pmd->info, sizeof(pmd->nb_info)); | ||
448 | pmd->nb_info.tm = pmd->nb_tm; | ||
449 | |||
450 | pmd->tl_info.tm = tm; | ||
451 | pmd->tl_info.levels = 1; | ||
452 | pmd->tl_info.value_type.context = &pmd->info; | ||
453 | pmd->tl_info.value_type.size = sizeof(__le64); | ||
454 | pmd->tl_info.value_type.inc = subtree_inc; | ||
455 | pmd->tl_info.value_type.dec = subtree_dec; | ||
456 | pmd->tl_info.value_type.equal = subtree_equal; | ||
457 | |||
458 | pmd->bl_info.tm = tm; | ||
459 | pmd->bl_info.levels = 1; | ||
460 | pmd->bl_info.value_type.context = pmd->data_sm; | ||
461 | pmd->bl_info.value_type.size = sizeof(__le64); | ||
462 | pmd->bl_info.value_type.inc = data_block_inc; | ||
463 | pmd->bl_info.value_type.dec = data_block_dec; | ||
464 | pmd->bl_info.value_type.equal = data_block_equal; | ||
465 | |||
466 | pmd->details_info.tm = tm; | ||
467 | pmd->details_info.levels = 1; | ||
468 | pmd->details_info.value_type.context = NULL; | ||
469 | pmd->details_info.value_type.size = sizeof(struct disk_device_details); | ||
470 | pmd->details_info.value_type.inc = NULL; | ||
471 | pmd->details_info.value_type.dec = NULL; | ||
472 | pmd->details_info.value_type.equal = NULL; | ||
473 | |||
474 | pmd->root = 0; | 478 | pmd->root = 0; |
475 | 479 | ||
476 | init_rwsem(&pmd->root_lock); | 480 | init_rwsem(&pmd->root_lock); |