Bug 2175540

Summary: Periodic mdcheck raid check service does not seem to work properly
Product: [Fedora] Fedora Reporter: Eric Sandeen <esandeen>
Component: mdadmAssignee: XiaoNi <xni>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: adstak, agk, dledford, ffan, jes.sorensen, jonathan, xni
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: mdadm-4.2-5.fc39 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-06-02 01:04:58 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Eric Sandeen 2023-03-05 17:36:40 UTC
There seem to be several problems with the periodic md raid check service (mdcheck_start.service and mdcheck_continue.service)

mdcheck_start.service contains:

ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh
ExecStart=/usr/share/mdadm/mdcheck --duration ${MDADM_CHECK_DURATION}

but neither of those files exists in the mdadm rpm.  (the mdcheck shell script is in /usr/share/doc/mdadm/mdcheck for some reason).

For large md raid, it can be nice to do partial/progressive checks for a shorter duration each night, rather than scheduling a full raid check once per week which can impact performace while it's running well into the day.

Would it be possible to fix up the package to make these services work properly?

Thanks!

Comment 1 XiaoNi 2023-04-07 22:53:13 UTC
The patch https://www.spinics.net/lists/raid/msg73068.html has sent to upstream to fix this problem

Comment 2 Adam Stackhouse 2023-04-11 12:08:15 UTC
Just to confirm as I can see the patch upstream has been applied here --> https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/commit/?id=76c224c6cfc8ff154bd041d30b9551faecd593c1

Will the issue with mdcheck script being in "/usr/share/doc/" and not "/usr/share/mdadm/" as per the unit file be addressed in the spec file when the rpm is updated with the patch upstream?

Comment 3 Jonathan Wright 2023-04-11 12:24:08 UTC
@xiaoni are you actively working on this?  If not I can.

Comment 4 XiaoNi 2023-04-11 13:53:38 UTC
@Jonathan, yes, I'm waiting for the patch mentioned in comment 1 to be merged. I have tried
with the patch and it can fix this problem. Do you think the patch is right to fix this bug?

Comment 5 XiaoNi 2023-04-11 14:00:17 UTC
(In reply to Adam Stackhouse from comment #2)
> Just to confirm as I can see the patch upstream has been applied here -->
> https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/commit/
> ?id=76c224c6cfc8ff154bd041d30b9551faecd593c1

Hi Aadm

Thanks. I'll back port this one.

> 
> Will the issue with mdcheck script being in "/usr/share/doc/" and not
> "/usr/share/mdadm/" as per the unit file be addressed in the spec file when
> the rpm is updated with the patch upstream?

You mean something like this?
diff --git a/systemd/mdcheck_continue.service b/systemd/mdcheck_continue.service
index f576e0167f3c..6145a9725c19 100644
--- a/systemd/mdcheck_continue.service
+++ b/systemd/mdcheck_continue.service
@@ -12,4 +12,4 @@ ConditionPathExistsGlob = /var/lib/mdcheck/MD_UUID_*
 [Service]
 Type=oneshot
 Environment="MDADM_CHECK_DURATION=6 hours"
-ExecStart=/usr/share/mdadm/mdcheck --continue --duration ${MDADM_CHECK_DURATION}
+ExecStart=/usr/share/doc/mdcheck --continue --duration ${MDADM_CHECK_DURATION}
diff --git a/systemd/mdcheck_start.service b/systemd/mdcheck_start.service
index f98e5c6f52d7..3c415a264501 100644
--- a/systemd/mdcheck_start.service
+++ b/systemd/mdcheck_start.service
@@ -12,4 +12,4 @@ Wants=mdcheck_continue.timer
 [Service]
 Type=oneshot
 Environment="MDADM_CHECK_DURATION=6 hours"
-ExecStart=/usr/share/mdadm/mdcheck --duration ${MDADM_CHECK_DURATION}
+ExecStart=/usr/share/doc/mdcheck --duration ${MDADM_CHECK_DURATION}

I don't know how to choose a right place to place mdcheck. Is there some doc that
describe it? I don't send a patch about this and it doesn't affect mdcheck. So
if it's a bug, it'll be fixed once it's fixed in upstream.

Thanks
Xiao

Comment 6 Adam Stackhouse 2023-04-11 14:32:37 UTC
@xni 

Hi, 

The location for mdcheck is coming from the the unit file provided by the rpm in the spec file --> https://gitlab.com/redhat/centos-stream/rpms/mdadm/-/blob/c9s/mdadm.spec The unit files in question are pulled from upstream here --> https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/tree/systemd and inside these the location of "/usr/share/mdadm/mdcheck" is decided.

Its weird as this was correct in the rhel8 spec file as you can see here --> https://gitlab.com/redhat/centos-stream/rpms/mdadm/-/blob/c8s/mdadm.spec

However it seems in the rhel8 version the mdcheck has its own Source in the spec so is specifically installed in the %install phase. 

Looking at the rhel9 version I can see the following line in the spec:

"%doc mdadm.conf-example misc/*"

When I look in the tarball upstream for mdadm I can see mdcheck is located in the misc/* dir here "./misc/mdcheck"

So I think its just a case of mdcheck being caught by this "misc/*" wildcard and placed in the docs dir by mistake. 

In terms of a suggested fix possibly having it as a Source its self and placing it like it was for rhel8 would be fine as it would then match the assumed location from upstream.

Trying to put as much info as possible in the comment to prevent too much back and fourth but if you need anything else just shout up :)

Comment 7 XiaoNi 2023-04-12 00:59:01 UTC
(In reply to Adam Stackhouse from comment #6)
> @xni 
> 
> Hi, 
> 
> The location for mdcheck is coming from the the unit file provided by the
> rpm in the spec file -->
> https://gitlab.com/redhat/centos-stream/rpms/mdadm/-/blob/c9s/mdadm.spec The
> unit files in question are pulled from upstream here -->
> https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/tree/systemd and inside
> these the location of "/usr/share/mdadm/mdcheck" is decided.
> 
> Its weird as this was correct in the rhel8 spec file as you can see here -->
> https://gitlab.com/redhat/centos-stream/rpms/mdadm/-/blob/c8s/mdadm.spec
> 
> However it seems in the rhel8 version the mdcheck has its own Source in the
> spec so is specifically installed in the %install phase. 
> 
> Looking at the rhel9 version I can see the following line in the spec:
> 
> "%doc mdadm.conf-example misc/*"
> 
> When I look in the tarball upstream for mdadm I can see mdcheck is located
> in the misc/* dir here "./misc/mdcheck"
> 
> So I think its just a case of mdcheck being caught by this "misc/*" wildcard
> and placed in the docs dir by mistake. 
> 
> In terms of a suggested fix possibly having it as a Source its self and
> placing it like it was for rhel8 would be fine as it would then match the
> assumed location from upstream.
> 
> Trying to put as much info as possible in the comment to prevent too much
> back and fourth but if you need anything else just shout up :)

Hi Adam

Thanks for this. I got it. I didn't notice the %doc part. For rhel9, mdcheck will be
placed into the right place as rhel8 does. And for fedora, mdcheck isn't in the right
place too. I'll fix it this time too.

Thanks
Xiao

Comment 8 XiaoNi 2023-04-12 13:59:10 UTC
Hi all

I've pushed the patch and build a new package. Beside fixing this problem, I also did a
backport from upstream.

Thanks
Xiao