-
Notifications
You must be signed in to change notification settings - Fork 14
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
super-ddf: optimize DDF header search for widely used RAID controllers #136
base: main
Are you sure you want to change the base?
Conversation
HI @slayercat |
super-ddf.c
Outdated
const size_t READ_BLOCK_SIZE = 4096; | ||
const unsigned long long SEARCH_REGION_SIZE = 32 * 1024 * 1024; | ||
|
||
// Determine the search range |
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.
For comments, you should use one of:
/*Body*/
/*
* Body
*/
@slayercat |
527767d
to
441074a
Compare
Thank you for pointing out the issues with the code style. I have reviewed and modified the submitted code snippets. |
Kernel style is not only about the code style. You should also follow commit rules, described here: I think that the description is good but you should divide it into 2 patches. Please do not use markup in commit body, you can keep it in PR description because I'm always cherry-picking commits and PR description is irrelevant. Sorry, for that! I'm not trying to be nitpicker. As long as mailing list contribution is welcomed we trying to keep similar level of commits quality! If you are interested, You can explore list online archive to find see comments from kernel folks on mdadm patches (you can search by "mdadm"): I hope, this exercise will be useful for you to be better prepared for linux kernel contributions :) |
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.
Hello,
I did a quick code review. Please see my comments.
Thanks,
Mariusz
super-ddf.c
Outdated
* A dummy update_super function is needed | ||
* to enable the mounting feature. | ||
*/ | ||
pr_err("%s: not implemented\n", __func__); |
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.
printing error each time is pointless. Please convert this to debug message dprintf
or remove it.
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.
Thank you for addressing that. I have converted this to use dprintf.
super-ddf.c
Outdated
int uuid_set, char *homehost) | ||
{ | ||
/* | ||
* A dummy update_super function is needed |
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.
What I see is mdadm assumes that this function exists for each metadata handler.
This is not about mounting at all but about making mdadm to work reliable with DDF.
It would be nice if you can put a crash (I assume it is crashing) in the commit message.
I would rephrase it:
A dummy function is defined because availability of ss->update_super is not always verified.
I don't see any clear reference to mounting in this context.
Mounting is handler by kernel when mdadm handles assemblation (preparing of the raid device to be mounted on demand later).
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.
Thank you for addressing that. I have added the reason in the commit message and found a related discussion about this in the maillist.
commit e3d493d7046cc07b4eca95a2cc24cc59e0ee3b34
Author: lilinzhe <[email protected]>
Date: Mon Dec 16 12:00:02 2024 +0800
super-ddf: Prevent crash when handling DDF metadata
A dummy function is defined because availability of ss->update_super is
not always verified.
This fix addresses a crash reported when assembling a RAID array using
mdadm with DDF metadata. For more details, see the discussion at:
https://lore.kernel.org/all/
CALHdMH30LuxR4tz9jP2ykDaDJtZ3P7L3LrZ+9e4Fq=Q6NwSM=Q@mail.gmail.com/
The discussion centers on an issue with mdadm where attempting to
assemble a RAID array caused a null pointer dereference. The problem
was traced to a missing update_super() function in super-ddf.c, which
led to a crash in Assemble.c.
Signed-off-by: lilinzhe <[email protected]>
super-ddf.c
Outdated
@@ -877,30 +877,170 @@ static void *load_section(int fd, struct ddf_super *super, void *buf, | |||
return buf; | |||
} | |||
|
|||
static int load_ddf_headers(int fd, struct ddf_super *super, char *devname) | |||
|
|||
/* Search for DDF_HEADER_MAGIC in the last 32MB of the device */ |
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 copy part of the commit message here, I would like to have clarification why we are not following spec as a comment to. blame is volatile.
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.
Thank you for addressing that. I have added the reason to the comments at the beginning of search_for_ddf_headers.
/*
* Search for DDF_HEADER_MAGIC in the last 32MB of the device
*
* According to the specification, the Anchor Header should be placed at
* the end of the disk. However,some widely used RAID hardware, such as
* LSI and PERC, do not position it within the last 512 bytes of the disk.
*
*/
static int search_for_ddf_headers(int fd, char *devname,
unsigned long long *out)
A dummy function is defined because availability of ss->update_super is not always verified. This fix addresses a crash reported when assembling a RAID array using mdadm with DDF metadata. For more details, see the discussion at: https://lore.kernel.org/all/ CALHdMH30LuxR4tz9jP2ykDaDJtZ3P7L3LrZ+9e4Fq=Q6NwSM=Q@mail.gmail.com/ The discussion centers on an issue with mdadm where attempting to assemble a RAID array caused a null pointer dereference. The problem was traced to a missing update_super() function in super-ddf.c, which led to a crash in Assemble.c. Signed-off-by: lilinzhe <[email protected]>
Thank you very much for your prompt response and detailed guidance. I have addressed your comments and corrected the submission accordingly. If there is anything I may have misunderstood or any other areas that need further adjustments, please let me know. Additionally, I performed a local CI check, focusing on the unit tests that previously failed in the CI server. Strangely, the tests that failed on the server did not fail locally. However, some tests failed locally, such as I have attached the output of /var/tmp/07revert-inplace.log for your reference.
|
Implemented fallback logic to search the last 32MB of the device for the DDF header (magic). If found, proceeds to load the DDF metadata from the located position. According to the specification, the Anchor Header should be placed at the end of the disk. However,some widely used RAID hardware, such as LSI and PERC, do not position it within the last 512 bytes of the disk. Signed-off-by: lilinzhe <[email protected]>
Thanks @slayercat, |
Take care~ I hope you feel better soon! Wishing you a joyful Christmas season filled with warmth and happiness. Rest up and take your time. Looking forward to catching up after the holidays. |
Added logic to check the last 512 bytes of the device (
dsize - 512
) firstfor the presence of the DDF header (
DDF_HEADER_MAGIC
).Fallback to searching the last 32MB of the device
using the
search_for_ddf_headers
function when the last 512 bytes do not contain the header.see also: #135