diff options
author | Vishal Verma <vishal.l.verma@intel.com> | 2015-07-29 16:58:07 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2015-08-14 13:43:04 -0400 |
commit | fbde1414acc0440024083bf0c391b259bcfc4826 (patch) | |
tree | a9130d2912234cc043d9d56167153bcfc98718b0 | |
parent | f6ef5a2a50816b58e3126206de13d0b9fdf89df5 (diff) |
libnvdimm, btt: clean up internal interfaces
Consolidate the parameters passed to arena_is_valid into just nd_btt,
and an info block to increase re-usability.
Similarly, btt_arena_write_layout doesn't need to be passed a uuid, as
it can be obtained from arena->nd_btt.
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r-- | drivers/nvdimm/btt.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c index 552f1c4f4dc6..87e6a96a6c19 100644 --- a/drivers/nvdimm/btt.c +++ b/drivers/nvdimm/btt.c | |||
@@ -585,12 +585,11 @@ static void free_arenas(struct btt *btt) | |||
585 | /* | 585 | /* |
586 | * This function checks if the metadata layout is valid and error free | 586 | * This function checks if the metadata layout is valid and error free |
587 | */ | 587 | */ |
588 | static int arena_is_valid(struct arena_info *arena, struct btt_sb *super, | 588 | static int arena_is_valid(struct nd_btt *nd_btt, struct btt_sb *super) |
589 | u8 *uuid, u32 lbasize) | ||
590 | { | 589 | { |
591 | u64 checksum; | 590 | u64 checksum; |
592 | 591 | ||
593 | if (memcmp(super->uuid, uuid, 16)) | 592 | if (memcmp(super->uuid, nd_btt->uuid, 16)) |
594 | return 0; | 593 | return 0; |
595 | 594 | ||
596 | checksum = le64_to_cpu(super->checksum); | 595 | checksum = le64_to_cpu(super->checksum); |
@@ -599,12 +598,12 @@ static int arena_is_valid(struct arena_info *arena, struct btt_sb *super, | |||
599 | return 0; | 598 | return 0; |
600 | super->checksum = cpu_to_le64(checksum); | 599 | super->checksum = cpu_to_le64(checksum); |
601 | 600 | ||
602 | if (lbasize != le32_to_cpu(super->external_lbasize)) | 601 | if (nd_btt->lbasize != le32_to_cpu(super->external_lbasize)) |
603 | return 0; | 602 | return 0; |
604 | 603 | ||
605 | /* TODO: figure out action for this */ | 604 | /* TODO: figure out action for this */ |
606 | if ((le32_to_cpu(super->flags) & IB_FLAG_ERROR_MASK) != 0) | 605 | if ((le32_to_cpu(super->flags) & IB_FLAG_ERROR_MASK) != 0) |
607 | dev_info(to_dev(arena), "Found arena with an error flag\n"); | 606 | dev_info(&nd_btt->dev, "Found arena with an error flag\n"); |
608 | 607 | ||
609 | return 1; | 608 | return 1; |
610 | } | 609 | } |
@@ -666,8 +665,7 @@ static int discover_arenas(struct btt *btt) | |||
666 | if (ret) | 665 | if (ret) |
667 | goto out; | 666 | goto out; |
668 | 667 | ||
669 | if (!arena_is_valid(arena, super, btt->nd_btt->uuid, | 668 | if (!arena_is_valid(btt->nd_btt, super)) { |
670 | btt->lbasize)) { | ||
671 | if (remaining == btt->rawsize) { | 669 | if (remaining == btt->rawsize) { |
672 | btt->init_state = INIT_NOTFOUND; | 670 | btt->init_state = INIT_NOTFOUND; |
673 | dev_info(to_dev(arena), "No existing arenas\n"); | 671 | dev_info(to_dev(arena), "No existing arenas\n"); |
@@ -756,10 +754,11 @@ static int create_arenas(struct btt *btt) | |||
756 | * It is only called for an uninitialized arena when a write | 754 | * It is only called for an uninitialized arena when a write |
757 | * to that arena occurs for the first time. | 755 | * to that arena occurs for the first time. |
758 | */ | 756 | */ |
759 | static int btt_arena_write_layout(struct arena_info *arena, u8 *uuid) | 757 | static int btt_arena_write_layout(struct arena_info *arena) |
760 | { | 758 | { |
761 | int ret; | 759 | int ret; |
762 | struct btt_sb *super; | 760 | struct btt_sb *super; |
761 | struct nd_btt *nd_btt = arena->nd_btt; | ||
763 | 762 | ||
764 | ret = btt_map_init(arena); | 763 | ret = btt_map_init(arena); |
765 | if (ret) | 764 | if (ret) |
@@ -774,7 +773,7 @@ static int btt_arena_write_layout(struct arena_info *arena, u8 *uuid) | |||
774 | return -ENOMEM; | 773 | return -ENOMEM; |
775 | 774 | ||
776 | strncpy(super->signature, BTT_SIG, BTT_SIG_LEN); | 775 | strncpy(super->signature, BTT_SIG, BTT_SIG_LEN); |
777 | memcpy(super->uuid, uuid, 16); | 776 | memcpy(super->uuid, nd_btt->uuid, 16); |
778 | super->flags = cpu_to_le32(arena->flags); | 777 | super->flags = cpu_to_le32(arena->flags); |
779 | super->version_major = cpu_to_le16(arena->version_major); | 778 | super->version_major = cpu_to_le16(arena->version_major); |
780 | super->version_minor = cpu_to_le16(arena->version_minor); | 779 | super->version_minor = cpu_to_le16(arena->version_minor); |
@@ -814,7 +813,7 @@ static int btt_meta_init(struct btt *btt) | |||
814 | 813 | ||
815 | mutex_lock(&btt->init_lock); | 814 | mutex_lock(&btt->init_lock); |
816 | list_for_each_entry(arena, &btt->arena_list, list) { | 815 | list_for_each_entry(arena, &btt->arena_list, list) { |
817 | ret = btt_arena_write_layout(arena, btt->nd_btt->uuid); | 816 | ret = btt_arena_write_layout(arena); |
818 | if (ret) | 817 | if (ret) |
819 | goto unlock; | 818 | goto unlock; |
820 | 819 | ||