btt.c (fbde1414acc0440024083bf0c391b259bcfc4826) btt.c (ab45e7632717b811e0786e46ca5ad279cb731b66)
1/*
2 * Block Translation Table
3 * Copyright (c) 2014-2015, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *

--- 569 unchanged lines hidden (view full) ---

578 kfree(arena->map_locks);
579 kfree(arena->freelist);
580 debugfs_remove_recursive(arena->debugfs_dir);
581 kfree(arena);
582 }
583}
584
585/*
1/*
2 * Block Translation Table
3 * Copyright (c) 2014-2015, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *

--- 569 unchanged lines hidden (view full) ---

578 kfree(arena->map_locks);
579 kfree(arena->freelist);
580 debugfs_remove_recursive(arena->debugfs_dir);
581 kfree(arena);
582 }
583}
584
585/*
586 * This function checks if the metadata layout is valid and error free
587 */
588static int arena_is_valid(struct nd_btt *nd_btt, struct btt_sb *super)
589{
590 u64 checksum;
591
592 if (memcmp(super->uuid, nd_btt->uuid, 16))
593 return 0;
594
595 checksum = le64_to_cpu(super->checksum);
596 super->checksum = 0;
597 if (checksum != nd_btt_sb_checksum(super))
598 return 0;
599 super->checksum = cpu_to_le64(checksum);
600
601 if (nd_btt->lbasize != le32_to_cpu(super->external_lbasize))
602 return 0;
603
604 /* TODO: figure out action for this */
605 if ((le32_to_cpu(super->flags) & IB_FLAG_ERROR_MASK) != 0)
606 dev_info(&nd_btt->dev, "Found arena with an error flag\n");
607
608 return 1;
609}
610
611/*
612 * This function reads an existing valid btt superblock and
613 * populates the corresponding arena_info struct
614 */
615static void parse_arena_meta(struct arena_info *arena, struct btt_sb *super,
616 u64 arena_off)
617{
618 arena->internal_nlba = le32_to_cpu(super->internal_nlba);
619 arena->internal_lbasize = le32_to_cpu(super->internal_lbasize);

--- 40 unchanged lines hidden (view full) ---

660 goto out_super;
661 }
662
663 arena->infooff = cur_off;
664 ret = btt_info_read(arena, super);
665 if (ret)
666 goto out;
667
586 * This function reads an existing valid btt superblock and
587 * populates the corresponding arena_info struct
588 */
589static void parse_arena_meta(struct arena_info *arena, struct btt_sb *super,
590 u64 arena_off)
591{
592 arena->internal_nlba = le32_to_cpu(super->internal_nlba);
593 arena->internal_lbasize = le32_to_cpu(super->internal_lbasize);

--- 40 unchanged lines hidden (view full) ---

634 goto out_super;
635 }
636
637 arena->infooff = cur_off;
638 ret = btt_info_read(arena, super);
639 if (ret)
640 goto out;
641
668 if (!arena_is_valid(btt->nd_btt, super)) {
642 if (!nd_btt_arena_is_valid(btt->nd_btt, super)) {
669 if (remaining == btt->rawsize) {
670 btt->init_state = INIT_NOTFOUND;
671 dev_info(to_dev(arena), "No existing arenas\n");
672 goto out;
673 } else {
674 dev_info(to_dev(arena),
675 "Found corrupted metadata!\n");
676 ret = -ENODEV;

--- 803 unchanged lines hidden ---
643 if (remaining == btt->rawsize) {
644 btt->init_state = INIT_NOTFOUND;
645 dev_info(to_dev(arena), "No existing arenas\n");
646 goto out;
647 } else {
648 dev_info(to_dev(arena),
649 "Found corrupted metadata!\n");
650 ret = -ENODEV;

--- 803 unchanged lines hidden ---