Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the number of chunks issue #415

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

hkadayam
Copy link
Collaborator

At present the number of chunk info slots pre created is incorrectly did not convert number of bytes to bits. Fixed that issue.

@hkadayam hkadayam requested a review from xiaoxichen May 11, 2024 00:18
xiaoxichen
xiaoxichen previously approved these changes May 13, 2024
Copy link
Contributor

@xiaoxichen xiaoxichen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM through I dont really understand where the max_possible_bits comes from ?

Copy link
Contributor

@xiaoxichen xiaoxichen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that better to hornor the requested num_bits instead of honor the serialize size?

we are now:

  1. round num_chunks to 4K boundary and convert to byte, to get bit_map_size
  2. bitmap_size - serialization_tax then convert to bit, to the Bitset size.

which is a bit disconnect between the original requests (num_chunks) and final bitmap available bits.

Considering doing

m_chunk_info_slots = std::make_unique< sisl::Bitset >(hs_super_blk::max_chunks_in_pdev(m_dev_info));

the bitmap_mem is align to align_size (512) not 4K but it should be fine right

@hkadayam
Copy link
Collaborator Author

Is that better to hornor the requested num_bits instead of honor the serialize size?

we are now:

  1. round num_chunks to 4K boundary and convert to byte, to get bit_map_size
  2. bitmap_size - serialization_tax then convert to bit, to the Bitset size.

which is a bit disconnect between the original requests (num_chunks) and final bitmap available bits.

Considering doing

m_chunk_info_slots = std::make_unique< sisl::Bitset >(hs_super_blk::max_chunks_in_pdev(m_dev_info));

the bitmap_mem is align to align_size (512) not 4K but it should be fine right

Yes I adjusted the code accordingly @xiaoxichen please take a look.

@hkadayam hkadayam requested a review from xiaoxichen May 15, 2024 03:50
auto bitmap_mem = m_chunk_info_slots->serialize(m_pdev_info.dev_attr.align_size);
HS_REL_ASSERT_LE(bitmap_mem->size(), hs_super_blk::chunk_info_bitmap_size(m_dev_info),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see chunk_info_bitmap_size round up to 4K, and didnt properly handle the boundary when max_chunks_in_pdev % 8 != 0

however the bitset->serilize(align_size == 512) added up sizeof(bitset_serialized) and align to 512.

    static uint64_t chunk_info_bitmap_size(const dev_info& dinfo) {
        // Chunk bitmap area has bitmap of max_chunks rounded off to 4k page
        return sisl::round_up(std::max(1u, hs_super_blk::max_chunks_in_pdev(dinfo) / 8), 4096);
    }
           const uint64_t total_words{bitset_serialized::total_words(num_bits)};
           const uint64_t total_bytes{sizeof(bitset_serialized) + sizeof(word_t) * total_words};
           const uint64_t size{(alignment_size > 0) ? round_up(total_bytes, alignment_size) : total_bytes};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if hs_super_blk::max_chunks_in_pdev(m_dev_info) == 4096 * 8, we get
hs_super_blk::chunk_info_bitmap_size ==4096
and
m_chunk_info_slots->serialize = round_up (4096 + sizeof(bitset_serialized), 512) = 4608

Copy link
Contributor

@xiaoxichen xiaoxichen May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe change chunk_info_bitmap_size to

static uint64_t chunk_info_bitmap_size(const dev_info& dinfo) {
        // Chunk bitmap area has bitmap of max_chunks rounded off to 4k page
        return sisl::round_up(bitset_serialized::nbytes(hs_super_blk::max_chunks_in_pdev(dinfo)), 4096));
}

@@ -220,8 +220,10 @@ void PhysicalDev::submit_batch() { m_drive_iface->submit_batch(); }

//////////////////////////// Chunk Creation/Load related methods /////////////////////////////////////////
void PhysicalDev::format_chunks() {
m_chunk_info_slots = std::make_unique< sisl::Bitset >(hs_super_blk::chunk_info_bitmap_size(m_dev_info));
m_chunk_info_slots = std::make_unique< sisl::Bitset >(std::max(1u, hs_super_blk::max_chunks_in_pdev(m_dev_info)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add alignment_size = 4096

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't understand the comment, why would I need to alignment_size here

Copy link
Contributor

@xiaoxichen xiaoxichen May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you specified alignment when initializing the bitset , and use same alignment configuration for serialize(), the serialize() is free, otherwise it is a copy.
c.f https://github.com/eBay/sisl/blob/03282536e309252d85319bebf4b227be0be6f9fe/include/sisl/fds/bitset.hpp#L647

Copy link
Contributor

@JacksonYao287 JacksonYao287 May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now , when we call max_chunks_in_pdev, we calculate the max_chunks_num using the following code.

(dinfo.dev_size - 1) / min_chunk_size + 1;

however , we have superblk and vdevinfo in the starting part of a pdev, which will also take some space of a pdev. so should we take into account this when calculating?

@@ -220,8 +220,10 @@ void PhysicalDev::submit_batch() { m_drive_iface->submit_batch(); }

//////////////////////////// Chunk Creation/Load related methods /////////////////////////////////////////
void PhysicalDev::format_chunks() {
m_chunk_info_slots = std::make_unique< sisl::Bitset >(hs_super_blk::chunk_info_bitmap_size(m_dev_info));
m_chunk_info_slots = std::make_unique< sisl::Bitset >(std::max(1u, hs_super_blk::max_chunks_in_pdev(m_dev_info)));
auto bitmap_mem = m_chunk_info_slots->serialize(m_pdev_info.dev_attr.align_size);
Copy link
Contributor

@xiaoxichen xiaoxichen May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m_chunk_info_slots->serialized_size(4096);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are asking the bitset library to serialize based on pdev align size. So I don't see anything wrong here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in chunk_info_bitmap_size we round up to 4K instead of pdev align size. see the example here #415 (comment) we might hit the assert.

auto bitmap_mem = m_chunk_info_slots->serialize(m_pdev_info.dev_attr.align_size);
HS_REL_ASSERT_LE(bitmap_mem->size(), hs_super_blk::chunk_info_bitmap_size(m_dev_info),
Copy link
Contributor

@xiaoxichen xiaoxichen May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe change chunk_info_bitmap_size to

static uint64_t chunk_info_bitmap_size(const dev_info& dinfo) {
        // Chunk bitmap area has bitmap of max_chunks rounded off to 4k page
        return sisl::round_up(bitset_serialized::nbytes(hs_super_blk::max_chunks_in_pdev(dinfo)), 4096));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants