-
Notifications
You must be signed in to change notification settings - Fork 14
Fix Partition Rounding, Alignment, and Erase Logic #23
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No improvements since #22.
- Each commit should be described properly in the commit message (and subject)
- Missing Signed-off-by tags
also: - Don't close PRs just to post a new iteration. Instead please push to the same branch in order to keep review visible to others
- Don't add stray merge commits. Please rebase/reshuffle your changes in order to get rid of it.
Please see go/OSSBestPractices for an overview on how to better produce commit messages. Everything is part of the patch subject, please change to have a simplified subject line and a proper commit body with the rest of the commit message. Also please explain better the justification for the changes, not just saying what you are changing. |
55b3325
to
1d3fb95
Compare
ok, I have modified it as requested, please see if there are any other issues. Thank you |
Some more comments:
|
ok. Thanks for the feedback. I've updated the Author line to match the Signed-off-by line (xiaomzh [email protected]) to resolve the DCO check failure. |
This is not your real name. Please adjust your git setup and then the author and tags accordingly.
Please use imperative language. I.e. 'Adjust foo, Fix bar, Provision baz' instead of descriptive ('This change makes foo being adjusted...'). |
Please let me know if there are any further adjustments needed. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR looks much better now.
ptool.py
Outdated
TempResult +=1 | ||
PhyPartition[k][j]['size_in_kb'] = (TempResult * SECTOR_SIZE_IN_BYTES)/1024 | ||
size_kb = float(PhyPartition[k][j]['size_in_kb']) | ||
size_bytes = math.ceil(size_kb * 1024) #Count the number of bytes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the extra whitespaces at the end of the line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed the extra whitespaces at the end of the lines. Thanks for the reminder!
ptool.py
Outdated
PhyPartition[k][j]['size_in_kb'] = (TempResult * SECTOR_SIZE_IN_BYTES)/1024 | ||
size_kb = float(PhyPartition[k][j]['size_in_kb']) | ||
size_bytes = math.ceil(size_kb * 1024) #Count the number of bytes | ||
sectors = math.ceil(size_bytes / SECTOR_SIZE_IN_BYTES) #Calculate the number of sectors rounded up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One whitespace at the end of this one as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
ptool.py
Outdated
sectors = math.ceil(size_bytes / SECTOR_SIZE_IN_BYTES) #Calculate the number of sectors rounded up | ||
PhyPartition[k][j]['size_in_kb'] = sectors * SECTOR_SIZE_IN_BYTES / 1024 | ||
|
||
##import pdb; pdb.set_trace() ## verifying sizes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commented import pdb won't be in the correct indentation after your changes, either remove (as a separated patch) or align the indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing that out! I've aligned the indentation of the commented import pdb line in the latest commit. Please let me know if there's anything else that needs adjustment.
Fix partition sector rounding to avoid decimal sector counts. Ensure partition memory size is rounded up to the next whole sector. Prevent insufficient space allocation due to fractional sector values. Signed-off-by: Xiaoming Zhao <[email protected]>
Remove incorrect condition checking ALIGN_PARTITIONS_TO_PERFORMANCE_BOUNDARY. Ensure partitions align correctly to required boundaries such as 4KB. Prevent logic errors caused by unnecessary alignment checks. Signed-off-by: Xiaoming Zhao <[email protected]>
Erase main GPT sectors dynamically based on sector size. Use 34 sectors for 512-byte sectors and 6 for 4096-byte sectors. Improve accuracy and compatibility with different storage configurations. Signed-off-by: Xiaoming Zhao <[email protected]>
Preserve decimal precision in partition size specification. Avoid truncating fractional values during memory allocation. Enable more accurate and efficient memory usage. Signed-off-by: Xiaoming Zhao <[email protected]>
Erase MBR sector dynamically based on actual sector size. Use 0.5KB for 512-byte sectors and 4KB for 4096-byte sectors. Improve compatibility across devices with varying sector sizes. Signed-off-by: Xiaoming Zhao <[email protected]>
Erase backup GPT sectors dynamically based on sector size. Use 33 sectors for 512-byte and 5 for 4096-byte configurations. Ensure accurate and adaptable erase operations. Signed-off-by: Xiaoming Zhao <[email protected]>
Fix MBR sector occupancy calculation to reflect dynamic sector sizes. Ensure MBR occupies one sector: 0.5KB or 4KB depending on configuration. Match actual device layout for correctness. Signed-off-by: Xiaoming Zhao <[email protected]>
Fix undefined variable reference in Partition hash instructions. Replace incorrect variable with valid HashInstructions key. Prevent runtime errors and improve reliability. Signed-off-by: Xiaoming Zhao <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the clean up. Pretty nice, especially given how un-readable this piece of code is :)
ptool advice:Fix Partition Rounding, Alignment, and Erase Logic