Bug 740645 - md driver imposes an unconditional 1 second sleep in the shutdown path
md driver imposes an unconditional 1 second sleep in the shutdown path
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: kernel (Show other bugs)
15
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Kernel Maintainer List
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-09-22 15:56 EDT by Daniel Berrange
Modified: 2011-10-05 19:58 EDT (History)
5 users (show)

See Also:
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 19:58:42 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Simple attempt to skip the 1 second sleep if no MD devices exist (1.11 KB, patch)
2011-09-22 15:58 EDT, Daniel Berrange
no flags Details | Diff

  None (edit)
Description Daniel Berrange 2011-09-22 15:56:29 EDT
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 Berrange 2011-09-22 15:58:31 EDT
Created attachment 524464 [details]
Simple attempt to skip the 1 second sleep if no MD devices exist
Comment 2 Josh Boyer 2011-09-22 16:16:11 EDT
(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 Berrange 2011-09-23 06:17:53 EDT
Posted to LKML/linux-raid

http://marc.info/?l=linux-kernel&m=131677175617733&w=2
Comment 4 Josh Boyer 2011-09-23 09:25:34 EDT
(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 15:42:37 EDT
This was committed today.  It will be in the next F15 build.
Comment 6 Fedora Update System 2011-10-04 10:14:33 EDT
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-04 23:58:56 EDT
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 19:58:42 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.