Using a file-backed swap via md0 results in panic on reboot.. - FreeBSD

This is a discussion on Using a file-backed swap via md0 results in panic on reboot.. - FreeBSD ; So if you attach an md device to a file and then use that md0 device for swap, you will get a panic on shutdown if the swap file was in use. The reason is that we remove swap devices ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Using a file-backed swap via md0 results in panic on reboot..

  1. Using a file-backed swap via md0 results in panic on reboot..

    So if you attach an md device to a file and then use that md0 device for swap,
    you will get a panic on shutdown if the swap file was in use. The reason is
    that we remove swap devices _after_ unmounting the filesystems in boot():

    if (nbusy) {
    /*
    * Failed to sync all blocks. Indicate this and don't
    * unmount filesystems (thus forcing an fsck on reboot).
    */
    printf("Giving up on %d buffers\n", nbusy);
    DELAY(5000000); /* 5 seconds */
    } else {
    if (!first_buf_printf)
    printf("Final sync complete\n");
    /*
    * Unmount filesystems
    */
    if (panicstr == 0)
    vfs_unmountall();
    }
    swapoff_all();
    DELAY(100000); /* wait for console output to finish */

    Is there any reason we can't move the swapoff_all()? Should we perhaps only
    do it in "clean" case? Alternatively, should the swapoff_all() during
    shutdown have a special flag so that it doesn't actually read in any data
    from disk and just throws away the data instead? Sample panic:

    Waiting (max 60 seconds) for system process `vnlru' to stop...done
    Waiting (max 60 seconds) for system process `syncer' to stop...
    Syncing disks, vnodes remaining...2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0
    0 0 done
    Waiting (max 60 seconds) for system process `bufdaemon' to stop...done
    All buffers synced.
    Swap device ad0s1b removed.
    swap_pager: I/O error - pagein failed; blkno 2097177,size 4096, error 5
    panic: swap_pager_force_pagein: read from swap failed
    cpuid = 0
    KDB: stack backtrace:
    panic() at panic+0x2c5
    swapoff_one() at swapoff_one+0x5bb
    swapoff_all() at swapoff_all+0xe4
    boot() at boot+0x871
    reboot() at reboot+0x45
    syscall() at syscall+0x642
    Xfast_syscall() at Xfast_syscall+0xa8

    --
    John Baldwin
    _______________________________________________
    freebsd-arch@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-arch
    To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"


  2. Re: Using a file-backed swap via md0 results in panic on reboot..

    On Tue, Sep 23, 2008 at 03:09:40PM -0400, John Baldwin wrote:
    > So if you attach an md device to a file and then use that md0 device for swap,
    > you will get a panic on shutdown if the swap file was in use. The reasonis
    > that we remove swap devices _after_ unmounting the filesystems in boot():
    >
    > if (nbusy) {
    > /*
    > * Failed to sync all blocks. Indicate this and don't
    > * unmount filesystems (thus forcing an fsck on reboot).
    > */
    > printf("Giving up on %d buffers\n", nbusy);
    > DELAY(5000000); /* 5 seconds */
    > } else {
    > if (!first_buf_printf)
    > printf("Final sync complete\n");
    > /*
    > * Unmount filesystems
    > */
    > if (panicstr == 0)
    > vfs_unmountall();
    > }
    > swapoff_all();
    > DELAY(100000); /* wait for console output to finish */
    >
    > Is there any reason we can't move the swapoff_all()? Should we perhaps only
    > do it in "clean" case? Alternatively, should the swapoff_all() during
    > shutdown have a special flag so that it doesn't actually read in any data
    > from disk and just throws away the data instead? Sample panic:
    >
    > Waiting (max 60 seconds) for system process `vnlru' to stop...done
    > Waiting (max 60 seconds) for system process `syncer' to stop...
    > Syncing disks, vnodes remaining...2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 0 0 0 0 00 0
    > 0 0 done
    > Waiting (max 60 seconds) for system process `bufdaemon' to stop...done
    > All buffers synced.
    > Swap device ad0s1b removed.
    > swap_pager: I/O error - pagein failed; blkno 2097177,size 4096, error 5
    > panic: swap_pager_force_pagein: read from swap failed
    > cpuid = 0
    > KDB: stack backtrace:
    > panic() at panic+0x2c5
    > swapoff_one() at swapoff_one+0x5bb
    > swapoff_all() at swapoff_all+0xe4
    > boot() at boot+0x871
    > reboot() at reboot+0x45
    > syscall() at syscall+0x642
    > Xfast_syscall() at Xfast_syscall+0xa8


    The problem is this: sometimes we want to first unmount file systems and
    sometimes we want to first remove swap devices.

    In your case you have swap device residing on a file system. Imagine the
    opposite situation where you have a file system residing on swap device:

    mdconfig -t swap; newfs /dev/mdX; mount /dev/mdX

    The solution I have been thinking about is to call vfs_unmountall() and
    swapoff_all() in a loop and changed them to return number of file system
    unmounted or swap devices removed respectively:

    do {
    i = vfs_unmountall();
    j = swapoff_all();
    } while (i > 0 || j > 0);

    Something like that would cover both situations and even more complex
    (although not very realistic) situations: FS on SWAP on FS on SWAP, etc.

    Of course vfs_unmountall() and swapoff_all() would have to skip busy
    file systems/swap devices.

    --
    Pawel Jakub Dawidek http://www.wheel.pl
    pjd@FreeBSD.org http://www.FreeBSD.org
    FreeBSD committer Am I Evil? Yes, I Am!

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v2.0.4 (FreeBSD)

    iD8DBQFI2Uc2ForvXbEpPzQRAj8BAJ4tL3155Jc0ntg6LCwo+1 VA5qTYggCgiD7c
    G8rWVF2s6cBzG9k60x+tAOY=
    =IuRy
    -----END PGP SIGNATURE-----


  3. Re: Using a file-backed swap via md0 results in panic on reboot..

    John Baldwin wrote:
    > So if you attach an md device to a file and then use that md0 device for swap,
    > you will get a panic on shutdown if the swap file was in use. The reason is
    > that we remove swap devices _after_ unmounting the filesystems in boot():
    >
    > if (nbusy) {
    > /*
    > * Failed to sync all blocks. Indicate this and don't
    > * unmount filesystems (thus forcing an fsck on reboot).
    > */
    > printf("Giving up on %d buffers\n", nbusy);
    > DELAY(5000000); /* 5 seconds */
    > } else {
    > if (!first_buf_printf)
    > printf("Final sync complete\n");
    > /*
    > * Unmount filesystems
    > */
    > if (panicstr == 0)
    > vfs_unmountall();
    > }
    > swapoff_all();
    > DELAY(100000); /* wait for console output to finish */
    >
    > Is there any reason we can't move the swapoff_all()? Should we perhaps only
    > do it in "clean" case? Alternatively, should the swapoff_all() during
    > shutdown have a special flag so that it doesn't actually read in any data
    > from disk and just throws away the data instead? Sample panic:


    then what happens with a swap based filesystem?

    >
    > Waiting (max 60 seconds) for system process `vnlru' to stop...done
    > Waiting (max 60 seconds) for system process `syncer' to stop...
    > Syncing disks, vnodes remaining...2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0
    > 0 0 done
    > Waiting (max 60 seconds) for system process `bufdaemon' to stop...done
    > All buffers synced.
    > Swap device ad0s1b removed.
    > swap_pager: I/O error - pagein failed; blkno 2097177,size 4096, error 5
    > panic: swap_pager_force_pagein: read from swap failed
    > cpuid = 0
    > KDB: stack backtrace:
    > panic() at panic+0x2c5
    > swapoff_one() at swapoff_one+0x5bb
    > swapoff_all() at swapoff_all+0xe4
    > boot() at boot+0x871
    > reboot() at reboot+0x45
    > syscall() at syscall+0x642
    > Xfast_syscall() at Xfast_syscall+0xa8
    >


    _______________________________________________
    freebsd-arch@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-arch
    To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"


+ Reply to Thread