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

Vibhansa/truncate update #1517

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

Vibhansa/truncate update #1517

wants to merge 19 commits into from

Conversation

vibhansa-msft
Copy link
Member

No description provided.

}
return data, err

return bb.createSparseFile(name, newSize, blockSize, blkList, idLen)
Copy link
Member

Choose a reason for hiding this comment

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

If file size is not aligning with the block size and truncate is used to expand the size, this will lead to irregular blocksizes in the block list.
Eg: lets say blocksize = 4M
file size = 5M (i.e., 2blocks) block1 = 4M, block2 = 1M

Call for truncate(10M)

I suppose the logic in this PR will make the block list look like this after truncate operation:
block1 = 4M, block2 = 1M, block3 = 4M, block4 = 1M.
Although this looks correct but the subsequent operations in block cache cannot utilize this sort of blocklist.
Please correct me if I am wrong

return data, err
}

func (bb *BlockBlob) createSparseFile(name string, size int64, blockSize int64, blkList []string, idLen int64) error {
Copy link
Member

@syeleti-msft syeleti-msft Nov 11, 2024

Choose a reason for hiding this comment

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

It is better to have 2 functions originating from truncate function which are

  1. Expand
  2. Shrink

This will make the code more readable imo.

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

Successfully merging this pull request may close these issues.

4 participants