kern/140461: Fail to read from swap. The swap_pager.c contains incomplete routine as stated in its comments

Alekseev Sergey varnie29a at mail.ru
Tue Nov 10 23:20:03 UTC 2009


>Number:         140461
>Category:       kern
>Synopsis:       Fail to read from swap. The swap_pager.c contains incomplete routine as stated in its comments
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Nov 10 23:20:02 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Alekseev Sergey
>Release:        FreeBSD 7.2-RELEASE-p4
>Organization:
>Environment:
FreeBSD varnie.my.domain 7.2-RELEASE-p4 FreeBSD 7.2-RELEASE-p4 #0: Sat Oct 10 04:13:17 YEKST 2009     varnie at varnie.my.domain:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
Few days ago i've added an additional swap on the partition (500MB) using the instructions (http://www.freebsd.org/doc/en/books/handbook/adding-swap-space.html). When i tried to shutdown i got the panic error:
"savecore: reboot after panic: swap_pager_force_pagein: read from swap failed
savecore: writing core to vmcore.2"
and the FreeBSD box rebooted producing vmcore dump.

During my researches i've found that the /usr/src/sys/vm/swap_pager.c contains *unfinished* function named "swp_pager_force_pagein". it is pretty clear it is incomplete from its comments. here it is:
//////
/*
 * SWP_PAGER_FORCE_PAGEIN() - force a swap block to be paged in
 *
 *	This routine dissociates the page at the given index within a
 *	swap block from its backing store, paging it in if necessary.
 *	If the page is paged in, it is placed in the inactive queue,
 *	since it had its backing store ripped out from under it.
 *	We also attempt to swap in all other pages in the swap block,
 *	we only guarantee that the one at the specified index is
 *	paged in.
 *
 *	XXX - The code to page the whole block in doesn't work, so we
 *	      revert to the one-by-one behavior for now.  Sigh.
 */
static inline void
swp_pager_force_pagein(vm_object_t object, vm_pindex_t pindex)
{
	vm_page_t m;

	vm_object_pip_add(object, 1);
	m = vm_page_grab(object, pindex, VM_ALLOC_NORMAL|VM_ALLOC_RETRY);
	if (m->valid == VM_PAGE_BITS_ALL) {
		vm_object_pip_subtract(object, 1);
		vm_page_lock_queues();
		vm_page_activate(m);
		vm_page_dirty(m);
		vm_page_unlock_queues();
		vm_page_wakeup(m);
		vm_pager_page_unswapped(m);
		return;
	}

	if (swap_pager_getpages(object, &m, 1, 0) != VM_PAGER_OK)
		panic("swap_pager_force_pagein: read from swap failed");/*XXX*/
	vm_object_pip_subtract(object, 1);
	vm_page_lock_queues();
	vm_page_dirty(m);
	vm_page_dontneed(m);
	vm_page_unlock_queues();
	vm_page_wakeup(m);
	vm_pager_page_unswapped(m);
}
//////

The programmer marked an unfinished piece of code with "/*XXX*/" and commented that "The code to page the whole block in doesn't work, so we revert to the one-by-one behavior for now.  Sigh."

I think it has to be finished/updated. Thank you for your efforts.

ps: by the way, my hard-drive is healthy and contains no bad-blocks. i've checked it with several utils.
>How-To-Repeat:
add big enough additional swap in partition and try to shutdown the FreeBSD box properly.
>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list