Bug 740645

Summary: md driver imposes an unconditional 1 second sleep in the shutdown path
Product: [Fedora] Fedora Reporter: Daniel Berrangé <berrange>
Component: kernelAssignee: Kernel Maintainer List <kernel-maint>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 15CC: gansalmon, itamar, jonathan, kernel-maint, madhu.chinakonda
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: kernel-2.6.40.6-0.fc15 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-10-05 23:58:42 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Simple attempt to skip the 1 second sleep if no MD devices exist none

Description Daniel Berrangé 2011-09-22 19:56:29 UTC
Description of problem:
Looking at the kernel printk output on shutdown of the kernel running in one of my virtual machines, I see a consistent 1 second delay after 'md: stopping all md devices' message is printed:

[    1.393524] md: stopping all md devices.
[    2.396385] ACPI: Preparing to enter system sleep state S5
[    2.397101] Disabling non-boot CPUs ...
[    2.397101] Power down.
[    2.397101] acpi_power_off called


Looking at the code in drivers/md/md.c, confirms there is an unconditional sleep in the shutdown path:


static int md_notify_reboot(struct notifier_block *this,
                            unsigned long code, void *x)
{
        struct list_head *tmp;
        mddev_t *mddev;

        if ((code == SYS_DOWN) || (code == SYS_HALT) || (code == SYS_POWER_OFF)) {

                printk(KERN_INFO "md: stopping all md devices.\n");

                for_each_mddev(mddev, tmp)
                        if (mddev_trylock(mddev)) {
                                /* Force a switch to readonly even array
                                 * appears to still be in use.  Hence
                                 * the '100'.
                                 */
                                md_set_readonly(mddev, 100);
                                mddev_unlock(mddev);
                        }
                /*
                 * certain more exotic SCSI devices are known to be
                 * volatile wrt too early system reboots. While the
                 * right place to handle this issue is the given
                 * driver, we do want to have a safe RAID driver ...
                 */
                mdelay(1000*1);
        }
        return NOTIFY_DONE;
}


I don't know whether the comment about exotic SCSI devices is still relevant, but at the very least this delay should be made conditional on the existence of any MD devices.

My virtual machine has no block devices, booting directly off a virtio 9p filesystem. From initial boot, through running the application, to shutting down, my virtual machine only runs for 1.9 seconds. 

In other words, this delay imposed by the MD driver is accounting for > 50% of my wallclock time, despite not having any MD devices in the guest.

Version-Release number of selected component (if applicable):
2.6.40.4-5.fc15.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Provision a (virtual) machine, which does *not* setup any MD devices.
1. Boot the (virtual) machine, ensuring the kernel log level is sufficient to show all printk lines
2. Shutdown the machine, watching the printk messages
3.
  
Actual results:
A 1 second delay occurs at the time this is printed:

[    1.393524] md: stopping all md devices.

Expected results:
There is no delay by the MD driver

Additional info:

Comment 1 Daniel Berrangé 2011-09-22 19:58:31 UTC
Created attachment 524464 [details]
Simple attempt to skip the 1 second sleep if no MD devices exist

Comment 2 Josh Boyer 2011-09-22 20:16:11 UTC
(In reply to comment #1)
> Created attachment 524464 [details]
> Simple attempt to skip the 1 second sleep if no MD devices exist

Can you send that upstream?

Comment 3 Daniel Berrangé 2011-09-23 10:17:53 UTC
Posted to LKML/linux-raid

http://marc.info/?l=linux-kernel&m=131677175617733&w=2

Comment 4 Josh Boyer 2011-09-23 13:25:34 UTC
(In reply to comment #3)
> Posted to LKML/linux-raid
> 
> http://marc.info/?l=linux-kernel&m=131677175617733&w=2

Excellent.  Looks like it is queued already as well.  I'll bring this in later today.

Comment 5 Josh Boyer 2011-09-23 19:42:37 UTC
This was committed today.  It will be in the next F15 build.

Comment 6 Fedora Update System 2011-10-04 14:14:33 UTC
kernel-2.6.40.6-0.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/kernel-2.6.40.6-0.fc15

Comment 7 Fedora Update System 2011-10-05 03:58:56 UTC
Package kernel-2.6.40.6-0.fc15:
* should fix your issue,
* was pushed to the Fedora 15 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing kernel-2.6.40.6-0.fc15'
as soon as you are able to, then reboot.
Please go to the following url:
https://admin.fedoraproject.org/updates/kernel-2.6.40.6-0.fc15
then log in and leave karma (feedback).

Comment 8 Fedora Update System 2011-10-05 23:58:42 UTC
kernel-2.6.40.6-0.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.